Skip to content

Commit

Permalink
更好的选择overlay的交互
Browse files Browse the repository at this point in the history
  • Loading branch information
boybook committed Dec 29, 2024
1 parent 4651c6f commit c4651c2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 13 deletions.
Binary file added public/overlay-preview/glass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/overlay-preview/highlight-bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/overlay-preview/highlight-top-bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/overlay-preview/highlight-top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/overlay-preview/inner-stroke.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/overlay-preview/shine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/components/Text3D.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const Text3D = forwardRef<THREE.Group, Text3DProps>(({
const grp = new THREE.Group();
grp.add(mainMesh);
// overlayMesh,用于实现overlay的材质
if (opts.overlay) {
if (content.length > 0 && opts.overlay) {
const overlayMesh = mainMesh.clone();
overlayMesh.geometry = mainMesh.geometry.clone();
if (overlayMaterial) overlayMesh.material = overlayMaterial;
Expand All @@ -162,7 +162,7 @@ const Text3D = forwardRef<THREE.Group, Text3DProps>(({
grp.position.set(...position);
grp.rotation.set(...rotation);
return grp;
}, [mainMesh, opts.overlay, outlineMesh, overlayMaterial, position, rotation]);
}, [content.length, mainMesh, opts.overlay, outlineMesh, overlayMaterial, position, rotation]);

return <>
<primitive object={group} ref={ref} />
Expand Down
16 changes: 13 additions & 3 deletions src/components/TextSettingsOverlayPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,33 @@ const TextSettingsOverlayPanel: React.FC<TextSettingsOverlayPanelProps> = (props

return (
<Card size={'small'}>
<Flex gap={'small'} vertical>
<Flex gap={'small'} wrap>
<Button
block
type={overlay === undefined ? 'primary' : undefined}
ghost={overlay === undefined}
style={{
height: 'auto'
}}
onClick={() => setOverlay(undefined)}
>
{gLang('overlay.none')}
</Button>
{builtinOverlayRenderers.map((info) => (
<Button
block
type={overlay && overlay.name === info.name ? 'primary' : undefined}
ghost={overlay && overlay.name === info.name}
onClick={() => setOverlay(info)}
style={{
height: 'auto',
minWidth: '120px',
flex: '1 1 auto'
}}
>
{gLang(info.name)}
<Flex gap={'small'} vertical>
<img src={info.preview} alt={info.name} height={32} width="auto" style={{ marginTop: 8, marginBottom: 0 }} />
{gLang(info.name)}
</Flex>
</Button>
))}
</Flex>
Expand Down
1 change: 1 addition & 0 deletions src/components/ThreeCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const ThreeCanvas = forwardRef<ThreeCanvasHandle, ThreeCanvasProps>((props, ref)
resetCamera: () => {
orbitRef.current?.reset();
camera.position.set(0, -20, 50);
//camera.position.set(0, 0, 50);
camera.lookAt(0, 0, 0);
camera.updateProjectionMatrix();
},
Expand Down
12 changes: 6 additions & 6 deletions src/language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export const languageConfig: Readonly<LanguageConfig> = {
overlay: {
title: "叠加效果",
none: "无",
highlightButtom: "底部高亮",
highlightBottom: "底部高亮",
highlightTop: "顶部高亮",
highlightTopButtom: "上下高亮",
highlightTopBottom: "上下高亮",
highlightInnerStroke: "内描边",
highlightShine: "光泽",
highlightGlass: "玻璃(温和)"
Expand Down Expand Up @@ -182,9 +182,9 @@ export const languageConfig: Readonly<LanguageConfig> = {
overlay: {
title: "Overlay Effect",
none: "None",
highlightButtom: "Highlight Buttom",
highlightBottom: "Highlight Buttom",
highlightTop: "Highlight Top",
highlightTopButtom: "Highlight Top Buttom",
highlightTopBottom: "Highlight Top Buttom",
highlightInnerStroke: "Inner Stroke",
highlightShine: "Shine",
highlightGlass: "Glass (Tempered)"
Expand Down Expand Up @@ -270,9 +270,9 @@ export const languageConfig: Readonly<LanguageConfig> = {
overlay: {
title: "オーバーレイ効果",
none: "なし",
highlightButtom: "下部ハイライト",
highlightBottom: "下部ハイライト",
highlightTop: "上部ハイライト",
highlightTopButtom: "上部下部ハイライト",
highlightTopBottom: "上部下部ハイライト",
highlightInnerStroke: "内部ストローク",
highlightShine: "輝き",
highlightGlass: "ガラス(強化)"
Expand Down
11 changes: 9 additions & 2 deletions src/utils/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,39 @@ export const overlayRendererShine: OverlayRenderer = (ctx, _, width, height) =>
export interface OverlayRendererInfo {
name: string;
renderer: OverlayRenderer;
preview: string;
};

export const builtinOverlayRenderers: OverlayRendererInfo[] = [
{
name: "overlay.highlightTop",
renderer: overlayRendererHighlightUp,
preview: "/overlay-preview/highlight-top.png",
},
{
name: "overlay.highlightButtom",
name: "overlay.highlightBottom",
renderer: overlayRendererHighlightDown,
preview: "/overlay-preview/highlight-bottom.png",
},
{
name: "overlay.highlightTopButtom",
name: "overlay.highlightTopBottom",
renderer: overlayRendererHighlightUpDown,
preview: "/overlay-preview/highlight-top-bottom.png",
},
{
name: "overlay.highlightInnerStroke",
renderer: overlayRendererInnerStroke,
preview: "/overlay-preview/inner-stroke.png",
},
{
name: "overlay.highlightShine",
renderer: overlayRendererShine,
preview: "/overlay-preview/shine.png",
},
{
name: "overlay.highlightGlass",
renderer: overlayRendererGlass,
preview: "/overlay-preview/glass.png",
}
];

Expand Down

0 comments on commit c4651c2

Please sign in to comment.