@automovie/render 0.3.0 → 0.3.2

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 (110) hide show
  1. package/lib/AutoMovieFrameGrid.d.ts +54 -0
  2. package/lib/AutoMovieFrameGrid.js +71 -0
  3. package/lib/AutoMovieFrameGrid.js.map +1 -0
  4. package/lib/AutoMovieFrameGrid.mjs +20 -0
  5. package/lib/AutoMovieFrameGrid.mjs.map +1 -0
  6. package/lib/caption/canonicalProductionWebVtt.d.ts +5 -3
  7. package/lib/caption/canonicalProductionWebVtt.js +19 -4
  8. package/lib/caption/canonicalProductionWebVtt.js.map +1 -1
  9. package/lib/caption/canonicalProductionWebVtt.mjs +15 -4
  10. package/lib/caption/canonicalProductionWebVtt.mjs.map +1 -1
  11. package/lib/draw/bindAutoMovieDrawSceneSoftProps.d.ts +15 -0
  12. package/lib/draw/bindAutoMovieDrawSceneSoftProps.js +41 -0
  13. package/lib/draw/bindAutoMovieDrawSceneSoftProps.js.map +1 -0
  14. package/lib/draw/bindAutoMovieDrawSceneSoftProps.mjs +36 -0
  15. package/lib/draw/bindAutoMovieDrawSceneSoftProps.mjs.map +1 -0
  16. package/lib/draw/index.d.ts +1 -0
  17. package/lib/draw/index.js +1 -0
  18. package/lib/draw/index.js.map +1 -1
  19. package/lib/draw/index.mjs +2 -1
  20. package/lib/index.d.ts +1 -0
  21. package/lib/index.js +1 -0
  22. package/lib/index.js.map +1 -1
  23. package/lib/index.mjs +12 -7
  24. package/lib/planSequenceRender.d.ts +5 -5
  25. package/lib/planSequenceRender.js +12 -6
  26. package/lib/planSequenceRender.js.map +1 -1
  27. package/lib/planSequenceRender.mjs +12 -8
  28. package/lib/planSequenceRender.mjs.map +1 -1
  29. package/lib/scene/IAutoMovieSceneObject.d.ts +4 -1
  30. package/lib/scene/IAutoMovieSceneSoftProps.d.ts +36 -0
  31. package/lib/scene/IAutoMovieSceneSoftProps.js +3 -0
  32. package/lib/scene/IAutoMovieSceneSoftProps.js.map +1 -0
  33. package/lib/scene/IAutoMovieSceneSoftProps.mjs +0 -0
  34. package/lib/scene/IChunkObject.d.ts +7 -3
  35. package/lib/scene/applyPracticalSurfaceMaterials.d.ts +31 -0
  36. package/lib/scene/applyPracticalSurfaceMaterials.js +87 -0
  37. package/lib/scene/applyPracticalSurfaceMaterials.js.map +1 -0
  38. package/lib/scene/applyPracticalSurfaceMaterials.mjs +47 -0
  39. package/lib/scene/applyPracticalSurfaceMaterials.mjs.map +1 -0
  40. package/lib/scene/buildInstancedFormation.d.ts +1 -1
  41. package/lib/scene/buildInstancedFormation.js +44 -19
  42. package/lib/scene/buildInstancedFormation.js.map +1 -1
  43. package/lib/scene/buildInstancedFormation.mjs +30 -13
  44. package/lib/scene/buildInstancedFormation.mjs.map +1 -1
  45. package/lib/scene/buildScene.d.ts +10 -7
  46. package/lib/scene/buildScene.js +21 -7
  47. package/lib/scene/buildScene.js.map +1 -1
  48. package/lib/scene/buildScene.mjs +27 -9
  49. package/lib/scene/buildScene.mjs.map +1 -1
  50. package/lib/scene/buildSceneSoftProps.d.ts +15 -0
  51. package/lib/scene/buildSceneSoftProps.js +71 -0
  52. package/lib/scene/buildSceneSoftProps.js.map +1 -0
  53. package/lib/scene/buildSceneSoftProps.mjs +67 -0
  54. package/lib/scene/buildSceneSoftProps.mjs.map +1 -0
  55. package/lib/scene/human-polygon/AutoMovieHumanPolygon.d.ts +52 -1
  56. package/lib/scene/human-polygon/buildHumanPolygon.d.ts +3 -1
  57. package/lib/scene/human-polygon/buildHumanPolygon.js +14 -2
  58. package/lib/scene/human-polygon/buildHumanPolygon.js.map +1 -1
  59. package/lib/scene/human-polygon/buildHumanPolygon.mjs +11 -2
  60. package/lib/scene/human-polygon/buildHumanPolygon.mjs.map +1 -1
  61. package/lib/scene/human-polygon/buildPolygonShotActor.d.ts +40 -0
  62. package/lib/scene/human-polygon/buildPolygonShotActor.js +69 -0
  63. package/lib/scene/human-polygon/buildPolygonShotActor.js.map +1 -0
  64. package/lib/scene/human-polygon/buildPolygonShotActor.mjs +74 -0
  65. package/lib/scene/human-polygon/buildPolygonShotActor.mjs.map +1 -0
  66. package/lib/scene/human-polygon/index.d.ts +1 -0
  67. package/lib/scene/human-polygon/index.js +3 -1
  68. package/lib/scene/human-polygon/index.js.map +1 -1
  69. package/lib/scene/human-polygon/index.mjs +2 -1
  70. package/lib/scene/human-polygon/prepareHumanPolygonPresentation.d.ts +17 -0
  71. package/lib/scene/human-polygon/prepareHumanPolygonPresentation.js +231 -0
  72. package/lib/scene/human-polygon/prepareHumanPolygonPresentation.js.map +1 -0
  73. package/lib/scene/human-polygon/prepareHumanPolygonPresentation.mjs +189 -0
  74. package/lib/scene/human-polygon/prepareHumanPolygonPresentation.mjs.map +1 -0
  75. package/lib/scene/index.d.ts +3 -0
  76. package/lib/scene/index.js +3 -0
  77. package/lib/scene/index.js.map +1 -1
  78. package/lib/scene/index.mjs +45 -42
  79. package/lib/scene/renderAutoMovieFilmFrame.d.ts +6 -4
  80. package/lib/scene/renderAutoMovieFilmFrame.js +12 -8
  81. package/lib/scene/renderAutoMovieFilmFrame.js.map +1 -1
  82. package/lib/scene/renderAutoMovieFilmFrame.mjs +12 -8
  83. package/lib/scene/renderAutoMovieFilmFrame.mjs.map +1 -1
  84. package/lib/scene/softPropCordSurface.d.ts +14 -0
  85. package/lib/scene/softPropCordSurface.js +128 -0
  86. package/lib/scene/softPropCordSurface.js.map +1 -0
  87. package/lib/scene/softPropCordSurface.mjs +88 -0
  88. package/lib/scene/softPropCordSurface.mjs.map +1 -0
  89. package/package.json +4 -4
  90. package/src/AutoMovieFrameGrid.ts +70 -0
  91. package/src/caption/canonicalProductionWebVtt.ts +20 -4
  92. package/src/draw/bindAutoMovieDrawSceneSoftProps.ts +43 -0
  93. package/src/draw/index.ts +1 -0
  94. package/src/index.ts +1 -0
  95. package/src/planSequenceRender.ts +21 -10
  96. package/src/scene/IAutoMovieSceneObject.ts +6 -1
  97. package/src/scene/IAutoMovieSceneSoftProps.ts +38 -0
  98. package/src/scene/IChunkObject.ts +10 -3
  99. package/src/scene/applyPracticalSurfaceMaterials.ts +79 -0
  100. package/src/scene/buildInstancedFormation.ts +86 -55
  101. package/src/scene/buildScene.ts +22 -6
  102. package/src/scene/buildSceneSoftProps.ts +83 -0
  103. package/src/scene/human-polygon/AutoMovieHumanPolygon.ts +61 -1
  104. package/src/scene/human-polygon/buildHumanPolygon.ts +22 -2
  105. package/src/scene/human-polygon/buildPolygonShotActor.ts +112 -0
  106. package/src/scene/human-polygon/index.ts +1 -0
  107. package/src/scene/human-polygon/prepareHumanPolygonPresentation.ts +328 -0
  108. package/src/scene/index.ts +3 -0
  109. package/src/scene/renderAutoMovieFilmFrame.ts +14 -9
  110. package/src/scene/softPropCordSurface.ts +132 -0
