cozyclay 1.1.0 → 1.3.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 (138) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +91 -25
  3. package/THIRD_PARTY_NOTICES.md +68 -1
  4. package/bin/cozyclay.mjs +71 -8
  5. package/dist/CNAME +1 -0
  6. package/dist/ai-camera-control/index.html +406 -0
  7. package/dist/app/index.html +57 -0
  8. package/dist/assets/app-B3U5aut1.js +4811 -0
  9. package/dist/assets/app-BrRF0wso.css +1 -0
  10. package/dist/assets/vision_bundle-jFkh-fIS.js +41 -0
  11. package/dist/favicon.ico +0 -0
  12. package/dist/fonts/InstrumentSerif-OFL.txt +93 -0
  13. package/dist/fonts/Inter-OFL.txt +92 -0
  14. package/dist/fonts/README.md +15 -0
  15. package/dist/icons/apple-touch-icon.png +0 -0
  16. package/dist/icons/icon-192.png +0 -0
  17. package/dist/icons/icon-32.png +0 -0
  18. package/dist/icons/icon-512.png +0 -0
  19. package/dist/icons/icon-maskable-512.png +0 -0
  20. package/dist/index.html +450 -5
  21. package/dist/manifest.webmanifest +42 -0
  22. package/dist/media/cozyclay-demo-poster.jpg +0 -0
  23. package/dist/media/cozyclay-logo.png +0 -0
  24. package/dist/robots.txt +4 -0
  25. package/dist/sitemap.xml +15 -0
  26. package/dist/sw.js +127 -0
  27. package/mcp/LIVE-PROTOCOL.md +63 -0
  28. package/mcp/README.md +142 -0
  29. package/mcp/ardy-prompts.mjs +170 -0
  30. package/mcp/live-hub.mjs +105 -0
  31. package/mcp/package.json +24 -0
  32. package/mcp/server.mjs +1394 -0
  33. package/package.json +122 -78
  34. package/src/App.jsx +4235 -1047
  35. package/src/ardy/client.js +5 -4
  36. package/src/ardy/cskel27.js +7 -2
  37. package/src/ardy/ik.js +25 -15
  38. package/src/ardy/mp4-duration.js +102 -0
  39. package/src/ardy/npz.js +64 -3
  40. package/src/ardy/playback.js +31 -1
  41. package/src/ardy/prompt-clips.js +7 -2
  42. package/src/ardy/retime.js +211 -0
  43. package/src/ardy/timeline-coordinates.js +24 -0
  44. package/src/ardy/timeline.jsx +650 -70
  45. package/src/ardy/to-cskel27.js +34 -12
  46. package/src/ardy/trim.js +33 -0
  47. package/src/ardy/waypoints.js +14 -9
  48. package/src/asset-pane.jsx +36 -0
  49. package/src/camera-block.js +60 -0
  50. package/src/camera-follow.js +49 -10
  51. package/src/camera-rail-schedule.js +176 -0
  52. package/src/controls.jsx +16 -2
  53. package/src/cuts.js +184 -0
  54. package/src/dualview.jsx +14 -8
  55. package/src/generation/client.js +56 -0
  56. package/src/generation/session.js +47 -0
  57. package/src/generation/shot-spec.js +40 -0
  58. package/src/generation/use-generation.js +55 -0
  59. package/src/hierarchy-model.js +104 -30
  60. package/src/hierarchy-panel.jsx +306 -26
  61. package/src/live-control.js +122 -0
  62. package/src/locale-toggle.jsx +18 -0
  63. package/src/locale.js +34 -0
  64. package/src/main.jsx +5 -0
  65. package/src/matte-editor.js +543 -0
  66. package/src/matte.js +503 -0
  67. package/src/multimodel-ingest.js +344 -0
  68. package/src/object-catalog.jsx +32 -3
  69. package/src/object-gizmo.jsx +43 -15
  70. package/src/planview.jsx +208 -89
  71. package/src/pose-extract/browser.js +42 -0
  72. package/src/pose-extract/detector.js +75 -0
  73. package/src/pose-extract/fit.js +194 -0
  74. package/src/pose-extract/index.js +56 -0
  75. package/src/pose-extract/keyframes.js +74 -0
  76. package/src/pose-extract/landmarks.js +162 -0
  77. package/src/pose-extract/take.js +87 -0
  78. package/src/pose-extract/video-frames.js +91 -0
  79. package/src/pose-thumbs.js +152 -0
  80. package/src/poses.js +114 -0
  81. package/src/posestudio.jsx +434 -22
  82. package/src/project-browser.jsx +135 -0
  83. package/src/project.js +289 -0
  84. package/src/props.jsx +69 -3
  85. package/src/pwa.js +42 -0
  86. package/src/result-modal.jsx +124 -0
  87. package/src/room.jsx +14 -35
  88. package/src/scene-asset-cache.js +125 -0
  89. package/src/scene-assets.js +288 -0
  90. package/src/scene-objects.js +245 -7
  91. package/src/scenes.js +404 -0
  92. package/src/shot-authoring.js +246 -77
  93. package/src/shot.js +8 -4
  94. package/src/styles.css +2151 -183
  95. package/src/ui.jsx +54 -5
  96. package/tools/ardy/BRIDGE.md +73 -6
  97. package/tools/ardy/README.md +64 -5
  98. package/tools/ardy/bridge.mjs +146 -390
  99. package/tools/ardy/bvh-cskel27.mjs +1209 -0
  100. package/tools/ardy/cclay_constrained_generate.py +561 -0
  101. package/tools/ardy/cclay_motion_edit.py +74 -9
  102. package/tools/ardy/cclay_sequence_generate.py +117 -7
  103. package/tools/ardy/cclay_worker.py +304 -0
  104. package/tools/ardy/extract.mjs +367 -0
  105. package/tools/ardy/footage.mjs +462 -0
  106. package/tools/ardy/merge-text-encoder.py +160 -0
  107. package/tools/ardy/npz.mjs +74 -9
  108. package/tools/ardy/run-local.mjs +233 -0
  109. package/tools/ardy/run-on-box.sh +25 -0
  110. package/tools/ardy/run-sequence-on-box.sh +15 -0
  111. package/tools/ardy/runners/index.mjs +23 -0
  112. package/tools/ardy/runners/local.mjs +452 -0
  113. package/tools/ardy/runners/proc.mjs +125 -0
  114. package/tools/ardy/runners/remote.mjs +252 -0
  115. package/tools/ardy/setup-local.mjs +189 -0
  116. package/tools/ardy/setup-text-encoder-on-box.sh +93 -0
  117. package/tools/ardy/setup-text-encoder.py +296 -0
  118. package/tools/generation/README.md +29 -0
  119. package/tools/generation/bridge.mjs +149 -0
  120. package/tools/generation/job-store.mjs +51 -0
  121. package/tools/generation/providers/kling.mjs +76 -0
  122. package/tools/generation/providers/runway.mjs +101 -0
  123. package/tools/generation/providers/seedance.mjs +87 -0
  124. package/tools/generation/providers/shared.mjs +49 -0
  125. package/tools/generation/providers/veo.mjs +84 -0
  126. package/tools/metrics/archive-traffic.mjs +138 -0
  127. package/dist/assets/index-BW_S1YRy.js +0 -4395
  128. package/dist/assets/index-nRmmJgap.css +0 -1
  129. package/tools/ardy/__pycache__/cclay_sequence_generate.cpython-313.pyc +0 -0
  130. package/tools/ardy/out/gen-1786443326924-c6019e-generated.npz +0 -0
  131. package/tools/ardy/out/gen-1786443609325-0053db-generated.npz +0 -0
  132. package/tools/ardy/out/gen-1786443835628-749ed1-generated.npz +0 -0
  133. package/tools/ardy/out/gen-1786462605247-03cb19-generated.npz +0 -0
  134. package/tools/qa-browser.mjs +0 -84
  135. package/tools/qa-crop3.mjs +0 -22
  136. package/tools/qa-playview.mjs +0 -49
  137. package/tools/qa-screenshot.mjs +0 -24
  138. package/tools/qa-visual.mjs +0 -51
