cozyclay 2.1.1 → 3.0.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 (577) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +12 -30
  3. package/bin/agent/agent-routes.mjs +40 -113
  4. package/bin/agent/agent-runner.mjs +9 -10
  5. package/bin/agent/cliproxy-provider.mjs +135 -0
  6. package/bin/agent/credential-store.mjs +30 -7
  7. package/bin/agent/pi-tools.mjs +4 -1
  8. package/bin/agent/provider-keys.mjs +32 -0
  9. package/bin/agent/provider-login.mjs +110 -0
  10. package/bin/agent/provider-routes.mjs +99 -0
  11. package/bin/agent/providers.mjs +19 -97
  12. package/bin/agent/script-tool.mjs +17 -4
  13. package/bin/agent/studio-motion-reference.mjs +23 -0
  14. package/bin/agent/studio-prompt.mjs +1 -1
  15. package/bin/agent/studio-rebase-text.mjs +32 -0
  16. package/bin/agent/studio-rebase.mjs +26 -39
  17. package/bin/agent/studio-tools.mjs +9 -28
  18. package/bin/agent/tool-arguments.mjs +49 -0
  19. package/bin/agent/turn-frames.mjs +66 -0
  20. package/bin/codex-auth.mjs +9 -2
  21. package/bin/cozyclay.mjs +10 -116
  22. package/bin/live/cli.mjs +3 -3
  23. package/bin/mcp-runtime.mjs +2 -12
  24. package/bin/package-signature.mjs +0 -4
  25. package/dist/app/index.html +7 -6
  26. package/dist/assets/EXRLoader-CvVIvGVE.js +1 -0
  27. package/dist/assets/analytics-C9sUnndd.js +1 -0
  28. package/dist/assets/app-CCh--1Hc.js +5087 -0
  29. package/dist/assets/app-f-fkV5uP.css +1 -0
  30. package/dist/assets/compile-worker-CkxiD6lH.js +5 -0
  31. package/dist/assets/fflate.module-KbGj5-H6.js +5 -0
  32. package/dist/assets/{first-shot-handoff-msLI71g1.js → first-shot-handoff-CC4xe4HM.js} +1 -1
  33. package/dist/assets/{landing-ChUvB_zL.js → landing-DjHD8u7k.js} +1 -1
  34. package/dist/assets/scene-asset-sync-Hx_FzdOH.js +20 -0
  35. package/dist/assets/scene-asset-sync-_S8NQl5B.css +1 -0
  36. package/dist/assets/workflow-C4yKH1p4.js +179 -0
  37. package/dist/cozyclay-package.json +1 -1
  38. package/dist/index.html +3 -3
  39. package/dist/sw.js +3 -6
  40. package/dist/workflow/index.html +5 -4
  41. package/mcp/LIVE-PROTOCOL.md +7 -47
  42. package/mcp/README.md +16 -26
  43. package/mcp/live-hub.mjs +6 -10
  44. package/mcp/package.json +1 -3
  45. package/mcp/tool-handlers.mjs +4 -168
  46. package/package.json +3 -22
  47. package/src/App.jsx +150 -2624
  48. package/src/agent-progress.js +79 -0
  49. package/src/agent-turn-mark.js +30 -0
  50. package/src/analytics.js +1 -19
  51. package/src/app-context.js +5 -0
  52. package/src/app-stage.jsx +2 -34
  53. package/src/asset-pane.jsx +6 -5
  54. package/src/camera-block.js +21 -0
  55. package/src/camera-direction.js +120 -0
  56. package/src/character-kind.js +3 -9
  57. package/src/command-bus.js +8 -6
  58. package/src/commands/cast.js +5 -34
  59. package/src/commands/elements/character.js +1 -1
  60. package/src/commands/elements/motion.js +1 -6
  61. package/src/commands/elements/object.js +6 -2
  62. package/src/commands/elements/shot.js +4 -1
  63. package/src/commands/elements.js +38 -14
  64. package/src/commands/index.js +3 -1
  65. package/src/commands/kits.js +37 -0
  66. package/src/commands/motion-timing.js +57 -0
  67. package/src/commands/motion.js +9 -152
  68. package/src/commands/motion3-compile.js +65 -0
  69. package/src/commands/motion3.js +207 -0
  70. package/src/commands/objects.js +6 -4
  71. package/src/commands/shot.js +49 -11
  72. package/src/commands/stage.js +14 -1
  73. package/src/commands/view.js +4 -1
  74. package/src/document-mirrors.js +42 -0
  75. package/src/document-store.js +4 -0
  76. package/src/domains/cast.js +19 -194
  77. package/src/domains/motion/motion-range-pin-rules.js +1 -1
  78. package/src/domains/motion/take-source.js +51 -0
  79. package/src/domains/motion.js +60 -1838
  80. package/src/domains/scenes.js +12 -55
  81. package/src/domains/shots.js +2 -2
  82. package/src/domains/stage.js +4 -2
  83. package/src/draft-ghost.js +46 -0
  84. package/src/draft-ghost.jsx +129 -0
  85. package/src/dualview.jsx +4 -3
  86. package/src/effects/EffectsLayer.jsx +112 -0
  87. package/src/effects/effect-meshes.js +232 -0
  88. package/src/effects/effect-record.js +103 -0
  89. package/src/effects/emitter.js +59 -0
  90. package/src/effects/simulate.js +261 -0
  91. package/src/effects/state.js +59 -0
  92. package/src/execution-telemetry.js +2 -3
  93. package/src/first-success-guide.jsx +5 -5
  94. package/src/ghost-set.js +257 -0
  95. package/src/held-object-edit.jsx +113 -0
  96. package/src/held-object-pose.js +175 -0
  97. package/src/hierarchy-model.js +1 -1
  98. package/src/hierarchy-panel.jsx +1 -1
  99. package/src/imported-mesh.jsx +103 -0
  100. package/src/kits/held.js +84 -0
  101. package/src/kits/index.js +70 -0
  102. package/src/kits/smoking.js +57 -0
  103. package/src/light-blockers.js +93 -0
  104. package/src/motion/beat-board-model.js +84 -0
  105. package/src/motion/beat-board.css +124 -0
  106. package/src/motion/beat-board.jsx +59 -0
  107. package/src/motion/center-of-mass.js +66 -0
  108. package/src/motion/fix-collisions.js +850 -0
  109. package/src/motion/physics-review.js +118 -0
  110. package/src/{ardy → motion}/physics-support.js +1 -76
  111. package/src/motion/rig-snapshot.js +22 -0
  112. package/src/motion/take-segments.jsx +140 -0
  113. package/src/{ardy → motion}/timeline-coordinates.js +0 -21
  114. package/src/{ardy → motion}/timeline.css +1 -2
  115. package/src/{ardy → motion}/timeline.jsx +42 -413
  116. package/src/motion/waypoints.js +76 -0
  117. package/src/motion3/beats.js +83 -0
  118. package/src/motion3/body.js +158 -0
  119. package/src/motion3/bones.js +47 -0
  120. package/src/motion3/carried.js +47 -0
  121. package/src/motion3/compile-job.js +75 -0
  122. package/src/motion3/compile-worker.js +10 -0
  123. package/src/motion3/compiler/anchors.js +105 -0
  124. package/src/motion3/compiler/arm-orient.js +128 -0
  125. package/src/motion3/compiler/channels.js +125 -0
  126. package/src/motion3/compiler/compile.js +205 -0
  127. package/src/motion3/compiler/gait-rhythm.js +97 -0
  128. package/src/motion3/compiler/grip.js +171 -0
  129. package/src/motion3/compiler/head-steady.js +48 -0
  130. package/src/motion3/compiler/hold.js +134 -0
  131. package/src/motion3/compiler/idle.js +113 -0
  132. package/src/motion3/compiler/limbs.js +170 -0
  133. package/src/motion3/compiler/math.js +72 -0
  134. package/src/motion3/compiler/pose.js +162 -0
  135. package/src/motion3/compiler/quat.js +49 -0
  136. package/src/motion3/compiler/skeleton.js +74 -0
  137. package/src/motion3/compiler/validate-common.js +32 -0
  138. package/src/motion3/compiler/validate-goals.js +118 -0
  139. package/src/motion3/compiler/validate-objects.js +143 -0
  140. package/src/motion3/compiler/validate-parts.js +116 -0
  141. package/src/motion3/compiler/validate.js +122 -0
  142. package/src/motion3/compiler/vocab.js +73 -0
  143. package/src/motion3/compiler/walk-pelvis.js +275 -0
  144. package/src/motion3/compiler/walk.js +207 -0
  145. package/src/motion3/compiler/wrist-clamp.js +32 -0
  146. package/src/motion3/delta.js +47 -0
  147. package/src/motion3/describe.js +174 -0
  148. package/src/motion3/docs.js +27 -0
  149. package/src/motion3/edit-carry.js +21 -0
  150. package/src/motion3/fix/ease.js +16 -0
  151. package/src/motion3/fix/ground.js +37 -0
  152. package/src/motion3/fix/index.js +52 -0
  153. package/src/motion3/fix/push.js +71 -0
  154. package/src/motion3/fix/reach.js +46 -0
  155. package/src/motion3/fix/retime.js +79 -0
  156. package/src/motion3/fix/self.js +211 -0
  157. package/src/motion3/fix/slide.js +70 -0
  158. package/src/motion3/fix/turn.js +51 -0
  159. package/src/motion3/follow.js +39 -0
  160. package/src/motion3/free-motion.js +173 -0
  161. package/src/motion3/grip-choice.js +130 -0
  162. package/src/motion3/hold-plan.js +157 -0
  163. package/src/motion3/json-patch.js +77 -0
  164. package/src/motion3/key-aim.js +105 -0
  165. package/src/motion3/key-edit.js +82 -0
  166. package/src/motion3/lenient.js +127 -0
  167. package/src/motion3/object-keys.js +236 -0
  168. package/src/motion3/object-pose.js +182 -0
  169. package/src/motion3/object-tracks.js +12 -0
  170. package/src/motion3/pipeline.js +102 -0
  171. package/src/motion3/playback.js +51 -0
  172. package/src/motion3/probes.js +91 -0
  173. package/src/motion3/qa/body-checks.js +34 -0
  174. package/src/motion3/qa/check-names.js +14 -0
  175. package/src/motion3/qa/checks.js +121 -0
  176. package/src/motion3/qa/contact-checks.js +51 -0
  177. package/src/motion3/qa/explain.js +80 -0
  178. package/src/motion3/qa/fmt.js +5 -0
  179. package/src/motion3/qa/foot-checks.js +72 -0
  180. package/src/motion3/qa/geometry.js +77 -0
  181. package/src/motion3/qa/goals.js +191 -0
  182. package/src/motion3/qa/ground.js +60 -0
  183. package/src/motion3/qa/hints-contact.js +179 -0
  184. package/src/motion3/qa/hints-goal.js +160 -0
  185. package/src/motion3/qa/hints-knee.js +24 -0
  186. package/src/motion3/qa/hints-motion.js +209 -0
  187. package/src/motion3/qa/hints-object.js +91 -0
  188. package/src/motion3/qa/index.js +42 -0
  189. package/src/motion3/qa/key-checks.js +82 -0
  190. package/src/motion3/qa/near.js +96 -0
  191. package/src/motion3/qa/object-checks.js +135 -0
  192. package/src/motion3/qa/patch.js +161 -0
  193. package/src/motion3/qa/severity.js +38 -0
  194. package/src/motion3/qa/spec-checks.js +65 -0
  195. package/src/motion3/qa/style.js +218 -0
  196. package/src/motion3/qa/wrist-checks.js +69 -0
  197. package/src/motion3/qa/wrist-obs.js +60 -0
  198. package/src/motion3/refs.js +120 -0
  199. package/src/motion3/repair-tune.js +121 -0
  200. package/src/motion3/repair.js +83 -0
  201. package/src/motion3/report.js +67 -0
  202. package/src/motion3/rigs/index.js +14 -0
  203. package/src/motion3/rigs/x-bot-tpose-body.json +1 -0
  204. package/src/motion3/rigs/x-bot-tpose.json +1 -0
  205. package/src/motion3/rigs/y-bot-tpose-body.json +1 -0
  206. package/src/motion3/rigs/y-bot-tpose.json +1 -0
  207. package/src/motion3/scene.js +60 -0
  208. package/src/motion3/schema/brief.js +89 -0
  209. package/src/motion3/schema/fields.js +44 -0
  210. package/src/motion3/schema/spec-examples.js +46 -0
  211. package/src/motion3/schema/topics.js +111 -0
  212. package/src/motion3/schema/types.js +147 -0
  213. package/src/motion3/search.js +117 -0
  214. package/src/motion3/second-hand.js +112 -0
  215. package/src/motion3/skills/basic.js +82 -0
  216. package/src/motion3/skills/book.js +76 -0
  217. package/src/motion3/skills/car.js +145 -0
  218. package/src/motion3/skills/frames-auto.js +29 -0
  219. package/src/motion3/skills/index.js +83 -0
  220. package/src/motion3/skills/info.js +65 -0
  221. package/src/motion3/skills/smoke-kit.js +109 -0
  222. package/src/motion3/skills/smoke.js +160 -0
  223. package/src/motion3/spec-store.js +59 -0
  224. package/src/motion3/take-edit.js +155 -0
  225. package/src/motion3/take.js +63 -0
  226. package/src/motion3/timeline.js +127 -0
  227. package/src/motion3/views.js +121 -0
  228. package/src/motion3/walk-plan.js +119 -0
  229. package/src/object-catalog.jsx +7 -1
  230. package/src/object-colors.js +98 -0
  231. package/src/object-gizmo-parts.js +115 -0
  232. package/src/object-gizmo.jsx +37 -122
  233. package/src/object-glow.js +139 -0
  234. package/src/object-hidden.js +33 -0
  235. package/src/object-look.js +196 -0
  236. package/src/object-size.js +10 -0
  237. package/src/object-travel.js +71 -6
  238. package/src/panels/CameraPanel.jsx +7 -7
  239. package/src/panels/HdrEnvironmentControls.jsx +59 -0
  240. package/src/panels/LightPanel.jsx +25 -4
  241. package/src/panels/ObjectLookPanel.jsx +88 -0
  242. package/src/panels/PosePanel.jsx +2 -17
  243. package/src/panels/RigControlPanel.jsx +5 -53
  244. package/src/panels/SubjectBox.jsx +4 -1
  245. package/src/panels/details.css +14 -0
  246. package/src/posestudio.jsx +4 -27
  247. package/src/project-browser.jsx +3 -4
  248. package/src/project-resources.js +18 -31
  249. package/src/project.js +13 -104
  250. package/src/props.jsx +25 -280
  251. package/src/rail-dot-drag.js +23 -0
  252. package/src/render-passes.js +10 -0
  253. package/src/resource-status.jsx +1 -0
  254. package/src/result-modal.jsx +4 -19
  255. package/src/room.jsx +20 -12
  256. package/src/scene-assets.js +8 -6
  257. package/src/scene-light-place.js +72 -0
  258. package/src/scene-lights.jsx +148 -0
  259. package/src/scene-objects.js +31 -139
  260. package/src/scenes.js +15 -105
  261. package/src/semantic-edit.js +2 -5
  262. package/src/set-pieces.jsx +183 -0
  263. package/src/settings-menu.jsx +3 -11
  264. package/src/shell/BottomDock.jsx +9 -51
  265. package/src/shell/DetailsSlot.jsx +16 -200
  266. package/src/shell/GhostsMenuGroup.jsx +74 -0
  267. package/src/shell/LibrarySlot.jsx +1 -3
  268. package/src/shell/MenuBar.jsx +3 -3
  269. package/src/shell/PreferencesDialog.jsx +15 -264
  270. package/src/shell/PreferencesSlot.jsx +2 -8
  271. package/src/shell/TopBar.jsx +5 -84
  272. package/src/shell/ViewportToolbar.jsx +10 -70
  273. package/src/shell/agent-glass.css +19 -6
  274. package/src/shell/details-selection.js +42 -0
  275. package/src/shell/ghosts-menu.css +22 -0
  276. package/src/shell/glass-regions.css +29 -3
  277. package/src/shell/preferences.css +6 -1
  278. package/src/shot-authoring.js +4 -7
  279. package/src/soft-shadows.js +37 -0
  280. package/src/stage-attach-frames.js +12 -12
  281. package/src/stage-canvas-rigs.jsx +3 -3
  282. package/src/stage-capture.jsx +42 -8
  283. package/src/stage-characters.jsx +22 -216
  284. package/src/stage-editor-gizmos.jsx +6 -6
  285. package/src/stage-environment.js +93 -0
  286. package/src/stage-hdr-builtins.js +107 -0
  287. package/src/stage-hdr-image.js +116 -0
  288. package/src/stage-hdr-library.js +70 -0
  289. package/src/stage-hdr-map.js +94 -0
  290. package/src/stage-hdr.js +130 -0
  291. package/src/stage-lighting.js +149 -0
  292. package/src/stage-occlusion.js +210 -0
  293. package/src/stage-sky.jsx +159 -0
  294. package/src/stage-startup-defaults.js +5 -9
  295. package/src/studio-actions.js +12 -14
  296. package/src/studio-agent-commands.js +19 -16
  297. package/src/studio-agent-motion.js +9 -9
  298. package/src/studio-agent-protocol.js +41 -71
  299. package/src/studio-app-binding.js +25 -45
  300. package/src/studio-asset-list.js +17 -0
  301. package/src/studio-contact-sheet.js +37 -5
  302. package/src/studio-elements.js +27 -7
  303. package/src/studio-entity-bounds.js +18 -0
  304. package/src/studio-error-codes.js +8 -0
  305. package/src/studio-export-framing.js +152 -0
  306. package/src/studio-lighting-check.js +103 -0
  307. package/src/studio-motion-visual.js +150 -0
  308. package/src/studio-schema-errors.js +80 -0
  309. package/src/studio-support-gap.js +74 -0
  310. package/src/styles.css +1 -19
  311. package/src/timeline-defaults.js +5 -0
  312. package/src/timeline-extent.js +8 -20
  313. package/src/tutorial-walk.js +17 -0
  314. package/src/ui-scrub.js +1 -1
  315. package/src/use-shot-camera-tracks.js +12 -0
  316. package/src/view-ghosts.js +97 -0
  317. package/src/view-ghosts.jsx +49 -0
  318. package/src/workflow/AgentPanel.jsx +47 -166
  319. package/src/workflow/AgentProgressCard.jsx +107 -0
  320. package/src/workflow/AgentReplyText.jsx +37 -0
  321. package/src/workflow/AgentTurnSteps.jsx +84 -0
  322. package/src/workflow/LoginPanel.jsx +140 -0
  323. package/src/workflow/WorkflowBuilder.jsx +7 -23
  324. package/src/workflow/agent-client.js +54 -51
  325. package/src/workflow/agent-panel.css +71 -1
  326. package/src/workflow/agent-progress-card.css +167 -0
  327. package/src/workflow/agent-progress-view.js +47 -0
  328. package/src/workflow/agent-turn-steps.css +113 -0
  329. package/src/workflow/agent-turn.js +191 -0
  330. package/src/workflow/login-client.js +34 -0
  331. package/src/workflow/motion-input.js +18 -31
  332. package/src/workflow/node-schema.js +1 -1
  333. package/src/workflow/reply-markdown.js +69 -0
  334. package/src/workflow/scene-asset-sync.js +8 -8
  335. package/tools/agent-session-stats.mjs +61 -0
  336. package/tools/dev-full.mjs +5 -56
  337. package/tools/eslint-baseline.json +12 -13
  338. package/tools/knip-baseline.json +0 -179
  339. package/tools/loc-baseline.json +31 -81
  340. package/tools/motion3/extract-body.mjs +103 -0
  341. package/tools/motion3/extract-rig.mjs +85 -0
  342. package/tools/process-supervisor.mjs +0 -88
  343. package/tools/run-tests.mjs +8 -124
  344. package/bin/agent/motion-runtime.mjs +0 -76
  345. package/dist/ardy/cskel27-rest.json +0 -557
  346. package/dist/assets/analytics-C9pMpW7s.js +0 -1
  347. package/dist/assets/app-B_2XB9rw.css +0 -1
  348. package/dist/assets/app-DAuvKPP8.js +0 -4920
  349. package/dist/assets/config-Bx7pYsD9.js +0 -1
  350. package/dist/assets/config-DeoFTYzb.css +0 -1
  351. package/dist/assets/demo-CvKuBgy5.js +0 -1
  352. package/dist/assets/scene-asset-sync-DKkpjKBV.js +0 -19
  353. package/dist/assets/scene-asset-sync-DjJ_cJ2R.css +0 -1
  354. package/dist/assets/ticket-BPk2Ni95.js +0 -1
  355. package/dist/assets/workflow-jJRBR94Z.js +0 -179
  356. package/dist/demo/walk-then-stop.npz +0 -0
  357. package/mcp/ardy-prompts.mjs +0 -218
  358. package/src/ardy/auto-fix-panel.css +0 -108
  359. package/src/ardy/auto-physics.js +0 -1194
  360. package/src/ardy/client.js +0 -153
  361. package/src/ardy/convert.js +0 -313
  362. package/src/ardy/cskel27-neutral.js +0 -39
  363. package/src/ardy/cskel27.js +0 -77
  364. package/src/ardy/export.js +0 -165
  365. package/src/ardy/fix-collisions.js +0 -2257
  366. package/src/ardy/foot-lock.js +0 -230
  367. package/src/ardy/motion-calibration.js +0 -118
  368. package/src/ardy/motion-edit.js +0 -213
  369. package/src/ardy/motion-url.js +0 -55
  370. package/src/ardy/mp4-duration.js +0 -102
  371. package/src/ardy/npz.js +0 -595
  372. package/src/ardy/physics-panel.css +0 -21
  373. package/src/ardy/physics-panel.jsx +0 -89
  374. package/src/ardy/physics-refine.js +0 -111
  375. package/src/ardy/physics-review.js +0 -567
  376. package/src/ardy/physics-temporal.js +0 -54
  377. package/src/ardy/platform-fit-panel.css +0 -64
  378. package/src/ardy/platform-fit-panel.jsx +0 -41
  379. package/src/ardy/platform-fit.js +0 -326
  380. package/src/ardy/playback.js +0 -711
  381. package/src/ardy/pose-pin.js +0 -97
  382. package/src/ardy/prompt-clips.js +0 -30
  383. package/src/ardy/retime.js +0 -211
  384. package/src/ardy/root-drop.js +0 -369
  385. package/src/ardy/timeline-resize.js +0 -13
  386. package/src/ardy/to-cskel27.js +0 -225
  387. package/src/ardy/trim.js +0 -33
  388. package/src/ardy/waypoints.js +0 -369
  389. package/src/ardy-bridge-contract.js +0 -281
  390. package/src/domains/motion/motion-video-capture.js +0 -664
  391. package/src/i2v-motion-client.js +0 -77
  392. package/src/i2v-motion-studio.jsx +0 -180
  393. package/src/line-edit.js +0 -1348
  394. package/src/motion/generation.js +0 -105
  395. package/src/motion-readiness-ui.jsx +0 -67
  396. package/src/motion-readiness.js +0 -40
  397. package/src/motion-resources.js +0 -177
  398. package/src/motion-store.js +0 -65
  399. package/src/motion-trail.js +0 -601
  400. package/src/multimodel-ingest.js +0 -394
  401. package/src/panels/PromptBlocksPanel.jsx +0 -444
  402. package/src/panels/VideoCapturePanel.jsx +0 -181
  403. package/src/pose-extract/browser.js +0 -42
  404. package/src/pose-extract/detector.js +0 -100
  405. package/src/pose-extract/fit.js +0 -227
  406. package/src/pose-extract/image-frame.js +0 -51
  407. package/src/pose-extract/index.js +0 -58
  408. package/src/pose-extract/keyframes.js +0 -74
  409. package/src/pose-extract/landmarks.js +0 -162
  410. package/src/pose-extract/mirror.js +0 -153
  411. package/src/pose-extract/take.js +0 -131
  412. package/src/pose-extract/video-frames.js +0 -91
  413. package/src/take-recipe.js +0 -165
  414. package/src/trail-key-conflicts.js +0 -39
  415. package/src/trail-pick.js +0 -59
  416. package/src/use-i2v-capture-modal.js +0 -15
  417. package/tools/ardy/BRIDGE.md +0 -37
  418. package/tools/ardy/GVHMR-NPZ.md +0 -68
  419. package/tools/ardy/README.md +0 -124
  420. package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
  421. package/tools/ardy/artifacts.mjs +0 -34
  422. package/tools/ardy/bridge.mjs +0 -1732
  423. package/tools/ardy/bvh-cskel27.mjs +0 -1265
  424. package/tools/ardy/cclay_constrained_generate.py +0 -561
  425. package/tools/ardy/cclay_gvhmr_worker.py +0 -264
  426. package/tools/ardy/cclay_motion_edit.py +0 -510
  427. package/tools/ardy/cclay_sequence_generate.py +0 -705
  428. package/tools/ardy/cclay_worker.py +0 -304
  429. package/tools/ardy/dump-npz.py +0 -205
  430. package/tools/ardy/extract-rest.mjs +0 -299
  431. package/tools/ardy/extract.mjs +0 -507
  432. package/tools/ardy/footage.mjs +0 -467
  433. package/tools/ardy/gvhmr-floor.mjs +0 -102
  434. package/tools/ardy/gvhmr-to-cskel27.mjs +0 -21
  435. package/tools/ardy/gvhmr_fastpath.py +0 -168
  436. package/tools/ardy/gvhmr_trajectory.py +0 -240
  437. package/tools/ardy/merge-text-encoder.py +0 -160
  438. package/tools/ardy/mocap-metrics.mjs +0 -200
  439. package/tools/ardy/mocap-quality-gate.mjs +0 -110
  440. package/tools/ardy/motion-stabilize.mjs +0 -348
  441. package/tools/ardy/npz.mjs +0 -414
  442. package/tools/ardy/pose-to-npz.mjs +0 -106
  443. package/tools/ardy/prompt-limits.mjs +0 -5
  444. package/tools/ardy/run-edit-on-box.sh +0 -73
  445. package/tools/ardy/run-local.mjs +0 -233
  446. package/tools/ardy/run-on-box.sh +0 -593
  447. package/tools/ardy/run-sequence-on-box.sh +0 -177
  448. package/tools/ardy/runners/gvhmr-worker.mjs +0 -206
  449. package/tools/ardy/runners/index.mjs +0 -18
  450. package/tools/ardy/runners/local.mjs +0 -455
  451. package/tools/ardy/runners/proc.mjs +0 -125
  452. package/tools/ardy/runners/remote.mjs +0 -252
  453. package/tools/ardy/setup-local.mjs +0 -189
  454. package/tools/ardy/setup-text-encoder-on-box.sh +0 -93
  455. package/tools/ardy/setup-text-encoder.py +0 -306
  456. package/tools/ardy/smpl-cskel27.mjs +0 -178
  457. package/tools/ardy/visual-qa.mjs +0 -196
  458. package/tools/ardy/vq-car.mjs +0 -52
  459. package/tools/bench/EXP3.md +0 -61
  460. package/tools/bench/cclay_bench_extract_incam.py +0 -125
  461. package/tools/bench/cclay_bench_extract_obs.py +0 -204
  462. package/tools/bench/cclay_bench_runner.py +0 -42
  463. package/tools/bench/cube-contact.mjs +0 -162
  464. package/tools/bench/exp3.mjs +0 -152
  465. package/tools/bench/extract-bench-lib.mjs +0 -216
  466. package/tools/bench/extract-bench.mjs +0 -302
  467. package/tools/bench/fal-generate.mjs +0 -88
  468. package/tools/bench/fit/README.md +0 -189
  469. package/tools/bench/fit/camera.mjs +0 -59
  470. package/tools/bench/fit/contact.mjs +0 -419
  471. package/tools/bench/fit/footlock.mjs +0 -234
  472. package/tools/bench/fit/motion.mjs +0 -85
  473. package/tools/bench/fit/pin.mjs +0 -27
  474. package/tools/bench/fit/remote.mjs +0 -105
  475. package/tools/bench/fit-bench.mjs +0 -126
  476. package/tools/bench/fit-sanity.mjs +0 -45
  477. package/tools/bench/metrics.mjs +0 -313
  478. package/tools/bench/obs/depth.mjs +0 -258
  479. package/tools/bench/obs/extrinsics.mjs +0 -175
  480. package/tools/bench/obs/fit_mannequin_betas.py +0 -340
  481. package/tools/bench/obs/ground.mjs +0 -294
  482. package/tools/bench/obs/heading.mjs +0 -151
  483. package/tools/bench/obs/ladder.mjs +0 -555
  484. package/tools/bench/obs/mannequin-betas.json +0 -124
  485. package/tools/bench/obs/remote.mjs +0 -83
  486. package/tools/bench/obs/rest_joints.py +0 -52
  487. package/tools/bench/obs/ybot-targets.mjs +0 -49
  488. package/tools/bench/obs-bench.mjs +0 -520
  489. package/tools/bench/score.mjs +0 -343
  490. package/tools/bench/summarize.mjs +0 -86
  491. package/tools/demo-worker/README.md +0 -137
  492. package/tools/demo-worker/api-client.mjs +0 -233
  493. package/tools/demo-worker/generate.mjs +0 -301
  494. package/tools/demo-worker/index.mjs +0 -466
  495. package/tools/demo-worker/sign-core.mjs +0 -112
  496. package/tools/demo-worker/sign.mjs +0 -161
  497. package/tools/gt-render/browser.mjs +0 -182
  498. package/tools/gt-render/camera-math.mjs +0 -276
  499. package/tools/gt-render/page.mjs +0 -267
  500. package/tools/gt-render/render.mjs +0 -514
  501. package/tools/gt-render/scene-box.mjs +0 -31
  502. package/tools/gt-render/take-transform.mjs +0 -87
  503. package/tools/kimodo/compare-seam.mjs +0 -108
  504. package/tools/kimodo/constraints.mjs +0 -244
  505. package/tools/kimodo/edit.mjs +0 -259
  506. package/tools/kimodo/effector-constraints.mjs +0 -200
  507. package/tools/kimodo/generate.mjs +0 -646
  508. package/tools/kimodo/local-output.mjs +0 -265
  509. package/tools/kimodo/measure-pose.mjs +0 -65
  510. package/tools/kimodo/measure-preserve.mjs +0 -899
  511. package/tools/kimodo/measure-waypoints.mjs +0 -55
  512. package/tools/kimodo/mlx-generate.py +0 -111
  513. package/tools/kimodo/pose-constraints.mjs +0 -248
  514. package/tools/kimodo/preserve-mask.mjs +0 -543
  515. package/tools/kimodo/read-npz.mjs +0 -189
  516. package/tools/kimodo/run-edit-on-box.mjs +0 -155
  517. package/tools/kimodo/run-sequence-on-box.mjs +0 -178
  518. package/tools/kimodo/runner.mjs +0 -284
  519. package/tools/kimodo/seam-batch.mjs +0 -77
  520. package/tools/kimodo/setup-local.mjs +0 -30
  521. package/tools/kimodo/setup-on-box.sh +0 -339
  522. package/tools/kimodo/soma77-to-cskel27.mjs +0 -305
  523. package/tools/morphgs/assets/gen_truth.py +0 -39
  524. package/tools/morphgs/assets/mesh_ori_rig.txt +0 -27
  525. package/tools/morphgs/assets/playback-check.mjs +0 -30
  526. package/tools/morphgs/demo-gate.sh +0 -26
  527. package/tools/morphgs/fbx2morphgs.mjs +0 -68
  528. package/tools/morphgs/morphgs-to-cskel27.mjs +0 -105
  529. package/tools/morphgs/patches/preprocess_src-none-mode.patch +0 -76
  530. package/tools/morphgs/setup-on-cluster.sh +0 -126
  531. package/tools/projflow/driver.py +0 -1069
  532. package/tools/projflow/generate.mjs +0 -805
  533. package/tools/projflow/hml22-to-cskel27.mjs +0 -735
  534. package/tools/projflow/line-edit-job.mjs +0 -547
  535. package/tools/projflow/replay.mjs +0 -452
  536. package/tools/projflow/runner.mjs +0 -269
  537. package/tools/projflow/service.mjs +0 -742
  538. package/tools/track/DESIGN.md +0 -513
  539. package/tools/track/backfill-provenance.mjs +0 -116
  540. package/tools/track/budget.mjs +0 -8
  541. package/tools/track/check-rig.mjs +0 -209
  542. package/tools/track/diagnostics.schema.json +0 -60
  543. package/tools/track/export-rig.mjs +0 -256
  544. package/tools/track/fallback.mjs +0 -7
  545. package/tools/track/fk-parity-fixture.mjs +0 -161
  546. package/tools/track/gate.mjs +0 -349
  547. package/tools/track/masks.mjs +0 -318
  548. package/tools/track/metrics.mjs +0 -201
  549. package/tools/track/publish-obs.mjs +0 -108
  550. package/tools/track/py/check_env.py +0 -61
  551. package/tools/track/py/eval_lr.py +0 -229
  552. package/tools/track/py/lr_viterbi.py +0 -294
  553. package/tools/track/py/masks.py +0 -405
  554. package/tools/track/py/objective.py +0 -382
  555. package/tools/track/py/rig.py +0 -508
  556. package/tools/track/py/scene.py +0 -326
  557. package/tools/track/py/test_joint_indices.py +0 -123
  558. package/tools/track/py/test_lr_viterbi.py +0 -195
  559. package/tools/track/py/test_masks.py +0 -229
  560. package/tools/track/py/test_rig.py +0 -288
  561. package/tools/track/py/test_scene.py +0 -354
  562. package/tools/track/py/test_track.py +0 -328
  563. package/tools/track/py/track.py +0 -411
  564. package/tools/track/remote.mjs +0 -140
  565. package/tools/track/rig-dump.mjs +0 -227
  566. package/tools/track/run-box-tests.mjs +0 -14
  567. package/tools/track/run-box.mjs +0 -168
  568. package/tools/track/setup-box.sh +0 -59
  569. package/tools/track/study-2d.mjs +0 -728
  570. /package/src/{ardy → motion}/collision-blockers.js +0 -0
  571. /package/src/{ardy → motion}/ground.js +0 -0
  572. /package/src/{ardy → motion}/ik-drag.js +0 -0
  573. /package/src/{ardy → motion}/ik-key-json.js +0 -0
  574. /package/src/{ardy → motion}/ik.js +0 -0
  575. /package/src/{ardy → motion}/physics-surface.js +0 -0
  576. /package/src/{ardy → motion}/playback-clock.js +0 -0
  577. /package/src/{ardy → motion}/range-pin.js +0 -0
