@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.
- package/lib/AutoMovieFrameGrid.d.ts +54 -0
- package/lib/AutoMovieFrameGrid.js +71 -0
- package/lib/AutoMovieFrameGrid.js.map +1 -0
- package/lib/AutoMovieFrameGrid.mjs +20 -0
- package/lib/AutoMovieFrameGrid.mjs.map +1 -0
- package/lib/caption/canonicalProductionWebVtt.d.ts +5 -3
- package/lib/caption/canonicalProductionWebVtt.js +19 -4
- package/lib/caption/canonicalProductionWebVtt.js.map +1 -1
- package/lib/caption/canonicalProductionWebVtt.mjs +15 -4
- package/lib/caption/canonicalProductionWebVtt.mjs.map +1 -1
- package/lib/draw/bindAutoMovieDrawSceneSoftProps.d.ts +15 -0
- package/lib/draw/bindAutoMovieDrawSceneSoftProps.js +41 -0
- package/lib/draw/bindAutoMovieDrawSceneSoftProps.js.map +1 -0
- package/lib/draw/bindAutoMovieDrawSceneSoftProps.mjs +36 -0
- package/lib/draw/bindAutoMovieDrawSceneSoftProps.mjs.map +1 -0
- package/lib/draw/index.d.ts +1 -0
- package/lib/draw/index.js +1 -0
- package/lib/draw/index.js.map +1 -1
- package/lib/draw/index.mjs +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +12 -7
- package/lib/planSequenceRender.d.ts +5 -5
- package/lib/planSequenceRender.js +12 -6
- package/lib/planSequenceRender.js.map +1 -1
- package/lib/planSequenceRender.mjs +12 -8
- package/lib/planSequenceRender.mjs.map +1 -1
- package/lib/scene/IAutoMovieSceneObject.d.ts +4 -1
- package/lib/scene/IAutoMovieSceneSoftProps.d.ts +36 -0
- package/lib/scene/IAutoMovieSceneSoftProps.js +3 -0
- package/lib/scene/IAutoMovieSceneSoftProps.js.map +1 -0
- package/lib/scene/IAutoMovieSceneSoftProps.mjs +0 -0
- package/lib/scene/IChunkObject.d.ts +7 -3
- package/lib/scene/applyPracticalSurfaceMaterials.d.ts +31 -0
- package/lib/scene/applyPracticalSurfaceMaterials.js +87 -0
- package/lib/scene/applyPracticalSurfaceMaterials.js.map +1 -0
- package/lib/scene/applyPracticalSurfaceMaterials.mjs +47 -0
- package/lib/scene/applyPracticalSurfaceMaterials.mjs.map +1 -0
- package/lib/scene/buildInstancedFormation.d.ts +1 -1
- package/lib/scene/buildInstancedFormation.js +44 -19
- package/lib/scene/buildInstancedFormation.js.map +1 -1
- package/lib/scene/buildInstancedFormation.mjs +30 -13
- package/lib/scene/buildInstancedFormation.mjs.map +1 -1
- package/lib/scene/buildScene.d.ts +10 -7
- package/lib/scene/buildScene.js +21 -7
- package/lib/scene/buildScene.js.map +1 -1
- package/lib/scene/buildScene.mjs +27 -9
- package/lib/scene/buildScene.mjs.map +1 -1
- package/lib/scene/buildSceneSoftProps.d.ts +15 -0
- package/lib/scene/buildSceneSoftProps.js +71 -0
- package/lib/scene/buildSceneSoftProps.js.map +1 -0
- package/lib/scene/buildSceneSoftProps.mjs +67 -0
- package/lib/scene/buildSceneSoftProps.mjs.map +1 -0
- package/lib/scene/human-polygon/AutoMovieHumanPolygon.d.ts +52 -1
- package/lib/scene/human-polygon/buildHumanPolygon.d.ts +3 -1
- package/lib/scene/human-polygon/buildHumanPolygon.js +14 -2
- package/lib/scene/human-polygon/buildHumanPolygon.js.map +1 -1
- package/lib/scene/human-polygon/buildHumanPolygon.mjs +11 -2
- package/lib/scene/human-polygon/buildHumanPolygon.mjs.map +1 -1
- package/lib/scene/human-polygon/buildPolygonShotActor.d.ts +40 -0
- package/lib/scene/human-polygon/buildPolygonShotActor.js +69 -0
- package/lib/scene/human-polygon/buildPolygonShotActor.js.map +1 -0
- package/lib/scene/human-polygon/buildPolygonShotActor.mjs +74 -0
- package/lib/scene/human-polygon/buildPolygonShotActor.mjs.map +1 -0
- package/lib/scene/human-polygon/index.d.ts +1 -0
- package/lib/scene/human-polygon/index.js +3 -1
- package/lib/scene/human-polygon/index.js.map +1 -1
- package/lib/scene/human-polygon/index.mjs +2 -1
- package/lib/scene/human-polygon/prepareHumanPolygonPresentation.d.ts +17 -0
- package/lib/scene/human-polygon/prepareHumanPolygonPresentation.js +231 -0
- package/lib/scene/human-polygon/prepareHumanPolygonPresentation.js.map +1 -0
- package/lib/scene/human-polygon/prepareHumanPolygonPresentation.mjs +189 -0
- package/lib/scene/human-polygon/prepareHumanPolygonPresentation.mjs.map +1 -0
- package/lib/scene/index.d.ts +3 -0
- package/lib/scene/index.js +3 -0
- package/lib/scene/index.js.map +1 -1
- package/lib/scene/index.mjs +45 -42
- package/lib/scene/renderAutoMovieFilmFrame.d.ts +6 -4
- package/lib/scene/renderAutoMovieFilmFrame.js +12 -8
- package/lib/scene/renderAutoMovieFilmFrame.js.map +1 -1
- package/lib/scene/renderAutoMovieFilmFrame.mjs +12 -8
- package/lib/scene/renderAutoMovieFilmFrame.mjs.map +1 -1
- package/lib/scene/softPropCordSurface.d.ts +14 -0
- package/lib/scene/softPropCordSurface.js +128 -0
- package/lib/scene/softPropCordSurface.js.map +1 -0
- package/lib/scene/softPropCordSurface.mjs +88 -0
- package/lib/scene/softPropCordSurface.mjs.map +1 -0
- package/package.json +4 -4
- package/src/AutoMovieFrameGrid.ts +70 -0
- package/src/caption/canonicalProductionWebVtt.ts +20 -4
- package/src/draw/bindAutoMovieDrawSceneSoftProps.ts +43 -0
- package/src/draw/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/planSequenceRender.ts +21 -10
- package/src/scene/IAutoMovieSceneObject.ts +6 -1
- package/src/scene/IAutoMovieSceneSoftProps.ts +38 -0
- package/src/scene/IChunkObject.ts +10 -3
- package/src/scene/applyPracticalSurfaceMaterials.ts +79 -0
- package/src/scene/buildInstancedFormation.ts +86 -55
- package/src/scene/buildScene.ts +22 -6
- package/src/scene/buildSceneSoftProps.ts +83 -0
- package/src/scene/human-polygon/AutoMovieHumanPolygon.ts +61 -1
- package/src/scene/human-polygon/buildHumanPolygon.ts +22 -2
- package/src/scene/human-polygon/buildPolygonShotActor.ts +112 -0
- package/src/scene/human-polygon/index.ts +1 -0
- package/src/scene/human-polygon/prepareHumanPolygonPresentation.ts +328 -0
- package/src/scene/index.ts +3 -0
- package/src/scene/renderAutoMovieFilmFrame.ts +14 -9
- package/src/scene/softPropCordSurface.ts +132 -0
package/lib/scene/buildScene.mjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { applyAutoMovieShadowParticipation } from "./applyAutoMovieShadowParticipation.mjs";
|
|
2
1
|
import { buildSpaceObject } from "./buildSpaceObject.mjs";
|
|
2
|
+
import { applyAutoMovieShadowParticipation } from "./applyAutoMovieShadowParticipation.mjs";
|
|
3
3
|
import { applySceneEnvironment } from "./applySceneEnvironment.mjs";
|
|
4
4
|
import { applySceneFog } from "./applySceneFog.mjs";
|
|
5
5
|
import { applyTransform } from "./applyTransform.mjs";
|
|
6
6
|
import { buildLight } from "./buildLight.mjs";
|
|
7
|
+
import { buildSceneSoftProps } from "./buildSceneSoftProps.mjs";
|
|
7
8
|
import "./buildSpace.mjs";
|
|
9
|
+
import { restoreAutoMovieRenderModeState } from "./restoreAutoMovieRenderModeState.mjs";
|
|
8
10
|
import { resolveAutoMovieShadowProfile } from "@automovie/engine";
|
|
9
11
|
import * as THREE from "three";
|
|
10
12
|
// src/scene/buildScene.ts
|
|
@@ -33,21 +35,24 @@ import * as THREE from "three";
|
|
|
33
35
|
* {@link buildSpaceObject}), so guide passes describe a world instead of actors
|
|
34
36
|
* floating in a void. Their ordinary material writes no beauty colour or depth,
|
|
35
37
|
* because a semantic support declaration is not evidence that physical floor
|
|
36
|
-
* geometry exists. The group
|
|
37
|
-
*
|
|
38
|
-
*
|
|
38
|
+
* geometry exists. The group follows the nodes and lights so the whole
|
|
39
|
+
* ground reads as one mask colour rather than one per surface.
|
|
40
|
+
*
|
|
41
|
+
* An optional frame of soft props follows the designed scene objects.
|
|
42
|
+
* Its returned handle updates plain surfaces at later times and releases
|
|
43
|
+
* the meshes. Pass an empty frame to opt in before the first prop appears.
|
|
39
44
|
*
|
|
40
45
|
* The cited refusal contribution covers the supplied shadow profile and unresolved node model. Complete hierarchy, material and numeric admission, lowering receipts and structured safe-retry policy remain with their corresponding owners.
|
|
41
46
|
*
|
|
42
47
|
* @evidence contracts/development/implementation.md#principled-implementation Preserves authored node order under placement groups, admits the shadow profile, builds native lights/cameras, optional semantic support, fog and environment; each resolver call must supply a distinct mutable model object and valid admitted TRS. Static pose/props/compiled populations are not lowered here and current production pages assemble their own graph rather than calling this producer.
|
|
43
|
-
* @evidence contracts/development/implementation.md#clear-and-simple-structure Owns the scene graph join and camera/light lookup
|
|
48
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Owns the scene graph join and camera/light lookup while model loading, articulation, temporal sampling and rendering remain external. The soft layer uses its own owner and follows the designed children.
|
|
44
49
|
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses unresolved models rather than dropping an authored child and shifting mask indices; no fixture nodes/lights are invented, but complete admission and partial-construction rollback are not supplied by this scene wrapper.
|
|
45
50
|
* @evidence contracts/development/common.md#meaningful-documentation States resolver uniqueness, authored node order, placement/root composition, semantic-ground beauty exclusion, static-pose caller duty and explicit refusal/admission ownership boundary.
|
|
46
51
|
* @evidence contracts/development/implementation.md#efficient-algorithms Builds N placement groups, L lights and C cameras with id maps plus support tessellation and shadow participation traversal; dominant memory follows actual model/support resources returned by producers, and no anonymous member runtime is created here.
|
|
47
52
|
* @evidence contracts/development/implementation.md#reuse-equivalent-work Reuses canonical transform/light/fog/environment/space adapters and maps lights by semantic id; model object reuse across placements is invalid because native parenting is exclusive, and scene-level effectful construction is not cached.
|
|
48
|
-
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Transfers new scene
|
|
53
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Transfers new scene, group, light, camera and support references and adopts resolver model objects. Failed soft-prop mounting retires that layer. The caller otherwise owns retirement and partial graph recovery; environment texture handoff has a separate owner.
|
|
49
54
|
*/
|
|
50
|
-
const buildScene = (scene, getModelObject, environmentTexture) => {
|
|
55
|
+
const buildScene = (scene, getModelObject, environmentTexture, softFrame) => {
|
|
51
56
|
const shadowProfile = resolveAutoMovieShadowProfile({
|
|
52
57
|
lights: scene.lights,
|
|
53
58
|
shadows: scene.environment?.shadows
|
|
@@ -74,11 +79,24 @@ const buildScene = (scene, getModelObject, environmentTexture) => {
|
|
|
74
79
|
applySceneFog(root, scene.fog);
|
|
75
80
|
applySceneEnvironment(root, scene.environment, environmentTexture);
|
|
76
81
|
applyAutoMovieShadowParticipation(root);
|
|
77
|
-
|
|
82
|
+
const cameras = scene.cameras.map(buildCamera);
|
|
83
|
+
if (softFrame === void 0) return {
|
|
78
84
|
scene: root,
|
|
79
|
-
cameras
|
|
85
|
+
cameras,
|
|
80
86
|
lights
|
|
81
87
|
};
|
|
88
|
+
const softProps = buildSceneSoftProps(root);
|
|
89
|
+
try {
|
|
90
|
+
softProps.update(softFrame);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
restoreAutoMovieRenderModeState([softProps.dispose], { error });
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
scene: root,
|
|
96
|
+
cameras,
|
|
97
|
+
lights,
|
|
98
|
+
softProps
|
|
99
|
+
};
|
|
82
100
|
};
|
|
83
101
|
const buildCamera = (cam) => {
|
|
84
102
|
const camera = new THREE.PerspectiveCamera(cam.fovY, 1, cam.near, cam.far);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildScene.mjs","names":[],"sources":["../../src/scene/buildScene.ts"],"sourcesContent":["import { resolveAutoMovieShadowProfile } from \"@automovie/engine\";\nimport type {\n IAutoMovieCamera,\n IAutoMovieScene,\n IAutoMovieSpace,\n} from \"@automovie/interface\";\nimport * as THREE from \"three\";\n\nimport type { IAutoMovieModelObject } from \"./IAutoMovieModelObject.js\";\nimport type { IAutoMovieSceneObject } from \"./IAutoMovieSceneObject.js\";\nimport { applyAutoMovieShadowParticipation } from \"./applyAutoMovieShadowParticipation.js\";\nimport { applySceneEnvironment } from \"./applySceneEnvironment.js\";\nimport { applySceneFog } from \"./applySceneFog.js\";\nimport { applyTransform } from \"./applyTransform.js\";\nimport { buildLight } from \"./buildLight.js\";\nimport { buildSpaceObject } from \"./buildSpace.js\";\n\n/**\n * Build a `three.js` scene from an {@link IAutoMovieScene}.\n *\n * `getModelObject` resolves a node's `model` id to a built\n * {@link IAutoMovieModelObject}. If the same model id appears in multiple nodes\n * it should return a distinct object each call (a `three.js` object can live in\n * one place only). Each node is wrapped in a group placed at its world\n * transform, so node placement and a pose's own root transform compose\n * cleanly.\n *\n * Cameras and the four light kinds (point, area, directional and spot) map onto their `three.js` equivalents.\n *\n * **The first `scene.nodes.length` top-level children ARE the designed nodes,\n * in design order.** Both mask passes read that: the legacy ramp colours the\n * Nth child with the Nth colour, and the stable semantic palette resolves a\n * designed node to `root.children[index]` (see\n * {@link applyAutoMovieSemanticMask}). Anything this function adds of its own\n * goes after them, and a host that prepends a child of its own breaks the\n * second one exactly as it always broke the first.\n *\n * A scene carrying a `space` also gets its structural ground (#1173): the\n * standable surfaces become real meshes under one `SPACE_GROUP_NAME` group (see\n * {@link buildSpaceObject}), so guide passes describe a world instead of actors\n * floating in a void. Their ordinary material writes no beauty colour or depth,\n * because a semantic support declaration is not evidence that physical floor\n * geometry exists. The group is added LAST, after the nodes and lights, for\n * that reason, and so the whole ground reads as one mask colour rather than one\n * per surface.\n *\n * The cited refusal contribution covers the supplied shadow profile and unresolved node model. Complete hierarchy, material and numeric admission, lowering receipts and structured safe-retry policy remain with their corresponding owners.\n *\n * @evidence contracts/development/implementation.md#principled-implementation Preserves authored node order under placement groups, admits the shadow profile, builds native lights/cameras, optional semantic support, fog and environment; each resolver call must supply a distinct mutable model object and valid admitted TRS. Static pose/props/compiled populations are not lowered here and current production pages assemble their own graph rather than calling this producer.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure Owns the scene graph join and camera/light lookup result while model loading/building, articulation, temporal sampling and rendering remain external; leading node-child order exposes the existing positional semantic-mask dependency.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses unresolved models rather than dropping an authored child and shifting mask indices; no fixture nodes/lights are invented, but complete admission and partial-construction rollback are not supplied by this scene wrapper.\n * @evidence contracts/development/common.md#meaningful-documentation States resolver uniqueness, authored node order, placement/root composition, semantic-ground beauty exclusion, static-pose caller duty and explicit refusal/admission ownership boundary.\n * @evidence contracts/development/implementation.md#efficient-algorithms Builds N placement groups, L lights and C cameras with id maps plus support tessellation and shadow participation traversal; dominant memory follows actual model/support resources returned by producers, and no anonymous member runtime is created here.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work Reuses canonical transform/light/fog/environment/space adapters and maps lights by semantic id; model object reuse across placements is invalid because native parenting is exclusive, and scene-level effectful construction is not cached.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Transfers new scene/group/light/camera/support references and adopts resolver model objects into the result; environment texture handoff has its separate exclusive owner. No universal scene disposer or late-refusal rollback is returned, so callers must own both retirement and partially assembled graph recovery rather than assuming this wrapper frees them.\n */\nexport const buildScene: (\n scene: IAutoMovieScene,\n getModelObject: (modelId: string) => IAutoMovieModelObject | undefined,\n environmentTexture?: THREE.Texture,\n) => IAutoMovieSceneObject = (\n scene: IAutoMovieScene,\n getModelObject: (modelId: string) => IAutoMovieModelObject | undefined,\n environmentTexture?: THREE.Texture,\n): IAutoMovieSceneObject => {\n const shadowProfile: ReturnType<typeof resolveAutoMovieShadowProfile> =\n resolveAutoMovieShadowProfile({\n lights: scene.lights,\n shadows: scene.environment?.shadows,\n });\n if (!shadowProfile.success)\n throw new Error(\n \"Unsupported shadow profile: \" + JSON.stringify(shadowProfile.violations),\n );\n const root: THREE.Scene<THREE.Object3DEventMap> = new THREE.Scene();\n\n for (const node of scene.nodes) {\n const built: IAutoMovieModelObject | undefined = getModelObject(node.model);\n // Caller data that cannot resolve is an error, not a skip (#1051): both\n // mask passes read a designed node off its top-level child INDEX, so a\n // silently dropped node would shift every later node one place over and a\n // mask consumer would attribute pixels to the wrong node.\n if (built === undefined)\n throw new Error(\n `scene node \"${node.id}\" references model \"${node.model}\", which getModelObject could not resolve`,\n );\n const nodeGroup: THREE.Group<THREE.Object3DEventMap> = new THREE.Group();\n // Named, so a consumer can find a node's group by its scene id instead of\n // by position among `root.children`. The two agree today only because this\n // loop appends in design order, which a host that prepends anything of its\n // own silently breaks.\n nodeGroup.name = node.id;\n applyTransform(nodeGroup, node.transform);\n nodeGroup.add(built.object);\n // Static posing (node.pose) is done by the caller via `applyPose`, since it\n // needs the model's skeleton, which buildScene does not resolve here.\n root.add(nodeGroup);\n }\n\n // Lights stay top-level children, after the nodes, so the designed nodes keep\n // the leading run of `root.children` that both mask passes read them off. The\n // id map is built alongside so a shot's `lightMotions` can find one without\n // depending on where it landed.\n const lights: Map<string, THREE.Light> = new Map<string, THREE.Light>();\n for (const light of scene.lights) {\n const object: THREE.Light = buildLight(light);\n root.add(object);\n lights.set(light.id, object);\n }\n\n const space: IAutoMovieSpace | null = scene.space ?? null;\n if (space !== null) root.add(buildSpaceObject(space));\n\n // The atmosphere is a scene property, not an object: it takes no top-level\n // child, so the mask palette's child indices are untouched by declaring it.\n applySceneFog(root, scene.fog);\n applySceneEnvironment(root, scene.environment, environmentTexture);\n\n applyAutoMovieShadowParticipation(root);\n\n const cameras: THREE.PerspectiveCamera[] = scene.cameras.map(buildCamera);\n return { scene: root, cameras, lights };\n};\n\nconst buildCamera: (cam: IAutoMovieCamera) => THREE.PerspectiveCamera = (\n cam: IAutoMovieCamera,\n): THREE.PerspectiveCamera => {\n const camera: THREE.PerspectiveCamera = new THREE.PerspectiveCamera(\n cam.fovY,\n 1,\n cam.near,\n cam.far,\n );\n applyTransform(camera, cam.transform);\n return camera;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAa,cAKX,OACA,gBACA,uBAC0B;CAC1B,MAAM,gBACJ,8BAA8B;EAC5B,QAAQ,MAAM;EACd,SAAS,MAAM,aAAa;CAC9B,CAAC;CACH,IAAI,CAAC,cAAc,SACjB,MAAM,IAAI,MACR,iCAAiC,KAAK,UAAU,cAAc,UAAU,CAC1E;CACF,MAAM,OAA4C,IAAI,MAAM,MAAM;CAElE,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,MAAM,QAA2C,eAAe,KAAK,KAAK;EAK1E,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MACR,eAAe,KAAK,GAAG,sBAAsB,KAAK,MAAM,0CAC1D;EACF,MAAM,YAAiD,IAAI,MAAM,MAAM;EAKvE,UAAU,OAAO,KAAK;EACtB,eAAe,WAAW,KAAK,SAAS;EACxC,UAAU,IAAI,MAAM,MAAM;EAG1B,KAAK,IAAI,SAAS;CACpB;CAMA,MAAM,yBAAmC,IAAI,IAAyB;CACtE,KAAK,MAAM,SAAS,MAAM,QAAQ;EAChC,MAAM,SAAsB,WAAW,KAAK;EAC5C,KAAK,IAAI,MAAM;EACf,OAAO,IAAI,MAAM,IAAI,MAAM;CAC7B;CAEA,MAAM,QAAgC,MAAM,SAAS;CACrD,IAAI,UAAU,MAAM,KAAK,IAAI,iBAAiB,KAAK,CAAC;CAIpD,cAAc,MAAM,MAAM,GAAG;CAC7B,sBAAsB,MAAM,MAAM,aAAa,kBAAkB;CAEjE,kCAAkC,IAAI;CAGtC,OAAO;EAAE,OAAO;EAAM,SADqB,MAAM,QAAQ,IAAI,WACjC;EAAG;CAAO;AACxC;AAEA,MAAM,eACJ,QAC4B;CAC5B,MAAM,SAAkC,IAAI,MAAM,kBAChD,IAAI,MACJ,GACA,IAAI,MACJ,IAAI,GACN;CACA,eAAe,QAAQ,IAAI,SAAS;CACpC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"buildScene.mjs","names":[],"sources":["../../src/scene/buildScene.ts"],"sourcesContent":["import { resolveAutoMovieShadowProfile } from \"@automovie/engine\";\nimport type {\n IAutoMovieCamera,\n IAutoMovieRenderSoftPropFrame,\n IAutoMovieScene,\n IAutoMovieSpace,\n} from \"@automovie/interface\";\nimport * as THREE from \"three\";\n\nimport type { IAutoMovieModelObject } from \"./IAutoMovieModelObject.js\";\nimport type { IAutoMovieSceneObject } from \"./IAutoMovieSceneObject.js\";\nimport type { IAutoMovieSceneSoftProps } from \"./IAutoMovieSceneSoftProps.js\";\nimport { applyAutoMovieShadowParticipation } from \"./applyAutoMovieShadowParticipation.js\";\nimport { applySceneEnvironment } from \"./applySceneEnvironment.js\";\nimport { applySceneFog } from \"./applySceneFog.js\";\nimport { applyTransform } from \"./applyTransform.js\";\nimport { buildLight } from \"./buildLight.js\";\nimport { buildSceneSoftProps } from \"./buildSceneSoftProps.js\";\nimport { buildSpaceObject } from \"./buildSpace.js\";\nimport { restoreAutoMovieRenderModeState } from \"./restoreAutoMovieRenderModeState.js\";\n\n/**\n * Build a `three.js` scene from an {@link IAutoMovieScene}.\n *\n * `getModelObject` resolves a node's `model` id to a built\n * {@link IAutoMovieModelObject}. If the same model id appears in multiple nodes\n * it should return a distinct object each call (a `three.js` object can live in\n * one place only). Each node is wrapped in a group placed at its world\n * transform, so node placement and a pose's own root transform compose\n * cleanly.\n *\n * Cameras and the four light kinds (point, area, directional and spot) map onto their `three.js` equivalents.\n *\n * **The first `scene.nodes.length` top-level children ARE the designed nodes,\n * in design order.** Both mask passes read that: the legacy ramp colours the\n * Nth child with the Nth colour, and the stable semantic palette resolves a\n * designed node to `root.children[index]` (see\n * {@link applyAutoMovieSemanticMask}). Anything this function adds of its own\n * goes after them, and a host that prepends a child of its own breaks the\n * second one exactly as it always broke the first.\n *\n * A scene carrying a `space` also gets its structural ground (#1173): the\n * standable surfaces become real meshes under one `SPACE_GROUP_NAME` group (see\n * {@link buildSpaceObject}), so guide passes describe a world instead of actors\n * floating in a void. Their ordinary material writes no beauty colour or depth,\n * because a semantic support declaration is not evidence that physical floor\n * geometry exists. The group follows the nodes and lights so the whole\n * ground reads as one mask colour rather than one per surface.\n *\n * An optional frame of soft props follows the designed scene objects.\n * Its returned handle updates plain surfaces at later times and releases\n * the meshes. Pass an empty frame to opt in before the first prop appears.\n *\n * The cited refusal contribution covers the supplied shadow profile and unresolved node model. Complete hierarchy, material and numeric admission, lowering receipts and structured safe-retry policy remain with their corresponding owners.\n *\n * @evidence contracts/development/implementation.md#principled-implementation Preserves authored node order under placement groups, admits the shadow profile, builds native lights/cameras, optional semantic support, fog and environment; each resolver call must supply a distinct mutable model object and valid admitted TRS. Static pose/props/compiled populations are not lowered here and current production pages assemble their own graph rather than calling this producer.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure Owns the scene graph join and camera/light lookup while model loading, articulation, temporal sampling and rendering remain external. The soft layer uses its own owner and follows the designed children.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Refuses unresolved models rather than dropping an authored child and shifting mask indices; no fixture nodes/lights are invented, but complete admission and partial-construction rollback are not supplied by this scene wrapper.\n * @evidence contracts/development/common.md#meaningful-documentation States resolver uniqueness, authored node order, placement/root composition, semantic-ground beauty exclusion, static-pose caller duty and explicit refusal/admission ownership boundary.\n * @evidence contracts/development/implementation.md#efficient-algorithms Builds N placement groups, L lights and C cameras with id maps plus support tessellation and shadow participation traversal; dominant memory follows actual model/support resources returned by producers, and no anonymous member runtime is created here.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work Reuses canonical transform/light/fog/environment/space adapters and maps lights by semantic id; model object reuse across placements is invalid because native parenting is exclusive, and scene-level effectful construction is not cached.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Transfers new scene, group, light, camera and support references and adopts resolver model objects. Failed soft-prop mounting retires that layer. The caller otherwise owns retirement and partial graph recovery; environment texture handoff has a separate owner.\n */\nexport const buildScene: (\n scene: IAutoMovieScene,\n getModelObject: (modelId: string) => IAutoMovieModelObject | undefined,\n environmentTexture?: THREE.Texture,\n softFrame?: readonly IAutoMovieRenderSoftPropFrame[],\n) => IAutoMovieSceneObject = (\n scene: IAutoMovieScene,\n getModelObject: (modelId: string) => IAutoMovieModelObject | undefined,\n environmentTexture?: THREE.Texture,\n softFrame?: readonly IAutoMovieRenderSoftPropFrame[],\n): IAutoMovieSceneObject => {\n const shadowProfile: ReturnType<typeof resolveAutoMovieShadowProfile> =\n resolveAutoMovieShadowProfile({\n lights: scene.lights,\n shadows: scene.environment?.shadows,\n });\n if (!shadowProfile.success)\n throw new Error(\n \"Unsupported shadow profile: \" + JSON.stringify(shadowProfile.violations),\n );\n const root: THREE.Scene<THREE.Object3DEventMap> = new THREE.Scene();\n\n for (const node of scene.nodes) {\n const built: IAutoMovieModelObject | undefined = getModelObject(node.model);\n // Caller data that cannot resolve is an error, not a skip (#1051): both\n // mask passes read a designed node off its top-level child INDEX, so a\n // silently dropped node would shift every later node one place over and a\n // mask consumer would attribute pixels to the wrong node.\n if (built === undefined)\n throw new Error(\n `scene node \"${node.id}\" references model \"${node.model}\", which getModelObject could not resolve`,\n );\n const nodeGroup: THREE.Group<THREE.Object3DEventMap> = new THREE.Group();\n // Named, so a consumer can find a node's group by its scene id instead of\n // by position among `root.children`. The two agree today only because this\n // loop appends in design order, which a host that prepends anything of its\n // own silently breaks.\n nodeGroup.name = node.id;\n applyTransform(nodeGroup, node.transform);\n nodeGroup.add(built.object);\n // Static posing (node.pose) is done by the caller via `applyPose`, since it\n // needs the model's skeleton, which buildScene does not resolve here.\n root.add(nodeGroup);\n }\n\n // Lights stay top-level children, after the nodes, so the designed nodes keep\n // the leading run of `root.children` that both mask passes read them off. The\n // id map is built alongside so a shot's `lightMotions` can find one without\n // depending on where it landed.\n const lights: Map<string, THREE.Light> = new Map<string, THREE.Light>();\n for (const light of scene.lights) {\n const object: THREE.Light = buildLight(light);\n root.add(object);\n lights.set(light.id, object);\n }\n\n const space: IAutoMovieSpace | null = scene.space ?? null;\n if (space !== null) root.add(buildSpaceObject(space));\n\n // The atmosphere is a scene property, not an object: it takes no top-level\n // child, so the mask palette's child indices are untouched by declaring it.\n applySceneFog(root, scene.fog);\n applySceneEnvironment(root, scene.environment, environmentTexture);\n\n applyAutoMovieShadowParticipation(root);\n\n const cameras: THREE.PerspectiveCamera[] = scene.cameras.map(buildCamera);\n if (softFrame === undefined) return { scene: root, cameras, lights };\n const softProps: IAutoMovieSceneSoftProps = buildSceneSoftProps(root);\n try {\n softProps.update(softFrame);\n } catch (error) {\n restoreAutoMovieRenderModeState([softProps.dispose], { error });\n }\n return { scene: root, cameras, lights, softProps };\n};\n\nconst buildCamera: (cam: IAutoMovieCamera) => THREE.PerspectiveCamera = (\n cam: IAutoMovieCamera,\n): THREE.PerspectiveCamera => {\n const camera: THREE.PerspectiveCamera = new THREE.PerspectiveCamera(\n cam.fovY,\n 1,\n cam.near,\n cam.far,\n );\n applyTransform(camera, cam.transform);\n return camera;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,MAAa,cAMX,OACA,gBACA,oBACA,cAC0B;CAC1B,MAAM,gBACJ,8BAA8B;EAC5B,QAAQ,MAAM;EACd,SAAS,MAAM,aAAa;CAC9B,CAAC;CACH,IAAI,CAAC,cAAc,SACjB,MAAM,IAAI,MACR,iCAAiC,KAAK,UAAU,cAAc,UAAU,CAC1E;CACF,MAAM,OAA4C,IAAI,MAAM,MAAM;CAElE,KAAK,MAAM,QAAQ,MAAM,OAAO;EAC9B,MAAM,QAA2C,eAAe,KAAK,KAAK;EAK1E,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MACR,eAAe,KAAK,GAAG,sBAAsB,KAAK,MAAM,0CAC1D;EACF,MAAM,YAAiD,IAAI,MAAM,MAAM;EAKvE,UAAU,OAAO,KAAK;EACtB,eAAe,WAAW,KAAK,SAAS;EACxC,UAAU,IAAI,MAAM,MAAM;EAG1B,KAAK,IAAI,SAAS;CACpB;CAMA,MAAM,yBAAmC,IAAI,IAAyB;CACtE,KAAK,MAAM,SAAS,MAAM,QAAQ;EAChC,MAAM,SAAsB,WAAW,KAAK;EAC5C,KAAK,IAAI,MAAM;EACf,OAAO,IAAI,MAAM,IAAI,MAAM;CAC7B;CAEA,MAAM,QAAgC,MAAM,SAAS;CACrD,IAAI,UAAU,MAAM,KAAK,IAAI,iBAAiB,KAAK,CAAC;CAIpD,cAAc,MAAM,MAAM,GAAG;CAC7B,sBAAsB,MAAM,MAAM,aAAa,kBAAkB;CAEjE,kCAAkC,IAAI;CAEtC,MAAM,UAAqC,MAAM,QAAQ,IAAI,WAAW;CACxE,IAAI,cAAc,KAAA,GAAW,OAAO;EAAE,OAAO;EAAM;EAAS;CAAO;CACnE,MAAM,YAAsC,oBAAoB,IAAI;CACpE,IAAI;EACF,UAAU,OAAO,SAAS;CAC5B,SAAS,OAAO;EACd,gCAAgC,CAAC,UAAU,OAAO,GAAG,EAAE,MAAM,CAAC;CAChE;CACA,OAAO;EAAE,OAAO;EAAM;EAAS;EAAQ;CAAU;AACnD;AAEA,MAAM,eACJ,QAC4B;CAC5B,MAAM,SAAkC,IAAI,MAAM,kBAChD,IAAI,MACJ,GACA,IAAI,MACJ,IAAI,GACN;CACA,eAAe,QAAQ,IAAI,SAAS;CACpC,OAAO;AACT"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
import type { IAutoMovieSceneSoftProps } from "./IAutoMovieSceneSoftProps.js";
|
|
3
|
+
/**
|
|
4
|
+
* Own a scene's soft props without retaining film samples. Each update supplies
|
|
5
|
+
* the already evaluated world-space surfaces for one instant.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation Documents the scene owner, film-time boundary, replacement and cleanup.
|
|
8
|
+
* @evidence contracts/development/implementation.md#principled-implementation A map by performance subject updates one mesh per supplied frame. Common cloth projection owns Float32 geometry and material; a cord first acquires a tube through its particles.
|
|
9
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Admit unique subjects and project their geometry before changing the scene, then update retained meshes and withdraw absent meshes.
|
|
10
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Accepts producer status verbatim and adds no solve or interpolation. An effectful mesh update can fail after another mesh has already advanced.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Map work is linear in incoming and currently mounted subjects, with additional projection work linear in their buffers.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A subject present in successive frames retains its projection and uses compatible buffers through buildSoftBodyObject.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Holds one projection per mounted subject. Dropped meshes are detached and independently retired, and explicit disposal closes updates and retires all remaining meshes.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildSceneSoftProps(scene: THREE.Scene): IAutoMovieSceneSoftProps;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSceneSoftProps = buildSceneSoftProps;
|
|
4
|
+
const applyAutoMovieShadowParticipation_js_1 = require("./applyAutoMovieShadowParticipation.js");
|
|
5
|
+
const buildSoftBodyObject_js_1 = require("./buildSoftBodyObject.js");
|
|
6
|
+
const restoreAutoMovieRenderModeOnce_js_1 = require("./restoreAutoMovieRenderModeOnce.js");
|
|
7
|
+
const restoreAutoMovieRenderModeState_js_1 = require("./restoreAutoMovieRenderModeState.js");
|
|
8
|
+
const softPropCordSurface_js_1 = require("./softPropCordSurface.js");
|
|
9
|
+
/**
|
|
10
|
+
* Own a scene's soft props without retaining film samples. Each update supplies
|
|
11
|
+
* the already evaluated world-space surfaces for one instant.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/development/common.md#meaningful-documentation Documents the scene owner, film-time boundary, replacement and cleanup.
|
|
14
|
+
* @evidence contracts/development/implementation.md#principled-implementation A map by performance subject updates one mesh per supplied frame. Common cloth projection owns Float32 geometry and material; a cord first acquires a tube through its particles.
|
|
15
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Admit unique subjects and project their geometry before changing the scene, then update retained meshes and withdraw absent meshes.
|
|
16
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Accepts producer status verbatim and adds no solve or interpolation. An effectful mesh update can fail after another mesh has already advanced.
|
|
17
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Map work is linear in incoming and currently mounted subjects, with additional projection work linear in their buffers.
|
|
18
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A subject present in successive frames retains its projection and uses compatible buffers through buildSoftBodyObject.
|
|
19
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Holds one projection per mounted subject. Dropped meshes are detached and independently retired, and explicit disposal closes updates and retires all remaining meshes.
|
|
20
|
+
*/
|
|
21
|
+
function buildSceneSoftProps(scene) {
|
|
22
|
+
const mounted = new Map();
|
|
23
|
+
let closed = false;
|
|
24
|
+
return {
|
|
25
|
+
update: (frames) => {
|
|
26
|
+
if (closed)
|
|
27
|
+
throw new Error("The scene's soft props are closed.");
|
|
28
|
+
const incoming = new Map();
|
|
29
|
+
for (const frame of frames) {
|
|
30
|
+
if (frame.subject.trim() === "" || incoming.has(frame.subject))
|
|
31
|
+
throw new Error(`Invalid or repeated soft prop subject "${frame.subject}".`);
|
|
32
|
+
const surface = frame.cordRadius === undefined
|
|
33
|
+
? frame.surface
|
|
34
|
+
: (0, softPropCordSurface_js_1.softPropCordSurface)(frame.surface, frame.cordRadius);
|
|
35
|
+
incoming.set(frame.subject, { ...frame, surface });
|
|
36
|
+
}
|
|
37
|
+
for (const [subject, frame] of incoming) {
|
|
38
|
+
const previous = mounted.get(subject);
|
|
39
|
+
if (previous !== undefined)
|
|
40
|
+
previous.update(frame);
|
|
41
|
+
else {
|
|
42
|
+
const projection = (0, buildSoftBodyObject_js_1.buildSoftBodyObject)(frame);
|
|
43
|
+
projection.object.name = `soft:${subject}`;
|
|
44
|
+
mounted.set(subject, projection);
|
|
45
|
+
(0, applyAutoMovieShadowParticipation_js_1.applyAutoMovieShadowParticipation)(projection.object);
|
|
46
|
+
scene.add(projection.object);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const removals = [];
|
|
50
|
+
for (const [subject, projection] of mounted)
|
|
51
|
+
if (!incoming.has(subject)) {
|
|
52
|
+
mounted.delete(subject);
|
|
53
|
+
removals.push(() => {
|
|
54
|
+
scene.remove(projection.object);
|
|
55
|
+
}, projection.dispose);
|
|
56
|
+
}
|
|
57
|
+
(0, restoreAutoMovieRenderModeState_js_1.restoreAutoMovieRenderModeState)(removals);
|
|
58
|
+
},
|
|
59
|
+
dispose: (0, restoreAutoMovieRenderModeOnce_js_1.restoreAutoMovieRenderModeOnce)(() => {
|
|
60
|
+
closed = true;
|
|
61
|
+
const removals = [];
|
|
62
|
+
for (const projection of mounted.values())
|
|
63
|
+
removals.push(() => {
|
|
64
|
+
scene.remove(projection.object);
|
|
65
|
+
}, projection.dispose);
|
|
66
|
+
mounted.clear();
|
|
67
|
+
(0, restoreAutoMovieRenderModeState_js_1.restoreAutoMovieRenderModeState)(removals);
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=buildSceneSoftProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSceneSoftProps.js","sourceRoot":"","sources":["../../src/scene/buildSceneSoftProps.ts"],"names":[],"mappings":";;;AAQA,iGAA2F;AAC3F,qEAA+D;AAC/D,2FAAqF;AACrF,6FAAuF;AACvF,qEAA+D;AAE/D;;;;;;;;;;;GAWG;AACH,6BACE,KAAkB;IAElB,MAAM,OAAO,GAA0C,IAAI,GAAG,EAAE,CAAC;IACjE,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,OAAO;QACL,MAAM,EAAE,CAAC,MAAgD,EAAQ,EAAE;YACjE,IAAI,MAAM;gBAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;YAClE,MAAM,QAAQ,GAA+C,IAAI,GAAG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O;gBACzC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;oBAC3B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBACxB,QAAQ,CAAC,IAAI,CAAC,GAAS,EAAE;wBACvB,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;oBAClC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;gBACzB,CAAC;YACH,IAAA,oEAA+B,EAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,EAAE,IAAA,kEAA8B,EAAC,GAAS,EAAE;YACjD,MAAM,GAAG,IAAI,CAAC;YACd,MAAM,QAAQ,GAAmB,EAAE,CAAC;YACpC,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE;gBACvC,QAAQ,CAAC,IAAI,CAAC,GAAS,EAAE;oBACvB,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAClC,CAAC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;YACzB,OAAO,CAAC,KAAK,EAAE,CAAC;YAChB,IAAA,oEAA+B,EAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { applyAutoMovieShadowParticipation } from "./applyAutoMovieShadowParticipation.mjs";
|
|
2
|
+
import { buildSoftBodyObject } from "./buildSoftBodyObject.mjs";
|
|
3
|
+
import { restoreAutoMovieRenderModeOnce } from "./restoreAutoMovieRenderModeOnce.mjs";
|
|
4
|
+
import { restoreAutoMovieRenderModeState } from "./restoreAutoMovieRenderModeState.mjs";
|
|
5
|
+
import { softPropCordSurface } from "./softPropCordSurface.mjs";
|
|
6
|
+
// src/scene/buildSceneSoftProps.ts
|
|
7
|
+
/**
|
|
8
|
+
* Own a scene's soft props without retaining film samples. Each update supplies
|
|
9
|
+
* the already evaluated world-space surfaces for one instant.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/development/common.md#meaningful-documentation Documents the scene owner, film-time boundary, replacement and cleanup.
|
|
12
|
+
* @evidence contracts/development/implementation.md#principled-implementation A map by performance subject updates one mesh per supplied frame. Common cloth projection owns Float32 geometry and material; a cord first acquires a tube through its particles.
|
|
13
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Admit unique subjects and project their geometry before changing the scene, then update retained meshes and withdraw absent meshes.
|
|
14
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Accepts producer status verbatim and adds no solve or interpolation. An effectful mesh update can fail after another mesh has already advanced.
|
|
15
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Map work is linear in incoming and currently mounted subjects, with additional projection work linear in their buffers.
|
|
16
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A subject present in successive frames retains its projection and uses compatible buffers through buildSoftBodyObject.
|
|
17
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Holds one projection per mounted subject. Dropped meshes are detached and independently retired, and explicit disposal closes updates and retires all remaining meshes.
|
|
18
|
+
*/
|
|
19
|
+
function buildSceneSoftProps(scene) {
|
|
20
|
+
const mounted = /* @__PURE__ */ new Map();
|
|
21
|
+
let closed = false;
|
|
22
|
+
return {
|
|
23
|
+
update: (frames) => {
|
|
24
|
+
if (closed) throw new Error("The scene's soft props are closed.");
|
|
25
|
+
const incoming = /* @__PURE__ */ new Map();
|
|
26
|
+
for (const frame of frames) {
|
|
27
|
+
if (frame.subject.trim() === "" || incoming.has(frame.subject)) throw new Error(`Invalid or repeated soft prop subject "${frame.subject}".`);
|
|
28
|
+
const surface = frame.cordRadius === void 0 ? frame.surface : softPropCordSurface(frame.surface, frame.cordRadius);
|
|
29
|
+
incoming.set(frame.subject, {
|
|
30
|
+
...frame,
|
|
31
|
+
surface
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
for (const [subject, frame] of incoming) {
|
|
35
|
+
const previous = mounted.get(subject);
|
|
36
|
+
if (previous !== void 0) previous.update(frame);
|
|
37
|
+
else {
|
|
38
|
+
const projection = buildSoftBodyObject(frame);
|
|
39
|
+
projection.object.name = `soft:${subject}`;
|
|
40
|
+
mounted.set(subject, projection);
|
|
41
|
+
applyAutoMovieShadowParticipation(projection.object);
|
|
42
|
+
scene.add(projection.object);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const removals = [];
|
|
46
|
+
for (const [subject, projection] of mounted) if (!incoming.has(subject)) {
|
|
47
|
+
mounted.delete(subject);
|
|
48
|
+
removals.push(() => {
|
|
49
|
+
scene.remove(projection.object);
|
|
50
|
+
}, projection.dispose);
|
|
51
|
+
}
|
|
52
|
+
restoreAutoMovieRenderModeState(removals);
|
|
53
|
+
},
|
|
54
|
+
dispose: restoreAutoMovieRenderModeOnce(() => {
|
|
55
|
+
closed = true;
|
|
56
|
+
const removals = [];
|
|
57
|
+
for (const projection of mounted.values()) removals.push(() => {
|
|
58
|
+
scene.remove(projection.object);
|
|
59
|
+
}, projection.dispose);
|
|
60
|
+
mounted.clear();
|
|
61
|
+
restoreAutoMovieRenderModeState(removals);
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export { buildSceneSoftProps };
|
|
66
|
+
|
|
67
|
+
//# sourceMappingURL=buildSceneSoftProps.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSceneSoftProps.mjs","names":[],"sources":["../../src/scene/buildSceneSoftProps.ts"],"sourcesContent":["import type {\n IAutoMovieRenderSoftPropFrame,\n IAutoMovieSoftBodySurface,\n} from \"@automovie/interface\";\nimport type * as THREE from \"three\";\n\nimport type { IAutoMovieSceneSoftProps } from \"./IAutoMovieSceneSoftProps.js\";\nimport type { IAutoMovieSoftBodyObject } from \"./IAutoMovieSoftBodyObject.js\";\nimport { applyAutoMovieShadowParticipation } from \"./applyAutoMovieShadowParticipation.js\";\nimport { buildSoftBodyObject } from \"./buildSoftBodyObject.js\";\nimport { restoreAutoMovieRenderModeOnce } from \"./restoreAutoMovieRenderModeOnce.js\";\nimport { restoreAutoMovieRenderModeState } from \"./restoreAutoMovieRenderModeState.js\";\nimport { softPropCordSurface } from \"./softPropCordSurface.js\";\n\n/**\n * Own a scene's soft props without retaining film samples. Each update supplies\n * the already evaluated world-space surfaces for one instant.\n *\n * @evidence contracts/development/common.md#meaningful-documentation Documents the scene owner, film-time boundary, replacement and cleanup.\n * @evidence contracts/development/implementation.md#principled-implementation A map by performance subject updates one mesh per supplied frame. Common cloth projection owns Float32 geometry and material; a cord first acquires a tube through its particles.\n * @evidence contracts/development/implementation.md#clear-and-simple-structure Admit unique subjects and project their geometry before changing the scene, then update retained meshes and withdraw absent meshes.\n * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Accepts producer status verbatim and adds no solve or interpolation. An effectful mesh update can fail after another mesh has already advanced.\n * @evidence contracts/development/implementation.md#efficient-algorithms Map work is linear in incoming and currently mounted subjects, with additional projection work linear in their buffers.\n * @evidence contracts/development/implementation.md#reuse-equivalent-work A subject present in successive frames retains its projection and uses compatible buffers through buildSoftBodyObject.\n * @evidence contracts/development/implementation.md#bound-retention-and-release-resources Holds one projection per mounted subject. Dropped meshes are detached and independently retired, and explicit disposal closes updates and retires all remaining meshes.\n */\nexport function buildSceneSoftProps(\n scene: THREE.Scene,\n): IAutoMovieSceneSoftProps {\n const mounted: Map<string, IAutoMovieSoftBodyObject> = new Map();\n let closed: boolean = false;\n return {\n update: (frames: readonly IAutoMovieRenderSoftPropFrame[]): void => {\n if (closed) throw new Error(\"The scene's soft props are closed.\");\n const incoming: Map<string, IAutoMovieRenderSoftPropFrame> = new Map();\n for (const frame of frames) {\n if (frame.subject.trim() === \"\" || incoming.has(frame.subject))\n throw new Error(\n `Invalid or repeated soft prop subject \"${frame.subject}\".`,\n );\n const surface: IAutoMovieSoftBodySurface =\n frame.cordRadius === undefined\n ? frame.surface\n : softPropCordSurface(frame.surface, frame.cordRadius);\n incoming.set(frame.subject, { ...frame, surface });\n }\n\n for (const [subject, frame] of incoming) {\n const previous: IAutoMovieSoftBodyObject | undefined =\n mounted.get(subject);\n if (previous !== undefined) previous.update(frame);\n else {\n const projection: IAutoMovieSoftBodyObject =\n buildSoftBodyObject(frame);\n projection.object.name = `soft:${subject}`;\n mounted.set(subject, projection);\n applyAutoMovieShadowParticipation(projection.object);\n scene.add(projection.object);\n }\n }\n\n const removals: (() => void)[] = [];\n for (const [subject, projection] of mounted)\n if (!incoming.has(subject)) {\n mounted.delete(subject);\n removals.push((): void => {\n scene.remove(projection.object);\n }, projection.dispose);\n }\n restoreAutoMovieRenderModeState(removals);\n },\n dispose: restoreAutoMovieRenderModeOnce((): void => {\n closed = true;\n const removals: (() => void)[] = [];\n for (const projection of mounted.values())\n removals.push((): void => {\n scene.remove(projection.object);\n }, projection.dispose);\n mounted.clear();\n restoreAutoMovieRenderModeState(removals);\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAgB,oBACd,OAC0B;CAC1B,MAAM,0BAAiD,IAAI,IAAI;CAC/D,IAAI,SAAkB;CACtB,OAAO;EACL,SAAS,WAA2D;GAClE,IAAI,QAAQ,MAAM,IAAI,MAAM,oCAAoC;GAChE,MAAM,2BAAuD,IAAI,IAAI;GACrE,KAAK,MAAM,SAAS,QAAQ;IAC1B,IAAI,MAAM,QAAQ,KAAK,MAAM,MAAM,SAAS,IAAI,MAAM,OAAO,GAC3D,MAAM,IAAI,MACR,0CAA0C,MAAM,QAAQ,GAC1D;IACF,MAAM,UACJ,MAAM,eAAe,KAAA,IACjB,MAAM,UACN,oBAAoB,MAAM,SAAS,MAAM,UAAU;IACzD,SAAS,IAAI,MAAM,SAAS;KAAE,GAAG;KAAO;IAAQ,CAAC;GACnD;GAEA,KAAK,MAAM,CAAC,SAAS,UAAU,UAAU;IACvC,MAAM,WACJ,QAAQ,IAAI,OAAO;IACrB,IAAI,aAAa,KAAA,GAAW,SAAS,OAAO,KAAK;SAC5C;KACH,MAAM,aACJ,oBAAoB,KAAK;KAC3B,WAAW,OAAO,OAAO,QAAQ;KACjC,QAAQ,IAAI,SAAS,UAAU;KAC/B,kCAAkC,WAAW,MAAM;KACnD,MAAM,IAAI,WAAW,MAAM;IAC7B;GACF;GAEA,MAAM,WAA2B,CAAC;GAClC,KAAK,MAAM,CAAC,SAAS,eAAe,SAClC,IAAI,CAAC,SAAS,IAAI,OAAO,GAAG;IAC1B,QAAQ,OAAO,OAAO;IACtB,SAAS,WAAiB;KACxB,MAAM,OAAO,WAAW,MAAM;IAChC,GAAG,WAAW,OAAO;GACvB;GACF,gCAAgC,QAAQ;EAC1C;EACA,SAAS,qCAA2C;GAClD,SAAS;GACT,MAAM,WAA2B,CAAC;GAClC,KAAK,MAAM,cAAc,QAAQ,OAAO,GACtC,SAAS,WAAiB;IACxB,MAAM,OAAO,WAAW,MAAM;GAChC,GAAG,WAAW,OAAO;GACvB,QAAQ,MAAM;GACd,gCAAgC,QAAQ;EAC1C,CAAC;CACH;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAutoMovieHumanSkeleton } from "@automovie/interface";
|
|
1
|
+
import type { IAutoMovieHumanSkeleton, IAutoMoviePolygonBodyCue, IAutoMovieRigidTransform } from "@automovie/interface";
|
|
2
2
|
import type * as THREE from "three";
|
|
3
3
|
/**
|
|
4
4
|
* Actual Three drawing handles for the original polygon mannequin.
|
|
@@ -15,6 +15,44 @@ import type * as THREE from "three";
|
|
|
15
15
|
* @evidence contracts/development/design.md#prohibited-design-shortcuts Scanning the declaration finds no `any`, no `unknown`, no index signature and no cast; the native drawing handle borrows canonical Human placements rather than restating their shape.
|
|
16
16
|
*/
|
|
17
17
|
export declare namespace AutoMovieHumanPolygon {
|
|
18
|
+
/**
|
|
19
|
+
* Source-clock readers and authored cues for one actor's visible drawing.
|
|
20
|
+
*
|
|
21
|
+
* @evidence contracts/development/common.md#meaningful-documentation Names the subject filter, source clock and body-to-world frame convention.
|
|
22
|
+
* @evidence contracts/development/design.md#principled-representation Shares canonical authored cues, placements and rigid transforms at the drawing boundary.
|
|
23
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface Render receives the existing source pose and optional staging reader without owning either timeline.
|
|
24
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts Actor staging remains caller-owned and the pose contains the original evaluated bones.
|
|
25
|
+
*/
|
|
26
|
+
interface IPresentation {
|
|
27
|
+
/** Exact staged actor identity. Only matching cues apply to this drawing. */
|
|
28
|
+
subject: string;
|
|
29
|
+
/** Cues in shot-local source seconds. Selected bone subtrees must be disjoint. */
|
|
30
|
+
cues: readonly IAutoMoviePolygonBodyCue[];
|
|
31
|
+
/**
|
|
32
|
+
* Read the complete deterministic pose in Human body coordinates at shot-local source seconds.
|
|
33
|
+
*
|
|
34
|
+
* @evidence contracts/development/common.md#meaningful-documentation Reads evaluated bone placements for an arbitrary source second. Source errors propagate to the builder or drawing.
|
|
35
|
+
* @evidence contracts/development/implementation.md#principled-implementation Preparation samples detach boundaries once and the prepared sampler reads the requested pose per seek. The drawing admits resulting placements before writing groups.
|
|
36
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The callback owns source pose evaluation and the presentation adapter owns cue deltas.
|
|
37
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Reads the complete source pose even when a cue replaces some of it. A release admits replaced live placements before writing its own values.
|
|
38
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One source pose read per seek plus one per detach cue at preparation. The host determines the cost of each read.
|
|
39
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Captured release placements serve later seeks. Arbitrary live poses are read at the requested time.
|
|
40
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The sampler borrows the reader for the drawing lifetime and keeps only selected release frames. Disposal drops its sampler reference.
|
|
41
|
+
*/
|
|
42
|
+
poseAt: (seconds: number) => Pick<IAutoMovieHumanSkeleton.IOutput, "posed">;
|
|
43
|
+
/**
|
|
44
|
+
* Read the actor-local to shot-world rigid frame at shot-local source seconds. Omission means identity. The host applies this frame through the drawing's parent.
|
|
45
|
+
*
|
|
46
|
+
* @evidence contracts/development/common.md#meaningful-documentation Returns metre translation and an x-y-z-w unit rotation synchronously. Invalid frames and reader errors propagate.
|
|
47
|
+
* @evidence contracts/development/implementation.md#principled-implementation Preparation moves detached source joints into the release world frame. Active samples cancel the current actor frame so the parent transform applies once.
|
|
48
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The host owns the source and parent placement. The presentation adapter admits and converts the returned rigid transform.
|
|
49
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Finite translation and squared quaternion norm within 1e-6 are checked before use. Identity is the specified behavior for an omitted reader.
|
|
50
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Calls once per detach cue at preparation and at most once per seek. The host determines the cost of each read.
|
|
51
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work The first active detach cue per seek reads the live frame and its inverse for reuse by all active detach cues.
|
|
52
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The drawing drops its borrowed reader with the sampler at disposal. Converted live frames are local to each seek.
|
|
53
|
+
*/
|
|
54
|
+
actorFrameAt?: (seconds: number) => IAutoMovieRigidTransform;
|
|
55
|
+
}
|
|
18
56
|
/**
|
|
19
57
|
* Actual rigid polygon drawing and its owned resource lifetime.
|
|
20
58
|
*
|
|
@@ -59,6 +97,19 @@ export declare namespace AutoMovieHumanPolygon {
|
|
|
59
97
|
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Temporary placement references expire after the call; drawing resources retain their existing owner and no clock or task is acquired.
|
|
60
98
|
*/
|
|
61
99
|
setPose: (output: Pick<IAutoMovieHumanSkeleton.IOutput, "posed">) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Draw the source pose with authored polygon cues at the given shot-local seconds.
|
|
102
|
+
* Present when the drawing was built with a presentation.
|
|
103
|
+
*
|
|
104
|
+
* @evidence contracts/development/common.md#meaningful-documentation Specifies availability, units and source clock.
|
|
105
|
+
* @evidence contracts/development/implementation.md#principled-implementation Samples visual poses from the requested time and applies them through setPose.
|
|
106
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The prepared sampler owns cue arithmetic and setPose owns graphics updates.
|
|
107
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The source pose and graphics inventory are reused for each seek.
|
|
108
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Sampling and applying a complete pose are both linear in the skeletal drawing size.
|
|
109
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Release frames are captured once and reused by any ordering of seeks.
|
|
110
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The drawing releases its sampler at disposal and refuses drawing after retirement.
|
|
111
|
+
*/
|
|
112
|
+
drawAt?: (seconds: number) => void;
|
|
62
113
|
/**
|
|
63
114
|
* Replace emitted-part RGB overrides; undefined restores the borrowed clay material.
|
|
64
115
|
*
|
|
@@ -24,7 +24,7 @@ import type { AutoMovieHumanPolygon } from "./AutoMovieHumanPolygon.js";
|
|
|
24
24
|
* The caller may attach a face to `head.object` in that same local frame.
|
|
25
25
|
*
|
|
26
26
|
* @param output Generated bones and placements.
|
|
27
|
-
* @param options Optional display colours keyed by emitted bone name
|
|
27
|
+
* @param options Optional display colours keyed by emitted bone name and authored cues sampled on the shot-local source clock.
|
|
28
28
|
* @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.
|
|
29
29
|
*
|
|
30
30
|
* @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.
|
|
@@ -38,4 +38,6 @@ import type { AutoMovieHumanPolygon } from "./AutoMovieHumanPolygon.js";
|
|
|
38
38
|
export declare function buildHumanPolygon(output: Pick<IAutoMovieHumanSkeleton.IOutput, "bones" | "posed">, options?: {
|
|
39
39
|
/** RGB hex overrides for matching emitted parts; omitted parts retain clay. */
|
|
40
40
|
partColors?: Readonly<Record<string, number>>;
|
|
41
|
+
/** Source pose, actor frame and authored polygon cues for optional time-based drawing. */
|
|
42
|
+
presentation?: AutoMovieHumanPolygon.IPresentation;
|
|
41
43
|
}): AutoMovieHumanPolygon.IDrawing;
|
|
@@ -40,6 +40,7 @@ const applyHumanPolygonPose_js_1 = require("./applyHumanPolygonPose.js");
|
|
|
40
40
|
const buildHumanPolygonModule_js_1 = require("./buildHumanPolygonModule.js");
|
|
41
41
|
const buildHumanPolygonParts_js_1 = require("./buildHumanPolygonParts.js");
|
|
42
42
|
const createHumanPolygonPalette_js_1 = require("./createHumanPolygonPalette.js");
|
|
43
|
+
const prepareHumanPolygonPresentation_js_1 = require("./prepareHumanPolygonPresentation.js");
|
|
43
44
|
/**
|
|
44
45
|
* Draw a rigid polygon blockout from the generated skeleton, in metres.
|
|
45
46
|
*
|
|
@@ -64,7 +65,7 @@ const createHumanPolygonPalette_js_1 = require("./createHumanPolygonPalette.js")
|
|
|
64
65
|
* The caller may attach a face to `head.object` in that same local frame.
|
|
65
66
|
*
|
|
66
67
|
* @param output Generated bones and placements.
|
|
67
|
-
* @param options Optional display colours keyed by emitted bone name
|
|
68
|
+
* @param options Optional display colours keyed by emitted bone name and authored cues sampled on the shot-local source clock.
|
|
68
69
|
* @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.
|
|
69
70
|
*
|
|
70
71
|
* @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.
|
|
@@ -134,6 +135,7 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
134
135
|
});
|
|
135
136
|
const palette = (0, createHumanPolygonPalette_js_1.createHumanPolygonPalette)(material, partMeshes);
|
|
136
137
|
let disposed = false;
|
|
138
|
+
let samplePresentation;
|
|
137
139
|
let retirementFailure;
|
|
138
140
|
/**
|
|
139
141
|
* Guard the existing palette lifetime before replacing display colours.
|
|
@@ -191,6 +193,7 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
191
193
|
if (disposed)
|
|
192
194
|
return;
|
|
193
195
|
disposed = true;
|
|
196
|
+
samplePresentation = undefined;
|
|
194
197
|
try {
|
|
195
198
|
(0, reportAutoMovieResourceRetirement_js_1.reportAutoMovieResourceRetirement)([
|
|
196
199
|
...geometries.map((geometry) => () => geometry.dispose()),
|
|
@@ -231,6 +234,8 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
231
234
|
groups.set(bone.bone, joint);
|
|
232
235
|
bindings.set(bone.bone, [joint]);
|
|
233
236
|
}
|
|
237
|
+
if (options.presentation !== undefined)
|
|
238
|
+
samplePresentation = (0, prepareHumanPolygonPresentation_js_1.prepareHumanPolygonPresentation)(options.presentation, bones, new Set(partMeshes.keys()));
|
|
234
239
|
setPartColors(options.partColors);
|
|
235
240
|
(0, applyHumanPolygonPose_js_1.applyHumanPolygonPose)(object, bindings, required, output);
|
|
236
241
|
}
|
|
@@ -238,7 +243,7 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
238
243
|
dispose({ error });
|
|
239
244
|
throw error;
|
|
240
245
|
}
|
|
241
|
-
|
|
246
|
+
const drawing = {
|
|
242
247
|
object,
|
|
243
248
|
surface,
|
|
244
249
|
sections,
|
|
@@ -259,5 +264,12 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
259
264
|
},
|
|
260
265
|
dispose,
|
|
261
266
|
};
|
|
267
|
+
if (samplePresentation !== undefined)
|
|
268
|
+
drawing.drawAt = (seconds) => {
|
|
269
|
+
if (samplePresentation === undefined)
|
|
270
|
+
throw new Error("Polygon drawing is disposed");
|
|
271
|
+
drawing.setPose(samplePresentation(seconds));
|
|
272
|
+
};
|
|
273
|
+
return drawing;
|
|
262
274
|
}
|
|
263
275
|
//# sourceMappingURL=buildHumanPolygon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildHumanPolygon.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/buildHumanPolygon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAY,KAAK,kCAAc;AAE/B,kGAA4F;AAE5F,yEAAmE;AACnE,6EAAuE;AACvE,2EAAqE;AACrE,iFAA2E;
|
|
1
|
+
{"version":3,"file":"buildHumanPolygon.js","sourceRoot":"","sources":["../../../src/scene/human-polygon/buildHumanPolygon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAY,KAAK,kCAAc;AAE/B,kGAA4F;AAE5F,yEAAmE;AACnE,6EAAuE;AACvE,2EAAqE;AACrE,iFAA2E;AAC3E,6FAAuF;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,2BACE,MAAgE,EAChE,OAAO,GAKH,EAAE;IAEN,wDAAyB,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvD,MAAM,KAAK,GAAyC,IAAI,GAAG,EAAE,CAAC;IAC9D,MAAM,UAAU,GAA8C,IAAI,GAAG,EAAE,CAAC;IACxE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAChC,IACE,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACpB,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;YAClB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7B,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;YACrC,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAA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C,6BAA6B,CAAC,CAAC;YACjD,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,CAAC,CAAC;IACJ,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { applyHumanPolygonPose } from "./applyHumanPolygonPose.mjs";
|
|
|
3
3
|
import { buildHumanPolygonModule } from "./buildHumanPolygonModule.mjs";
|
|
4
4
|
import { buildHumanPolygonParts } from "./buildHumanPolygonParts.mjs";
|
|
5
5
|
import { createHumanPolygonPalette } from "./createHumanPolygonPalette.mjs";
|
|
6
|
+
import { prepareHumanPolygonPresentation } from "./prepareHumanPolygonPresentation.mjs";
|
|
6
7
|
import * as THREE from "three";
|
|
7
8
|
// src/scene/human-polygon/buildHumanPolygon.ts
|
|
8
9
|
/**
|
|
@@ -29,7 +30,7 @@ import * as THREE from "three";
|
|
|
29
30
|
* The caller may attach a face to `head.object` in that same local frame.
|
|
30
31
|
*
|
|
31
32
|
* @param output Generated bones and placements.
|
|
32
|
-
* @param options Optional display colours keyed by emitted bone name
|
|
33
|
+
* @param options Optional display colours keyed by emitted bone name and authored cues sampled on the shot-local source clock.
|
|
33
34
|
* @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.
|
|
34
35
|
*
|
|
35
36
|
* @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.
|
|
@@ -90,6 +91,7 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
90
91
|
});
|
|
91
92
|
const palette = createHumanPolygonPalette(material, partMeshes);
|
|
92
93
|
let disposed = false;
|
|
94
|
+
let samplePresentation;
|
|
93
95
|
let retirementFailure;
|
|
94
96
|
/**
|
|
95
97
|
* Guard the existing palette lifetime before replacing display colours.
|
|
@@ -143,6 +145,7 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
143
145
|
if (retirementFailure !== void 0) throw retirementFailure.error;
|
|
144
146
|
if (disposed) return;
|
|
145
147
|
disposed = true;
|
|
148
|
+
samplePresentation = void 0;
|
|
146
149
|
try {
|
|
147
150
|
reportAutoMovieResourceRetirement([
|
|
148
151
|
...geometries.map((geometry) => () => geometry.dispose()),
|
|
@@ -179,13 +182,14 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
179
182
|
groups.set(bone.bone, joint);
|
|
180
183
|
bindings.set(bone.bone, [joint]);
|
|
181
184
|
}
|
|
185
|
+
if (options.presentation !== void 0) samplePresentation = prepareHumanPolygonPresentation(options.presentation, bones, new Set(partMeshes.keys()));
|
|
182
186
|
setPartColors(options.partColors);
|
|
183
187
|
applyHumanPolygonPose(object, bindings, required, output);
|
|
184
188
|
} catch (error) {
|
|
185
189
|
dispose({ error });
|
|
186
190
|
throw error;
|
|
187
191
|
}
|
|
188
|
-
|
|
192
|
+
const drawing = {
|
|
189
193
|
object,
|
|
190
194
|
surface,
|
|
191
195
|
sections,
|
|
@@ -213,6 +217,11 @@ function buildHumanPolygon(output, options = {}) {
|
|
|
213
217
|
},
|
|
214
218
|
dispose
|
|
215
219
|
};
|
|
220
|
+
if (samplePresentation !== void 0) drawing.drawAt = (seconds) => {
|
|
221
|
+
if (samplePresentation === void 0) throw new Error("Polygon drawing is disposed");
|
|
222
|
+
drawing.setPose(samplePresentation(seconds));
|
|
223
|
+
};
|
|
224
|
+
return drawing;
|
|
216
225
|
}
|
|
217
226
|
export { buildHumanPolygon };
|
|
218
227
|
|