cozyclay 2.1.0 → 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 (583) hide show
  1. package/CHANGELOG.md +65 -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 +22 -6
  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-BlT33CGf.js → first-shot-handoff-CC4xe4HM.js} +1 -1
  33. package/dist/assets/{landing-BSesrCpL.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/llms.txt +14 -0
  40. package/dist/sw.js +3 -6
  41. package/dist/workflow/index.html +5 -4
  42. package/mcp/LIVE-PROTOCOL.md +7 -47
  43. package/mcp/README.md +16 -26
  44. package/mcp/live-hub.mjs +6 -10
  45. package/mcp/package.json +1 -3
  46. package/mcp/tool-handlers.mjs +4 -168
  47. package/package.json +3 -22
  48. package/src/App.jsx +174 -2639
  49. package/src/agent-progress.js +79 -0
  50. package/src/agent-turn-mark.js +30 -0
  51. package/src/analytics.js +1 -19
  52. package/src/app-context.js +5 -0
  53. package/src/app-stage.jsx +2 -34
  54. package/src/asset-pane.jsx +6 -5
  55. package/src/camera-block.js +21 -0
  56. package/src/camera-direction.js +120 -0
  57. package/src/character-kind.js +3 -9
  58. package/src/command-bus.js +8 -6
  59. package/src/commands/cast.js +5 -34
  60. package/src/commands/elements/character.js +1 -1
  61. package/src/commands/elements/motion.js +1 -6
  62. package/src/commands/elements/object.js +6 -2
  63. package/src/commands/elements/shot.js +4 -1
  64. package/src/commands/elements.js +38 -14
  65. package/src/commands/index.js +3 -1
  66. package/src/commands/kits.js +37 -0
  67. package/src/commands/motion-timing.js +57 -0
  68. package/src/commands/motion.js +9 -152
  69. package/src/commands/motion3-compile.js +65 -0
  70. package/src/commands/motion3.js +207 -0
  71. package/src/commands/objects.js +6 -4
  72. package/src/commands/shot.js +49 -11
  73. package/src/commands/stage.js +14 -1
  74. package/src/commands/view.js +4 -1
  75. package/src/document-mirrors.js +42 -0
  76. package/src/document-store.js +4 -0
  77. package/src/domains/cast.js +19 -194
  78. package/src/domains/motion/motion-range-pin-rules.js +1 -1
  79. package/src/domains/motion/take-source.js +51 -0
  80. package/src/domains/motion.js +60 -1838
  81. package/src/domains/scenes.js +12 -55
  82. package/src/domains/shots.js +2 -2
  83. package/src/domains/stage.js +4 -2
  84. package/src/draft-ghost.js +46 -0
  85. package/src/draft-ghost.jsx +129 -0
  86. package/src/dualview.jsx +4 -3
  87. package/src/effects/EffectsLayer.jsx +112 -0
  88. package/src/effects/effect-meshes.js +232 -0
  89. package/src/effects/effect-record.js +103 -0
  90. package/src/effects/emitter.js +59 -0
  91. package/src/effects/simulate.js +261 -0
  92. package/src/effects/state.js +59 -0
  93. package/src/execution-telemetry.js +2 -3
  94. package/src/first-success-guide.jsx +5 -5
  95. package/src/ghost-set.js +257 -0
  96. package/src/held-object-edit.jsx +113 -0
  97. package/src/held-object-pose.js +175 -0
  98. package/src/hierarchy-model.js +1 -1
  99. package/src/hierarchy-panel.jsx +1 -1
  100. package/src/imported-mesh.jsx +103 -0
  101. package/src/kits/held.js +84 -0
  102. package/src/kits/index.js +70 -0
  103. package/src/kits/smoking.js +57 -0
  104. package/src/light-blockers.js +93 -0
  105. package/src/motion/beat-board-model.js +84 -0
  106. package/src/motion/beat-board.css +124 -0
  107. package/src/motion/beat-board.jsx +59 -0
  108. package/src/motion/center-of-mass.js +66 -0
  109. package/src/motion/fix-collisions.js +850 -0
  110. package/src/motion/physics-review.js +118 -0
  111. package/src/{ardy → motion}/physics-support.js +1 -76
  112. package/src/motion/rig-snapshot.js +22 -0
  113. package/src/motion/take-segments.jsx +140 -0
  114. package/src/{ardy → motion}/timeline-coordinates.js +0 -21
  115. package/src/{ardy → motion}/timeline.css +1 -2
  116. package/src/{ardy → motion}/timeline.jsx +48 -419
  117. package/src/motion/waypoints.js +76 -0
  118. package/src/motion3/beats.js +83 -0
  119. package/src/motion3/body.js +158 -0
  120. package/src/motion3/bones.js +47 -0
  121. package/src/motion3/carried.js +47 -0
  122. package/src/motion3/compile-job.js +75 -0
  123. package/src/motion3/compile-worker.js +10 -0
  124. package/src/motion3/compiler/anchors.js +105 -0
  125. package/src/motion3/compiler/arm-orient.js +128 -0
  126. package/src/motion3/compiler/channels.js +125 -0
  127. package/src/motion3/compiler/compile.js +205 -0
  128. package/src/motion3/compiler/gait-rhythm.js +97 -0
  129. package/src/motion3/compiler/grip.js +171 -0
  130. package/src/motion3/compiler/head-steady.js +48 -0
  131. package/src/motion3/compiler/hold.js +134 -0
  132. package/src/motion3/compiler/idle.js +113 -0
  133. package/src/motion3/compiler/limbs.js +170 -0
  134. package/src/motion3/compiler/math.js +72 -0
  135. package/src/motion3/compiler/pose.js +162 -0
  136. package/src/motion3/compiler/quat.js +49 -0
  137. package/src/motion3/compiler/skeleton.js +74 -0
  138. package/src/motion3/compiler/validate-common.js +32 -0
  139. package/src/motion3/compiler/validate-goals.js +118 -0
  140. package/src/motion3/compiler/validate-objects.js +143 -0
  141. package/src/motion3/compiler/validate-parts.js +116 -0
  142. package/src/motion3/compiler/validate.js +122 -0
  143. package/src/motion3/compiler/vocab.js +73 -0
  144. package/src/motion3/compiler/walk-pelvis.js +275 -0
  145. package/src/motion3/compiler/walk.js +207 -0
  146. package/src/motion3/compiler/wrist-clamp.js +32 -0
  147. package/src/motion3/delta.js +47 -0
  148. package/src/motion3/describe.js +174 -0
  149. package/src/motion3/docs.js +27 -0
  150. package/src/motion3/edit-carry.js +21 -0
  151. package/src/motion3/fix/ease.js +16 -0
  152. package/src/motion3/fix/ground.js +37 -0
  153. package/src/motion3/fix/index.js +52 -0
  154. package/src/motion3/fix/push.js +71 -0
  155. package/src/motion3/fix/reach.js +46 -0
  156. package/src/motion3/fix/retime.js +79 -0
  157. package/src/motion3/fix/self.js +211 -0
  158. package/src/motion3/fix/slide.js +70 -0
  159. package/src/motion3/fix/turn.js +51 -0
  160. package/src/motion3/follow.js +39 -0
  161. package/src/motion3/free-motion.js +173 -0
  162. package/src/motion3/grip-choice.js +130 -0
  163. package/src/motion3/hold-plan.js +157 -0
  164. package/src/motion3/json-patch.js +77 -0
  165. package/src/motion3/key-aim.js +105 -0
  166. package/src/motion3/key-edit.js +82 -0
  167. package/src/motion3/lenient.js +127 -0
  168. package/src/motion3/object-keys.js +236 -0
  169. package/src/motion3/object-pose.js +182 -0
  170. package/src/motion3/object-tracks.js +12 -0
  171. package/src/motion3/pipeline.js +102 -0
  172. package/src/motion3/playback.js +51 -0
  173. package/src/motion3/probes.js +91 -0
  174. package/src/motion3/qa/body-checks.js +34 -0
  175. package/src/motion3/qa/check-names.js +14 -0
  176. package/src/motion3/qa/checks.js +121 -0
  177. package/src/motion3/qa/contact-checks.js +51 -0
  178. package/src/motion3/qa/explain.js +80 -0
  179. package/src/motion3/qa/fmt.js +5 -0
  180. package/src/motion3/qa/foot-checks.js +72 -0
  181. package/src/motion3/qa/geometry.js +77 -0
  182. package/src/motion3/qa/goals.js +191 -0
  183. package/src/motion3/qa/ground.js +60 -0
  184. package/src/motion3/qa/hints-contact.js +179 -0
  185. package/src/motion3/qa/hints-goal.js +160 -0
  186. package/src/motion3/qa/hints-knee.js +24 -0
  187. package/src/motion3/qa/hints-motion.js +209 -0
  188. package/src/motion3/qa/hints-object.js +91 -0
  189. package/src/motion3/qa/index.js +42 -0
  190. package/src/motion3/qa/key-checks.js +82 -0
  191. package/src/motion3/qa/near.js +96 -0
  192. package/src/motion3/qa/object-checks.js +135 -0
  193. package/src/motion3/qa/patch.js +161 -0
  194. package/src/motion3/qa/severity.js +38 -0
  195. package/src/motion3/qa/spec-checks.js +65 -0
  196. package/src/motion3/qa/style.js +218 -0
  197. package/src/motion3/qa/wrist-checks.js +69 -0
  198. package/src/motion3/qa/wrist-obs.js +60 -0
  199. package/src/motion3/refs.js +120 -0
  200. package/src/motion3/repair-tune.js +121 -0
  201. package/src/motion3/repair.js +83 -0
  202. package/src/motion3/report.js +67 -0
  203. package/src/motion3/rigs/index.js +14 -0
  204. package/src/motion3/rigs/x-bot-tpose-body.json +1 -0
  205. package/src/motion3/rigs/x-bot-tpose.json +1 -0
  206. package/src/motion3/rigs/y-bot-tpose-body.json +1 -0
  207. package/src/motion3/rigs/y-bot-tpose.json +1 -0
  208. package/src/motion3/scene.js +60 -0
  209. package/src/motion3/schema/brief.js +89 -0
  210. package/src/motion3/schema/fields.js +44 -0
  211. package/src/motion3/schema/spec-examples.js +46 -0
  212. package/src/motion3/schema/topics.js +111 -0
  213. package/src/motion3/schema/types.js +147 -0
  214. package/src/motion3/search.js +117 -0
  215. package/src/motion3/second-hand.js +112 -0
  216. package/src/motion3/skills/basic.js +82 -0
  217. package/src/motion3/skills/book.js +76 -0
  218. package/src/motion3/skills/car.js +145 -0
  219. package/src/motion3/skills/frames-auto.js +29 -0
  220. package/src/motion3/skills/index.js +83 -0
  221. package/src/motion3/skills/info.js +65 -0
  222. package/src/motion3/skills/smoke-kit.js +109 -0
  223. package/src/motion3/skills/smoke.js +160 -0
  224. package/src/motion3/spec-store.js +59 -0
  225. package/src/motion3/take-edit.js +155 -0
  226. package/src/motion3/take.js +63 -0
  227. package/src/motion3/timeline.js +127 -0
  228. package/src/motion3/views.js +121 -0
  229. package/src/motion3/walk-plan.js +119 -0
  230. package/src/object-catalog.jsx +7 -1
  231. package/src/object-colors.js +98 -0
  232. package/src/object-gizmo-parts.js +115 -0
  233. package/src/object-gizmo.jsx +37 -122
  234. package/src/object-glow.js +139 -0
  235. package/src/object-hidden.js +33 -0
  236. package/src/object-look.js +196 -0
  237. package/src/object-size.js +10 -0
  238. package/src/object-travel.js +71 -6
  239. package/src/panels/CameraPanel.jsx +7 -7
  240. package/src/panels/HdrEnvironmentControls.jsx +59 -0
  241. package/src/panels/LightPanel.jsx +25 -4
  242. package/src/panels/ObjectLookPanel.jsx +88 -0
  243. package/src/panels/PoseImagePanel.jsx +1 -1
  244. package/src/panels/PosePanel.jsx +2 -17
  245. package/src/panels/RigControlPanel.jsx +5 -53
  246. package/src/panels/SubjectBox.jsx +4 -1
  247. package/src/panels/details.css +14 -0
  248. package/src/posestudio.jsx +4 -27
  249. package/src/project-browser.jsx +3 -4
  250. package/src/project-resources.js +18 -31
  251. package/src/project.js +13 -104
  252. package/src/props.jsx +25 -280
  253. package/src/rail-dot-drag.js +23 -0
  254. package/src/render-passes.js +10 -0
  255. package/src/resource-status.jsx +1 -0
  256. package/src/result-modal.jsx +4 -19
  257. package/src/room.jsx +20 -12
  258. package/src/scene-assets.js +8 -6
  259. package/src/scene-light-place.js +72 -0
  260. package/src/scene-lights.jsx +148 -0
  261. package/src/scene-objects.js +31 -139
  262. package/src/scenes.js +15 -105
  263. package/src/semantic-edit.js +2 -5
  264. package/src/set-pieces.jsx +183 -0
  265. package/src/settings-menu.jsx +3 -11
  266. package/src/shell/BottomDock.jsx +11 -53
  267. package/src/shell/CompositionGuideButton.jsx +20 -0
  268. package/src/shell/DetailsSlot.jsx +16 -200
  269. package/src/shell/GhostsMenuGroup.jsx +74 -0
  270. package/src/shell/LibrarySlot.jsx +1 -3
  271. package/src/shell/MenuBar.jsx +3 -3
  272. package/src/shell/PreferencesDialog.jsx +15 -264
  273. package/src/shell/PreferencesSlot.jsx +2 -8
  274. package/src/shell/ShotPreviewHeader.jsx +17 -0
  275. package/src/shell/TopBar.jsx +5 -83
  276. package/src/shell/ViewportToolbar.jsx +23 -93
  277. package/src/shell/agent-glass.css +19 -6
  278. package/src/shell/details-selection.js +42 -0
  279. package/src/shell/ghosts-menu.css +22 -0
  280. package/src/shell/glass-regions.css +29 -3
  281. package/src/shell/preferences.css +6 -1
  282. package/src/shell/viewport.css +12 -0
  283. package/src/shot-authoring.js +4 -7
  284. package/src/soft-shadows.js +37 -0
  285. package/src/stage-attach-frames.js +12 -12
  286. package/src/stage-canvas-rigs.jsx +3 -3
  287. package/src/stage-capture.jsx +42 -8
  288. package/src/stage-characters.jsx +22 -216
  289. package/src/stage-editor-gizmos.jsx +6 -6
  290. package/src/stage-environment.js +93 -0
  291. package/src/stage-hdr-builtins.js +107 -0
  292. package/src/stage-hdr-image.js +116 -0
  293. package/src/stage-hdr-library.js +70 -0
  294. package/src/stage-hdr-map.js +94 -0
  295. package/src/stage-hdr.js +130 -0
  296. package/src/stage-lighting.js +149 -0
  297. package/src/stage-occlusion.js +210 -0
  298. package/src/stage-sky.jsx +159 -0
  299. package/src/stage-startup-defaults.js +5 -9
  300. package/src/studio-actions.js +12 -14
  301. package/src/studio-agent-commands.js +46 -16
  302. package/src/studio-agent-motion.js +9 -9
  303. package/src/studio-agent-protocol.js +46 -73
  304. package/src/studio-app-binding.js +29 -45
  305. package/src/studio-asset-list.js +17 -0
  306. package/src/studio-contact-sheet.js +37 -5
  307. package/src/studio-elements.js +27 -7
  308. package/src/studio-entity-bounds.js +18 -0
  309. package/src/studio-error-codes.js +8 -0
  310. package/src/studio-export-framing.js +152 -0
  311. package/src/studio-lighting-check.js +103 -0
  312. package/src/studio-motion-visual.js +150 -0
  313. package/src/studio-schema-errors.js +80 -0
  314. package/src/studio-support-gap.js +74 -0
  315. package/src/styles.css +1 -19
  316. package/src/timeline-defaults.js +5 -0
  317. package/src/timeline-extent.js +8 -20
  318. package/src/tutorial-walk.js +17 -0
  319. package/src/ui-scrub.js +1 -1
  320. package/src/use-shot-camera-tracks.js +12 -0
  321. package/src/view-ghosts.js +97 -0
  322. package/src/view-ghosts.jsx +49 -0
  323. package/src/workflow/AgentPanel.jsx +47 -166
  324. package/src/workflow/AgentProgressCard.jsx +107 -0
  325. package/src/workflow/AgentReplyText.jsx +37 -0
  326. package/src/workflow/AgentTurnSteps.jsx +84 -0
  327. package/src/workflow/LoginPanel.jsx +140 -0
  328. package/src/workflow/WorkflowBuilder.jsx +7 -23
  329. package/src/workflow/agent-client.js +54 -51
  330. package/src/workflow/agent-panel.css +71 -1
  331. package/src/workflow/agent-progress-card.css +167 -0
  332. package/src/workflow/agent-progress-view.js +47 -0
  333. package/src/workflow/agent-turn-steps.css +113 -0
  334. package/src/workflow/agent-turn.js +191 -0
  335. package/src/workflow/login-client.js +34 -0
  336. package/src/workflow/motion-input.js +18 -31
  337. package/src/workflow/node-schema.js +1 -1
  338. package/src/workflow/reply-markdown.js +69 -0
  339. package/src/workflow/scene-asset-sync.js +8 -8
  340. package/tools/agent-session-stats.mjs +61 -0
  341. package/tools/dev-full.mjs +5 -56
  342. package/tools/eslint-baseline.json +12 -13
  343. package/tools/headless-studio.mjs +85 -0
  344. package/tools/knip-baseline.json +0 -179
  345. package/tools/loc-baseline.json +33 -83
  346. package/tools/motion3/extract-body.mjs +103 -0
  347. package/tools/motion3/extract-rig.mjs +85 -0
  348. package/tools/process-supervisor.mjs +0 -88
  349. package/tools/run-tests.mjs +9 -124
  350. package/bin/agent/motion-runtime.mjs +0 -76
  351. package/dist/ardy/cskel27-rest.json +0 -557
  352. package/dist/assets/analytics-B41FmPYI.js +0 -1
  353. package/dist/assets/app-Do-Og5Pu.css +0 -1
  354. package/dist/assets/app-DwP-tl2x.js +0 -4920
  355. package/dist/assets/config-Bx7pYsD9.js +0 -1
  356. package/dist/assets/config-DeoFTYzb.css +0 -1
  357. package/dist/assets/demo-Dt0qZfS7.js +0 -1
  358. package/dist/assets/scene-asset-sync-BCWDJB1d.js +0 -19
  359. package/dist/assets/scene-asset-sync-DjJ_cJ2R.css +0 -1
  360. package/dist/assets/ticket-jqMhqL88.js +0 -1
  361. package/dist/assets/workflow-Br-K7Srs.js +0 -179
  362. package/dist/demo/walk-then-stop.npz +0 -0
  363. package/mcp/ardy-prompts.mjs +0 -218
  364. package/src/ardy/auto-fix-panel.css +0 -108
  365. package/src/ardy/auto-physics.js +0 -1194
  366. package/src/ardy/client.js +0 -153
  367. package/src/ardy/convert.js +0 -313
  368. package/src/ardy/cskel27-neutral.js +0 -39
  369. package/src/ardy/cskel27.js +0 -77
  370. package/src/ardy/export.js +0 -165
  371. package/src/ardy/fix-collisions.js +0 -2257
  372. package/src/ardy/foot-lock.js +0 -230
  373. package/src/ardy/motion-calibration.js +0 -118
  374. package/src/ardy/motion-edit.js +0 -213
  375. package/src/ardy/motion-url.js +0 -55
  376. package/src/ardy/mp4-duration.js +0 -102
  377. package/src/ardy/npz.js +0 -595
  378. package/src/ardy/physics-panel.css +0 -21
  379. package/src/ardy/physics-panel.jsx +0 -89
  380. package/src/ardy/physics-refine.js +0 -111
  381. package/src/ardy/physics-review.js +0 -567
  382. package/src/ardy/physics-temporal.js +0 -54
  383. package/src/ardy/platform-fit-panel.css +0 -64
  384. package/src/ardy/platform-fit-panel.jsx +0 -41
  385. package/src/ardy/platform-fit.js +0 -326
  386. package/src/ardy/playback.js +0 -711
  387. package/src/ardy/pose-pin.js +0 -97
  388. package/src/ardy/prompt-clips.js +0 -30
  389. package/src/ardy/retime.js +0 -211
  390. package/src/ardy/root-drop.js +0 -369
  391. package/src/ardy/timeline-resize.js +0 -13
  392. package/src/ardy/to-cskel27.js +0 -225
  393. package/src/ardy/trim.js +0 -33
  394. package/src/ardy/waypoints.js +0 -369
  395. package/src/ardy-bridge-contract.js +0 -281
  396. package/src/domains/motion/motion-video-capture.js +0 -664
  397. package/src/i2v-motion-client.js +0 -77
  398. package/src/i2v-motion-studio.jsx +0 -180
  399. package/src/line-edit.js +0 -1348
  400. package/src/motion/generation.js +0 -105
  401. package/src/motion-readiness-ui.jsx +0 -67
  402. package/src/motion-readiness.js +0 -40
  403. package/src/motion-resources.js +0 -177
  404. package/src/motion-store.js +0 -65
  405. package/src/motion-trail.js +0 -601
  406. package/src/multimodel-ingest.js +0 -394
  407. package/src/panels/PromptBlocksPanel.jsx +0 -444
  408. package/src/panels/VideoCapturePanel.jsx +0 -181
  409. package/src/pose-extract/browser.js +0 -42
  410. package/src/pose-extract/detector.js +0 -100
  411. package/src/pose-extract/fit.js +0 -227
  412. package/src/pose-extract/image-frame.js +0 -51
  413. package/src/pose-extract/index.js +0 -58
  414. package/src/pose-extract/keyframes.js +0 -74
  415. package/src/pose-extract/landmarks.js +0 -162
  416. package/src/pose-extract/mirror.js +0 -153
  417. package/src/pose-extract/take.js +0 -131
  418. package/src/pose-extract/video-frames.js +0 -91
  419. package/src/take-recipe.js +0 -165
  420. package/src/trail-key-conflicts.js +0 -39
  421. package/src/trail-pick.js +0 -59
  422. package/src/use-i2v-capture-modal.js +0 -15
  423. package/tools/ardy/BRIDGE.md +0 -37
  424. package/tools/ardy/GVHMR-NPZ.md +0 -68
  425. package/tools/ardy/README.md +0 -124
  426. package/tools/ardy/__pycache__/cclay_gvhmr_worker.cpython-313.pyc +0 -0
  427. package/tools/ardy/artifacts.mjs +0 -34
  428. package/tools/ardy/bridge.mjs +0 -1732
  429. package/tools/ardy/bvh-cskel27.mjs +0 -1265
  430. package/tools/ardy/cclay_constrained_generate.py +0 -561
  431. package/tools/ardy/cclay_gvhmr_worker.py +0 -264
  432. package/tools/ardy/cclay_motion_edit.py +0 -510
  433. package/tools/ardy/cclay_sequence_generate.py +0 -705
  434. package/tools/ardy/cclay_worker.py +0 -304
  435. package/tools/ardy/dump-npz.py +0 -205
  436. package/tools/ardy/extract-rest.mjs +0 -299
  437. package/tools/ardy/extract.mjs +0 -507
  438. package/tools/ardy/footage.mjs +0 -467
  439. package/tools/ardy/gvhmr-floor.mjs +0 -102
  440. package/tools/ardy/gvhmr-to-cskel27.mjs +0 -21
  441. package/tools/ardy/gvhmr_fastpath.py +0 -168
  442. package/tools/ardy/gvhmr_trajectory.py +0 -240
  443. package/tools/ardy/merge-text-encoder.py +0 -160
  444. package/tools/ardy/mocap-metrics.mjs +0 -200
  445. package/tools/ardy/mocap-quality-gate.mjs +0 -110
  446. package/tools/ardy/motion-stabilize.mjs +0 -348
  447. package/tools/ardy/npz.mjs +0 -414
  448. package/tools/ardy/pose-to-npz.mjs +0 -106
  449. package/tools/ardy/prompt-limits.mjs +0 -5
  450. package/tools/ardy/run-edit-on-box.sh +0 -73
  451. package/tools/ardy/run-local.mjs +0 -233
  452. package/tools/ardy/run-on-box.sh +0 -593
  453. package/tools/ardy/run-sequence-on-box.sh +0 -177
  454. package/tools/ardy/runners/gvhmr-worker.mjs +0 -206
  455. package/tools/ardy/runners/index.mjs +0 -18
  456. package/tools/ardy/runners/local.mjs +0 -455
  457. package/tools/ardy/runners/proc.mjs +0 -125
  458. package/tools/ardy/runners/remote.mjs +0 -252
  459. package/tools/ardy/setup-local.mjs +0 -189
  460. package/tools/ardy/setup-text-encoder-on-box.sh +0 -93
  461. package/tools/ardy/setup-text-encoder.py +0 -306
  462. package/tools/ardy/smpl-cskel27.mjs +0 -178
  463. package/tools/ardy/visual-qa.mjs +0 -196
  464. package/tools/ardy/vq-car.mjs +0 -52
  465. package/tools/bench/EXP3.md +0 -61
  466. package/tools/bench/cclay_bench_extract_incam.py +0 -125
  467. package/tools/bench/cclay_bench_extract_obs.py +0 -204
  468. package/tools/bench/cclay_bench_runner.py +0 -42
  469. package/tools/bench/cube-contact.mjs +0 -162
  470. package/tools/bench/exp3.mjs +0 -152
  471. package/tools/bench/extract-bench-lib.mjs +0 -216
  472. package/tools/bench/extract-bench.mjs +0 -302
  473. package/tools/bench/fal-generate.mjs +0 -88
  474. package/tools/bench/fit/README.md +0 -189
  475. package/tools/bench/fit/camera.mjs +0 -59
  476. package/tools/bench/fit/contact.mjs +0 -419
  477. package/tools/bench/fit/footlock.mjs +0 -234
  478. package/tools/bench/fit/motion.mjs +0 -85
  479. package/tools/bench/fit/pin.mjs +0 -27
  480. package/tools/bench/fit/remote.mjs +0 -105
  481. package/tools/bench/fit-bench.mjs +0 -126
  482. package/tools/bench/fit-sanity.mjs +0 -45
  483. package/tools/bench/metrics.mjs +0 -313
  484. package/tools/bench/obs/depth.mjs +0 -258
  485. package/tools/bench/obs/extrinsics.mjs +0 -175
  486. package/tools/bench/obs/fit_mannequin_betas.py +0 -340
  487. package/tools/bench/obs/ground.mjs +0 -294
  488. package/tools/bench/obs/heading.mjs +0 -151
  489. package/tools/bench/obs/ladder.mjs +0 -555
  490. package/tools/bench/obs/mannequin-betas.json +0 -124
  491. package/tools/bench/obs/remote.mjs +0 -83
  492. package/tools/bench/obs/rest_joints.py +0 -52
  493. package/tools/bench/obs/ybot-targets.mjs +0 -49
  494. package/tools/bench/obs-bench.mjs +0 -520
  495. package/tools/bench/score.mjs +0 -343
  496. package/tools/bench/summarize.mjs +0 -86
  497. package/tools/demo-worker/README.md +0 -137
  498. package/tools/demo-worker/api-client.mjs +0 -233
  499. package/tools/demo-worker/generate.mjs +0 -301
  500. package/tools/demo-worker/index.mjs +0 -466
  501. package/tools/demo-worker/sign-core.mjs +0 -112
  502. package/tools/demo-worker/sign.mjs +0 -161
  503. package/tools/gt-render/browser.mjs +0 -159
  504. package/tools/gt-render/camera-math.mjs +0 -276
  505. package/tools/gt-render/page.mjs +0 -267
  506. package/tools/gt-render/render.mjs +0 -514
  507. package/tools/gt-render/scene-box.mjs +0 -31
  508. package/tools/gt-render/take-transform.mjs +0 -87
  509. package/tools/kimodo/compare-seam.mjs +0 -108
  510. package/tools/kimodo/constraints.mjs +0 -244
  511. package/tools/kimodo/edit.mjs +0 -259
  512. package/tools/kimodo/effector-constraints.mjs +0 -200
  513. package/tools/kimodo/generate.mjs +0 -646
  514. package/tools/kimodo/local-output.mjs +0 -265
  515. package/tools/kimodo/measure-pose.mjs +0 -65
  516. package/tools/kimodo/measure-preserve.mjs +0 -899
  517. package/tools/kimodo/measure-waypoints.mjs +0 -55
  518. package/tools/kimodo/mlx-generate.py +0 -111
  519. package/tools/kimodo/pose-constraints.mjs +0 -248
  520. package/tools/kimodo/preserve-mask.mjs +0 -543
  521. package/tools/kimodo/read-npz.mjs +0 -189
  522. package/tools/kimodo/run-edit-on-box.mjs +0 -155
  523. package/tools/kimodo/run-sequence-on-box.mjs +0 -178
  524. package/tools/kimodo/runner.mjs +0 -284
  525. package/tools/kimodo/seam-batch.mjs +0 -77
  526. package/tools/kimodo/setup-local.mjs +0 -30
  527. package/tools/kimodo/setup-on-box.sh +0 -339
  528. package/tools/kimodo/soma77-to-cskel27.mjs +0 -305
  529. package/tools/morphgs/assets/gen_truth.py +0 -39
  530. package/tools/morphgs/assets/mesh_ori_rig.txt +0 -27
  531. package/tools/morphgs/assets/playback-check.mjs +0 -30
  532. package/tools/morphgs/demo-gate.sh +0 -26
  533. package/tools/morphgs/fbx2morphgs.mjs +0 -68
  534. package/tools/morphgs/morphgs-to-cskel27.mjs +0 -105
  535. package/tools/morphgs/patches/preprocess_src-none-mode.patch +0 -76
  536. package/tools/morphgs/setup-on-cluster.sh +0 -126
  537. package/tools/projflow/driver.py +0 -1069
  538. package/tools/projflow/generate.mjs +0 -805
  539. package/tools/projflow/hml22-to-cskel27.mjs +0 -735
  540. package/tools/projflow/line-edit-job.mjs +0 -547
  541. package/tools/projflow/replay.mjs +0 -452
  542. package/tools/projflow/runner.mjs +0 -269
  543. package/tools/projflow/service.mjs +0 -742
  544. package/tools/track/DESIGN.md +0 -513
  545. package/tools/track/backfill-provenance.mjs +0 -116
  546. package/tools/track/budget.mjs +0 -8
  547. package/tools/track/check-rig.mjs +0 -209
  548. package/tools/track/diagnostics.schema.json +0 -60
  549. package/tools/track/export-rig.mjs +0 -256
  550. package/tools/track/fallback.mjs +0 -7
  551. package/tools/track/fk-parity-fixture.mjs +0 -161
  552. package/tools/track/gate.mjs +0 -349
  553. package/tools/track/masks.mjs +0 -318
  554. package/tools/track/metrics.mjs +0 -201
  555. package/tools/track/publish-obs.mjs +0 -108
  556. package/tools/track/py/check_env.py +0 -61
  557. package/tools/track/py/eval_lr.py +0 -229
  558. package/tools/track/py/lr_viterbi.py +0 -294
  559. package/tools/track/py/masks.py +0 -405
  560. package/tools/track/py/objective.py +0 -382
  561. package/tools/track/py/rig.py +0 -508
  562. package/tools/track/py/scene.py +0 -326
  563. package/tools/track/py/test_joint_indices.py +0 -123
  564. package/tools/track/py/test_lr_viterbi.py +0 -195
  565. package/tools/track/py/test_masks.py +0 -229
  566. package/tools/track/py/test_rig.py +0 -288
  567. package/tools/track/py/test_scene.py +0 -354
  568. package/tools/track/py/test_track.py +0 -328
  569. package/tools/track/py/track.py +0 -411
  570. package/tools/track/remote.mjs +0 -140
  571. package/tools/track/rig-dump.mjs +0 -227
  572. package/tools/track/run-box-tests.mjs +0 -14
  573. package/tools/track/run-box.mjs +0 -168
  574. package/tools/track/setup-box.sh +0 -59
  575. package/tools/track/study-2d.mjs +0 -728
  576. /package/src/{ardy → motion}/collision-blockers.js +0 -0
  577. /package/src/{ardy → motion}/ground.js +0 -0
  578. /package/src/{ardy → motion}/ik-drag.js +0 -0
  579. /package/src/{ardy → motion}/ik-key-json.js +0 -0
  580. /package/src/{ardy → motion}/ik.js +0 -0
  581. /package/src/{ardy → motion}/physics-surface.js +0 -0
  582. /package/src/{ardy → motion}/playback-clock.js +0 -0
  583. /package/src/{ardy → motion}/range-pin.js +0 -0
@@ -0,0 +1,127 @@
1
+ // Mechanical input mistakes are fixed, not refused, when the fix cannot change what was meant; each
2
+ // fix is one short note the answer carries in output.adjusted (commands/motion3.js). Refused as before:
3
+ // anything that changes timing or meaning (keys past the clip, tol on above, a window wholly past it).
4
+ // relaxSpec on the expanded spec before validation (pipeline.js): a goal window partly past the
5
+ // clip is cut to it; an object key with only pos takes the turn of the key before it
6
+ // (else after it, else its scene pose: rot for a free entry, aim for a carry so the
7
+ // arm picks the roll); a rot of length strictly between 0.5 and 2 is normalized
8
+ // clampProbe a probe window partly past the take is cut to it (probes.js)
9
+ // fitEvery a position probe's every grows to fit its 16 rows (probes.js)
10
+ // clampFrames contact-sheet frames past the range are pulled into it (studio-motion-visual.js)
11
+ // normalizeCompileArgs install spellings ("always", "if_clean", ...) and repair: { rounds: 0 } / true
12
+ // (the registry's normalizeArgs, before the schema check)
13
+ import { quatFromMat } from "./compiler/math.js";
14
+ import { groupsOf } from "./scene.js";
15
+ import { isCarried } from "./carried.js";
16
+ import { isFree } from "./free-motion.js";
17
+
18
+ const fmtRange = r => `[${r[0]},${r[1]}]`;
19
+ /** Adds note to notes once (search trials expand the same spec again). */
20
+ const note = (notes, text) => { if (notes && !notes.includes(text)) notes.push(text); };
21
+
22
+ /** [f0, f1] cut to 0..last when it overlaps it; null when nothing is left or it is not a frame range. */
23
+ function clampRange(range, last) {
24
+ if (!(Array.isArray(range) && range.length === 2 && range.every(Number.isInteger) && range[0] <= range[1])) return null;
25
+ const lo = Math.max(0, range[0]), hi = Math.min(last, range[1]);
26
+ return lo <= hi ? [lo, hi] : null;
27
+ }
28
+
29
+ /** goals[].at partly outside 0..frames-1 is cut to the clip; a window wholly outside is left for validation to refuse. */
30
+ function relaxGoals(spec, notes) {
31
+ if (!Array.isArray(spec.goals) || !Number.isInteger(spec.frames)) return;
32
+ const last = spec.frames - 1;
33
+ spec.goals.forEach((g, i) => {
34
+ if (!g || typeof g !== "object" || !Array.isArray(g.at)) return;
35
+ const cut = clampRange(g.at, last);
36
+ if (!cut || (cut[0] === g.at[0] && cut[1] === g.at[1])) return;
37
+ note(notes, `goals[${i}]${g.name ? ` "${g.name}"` : ""} at ${fmtRange(g.at)} -> ${fmtRange(cut)}: the clip is 0..${last}`);
38
+ g.at = cut;
39
+ });
40
+ }
41
+
42
+ const turnOf = k => (k.rot !== undefined ? { rot: k.rot } : { aim: k.aim, ...(k.roll !== undefined ? { roll: k.roll } : {}), ...(k.lean !== undefined ? { lean: k.lean } : {}) });
43
+ const hasTurn = k => k && (k.rot !== undefined || k.aim !== undefined);
44
+ const bare = k => k && typeof k === "object" && !Array.isArray(k) && !hasTurn(k) && k.roll === undefined && k.lean === undefined;
45
+
46
+ /** A key that gives pos only holds the turn it has: the key before it, else after it, else the scene pose. */
47
+ function fillTurns(id, o, scene, notes) {
48
+ const keys = o.keys.map((k, i) => ({ k, i })).filter(({ k }) => k && Number.isInteger(k.f)).sort((a, b) => a.k.f - b.k.f);
49
+ const missing = keys.filter(({ k }) => bare(k));
50
+ if (!missing.length) return;
51
+ const rest = scene?.objects?.[id] ?? groupsOf(scene ?? {})[id];
52
+ const fromRest = rest ? (isCarried(o) ? { aim: [rest.R[0][1], rest.R[1][1], rest.R[2][1]].map(v => Math.round(v * 1e4) / 1e4) } : { rot: quatFromMat(rest.R) }) : null;
53
+ // sources are the keys that gave a turn, so a filled key never passes its fill on
54
+ const given = keys.filter(e => hasTurn(e.k)), held = [], restIdx = [];
55
+ for (const { k, i } of missing) {
56
+ const from = given.filter(e => e.k.f < k.f).at(-1) ?? given.find(e => e.k.f > k.f);
57
+ if (from) { Object.assign(k, turnOf(from.k)); held.push(i); }
58
+ else if (fromRest) { Object.assign(k, fromRest); restIdx.push(i); }
59
+ }
60
+ if (held.length) note(notes, `objects.${id}.keys[${held.join(",")}] had no rot or aim: each holds the turn of the nearest key before it (else after)`);
61
+ if (restIdx.length) note(notes, `objects.${id}.keys[${restIdx.join(",")}] had no rot or aim: ${fromRest.aim ? `+Y as in the scene, aim [${fromRest.aim}]` : "turned as in the scene"}`);
62
+ }
63
+
64
+ /** A rot that is a quaternion off unit length (strictly between 0.5 and 2) is normalized. */
65
+ function normalizeRots(id, o, notes) {
66
+ o.keys.forEach((k, i) => {
67
+ if (!Array.isArray(k?.rot) || k.rot.length !== 4 || !k.rot.every(Number.isFinite)) return;
68
+ const n = Math.hypot(...k.rot);
69
+ if (Math.abs(n - 1) <= 0.01 || n <= 0.5 || n >= 2) return;
70
+ k.rot = k.rot.map(v => v / n);
71
+ note(notes, `objects.${id}.keys[${i}].rot had length ${n.toFixed(3)}: normalized`);
72
+ });
73
+ }
74
+
75
+ /**
76
+ * relaxSpec(spec, scene, notes): the fixes above, in place on the expanded spec (a plain JSON copy the
77
+ * compile measures; the stored spec stays as sent). notes collects one line per fix.
78
+ */
79
+ export function relaxSpec(spec, scene, notes) {
80
+ if (!spec || typeof spec !== "object") return spec;
81
+ relaxGoals(spec, notes);
82
+ for (const [id, o] of Object.entries(spec.objects ?? {})) {
83
+ if (!o || typeof o !== "object" || !Array.isArray(o.keys) || !(isCarried(o) || isFree(o))) continue;
84
+ fillTurns(id, o, scene, notes);
85
+ normalizeRots(id, o, notes);
86
+ }
87
+ return spec;
88
+ }
89
+
90
+ /** A probe window cut to the take (frames: one frame or [f0, f1]); null (refused) when nothing is left. */
91
+ export function clampProbe(frames, last, at, notes) {
92
+ const range = Number.isInteger(frames) ? [frames, frames] : frames, cut = clampRange(range, last);
93
+ if (cut && (cut[0] !== range[0] || cut[1] !== range[1])) note(notes, `${at}.frames ${fmtRange(range)} -> ${fmtRange(cut)}: the take is 0..${last}`);
94
+ return cut;
95
+ }
96
+
97
+ /** The every a position probe needs to answer at most max rows over span frames (the asked one if it fits). */
98
+ export function fitEvery(every, span, max, at, notes) {
99
+ if (Math.ceil(span / every) <= max) return every;
100
+ const fit = Math.ceil(span / max);
101
+ note(notes, `${at}.every ${every} -> ${fit}: a position probe answers at most ${max} rows`);
102
+ return fit;
103
+ }
104
+
105
+ /** Contact-sheet frames pulled into lo..hi, in order, each once: { frames, adjusted? }. */
106
+ export function clampFrames(frames, [lo, hi]) {
107
+ const outside = frames.filter(f => f < lo || f > hi);
108
+ const kept = [...new Set(frames.map(f => Math.min(hi, Math.max(lo, f))))].sort((a, b) => a - b);
109
+ return outside.length ? { frames: kept, adjusted: `frames ${outside.join(", ")} lie outside ${lo}..${hi}: drawn at ${kept.filter(f => f === lo || f === hi).join(", ")}` } : { frames: kept };
110
+ }
111
+
112
+ const INSTALL_WORDS = { always: true, yes: true, true: true, on: true, never: "never", no: "never", false: "never", off: "never", none: "never",
113
+ ifclean: "ifClean", whenclean: "ifClean", onlyifclean: "ifClean", clean: "ifClean" };
114
+
115
+ /** motion.compile args with the obvious other spellings turned into the declared ones (meaning unchanged). */
116
+ export function normalizeCompileArgs(args) {
117
+ if (!args || typeof args !== "object" || Array.isArray(args)) return args;
118
+ let out = args;
119
+ if (typeof args.install === "string" && args.install !== "ifClean" && args.install !== "never") {
120
+ const word = INSTALL_WORDS[args.install.toLowerCase().replace(/[^a-z]/g, "")];
121
+ if (word !== undefined) out = { ...out, install: word };
122
+ }
123
+ if (args.repair === true) out = { ...out, repair: {} };
124
+ else if (args.repair === false || (args.repair && typeof args.repair === "object" && args.repair.rounds === 0 && Object.keys(args.repair).length === 1))
125
+ out = Object.fromEntries(Object.entries(out).filter(([k]) => k !== "repair"));
126
+ return out;
127
+ }
@@ -0,0 +1,236 @@
1
+ // C14. Held-object keys: spec.objects[id].keys = [{ f, pos, rot }] on a carry entry. Each key is
2
+ // the world pose of the object's root (the group root for a group id, else the body: its base
3
+ // pivot, rot a quaternion [x, y, z, w]) at absolute frame f, grab <= f <= release.
4
+ // between keys a cubic Hermite on pos and the same in rotation-vector space on rot (squad
5
+ // like), Catmull-Rom tangents through inner keys, zero at the first and last key
6
+ // around the span the hand blends from the plain carry into the keyed span over KEY_BLEND frames
7
+ // (inside grab..release; smoothstep), so nothing jumps
8
+ // the object leads the hand: compile.js asks holdHook for the palm frame the keys put the grip
9
+ // at, palm = key o attach^-1, and pose.js solves the hand to it (compiler/hold.js)
10
+ // The object itself is still drawn in the hand (object-pose.js): the residual is what the arm
11
+ // and the wrist could not reach, and QA reports it (qa/key-checks.js).
12
+ import { isCarried, carriedPose, compose, relative } from "./carried.js";
13
+ import { groupsOf } from "./scene.js";
14
+ import { restState } from "./compiler/skeleton.js";
15
+ import { add, scale, sub, apply, T, matFromQuat, quatFromMat } from "./compiler/math.js";
16
+ import { qmul, qconj, qlog, qexp, qrot, qdot, qnorm } from "./compiler/quat.js";
17
+ import { keyRots, leanPos } from "./key-aim.js";
18
+ import { holdCost } from "./compiler/hold.js";
19
+ import { polePlan, smoothPath, smoothed } from "./hold-plan.js";
20
+ import { secondGrip, secondHold, gripGate } from "./second-hand.js";
21
+ import { SIDES } from "./compiler/pose.js";
22
+ import { chooseGrip, between, thinBody } from "./grip-choice.js";
23
+
24
+ /** Frames over which the hand blends into and out of the keyed span. */
25
+ export const KEY_BLEND = 8;
26
+ // the frames a hand takes to turn into a chosen grip before its grab and out of it after its release (grip-choice.js)
27
+ const GRAB_EASE = 12;
28
+
29
+ const smooth = x => x * x * (3 - 2 * x);
30
+ /** [grab, release] in absolute frames of `out` (object-pose.js spanOf, kept here to stay out of its import cycle). */
31
+ const spanIn = (out, o) => { const map = f => (out.timeMap ? Math.round(out.timeMap(f)) : f); return [map(o.grab ?? 0), o.release === undefined ? out.frameCount - 1 : map(o.release)]; };
32
+ const invert = p => { const Rt = T(p.R); return { pos: scale(apply(Rt, p.pos), -1), R: Rt }; };
33
+
34
+ /** The keys of entry o as a curve: times (after a retime), positions, quaternions on one hemisphere (aim keys resolved: key-aim.js), tangents. */
35
+ export function curveOf(o, map, plain, strain, top = 0) {
36
+ const keys = [...o.keys].sort((a, b) => a.f - b.f), t = keys.map(k => map(k.f)), q = [];
37
+ const rots = keyRots(keys, i => plain(t[i]), strain && ((i, r) => strain(t[i], leanPos(keys[i], r, top), r, keys[i].lean ? { shoulder: true } : undefined)));
38
+ const p = keys.map((k, i) => leanPos(k, qnorm(rots[i]), top).slice());
39
+ for (const r of rots) { const n = qnorm(r); q.push(q.length && qdot(q[q.length - 1], n) < 0 ? n.map(v => -v) : n); }
40
+ const last = keys.length - 1, rate = i => scale(qlog(qmul(qconj(q[i]), q[i + 1])), 1 / (t[i + 1] - t[i]));
41
+ const tangent = (i, of) => (i === 0 || i === last ? [0, 0, 0] : scale(add(scale(of(i), t[i] - t[i - 1]), scale(of(i - 1), t[i + 1] - t[i])), 1 / (t[i + 1] - t[i - 1])));
42
+ const m = p.map((_, i) => tangent(i, j => scale(sub(p[j + 1], p[j]), 1 / (t[j + 1] - t[j])))), w = q.map((_, i) => tangent(i, rate));
43
+ return { t, p, q, m, w, rots };
44
+ }
45
+
46
+ const curves = new WeakMap();
47
+ /**
48
+ * The key curve of spec.objects[id] in `out` (cached per compile result, time map and baked
49
+ * channels: an aim key turns from the plain carry at its frame, and one without roll takes the
50
+ * roll the arm holds there most easily).
51
+ */
52
+ export function curveIn(out, id) {
53
+ if (!curves.has(out)) curves.set(out, new Map());
54
+ const cache = curves.get(out), map = out.timeMap, baked = out.baked, had = cache.get(id);
55
+ if (!had || had.map !== map || had.baked !== baked) {
56
+ const hold = out.ctx.hold, solved = new Map(), at = t => { const f = Math.round(t); if (!solved.has(f)) solved.set(f, hold.plainFrame(f).s); return solved.get(f); };
57
+ const plain = t => quatFromMat(hold.carryOn(id, at(t)).R), strain = (t, pos, q, opts) => hold.strainOn(id, at(t), { pos, R: matFromQuat(q) }, opts);
58
+ cache.set(id, { map, baked, curve: curveOf(out.ctx.spec.objects[id], f => (map ? map(f) : f), plain, strain, 2 * (out.ctx.scene?.objects?.[id]?.half?.[1] ?? 0)) });
59
+ }
60
+ return cache.get(id).curve;
61
+ }
62
+
63
+ /** World pose { pos, R } the keys ask for at absolute frame f (held at the first / last key outside them). */
64
+ export function keyedPose({ t, p, q, m, w }, f) {
65
+ const n = t.length;
66
+ if (n === 1 || f <= t[0]) return { pos: p[0].slice(), R: matFromQuat(q[0]) };
67
+ if (f >= t[n - 1]) return { pos: p[n - 1].slice(), R: matFromQuat(q[n - 1]) };
68
+ let i = 0;
69
+ while (f > t[i + 1]) i++;
70
+ const h = t[i + 1] - t[i], u = (f - t[i]) / h, u2 = u * u, u3 = u2 * u;
71
+ const h00 = 2 * u3 - 3 * u2 + 1, h10 = u3 - 2 * u2 + u, h01 = -2 * u3 + 3 * u2, h11 = u3 - u2;
72
+ const pos = add(add(scale(p[i], h00), scale(m[i], h * h10)), add(scale(p[i + 1], h01), scale(m[i + 1], h * h11)));
73
+ // rotation: q_i exp(v), v a Hermite in q_i's frame from 0 to the step to q_i+1 (the end tangent turned into that frame)
74
+ const step = qmul(qconj(q[i]), q[i + 1]), d = qlog(step);
75
+ const v = add(add(scale(d, h01), scale(w[i], h * h10)), scale(qrot(step, w[i + 1]), h * h11));
76
+ return { pos, R: matFromQuat(qmul(q[i], qexp(v))) };
77
+ }
78
+
79
+ /**
80
+ * 0..1: how much the keys lead the hand at absolute frame f (1 from the first to the last key).
81
+ * After the last key the hand eases out over KEY_BLEND frames even when the release comes sooner:
82
+ * the rest of the ease runs past the release (holdHook easeOut), so the arm does not snap.
83
+ */
84
+ function leadWeight(curve, [grab, release], f) {
85
+ const t0 = curve.t[0], t1 = curve.t[curve.t.length - 1];
86
+ if (f < grab || f > release) return 0;
87
+ if (f >= t0 && f <= t1) return 1;
88
+ const b = f < t0 ? Math.min(KEY_BLEND, t0 - grab) : KEY_BLEND, gap = f < t0 ? t0 - f : f - t1;
89
+ return b > 0 && gap < b ? smooth(1 - gap / b) : 0;
90
+ }
91
+
92
+ /** The keyed carry entries: [[id, entry]]. */
93
+ export const keyedEntries = spec => Object.entries(spec.objects ?? {}).filter(([, o]) => isCarried(o) && o.keys?.length);
94
+
95
+ /**
96
+ * The hooks a compile needs when some carry has keys (else null): lead(k, f, s, c) -> { w,
97
+ * palm, measure, pole? } | null for pose.js hooks.hold (the holding hand, or a left hand anchored
98
+ * to the carry: second-hand.js), and attach(id) -> the object in the palm frame (the
99
+ * plain carry's offset: at/along, or the grab-frame offset solved without the keys, so the keys
100
+ * never feed back into it). For aim keys (key-aim.js): plainFrame(f) solves frame f without the
101
+ * keys (solveLed(f) with them, the second hands left out: what a second hand's roll is planned
102
+ * on), carryOn(id, s) is where the plain carry holds id on such a pose (where an aim key turns
103
+ * from) and strainOn(id, s, pose) the arm's cost of holding id at world pose { pos, R } there
104
+ * (compiler/hold.js holdCost, the roll of an aim key without one).
105
+ */
106
+ export function holdHook(ctx, out, solvePlain, solveLed) {
107
+ const { sk, spec, scene } = ctx, held = keyedEntries(spec);
108
+ if (!held.length) return null;
109
+ const palmOf = (o, s) => carriedPose(sk, spec, s, { prop: o.prop }), attached = new WeakMap(), attaching = new Set();
110
+ const restAt = (id, f) => ctx.restingAt?.(id, f) ?? scene?.objects?.[id] ?? groupsOf(scene)[id];
111
+ // a keyed carry of a thin body (a cup, a can, a bar) whose grip is free (no at/along, no orient: false, no keyed wrist at
112
+ // the grab) keeps the grip its keyed path holds most comfortably (grip-choice.js), solved on the plain frames with the
113
+ // body read at rest; a box keeps the grip grip.js gives it at the grab
114
+ const choices = new WeakMap(), mapped = f => (out.timeMap ? Math.round(out.timeMap(f)) : f);
115
+ // chosen once per compile (the first bake): the fixes' rebakes move the body a little, the carry's keys not at all
116
+ const chosen = id => {
117
+ if (!choices.has(out)) choices.set(out, new Map());
118
+ const cache = choices.get(out), o = spec.objects[id], k = spec.props?.[o.prop]?.hand, grab = spanIn(out, o)[0], b = out.baked ?? {};
119
+ if (cache.has(id)) return cache.get(id);
120
+ cache.set(id, null);
121
+ const free = k && o.at === undefined && o.along === undefined && (o.grab !== undefined || !scene?.objects?.[id]) && thinBody(scene, id) && !(spec.fits ?? []).some(fit => fit.side === k && fit.orient === false)
122
+ && !["wtwist", "wflex"].some(ch => Math.abs(b[`${ch}_${k}`]?.[grab] ?? 0) > 1e-3)
123
+ // keys that start after the grab: the body rides the hand from where it rests, which only today's grip meets exactly
124
+ && mapped(Math.min(...o.keys.map(key => key.f))) <= grab;
125
+ if (!free) return null;
126
+ attaching.add(id);
127
+ try { cache.set(id, chooseGrip({ sk, o, side: SIDES[k], grab, rest: restAt(id, grab), plain: f => solvePlain(f).s, palmOf: s => palmOf(o, s), map: mapped })); } finally { attaching.delete(id); }
128
+ return cache.get(id);
129
+ };
130
+ const attach = id => {
131
+ if (!attached.has(out.baked)) attached.set(out.baked, new Map());
132
+ const cache = attached.get(out.baked), o = spec.objects[id];
133
+ if (cache.has(id)) return cache.get(id);
134
+ const picked = chosen(id);
135
+ if (picked && picked.name !== "today") { cache.set(id, picked.offset); return picked.offset; }
136
+ const rest = scene?.objects?.[id] ?? groupsOf(scene)[id], group = !scene?.objects?.[id] && !!rest;
137
+ const keeps = o.at === undefined && o.along === undefined && (group || o.grab !== undefined);
138
+ // the grab frame solved without the keys: a left hand anchored on id reads it there (object-pose.js), where this offset puts it
139
+ attaching.add(id);
140
+ let s;
141
+ try { s = keeps ? solvePlain(spanIn(out, o)[0]).s : restState(sk); } finally { attaching.delete(id); }
142
+ const a = relative(palmOf(o, s), keeps ? ctx.restingAt?.(id, spanIn(out, o)[0]) ?? { pos: rest.pos, R: rest.R } : carriedPose(sk, spec, s, o));
143
+ cache.set(id, a);
144
+ return a;
145
+ };
146
+ const carryOn = (id, s) => compose(palmOf(spec.objects[id], s), attach(id));
147
+ const strainOn = (id, s, pose, opts) => { const o = spec.objects[id]; return holdCost(sk, s, SIDES[spec.props[o.prop].hand], compose(pose, invert(attach(id))), palmOf(o, s), opts); };
148
+ const heldAt = (id, o, f) => {
149
+ const curve = curveIn(out, id), w = leadWeight(curve, spanIn(out, o), f);
150
+ return w > 0 ? { w, palm: compose(keyedPose(curve, f), invert(attach(id))), measure: s => palmOf(o, s), comfort: o.keys.some(k => k.lean > 0) } : null;
151
+ };
152
+ // the elbow's planned path over the frames the keys lead (hold-plan.js), once per baked channels and time map
153
+ const plans = new WeakMap();
154
+ const planOf = (id, o) => {
155
+ if (!plans.has(out.baked)) plans.set(out.baked, new Map());
156
+ const cache = plans.get(out.baked), had = cache.get(id);
157
+ if (had && had.map === out.timeMap) return had.plan;
158
+ const [grab, release] = spanIn(out, o), frames = [];
159
+ for (let f = Math.max(0, grab); f <= Math.min(out.frameCount - 1, release); f++) if (leadWeight(curveIn(out, id), [grab, release], f) > 0) frames.push(f);
160
+ const plan = polePlan(sk, SIDES[spec.props[o.prop].hand], frames, f => ({ s: solvePlain(f).s, held: heldAt(id, o, f) }));
161
+ cache.set(id, { map: out.timeMap, plan });
162
+ return plan;
163
+ };
164
+ // a left hand anchored to a carry the right hand holds grips it too (second-hand.js): its roll about the object, planned over the frames like the elbow
165
+ let planning = false;
166
+ const gripAt = (id, s, c) => { const R = carryOn(id, s).R; return secondGrip(sk, spec, id, s, c, [R[0][1], R[1][1], R[2][1]]); };
167
+ const rollPlans = new WeakMap();
168
+ const rollsOf = (id, o) => {
169
+ if (!rollPlans.has(out.baked)) rollPlans.set(out.baked, new Map());
170
+ const cache = rollPlans.get(out.baked), had = cache.get(id);
171
+ if (had && had.map === out.timeMap) return had.plan;
172
+ const [grab, release] = spanIn(out, o), plan = new Map();
173
+ planning = true;
174
+ let run = [];
175
+ const flush = () => {
176
+ const x = smoothPath((i, r) => run[i].grip.cost(r), (i, r) => run[i].grip.point(r), run.map(g => g.grip.softmin())), gate = smoothed(run.map((g, i) => gripGate(g.grip, x[i])));
177
+ // then its elbow's path at those rolls, like the holding elbow's (hold-plan.js)
178
+ const arm = i => run[i].grip.arm(x[i]), th = smoothPath((i, t) => arm(i).at(t).cost, (i, t) => arm(i).at(t).elbow, run.map((_, i) => arm(i).best.th));
179
+ run.forEach((g, i) => plan.set(g.f, { roll: x[i], gate: gate[i], pole: arm(i).at(th[i]).pv }));
180
+ run = [];
181
+ };
182
+ for (let f = Math.max(0, grab); f <= Math.min(out.frameCount - 1, release); f++) {
183
+ const solved = leadWeight(curveIn(out, id), [grab, release], f) > 0 ? solveLed(f) : null, grip = solved && gripAt(id, solved.s, solved.c);
184
+ if (grip) run.push({ f, grip }); else if (run.length) flush();
185
+ }
186
+ if (run.length) flush();
187
+ planning = false;
188
+ cache.set(id, { map: out.timeMap, plan });
189
+ return plan;
190
+ };
191
+ // around its keys the hand holds a chosen grip: it turns into it over the GRAB_EASE frames before the grab, holds it from the
192
+ // grab until the keys lead, keeps it on the body where the last key left it, and turns out of it over the GRAB_EASE frames
193
+ // after the release (by time, not by a fit's weight, which an agent may key on in a frame), so nothing jumps
194
+ const gripAround = (id, o, f) => {
195
+ const pick = chosen(id);
196
+ if (!pick || pick.name === "today") return null;
197
+ const curve = curveIn(out, id), t0 = curve.t[0], t1 = curve.t[curve.t.length - 1], [grab, release] = spanIn(out, o);
198
+ if (f >= t0 && f <= t1) return null;
199
+ // the elbow takes the planned pole of the nearest keyed frame (hold-plan.js), so it does not swing at the span's ends
200
+ // the grip on the body where the first key puts it (an aim key's roll is picked for this grip), so the reach meets the keys
201
+ const on = keyedPose(curve, f < t0 ? t0 : t1), grip = compose(on, invert(pick.offset)), measure = s => palmOf(o, s), pole = planOf(id, o).get(Math.round(f < t0 ? t0 : t1));
202
+ if (f < grab || f > release) { const w = smooth(Math.max(0, 1 - (f < grab ? grab - f : f - release) / GRAB_EASE)); return w > 1e-3 ? { w, palm: grip, measure, pole } : null; }
203
+ const h = heldAt(id, o, f);
204
+ return { w: 1, palm: h ? { pos: add(scale(grip.pos, 1 - h.w), scale(h.palm.pos, h.w)), R: between(grip.R, h.palm.R, h.w) } : grip, measure, pole };
205
+ };
206
+ // a release within KEY_BLEND frames of the last key: the hands finish easing out of the keys after it (weight from the last
207
+ // key), the holding hand from the palm they gave it at the release (the object stays where it was let go), each hand with
208
+ // the elbow pole (and the second hand the roll) planned for the release frame
209
+ const pastRelease = (id, o, f) => {
210
+ const curve = curveIn(out, id), t1 = curve.t[curve.t.length - 1], release = spanIn(out, o)[1];
211
+ return f > release && f - t1 < KEY_BLEND ? { curve, release, w: smooth(1 - (f - t1) / KEY_BLEND) } : null;
212
+ };
213
+ const easeOut = (id, o, f) => {
214
+ const e = pastRelease(id, o, f);
215
+ return e && { w: e.w, palm: compose(keyedPose(e.curve, e.release), invert(attach(id))), measure: s => palmOf(o, s), pole: planOf(id, o).get(e.release) };
216
+ };
217
+ // the hand that holds a keyed carry follows its keys
218
+ const lead = (k, f, s, c) => {
219
+ for (const [id, o] of held) {
220
+ const pre = spec.props?.[o.prop]?.hand === k ? gripAround(id, o, f) ?? easeOut(id, o, f) : null;
221
+ if (pre) return pre;
222
+ const h = spec.props?.[o.prop]?.hand === k ? heldAt(id, o, f) : null;
223
+ if (h) return { ...h, pole: planOf(id, o).get(f) };
224
+ const after = k === "l" && s && !planning ? pastRelease(id, o, f) : null;
225
+ const w = k === "l" && s && !planning ? leadWeight(curveIn(out, id), spanIn(out, o), f) || (after?.w ?? 0) : 0, grip = w > 0 ? gripAt(id, s, c) : null;
226
+ const planned = grip && rollsOf(id, o).get(after ? after.release : f), roll = planned?.roll ?? grip?.softmin();
227
+ if (grip) return secondHold(grip, w, roll, planned?.gate ?? gripGate(grip, roll), planned?.pole ?? grip.arm(roll).best.pole);
228
+ }
229
+ return null;
230
+ };
231
+ // the grip (compiler/grip.js) reads where a keyed carry's span and keys begin, after a retime
232
+ const firstKey = id => { const t = Math.min(...spec.objects[id].keys.map(k => k.f)); return out.timeMap ? Math.round(out.timeMap(t)) : t; };
233
+ // the grips chosen for keyed carries (observations.wrist reads them): [{ id, hand, name, cost, today }]
234
+ const grips = () => held.map(([id, o]) => { const p = chosen(id); return p && { id, hand: spec.props[o.prop].hand, name: p.name, cost: p.cost, today: p.today }; }).filter(Boolean);
235
+ return { lead, attach, attaching: id => attaching.has(id), plainFrame: solvePlain, carryOn, strainOn, span: id => spanIn(out, spec.objects[id]), firstKey, grips };
236
+ }
@@ -0,0 +1,182 @@
1
+ // C3. Where a scene object or a group is at a frame: the one place refs, probes, goals, the
2
+ // timeline, the take and QA read object poses from. See docs/motion-api-v3.1.md (C3, 7.1, 7.2).
3
+ //
4
+ // The group (an Empty) is the unit. spec.objects[id] may name a body or a group:
5
+ // hinge { pivot, axis, channel } turns the record (a group: the whole group
6
+ // about the group root) by a keyed angle
7
+ // carry { prop, grab?, release?, at?, along?, visible?, level? } the record rides prop `prop`'s hand
8
+ // switch { visible?, level? } moves nothing: shows/hides and dims the record (C15)
9
+ // A carried or hinged group gets ONE track, on the group root (take.objects[groupId]); its parts
10
+ // follow through the parent carry that already exists in src/object-travel.js (ancestorsOf /
11
+ // ownTravelMatrix). There are no per-part tracks. While the group is in hand (grab..release) its
12
+ // track is in world space and the carry from the group's own parent (a table) is cut, so nothing
13
+ // is carried twice (the take's `hold` flags, object-travel.js).
14
+ // f < grab the scene pose
15
+ // grab <= f <= release follows the prop's hand; without at/along it keeps the transform it had
16
+ // against the palm axes at grab (no jump); at/along pin an offset (a group: its root, C15)
17
+ // f > release frozen at the release pose
18
+ // no grab: in hand from frame 0; no release: in hand to the end (PR #14 behaviour)
19
+ // keys (C14, object-keys.js): the object leads and the hand follows; the object is still drawn
20
+ // in the hand, so what the hand cannot reach shows as a residual (QA)
21
+ // follow { follow, offset?, aim?, visible?, level? } rides a point of the body every frame (C16, follow.js)
22
+ // free { keys?, fall?, visible?, level? } moves on its own: keys, falls (C17, free-motion.js); a carry's
23
+ // fall puts it where it lands before grab (the hand finds it there) or after release
24
+ // Carried objects are OBSTACLES at every frame, at their pose that frame (qa/object-checks.js);
25
+ // a follow entry is none.
26
+ import { isCarried, isFollow, carriedPose, compose, relative, movesRecord } from "./carried.js";
27
+ import { followPose } from "./follow.js";
28
+ import { groupsOf } from "./scene.js";
29
+ import { solveFrame } from "./compiler/compile.js";
30
+ import { channelsAt } from "./compiler/channels.js";
31
+ import { resolveBone } from "./bones.js";
32
+ import { isFree, freePoseAt, beforeGrab, afterRelease } from "./free-motion.js";
33
+
34
+ /**
35
+ * Body ids that make up `id` in a motionScene: [id] for a body (plus any bodies parented under
36
+ * it), every body under it for a group, [] when the scene knows no such id.
37
+ * @returns {string[]}
38
+ */
39
+ export function partsOf(scene, id) {
40
+ const objects = scene?.objects ?? {};
41
+ return Object.keys(objects).filter(k => k === id || objects[k].ancestors?.includes(id));
42
+ }
43
+
44
+ /**
45
+ * True while spec.objects entry `o` holds its record in a hand at absolute frame f
46
+ * (grab <= f <= release; a missing grab is 0, a missing release the last frame).
47
+ */
48
+ export function inHandAt(o, f) {
49
+ return isCarried(o) && f >= (o.grab ?? 0) && (o.release === undefined || f <= o.release);
50
+ }
51
+
52
+ /** The scene pose { pos, R } of a body or a group root, or null. */
53
+ function restPose(scene, id) {
54
+ return scene?.objects?.[id] ?? groupsOf(scene)[id] ?? null;
55
+ }
56
+
57
+ /** The spec.objects key that moves body or group `id`: itself or its nearest group with a carry, follow or hinge entry (a switch moves nothing), or null. */
58
+ function moverOf(spec, scene, id) {
59
+ return [id, ...(scene?.objects?.[id]?.ancestors ?? groupsOf(scene)[id]?.ancestors ?? [])].find(k => movesRecord(spec.objects?.[k])) ?? null;
60
+ }
61
+
62
+ /** [grab, release] of a carried entry in absolute frames of `out` (after a retime). */
63
+ export function spanOf(out, o) {
64
+ const map = f => (out.timeMap ? Math.round(out.timeMap(f)) : f);
65
+ return [map(o.grab ?? 0), o.release === undefined ? out.frameCount - 1 : map(o.release)];
66
+ }
67
+
68
+ /** Without at/along a grabbed body, and a group, keeps its grab-frame palm offset; at/along pin one (a kit root, C15). */
69
+ const keepsOffset = (scene, id, o) => o.at === undefined && o.along === undefined && ((!scene?.objects?.[id] && !!groupsOf(scene)[id]) || o.grab !== undefined);
70
+
71
+ const solved = new WeakMap(), poses = new WeakMap();
72
+
73
+ /** What free-motion.js reads of a compile result: the spec, the scene and the time map. */
74
+ const freeCtx = out => ({ spec: out.ctx.spec, scene: out.ctx.scene, timeMap: out.timeMap });
75
+
76
+ /**
77
+ * Where a carried body or group `id` (or a part of one) rests at absolute f before its grab, and where the hand took
78
+ * it from after: its scene pose, or where a fall before the grab left it (C17). null when no carry moves it.
79
+ */
80
+ export function restingAt(out, id, f) {
81
+ const { spec, scene } = out.ctx, mover = moverOf(spec, scene, id), o = spec.objects?.[mover];
82
+ if (!isCarried(o)) return null;
83
+ const root = beforeGrab(freeCtx(out), mover, o, f, spanOf(out, o)[0]);
84
+ return root && (mover === id ? root : compose(root, relative(restPose(scene, mover), restPose(scene, id))));
85
+ }
86
+
87
+ /** The solved frame at absolute f: out.frames, or solved once on demand outside a window. */
88
+ function frameAt(out, f) {
89
+ const own = out.frames[f - (out.f0 ?? 0)];
90
+ if (own) return own;
91
+ if (!solved.has(out)) solved.set(out, new Map());
92
+ const cache = solved.get(out);
93
+ if (!cache.has(f)) cache.set(f, solveFrame(out.ctx, channelsAt(out.baked, f), f));
94
+ return cache.get(f);
95
+ }
96
+
97
+ /** Pose of the record a carried entry moves at in-hand frame f, on that frame's pose s. */
98
+ function carriedOn(out, id, o, f, s) {
99
+ const { sk, spec, scene } = out.ctx;
100
+ if (!keepsOffset(scene, id, o)) return carriedPose(sk, spec, s, o);
101
+ // keyed (object-keys.js): the grab-frame offset solved without the keys, which the hand followed. While that
102
+ // grab frame is solved (a hand anchored on the object reads it), the object is where the offset puts it: at rest.
103
+ if (o.keys?.length && out.ctx.hold) return out.ctx.hold.attaching(id) ? restPose(scene, id) : compose(carriedPose(sk, spec, s, { prop: o.prop }), out.ctx.hold.attach(id));
104
+ const palm = st => carriedPose(sk, spec, st, { prop: o.prop }), grab = spanOf(out, o)[0];
105
+ return compose(palm(s), relative(palm(grab === f ? s : frameAt(out, grab).s), restingAt(out, id, grab) ?? restPose(scene, id)));
106
+ }
107
+
108
+ /** Pose of the record a carried entry moves, cached on the solved frame. */
109
+ function carriedAt(out, id, o, f) {
110
+ const fr = frameAt(out, f);
111
+ if (!poses.has(fr)) poses.set(fr, new Map());
112
+ const cache = poses.get(fr);
113
+ if (!cache.has(id)) cache.set(id, carriedOn(out, id, o, f, fr.s));
114
+ return cache.get(id);
115
+ }
116
+
117
+ /**
118
+ * World pose { pos, R } of the record spec.objects[id] moves (a body or a group root) at
119
+ * absolute frame f: carried, hinged (out.ctx.objectsAt for a body; the group root turned by
120
+ * the same hinge) or still. null for an id the scene does not know. `now` ({ s, diag, c }) is
121
+ * frame f while the compiler solves it (an object anchor): its pose so far stands in for the
122
+ * solved frame, so the carrying hand must already be solved (compiler/anchors.js).
123
+ */
124
+ export function rootPoseAt(out, id, f, now = null) {
125
+ const { spec, scene } = out.ctx, o = movesRecord(spec.objects?.[id]) ? spec.objects[id] : undefined, rest = restPose(scene, id);
126
+ if (isFollow(o)) return followPose(now ? { ...out, f0: f, frames: [now] } : out, o, f);
127
+ if (isCarried(o) && (rest || !keepsOffset(scene, id, o))) {
128
+ const [grab, release] = spanOf(out, o), g = Math.max(grab, Math.min(f, release));
129
+ if (f < grab && rest) return restingAt(out, id, f);
130
+ const after = f > release ? afterRelease(freeCtx(out), id, o, f, release, carriedAt(out, id, o, release)) : null;
131
+ if (after) return after;
132
+ return now && g === f ? carriedOn(out, id, o, f, now.s) : carriedAt(out, id, o, g);
133
+ }
134
+ if (!rest) return null;
135
+ if (isFree(o)) return freePoseAt(freeCtx(out), id, f);
136
+ if (o && scene.objects[id]) return out.ctx.objectsAt(f)[id];
137
+ if (o) { const part = partsOf(scene, id)[0], box = out.ctx.objectsAt(f)[part]; return compose(box, relative(scene.objects[part], rest)); }
138
+ return { pos: rest.pos, R: rest.R };
139
+ }
140
+
141
+ /**
142
+ * The boxes of `id` at absolute frame f of a compile result `out` (out.ctx.scene, out.ctx.spec):
143
+ * [{ id: partId, pos, R, half }] for a body ([its own box]) or a group (every part box, moved by
144
+ * the group root's pose at f). null when f is outside the compiled window (out.f0 ..
145
+ * out.f0 + out.frames.length - 1) or the scene has no such id.
146
+ * @returns {{ id: string, pos: number[], R: number[][], half: number[] }[] | null}
147
+ */
148
+ export function objectBoxesAt(out, id, f) {
149
+ const fr = out.frames?.[f - (out.f0 ?? 0)], scene = out.ctx.scene, parts = partsOf(scene, id);
150
+ if (!fr || !parts.length) return null;
151
+ return parts.map(p => { const pose = objectPoseAt(out, p, f); return { id: p, pos: pose.pos, R: pose.R, half: scene.objects[p].half }; });
152
+ }
153
+
154
+ /**
155
+ * The hand ("l" | "r") body or group `id` rides at absolute frame f, so a pose of that frame needs that arm solved
156
+ * first: a carry while in hand (grab..release; after release it is frozen at a frame already solved), a follow on a
157
+ * joint of that arm or a point of its prop. null otherwise.
158
+ */
159
+ export function handOf(out, id, f) {
160
+ const { spec, scene, sk } = out.ctx, entry = spec.objects?.[moverOf(spec, scene, id)];
161
+ if (isCarried(entry)) { const [grab, release] = spanOf(out, entry); return f >= grab && f <= release ? spec.props?.[entry.prop]?.hand ?? null : null; }
162
+ if (!isFollow(entry)) return null;
163
+ const [kind, rest = ""] = String(entry.follow).split(/:(.*)/s);
164
+ if (kind === "prop") return spec.props?.[rest.split(".")[0]]?.hand ?? null;
165
+ const arm = (kind === "joint" || kind === "bone") && /^(Left|Right)(Arm|ForeArm|Hand)/.exec(resolveBone(sk, rest).bone ?? "");
166
+ return arm ? (arm[1] === "Left" ? "l" : "r") : null;
167
+ }
168
+
169
+ /**
170
+ * World pose { pos, R } of a body (its base pivot) or a group (its origin) at absolute frame f:
171
+ * the one pose object refs, probes, goals, QA and object anchors read. A carried or follow record
172
+ * is where it rides, a hinged one turned, any other at its scene pose. `now` as rootPoseAt.
173
+ * null for an id the scene does not know.
174
+ */
175
+ export function objectPoseAt(out, id, f, now = null) {
176
+ const { spec, scene } = out.ctx, rest = restPose(scene, id), mover = moverOf(spec, scene, id), entry = spec.objects?.[mover];
177
+ if (!rest) return null;
178
+ if (isCarried(entry) || isFollow(entry) || isFree(entry)) { const root = rootPoseAt(out, mover, f, now); return root && compose(root, relative(restPose(scene, mover), rest)); }
179
+ if (!mover) return { pos: rest.pos, R: rest.R };
180
+ if (scene.objects[id]) return out.ctx.objectsAt(f)[id] ?? rest;
181
+ return mover === id ? rootPoseAt(out, id, f) : compose(rootPoseAt(out, mover, f), relative(restPose(scene, mover), rest));
182
+ }
@@ -0,0 +1,12 @@
1
+ // Scene objects the installed takes animate (hinged doors and the like), for object-travel.js:
2
+ // id -> { frameCount, characterId, pos: Float32Array(F*3), quat: Float32Array(F*4), hold?, vis? } across the whole cast
3
+ // (characterId: whose take draws it, for motion.keyObject).
4
+ export function objectTracksOf(motionOwner, characters = []) {
5
+ const tracks = new Map();
6
+ for (const character of characters) {
7
+ const take = motionOwner?.motionFor?.(character.id);
8
+ if (take?.schema !== "cozyclay.take.v3") continue;
9
+ for (const [id, track] of Object.entries(take.objects ?? {})) tracks.set(id, { frameCount: take.frameCount, characterId: character.id, ...track });
10
+ }
11
+ return tracks;
12
+ }