@@ -1,161 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * HMAC v1 signing primitives used by the demo worker.
4
- *
5
- * The Worker verifier in workers/api/src/worker-auth.js signs these exact
6
- * canonical bytes:
7
- *
8
- * v1
9
- * worker id
10
- * timestamp (milliseconds)
11
- * nonce
12
- * HTTP method
13
- * request-target path (including query)
14
- * job id
15
- * lease token
16
- * SHA-256(raw body), hexadecimal
17
- *
18
- * Keep this module free of network and filesystem side effects when imported.
19
- * The small CLI at the bottom is deliberately just a convenience for curl.
20
- */
21
-
22
- import { readFileSync } from "node:fs";
23
- import { resolve } from "node:path";
24
- import { fileURLToPath } from "node:url";
25
- import {
26
- bodyBytes,
27
- canonicalBytes,
28
- canonicalString,
29
- digestHex,
30
- randomNonce,
31
- signPayload,
32
- signRequest,
33
- signedHeaders,
34
- toBase64Url,
35
- } from "./sign-core.mjs";
36
-
37
- export {
38
- bodyBytes,
39
- canonicalBytes,
40
- canonicalString,
41
- digestHex,
42
- randomNonce,
43
- signPayload,
44
- signRequest,
45
- signedHeaders,
46
- toBase64Url,
47
- };
48
-
49
- function shellQuote(value) {
50
- return `'${String(value).replaceAll("'", "'\\''")}'`;
51
- }
52
-
53
- function parseCli(argv) {
54
- const result = {
55
- method: null,
56
- path: null,
57
- jobId: "",
58
- leaseToken: "",
59
- bodyFile: null,
60
- ts: undefined,
61
- nonce: undefined,
62
- };
63
- const positional = [];
64
- for (let index = 0; index < argv.length; index += 1) {
65
- const arg = argv[index];
66
- if (!arg.startsWith("-")) {
67
- positional.push(arg);
68
- continue;
69
- }
70
- const take = (name) => {
71
- const value = argv[++index];
72
- if (value === undefined || value.startsWith("--")) throw new Error(`${name} needs a value`);
73
- return value;
74
- };
75
- switch (arg) {
76
- case "--method":
77
- result.method = take(arg);
78
- break;
79
- case "--path":
80
- result.path = take(arg);
81
- break;
82
- case "--job":
83
- case "--job-id":
84
- result.jobId = take(arg);
85
- break;
86
- case "--lease":
87
- case "--lease-token":
88
- result.leaseToken = take(arg);
89
- break;
90
- case "--body-file":
91
- result.bodyFile = take(arg);
92
- break;
93
- case "--ts":
94
- result.ts = Number(take(arg));
95
- if (!Number.isFinite(result.ts)) throw new Error("--ts must be a finite number");
96
- break;
97
- case "--nonce":
98
- result.nonce = take(arg);
99
- break;
100
- case "--help":
101
- case "-h":
102
- throw new Error(
103
- "usage: node tools/demo-worker/sign.mjs <method> <path> [jobId] [leaseToken] [bodyFile]\n" +
104
- " or: node tools/demo-worker/sign.mjs --method GET --path /worker/next [--job id] [--lease token] [--body-file file]",
105
- );
106
- default:
107
- throw new Error(`unknown option ${arg}`);
108
- }
109
- }
110
- if (result.method == null && positional.length > 0) result.method = positional.shift();
111
- if (result.path == null && positional.length > 0) result.path = positional.shift();
112
- if (!result.jobId && positional.length > 0) result.jobId = positional.shift();
113
- if (!result.leaseToken && positional.length > 0) result.leaseToken = positional.shift();
114
- if (!result.bodyFile && positional.length > 0) result.bodyFile = positional.shift();
115
- if (positional.length > 0) throw new Error(`unexpected positional argument ${positional[0]}`);
116
- if (!result.method || !result.path) throw new Error("method and path are required");
117
- return result;
118
- }
119
-
120
- /** Run the CLI and return its exit status; exported for focused tests. */
121
- export function runCli(argv = process.argv.slice(2), env = process.env) {
122
- try {
123
- if (argv.includes("--help") || argv.includes("-h")) {
124
- process.stdout.write(
125
- "usage: node tools/demo-worker/sign.mjs <method> <path> [jobId] [leaseToken] [bodyFile]\n" +
126
- " or: node tools/demo-worker/sign.mjs --method GET --path /worker/next [--job id] [--lease token] [--body-file file]\n",
127
- );
128
- return 0;
129
- }
130
- const options = parseCli(argv);
131
- const secret = env.CC_WORKER_SECRET;
132
- const workerId = env.CC_WORKER_ID;
133
- if (!secret) throw new Error("CC_WORKER_SECRET is required");
134
- if (!workerId) throw new Error("CC_WORKER_ID is required");
135
- const body = options.bodyFile ? readFileSync(resolve(options.bodyFile)) : new Uint8Array();
136
- const headers = signedHeaders({
137
- secret,
138
- workerId,
139
- method: options.method,
140
- path: options.path,
141
- jobId: options.jobId,
142
- leaseToken: options.leaseToken,
143
- body,
144
- ts: options.ts,
145
- nonce: options.nonce,
146
- });
147
- for (const [name, value] of Object.entries(headers)) {
148
- process.stdout.write(`-H ${shellQuote(`${name}: ${value}`)}\n`);
149
- }
150
- return 0;
151
- } catch (error) {
152
- console.error(`demo-worker sign: ${error?.message ?? error}`);
153
- return 2;
154
- }
155
- }
156
-
157
- const thisFile = fileURLToPath(import.meta.url);
158
- if (process.argv[1] && resolve(process.argv[1]) === thisFile) {
159
- process.exitCode = runCli();
160
- }
161
-
@@ -1,182 +0,0 @@
1
- /**
2
- * Headless Chrome + Vite plumbing for the ground-truth renderer (#428).
3
- * Same launch/seed pattern as tools/qa-browser.mjs, but owned by one CLI run:
4
- * every child it starts is terminated on exit or signal.
5
- */
6
- import { existsSync, mkdtempSync, rmSync } from "node:fs";
7
- import { tmpdir } from "node:os";
8
- import { join } from "node:path";
9
- import { spawnOwned, terminateOwned } from "../process-supervisor.mjs";
10
-
11
- const CHROME_CANDIDATES = [
12
- process.env.CHROME_PATH,
13
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
14
- "/usr/bin/google-chrome",
15
- "/usr/bin/chromium",
16
- ].filter(Boolean);
17
-
18
- /** Poll `probe` until it resolves truthy; bounded, fails loudly. */
19
- export async function waitFor(label, probe, { timeoutMs = 60000, intervalMs = 100, child = null } = {}) {
20
- const deadline = Date.now() + timeoutMs;
21
- for (;;) {
22
- if (child && (child.exitCode !== null || child.signalCode !== null)) throw new Error(`${label}: process exited early`);
23
- try {
24
- const value = await probe();
25
- if (value) return value;
26
- } catch {
27
- // not ready yet; retried until the deadline
28
- }
29
- if (Date.now() >= deadline) throw new Error(`${label}: timed out after ${timeoutMs} ms`);
30
- await new Promise((resolve) => setTimeout(resolve, intervalMs));
31
- }
32
- }
33
-
34
- async function portAnswers(url) {
35
- try {
36
- await fetch(url);
37
- return true;
38
- } catch {
39
- return false;
40
- }
41
- }
42
-
43
- /** Start Vite on `port` in `root` unless `url` is given. */
44
- export async function startVite({ root, port, children }) {
45
- const url = `http://127.0.0.1:${port}`;
46
- if (await portAnswers(url)) throw new Error(`port ${port} is already in use; stop it or pass --url to reuse a running server`);
47
- const vite = spawnOwned(process.execPath, [join(root, "node_modules/vite/bin/vite.js"), "--host", "127.0.0.1", "--port", String(port), "--strictPort"], {
48
- cwd: root,
49
- // Point the Studio's live-control socket at an unused port so it can
50
- // never attach to another session's hub (the default is 5184).
51
- env: { ...process.env, COZYCLAY_LIVE_PORT: process.env.COZYCLAY_LIVE_PORT || "5728" },
52
- stdio: ["ignore", "ignore", "inherit"],
53
- });
54
- children.push(vite);
55
- await waitFor("vite startup", async () => (await fetch(`${url}/app/`)).ok, { child: vite });
56
- return url;
57
- }
58
-
59
- export async function startChrome({ port, children, cleanups }) {
60
- const chromePath = CHROME_CANDIDATES.find(existsSync);
61
- if (!chromePath) throw new Error("Google Chrome/Chromium not found; set CHROME_PATH");
62
- const versionUrl = `http://127.0.0.1:${port}/json/version`;
63
- if (await portAnswers(versionUrl)) throw new Error(`CDP port ${port} is already in use`);
64
- const profileDir = mkdtempSync(join(tmpdir(), "cozyclay-gt-render-"));
65
- cleanups.push(() => rmSync(profileDir, { recursive: true, force: true }));
66
- const chrome = spawnOwned(chromePath, [
67
- "--headless=new",
68
- `--remote-debugging-port=${port}`,
69
- `--user-data-dir=${profileDir}`,
70
- "--window-size=1600,1000",
71
- "--no-first-run",
72
- "--no-default-browser-check",
73
- "about:blank",
74
- ], { stdio: ["ignore", "ignore", "ignore"] });
75
- children.push(chrome);
76
- await waitFor("chrome CDP startup", async () => (await fetch(versionUrl)).ok, { child: chrome, timeoutMs: 30000 });
77
- const targets = await (await fetch(`http://127.0.0.1:${port}/json`)).json();
78
- const page = targets.find((target) => target.type === "page" && target.webSocketDebuggerUrl);
79
- if (!page) throw new Error("headless Chrome exposed no page target");
80
- return connect(page.webSocketDebuggerUrl);
81
- }
82
-
83
- /** Minimal CDP client over Node's global WebSocket. */
84
- export async function connect(wsUrl) {
85
- const ws = new WebSocket(wsUrl);
86
- await new Promise((resolve, reject) => {
87
- ws.onopen = resolve;
88
- ws.onerror = () => reject(new Error(`CDP connect failed: ${wsUrl}`));
89
- });
90
- let nextId = 1;
91
- const pending = new Map();
92
- const listeners = new Set();
93
- ws.onmessage = (event) => {
94
- const message = JSON.parse(event.data);
95
- if (message.id && pending.has(message.id)) {
96
- const { resolve, reject } = pending.get(message.id);
97
- pending.delete(message.id);
98
- if (message.error) reject(new Error(`${message.error.message} (${message.error.code})`));
99
- else resolve(message.result);
100
- return;
101
- }
102
- for (const listener of listeners) listener(message);
103
- };
104
- ws.onclose = () => {
105
- for (const { reject } of pending.values()) reject(new Error("CDP connection closed"));
106
- pending.clear();
107
- };
108
- const send = (method, params = {}) => new Promise((resolve, reject) => {
109
- const id = nextId++;
110
- pending.set(id, { resolve, reject });
111
- ws.send(JSON.stringify({ id, method, params }));
112
- });
113
- const evaluate = async (expression) => {
114
- const result = await send("Runtime.evaluate", { expression, awaitPromise: true, returnByValue: true });
115
- if (result.exceptionDetails) {
116
- throw new Error(result.exceptionDetails.exception?.description || result.exceptionDetails.text || "page evaluation failed");
117
- }
118
- return result.result?.value;
119
- };
120
- /** Resolve on the next event `method`; subscribe BEFORE triggering it. */
121
- const once = (method, timeoutMs = 60000) => {
122
- let listener;
123
- let timer;
124
- const promise = new Promise((resolve, reject) => {
125
- listener = (message) => {
126
- if (message.method === method) resolve(message.params);
127
- };
128
- listeners.add(listener);
129
- timer = setTimeout(() => reject(new Error(`${method}: no event within ${timeoutMs} ms`)), timeoutMs);
130
- });
131
- return promise.finally(() => {
132
- listeners.delete(listener);
133
- clearTimeout(timer);
134
- });
135
- };
136
- return { send, evaluate, once, close: () => ws.close() };
137
- }
138
-
139
- /**
140
- * Open the Studio on `studioUrl` with a clean origin: storage wiped (so a
141
- * previous motion's autosaved session cannot come back and mask ?motion=),
142
- * then the project session seeded so the first-run chooser does not open.
143
- */
144
- export async function openStudioClean(cdp, studioUrl) {
145
- const origin = new URL(studioUrl).origin;
146
- await cdp.send("Page.enable");
147
- await cdp.send("Storage.clearDataForOrigin", { origin, storageTypes: "all" });
148
- let loaded = cdp.once("Page.loadEventFired");
149
- await cdp.send("Page.navigate", { url: `${origin}/favicon.ico` });
150
- await loaded;
151
- await cdp.evaluate("localStorage.setItem('cozyclay.project-session.v1', JSON.stringify({ name: 'gt-render', updatedAt: Date.now() }))");
152
- loaded = cdp.once("Page.loadEventFired");
153
- await cdp.send("Page.navigate", { url: studioUrl });
154
- await loaded;
155
- }
156
-
157
- /** Load a portable project into the same Studio that a user opens. The project
158
- * document is seeded before the app bundle runs, so this path exercises the
159
- * real scene store and live-control connection instead of a test renderer. */
160
- export async function openStudioProject(cdp, studioUrl, project) {
161
- const origin = new URL(studioUrl).origin;
162
- if (!project?.scenesDocument || typeof project.scenesDocument !== "object") throw new Error("headless Studio needs a parsed project with scenesDocument");
163
- await cdp.send("Page.enable");
164
- await cdp.send("Storage.clearDataForOrigin", { origin, storageTypes: "all" });
165
- const scenes = JSON.stringify(project.scenesDocument), name = String(project.name || "Headless Project");
166
- const values = [
167
- `localStorage.setItem('cozyclay.scenes.v5', ${JSON.stringify(scenes)})`,
168
- `localStorage.setItem('cozyclay.project-session.v1', ${JSON.stringify(JSON.stringify({ name, previsMode: project.previsMode || "animation", updatedAt: Date.now() }))})`,
169
- project.workflow ? `localStorage.setItem('cozyclay.workflow.v1', ${JSON.stringify(JSON.stringify(project.workflow))})` : null,
170
- project.workspaceLayout ? `localStorage.setItem('cozyclay.workspace-layout.v1', ${JSON.stringify(JSON.stringify(project.workspaceLayout))})` : null,
171
- ].filter(Boolean);
172
- const source = `${values.join("; ")};`;
173
- await cdp.send("Page.addScriptToEvaluateOnNewDocument", { source });
174
- const loaded = cdp.once("Page.loadEventFired");
175
- await cdp.send("Page.navigate", { url: studioUrl });
176
- await loaded;
177
- await waitFor("Studio canvas", async () => cdp.evaluate("Boolean(document.querySelector('canvas'))"), { timeoutMs: 60000 });
178
- }
179
-
180
- export async function terminateAll(children) {
181
- await Promise.allSettled(children.splice(0).reverse().map((child) => terminateOwned(child)));
182
- }
@@ -1,276 +0,0 @@
1
- /**
2
- * Pure camera math for the ground-truth renderer (#428): GVHMR focal
3
- * conversion, Three.js-compatible intrinsics, static camera placement and
4
- * pinhole projection. No DOM, no Three, no I/O, so it is unit-tested under
5
- * Node (test/verify-gt-render-camera.mjs) and `supportValues` is injected
6
- * verbatim into the Studio page by render.mjs.
7
- *
8
- * Conventions (stated once, used everywhere):
9
- * - World: the Studio's Three.js scene. Right-handed, +Y up, metres.
10
- * - Studio camera: Three.js PerspectiveCamera, rotation order "YXZ",
11
- * rotation = (pitch, yaw, 0), looking down its local -Z, local +Y up.
12
- * `R` below is its camera->world rotation Ry(yaw) * Rx(pitch), row-major.
13
- * - Azimuth/elevation place the camera around the subject: azimuth 0 puts it
14
- * on +Z looking toward -Z (the rig's front for a take facing +Z), positive
15
- * azimuth swings it toward +X; positive elevation raises it and tilts it
16
- * down. yaw = azimuth, pitch = -elevation.
17
- * - Image: pixel coordinates are continuous, origin at the top-left corner of
18
- * the top-left pixel, u to the right, v DOWN. Pixel (col, row) covers
19
- * [col, col+1) x [row, row+1); its centre is (col + 0.5, row + 0.5).
20
- * cx = W/2, cy = H/2, square pixels (fx = fy). This is exactly where
21
- * Three's NDC lands after the viewport transform.
22
- * - OpenCV extrinsics: X_cv = R_cv * X_world + t_cv with camera x right,
23
- * y down, z forward; u = fx * X/Z + cx, v = fy * Y/Z + cy.
24
- */
25
-
26
- /** The 35 mm full-frame diagonal GVHMR's `--f-mm` is measured against. */
27
- export const FULL_FRAME_DIAGONAL_MM = Math.hypot(24, 36);
28
-
29
- const DEG = Math.PI / 180;
30
-
31
- /** Focal length in pixels GVHMR derives from `--f-mm` for a W x H video. */
32
- export function gvhmrFocalPx(fMm, width, height) {
33
- return (Math.hypot(width, height) / FULL_FRAME_DIAGONAL_MM) * fMm;
34
- }
35
-
36
- /** Inverse of gvhmrFocalPx (not rounded). */
37
- export function gvhmrFMmFromFocalPx(focalPx, width, height) {
38
- return (focalPx * FULL_FRAME_DIAGONAL_MM) / Math.hypot(width, height);
39
- }
40
-
41
- /** Three's vertical field of view (degrees) that renders with gvhmrFocalPx. */
42
- export function fovDegFromFMm(fMm, width, height) {
43
- return (2 * Math.atan(height / 2 / gvhmrFocalPx(fMm, width, height))) / DEG;
44
- }
45
-
46
- /** Pinhole intrinsics of a Three PerspectiveCamera with vertical `fovDeg`
47
- * rendered at width x height with aspect = width / height. */
48
- export function intrinsicsFromFov({ width, height, fovDeg }) {
49
- const fy = height / 2 / Math.tan((fovDeg * DEG) / 2);
50
- return { width, height, fovDeg, fx: fy, fy, cx: width / 2, cy: height / 2 };
51
- }
52
-
53
- /** Yaw/pitch (radians) and the camera->world rotation for an orbit angle. */
54
- export function orbitRotation(azimuthDeg, elevationDeg) {
55
- const yaw = azimuthDeg * DEG;
56
- const pitch = -elevationDeg * DEG;
57
- return { yaw, pitch, R: rotationYXZ(yaw, pitch) };
58
- }
59
-
60
- /** Ry(yaw) * Rx(pitch), row-major 3x3: the camera->world rotation Three
61
- * builds from Euler(pitch, yaw, 0, "YXZ"). Columns are the camera's x (right),
62
- * y (up) and z (backward) axes in world space. */
63
- export function rotationYXZ(yaw, pitch) {
64
- const cy = Math.cos(yaw);
65
- const sy = Math.sin(yaw);
66
- const cp = Math.cos(pitch);
67
- const sp = Math.sin(pitch);
68
- return [
69
- cy, sy * sp, sy * cp,
70
- 0, cp, -sp,
71
- -sy, cy * sp, cy * cp,
72
- ];
73
- }
74
-
75
- /** Placement slopes: a point at lateral offset x and depth d is inside the
76
- * margin box iff kx * |x| <= d (and likewise ky for y). `margin` is the
77
- * fraction of each image dimension kept clear on every side. */
78
- export function marginSlopes({ fx, fy, width, height }, margin) {
79
- if (!(margin >= 0 && margin < 0.5)) throw new Error(`margin must be in [0, 0.5), got ${margin}`);
80
- return { kx: fx / ((0.5 - margin) * width), ky: fy / ((0.5 - margin) * height) };
81
- }
82
-
83
- /**
84
- * Support values of a point set for the camera solve, in the camera's
85
- * rotated frame p' = R^T * P. Exact reduction: the minimal camera distance
86
- * over any set is a function of these five maxima alone, so the page reduces
87
- * every skinned vertex of a frame to five numbers.
88
- *
89
- * Self-contained on purpose (no outer references): render.mjs injects its
90
- * source into the browser with Function.prototype.toString.
91
- *
92
- * @param {ArrayLike<number>} points flat [x0, y0, z0, x1, ...] in world metres
93
- * @param {number[]} R row-major camera->world rotation
94
- * @returns {{ axp: number, axm: number, ayp: number, aym: number, zmax: number, count: number }}
95
- */
96
- export function supportValues(points, R, kx, ky) {
97
- let axp = -Infinity;
98
- let axm = -Infinity;
99
- let ayp = -Infinity;
100
- let aym = -Infinity;
101
- let zmax = -Infinity;
102
- const count = Math.floor(points.length / 3);
103
- for (let i = 0; i < count; i += 1) {
104
- const x = points[i * 3];
105
- const y = points[i * 3 + 1];
106
- const z = points[i * 3 + 2];
107
- const px = R[0] * x + R[3] * y + R[6] * z;
108
- const py = R[1] * x + R[4] * y + R[7] * z;
109
- const pz = R[2] * x + R[5] * y + R[8] * z;
110
- if (pz + kx * px > axp) axp = pz + kx * px;
111
- if (pz - kx * px > axm) axm = pz - kx * px;
112
- if (pz + ky * py > ayp) ayp = pz + ky * py;
113
- if (pz - ky * py > aym) aym = pz - ky * py;
114
- if (pz > zmax) zmax = pz;
115
- }
116
- return { axp, axm, ayp, aym, zmax, count };
117
- }
118
-
119
- /** Union of support values (the support of the union of the point sets). */
120
- export function mergeSupports(list) {
121
- const out = { axp: -Infinity, axm: -Infinity, ayp: -Infinity, aym: -Infinity, zmax: -Infinity, count: 0 };
122
- for (const s of list) {
123
- for (const key of ["axp", "axm", "ayp", "aym", "zmax"]) out[key] = Math.max(out[key], s[key]);
124
- out.count += s.count;
125
- }
126
- return out;
127
- }
128
-
129
- /**
130
- * The closest static camera with orientation R that keeps every supported
131
- * point inside the margin box. In the rotated frame the camera sits at
132
- * (tx, ty, D); a point p' has depth D - p'z and lateral offset p'x - tx, so
133
- * the box constraint is D >= p'z + kx * |p'x - tx|. Maximised over the set
134
- * that is max(axp - kx*tx, axm + kx*tx), minimised at tx = (axp - axm)/(2kx):
135
- * the extreme points end up symmetric about the image centre.
136
- *
137
- * @returns {{ position: {x,y,z}, rotated: [number, number, number], bindingAxis: "x"|"y"|"depth" }}
138
- */
139
- export function solvePlacement(support, R, { kx, ky }, minDepth = 0.3) {
140
- if (!(support.count > 0)) throw new Error("camera placement needs at least one point");
141
- const tx = (support.axp - support.axm) / (2 * kx);
142
- const ty = (support.ayp - support.aym) / (2 * ky);
143
- const dx = (support.axp + support.axm) / 2;
144
- const dy = (support.ayp + support.aym) / 2;
145
- const dz = support.zmax + minDepth;
146
- const D = Math.max(dx, dy, dz);
147
- const bindingAxis = D === dx ? "x" : D === dy ? "y" : "depth";
148
- const rotated = [tx, ty, D];
149
- return { position: applyRotation(R, rotated), rotated, bindingAxis };
150
- }
151
-
152
- function applyRotation(R, [x, y, z]) {
153
- return {
154
- x: R[0] * x + R[1] * y + R[2] * z,
155
- y: R[3] * x + R[4] * y + R[5] * z,
156
- z: R[6] * x + R[7] * y + R[8] * z,
157
- };
158
- }
159
-
160
- /** OpenCV world->camera 4x4 (row-major): camera x right, y down, z forward. */
161
- export function worldToCameraCv(R, position) {
162
- // R_cv = diag(1, -1, -1) * R^T
163
- const Rcv = [
164
- R[0], R[3], R[6],
165
- -R[1], -R[4], -R[7],
166
- -R[2], -R[5], -R[8],
167
- ];
168
- const t = [0, 1, 2].map((row) => -(Rcv[row * 3] * position.x + Rcv[row * 3 + 1] * position.y + Rcv[row * 3 + 2] * position.z));
169
- return [
170
- [Rcv[0], Rcv[1], Rcv[2], t[0]],
171
- [Rcv[3], Rcv[4], Rcv[5], t[1]],
172
- [Rcv[6], Rcv[7], Rcv[8], t[2]],
173
- [0, 0, 0, 1],
174
- ];
175
- }
176
-
177
- /** Three/OpenGL view matrix (camera.matrixWorldInverse) as row-major 4x4:
178
- * camera x right, y up, looking down -z. */
179
- export function worldToCameraGl(R, position) {
180
- const t = [0, 1, 2].map((col) => -(R[col] * position.x + R[3 + col] * position.y + R[6 + col] * position.z));
181
- return [
182
- [R[0], R[3], R[6], t[0]],
183
- [R[1], R[4], R[7], t[1]],
184
- [R[2], R[5], R[8], t[2]],
185
- [0, 0, 0, 1],
186
- ];
187
- }
188
-
189
- /** Project a world point with a camera record ({ fx, fy, cx, cy,
190
- * worldToCameraCv }). Returns [u, v, depth] in the image convention above;
191
- * depth <= 0 means behind the camera. */
192
- export function projectPoint([x, y, z], camera) {
193
- const M = camera.worldToCameraCv;
194
- const X = M[0][0] * x + M[0][1] * y + M[0][2] * z + M[0][3];
195
- const Y = M[1][0] * x + M[1][1] * y + M[1][2] * z + M[1][3];
196
- const Z = M[2][0] * x + M[2][1] * y + M[2][2] * z + M[2][3];
197
- return [camera.fx * (X / Z) + camera.cx, camera.fy * (Y / Z) + camera.cy, Z];
198
- }
199
-
200
- /**
201
- * Full static camera for a set of support values: intrinsics from an integer
202
- * GVHMR f-mm, orientation from azimuth/elevation, position from the solve.
203
- * The returned record is what camera.json stores.
204
- */
205
- export function buildCamera({ width, height, fMm, azimuthDeg, elevationDeg, margin, support, minDepth = 0.3 }) {
206
- if (!Number.isInteger(fMm) || fMm <= 0) throw new Error(`f-mm must be a positive integer (GVHMR --f-mm), got ${fMm}`);
207
- const fovDeg = fovDegFromFMm(fMm, width, height);
208
- const intrinsics = intrinsicsFromFov({ width, height, fovDeg });
209
- const { yaw, pitch, R } = orbitRotation(azimuthDeg, elevationDeg);
210
- const slopes = marginSlopes(intrinsics, margin);
211
- const placement = solvePlacement(support, R, slopes, minDepth);
212
- return {
213
- ...intrinsics,
214
- gvhmrFMm: fMm,
215
- azimuthDeg,
216
- elevationDeg,
217
- margin,
218
- position: placement.position,
219
- yaw,
220
- pitch,
221
- bindingAxis: placement.bindingAxis,
222
- cameraToWorldRotation: R,
223
- worldToCameraCv: worldToCameraCv(R, placement.position),
224
- worldToCameraGl: worldToCameraGl(R, placement.position),
225
- };
226
- }
227
-
228
- /**
229
- * Rebuild the camera record from a camera.json written by render.mjs, so a
230
- * later render uses that exact camera (--camera). The pose is taken from
231
- * position/yaw/pitch/fovDeg and checked against the stored intrinsics and
232
- * worldToCamera, so a file in another convention is refused, not reinterpreted.
233
- */
234
- export function cameraFromRecord(record) {
235
- const { width, height, fovDeg, position, yaw, pitch } = record ?? {};
236
- const finite = [width, height, fovDeg, yaw, pitch, position?.x, position?.y, position?.z].every(Number.isFinite);
237
- if (!finite) throw new Error("camera.json needs width, height, fovDeg, yaw, pitch and position {x, y, z}");
238
- const intrinsics = intrinsicsFromFov({ width, height, fovDeg });
239
- for (const key of ["fx", "fy", "cx", "cy"]) {
240
- if (record[key] !== undefined && Math.abs(record[key] - intrinsics[key]) > 1e-6) throw new Error(`camera.json ${key} ${record[key]} does not match fovDeg (${intrinsics[key]})`);
241
- }
242
- const R = rotationYXZ(yaw, pitch);
243
- const camera = {
244
- ...intrinsics,
245
- gvhmrFMm: record.gvhmrFMm ?? null,
246
- azimuthDeg: record.azimuthDeg ?? null,
247
- elevationDeg: record.elevationDeg ?? null,
248
- margin: record.margin ?? null,
249
- position: { x: position.x, y: position.y, z: position.z },
250
- yaw,
251
- pitch,
252
- bindingAxis: record.bindingAxis ?? "given",
253
- cameraToWorldRotation: R,
254
- worldToCameraCv: worldToCameraCv(R, position),
255
- worldToCameraGl: worldToCameraGl(R, position),
256
- };
257
- if (record.worldToCamera) {
258
- const gap = Math.max(...record.worldToCamera.flatMap((row, r) => row.map((value, c) => Math.abs(value - camera.worldToCameraCv[r][c]))));
259
- if (!(gap <= 1e-9)) throw new Error(`camera.json worldToCamera differs from its position/yaw/pitch by ${gap}`);
260
- }
261
- return camera;
262
- }
263
-
264
- /** The same camera moved by `offset` (world metres); orientation unchanged. */
265
- export function translateCamera(camera, offset) {
266
- const position = { x: camera.position.x + offset.x, y: camera.position.y + offset.y, z: camera.position.z + offset.z };
267
- const R = camera.cameraToWorldRotation;
268
- return { ...camera, position, worldToCameraCv: worldToCameraCv(R, position), worldToCameraGl: worldToCameraGl(R, position) };
269
- }
270
-
271
- /** The minimal support-value arguments a caller needs for a camera orientation. */
272
- export function supportArgs({ width, height, fMm, azimuthDeg, elevationDeg, margin }) {
273
- const intrinsics = intrinsicsFromFov({ width, height, fovDeg: fovDegFromFMm(fMm, width, height) });
274
- const { R } = orbitRotation(azimuthDeg, elevationDeg);
275
- return { R, ...marginSlopes(intrinsics, margin) };
276
- }