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.
Files changed (94) hide show
  1. package/README.md +59 -24
  2. package/THIRD_PARTY_NOTICES.md +31 -0
  3. package/bin/cozyclay.mjs +105 -11
  4. package/dist/CNAME +1 -0
  5. package/dist/app/index.html +57 -0
  6. package/dist/assets/app-Cgpk2hwX.js +4803 -0
  7. package/dist/assets/app-DgZvaAE1.css +1 -0
  8. package/dist/favicon.ico +0 -0
  9. package/dist/icons/apple-touch-icon.png +0 -0
  10. package/dist/icons/icon-192.png +0 -0
  11. package/dist/icons/icon-32.png +0 -0
  12. package/dist/icons/icon-512.png +0 -0
  13. package/dist/icons/icon-maskable-512.png +0 -0
  14. package/dist/index.html +406 -5
  15. package/dist/manifest.webmanifest +42 -0
  16. package/dist/media/cozyclay-demo-poster.jpg +0 -0
  17. package/dist/media/cozyclay-logo.png +0 -0
  18. package/dist/robots.txt +4 -0
  19. package/dist/sitemap.xml +9 -0
  20. package/dist/sw.js +127 -0
  21. package/package.json +15 -3
  22. package/src/App.jsx +1393 -648
  23. package/src/ardy/client.js +5 -4
  24. package/src/ardy/mp4-duration.js +102 -0
  25. package/src/ardy/timeline-coordinates.js +11 -0
  26. package/src/ardy/timeline.jsx +528 -67
  27. package/src/ardy/waypoints.js +14 -9
  28. package/src/camera-block.js +60 -0
  29. package/src/camera-follow.js +49 -10
  30. package/src/camera-rail-schedule.js +176 -0
  31. package/src/controls.jsx +16 -2
  32. package/src/cuts.js +184 -0
  33. package/src/generation/client.js +56 -0
  34. package/src/generation/session.js +47 -0
  35. package/src/generation/shot-spec.js +40 -0
  36. package/src/generation/use-generation.js +55 -0
  37. package/src/hierarchy-model.js +9 -17
  38. package/src/hierarchy-panel.jsx +170 -23
  39. package/src/locale-toggle.jsx +18 -0
  40. package/src/locale.js +34 -0
  41. package/src/main.jsx +5 -0
  42. package/src/object-catalog.jsx +32 -3
  43. package/src/planview.jsx +174 -66
  44. package/src/pose-extract/browser.js +42 -0
  45. package/src/pose-extract/fit.js +194 -0
  46. package/src/pose-extract/index.js +53 -0
  47. package/src/pose-extract/keyframes.js +74 -0
  48. package/src/pose-extract/landmarks.js +162 -0
  49. package/src/poses.js +114 -0
  50. package/src/posestudio.jsx +75 -13
  51. package/src/pwa.js +42 -0
  52. package/src/result-modal.jsx +124 -0
  53. package/src/scenes.js +223 -0
  54. package/src/shot-authoring.js +204 -77
  55. package/src/shot.js +8 -4
  56. package/src/styles.css +839 -38
  57. package/src/ui.jsx +54 -5
  58. package/tools/ardy/BRIDGE.md +70 -4
  59. package/tools/ardy/README.md +55 -0
  60. package/tools/ardy/bridge.mjs +89 -389
  61. package/tools/ardy/cclay_constrained_generate.py +449 -0
  62. package/tools/ardy/cclay_motion_edit.py +74 -9
  63. package/tools/ardy/cclay_sequence_generate.py +68 -7
  64. package/tools/ardy/cclay_worker.py +304 -0
  65. package/tools/ardy/merge-text-encoder.py +160 -0
  66. package/tools/ardy/run-local.mjs +233 -0
  67. package/tools/ardy/runners/index.mjs +23 -0
  68. package/tools/ardy/runners/local.mjs +452 -0
  69. package/tools/ardy/runners/proc.mjs +125 -0
  70. package/tools/ardy/runners/remote.mjs +246 -0
  71. package/tools/ardy/setup-local.mjs +189 -0
  72. package/tools/ardy/setup-text-encoder-on-box.sh +93 -0
  73. package/tools/ardy/setup-text-encoder.py +296 -0
  74. package/tools/generation/README.md +29 -0
  75. package/tools/generation/bridge.mjs +149 -0
  76. package/tools/generation/job-store.mjs +51 -0
  77. package/tools/generation/providers/kling.mjs +76 -0
  78. package/tools/generation/providers/runway.mjs +101 -0
  79. package/tools/generation/providers/seedance.mjs +87 -0
  80. package/tools/generation/providers/shared.mjs +49 -0
  81. package/tools/generation/providers/veo.mjs +84 -0
  82. package/tools/metrics/archive-traffic.mjs +138 -0
  83. package/dist/assets/index-BW_S1YRy.js +0 -4395
  84. package/dist/assets/index-nRmmJgap.css +0 -1
  85. package/tools/ardy/__pycache__/cclay_sequence_generate.cpython-313.pyc +0 -0
  86. package/tools/ardy/out/gen-1786443326924-c6019e-generated.npz +0 -0
  87. package/tools/ardy/out/gen-1786443609325-0053db-generated.npz +0 -0
  88. package/tools/ardy/out/gen-1786443835628-749ed1-generated.npz +0 -0
  89. package/tools/ardy/out/gen-1786462605247-03cb19-generated.npz +0 -0
  90. package/tools/qa-browser.mjs +0 -84
  91. package/tools/qa-crop3.mjs +0 -22
  92. package/tools/qa-playview.mjs +0 -49
  93. package/tools/qa-screenshot.mjs +0 -24
  94. package/tools/qa-visual.mjs +0 -51
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Public video-to-pose-keys contract.
3
+ *
4
+ * App wiring should pass MediaPipe world-landmark samples here, then merge
5
+ * `result.keys` into the same `{ frame, pose }[]` list currently sent as
6
+ * `body.poses`. The output is intentionally ordinary cozyclay.pose.v1 data:
7
+ * no bridge endpoint, npz path or root-recovery schema is introduced.
8
+ */
9
+
10
+ import { fitLandmarksToPose } from "./fit.js";
11
+ import { selectPoseKeyframes } from "./keyframes.js";
12
+ import { filterLandmarkTrack, normalizeLandmarkTrack } from "./landmarks.js";
13
+
14
+ export { collectLandmarkTrack, selectMostConfidentPerson } from "./browser.js";
15
+ export { fitLandmarksToPose } from "./fit.js";
16
+ export { poseChangeScores, selectPoseKeyframes } from "./keyframes.js";
17
+ export { filterLandmarkTrack, normalizeLandmarkSample, normalizeLandmarkTrack, POSE_LANDMARK } from "./landmarks.js";
18
+
19
+ export function videoLandmarksToPoseKeys({ samples, rest, fps = 20, ...options }) {
20
+ if (!Number.isFinite(fps) || fps <= 0) {
21
+ throw new Error("videoLandmarksToPoseKeys: fps must be a positive finite number");
22
+ }
23
+ const normalized = normalizeLandmarkTrack(samples, options);
24
+ const filtered = filterLandmarkTrack(normalized, options.filter);
25
+ const { indices, scores } = selectPoseKeyframes(filtered, options);
26
+ const keys = [];
27
+ const diagnostics = [];
28
+ for (const sampleIndex of indices) {
29
+ const sample = filtered[sampleIndex];
30
+ const frame = Math.max(0, Math.round(sample.timeS * fps));
31
+ const fitted = fitLandmarksToPose({ sample, rest, createdMs: options.createdMs ?? 0 });
32
+ const entry = { frame, pose: fitted.pose };
33
+ const diagnostic = {
34
+ frame,
35
+ sampleIndex,
36
+ sourceTimeS: sample.timeS,
37
+ score: scores[sampleIndex],
38
+ confidence: fitted.confidence,
39
+ releasedBones: fitted.releasedBones,
40
+ };
41
+ const prior = keys[keys.length - 1];
42
+ if (prior?.frame === frame) {
43
+ if (diagnostic.score > diagnostics[diagnostics.length - 1].score) {
44
+ keys[keys.length - 1] = entry;
45
+ diagnostics[diagnostics.length - 1] = diagnostic;
46
+ }
47
+ } else {
48
+ keys.push(entry);
49
+ diagnostics.push(diagnostic);
50
+ }
51
+ }
52
+ return { keys, diagnostics };
53
+ }
@@ -0,0 +1,74 @@
1
+ /** Pure pose-change scoring and keyframe selection. */
2
+
3
+ function landmarkDistance(a, b) {
4
+ let sum = 0;
5
+ let weight = 0;
6
+ const count = Math.min(a.landmarks.length, b.landmarks.length);
7
+ for (let index = 0; index < count; index += 1) {
8
+ const pa = a.landmarks[index];
9
+ const pb = b.landmarks[index];
10
+ if (!pa || !pb) continue;
11
+ const confidence = Math.min(pa.visibility, pb.visibility);
12
+ const delta = Math.hypot(
13
+ pa.position[0] - pb.position[0],
14
+ pa.position[1] - pb.position[1],
15
+ pa.position[2] - pb.position[2]
16
+ );
17
+ sum += delta * confidence;
18
+ weight += confidence;
19
+ }
20
+ return weight > 0 ? sum / weight : 0;
21
+ }
22
+
23
+ export function poseChangeScores(samples) {
24
+ if (!Array.isArray(samples)) throw new Error("poseChangeScores: samples must be an array");
25
+ return samples.map((sample, index) => {
26
+ if (!sample.valid || index === 0 || index === samples.length - 1) return 0;
27
+ const before = samples[index - 1];
28
+ const after = samples[index + 1];
29
+ if (!before.valid || !after.valid) return 0;
30
+ const dtBefore = Math.max(sample.timeS - before.timeS, 1e-6);
31
+ const dtAfter = Math.max(after.timeS - sample.timeS, 1e-6);
32
+ return (
33
+ landmarkDistance(before, sample) / dtBefore +
34
+ landmarkDistance(sample, after) / dtAfter
35
+ );
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Keep valid endpoints plus the strongest local pose-change peaks. Returned
41
+ * indices are source ordered and respect `minSpacingS` wherever possible.
42
+ */
43
+ export function selectPoseKeyframes(samples, options = {}) {
44
+ if (!Array.isArray(samples) || samples.length === 0) {
45
+ throw new Error("selectPoseKeyframes: samples must be a non-empty array");
46
+ }
47
+ const maxKeys = Math.max(1, Math.floor(options.maxKeys ?? 12));
48
+ const minSpacingS = Math.max(0, options.minSpacingS ?? 0.25);
49
+ const valid = samples.map((sample, index) => sample.valid ? index : -1).filter((index) => index >= 0);
50
+ if (valid.length === 0) return { indices: [], scores: poseChangeScores(samples) };
51
+ if (maxKeys === 1) return { indices: [valid[0]], scores: poseChangeScores(samples) };
52
+
53
+ const scores = poseChangeScores(samples);
54
+ const selected = new Set([valid[0], valid[valid.length - 1]]);
55
+ const peaks = valid
56
+ .filter((index) => index > 0 && index < samples.length - 1)
57
+ .filter((index) => scores[index] >= scores[index - 1] && scores[index] >= scores[index + 1])
58
+ .sort((a, b) => scores[b] - scores[a] || a - b);
59
+ const candidates = [
60
+ ...peaks,
61
+ ...valid
62
+ .filter((index) => index > 0 && index < samples.length - 1 && !peaks.includes(index))
63
+ .sort((a, b) => scores[b] - scores[a] || a - b),
64
+ ];
65
+
66
+ for (const index of candidates) {
67
+ if (selected.size >= maxKeys) break;
68
+ const time = samples[index].timeS;
69
+ if ([...selected].every((other) => Math.abs(samples[other].timeS - time) >= minSpacingS)) {
70
+ selected.add(index);
71
+ }
72
+ }
73
+ return { indices: [...selected].sort((a, b) => a - b), scores };
74
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * Pure MediaPipe Pose landmark preparation.
3
+ *
4
+ * Input samples use MediaPipe's 33-landmark shape and camera coordinates
5
+ * (X right, Y down, Z away from the camera). Output is hip-centred, Y-up,
6
+ * forward-positive and torso-normalised. Root translation is intentionally
7
+ * discarded: CozyClay authors it with waypoints and ARDY synthesises it.
8
+ */
9
+
10
+ export const POSE_LANDMARK = Object.freeze({
11
+ NOSE: 0,
12
+ LEFT_EYE: 2,
13
+ RIGHT_EYE: 5,
14
+ LEFT_EAR: 7,
15
+ RIGHT_EAR: 8,
16
+ LEFT_SHOULDER: 11,
17
+ RIGHT_SHOULDER: 12,
18
+ LEFT_ELBOW: 13,
19
+ RIGHT_ELBOW: 14,
20
+ LEFT_WRIST: 15,
21
+ RIGHT_WRIST: 16,
22
+ LEFT_PINKY: 17,
23
+ RIGHT_PINKY: 18,
24
+ LEFT_INDEX: 19,
25
+ RIGHT_INDEX: 20,
26
+ LEFT_HIP: 23,
27
+ RIGHT_HIP: 24,
28
+ LEFT_KNEE: 25,
29
+ RIGHT_KNEE: 26,
30
+ LEFT_ANKLE: 27,
31
+ RIGHT_ANKLE: 28,
32
+ LEFT_HEEL: 29,
33
+ RIGHT_HEEL: 30,
34
+ LEFT_FOOT_INDEX: 31,
35
+ RIGHT_FOOT_INDEX: 32,
36
+ });
37
+
38
+ const REQUIRED_CORE = [
39
+ POSE_LANDMARK.LEFT_SHOULDER,
40
+ POSE_LANDMARK.RIGHT_SHOULDER,
41
+ POSE_LANDMARK.LEFT_HIP,
42
+ POSE_LANDMARK.RIGHT_HIP,
43
+ ];
44
+
45
+ function finite(value) {
46
+ return typeof value === "number" && Number.isFinite(value);
47
+ }
48
+
49
+ function midpoint(a, b) {
50
+ return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
51
+ }
52
+
53
+ function distance(a, b) {
54
+ return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
55
+ }
56
+
57
+ function readLandmark(entry, index, minVisibility, mirrored) {
58
+ if (!entry || !finite(entry.x) || !finite(entry.y) || !finite(entry.z)) return null;
59
+ const visibility = finite(entry.visibility) ? entry.visibility : 1;
60
+ if (visibility < minVisibility) return null;
61
+ return {
62
+ position: [(mirrored ? -1 : 1) * entry.x, -entry.y, -entry.z],
63
+ visibility,
64
+ index,
65
+ };
66
+ }
67
+
68
+ /** Normalize one `{ timeS, landmarks }` sample without using DOM or three.js. */
69
+ export function normalizeLandmarkSample(sample, options = {}) {
70
+ const minVisibility = options.minVisibility ?? 0.35;
71
+ const mirrored = options.mirrored === true;
72
+ if (!sample || !finite(sample.timeS) || sample.timeS < 0) {
73
+ throw new Error("normalizeLandmarkSample: sample.timeS must be a non-negative finite number");
74
+ }
75
+ if (!Array.isArray(sample.landmarks) || sample.landmarks.length < 33) {
76
+ throw new Error("normalizeLandmarkSample: landmarks must contain the 33 MediaPipe Pose landmarks");
77
+ }
78
+ const landmarks = sample.landmarks.map((entry, index) =>
79
+ readLandmark(entry, index, minVisibility, mirrored)
80
+ );
81
+ if (REQUIRED_CORE.some((index) => landmarks[index] === null)) {
82
+ return { timeS: sample.timeS, landmarks, valid: false, scale: null };
83
+ }
84
+
85
+ const leftHip = landmarks[POSE_LANDMARK.LEFT_HIP].position;
86
+ const rightHip = landmarks[POSE_LANDMARK.RIGHT_HIP].position;
87
+ const leftShoulder = landmarks[POSE_LANDMARK.LEFT_SHOULDER].position;
88
+ const rightShoulder = landmarks[POSE_LANDMARK.RIGHT_SHOULDER].position;
89
+ const hipCentre = midpoint(leftHip, rightHip);
90
+ const shoulderCentre = midpoint(leftShoulder, rightShoulder);
91
+ const torso = distance(hipCentre, shoulderCentre);
92
+ const shoulderWidth = distance(leftShoulder, rightShoulder);
93
+ const hipWidth = distance(leftHip, rightHip);
94
+ const scale = torso > 1e-6 ? torso : Math.max(shoulderWidth, hipWidth);
95
+ if (!(scale > 1e-6)) return { timeS: sample.timeS, landmarks, valid: false, scale: null };
96
+
97
+ for (const landmark of landmarks) {
98
+ if (!landmark) continue;
99
+ landmark.position = landmark.position.map((value, axis) =>
100
+ (value - hipCentre[axis]) / scale
101
+ );
102
+ }
103
+ return { timeS: sample.timeS, landmarks, valid: true, scale };
104
+ }
105
+
106
+ export function normalizeLandmarkTrack(samples, options = {}) {
107
+ if (!Array.isArray(samples) || samples.length === 0) {
108
+ throw new Error("normalizeLandmarkTrack: samples must be a non-empty array");
109
+ }
110
+ let previous = -Infinity;
111
+ return samples.map((sample) => {
112
+ if (sample?.timeS <= previous) {
113
+ throw new Error("normalizeLandmarkTrack: sample times must be strictly ascending");
114
+ }
115
+ previous = sample.timeS;
116
+ return normalizeLandmarkSample(sample, options);
117
+ });
118
+ }
119
+
120
+ function smoothingAlpha(cutoff, dt) {
121
+ const tau = 1 / (2 * Math.PI * cutoff);
122
+ return 1 / (1 + tau / dt);
123
+ }
124
+
125
+ /** One-Euro filter over a normalised track. Missing/low-confidence points stay released. */
126
+ export function filterLandmarkTrack(samples, options = {}) {
127
+ const minCutoff = options.minCutoff ?? 1;
128
+ const beta = options.beta ?? 0.08;
129
+ const derivativeCutoff = options.derivativeCutoff ?? 1;
130
+ const state = new Array(33).fill(null);
131
+ return samples.map((sample) => {
132
+ const landmarks = sample.landmarks.map((landmark, index) => {
133
+ if (!landmark) return null;
134
+ const previous = state[index];
135
+ if (!previous) {
136
+ state[index] = {
137
+ timeS: sample.timeS,
138
+ raw: landmark.position.slice(),
139
+ filtered: landmark.position.slice(),
140
+ derivative: [0, 0, 0],
141
+ };
142
+ return { ...landmark, position: landmark.position.slice() };
143
+ }
144
+ const dt = Math.max(sample.timeS - previous.timeS, 1e-6);
145
+ const derivativeAlpha = smoothingAlpha(derivativeCutoff, dt);
146
+ const rawDerivative = landmark.position.map((value, axis) =>
147
+ (value - previous.raw[axis]) / dt
148
+ );
149
+ const derivative = rawDerivative.map((value, axis) =>
150
+ previous.derivative[axis] + derivativeAlpha * (value - previous.derivative[axis])
151
+ );
152
+ const speed = Math.hypot(...derivative);
153
+ const alpha = smoothingAlpha(minCutoff + beta * speed, dt);
154
+ const filtered = landmark.position.map((value, axis) =>
155
+ previous.filtered[axis] + alpha * (value - previous.filtered[axis])
156
+ );
157
+ state[index] = { timeS: sample.timeS, raw: landmark.position.slice(), filtered, derivative };
158
+ return { ...landmark, position: filtered };
159
+ });
160
+ return { ...sample, landmarks };
161
+ });
162
+ }
package/src/poses.js CHANGED
@@ -198,6 +198,120 @@ export const BUILT_IN_POSES = [
198
198
  rArm: [-1.6214, 0.2072, 0.0104],
199
199
  },
200
200
  },
201
+ {
202
+ id: "wave",
203
+ label: "Wave",
204
+ category: "gesture",
205
+ prompt: "standing in a friendly wave with the right hand raised beside the head",
206
+ bones: {
207
+ chest: [0, -0.08, 0],
208
+ head: [0, -0.12, 0],
209
+ lArm: [1.5632, 0.1164, -0.2889],
210
+ lForeArm: [-0.0076, 0.0003, -0.0874],
211
+ rArm: [-0.762, 0.118, 0.865],
212
+ rForeArm: [-0.94, -0.12, 0.42],
213
+ rHand: [0.12, 0.2, 0.3],
214
+ },
215
+ },
216
+ {
217
+ id: "thinking",
218
+ label: "Thinking",
219
+ category: "gesture",
220
+ prompt: "standing thoughtfully with one hand near the chin and the other arm relaxed",
221
+ bones: {
222
+ spine: [-0.04, -0.05, 0],
223
+ neck: [0.08, -0.08, 0],
224
+ head: [0.12, -0.12, 0],
225
+ lArm: [1.5632, 0.1164, -0.2889],
226
+ lForeArm: [-0.0076, 0.0003, -0.0874],
227
+ rArm: [0.55, -0.18, 0.48],
228
+ rForeArm: [1.42, -0.18, -0.32],
229
+ rHand: [0.18, -0.1, -0.08],
230
+ },
231
+ },
232
+ {
233
+ id: "crouch",
234
+ label: "Crouch",
235
+ category: "action",
236
+ prompt: "crouching low with knees bent and arms balancing forward",
237
+ bones: {
238
+ hips: [0.34, 0, 0],
239
+ spine: [-0.24, 0, 0],
240
+ chest: [-0.12, 0, 0],
241
+ lUpLeg: [1.02, 0.08, 0.08],
242
+ rUpLeg: [1.02, -0.08, -0.08],
243
+ lLeg: [1.26, 0, 0],
244
+ rLeg: [1.26, 0, 0],
245
+ lFoot: [-0.74, 0, 0],
246
+ rFoot: [-0.74, 0, 0],
247
+ lArm: [0.72, 0.14, -0.54],
248
+ rArm: [0.72, -0.14, 0.54],
249
+ lForeArm: [0.24, 0.02, -0.2],
250
+ rForeArm: [0.24, -0.02, 0.2],
251
+ },
252
+ },
253
+ {
254
+ id: "kneel",
255
+ label: "Kneel",
256
+ category: "floor",
257
+ prompt: "kneeling on one knee with the torso upright and hands relaxed",
258
+ bones: {
259
+ hips: [0.16, 0, -0.04],
260
+ spine: [-0.12, 0, 0.02],
261
+ lUpLeg: [1.12, 0.04, 0.08],
262
+ lLeg: [1.48, 0, 0],
263
+ lFoot: [-1.1, 0, 0],
264
+ rUpLeg: [0.28, -0.04, -0.08],
265
+ rLeg: [1.28, 0, 0],
266
+ rFoot: [-0.62, 0, 0],
267
+ lArm: [1.45, 0.12, -0.28],
268
+ rArm: [1.45, -0.12, 0.28],
269
+ lForeArm: [0.18, 0.02, -0.18],
270
+ rForeArm: [0.18, -0.02, 0.18],
271
+ },
272
+ },
273
+ {
274
+ id: "run",
275
+ label: "Run",
276
+ category: "action",
277
+ prompt: "running in an energetic stride with opposite arm and leg driving forward",
278
+ bones: {
279
+ hips: [0.18, 0, -0.05],
280
+ spine: [-0.22, 0.03, 0.04],
281
+ chest: [-0.12, -0.04, 0],
282
+ rUpLeg: [0.96, 0, 0],
283
+ rLeg: [0.8, 0, 0],
284
+ rFoot: [-0.38, 0, 0],
285
+ lUpLeg: [-0.82, 0, 0],
286
+ lLeg: [-0.52, 0, 0],
287
+ lFoot: [0.24, 0, 0],
288
+ lArm: [0.88, -0.5, -0.76],
289
+ lForeArm: [-0.78, 0.16, -0.44],
290
+ rArm: [1.92, -0.54, 0.36],
291
+ rForeArm: [-0.68, 0.12, 0.62],
292
+ },
293
+ },
294
+ {
295
+ id: "jump",
296
+ label: "Jump",
297
+ category: "action",
298
+ prompt: "jumping upward with both arms lifted and knees slightly tucked",
299
+ bones: {
300
+ hips: [0.08, 0, 0],
301
+ spine: [-0.12, 0, 0],
302
+ chest: [-0.08, 0, 0],
303
+ lArm: [-1.18, -0.18, -0.18],
304
+ rArm: [-1.18, 0.18, 0.18],
305
+ lForeArm: [-0.2, 0.04, -0.08],
306
+ rForeArm: [-0.2, -0.04, 0.08],
307
+ lUpLeg: [0.46, 0.1, 0.12],
308
+ rUpLeg: [0.46, -0.1, -0.12],
309
+ lLeg: [0.78, 0, 0],
310
+ rLeg: [0.78, 0, 0],
311
+ lFoot: [-0.34, 0, 0],
312
+ rFoot: [-0.34, 0, 0],
313
+ },
314
+ },
201
315
  ];
202
316
  const STORAGE_KEY = "cozyclay_poses";
203
317
 
@@ -4,6 +4,7 @@ import * as THREE from "three";
4
4
  import { POSE_BONES, normalizeBoneName, primeBindPose } from "./poses.js";
5
5
  import { IK_TRACKS, MID_TRACKS } from "./ardy/ik.js";
6
6
  import { POSER_LAYER } from "./dualview.jsx";
7
+ import { ko, isKo } from "./locale.js";
7
8
 
8
9
  /** Same normalised-name match rule as poses.js: equal, or one is a suffix of
9
10
  * the other, so `mixamorig:LeftArm`, `mixamorigLeftArm` and `LeftArm` all hit. */
@@ -759,38 +760,99 @@ const CLICK_PX = 4;
759
760
  * `{ thumb, custom: true }`. The tile entry animation cascades with the same
760
761
  * stagger as the reference.
761
762
  */
762
- export function PoseStudioPanel({ subject, poses, selectedId, onSelect, onApply, onReset, onSave, onDelete, onClose, closing }) {
763
+ export function PoseStudioPanel({ subject, poses, selectedId, onSelect, onApply, onReset, onSave, onDelete, onClose, closing, motionActive = false }) {
764
+ const poseLabelsKo = {
765
+ "T-pose": ko("T-pose", "T 포즈"),
766
+ Relaxed: ko("Relaxed", "편안한 자세"),
767
+ Contrapposto: ko("Contrapposto", "콘트라포스토"),
768
+ Walking: ko("Walking", "걷는 자세"),
769
+ Seated: ko("Seated", "앉은 자세"),
770
+ "Arms crossed": ko("Arms crossed", "팔짱"),
771
+ Pointing: ko("Pointing", "가리키기"),
772
+ "Hands on hips": ko("Hands on hips", "허리에 손"),
773
+ "Looking back": ko("Looking back", "뒤돌아보기"),
774
+ "Hands up": ko("Hands up", "손 올리기"),
775
+ Wave: ko("Wave", "손 흔들기"),
776
+ Thinking: ko("Thinking", "생각하기"),
777
+ Crouch: ko("Crouch", "웅크리기"),
778
+ Kneel: ko("Kneel", "무릎 꿇기"),
779
+ Run: ko("Run", "달리기"),
780
+ Jump: ko("Jump", "점프"),
781
+ };
782
+ const categoryLabelsKo = {
783
+ all: ko("All", "전체"),
784
+ basic: ko("Basic", "기본"),
785
+ gesture: ko("Gesture", "제스처"),
786
+ action: ko("Action", "동작"),
787
+ floor: ko("Floor", "바닥"),
788
+ custom: ko("My poses", "내 포즈"),
789
+ };
790
+ const displayPoseLabel = (pose) => pose.custom ? pose.label : poseLabelsKo[pose.label] ?? pose.label;
791
+ const poseCategory = (pose) => pose.custom ? "custom" : pose.category ?? "basic";
792
+ const [category, setCategory] = useState("all");
793
+ const selectedIdRef = useRef(selectedId);
794
+ useEffect(() => {
795
+ selectedIdRef.current = selectedId;
796
+ }, [selectedId]);
797
+ const selectPose = (id) => {
798
+ selectedIdRef.current = id;
799
+ onSelect(id);
800
+ };
801
+ const categories = ["all", ...Array.from(new Set(poses.map(poseCategory)))];
802
+ const visiblePoses = category === "all" ? poses : poses.filter((pose) => poseCategory(pose) === category);
763
803
  return (
764
804
  <div className={"pose-studio" + (closing ? " closing" : "")}>
765
805
  <div className="studio-head">
766
- <span>Pose Studio · Subject {subject}</span>
767
- <button type="button" className="x" onClick={onClose}>
806
+ <span>{isKo ? `포즈 스튜디오 · 인물 ${subject}` : `Pose Studio · Subject ${subject}`}</span>
807
+ <button type="button" className="x" onClick={onClose} aria-label={ko("Close pose studio", "포즈 스튜디오 닫기")}>
768
808
  ✕
769
809
  </button>
770
810
  </div>
811
+ {motionActive && (
812
+ <p className="studio-hint" data-pose-motion-warning role="status">
813
+ {ko("A sample motion is moving the character — applying a pose clears it and returns to the blocking pose.", "현재 샘플 모션이 캐릭터를 움직이고 있어요. 포즈를 눈앞에 적용하려면 샘플 모션을 지우고 블로킹 포즈로 전환합니다.")}
814
+ </p>
815
+ )}
771
816
  <div className="studio-actions">
772
- <button type="button" className="btn primary full" onClick={onApply}>
773
- Apply pose
817
+ <button type="button" className="btn primary full" data-pose-apply onClick={() => onApply(selectedIdRef.current)}>
818
+ {motionActive ? ko("Clear motion and apply pose", "모션 지우고 포즈 적용") : ko("Apply pose", "포즈 적용")}
774
819
  </button>
775
820
  <button type="button" className="btn ghost full" onClick={onReset}>
776
- Reset pose
821
+ {ko("Reset pose", "포즈 초기화")}
777
822
  </button>
778
823
  </div>
824
+ {categories.length > 2 && (
825
+ <div className="studio-filters" aria-label={ko("Pose categories", "포즈 카테고리")}>
826
+ {categories.map((item) => (
827
+ <button
828
+ type="button"
829
+ key={item}
830
+ className={"btn ghost" + (item === category ? " active" : "")}
831
+ aria-pressed={item === category}
832
+ onClick={() => setCategory(item)}
833
+ >
834
+ {categoryLabelsKo[item] ?? item}
835
+ </button>
836
+ ))}
837
+ </div>
838
+ )}
779
839
  <div className="pose-grid">
780
- {poses.map((pose, index) => (
840
+ {visiblePoses.map((pose, index) => (
781
841
  <button
782
842
  type="button"
783
843
  key={pose.id}
784
844
  className={"pose-tile" + (pose.id === selectedId ? " active" : "")}
845
+ data-pose-id={pose.id}
846
+ data-pose-category={poseCategory(pose)}
785
847
  style={{ animationDelay: `${0.04 + index * 0.028}s` }}
786
- onClick={() => onSelect(pose.id)}
848
+ onClick={() => selectPose(pose.id)}
787
849
  >
788
- {pose.thumb ? <img src={pose.thumb} alt={pose.label} /> : <div className="tile-blank" />}
789
- <span>{pose.label}</span>
850
+ {pose.thumb ? <img src={pose.thumb} alt={displayPoseLabel(pose)} /> : <div className="tile-blank" />}
851
+ <span>{displayPoseLabel(pose)}</span>
790
852
  {pose.custom && (
791
853
  <em
792
854
  className="del"
793
- title="Delete"
855
+ title={ko("Delete", "삭제")}
794
856
  onClick={(e) => {
795
857
  e.stopPropagation();
796
858
  onDelete(pose.id);
@@ -801,9 +863,9 @@ export function PoseStudioPanel({ subject, poses, selectedId, onSelect, onApply,
801
863
  )}
802
864
  </button>
803
865
  ))}
804
- <button type="button" className="pose-tile add" title="Save the character's current pose" onClick={onSave}>
866
+ <button type="button" className="pose-tile add" data-pose-id="save-custom" title={ko("Save the character's current pose", "현재 캐릭터 포즈 저장")} onClick={onSave}>
805
867
  <span className="add-plus">+</span>
806
- <span className="add-text">Save pose</span>
868
+ <span className="add-text">{ko("Save pose", "포즈 저장")}</span>
807
869
  </button>
808
870
  </div>
809
871
  </div>
package/src/pwa.js ADDED
@@ -0,0 +1,42 @@
1
+ export const PWA_UPDATE_EVENT = "cozyclay:pwa-update-ready";
2
+
3
+ function announceUpdate(registration) {
4
+ window.dispatchEvent(new CustomEvent(PWA_UPDATE_EVENT, { detail: registration }));
5
+ }
6
+
7
+ export function registerPwa() {
8
+ if (!import.meta.env.PROD || !("serviceWorker" in navigator)) return;
9
+
10
+ let hasController = Boolean(navigator.serviceWorker.controller);
11
+ let reloading = false;
12
+
13
+ navigator.serviceWorker.addEventListener("controllerchange", () => {
14
+ if (!hasController) {
15
+ hasController = true;
16
+ return;
17
+ }
18
+ if (reloading) return;
19
+ reloading = true;
20
+ window.location.reload();
21
+ });
22
+
23
+ window.addEventListener("load", async () => {
24
+ try {
25
+ const registration = await navigator.serviceWorker.register(`${import.meta.env.BASE_URL}sw.js`, {
26
+ scope: import.meta.env.BASE_URL,
27
+ });
28
+
29
+ if (registration.waiting) announceUpdate(registration);
30
+ registration.addEventListener("updatefound", () => {
31
+ const worker = registration.installing;
32
+ worker?.addEventListener("statechange", () => {
33
+ if (worker.state === "installed" && navigator.serviceWorker.controller) {
34
+ announceUpdate(registration);
35
+ }
36
+ });
37
+ });
38
+ } catch {
39
+ return;
40
+ }
41
+ }, { once: true });
42
+ }