@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
IAutoMovieSoftBodySurface,
|
|
3
|
+
IAutoMovieSoftBounds,
|
|
4
|
+
} from "@automovie/interface";
|
|
5
|
+
import * as THREE from "three";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Use a ring of the Three.js tube at each distinct adjoining particle.
|
|
9
|
+
* The input is an unindexed one-wide surface in world metres.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/development/common.md#meaningful-documentation States the source, coordinate frame and tube sampling rule.
|
|
12
|
+
* @evidence contracts/development/implementation.md#principled-implementation TubeGeometry transports its frame along a path parameterized by particle index, preserving nonuniform particle spacing in the ring centres up to Float32 conversion.
|
|
13
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The path defines the parameterization and tangents. Three.js owns ring construction, winding, normals and UVs.
|
|
14
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The radius is the caller's in metres, and the radial tessellation is Three.js's default. Missing or unrepresentable coordinates and nonfinite tube output are refused. Consecutive identical points share a ring; a point-only configuration has no tube.
|
|
15
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Linear in particles and the SDK's fixed radial segments. Adjacent coincident points are removed once and all path samples use direct index addressing.
|
|
16
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work The geometry represents one frame's particle positions, with no assumption that another frame has the same points.
|
|
17
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Disposes the temporary buffer geometry after copying its attributes; the result retains only plain arrays and its extent.
|
|
18
|
+
*/
|
|
19
|
+
export function softPropCordSurface(
|
|
20
|
+
surface: IAutoMovieSoftBodySurface,
|
|
21
|
+
radius: number,
|
|
22
|
+
): IAutoMovieSoftBodySurface {
|
|
23
|
+
const positions: readonly number[] = surface.mesh.positions;
|
|
24
|
+
const projectedRadius: number = Math.fround(radius);
|
|
25
|
+
if (
|
|
26
|
+
!Number.isFinite(projectedRadius) ||
|
|
27
|
+
projectedRadius <= 0 ||
|
|
28
|
+
surface.bounds !== null ||
|
|
29
|
+
(surface.mesh.indices?.length ?? 0) !== 0 ||
|
|
30
|
+
positions.length < 6 ||
|
|
31
|
+
positions.length % 3 !== 0
|
|
32
|
+
)
|
|
33
|
+
throw new Error(
|
|
34
|
+
`Soft prop domain "${surface.domain}" needs an unindexed cord with finite particles and a positive finite radius.`,
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const points: THREE.Vector3[] = [];
|
|
38
|
+
for (let offset: number = 0; offset < positions.length; offset += 3) {
|
|
39
|
+
const point: THREE.Vector3 = new THREE.Vector3().fromArray(
|
|
40
|
+
positions,
|
|
41
|
+
offset,
|
|
42
|
+
);
|
|
43
|
+
if (
|
|
44
|
+
!Number.isFinite(Math.fround(point.x)) ||
|
|
45
|
+
!Number.isFinite(Math.fround(point.y)) ||
|
|
46
|
+
!Number.isFinite(Math.fround(point.z))
|
|
47
|
+
)
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Soft prop domain "${surface.domain}" has an unrepresentable cord particle.`,
|
|
50
|
+
);
|
|
51
|
+
const previous: THREE.Vector3 | undefined = points[points.length - 1];
|
|
52
|
+
if (previous === undefined || !point.equals(previous)) points.push(point);
|
|
53
|
+
}
|
|
54
|
+
if (points.length < 2) return surface;
|
|
55
|
+
|
|
56
|
+
const geometry: THREE.TubeGeometry = new THREE.TubeGeometry(
|
|
57
|
+
new ParticlePath(points),
|
|
58
|
+
points.length - 1,
|
|
59
|
+
radius,
|
|
60
|
+
);
|
|
61
|
+
try {
|
|
62
|
+
const vertices: number[] = Array.from(
|
|
63
|
+
geometry.getAttribute("position").array,
|
|
64
|
+
);
|
|
65
|
+
const normals: number[] = Array.from(geometry.getAttribute("normal").array);
|
|
66
|
+
if (!vertices.every(Number.isFinite) || !normals.every(Number.isFinite))
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Soft prop domain "${surface.domain}" generated nonfinite tube geometry.`,
|
|
69
|
+
);
|
|
70
|
+
geometry.computeBoundingBox();
|
|
71
|
+
const box: THREE.Box3 = geometry.boundingBox!;
|
|
72
|
+
const bounds: IAutoMovieSoftBounds = {
|
|
73
|
+
min: { x: box.min.x, y: box.min.y, z: box.min.z },
|
|
74
|
+
max: { x: box.max.x, y: box.max.y, z: box.max.z },
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
domain: surface.domain,
|
|
78
|
+
step: surface.step,
|
|
79
|
+
bounds,
|
|
80
|
+
mesh: {
|
|
81
|
+
positions: vertices,
|
|
82
|
+
normals,
|
|
83
|
+
uvs: Array.from(geometry.getAttribute("uv").array),
|
|
84
|
+
indices: Array.from(geometry.getIndex()!.array),
|
|
85
|
+
skin: null,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
} finally {
|
|
89
|
+
geometry.dispose();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A piecewise straight path with one uniformly indexed parameter per particle. */
|
|
94
|
+
class ParticlePath extends THREE.Curve<THREE.Vector3> {
|
|
95
|
+
/** At least two points, with each consecutive pair distinct. */
|
|
96
|
+
public constructor(private readonly points: readonly THREE.Vector3[]) {
|
|
97
|
+
super();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Interpolate between the adjacent particle indices around this parameter. */
|
|
101
|
+
public override getPoint(
|
|
102
|
+
t: number,
|
|
103
|
+
target: THREE.Vector3 = new THREE.Vector3(),
|
|
104
|
+
): THREE.Vector3 {
|
|
105
|
+
const scaled: number = t * (this.points.length - 1);
|
|
106
|
+
const from: number = Math.min(this.points.length - 2, Math.floor(scaled));
|
|
107
|
+
return target.lerpVectors(
|
|
108
|
+
this.points[from]!,
|
|
109
|
+
this.points[from + 1]!,
|
|
110
|
+
scaled - from,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Tube rings use the authored particle spacing in place of arc-length spacing. */
|
|
115
|
+
public override getPointAt(u: number, target?: THREE.Vector3): THREE.Vector3 {
|
|
116
|
+
return this.getPoint(u, target);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Use the outgoing segment at each SDK ring, with an incoming one at the end. */
|
|
120
|
+
public override getTangentAt(
|
|
121
|
+
u: number,
|
|
122
|
+
target: THREE.Vector3 = new THREE.Vector3(),
|
|
123
|
+
): THREE.Vector3 {
|
|
124
|
+
const from: number = Math.min(
|
|
125
|
+
this.points.length - 2,
|
|
126
|
+
Math.round(u * (this.points.length - 1)),
|
|
127
|
+
);
|
|
128
|
+
return target
|
|
129
|
+
.subVectors(this.points[from + 1]!, this.points[from]!)
|
|
130
|
+
.normalize();
|
|
131
|
+
}
|
|
132
|
+
}
|