cozyclay 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -24
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/bin/cozyclay.mjs +105 -11
- package/dist/CNAME +1 -0
- package/dist/app/index.html +57 -0
- package/dist/assets/app-Cgpk2hwX.js +4803 -0
- package/dist/assets/app-DgZvaAE1.css +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/icons/apple-touch-icon.png +0 -0
- package/dist/icons/icon-192.png +0 -0
- package/dist/icons/icon-32.png +0 -0
- package/dist/icons/icon-512.png +0 -0
- package/dist/icons/icon-maskable-512.png +0 -0
- package/dist/index.html +406 -5
- package/dist/manifest.webmanifest +42 -0
- package/dist/media/cozyclay-demo-poster.jpg +0 -0
- package/dist/media/cozyclay-logo.png +0 -0
- package/dist/robots.txt +4 -0
- package/dist/sitemap.xml +9 -0
- package/dist/sw.js +127 -0
- package/package.json +15 -3
- package/src/App.jsx +1393 -648
- package/src/ardy/client.js +5 -4
- package/src/ardy/mp4-duration.js +102 -0
- package/src/ardy/timeline-coordinates.js +11 -0
- package/src/ardy/timeline.jsx +528 -67
- package/src/ardy/waypoints.js +14 -9
- package/src/camera-block.js +60 -0
- package/src/camera-follow.js +49 -10
- package/src/camera-rail-schedule.js +176 -0
- package/src/controls.jsx +16 -2
- package/src/cuts.js +184 -0
- package/src/generation/client.js +56 -0
- package/src/generation/session.js +47 -0
- package/src/generation/shot-spec.js +40 -0
- package/src/generation/use-generation.js +55 -0
- package/src/hierarchy-model.js +9 -17
- package/src/hierarchy-panel.jsx +170 -23
- package/src/locale-toggle.jsx +18 -0
- package/src/locale.js +34 -0
- package/src/main.jsx +5 -0
- package/src/object-catalog.jsx +32 -3
- package/src/planview.jsx +174 -66
- package/src/pose-extract/browser.js +42 -0
- package/src/pose-extract/fit.js +194 -0
- package/src/pose-extract/index.js +53 -0
- package/src/pose-extract/keyframes.js +74 -0
- package/src/pose-extract/landmarks.js +162 -0
- package/src/poses.js +114 -0
- package/src/posestudio.jsx +75 -13
- package/src/pwa.js +42 -0
- package/src/result-modal.jsx +124 -0
- package/src/scenes.js +223 -0
- package/src/shot-authoring.js +204 -77
- package/src/shot.js +8 -4
- package/src/styles.css +839 -38
- package/src/ui.jsx +54 -5
- package/tools/ardy/BRIDGE.md +70 -4
- package/tools/ardy/README.md +55 -0
- package/tools/ardy/bridge.mjs +89 -389
- package/tools/ardy/cclay_constrained_generate.py +449 -0
- package/tools/ardy/cclay_motion_edit.py +74 -9
- package/tools/ardy/cclay_sequence_generate.py +68 -7
- package/tools/ardy/cclay_worker.py +304 -0
- package/tools/ardy/merge-text-encoder.py +160 -0
- package/tools/ardy/run-local.mjs +233 -0
- package/tools/ardy/runners/index.mjs +23 -0
- package/tools/ardy/runners/local.mjs +452 -0
- package/tools/ardy/runners/proc.mjs +125 -0
- package/tools/ardy/runners/remote.mjs +246 -0
- package/tools/ardy/setup-local.mjs +189 -0
- package/tools/ardy/setup-text-encoder-on-box.sh +93 -0
- package/tools/ardy/setup-text-encoder.py +296 -0
- package/tools/generation/README.md +29 -0
- package/tools/generation/bridge.mjs +149 -0
- package/tools/generation/job-store.mjs +51 -0
- package/tools/generation/providers/kling.mjs +76 -0
- package/tools/generation/providers/runway.mjs +101 -0
- package/tools/generation/providers/seedance.mjs +87 -0
- package/tools/generation/providers/shared.mjs +49 -0
- package/tools/generation/providers/veo.mjs +84 -0
- package/tools/metrics/archive-traffic.mjs +138 -0
- package/dist/assets/index-BW_S1YRy.js +0 -4395
- package/dist/assets/index-nRmmJgap.css +0 -1
- package/tools/ardy/__pycache__/cclay_sequence_generate.cpython-313.pyc +0 -0
- package/tools/ardy/out/gen-1786443326924-c6019e-generated.npz +0 -0
- package/tools/ardy/out/gen-1786443609325-0053db-generated.npz +0 -0
- package/tools/ardy/out/gen-1786443835628-749ed1-generated.npz +0 -0
- package/tools/ardy/out/gen-1786462605247-03cb19-generated.npz +0 -0
- package/tools/qa-browser.mjs +0 -84
- package/tools/qa-crop3.mjs +0 -22
- package/tools/qa-playview.mjs +0 -49
- package/tools/qa-screenshot.mjs +0 -24
- package/tools/qa-visual.mjs +0 -51
package/src/hierarchy-panel.jsx
CHANGED
|
@@ -1,7 +1,137 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { ko, isKo } from "./locale.js";
|
|
2
3
|
import { buildHierarchyNodes } from "./hierarchy-model.js";
|
|
3
4
|
import { sceneObjectIdFromHierarchy } from "./scene-objects.js";
|
|
4
|
-
import AddObjectMenu, { CatalogueEntries } from "./object-catalog.jsx";
|
|
5
|
+
import AddObjectMenu, { CatalogueEntries, displayObjectLabel } from "./object-catalog.jsx";
|
|
6
|
+
|
|
7
|
+
const HIERARCHY_LABELS_KO = {
|
|
8
|
+
"SCENE 01": "장면 01",
|
|
9
|
+
Camera: "카메라",
|
|
10
|
+
Characters: "캐릭터",
|
|
11
|
+
"Character 1": "캐릭터 1",
|
|
12
|
+
"Character 2": "캐릭터 2",
|
|
13
|
+
Rig: "리그",
|
|
14
|
+
"Root / Hips": "루트 / 골반",
|
|
15
|
+
Spine: "척추",
|
|
16
|
+
"Left Arm": "왼팔",
|
|
17
|
+
"Right Arm": "오른팔",
|
|
18
|
+
"Left Leg": "왼다리",
|
|
19
|
+
"Right Leg": "오른다리",
|
|
20
|
+
Environment: "환경",
|
|
21
|
+
Props: "소품",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const FALLBACK_SCENES = [{ id: "current-scene", name: "SCENE 01" }];
|
|
25
|
+
|
|
26
|
+
function displaySceneName(name) {
|
|
27
|
+
if (!isKo) return name;
|
|
28
|
+
const generatedName = /^SCENE\s+(\d+)$/i.exec(name);
|
|
29
|
+
return generatedName ? ko(`Scene ${generatedName[1]}`, `장면 ${generatedName[1]}`) : name;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Scene document boundary contract:
|
|
34
|
+
* - `scenes` contains lightweight `{ id, name }` records.
|
|
35
|
+
* - callbacks request document changes; this panel never owns or mutates scenes.
|
|
36
|
+
*
|
|
37
|
+
* A compact document selector sits above the entity tree instead of mixing
|
|
38
|
+
* every Scene into one tree. This keeps the current set readable and leaves
|
|
39
|
+
* Shot authoring in the timeline, where directors expect to find it.
|
|
40
|
+
*/
|
|
41
|
+
function SceneSwitcher({
|
|
42
|
+
scenes,
|
|
43
|
+
activeSceneId,
|
|
44
|
+
onSceneSelect,
|
|
45
|
+
onSceneCreate,
|
|
46
|
+
onSceneDuplicate,
|
|
47
|
+
onSceneRename,
|
|
48
|
+
onSceneDelete,
|
|
49
|
+
}) {
|
|
50
|
+
const availableScenes = scenes?.length ? scenes : FALLBACK_SCENES;
|
|
51
|
+
const selectedId = availableScenes.some((scene) => scene.id === activeSceneId) ? activeSceneId : availableScenes[0].id;
|
|
52
|
+
const selectedScene = availableScenes.find((scene) => scene.id === selectedId);
|
|
53
|
+
const [editingId, setEditingId] = useState(null);
|
|
54
|
+
const [deleteArmed, setDeleteArmed] = useState(false);
|
|
55
|
+
useEffect(() => setDeleteArmed(false), [selectedId, availableScenes.length]);
|
|
56
|
+
|
|
57
|
+
const commitRename = (scene, value) => {
|
|
58
|
+
setEditingId(null);
|
|
59
|
+
const name = value.trim();
|
|
60
|
+
if (name && name !== scene.name) onSceneRename?.(scene.id, name);
|
|
61
|
+
};
|
|
62
|
+
const requestDelete = () => {
|
|
63
|
+
if (availableScenes.length <= 1 || !selectedScene) return;
|
|
64
|
+
if (!deleteArmed) {
|
|
65
|
+
setDeleteArmed(true);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setDeleteArmed(false);
|
|
69
|
+
onSceneDelete?.(selectedScene.id);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div className="scene-switcher" aria-label={ko("Scene documents", "장면 문서") }>
|
|
74
|
+
<div className="scene-switcher-heading">
|
|
75
|
+
<div>
|
|
76
|
+
<strong>{ko("Scenes", "장면")}</strong>
|
|
77
|
+
<span>{isKo ? `${availableScenes.length}개 장면` : `${availableScenes.length} scene${availableScenes.length === 1 ? "" : "s"}`}</span>
|
|
78
|
+
</div>
|
|
79
|
+
<button type="button" className="scene-create-button" onClick={() => onSceneCreate?.()}>
|
|
80
|
+
{ko("+ New Scene", "+ 새 장면")}
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
<div className="scene-list" role="listbox" aria-label={ko("Select scene", "장면 선택")}>
|
|
84
|
+
{availableScenes.map((scene) => {
|
|
85
|
+
const active = scene.id === selectedId;
|
|
86
|
+
return (
|
|
87
|
+
<div key={scene.id} className={`scene-list-item${active ? " active" : ""}`}>
|
|
88
|
+
{editingId === scene.id ? (
|
|
89
|
+
<input
|
|
90
|
+
className="scene-rename-input"
|
|
91
|
+
defaultValue={scene.name}
|
|
92
|
+
autoFocus
|
|
93
|
+
aria-label={ko("Rename scene", "장면 이름 바꾸기")}
|
|
94
|
+
onFocus={(event) => event.currentTarget.select()}
|
|
95
|
+
onBlur={(event) => commitRename(scene, event.currentTarget.value)}
|
|
96
|
+
onKeyDown={(event) => {
|
|
97
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
98
|
+
else if (event.key === "Escape") setEditingId(null);
|
|
99
|
+
}}
|
|
100
|
+
/>
|
|
101
|
+
) : (
|
|
102
|
+
<button
|
|
103
|
+
type="button"
|
|
104
|
+
role="option"
|
|
105
|
+
aria-selected={active}
|
|
106
|
+
onClick={() => {
|
|
107
|
+
if (!active) onSceneSelect?.(scene.id);
|
|
108
|
+
}}
|
|
109
|
+
onDoubleClick={() => setEditingId(scene.id)}
|
|
110
|
+
>
|
|
111
|
+
<span className="scene-document-icon" aria-hidden="true" />
|
|
112
|
+
<span>{displaySceneName(scene.name)}</span>
|
|
113
|
+
</button>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</div>
|
|
119
|
+
<div className="scene-actions">
|
|
120
|
+
<button type="button" onClick={() => selectedScene && onSceneDuplicate?.(selectedScene.id)}>{ko("Duplicate", "복제")}</button>
|
|
121
|
+
<button type="button" onClick={() => selectedScene && setEditingId(selectedScene.id)}>{ko("Rename", "이름 바꾸기")}</button>
|
|
122
|
+
<button type="button" className={deleteArmed ? "danger" : undefined} disabled={availableScenes.length <= 1} onClick={requestDelete} title={availableScenes.length <= 1 ? ko("At least one scene is required", "장면은 최소 하나 필요합니다") : deleteArmed ? ko("Click again to permanently delete this scene", "한 번 더 누르면 이 장면을 완전히 삭제합니다") : undefined}>
|
|
123
|
+
{deleteArmed ? ko("Confirm delete", "삭제 확인") : ko("Delete", "삭제")}
|
|
124
|
+
</button>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function displayHierarchyLabel(node) {
|
|
131
|
+
if (node.kind === "object") return displayObjectLabel(node.label);
|
|
132
|
+
if (node.kind === "scene") return displaySceneName(node.label);
|
|
133
|
+
return isKo ? (HIERARCHY_LABELS_KO[node.label] ?? node.label) : node.label;
|
|
134
|
+
}
|
|
5
135
|
|
|
6
136
|
function indexParents(nodes, parent = null, parents = new Map()) {
|
|
7
137
|
for (const node of nodes) {
|
|
@@ -50,16 +180,16 @@ function RowContextMenu({ menu, onClose, onAction, onAddObject }) {
|
|
|
50
180
|
{menu.kind === "object" ? (
|
|
51
181
|
<>
|
|
52
182
|
<button type="button" role="menuitem" className="hierarchy-context-item" onClick={() => onAction("rename", menu.id)}>
|
|
53
|
-
Rename
|
|
183
|
+
{ko("Rename", "이름 바꾸기")}
|
|
54
184
|
</button>
|
|
55
185
|
<button type="button" role="menuitem" className="hierarchy-context-item" onClick={() => onAction("duplicate", menu.id)}>
|
|
56
|
-
Duplicate
|
|
186
|
+
{ko("Duplicate", "복제")}
|
|
57
187
|
</button>
|
|
58
188
|
<button type="button" role="menuitem" className="hierarchy-context-item" onClick={() => onAction("delete", menu.id)}>
|
|
59
|
-
Delete
|
|
189
|
+
{ko("Delete", "삭제")}
|
|
60
190
|
</button>
|
|
61
191
|
<button type="button" role="menuitem" className="hierarchy-context-item" onClick={() => onAction("frame", menu.id)}>
|
|
62
|
-
Frame
|
|
192
|
+
{ko("Frame", "프레임 맞추기")}
|
|
63
193
|
</button>
|
|
64
194
|
</>
|
|
65
195
|
) : (
|
|
@@ -84,6 +214,7 @@ function TreeRow({
|
|
|
84
214
|
onRowContextMenu,
|
|
85
215
|
}) {
|
|
86
216
|
const branch = !!node.children?.length;
|
|
217
|
+
const label = displayHierarchyLabel(node);
|
|
87
218
|
const rowWrapRef = useRef(null);
|
|
88
219
|
const inputRef = useRef(null);
|
|
89
220
|
// A commit/cancel may race the blur that follows the input unmounting;
|
|
@@ -120,7 +251,7 @@ function TreeRow({
|
|
|
120
251
|
<button
|
|
121
252
|
type="button"
|
|
122
253
|
className="hierarchy-toggle"
|
|
123
|
-
aria-label={`${expanded ? "Collapse" : "Expand"} ${
|
|
254
|
+
aria-label={isKo ? `${label} ${expanded ? "접기" : "펼치기"}` : `${expanded ? "Collapse" : "Expand"} ${label}`}
|
|
124
255
|
onClick={() => onToggle(node.id)}
|
|
125
256
|
>
|
|
126
257
|
{expanded ? "▾" : "▸"}
|
|
@@ -138,7 +269,7 @@ function TreeRow({
|
|
|
138
269
|
ref={inputRef}
|
|
139
270
|
className="hierarchy-rename-input"
|
|
140
271
|
defaultValue={node.label}
|
|
141
|
-
aria-label={`Rename ${
|
|
272
|
+
aria-label={isKo ? `${label} 이름 바꾸기` : `Rename ${label}`}
|
|
142
273
|
autoFocus
|
|
143
274
|
onFocus={(event) => event.currentTarget.select()}
|
|
144
275
|
onKeyDown={(event) => {
|
|
@@ -157,7 +288,7 @@ function TreeRow({
|
|
|
157
288
|
) : (
|
|
158
289
|
<button type="button" className="hierarchy-row" onClick={() => onSelect(node.id)}>
|
|
159
290
|
<span className={`hierarchy-icon ${node.kind}`} aria-hidden="true" />
|
|
160
|
-
<span className="hierarchy-label">{
|
|
291
|
+
<span className="hierarchy-label">{label}</span>
|
|
161
292
|
{status && <span className="hierarchy-status">{status}</span>}
|
|
162
293
|
{badge !== null && badge !== undefined && badge !== 0 && <span className="hierarchy-badge">{badge}</span>}
|
|
163
294
|
</button>
|
|
@@ -171,18 +302,22 @@ export default function HierarchyPanel({
|
|
|
171
302
|
onSelect,
|
|
172
303
|
showB,
|
|
173
304
|
motionFrames,
|
|
174
|
-
promptCount,
|
|
175
|
-
ikFrames,
|
|
176
305
|
ikMode,
|
|
177
|
-
waypointCount,
|
|
178
306
|
sceneObjects = [],
|
|
179
307
|
onAddObject,
|
|
180
308
|
onRenameObject,
|
|
181
309
|
onDuplicateObject,
|
|
182
310
|
onDeleteObject,
|
|
183
311
|
onFrameObject,
|
|
312
|
+
scenes,
|
|
313
|
+
activeSceneId,
|
|
314
|
+
onSceneSelect,
|
|
315
|
+
onSceneCreate,
|
|
316
|
+
onSceneDuplicate,
|
|
317
|
+
onSceneRename,
|
|
318
|
+
onSceneDelete,
|
|
184
319
|
}) {
|
|
185
|
-
const [expanded, setExpanded] = useState(() => new Set(["shot", "characters", "characterA"
|
|
320
|
+
const [expanded, setExpanded] = useState(() => new Set(["shot", "characters", "characterA"]));
|
|
186
321
|
const [contextMenu, setContextMenu] = useState(null);
|
|
187
322
|
// Row currently in in-place rename. The panel owns it: F2/Return and the
|
|
188
323
|
// row context menu are the only ways in, so app state stays out of it.
|
|
@@ -191,7 +326,14 @@ export default function HierarchyPanel({
|
|
|
191
326
|
const lastTreeSelectRef = useRef(null);
|
|
192
327
|
const firstRenderRef = useRef(true);
|
|
193
328
|
const pendingScrollRef = useRef(false);
|
|
194
|
-
const
|
|
329
|
+
const activeSceneName = useMemo(() => {
|
|
330
|
+
const availableScenes = scenes?.length ? scenes : FALLBACK_SCENES;
|
|
331
|
+
return (availableScenes.find((scene) => scene.id === activeSceneId) ?? availableScenes[0]).name;
|
|
332
|
+
}, [activeSceneId, scenes]);
|
|
333
|
+
const hierarchyNodes = useMemo(() => {
|
|
334
|
+
const nodes = buildHierarchyNodes(sceneObjects);
|
|
335
|
+
return nodes.map((node) => node.kind === "scene" ? { ...node, label: activeSceneName } : node);
|
|
336
|
+
}, [activeSceneName, sceneObjects]);
|
|
195
337
|
const parents = useMemo(() => indexParents(hierarchyNodes), [hierarchyNodes]);
|
|
196
338
|
|
|
197
339
|
useEffect(() => {
|
|
@@ -243,15 +385,11 @@ export default function HierarchyPanel({
|
|
|
243
385
|
};
|
|
244
386
|
const badgeFor = (id) => {
|
|
245
387
|
if (id === "characters") return showB ? 2 : 1;
|
|
246
|
-
if (id === "characterA.motion" || id === "characterA.baseMotion") return motionFrames ? `${motionFrames}f` : "empty";
|
|
247
|
-
if (id === "characterA.promptBlocks") return promptCount;
|
|
248
|
-
if (id === "characterA.ik") return ikFrames;
|
|
249
|
-
if (id === "rootPath") return waypointCount;
|
|
250
388
|
if (id === "props") return sceneObjects.length;
|
|
251
389
|
return null;
|
|
252
390
|
};
|
|
253
391
|
const statusFor = (id) => {
|
|
254
|
-
if (id === "characterA" && ikMode) return "IK ON";
|
|
392
|
+
if (id === "characterA" && ikMode) return ko("IK ON", "IK 켜짐");
|
|
255
393
|
return null;
|
|
256
394
|
};
|
|
257
395
|
|
|
@@ -334,18 +472,27 @@ export default function HierarchyPanel({
|
|
|
334
472
|
});
|
|
335
473
|
|
|
336
474
|
return (
|
|
337
|
-
<section className="hierarchy-pane" aria-label="
|
|
475
|
+
<section className="hierarchy-pane" aria-label={ko("Scene hierarchy", "장면 계층")}>
|
|
338
476
|
<div className="hierarchy-heading">
|
|
339
477
|
<div>
|
|
340
|
-
<span className="hierarchy-kicker">Hierarchy</span>
|
|
341
|
-
<strong>
|
|
478
|
+
<span className="hierarchy-kicker">{ko("Hierarchy", "계층")}</span>
|
|
479
|
+
<strong>{ko("Scene structure", "장면 구조")}</strong>
|
|
342
480
|
</div>
|
|
343
|
-
<span className="hierarchy-frame-status">{motionFrames ? `${motionFrames} frames` : "Blocking"}</span>
|
|
481
|
+
<span className="hierarchy-frame-status">{motionFrames ? (isKo ? `${motionFrames}프레임` : `${motionFrames} frames`) : ko("Blocking", "블로킹")}</span>
|
|
344
482
|
</div>
|
|
483
|
+
<SceneSwitcher
|
|
484
|
+
scenes={scenes}
|
|
485
|
+
activeSceneId={activeSceneId}
|
|
486
|
+
onSceneSelect={onSceneSelect}
|
|
487
|
+
onSceneCreate={onSceneCreate}
|
|
488
|
+
onSceneDuplicate={onSceneDuplicate}
|
|
489
|
+
onSceneRename={onSceneRename}
|
|
490
|
+
onSceneDelete={onSceneDelete}
|
|
491
|
+
/>
|
|
345
492
|
{onAddObject && (
|
|
346
493
|
<div className="hierarchy-toolbar">
|
|
347
494
|
<AddObjectMenu onAdd={onAddObject} />
|
|
348
|
-
<span className="hierarchy-frame-status">{motionFrames ? `${motionFrames} frames` : "Blocking"}</span>
|
|
495
|
+
<span className="hierarchy-frame-status">{motionFrames ? (isKo ? `${motionFrames}프레임` : `${motionFrames} frames`) : ko("Blocking", "블로킹")}</span>
|
|
349
496
|
</div>
|
|
350
497
|
)}
|
|
351
498
|
<div className="hierarchy-tree" role="tree" ref={treeRef} onKeyDown={onTreeKeyDown} onContextMenu={openCreateMenu}>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LOCALE, setLocale } from "./locale.js";
|
|
2
|
+
|
|
3
|
+
// One small header button: shows the language you would switch TO, so it
|
|
4
|
+
// reads as an action ("한국어" on the English UI, "EN" on the Korean one).
|
|
5
|
+
export default function LocaleToggle() {
|
|
6
|
+
const next = LOCALE === "ko" ? "en" : "ko";
|
|
7
|
+
return (
|
|
8
|
+
<button
|
|
9
|
+
type="button"
|
|
10
|
+
className="locale-toggle"
|
|
11
|
+
title={LOCALE === "ko" ? "Switch to English" : "한국어로 전환"}
|
|
12
|
+
aria-label={LOCALE === "ko" ? "Switch to English" : "한국어로 전환"}
|
|
13
|
+
onClick={() => setLocale(next)}
|
|
14
|
+
>
|
|
15
|
+
{next === "ko" ? "한국어" : "EN"}
|
|
16
|
+
</button>
|
|
17
|
+
);
|
|
18
|
+
}
|
package/src/locale.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// CozyClay UI locale. English is the default; Korean is opt-in.
|
|
2
|
+
//
|
|
3
|
+
// An explicit choice saved in localStorage wins. Without one, the UI always
|
|
4
|
+
// starts in English regardless of browser or operating-system language.
|
|
5
|
+
// The locale is fixed for the lifetime of the page — every label goes through
|
|
6
|
+
// ko() at render time, so switching saves the choice and reloads.
|
|
7
|
+
const KEY = "cozyclay.locale";
|
|
8
|
+
|
|
9
|
+
function stored() {
|
|
10
|
+
try {
|
|
11
|
+
const value = localStorage.getItem(KEY);
|
|
12
|
+
return value === "ko" || value === "en" ? value : null;
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const LOCALE = stored() ?? "en";
|
|
19
|
+
export const isKo = LOCALE === "ko";
|
|
20
|
+
|
|
21
|
+
/** Pick the label for the active locale: ko("Frame", "프레임"). */
|
|
22
|
+
export function ko(en, koText) {
|
|
23
|
+
return isKo ? koText : en;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function setLocale(next) {
|
|
27
|
+
if (next !== "ko" && next !== "en") return;
|
|
28
|
+
try {
|
|
29
|
+
localStorage.setItem(KEY, next);
|
|
30
|
+
} catch {
|
|
31
|
+
// Private mode without storage: the toggle still works for this load.
|
|
32
|
+
}
|
|
33
|
+
window.location.reload();
|
|
34
|
+
}
|
package/src/main.jsx
CHANGED
|
@@ -2,6 +2,11 @@ import { StrictMode } from "react";
|
|
|
2
2
|
import { createRoot } from "react-dom/client";
|
|
3
3
|
import App from "./App.jsx";
|
|
4
4
|
import "./styles.css";
|
|
5
|
+
import { registerPwa } from "./pwa.js";
|
|
6
|
+
import { LOCALE } from "./locale.js";
|
|
7
|
+
|
|
8
|
+
registerPwa();
|
|
9
|
+
document.documentElement.lang = LOCALE;
|
|
5
10
|
|
|
6
11
|
createRoot(document.getElementById("root")).render(
|
|
7
12
|
<StrictMode>
|
package/src/object-catalog.jsx
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { ko, isKo } from "./locale.js";
|
|
2
3
|
import { OBJECT_LIBRARY } from "./scene-objects.js";
|
|
3
4
|
|
|
5
|
+
const GROUP_LABELS_KO = {
|
|
6
|
+
Primitives: "기본 도형",
|
|
7
|
+
"Set pieces": "세트 소품",
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const OBJECT_LABELS_KO = {
|
|
11
|
+
Cube: "큐브",
|
|
12
|
+
Sphere: "구",
|
|
13
|
+
Capsule: "캡슐",
|
|
14
|
+
Cylinder: "원기둥",
|
|
15
|
+
Cone: "원뿔",
|
|
16
|
+
Plane: "평면",
|
|
17
|
+
Chair: "의자",
|
|
18
|
+
Car: "자동차",
|
|
19
|
+
"Plane (aircraft)": "비행기",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function displayObjectGroupName(name) {
|
|
23
|
+
return isKo ? (GROUP_LABELS_KO[name] ?? name) : name;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function displayObjectLabel(label) {
|
|
27
|
+
if (!isKo) return label;
|
|
28
|
+
const numbered = label.match(/^(.+?) (\d+)$/);
|
|
29
|
+
if (numbered && OBJECT_LABELS_KO[numbered[1]]) return `${OBJECT_LABELS_KO[numbered[1]]} ${numbered[2]}`;
|
|
30
|
+
return OBJECT_LABELS_KO[label] ?? label;
|
|
31
|
+
}
|
|
32
|
+
|
|
4
33
|
/**
|
|
5
34
|
* "Add object" — the hierarchy's create menu, Unity's GameObject > 3D Object
|
|
6
35
|
* in one popover. Grouped by catalogue section; picking an entry drops the
|
|
@@ -25,7 +54,7 @@ export function buildObjectMenuGroups() {
|
|
|
25
54
|
export function CatalogueEntries({ onPick }) {
|
|
26
55
|
return buildObjectMenuGroups().map((group) => (
|
|
27
56
|
<div className="add-object-group" key={group.name}>
|
|
28
|
-
<span className="add-object-heading">{group.name}</span>
|
|
57
|
+
<span className="add-object-heading">{displayObjectGroupName(group.name)}</span>
|
|
29
58
|
{group.entries.map((entry) => (
|
|
30
59
|
<button
|
|
31
60
|
type="button"
|
|
@@ -35,7 +64,7 @@ export function CatalogueEntries({ onPick }) {
|
|
|
35
64
|
onClick={() => onPick(entry.kind)}
|
|
36
65
|
>
|
|
37
66
|
<span className={`add-object-swatch ${entry.kind}`} style={{ background: entry.color }} aria-hidden="true" />
|
|
38
|
-
<span>{entry.label}</span>
|
|
67
|
+
<span>{displayObjectLabel(entry.label)}</span>
|
|
39
68
|
<small>{entry.footprint.width} × {entry.footprint.depth} m</small>
|
|
40
69
|
</button>
|
|
41
70
|
))}
|
|
@@ -43,7 +72,7 @@ export function CatalogueEntries({ onPick }) {
|
|
|
43
72
|
));
|
|
44
73
|
}
|
|
45
74
|
|
|
46
|
-
export default function AddObjectMenu({ onAdd, label = "Add object" }) {
|
|
75
|
+
export default function AddObjectMenu({ onAdd, label = ko("Add object", "오브젝트 추가") }) {
|
|
47
76
|
const [open, setOpen] = useState(false);
|
|
48
77
|
const rootRef = useRef(null);
|
|
49
78
|
|