@@ -1 +1 @@
1
- {"version":3,"file":"buildHumanPolygon.mjs","names":[],"sources":["../../../src/scene/human-polygon/buildHumanPolygon.ts"],"sourcesContent":["import type {\n IAutoMovieHumanBindBone,\n IAutoMovieHumanBonePlacement,\n IAutoMovieHumanSkeleton,\n} from \"@automovie/interface\";\nimport * as THREE from \"three\";\n\nimport { reportAutoMovieResourceRetirement } from \"../reportAutoMovieResourceRetirement.js\";\nimport type { AutoMovieHumanPolygon } from \"./AutoMovieHumanPolygon.js\";\nimport { applyHumanPolygonPose } from \"./applyHumanPolygonPose.js\";\nimport { buildHumanPolygonModule } from \"./buildHumanPolygonModule.js\";\nimport { buildHumanPolygonParts } from \"./buildHumanPolygonParts.js\";\nimport { createHumanPolygonPalette } from \"./createHumanPolygonPalette.js\";\n\n/**\n * Draw a rigid polygon blockout from the generated skeleton, in metres.\n *\n * Every module is procedural and comes from the skeleton alone: joint\n * positions, tips and skin girth radii, never the Human's skin surfaces, so the\n * polygon figure keeps working however the realistic skin is built. The\n * engine's `resolveAutoMovieHumanoidRingModules` owns the rings and their\n * points, which the physical profile also takes its colliders from. Modules\n * use eight-sided sections at their selected levels. Joint spans set torso,\n * palm and foot breadth; girth radii set thickness; the neck runs from the\n * neck joint to the head joint and the head closes on the head's tip. Each\n * rest-space module is moved once by its bone's world placement. Adjacent rigid modules can overlap\n * or separate when posed; this is not skin binding or a watertight skin.\n *\n * The blockout stays deliberately simple: a fix corrects a wrong value (a\n * radius, a length, a frame) within the same primitives and section count,\n * never adds geometry, smoothing, anatomy or realism, because its job is a\n * cheap, deterministic silhouette for motion checks and diffusion hints.\n *\n * The head attachment uses the head joint's rest axes: +X forward, +Y up and\n * +Z left. Its bounds describe the emitted polygon, before the posed transform.\n * The caller may attach a face to `head.object` in that same local frame.\n *\n * @param output Generated bones and placements.\n * @param options Optional display colours keyed by emitted bone name; unmatched palette entries are unused.\n * @returns Owned surface, actual bone/mesh registries, pose/palette ports, generating sections, head attachment and cleanup. Local probe points use registered rest point minus the corresponding rest joint; actor-root placement belongs to the parent.\n *\n * @evidence contracts/development/implementation.md#principled-implementation Every dimension comes from skeleton joints, tips and girth radii; no skin surface of the realistic Human is read, so a change in how the Human lofts its skin cannot break the blockout.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure One section loft draws each rigid module; body-frame placements are consumed once without rebuilding forward kinematics, actual string bone registries expose the same mesh frames, and setPose atomically updates surface and diagnostics.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No fixture dimension or imitated skin enters the drawing; missing joints refuse; rigid shared seams can open when posed.\n * @evidence contracts/development/common.md#meaningful-documentation Documents the LOD, units, head attachment frame, rigid-joint limitations and sticky palette/resource retirement failures.\n * @evidence contracts/development/implementation.md#efficient-algorithms Bone/child/placement maps are built once for B bones. Ring assembly, zipper joining and normal generation follow emitted vertices V and triangles T, with O(B+V+T) construction work/storage.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work Parts share the default clay and diagnostic materials; matching RGB overrides share one current material, and sections reuse emitted ring positions.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources A completed palette becomes owned before the previous pool retires. Independent cleanup attempts every remaining resource and detach operation once; retirement failures remain sticky, reject further colour changes and retain bounded uncertain owners without retry.\n */\nexport function buildHumanPolygon(\n output: Pick<IAutoMovieHumanSkeleton.IOutput, \"bones\" | \"posed\">,\n options: {\n /** RGB hex overrides for matching emitted parts; omitted parts retain clay. */\n partColors?: Readonly<Record<string, number>>;\n } = {},\n): AutoMovieHumanPolygon.IDrawing {\n createHumanPolygonPalette.validate(options.partColors);\n const bones: Map<string, IAutoMovieHumanBindBone> = new Map();\n const placements: Map<string, IAutoMovieHumanBonePlacement> = new Map();\n for (const bone of output.bones) {\n if (\n bones.has(bone.bone) ||\n !(bone.radius > 0) ||\n !Number.isFinite(bone.radius) ||\n !bone.position.every(Number.isFinite) ||\n (bone.tip !== null && !bone.tip.every(Number.isFinite))\n )\n throw new Error(`Invalid polygon skeleton bone: ${bone.bone}`);\n bones.set(bone.bone, bone);\n }\n for (const placement of output.posed)\n placements.set(placement.bone, placement);\n\n /**\n * Resolve an original construction joint or refuse its missing identity.\n *\n * Principled implementation: Reads the fixed rest map by exact bone id and throws instead of inventing a joint.\n * Clear and simple design: One lookup serves original shape selection.\n * Prohibited implementation shortcuts: No fallback anatomy or fixture selector is used.\n * Meaningful documentation: States exact identity and missing-joint refusal.\n * Efficient algorithms: Constant map lookup.\n * Reuse equivalent work: Reads the map built once from the supplied rest bones.\n * Bound retention and release resources: Borrows map entries only for synchronous construction.\n */\n const boneAt: (name: string) => IAutoMovieHumanBindBone = (\n name: string,\n ): IAutoMovieHumanBindBone => {\n const bone: IAutoMovieHumanBindBone | undefined = bones.get(name);\n if (bone === undefined)\n throw new Error(`Missing polygon skeleton bone: ${name}`);\n return bone;\n };\n const object: THREE.Group = new THREE.Group();\n object.name = \"human.polygon\";\n const surface: THREE.Group = new THREE.Group();\n surface.name = \"human.polygon.surface\";\n const sections: THREE.Group = new THREE.Group();\n sections.name = \"human.polygon.sections\";\n sections.visible = false;\n object.add(surface, sections);\n const geometries: THREE.BufferGeometry[] = [];\n const groups: Map<string, THREE.Group> = new Map();\n const partMeshes: Map<string, THREE.Mesh> = new Map();\n const bindings: Map<string, readonly THREE.Object3D[]> = new Map();\n const required: string[] = output.bones.map(\n (bone: IAutoMovieHumanBindBone): string => bone.bone,\n );\n\n // Validate the complete original rig, including custom non-emitted joints,\n // before acquiring drawing materials or mutating a displayed graph.\n applyHumanPolygonPose(object, bindings, required, output);\n const material: THREE.MeshStandardMaterial = new THREE.MeshStandardMaterial({\n color: 0xc7b6a3,\n roughness: 0.85,\n flatShading: true,\n });\n const lineMaterial: THREE.LineBasicMaterial = new THREE.LineBasicMaterial({\n color: 0x206b7a,\n depthTest: false,\n });\n const palette: ReturnType<typeof createHumanPolygonPalette> =\n createHumanPolygonPalette(material, partMeshes);\n let disposed: boolean = false;\n let retirementFailure: { error: unknown } | undefined;\n\n /**\n * Guard the existing palette lifetime before replacing display colours.\n *\n * Principled implementation: Refuses a disposed drawing and delegates RGB admission/allocation to the original palette owner.\n * Clear and simple design: The drawing owns the disposal guard and the palette owns materials.\n * Prohibited implementation shortcuts: Palette changes alter no geometry or pose.\n * Meaningful documentation: States lifetime refusal and palette delegation.\n * Efficient algorithms: Constant guard plus the palette's O(P) assignment scan.\n * Reuse equivalent work: Reuses emitted meshes and equal-current-RGB materials.\n * Bound retention and release resources: The palette owns current/uncertain material pools; this guard adds no native resource.\n */\n const setPartColors: (colors?: Readonly<Record<string, number>>) => void = (\n colors?: Readonly<Record<string, number>>,\n ): void => {\n if (disposed) throw new Error(\"Polygon drawing is disposed\");\n palette.setPartColors(colors);\n };\n\n /**\n * Register the original module's actual surface and diagnostic bone frames.\n *\n * Principled implementation: Calls the unchanged module assembler with the selected sections and supplied bind-relative placement, then registers its actual returned objects by exact bone identity.\n * Clear and simple design: One assembly seam connects original geometry to stable public mesh/group registries.\n * Prohibited implementation shortcuts: Registry values are displayed objects rather than collision proxies or reconstructed forms.\n * Meaningful documentation: States actual-object registration and shared diagnostic placement.\n * Efficient algorithms: One map lookup/registration plus the assembler's ring/index work per emitted part.\n * Reuse equivalent work: Reuses borrowed default materials and a single geometry retirement inventory.\n * Bound retention and release resources: Newly emitted buffers transfer to the drawing inventory and registries until terminal disposal.\n */\n const add: (\n bone: IAutoMovieHumanBindBone,\n rings: buildHumanPolygonModule.ISection[],\n axis: THREE.Vector3,\n breadth?: THREE.Vector3,\n topPole?: [number, number, number],\n ) => THREE.Group = (\n bone: IAutoMovieHumanBindBone,\n rings: buildHumanPolygonModule.ISection[],\n axis: THREE.Vector3,\n breadth?: THREE.Vector3,\n topPole?: [number, number, number],\n ): THREE.Group => {\n const placement: IAutoMovieHumanBonePlacement | undefined = placements.get(\n bone.bone,\n );\n if (placement === undefined)\n throw new Error(`Missing polygon placement: ${bone.bone}`);\n const {\n group,\n diagnostic,\n part,\n }: ReturnType<typeof buildHumanPolygonModule> = buildHumanPolygonModule(\n bone,\n rings,\n placement,\n material,\n lineMaterial,\n geometries,\n axis,\n breadth,\n topPole,\n );\n partMeshes.set(bone.bone, part);\n surface.add(group);\n sections.add(diagnostic);\n groups.set(bone.bone, group);\n bindings.set(bone.bone, [group, diagnostic]);\n return group;\n };\n\n /**\n * Preserve original one-attempt resource retirement and sticky failures.\n *\n * Principled implementation: Attempts every owned geometry/material/palette and graph-detach operation through the existing reporter; completed disposal clears registries, and failure is retained/rethrown without retry.\n * Clear and simple design: One terminal drawing owner coordinates palette retirement and actual graph release.\n * Prohibited implementation shortcuts: Separately attached faces/equipment are not silently claimed or disposed.\n * Meaningful documentation: States one-attempt cleanup, failure retention and attached-resource ownership.\n * Efficient algorithms: O(R+P) retirement for R owned buffers/materials and P registered parts; successful repeat is constant.\n * Reuse equivalent work: Repeated disposal returns or rethrows its original terminal result instead of rerunning effectful release.\n * Bound retention and release resources: Clears geometry and registry populations on success; failed retirement preserves the bounded uncertain owners and original cause.\n */\n const dispose: (primary?: { error: unknown }) => void = (primary?: {\n error: unknown;\n }): void => {\n if (retirementFailure !== undefined) throw retirementFailure.error;\n if (disposed) return;\n disposed = true;\n try {\n reportAutoMovieResourceRetirement(\n [\n ...geometries.map(\n (geometry: THREE.BufferGeometry): (() => void) =>\n (): void =>\n geometry.dispose(),\n ),\n (): void => material.dispose(),\n (): void => lineMaterial.dispose(),\n (): void => palette.dispose(),\n (): void => {\n object.removeFromParent();\n },\n (): void => {\n object.clear();\n },\n (): void => partMeshes.clear(),\n (): void => groups.clear(),\n (): void => bindings.clear(),\n ],\n palette.failure ?? primary,\n );\n palette.completeRetirement();\n geometries.length = 0;\n } catch (error: unknown) {\n retirementFailure = { error };\n throw error;\n }\n };\n let headObject: THREE.Group;\n let headMesh: THREE.Mesh;\n let headBox: THREE.Box3;\n try {\n ({ headObject, headMesh, headBox } = buildHumanPolygonParts(\n output,\n boneAt,\n add,\n ));\n // Non-emitted driving joints remain real scene nodes for attachments and\n // world-space inspection, using the same admitted evaluator placements.\n for (const bone of output.bones) {\n if (groups.has(bone.bone)) continue;\n const joint: THREE.Group = new THREE.Group();\n joint.name = bone.bone;\n surface.add(joint);\n groups.set(bone.bone, joint);\n bindings.set(bone.bone, [joint]);\n }\n setPartColors(options.partColors);\n applyHumanPolygonPose(object, bindings, required, output);\n } catch (error: unknown) {\n dispose({ error });\n throw error;\n }\n return {\n object,\n surface,\n sections,\n parts: partMeshes,\n bones: groups,\n bindings,\n setPose: (\n pose: Pick<\n Pick<IAutoMovieHumanSkeleton.IOutput, \"bones\" | \"posed\">,\n \"posed\"\n >,\n ): void => {\n if (disposed) throw new Error(\"Polygon drawing is disposed\");\n applyHumanPolygonPose(object, bindings, required, pose);\n },\n setPartColors,\n head: {\n object: headObject,\n min: [headBox.min.x, headBox.min.y, headBox.min.z],\n max: [headBox.max.x, headBox.max.y, headBox.max.z],\n frontAt: (y: number, z: number): number | undefined =>\n buildHumanPolygonModule.frontAt(headMesh.geometry, headBox, y, z),\n },\n dispose,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,kBACd,QACA,UAGI,CAAC,GAC2B;CAChC,0BAA0B,SA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EAGA,KAAK,MAAM,QAAQ,OAAO,OAAO;GAC/B,IAAI,OAAO,IAAI,KAAK,IAAI,GAAG;GAC3B,MAAM,QAAqB,IAAI,MAAM,MAAM;GAC3C,MAAM,OAAO,KAAK;GAClB,QAAQ,IAAI,KAAK;GACjB,OAAO,IAAI,KAAK,MAAM,KAAK;GAC3B,SAAS,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC;EACjC;EACA,cAAc,QAAQ,UAAU;EAChC,sBAAsB,QAAQ,UAAU,UAAU,MAAM;CAC1D,SAAS,OAAgB;EACvB,QAAQ,EAAE,MAAM,CAAC;EACjB,MAAM;CACR;CACA,OAAO;EACL;EACA;EACA;EACA,OAAO;EACP,OAAO;EACP;EACA,UACE,SAIS;GACT,IAAI,UAAU,MAAM,IAAI,MAAM,6BAA6B;GAC3D,sBAAsB,QAAQ,UAAU,UAAU,IAAI;EACxD;EACA;EACA,MAAM;GACJ,QAAQ;GACR,KAAK;IAAC,QAAQ,IAAI;IAAG,QAAQ,IAAI;IAAG,QAAQ,IAAI;GAAC;GACjD,KAAK;IAAC,QAAQ,IAAI;IAAG,QAAQ,IAAI;IAAG,QAAQ,IAAI;GAAC;GACjD,UAAU,GAAW,MACnB,wBAAwB,QAAQ,SAAS,UAAU,SAAS,GAAG,CAAC;EACpE;EACA;CACF;AACF"}
1
+ {"version":3,"file":"buildHumanPolygon.mjs","names":[],"sources":["../../../src/scene/human-polygon/buildHumanPolygon.ts"],"sourcesContent":["import type {\n IAutoMovieHumanBindBone,\n IAutoMovieHumanBonePlacement,\n IAutoMovieHumanSkeleton,\n} from \"@automovie/interface\";\nimport * as THREE from \"three\";\n\nimport { reportAutoMovieResourceRetirement } from \"../reportAutoMovieResourceRetirement.js\";\nimport type { AutoMovieHumanPolygon } from \"./AutoMovieHumanPolygon.js\";\nimport { applyHumanPolygonPose } from \"./applyHumanPolygonPose.js\";\nimport { buildHumanPolygonModule } from \"./buildHumanPolygonModule.js\";\nimport { buildHumanPolygonParts } from \"./buildHumanPolygonParts.js\";\nimport { createHumanPolygonPalette } from \"./createHumanPolygonPalette.js\";\nimport { prepareHumanPolygonPresentation } from \"./prepareHumanPolygonPresentation.js\";\n\n/**\n * Draw a rigid polygon blockout from the generated skeleton, in metres.\n *\n * Every module is procedural and comes from the skeleton alone: joint\n * positions, tips and skin girth radii, never the Human's skin surfaces, so the\n * polygon figure keeps working however the realistic skin is built. The\n * engine's `resolveAutoMovieHumanoidRingModules` owns the rings and their\n * points, which the physical profile also takes its colliders from. Modules\n * use eight-sided sections at their selected levels. Joint spans set torso,\n * palm and foot breadth; girth radii set thickness; the neck runs from the\n * neck joint to the head joint and the head closes on the head's tip. Each\n * rest-space module is moved once by its bone's world placement. Adjacent rigid modules can overlap\n * or separate when posed; this is not skin binding or a watertight skin.\n *\n * The blockout stays deliberately simple: a fix corrects a wrong value (a\n * radius, a length, a frame) within the same primitives and section count,\n * never adds geometry, smoothing, anatomy or realism, because its job is a\n * cheap, deterministic silhouette for motion checks and diffusion hints.\n *\n * The head attachment uses the head joint's rest axes: +X forward, +Y up and\n * +Z left. Its bounds describe the emitted polygon, before the posed transform.\n * The caller may attach a face to `head.object` in that same local frame.\n *\n * @param output Generated bones and placements.\n * @param options Optional display colours keyed by emitted bone name and authored cues sampled on the shot-local source clock.\n * @returns Owned surface, actual bone/mesh registries, pose/palette ports, generating sections, head attachment and cleanup. Local probe points use registered rest point minus the corresponding rest joint; actor-root placement belongs to the parent.\n *\n * @evidence contracts/development/implementation.md#principled-implementation Every dimension comes from skeleton joints, tips and girth radii; no skin surface of the realistic Human is read, so a change in how the Human lofts its skin cannot break the blockout.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure One section loft draws each rigid module; body-frame placements are consumed once without rebuilding forward kinematics, actual string bone registries expose the same mesh frames, and setPose atomically updates surface and diagnostics.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No fixture dimension or imitated skin enters the drawing; missing joints refuse; rigid shared seams can open when posed.\n * @evidence contracts/development/common.md#meaningful-documentation Documents the LOD, units, head attachment frame, rigid-joint limitations and sticky palette/resource retirement failures.\n * @evidence contracts/development/implementation.md#efficient-algorithms Bone/child/placement maps are built once for B bones. Ring assembly, zipper joining and normal generation follow emitted vertices V and triangles T, with O(B+V+T) construction work/storage.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work Parts share the default clay and diagnostic materials; matching RGB overrides share one current material, and sections reuse emitted ring positions.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources A completed palette becomes owned before the previous pool retires. Independent cleanup attempts every remaining resource and detach operation once; retirement failures remain sticky, reject further colour changes and retain bounded uncertain owners without retry.\n */\nexport function buildHumanPolygon(\n output: Pick<IAutoMovieHumanSkeleton.IOutput, \"bones\" | \"posed\">,\n options: {\n /** RGB hex overrides for matching emitted parts; omitted parts retain clay. */\n partColors?: Readonly<Record<string, number>>;\n /** Source pose, actor frame and authored polygon cues for optional time-based drawing. */\n presentation?: AutoMovieHumanPolygon.IPresentation;\n } = {},\n): AutoMovieHumanPolygon.IDrawing {\n createHumanPolygonPalette.validate(options.partColors);\n const bones: Map<string, IAutoMovieHumanBindBone> = new Map();\n const placements: Map<string, IAutoMovieHumanBonePlacement> = new Map();\n for (const bone of output.bones) {\n if (\n bones.has(bone.bone) ||\n !(bone.radius > 0) ||\n !Number.isFinite(bone.radius) ||\n !bone.position.every(Number.isFinite) ||\n (bone.tip !== null && !bone.tip.every(Number.isFinite))\n )\n throw new Error(`Invalid polygon skeleton bone: ${bone.bone}`);\n bones.set(bone.bone, bone);\n }\n for (const placement of output.posed)\n placements.set(placement.bone, placement);\n\n /**\n * Resolve an original construction joint or refuse its missing identity.\n *\n * Principled implementation: Reads the fixed rest map by exact bone id and throws instead of inventing a joint.\n * Clear and simple design: One lookup serves original shape selection.\n * Prohibited implementation shortcuts: No fallback anatomy or fixture selector is used.\n * Meaningful documentation: States exact identity and missing-joint refusal.\n * Efficient algorithms: Constant map lookup.\n * Reuse equivalent work: Reads the map built once from the supplied rest bones.\n * Bound retention and release resources: Borrows map entries only for synchronous construction.\n */\n const boneAt: (name: string) => IAutoMovieHumanBindBone = (\n name: string,\n ): IAutoMovieHumanBindBone => {\n const bone: IAutoMovieHumanBindBone | undefined = bones.get(name);\n if (bone === undefined)\n throw new Error(`Missing polygon skeleton bone: ${name}`);\n return bone;\n };\n const object: THREE.Group = new THREE.Group();\n object.name = \"human.polygon\";\n const surface: THREE.Group = new THREE.Group();\n surface.name = \"human.polygon.surface\";\n const sections: THREE.Group = new THREE.Group();\n sections.name = \"human.polygon.sections\";\n sections.visible = false;\n object.add(surface, sections);\n const geometries: THREE.BufferGeometry[] = [];\n const groups: Map<string, THREE.Group> = new Map();\n const partMeshes: Map<string, THREE.Mesh> = new Map();\n const bindings: Map<string, readonly THREE.Object3D[]> = new Map();\n const required: string[] = output.bones.map(\n (bone: IAutoMovieHumanBindBone): string => bone.bone,\n );\n\n // Validate the complete original rig, including custom non-emitted joints,\n // before acquiring drawing materials or mutating a displayed graph.\n applyHumanPolygonPose(object, bindings, required, output);\n const material: THREE.MeshStandardMaterial = new THREE.MeshStandardMaterial({\n color: 0xc7b6a3,\n roughness: 0.85,\n flatShading: true,\n });\n const lineMaterial: THREE.LineBasicMaterial = new THREE.LineBasicMaterial({\n color: 0x206b7a,\n depthTest: false,\n });\n const palette: ReturnType<typeof createHumanPolygonPalette> =\n createHumanPolygonPalette(material, partMeshes);\n let disposed: boolean = false;\n let samplePresentation:\n | ReturnType<typeof prepareHumanPolygonPresentation>\n | undefined;\n let retirementFailure: { error: unknown } | undefined;\n\n /**\n * Guard the existing palette lifetime before replacing display colours.\n *\n * Principled implementation: Refuses a disposed drawing and delegates RGB admission/allocation to the original palette owner.\n * Clear and simple design: The drawing owns the disposal guard and the palette owns materials.\n * Prohibited implementation shortcuts: Palette changes alter no geometry or pose.\n * Meaningful documentation: States lifetime refusal and palette delegation.\n * Efficient algorithms: Constant guard plus the palette's O(P) assignment scan.\n * Reuse equivalent work: Reuses emitted meshes and equal-current-RGB materials.\n * Bound retention and release resources: The palette owns current/uncertain material pools; this guard adds no native resource.\n */\n const setPartColors: (colors?: Readonly<Record<string, number>>) => void = (\n colors?: Readonly<Record<string, number>>,\n ): void => {\n if (disposed) throw new Error(\"Polygon drawing is disposed\");\n palette.setPartColors(colors);\n };\n\n /**\n * Register the original module's actual surface and diagnostic bone frames.\n *\n * Principled implementation: Calls the unchanged module assembler with the selected sections and supplied bind-relative placement, then registers its actual returned objects by exact bone identity.\n * Clear and simple design: One assembly seam connects original geometry to stable public mesh/group registries.\n * Prohibited implementation shortcuts: Registry values are displayed objects rather than collision proxies or reconstructed forms.\n * Meaningful documentation: States actual-object registration and shared diagnostic placement.\n * Efficient algorithms: One map lookup/registration plus the assembler's ring/index work per emitted part.\n * Reuse equivalent work: Reuses borrowed default materials and a single geometry retirement inventory.\n * Bound retention and release resources: Newly emitted buffers transfer to the drawing inventory and registries until terminal disposal.\n */\n const add: (\n bone: IAutoMovieHumanBindBone,\n rings: buildHumanPolygonModule.ISection[],\n axis: THREE.Vector3,\n breadth?: THREE.Vector3,\n topPole?: [number, number, number],\n ) => THREE.Group = (\n bone: IAutoMovieHumanBindBone,\n rings: buildHumanPolygonModule.ISection[],\n axis: THREE.Vector3,\n breadth?: THREE.Vector3,\n topPole?: [number, number, number],\n ): THREE.Group => {\n const placement: IAutoMovieHumanBonePlacement | undefined = placements.get(\n bone.bone,\n );\n if (placement === undefined)\n throw new Error(`Missing polygon placement: ${bone.bone}`);\n const {\n group,\n diagnostic,\n part,\n }: ReturnType<typeof buildHumanPolygonModule> = buildHumanPolygonModule(\n bone,\n rings,\n placement,\n material,\n lineMaterial,\n geometries,\n axis,\n breadth,\n topPole,\n );\n partMeshes.set(bone.bone, part);\n surface.add(group);\n sections.add(diagnostic);\n groups.set(bone.bone, group);\n bindings.set(bone.bone, [group, diagnostic]);\n return group;\n };\n\n /**\n * Preserve original one-attempt resource retirement and sticky failures.\n *\n * Principled implementation: Attempts every owned geometry/material/palette and graph-detach operation through the existing reporter; completed disposal clears registries, and failure is retained/rethrown without retry.\n * Clear and simple design: One terminal drawing owner coordinates palette retirement and actual graph release.\n * Prohibited implementation shortcuts: Separately attached faces/equipment are not silently claimed or disposed.\n * Meaningful documentation: States one-attempt cleanup, failure retention and attached-resource ownership.\n * Efficient algorithms: O(R+P) retirement for R owned buffers/materials and P registered parts; successful repeat is constant.\n * Reuse equivalent work: Repeated disposal returns or rethrows its original terminal result instead of rerunning effectful release.\n * Bound retention and release resources: Clears geometry and registry populations on success; failed retirement preserves the bounded uncertain owners and original cause.\n */\n const dispose: (primary?: { error: unknown }) => void = (primary?: {\n error: unknown;\n }): void => {\n if (retirementFailure !== undefined) throw retirementFailure.error;\n if (disposed) return;\n disposed = true;\n samplePresentation = undefined;\n try {\n reportAutoMovieResourceRetirement(\n [\n ...geometries.map(\n (geometry: THREE.BufferGeometry): (() => void) =>\n (): void =>\n geometry.dispose(),\n ),\n (): void => material.dispose(),\n (): void => lineMaterial.dispose(),\n (): void => palette.dispose(),\n (): void => {\n object.removeFromParent();\n },\n (): void => {\n object.clear();\n },\n (): void => partMeshes.clear(),\n (): void => groups.clear(),\n (): void => bindings.clear(),\n ],\n palette.failure ?? primary,\n );\n palette.completeRetirement();\n geometries.length = 0;\n } catch (error: unknown) {\n retirementFailure = { error };\n throw error;\n }\n };\n let headObject: THREE.Group;\n let headMesh: THREE.Mesh;\n let headBox: THREE.Box3;\n try {\n ({ headObject, headMesh, headBox } = buildHumanPolygonParts(\n output,\n boneAt,\n add,\n ));\n // Non-emitted driving joints remain real scene nodes for attachments and\n // world-space inspection, using the same admitted evaluator placements.\n for (const bone of output.bones) {\n if (groups.has(bone.bone)) continue;\n const joint: THREE.Group = new THREE.Group();\n joint.name = bone.bone;\n surface.add(joint);\n groups.set(bone.bone, joint);\n bindings.set(bone.bone, [joint]);\n }\n if (options.presentation !== undefined)\n samplePresentation = prepareHumanPolygonPresentation(\n options.presentation,\n bones,\n new Set(partMeshes.keys()),\n );\n setPartColors(options.partColors);\n applyHumanPolygonPose(object, bindings, required, output);\n } catch (error: unknown) {\n dispose({ error });\n throw error;\n }\n const drawing: AutoMovieHumanPolygon.IDrawing = {\n object,\n surface,\n sections,\n parts: partMeshes,\n bones: groups,\n bindings,\n setPose: (\n pose: Pick<\n Pick<IAutoMovieHumanSkeleton.IOutput, \"bones\" | \"posed\">,\n \"posed\"\n >,\n ): void => {\n if (disposed) throw new Error(\"Polygon drawing is disposed\");\n applyHumanPolygonPose(object, bindings, required, pose);\n },\n setPartColors,\n head: {\n object: headObject,\n min: [headBox.min.x, headBox.min.y, headBox.min.z],\n max: [headBox.max.x, headBox.max.y, headBox.max.z],\n frontAt: (y: number, z: number): number | undefined =>\n buildHumanPolygonModule.frontAt(headMesh.geometry, headBox, y, z),\n },\n dispose,\n };\n if (samplePresentation !== undefined)\n drawing.drawAt = (seconds: number): void => {\n if (samplePresentation === undefined)\n throw new Error(\"Polygon drawing is disposed\");\n drawing.setPose(samplePresentation(seconds));\n };\n return drawing;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,kBACd,QACA,UAKI,CAAC,GAC2B;CAChC,0BAA0B,SAAS,QAAQ,UAAU;CACrD,MAAM,wBAA8C,IAAI,IAAI;CAC5D,MAAM,6BAAwD,IAAI,IAAI;CACtE,KAAK,MAAM,QAAQ,OAAO,OAAO;EAC/B,IACE,MAAM,IAAI,KAAK,IAAI,KACnB,EAAE,KAAK,SAAS,MAChB,CAAC,OAAO,SAAS,KAAK,MAAM,KAC5B,CAAC,KAAK,SAAS,MAAM,OAAO,QAAQ,KACnC,KAAK,QAAQ,QAAQ,CAAC,KAAK,IAAI,MAAM,OAAO,QAAQ,GAErD,MAAM,IAAI,MAAM,kCAAkC,KAAK,MAAM;EAC/D,MAAM,IAAI,KAAK,MAAM,IAAI;CAC3B;CACA,KAAK,MAAM,aAAa,OAAO,OAC7B,WAAW,IAAI,UAAU,MAAM,SAAS;;;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AAgB;EACvB,QAAQ,EAAE,MAAM,CAAC;EACjB,MAAM;CACR;CACA,MAAM,UAA0C;EAC9C;EACA;EACA;EACA,OAAO;EACP,OAAO;EACP;EACA,UACE,SAIS;GACT,IAAI,UAAU,MAAM,IAAI,MAAM,6BAA6B;GAC3D,sBAAsB,QAAQ,UAAU,UAAU,IAAI;EACxD;EACA;EACA,MAAM;GACJ,QAAQ;GACR,KAAK;IAAC,QAAQ,IAAI;IAAG,QAAQ,IAAI;IAAG,QAAQ,IAAI;GAAC;GACjD,KAAK;IAAC,QAAQ,IAAI;IAAG,QAAQ,IAAI;IAAG,QAAQ,IAAI;GAAC;GACjD,UAAU,GAAW,MACnB,wBAAwB,QAAQ,SAAS,UAAU,SAAS,GAAG,CAAC;EACpE;EACA;CACF;CACA,IAAI,uBAAuB,KAAA,GACzB,QAAQ,UAAU,YAA0B;EAC1C,IAAI,uBAAuB,KAAA,GACzB,MAAM,IAAI,MAAM,6BAA6B;EAC/C,QAAQ,QAAQ,mBAAmB,OAAO,CAAC;CAC7C;CACF,OAAO;AACT"}
@@ -0,0 +1,40 @@
1
+ import type { IAutoMovieHumanSkeleton, IAutoMovieProductionFrameRate, IAutoMovieProductionRenderLayer, IAutoMovieRigidTransform, IAutoMovieShot } from "@automovie/interface";
2
+ import type { AutoMovieHumanPolygon } from "./AutoMovieHumanPolygon.js";
3
+ /**
4
+ * Build a polygon actor and its source-frame sampler for a compiled shot.
5
+ * A film host mounts the drawing in the shot scene and supplies `drawLayer`
6
+ * as a layer preparation callback. Its source frame accounts for cuts and
7
+ * trims. If an actor frame is supplied, the sampler also places the drawing
8
+ * at that world frame under its rigid parent. Without a supplied frame the
9
+ * cue's shot axes coincide with the drawing's axes at the origin.
10
+ * Dispose the drawing with the usual polygon drawing owner.
11
+ *
12
+ * @evidence contracts/development/common.md#meaningful-documentation States the host's mounting, sampling and disposal responsibilities, along with the source time and frame conventions.
13
+ * @evidence contracts/development/implementation.md#principled-implementation All passes read the same polygon node transform at the exact shot-local frame boundary.
14
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Build the existing drawing with its shot cues, then convert each layer's source frame through the production clock.
15
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses a layer from another shot and uses the timeline's source frame directly.
16
+ * @evidence contracts/development/implementation.md#efficient-algorithms The polygon drawing and cue plan are built once. Each layer converts one frame and applies one sample.
17
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Uses the regular polygon drawing and the same rational clock as other production render passes.
18
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned drawing owns the render resources. The sampler retains that drawing and the shot's fixed source clock.
19
+ */
20
+ export declare function buildPolygonShotActor(input: {
21
+ /** Compiled shot and its optional body presentation cues. */
22
+ shot: Pick<IAutoMovieShot, "id" | "polygonBodyCues">;
23
+ /** Staged actor id. */
24
+ subject: string;
25
+ /** Bind bones and placements used to build the polygon drawing. */
26
+ opening: Pick<IAutoMovieHumanSkeleton.IOutput, "bones" | "posed">;
27
+ /** Canonical body-frame pose at a shot-local time. */
28
+ poseAt: (seconds: number) => Pick<IAutoMovieHumanSkeleton.IOutput, "posed">;
29
+ /** Deterministic, synchronous actor rigid frame at shot-local time in scene-world axes. Detach sampling can read the same time again. */
30
+ actorFrameAt?: (seconds: number) => IAutoMovieRigidTransform;
31
+ /** Production frame grid used by the layer's source frame. */
32
+ frameRate: IAutoMovieProductionFrameRate;
33
+ /** Optional palette by emitted bone name. */
34
+ partColors?: Readonly<Record<string, number>>;
35
+ }): {
36
+ /** Drawing to mount in the shot scene and dispose when finished. */
37
+ drawing: AutoMovieHumanPolygon.IDrawing;
38
+ /** Evaluate the visible actor for an admitted render layer of this shot. */
39
+ drawLayer: (layer: IAutoMovieProductionRenderLayer) => void;
40
+ };
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildPolygonShotActor = buildPolygonShotActor;
4
+ const engine_1 = require("@automovie/engine");
5
+ const three_1 = require("three");
6
+ const buildHumanPolygon_js_1 = require("./buildHumanPolygon.js");
7
+ /**
8
+ * Build a polygon actor and its source-frame sampler for a compiled shot.
9
+ * A film host mounts the drawing in the shot scene and supplies `drawLayer`
10
+ * as a layer preparation callback. Its source frame accounts for cuts and
11
+ * trims. If an actor frame is supplied, the sampler also places the drawing
12
+ * at that world frame under its rigid parent. Without a supplied frame the
13
+ * cue's shot axes coincide with the drawing's axes at the origin.
14
+ * Dispose the drawing with the usual polygon drawing owner.
15
+ *
16
+ * @evidence contracts/development/common.md#meaningful-documentation States the host's mounting, sampling and disposal responsibilities, along with the source time and frame conventions.
17
+ * @evidence contracts/development/implementation.md#principled-implementation All passes read the same polygon node transform at the exact shot-local frame boundary.
18
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Build the existing drawing with its shot cues, then convert each layer's source frame through the production clock.
19
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses a layer from another shot and uses the timeline's source frame directly.
20
+ * @evidence contracts/development/implementation.md#efficient-algorithms The polygon drawing and cue plan are built once. Each layer converts one frame and applies one sample.
21
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Uses the regular polygon drawing and the same rational clock as other production render passes.
22
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned drawing owns the render resources. The sampler retains that drawing and the shot's fixed source clock.
23
+ */
24
+ function buildPolygonShotActor(input) {
25
+ const { shot, subject, opening, poseAt, actorFrameAt, frameRate, partColors, } = input;
26
+ const drawing = (0, buildHumanPolygon_js_1.buildHumanPolygon)(opening, {
27
+ ...(partColors === undefined ? {} : { partColors }),
28
+ presentation: {
29
+ subject,
30
+ cues: shot.polygonBodyCues ?? [],
31
+ poseAt,
32
+ ...(actorFrameAt === undefined ? {} : { actorFrameAt }),
33
+ },
34
+ });
35
+ const shotId = shot.id;
36
+ return {
37
+ drawing,
38
+ drawLayer: (layer) => {
39
+ if (layer.shot !== shotId)
40
+ throw new Error(`Polygon actor ${subject} belongs to shot ${shotId}`);
41
+ const seconds = (0, engine_1.productionFrameBoundaryToSeconds)({
42
+ frame: layer.sourceFrame,
43
+ frameRate,
44
+ });
45
+ if (actorFrameAt === undefined) {
46
+ drawing.drawAt(seconds);
47
+ return;
48
+ }
49
+ const { position: translation, rotation: orientation, } = actorFrameAt(seconds);
50
+ const { x: tx, y: ty, z: tz } = translation;
51
+ const { x, y, z, w } = orientation;
52
+ if (![tx, ty, tz, x, y, z, w].every(Number.isFinite) ||
53
+ Math.abs(x ** 2 + y ** 2 + z ** 2 + w ** 2 - 1) > 1e-6)
54
+ throw new Error(`Invalid staging frame for polygon actor ${subject}`);
55
+ const position = new three_1.Vector3(tx, ty, tz);
56
+ const rotation = new three_1.Quaternion(x, y, z, w).normalize();
57
+ const parent = drawing.object.parent;
58
+ if (parent !== null) {
59
+ parent.worldToLocal(position);
60
+ rotation.premultiply(parent.getWorldQuaternion(new three_1.Quaternion()).invert());
61
+ }
62
+ drawing.drawAt(seconds);
63
+ drawing.object.position.copy(position);
64
+ drawing.object.quaternion.copy(rotation);
65
+ drawing.object.updateWorldMatrix(true, true);
66
+ },
67
+ };
68
+ }
69
+ //# sourceMappingURL=buildPolygonShotActor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPolygonShotActor.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/buildPolygonShotActor.ts"],"names":[],"mappings":";;;AAAA,8CAAqE;AAUrE,iCAA4C;AAG5C,iEAA2D;AAE3D;;;;;;;;;;;;;;;;GAgBG;AACH,+BAAsC,KAerC;IAMC,MAAM,EACJ,IAAI,EACJ,OAAO,EACP,OAAO,EACP,MAAM,EACN,YAAY,EACZ,SAAS,EACT,UAAU,GACX,GAAG,KAAK,CAAC;IACV,MAAM,OAAO,GAAmC,IAAA,wCAAiB,EAAC,OAAO,EAAE;QACzE,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,YAAY,EA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C,GAAG,CAAC,CAAC,GAAG,IAAI;gBAEtD,MAAM,IAAI,KAAK,CAAC,2CAA2C,OAAO,EAAE,CAAC,CAAC;YACxE,MAAM,QAAQ,GAAY,IAAI,eAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;YAClD,MAAM,QAAQ,GAAe,IAAI,kBAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;YACpE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBACpB,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAC9B,QAAQ,CAAC,WAAW,CAClB,MAAM,CAAC,kBAAkB,CAAC,IAAI,kBAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CACrD,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,MAAO,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACvC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { buildHumanPolygon } from "./buildHumanPolygon.mjs";
2
+ import { productionFrameBoundaryToSeconds } from "@automovie/engine";
3
+ import { Quaternion, Vector3 } from "three";
4
+ // src/scene/human-polygon/buildPolygonShotActor.ts
5
+ /**
6
+ * Build a polygon actor and its source-frame sampler for a compiled shot.
7
+ * A film host mounts the drawing in the shot scene and supplies `drawLayer`
8
+ * as a layer preparation callback. Its source frame accounts for cuts and
9
+ * trims. If an actor frame is supplied, the sampler also places the drawing
10
+ * at that world frame under its rigid parent. Without a supplied frame the
11
+ * cue's shot axes coincide with the drawing's axes at the origin.
12
+ * Dispose the drawing with the usual polygon drawing owner.
13
+ *
14
+ * @evidence contracts/development/common.md#meaningful-documentation States the host's mounting, sampling and disposal responsibilities, along with the source time and frame conventions.
15
+ * @evidence contracts/development/implementation.md#principled-implementation All passes read the same polygon node transform at the exact shot-local frame boundary.
16
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Build the existing drawing with its shot cues, then convert each layer's source frame through the production clock.
17
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses a layer from another shot and uses the timeline's source frame directly.
18
+ * @evidence contracts/development/implementation.md#efficient-algorithms The polygon drawing and cue plan are built once. Each layer converts one frame and applies one sample.
19
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work Uses the regular polygon drawing and the same rational clock as other production render passes.
20
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned drawing owns the render resources. The sampler retains that drawing and the shot's fixed source clock.
21
+ */
22
+ function buildPolygonShotActor(input) {
23
+ const { shot, subject, opening, poseAt, actorFrameAt, frameRate, partColors } = input;
24
+ const drawing = buildHumanPolygon(opening, {
25
+ ...partColors === void 0 ? {} : { partColors },
26
+ presentation: {
27
+ subject,
28
+ cues: shot.polygonBodyCues ?? [],
29
+ poseAt,
30
+ ...actorFrameAt === void 0 ? {} : { actorFrameAt }
31
+ }
32
+ });
33
+ const shotId = shot.id;
34
+ return {
35
+ drawing,
36
+ drawLayer: (layer) => {
37
+ if (layer.shot !== shotId) throw new Error(`Polygon actor ${subject} belongs to shot ${shotId}`);
38
+ const seconds = productionFrameBoundaryToSeconds({
39
+ frame: layer.sourceFrame,
40
+ frameRate
41
+ });
42
+ if (actorFrameAt === void 0) {
43
+ drawing.drawAt(seconds);
44
+ return;
45
+ }
46
+ const { position: translation, rotation: orientation } = actorFrameAt(seconds);
47
+ const { x: tx, y: ty, z: tz } = translation;
48
+ const { x, y, z, w } = orientation;
49
+ if (![
50
+ tx,
51
+ ty,
52
+ tz,
53
+ x,
54
+ y,
55
+ z,
56
+ w
57
+ ].every(Number.isFinite) || Math.abs(x ** 2 + y ** 2 + z ** 2 + w ** 2 - 1) > 1e-6) throw new Error(`Invalid staging frame for polygon actor ${subject}`);
58
+ const position = new Vector3(tx, ty, tz);
59
+ const rotation = new Quaternion(x, y, z, w).normalize();
60
+ const parent = drawing.object.parent;
61
+ if (parent !== null) {
62
+ parent.worldToLocal(position);
63
+ rotation.premultiply(parent.getWorldQuaternion(new Quaternion()).invert());
64
+ }
65
+ drawing.drawAt(seconds);
66
+ drawing.object.position.copy(position);
67
+ drawing.object.quaternion.copy(rotation);
68
+ drawing.object.updateWorldMatrix(true, true);
69
+ }
70
+ };
71
+ }
72
+ export { buildPolygonShotActor };
73
+
74
+ //# sourceMappingURL=buildPolygonShotActor.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildPolygonShotActor.mjs","names":[],"sources":["../../../src/scene/human-polygon/buildPolygonShotActor.ts"],"sourcesContent":["import { productionFrameBoundaryToSeconds } from \"@automovie/engine\";\nimport type {\n IAutoMovieHumanSkeleton,\n IAutoMovieProductionFrameRate,\n IAutoMovieProductionRenderLayer,\n IAutoMovieQuaternion,\n IAutoMovieRigidTransform,\n IAutoMovieShot,\n IAutoMovieVector3,\n} from \"@automovie/interface\";\nimport { Quaternion, Vector3 } from \"three\";\n\nimport type { AutoMovieHumanPolygon } from \"./AutoMovieHumanPolygon.js\";\nimport { buildHumanPolygon } from \"./buildHumanPolygon.js\";\n\n/**\n * Build a polygon actor and its source-frame sampler for a compiled shot.\n * A film host mounts the drawing in the shot scene and supplies `drawLayer`\n * as a layer preparation callback. Its source frame accounts for cuts and\n * trims. If an actor frame is supplied, the sampler also places the drawing\n * at that world frame under its rigid parent. Without a supplied frame the\n * cue's shot axes coincide with the drawing's axes at the origin.\n * Dispose the drawing with the usual polygon drawing owner.\n *\n * @evidence contracts/development/common.md#meaningful-documentation States the host's mounting, sampling and disposal responsibilities, along with the source time and frame conventions.\n * @evidence contracts/development/implementation.md#principled-implementation All passes read the same polygon node transform at the exact shot-local frame boundary.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure Build the existing drawing with its shot cues, then convert each layer's source frame through the production clock.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses a layer from another shot and uses the timeline's source frame directly.\n * @evidence contracts/development/implementation.md#efficient-algorithms The polygon drawing and cue plan are built once. Each layer converts one frame and applies one sample.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work Uses the regular polygon drawing and the same rational clock as other production render passes.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned drawing owns the render resources. The sampler retains that drawing and the shot's fixed source clock.\n */\nexport function buildPolygonShotActor(input: {\n /** Compiled shot and its optional body presentation cues. */\n shot: Pick<IAutoMovieShot, \"id\" | \"polygonBodyCues\">;\n /** Staged actor id. */\n subject: string;\n /** Bind bones and placements used to build the polygon drawing. */\n opening: Pick<IAutoMovieHumanSkeleton.IOutput, \"bones\" | \"posed\">;\n /** Canonical body-frame pose at a shot-local time. */\n poseAt: (seconds: number) => Pick<IAutoMovieHumanSkeleton.IOutput, \"posed\">;\n /** Deterministic, synchronous actor rigid frame at shot-local time in scene-world axes. Detach sampling can read the same time again. */\n actorFrameAt?: (seconds: number) => IAutoMovieRigidTransform;\n /** Production frame grid used by the layer's source frame. */\n frameRate: IAutoMovieProductionFrameRate;\n /** Optional palette by emitted bone name. */\n partColors?: Readonly<Record<string, number>>;\n}): {\n /** Drawing to mount in the shot scene and dispose when finished. */\n drawing: AutoMovieHumanPolygon.IDrawing;\n /** Evaluate the visible actor for an admitted render layer of this shot. */\n drawLayer: (layer: IAutoMovieProductionRenderLayer) => void;\n} {\n const {\n shot,\n subject,\n opening,\n poseAt,\n actorFrameAt,\n frameRate,\n partColors,\n } = input;\n const drawing: AutoMovieHumanPolygon.IDrawing = buildHumanPolygon(opening, {\n ...(partColors === undefined ? {} : { partColors }),\n presentation: {\n subject,\n cues: shot.polygonBodyCues ?? [],\n poseAt,\n ...(actorFrameAt === undefined ? {} : { actorFrameAt }),\n },\n });\n const shotId: string = shot.id;\n return {\n drawing,\n drawLayer: (layer: IAutoMovieProductionRenderLayer): void => {\n if (layer.shot !== shotId)\n throw new Error(`Polygon actor ${subject} belongs to shot ${shotId}`);\n const seconds: number = productionFrameBoundaryToSeconds({\n frame: layer.sourceFrame,\n frameRate,\n });\n if (actorFrameAt === undefined) {\n drawing.drawAt!(seconds);\n return;\n }\n const {\n position: translation,\n rotation: orientation,\n }: IAutoMovieRigidTransform = actorFrameAt(seconds);\n const { x: tx, y: ty, z: tz }: IAutoMovieVector3 = translation;\n const { x, y, z, w }: IAutoMovieQuaternion = orientation;\n if (\n ![tx, ty, tz, x, y, z, w].every(Number.isFinite) ||\n Math.abs(x ** 2 + y ** 2 + z ** 2 + w ** 2 - 1) > 1e-6\n )\n throw new Error(`Invalid staging frame for polygon actor ${subject}`);\n const position: Vector3 = new Vector3(tx, ty, tz);\n const rotation: Quaternion = new Quaternion(x, y, z, w).normalize();\n const parent = drawing.object.parent;\n if (parent !== null) {\n parent.worldToLocal(position);\n rotation.premultiply(\n parent.getWorldQuaternion(new Quaternion()).invert(),\n );\n }\n drawing.drawAt!(seconds);\n drawing.object.position.copy(position);\n drawing.object.quaternion.copy(rotation);\n drawing.object.updateWorldMatrix(true, true);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,sBAAsB,OAoBpC;CACA,MAAM,EACJ,MACA,SACA,SACA,QACA,cACA,WACA,eACE;CACJ,MAAM,UAA0C,kBAAkB,SAAS;EACzE,GAAI,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW;EACjD,cAAc;GACZ;GACA,MAAM,KAAK,mBAAmB,CAAC;GAC/B;GACA,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACvD;CACF,CAAC;CACD,MAAM,SAAiB,KAAK;CAC5B,OAAO;EACL;EACA,YAAY,UAAiD;GAC3D,IAAI,MAAM,SAAS,QACjB,MAAM,IAAI,MAAM,iBAAiB,QAAQ,mBAAmB,QAAQ;GACtE,MAAM,UAAkB,iCAAiC;IACvD,OAAO,MAAM;IACb;GACF,CAAC;GACD,IAAI,iBAAiB,KAAA,GAAW;IAC9B,QAAQ,OAAQ,OAAO;IACvB;GACF;GACA,MAAM,EACJ,UAAU,aACV,UAAU,gBACkB,aAAa,OAAO;GAClD,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,GAAG,OAA0B;GACnD,MAAM,EAAE,GAAG,GAAG,GAAG,MAA4B;GAC7C,IACE,CAAC;IAAC;IAAI;IAAI;IAAI;IAAG;IAAG;IAAG;GAAC,CAAC,CAAC,MAAM,OAAO,QAAQ,KAC/C,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,CAAC,IAAI,MAElD,MAAM,IAAI,MAAM,2CAA2C,SAAS;GACtE,MAAM,WAAoB,IAAI,QAAQ,IAAI,IAAI,EAAE;GAChD,MAAM,WAAuB,IAAI,WAAW,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU;GAClE,MAAM,SAAS,QAAQ,OAAO;GAC9B,IAAI,WAAW,MAAM;IACnB,OAAO,aAAa,QAAQ;IAC5B,SAAS,YACP,OAAO,mBAAmB,IAAI,WAAW,CAAC,CAAC,CAAC,OAAO,CACrD;GACF;GACA,QAAQ,OAAQ,OAAO;GACvB,QAAQ,OAAO,SAAS,KAAK,QAAQ;GACrC,QAAQ,OAAO,WAAW,KAAK,QAAQ;GACvC,QAAQ,OAAO,kBAAkB,MAAM,IAAI;EAC7C;CACF;AACF"}
@@ -2,4 +2,5 @@ export type { AutoMovieHumanPolygon } from "./AutoMovieHumanPolygon.js";
2
2
  export type { AutoMovieHumanCartoon } from "./AutoMovieHumanCartoon.js";
3
3
  export { buildHumanPolygon } from "./buildHumanPolygon.js";
4
4
  export { buildHumanCartoonFace } from "./buildHumanCartoonFace.js";
5
+ export { buildPolygonShotActor } from "./buildPolygonShotActor.js";
5
6
  export { createAutoMovieHumanPolygonFigure } from "./createAutoMovieHumanPolygonFigure.js";
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAutoMovieHumanPolygonFigure = exports.buildHumanCartoonFace = exports.buildHumanPolygon = void 0;
3
+ exports.createAutoMovieHumanPolygonFigure = exports.buildPolygonShotActor = exports.buildHumanCartoonFace = exports.buildHumanPolygon = void 0;
4
4
  var buildHumanPolygon_js_1 = require("./buildHumanPolygon.js");
5
5
  Object.defineProperty(exports, "buildHumanPolygon", { enumerable: true, get: function () { return buildHumanPolygon_js_1.buildHumanPolygon; } });
6
6
  var buildHumanCartoonFace_js_1 = require("./buildHumanCartoonFace.js");
7
7
  Object.defineProperty(exports, "buildHumanCartoonFace", { enumerable: true, get: function () { return buildHumanCartoonFace_js_1.buildHumanCartoonFace; } });
8
+ var buildPolygonShotActor_js_1 = require("./buildPolygonShotActor.js");
9
+ Object.defineProperty(exports, "buildPolygonShotActor", { enumerable: true, get: function () { return buildPolygonShotActor_js_1.buildPolygonShotActor; } });
8
10
  var createAutoMovieHumanPolygonFigure_js_1 = require("./createAutoMovieHumanPolygonFigure.js");
9
11
  Object.defineProperty(exports, "createAutoMovieHumanPolygonFigure", { enumerable: true, get: function () { return createAutoMovieHumanPolygonFigure_js_1.createAutoMovieHumanPolygonFigure; } });
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/index.ts"],"names":[],"mappings":";;;AAEA,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,+FAA2F;AAAlF,yJAAA,iCAAiC,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/index.ts"],"names":[],"mappings":";;;AAEA,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA;AAC9B,+FAA2F;AAAlF,yJAAA,iCAAiC,OAAA"}
@@ -1,4 +1,5 @@
1
1
  import { buildHumanPolygon } from "./buildHumanPolygon.mjs";
2
2
  import { buildHumanCartoonFace } from "./buildHumanCartoonFace.mjs";
3
+ import { buildPolygonShotActor } from "./buildPolygonShotActor.mjs";
3
4
  import { createAutoMovieHumanPolygonFigure } from "./createAutoMovieHumanPolygonFigure.mjs";
4
- export { buildHumanCartoonFace, buildHumanPolygon, createAutoMovieHumanPolygonFigure };
5
+ export { buildHumanCartoonFace, buildHumanPolygon, buildPolygonShotActor, createAutoMovieHumanPolygonFigure };
@@ -0,0 +1,17 @@
1
+ import type { IAutoMovieHumanBindBone, IAutoMovieHumanSkeleton } from "@automovie/interface";
2
+ import type { AutoMovieHumanPolygon } from "./AutoMovieHumanPolygon.js";
3
+ /** A complete evaluated pose in registered Human body coordinates. */
4
+ type AutoMoviePolygonPose = Pick<IAutoMovieHumanSkeleton.IOutput, "posed">;
5
+ /**
6
+ * Prepare rigid visual cues for one polygon drawing on its source clock.
7
+ *
8
+ * @evidence contracts/development/common.md#meaningful-documentation Takes source poses, a source hierarchy, emitted targets and actor staging. Returns a seekable sampler in Human body coordinates.
9
+ * @evidence contracts/development/implementation.md#principled-implementation Resolves disjoint subtrees through source parents and requires an emitted part in each subtree. Bends use a live joint pivot. A release admits the replaced live placements and maps its world-space snapshot back through live actor staging.
10
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Preparation owns target admission and reference sampling. Existing pose admission and graphics writes remain at the drawing.
11
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Uses the actual source pivots and emitted descendants. No simulation, graph creation or changes to the source skeletal pose are performed.
12
+ * @evidence contracts/development/implementation.md#efficient-algorithms Admission builds a child index and visits each selected bone once. A release scans one source pose and retains only its branch placements. Active drawing samples index and visit the live pose once.
13
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The source hierarchy and captured release frames are reused across samples, including reverse seeks. Bend-only samples need no actor staging.
14
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Retains one reference frame per released bone and no graphics or external handles.
15
+ */
16
+ export declare function prepareHumanPolygonPresentation(presentation: AutoMovieHumanPolygon.IPresentation, bones: ReadonlyMap<string, IAutoMovieHumanBindBone>, emitted: ReadonlySet<string>): (seconds: number) => AutoMoviePolygonPose;
17
+ export {};
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareHumanPolygonPresentation = prepareHumanPolygonPresentation;
4
+ const three_1 = require("three");
5
+ /** Admit a finite quaternion with the same squared-norm tolerance as a polygon pose. */
6
+ function unitRotation(x, y, z, w, label) {
7
+ if (![x, y, z, w].every(Number.isFinite) ||
8
+ Math.abs(x ** 2 + y ** 2 + z ** 2 + w ** 2 - 1) > 1e-6)
9
+ throw new Error(`Invalid polygon rotation: ${label}`);
10
+ return new three_1.Quaternion(x, y, z, w).normalize();
11
+ }
12
+ /** Admit the metre translation of a rigid frame. */
13
+ function finitePosition(x, y, z, label) {
14
+ if (![x, y, z].every(Number.isFinite))
15
+ throw new Error(`Invalid polygon position: ${label}`);
16
+ return new three_1.Vector3(x, y, z);
17
+ }
18
+ /** Copy one source joint frame for arithmetic without mutating the evaluated pose. */
19
+ function boneFrame(placement) {
20
+ if (placement.position.length !== 3 || placement.rotation.length !== 4)
21
+ throw new Error(`Invalid polygon placement: ${placement.bone}`);
22
+ return {
23
+ position: finitePosition(...placement.position, placement.bone),
24
+ rotation: unitRotation(...placement.rotation, placement.bone),
25
+ };
26
+ }
27
+ /** Read the actor parent frame in shot world or use the fixed identity frame. */
28
+ function actorFrame(actorFrameAt, seconds) {
29
+ if (actorFrameAt === undefined)
30
+ return { position: new three_1.Vector3(), rotation: new three_1.Quaternion() };
31
+ const { position, rotation } = actorFrameAt(seconds);
32
+ return {
33
+ position: finitePosition(position.x, position.y, position.z, "actor frame"),
34
+ rotation: unitRotation(rotation.x, rotation.y, rotation.z, rotation.w, "actor frame"),
35
+ };
36
+ }
37
+ /**
38
+ * Prepare rigid visual cues for one polygon drawing on its source clock.
39
+ *
40
+ * @evidence contracts/development/common.md#meaningful-documentation Takes source poses, a source hierarchy, emitted targets and actor staging. Returns a seekable sampler in Human body coordinates.
41
+ * @evidence contracts/development/implementation.md#principled-implementation Resolves disjoint subtrees through source parents and requires an emitted part in each subtree. Bends use a live joint pivot. A release admits the replaced live placements and maps its world-space snapshot back through live actor staging.
42
+ * @evidence contracts/development/implementation.md#clear-and-simple-structure Preparation owns target admission and reference sampling. Existing pose admission and graphics writes remain at the drawing.
43
+ * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Uses the actual source pivots and emitted descendants. No simulation, graph creation or changes to the source skeletal pose are performed.
44
+ * @evidence contracts/development/implementation.md#efficient-algorithms Admission builds a child index and visits each selected bone once. A release scans one source pose and retains only its branch placements. Active drawing samples index and visit the live pose once.
45
+ * @evidence contracts/development/implementation.md#reuse-equivalent-work The source hierarchy and captured release frames are reused across samples, including reverse seeks. Bend-only samples need no actor staging.
46
+ * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Retains one reference frame per released bone and no graphics or external handles.
47
+ */
48
+ function prepareHumanPolygonPresentation(presentation, bones, emitted) {
49
+ const { subject, poseAt, actorFrameAt } = presentation;
50
+ const children = new Map();
51
+ for (const { bone, parent } of bones.values()) {
52
+ if (parent === null)
53
+ continue;
54
+ const siblings = children.get(parent);
55
+ if (siblings === undefined)
56
+ children.set(parent, [bone]);
57
+ else
58
+ siblings.push(bone);
59
+ }
60
+ const cuesByBone = new Map();
61
+ const occupied = new Set();
62
+ let firstCue = Infinity;
63
+ for (const cue of presentation.cues) {
64
+ if (cue.subject !== subject)
65
+ continue;
66
+ if (!bones.has(cue.bone))
67
+ throw new Error(`Unsupported polygon cue target: ${cue.bone}`);
68
+ if (!Number.isFinite(cue.at) ||
69
+ cue.at < 0 ||
70
+ !Number.isFinite(cue.duration) ||
71
+ cue.duration < 0 ||
72
+ !Number.isFinite(cue.at + cue.duration))
73
+ throw new Error(`Invalid polygon cue timing: ${cue.bone}`);
74
+ firstCue = Math.min(firstCue, cue.at);
75
+ const subtree = [cue.bone];
76
+ let hasEmittedPart = false;
77
+ for (const bone of subtree) {
78
+ if (occupied.has(bone))
79
+ throw new Error(`Overlapping polygon cue subtree: ${bone}`);
80
+ occupied.add(bone);
81
+ hasEmittedPart ||= emitted.has(bone);
82
+ for (const child of children.get(bone) ?? [])
83
+ subtree.push(child);
84
+ }
85
+ if (!hasEmittedPart)
86
+ throw new Error(`Unsupported polygon cue target: ${cue.bone}`);
87
+ // Authored cue admission measures the quaternion norm. Registered
88
+ // skeletal placements use the drawing's separate squared-norm tolerance.
89
+ const { x, y, z, w } = cue.rotation;
90
+ const norm = Math.hypot(x, y, z, w);
91
+ if (![x, y, z, w].every(Number.isFinite) || Math.abs(norm - 1) > 1e-6)
92
+ throw new Error(`Invalid polygon rotation: ${cue.bone}`);
93
+ const timing = {
94
+ at: cue.at,
95
+ duration: cue.duration,
96
+ rotation: new three_1.Quaternion(x / norm, y / norm, z / norm, w / norm),
97
+ };
98
+ let prepared;
99
+ if (cue.kind === "bend") {
100
+ prepared = { ...timing, kind: cue.kind, bone: cue.bone };
101
+ }
102
+ else if (cue.kind === "detach") {
103
+ const translation = finitePosition(cue.translation.x, cue.translation.y, cue.translation.z, cue.bone);
104
+ const released = new Map();
105
+ const selected = new Set(subtree);
106
+ const actor = actorFrame(actorFrameAt, cue.at);
107
+ // Capture the branch's world placement once so later poses and actor
108
+ // staging cannot drive the released parts.
109
+ for (const placement of poseAt(cue.at).posed) {
110
+ if (!selected.has(placement.bone))
111
+ continue;
112
+ if (released.has(placement.bone))
113
+ throw new Error(`Duplicate polygon release placement: ${placement.bone}`);
114
+ const frame = boneFrame(placement);
115
+ frame.position.applyQuaternion(actor.rotation).add(actor.position);
116
+ frame.rotation.premultiply(actor.rotation);
117
+ released.set(placement.bone, frame);
118
+ }
119
+ const origin = released.get(cue.bone);
120
+ if (origin === undefined || released.size !== subtree.length)
121
+ throw new Error(`Incomplete polygon release pose: ${cue.bone}`);
122
+ prepared = {
123
+ ...timing,
124
+ kind: cue.kind,
125
+ pivot: origin.position,
126
+ released,
127
+ translation,
128
+ };
129
+ }
130
+ else {
131
+ throw new Error("Unsupported polygon cue kind");
132
+ }
133
+ for (const bone of subtree)
134
+ cuesByBone.set(bone, prepared);
135
+ }
136
+ return (seconds) => {
137
+ if (!Number.isFinite(seconds))
138
+ throw new Error("Invalid polygon drawing time");
139
+ const pose = poseAt(seconds);
140
+ if (seconds < firstCue)
141
+ return pose;
142
+ const live = new Map(pose.posed.map((placement) => [
143
+ placement.bone,
144
+ placement,
145
+ ]));
146
+ const deltas = new Map();
147
+ let actor;
148
+ let inverseActorRotation;
149
+ return {
150
+ posed: pose.posed.map((placement) => {
151
+ const cue = cuesByBone.get(placement.bone);
152
+ if (cue === undefined || seconds < cue.at)
153
+ return placement;
154
+ const amount = cue.duration === 0
155
+ ? 1
156
+ : Math.min(1, (seconds - cue.at) / cue.duration);
157
+ if (amount === 0)
158
+ return placement;
159
+ let delta = deltas.get(cue);
160
+ if (delta === undefined) {
161
+ const rotation = new three_1.Quaternion().slerp(cue.rotation, amount);
162
+ if (cue.kind === "bend") {
163
+ const joint = live.get(cue.bone);
164
+ if (joint === undefined)
165
+ throw new Error(`Missing polygon bend pivot: ${cue.bone}`);
166
+ const frame = boneFrame(joint);
167
+ // Conjugating the local rotation gives the same turn in body
168
+ // coordinates, which the flat descendant placements share.
169
+ rotation
170
+ .premultiply(frame.rotation)
171
+ .multiply(frame.rotation.invert());
172
+ delta = { position: frame.position, rotation };
173
+ }
174
+ else {
175
+ actor ??= actorFrame(actorFrameAt, seconds);
176
+ inverseActorRotation ??= actor.rotation.clone().invert();
177
+ delta = {
178
+ position: cue.pivot
179
+ .clone()
180
+ .addScaledVector(cue.translation, amount),
181
+ rotation,
182
+ };
183
+ }
184
+ deltas.set(cue, delta);
185
+ }
186
+ // Admit the raw placement before a release can replace it.
187
+ let frame = boneFrame(placement);
188
+ if (cue.kind === "bend") {
189
+ frame.position
190
+ .sub(delta.position)
191
+ .applyQuaternion(delta.rotation)
192
+ .add(delta.position);
193
+ frame.rotation.premultiply(delta.rotation);
194
+ }
195
+ else {
196
+ const release = cue.released.get(placement.bone);
197
+ if (release === undefined ||
198
+ actor === undefined ||
199
+ inverseActorRotation === undefined)
200
+ throw new Error(`Missing polygon release frame: ${placement.bone}`);
201
+ // Existing groups are actor-local. Cancel the live parent frame
202
+ // so the renderer applies it once and reaches the intended world pose.
203
+ frame = {
204
+ position: release.position
205
+ .clone()
206
+ .sub(cue.pivot)
207
+ .applyQuaternion(delta.rotation)
208
+ .add(delta.position)
209
+ .sub(actor.position)
210
+ .applyQuaternion(inverseActorRotation),
211
+ rotation: release.rotation
212
+ .clone()
213
+ .premultiply(delta.rotation)
214
+ .premultiply(inverseActorRotation),
215
+ };
216
+ }
217
+ return {
218
+ bone: placement.bone,
219
+ position: [frame.position.x, frame.position.y, frame.position.z],
220
+ rotation: [
221
+ frame.rotation.x,
222
+ frame.rotation.y,
223
+ frame.rotation.z,
224
+ frame.rotation.w,
225
+ ],
226
+ };
227
+ }),
228
+ };
229
+ };
230
+ }
231
+ //# sourceMappingURL=prepareHumanPolygonPresentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prepareHumanPolygonPresentation.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/prepareHumanPolygonPresentation.ts"],"names":[],"mappings":";;;AAOA,iCAA4C;AAgC5C,wFAAwF;AACxF,SAAS,YAAY,CACnB,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS,EACT,KAAa;IAEb,IACE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAA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