@@ -0,0 +1,152 @@
1
+ import * as THREE from "three";
2
+ import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader.js";
3
+ import { SkeletonUtils } from "three/examples/jsm/Addons.js";
4
+ import { applyPose, primeBindPose, POSE_BONES } from "./poses.js";
5
+
6
+ /**
7
+ * Pose Studio thumbnails, rendered on demand. The studio's pose entries are
8
+ * pure bone data (no image assets ship), so each tile's preview is generated
9
+ * here: clone the character rig, apply the pose, render one 256px frame with
10
+ * the same clay look as the viewport, and hand back a data URL. Results are
11
+ * cached per model+pose for the session; the FBX itself is fetched once per
12
+ * model (the browser HTTP cache dedupes the studio's own copy).
13
+ */
14
+
15
+ const THUMB_SIZE = 256;
16
+ const BODY_CLAY = "#f2eee6";
17
+
18
+ const modelCache = new Map(); // model id -> Promise<Group>
19
+ const thumbCache = new Map(); // `${model}:${poseId}` -> Promise<dataURL>
20
+
21
+ // Thumbnail renders are SERIALIZED and yield to the browser between tiles:
22
+ // a burst of 16 skinned 165k-vert clones on the main thread freezes the
23
+ // studio open for half a second, so each tile waits for an idle slice.
24
+ let renderQueue = Promise.resolve();
25
+ const idle = () => new Promise((resolve) => {
26
+ if (typeof requestIdleCallback === "function") requestIdleCallback(() => resolve(), { timeout: 120 });
27
+ else setTimeout(resolve, 16);
28
+ });
29
+ function enqueueRender(work) {
30
+ const run = renderQueue.then(async () => {
31
+ await idle();
32
+ return work();
33
+ });
34
+ renderQueue = run.catch(() => {});
35
+ return run;
36
+ }
37
+
38
+ function loadModel(model) {
39
+ if (!modelCache.has(model)) {
40
+ modelCache.set(model, new Promise((resolve, reject) => {
41
+ new FBXLoader().load(`/models/${model}.fbx`, resolve, undefined, reject);
42
+ }));
43
+ }
44
+ return modelCache.get(model);
45
+ }
46
+
47
+ let renderer = null;
48
+ function thumbRenderer() {
49
+ if (renderer) return renderer;
50
+ const canvas = document.createElement("canvas");
51
+ canvas.width = THUMB_SIZE;
52
+ canvas.height = THUMB_SIZE;
53
+ renderer = new THREE.WebGLRenderer({ canvas, antialias: true, preserveDrawingBuffer: true });
54
+ renderer.setSize(THUMB_SIZE, THUMB_SIZE, false);
55
+ return renderer;
56
+ }
57
+
58
+ // One rig per model, RE-POSED per tile: cloning + material traversal per
59
+ // pose was the bulk of the studio-open stall — one clone serves them all.
60
+ const thumbRigCache = new Map(); // model id -> Promise<Group (prepared clone)>
61
+ function thumbRig(model) {
62
+ if (!thumbRigCache.has(model)) {
63
+ thumbRigCache.set(model, loadModel(model).then((fbx) => {
64
+ const rig = SkeletonUtils.clone(fbx);
65
+ rig.scale.setScalar(0.01); // Mixamo exports centimetres
66
+ const jointTint = new THREE.Color(BODY_CLAY).multiplyScalar(0.45);
67
+ rig.traverse((child) => {
68
+ if (child.isMesh) {
69
+ child.material = new THREE.MeshStandardMaterial({
70
+ color: /_Joints$/i.test(child.name) ? jointTint : BODY_CLAY,
71
+ roughness: 0.82,
72
+ metalness: 0,
73
+ });
74
+ child.frustumCulled = false;
75
+ }
76
+ });
77
+ primeBindPose(rig);
78
+ return rig;
79
+ }));
80
+ }
81
+ return thumbRigCache.get(model);
82
+ }
83
+
84
+ function thumbScene() {
85
+ const scene = new THREE.Scene();
86
+ scene.background = new THREE.Color("#101014");
87
+ const hemi = new THREE.HemisphereLight(0xffffff, 0x3a3a40, 1.25);
88
+ const key = new THREE.DirectionalLight(0xffffff, 1.6);
89
+ key.position.set(2.2, 4, 3);
90
+ // A barely-lighter floor so floor poses (seated, kneel) read grounded and
91
+ // air poses (jump) read airborne instead of everyone floating in a void.
92
+ const floor = new THREE.Mesh(
93
+ new THREE.CircleGeometry(6, 48),
94
+ new THREE.MeshStandardMaterial({ color: "#17171d", roughness: 1 })
95
+ );
96
+ floor.rotation.x = -Math.PI / 2;
97
+ scene.add(hemi, key, floor);
98
+ return scene;
99
+ }
100
+
101
+ /** Frame the POSED rig, not a standing mannequin: hands-up, jump and floor
102
+ * poses all leave the fixed framing of a standing figure, so the camera is
103
+ * recomputed from the pose's own bone extents (plus a small margin). */
104
+ function frameCamera(rig) {
105
+ rig.updateMatrixWorld(true);
106
+ const box = new THREE.Box3();
107
+ const point = new THREE.Vector3();
108
+ rig.traverse((object) => {
109
+ if (!object.isBone) return;
110
+ object.getWorldPosition(point);
111
+ box.expandByPoint(point);
112
+ });
113
+ if (box.isEmpty()) box.setFromObject(rig);
114
+ const center = box.getCenter(new THREE.Vector3());
115
+ const size = box.getSize(new THREE.Vector3());
116
+ // Hands and feet sit slightly past their bones; heads a touch more.
117
+ const padded = Math.max(size.x, size.y, size.z) * 0.5 + 0.22;
118
+ const camera = new THREE.PerspectiveCamera(35, 1, 0.01, 50);
119
+ const distance = padded / Math.tan(THREE.MathUtils.degToRad(camera.fov / 2));
120
+ const direction = new THREE.Vector3(0.3, 0.42, 1).normalize();
121
+ camera.position.copy(center).addScaledVector(direction, distance);
122
+ camera.lookAt(center.x, center.y - size.y * 0.04, center.z);
123
+ return camera;
124
+ }
125
+
126
+ /** Preload a rig model during browser idle so the first studio open does
127
+ * not pay the FBX parse in one frame. Fire-and-forget by design. */
128
+ export function warmThumbnailModels(models) {
129
+ for (const model of models) enqueueRender(() => thumbRig(model));
130
+ }
131
+
132
+ /** Render one pose of one rig model to a PNG data URL. */
133
+ export function poseThumbnail(model, pose) {
134
+ const key = `${model}:${pose.id}`;
135
+ if (!thumbCache.has(key)) {
136
+ thumbCache.set(key, enqueueRender(() => thumbRig(model).then((rig) => {
137
+ // Re-pose the shared rig: applyPose writes deltas over the stamped
138
+ // bind pose, so a rest stamp per tile resets the previous pose.
139
+ applyPose(rig, Object.fromEntries(POSE_BONES.map((bone) => [bone.id, [0, 0, 0]])));
140
+ applyPose(rig, pose.bones);
141
+ const scene = thumbScene();
142
+ scene.add(rig);
143
+ const camera = frameCamera(rig);
144
+ const gl = thumbRenderer();
145
+ gl.render(scene, camera);
146
+ const url = gl.domElement.toDataURL("image/png");
147
+ scene.remove(rig);
148
+ return url;
149
+ })));
150
+ }
151
+ return thumbCache.get(key);
152
+ }
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