@threenative/core 0.3.4 → 0.3.5
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/capabilities.json +1505 -79
- package/dist/{audio-7i3Xl0l3.d.ts → audio-DIJE5HTr.d.ts} +43 -3
- package/dist/{canvas-layer-DDmC_VVF.d.ts → canvas-layer-C1-5CviZ.d.ts} +5 -1
- package/dist/{game-CljaDv4D.d.ts → game-Bj8G1wmD.d.ts} +102 -11
- package/dist/hot.d.ts +4 -4
- package/dist/index.d.ts +712 -118
- package/dist/index.js +12423 -4955
- package/dist/{gpu-readback-CqJEfWNQ.d.ts → model-lod-BDAUYgsS.d.ts} +80 -5
- package/dist/playtest.d.ts +6 -10
- package/dist/playtest.js +47 -24
- package/dist/react-css.d.ts +62 -0
- package/dist/react-css.js +591 -0
- package/dist/react.d.ts +2 -2
- package/dist/{renderer-CfsS2hxi.d.ts → renderer-9yEo9hPa.d.ts} +489 -22
- package/dist/terrain-jobs-worker.d.ts +2 -0
- package/dist/terrain-jobs-worker.js +130 -0
- package/dist/ui-layer.js +59 -8
- package/dist/world.d.ts +766 -73
- package/dist/world.js +9307 -3543
- package/gpl/recipes/export_world.py +18 -1
- package/mcp/blender-server.mjs +7 -4
- package/mcp/blender.mjs +3 -4
- package/mcp/engine-server.mjs +2 -2
- package/mcp/servers.mjs +4 -4
- package/package.json +15 -9
- package/patches/three@0.185.1-prd269-upgrade.patch +22418 -0
- package/patches/three@0.185.1.patch +6594 -700
- package/scripts/apply-three-patch.mjs +62 -4
- package/src/animation-blend.ts +264 -0
- package/src/animation-composition.ts +362 -0
- package/src/animation-layers.ts +260 -0
- package/src/animation-root-motion.ts +283 -0
- package/src/animation.ts +896 -0
- package/src/assets.ts +1303 -0
- package/src/atmosphere/index.ts +335 -0
- package/src/atmosphere/luts.ts +298 -0
- package/src/atmosphere/params.ts +323 -0
- package/src/audio.ts +912 -0
- package/src/billboard.ts +124 -0
- package/src/bone-lengths.ts +157 -0
- package/src/camera-shake.ts +116 -0
- package/src/canvas-layer.ts +47 -0
- package/src/clip-audit.ts +401 -0
- package/src/clustered-batch.ts +492 -0
- package/src/clustered-mesh.ts +638 -0
- package/src/compute-driven.ts +176 -0
- package/src/compute-timing.ts +318 -0
- package/src/config.ts +593 -0
- package/src/debug.ts +82 -0
- package/src/engine-render-hook.ts +25 -0
- package/src/entities.ts +79 -0
- package/src/entity-snapshot.ts +53 -0
- package/src/flight.ts +683 -0
- package/src/fluid-field.ts +748 -0
- package/src/fluid-particles.ts +1253 -0
- package/src/frame-budget.ts +1368 -0
- package/src/game.ts +2390 -0
- package/src/geometry-capture.ts +1098 -0
- package/src/gpu-class.ts +160 -0
- package/src/gpu-frame-observation.ts +424 -0
- package/src/gpu-readback.ts +143 -0
- package/src/gpu-scene-bvh.ts +464 -0
- package/src/grounding.ts +100 -0
- package/src/hot.ts +161 -0
- package/src/import-meta.d.ts +13 -0
- package/src/index.ts +1536 -0
- package/src/input.ts +690 -0
- package/src/instanced-batch-lod.ts +283 -0
- package/src/instanced-batch.ts +274 -0
- package/src/interpolation.ts +129 -0
- package/src/launch-diagnostics.ts +161 -0
- package/src/loop.ts +564 -0
- package/src/matrix-world.ts +245 -0
- package/src/merge-parts.ts +812 -0
- package/src/model-lod.ts +1315 -0
- package/src/net-protocol.ts +333 -0
- package/src/net-session.ts +477 -0
- package/src/net.ts +80 -0
- package/src/ocean/fft.ts +72 -0
- package/src/ocean/spectral.ts +728 -0
- package/src/particle-significance.ts +102 -0
- package/src/particles.ts +648 -0
- package/src/path-follow.ts +175 -0
- package/src/picking.ts +250 -0
- package/src/pipeline-census.ts +1566 -0
- package/src/platform.ts +210 -0
- package/src/playtest.ts +839 -0
- package/src/pointer-events.ts +411 -0
- package/src/pose-measure.ts +435 -0
- package/src/profiling/FrameCounters.ts +231 -0
- package/src/profiling/Spans.ts +548 -0
- package/src/profiling/opacity-convention.ts +21 -0
- package/src/profiling/render-list-validate.ts +175 -0
- package/src/profiling/render-trap-audit.ts +84 -0
- package/src/profiling/scene-warning.ts +190 -0
- package/src/profiling/span-probes.ts +191 -0
- package/src/profiling/unlit-foliage-warning.ts +149 -0
- package/src/projection-apply.ts +1529 -0
- package/src/projection-marker.ts +142 -0
- package/src/projection-plan.ts +1258 -0
- package/src/projection-skinned.ts +419 -0
- package/src/projection-stability.ts +409 -0
- package/src/projection-uniform.ts +328 -0
- package/src/random.ts +41 -0
- package/src/react-css.ts +604 -0
- package/src/react-glyphs.ts +114 -0
- package/src/react-host.ts +576 -0
- package/src/react-layout.ts +265 -0
- package/src/react.ts +60 -0
- package/src/render/alpha-antialiasing.ts +159 -0
- package/src/render/batched-velocity.ts +126 -0
- package/src/render/chain.ts +1021 -0
- package/src/render/daylight.ts +189 -0
- package/src/render/depth-pyramid.ts +596 -0
- package/src/render/foliage-alpha.ts +166 -0
- package/src/render/material-key.ts +60 -0
- package/src/render/mesh-pool.ts +144 -0
- package/src/render/probe-volume.ts +1668 -0
- package/src/render/resolution-subrect.ts +253 -0
- package/src/render/velocity.ts +442 -0
- package/src/render/virtual-shadow-pages.ts +827 -0
- package/src/render/virtual-shadow-partial.ts +174 -0
- package/src/render/virtual-shadow.ts +3330 -0
- package/src/render/world-impostor-surface.ts +722 -0
- package/src/render/world-impostor.ts +558 -0
- package/src/render-camera-cull.ts +441 -0
- package/src/render-pass-budget.ts +501 -0
- package/src/renderProjection.ts +758 -0
- package/src/renderer-config.ts +127 -0
- package/src/renderer.ts +1847 -0
- package/src/replay-protocol.ts +85 -0
- package/src/replay.ts +205 -0
- package/src/resolution-scaler.ts +819 -0
- package/src/rig-preparation.ts +271 -0
- package/src/ripple-field.ts +432 -0
- package/src/scale.ts +109 -0
- package/src/scene.ts +239 -0
- package/src/schedule.ts +155 -0
- package/src/skeletal-mesh.ts +61 -0
- package/src/skeleton.ts +100 -0
- package/src/snow-field.ts +744 -0
- package/src/softbody-topology.ts +269 -0
- package/src/softbody.ts +516 -0
- package/src/sprite-animator.ts +222 -0
- package/src/startup-readiness.ts +386 -0
- package/src/state.ts +66 -0
- package/src/static-transform.ts +274 -0
- package/src/storage-buffer.ts +253 -0
- package/src/streaming.ts +308 -0
- package/src/target-fps.ts +92 -0
- package/src/terrain-jobs-worker.ts +17 -0
- package/src/terrain-jobs.ts +353 -0
- package/src/textures.ts +39 -0
- package/src/tracers.ts +237 -0
- package/src/ui-bridge.ts +368 -0
- package/src/ui-hit-regions.ts +380 -0
- package/src/ui-layer.ts +83 -0
- package/src/ui-state.ts +220 -0
- package/src/version.ts +2 -0
- package/src/viewport.ts +253 -0
- package/src/warmup.ts +1357 -0
- package/src/water-surface.ts +384 -0
- package/src/wave-field.ts +524 -0
- package/src/world-capabilities.ts +131 -0
- package/src/world-cell-proxy.ts +392 -0
- package/src/world-cells.ts +10564 -0
- package/src/world-gpu-scene.ts +3354 -0
- package/src/world-heightmap.ts +82 -0
- package/src/world-package.ts +469 -0
- package/src/world-passes.ts +582 -0
- package/src/world-region.ts +17 -0
- package/src/world-terrain-splat.ts +564 -0
- package/src/world-tiles.ts +3826 -0
- package/src/world-topology.ts +370 -0
- package/src/world-validate.ts +48 -0
- package/src/world.ts +805 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Selectively adapted from GGEZ packages/anim-core/src/root-motion.ts
|
|
3
|
+
* (translation difference, quaternion yaw) at
|
|
4
|
+
* 45ed541cb163ef98694467758f60d5533373ac60. Adds explicit root binding,
|
|
5
|
+
* continuous loop intervals, yaw unwrapping and validated Three transforms.
|
|
6
|
+
* MIT License
|
|
7
|
+
* Copyright (c) 2026 @alightinastorm (x.com/alightinastorm)
|
|
8
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
* in the Software without restriction, including without limitation the rights
|
|
11
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
* furnished to do so, subject to the following conditions:
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
import {
|
|
25
|
+
type AnimationClip,
|
|
26
|
+
type Bone,
|
|
27
|
+
type Interpolant,
|
|
28
|
+
InterpolateLinear,
|
|
29
|
+
type KeyframeTrack,
|
|
30
|
+
Matrix4,
|
|
31
|
+
NumberKeyframeTrack,
|
|
32
|
+
type Object3D,
|
|
33
|
+
Quaternion,
|
|
34
|
+
Vector3,
|
|
35
|
+
} from "three";
|
|
36
|
+
import { animationFinite } from "./animation-blend.js";
|
|
37
|
+
import { canonicalAnimationClip } from "./animation-layers.js";
|
|
38
|
+
import { uniformYawScale } from "./rig-preparation.js";
|
|
39
|
+
|
|
40
|
+
export interface IAnimationRootMotionOptions {
|
|
41
|
+
readonly bone: string;
|
|
42
|
+
/** Existing character-body object. Its parent must be identity in this first slice. */
|
|
43
|
+
readonly body: Object3D;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IAnimationMotionDelta {
|
|
47
|
+
readonly translation: Pick<Vector3, "x" | "y" | "z">;
|
|
48
|
+
readonly yaw: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface IRootSample {
|
|
52
|
+
readonly duration: number;
|
|
53
|
+
readonly position: Interpolant | undefined;
|
|
54
|
+
readonly yaw: Interpolant | undefined;
|
|
55
|
+
readonly cycle: Vector3;
|
|
56
|
+
readonly cycleYaw: number;
|
|
57
|
+
readonly start: Vector3;
|
|
58
|
+
readonly startYaw: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface ITrackInterpolant extends KeyframeTrack {
|
|
62
|
+
createInterpolant(result: Float32Array): Interpolant;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function interpolant(track: KeyframeTrack, width: number): Interpolant {
|
|
66
|
+
if (track.getInterpolation() !== InterpolateLinear)
|
|
67
|
+
throw new Error(`AnimationComposer: root track '${track.name}' requires linear interpolation.`);
|
|
68
|
+
return (track as ITrackInterpolant).createInterpolant(new Float32Array(width));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function wrappedYaw(value: number): number {
|
|
72
|
+
return Math.atan2(Math.sin(value), Math.cos(value));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function rotateYaw(vector: Vector3, angle: number): Vector3 {
|
|
76
|
+
const c = Math.cos(angle);
|
|
77
|
+
const s = Math.sin(angle);
|
|
78
|
+
const x = vector.x;
|
|
79
|
+
vector.x = c * x + s * vector.z;
|
|
80
|
+
vector.z = -s * x + c * vector.z;
|
|
81
|
+
return vector;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function animationYaw(q: Quaternion): number {
|
|
85
|
+
return Math.atan2(2 * (q.w * q.y + q.x * q.z), 1 - 2 * (q.y * q.y + q.z * q.z));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Borrowed output and interpolants are allocated once, then sampled over the fixed interval. */
|
|
89
|
+
export class AnimationRootMotion {
|
|
90
|
+
readonly node: Object3D;
|
|
91
|
+
readonly body: Object3D;
|
|
92
|
+
readonly proposal = { translation: new Vector3(), yaw: 0 };
|
|
93
|
+
#samples: readonly IRootSample[];
|
|
94
|
+
readonly #rotation = new Quaternion();
|
|
95
|
+
readonly #identity = new Matrix4();
|
|
96
|
+
readonly #local = new Vector3();
|
|
97
|
+
readonly #first = new Vector3();
|
|
98
|
+
readonly #last = new Vector3();
|
|
99
|
+
readonly #cycle = new Vector3();
|
|
100
|
+
#bufferBytes = 0;
|
|
101
|
+
#buffers = 0;
|
|
102
|
+
|
|
103
|
+
constructor(
|
|
104
|
+
root: Object3D,
|
|
105
|
+
sources: readonly AnimationClip[],
|
|
106
|
+
options: IAnimationRootMotionOptions,
|
|
107
|
+
) {
|
|
108
|
+
if (root === options.body)
|
|
109
|
+
throw new Error("AnimationComposer: use a separate rig root below the character body.");
|
|
110
|
+
const matches: Object3D[] = [];
|
|
111
|
+
root.traverse((node) => {
|
|
112
|
+
if (node.name === options.bone) matches.push(node);
|
|
113
|
+
});
|
|
114
|
+
if (matches.length !== 1)
|
|
115
|
+
throw new Error(
|
|
116
|
+
`AnimationComposer: root-motion bone '${options.bone}' is missing or ambiguous.`,
|
|
117
|
+
);
|
|
118
|
+
this.node = matches[0] as Object3D;
|
|
119
|
+
this.body = options.body;
|
|
120
|
+
if ((this.node.parent as Bone | null)?.isBone === true)
|
|
121
|
+
throw new Error(
|
|
122
|
+
"AnimationComposer: root-motion bone must be the skeleton root, with no animated bone ancestor.",
|
|
123
|
+
);
|
|
124
|
+
let ancestor: Object3D | null = root.parent;
|
|
125
|
+
while (ancestor !== null && ancestor !== this.body) ancestor = ancestor.parent;
|
|
126
|
+
if (ancestor === null)
|
|
127
|
+
throw new Error(
|
|
128
|
+
"AnimationComposer: rig root must be a strict descendant of the character body.",
|
|
129
|
+
);
|
|
130
|
+
const ancestors = new Set<string>();
|
|
131
|
+
for (let node = this.node.parent; node !== null; node = node.parent) ancestors.add(node.uuid);
|
|
132
|
+
this.validateSpace();
|
|
133
|
+
this.#samples = sources.map((source) => {
|
|
134
|
+
const clip = canonicalAnimationClip(root, source);
|
|
135
|
+
if (
|
|
136
|
+
clip.tracks.some((track) => ancestors.has(track.name.slice(0, track.name.lastIndexOf("."))))
|
|
137
|
+
)
|
|
138
|
+
throw new Error(
|
|
139
|
+
"AnimationComposer: root-motion ancestors and character body must not have animation tracks.",
|
|
140
|
+
);
|
|
141
|
+
const translation = clip.tracks.find((track) => track.name === `${this.node.uuid}.position`);
|
|
142
|
+
const rotation = clip.tracks.find((track) => track.name === `${this.node.uuid}.quaternion`);
|
|
143
|
+
if (translation === undefined && rotation === undefined)
|
|
144
|
+
throw new Error(
|
|
145
|
+
`AnimationComposer: '${clip.name}' has no named root-motion track for '${options.bone}'.`,
|
|
146
|
+
);
|
|
147
|
+
const position = translation === undefined ? undefined : interpolant(translation, 3);
|
|
148
|
+
let yaw: Interpolant | undefined;
|
|
149
|
+
if (rotation !== undefined) {
|
|
150
|
+
if (rotation.getInterpolation() !== InterpolateLinear)
|
|
151
|
+
throw new Error(
|
|
152
|
+
`AnimationComposer: root track '${rotation.name}' requires linear interpolation.`,
|
|
153
|
+
);
|
|
154
|
+
const values: number[] = [];
|
|
155
|
+
let previous = 0;
|
|
156
|
+
for (let i = 0; i < rotation.values.length; i += 4) {
|
|
157
|
+
this.#rotation.fromArray(rotation.values, i);
|
|
158
|
+
if (Math.abs(this.#rotation.x) + Math.abs(this.#rotation.z) > 1e-5)
|
|
159
|
+
throw new Error(
|
|
160
|
+
`AnimationComposer: '${rotation.name}' root rotation must be yaw-only.`,
|
|
161
|
+
);
|
|
162
|
+
const angle = animationYaw(this.#rotation);
|
|
163
|
+
previous = values.length === 0 ? angle : previous + wrappedYaw(angle - previous);
|
|
164
|
+
values.push(previous);
|
|
165
|
+
}
|
|
166
|
+
yaw = interpolant(new NumberKeyframeTrack(rotation.name, rotation.times, values), 1);
|
|
167
|
+
}
|
|
168
|
+
const cycle = new Vector3();
|
|
169
|
+
const start = new Vector3();
|
|
170
|
+
if (position !== undefined) {
|
|
171
|
+
start.fromArray(position.evaluate(0));
|
|
172
|
+
cycle.fromArray(position.evaluate(clip.duration)).sub(start);
|
|
173
|
+
}
|
|
174
|
+
const startYaw = yaw?.evaluate(0)[0] ?? 0;
|
|
175
|
+
const cycleYaw = (yaw?.evaluate(clip.duration)[0] ?? 0) - startYaw;
|
|
176
|
+
return { duration: clip.duration, position, yaw, cycle, cycleYaw, start, startYaw };
|
|
177
|
+
});
|
|
178
|
+
const buffers = new Set<ArrayBufferView>();
|
|
179
|
+
for (const sample of this.#samples)
|
|
180
|
+
for (const item of [sample.position, sample.yaw]) {
|
|
181
|
+
if (item === undefined) continue;
|
|
182
|
+
for (const values of [item.parameterPositions, item.sampleValues, item.resultBuffer]) {
|
|
183
|
+
if (ArrayBuffer.isView(values)) buffers.add(values);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
this.#buffers = buffers.size;
|
|
187
|
+
for (const values of buffers) this.#bufferBytes += values.byteLength;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get buffers() {
|
|
191
|
+
return this.#buffers;
|
|
192
|
+
}
|
|
193
|
+
get bufferBytes() {
|
|
194
|
+
return this.#bufferBytes;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
validateSpace(): void {
|
|
198
|
+
if (this.body.parent !== null) {
|
|
199
|
+
this.body.parent.updateWorldMatrix(true, false);
|
|
200
|
+
if (!this.body.parent.matrixWorld.equals(this.#identity))
|
|
201
|
+
throw new Error(
|
|
202
|
+
"AnimationComposer: character-body parent must be identity; parent transforms are unsupported.",
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const parent = this.node.parent ?? this.node;
|
|
206
|
+
parent.updateWorldMatrix(true, false);
|
|
207
|
+
if (uniformYawScale(parent.matrixWorld) === undefined)
|
|
208
|
+
throw new Error(
|
|
209
|
+
"AnimationComposer: root motion requires positive uniform scale and yaw-only parents; nonuniform/tilted/mirrored transforms are unsupported.",
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
sample(previous: number, next: number, weights: ArrayLike<number>): typeof this.proposal {
|
|
214
|
+
if (previous < 0 || next < previous || !Number.isSafeInteger(Math.floor(next)))
|
|
215
|
+
throw new Error(
|
|
216
|
+
"AnimationComposer: root phase interval exceeds the supported finite clock range.",
|
|
217
|
+
);
|
|
218
|
+
this.proposal.translation.set(0, 0, 0);
|
|
219
|
+
this.proposal.yaw = 0;
|
|
220
|
+
const loops = Math.floor(next) - Math.floor(previous);
|
|
221
|
+
const firstYaw = this.#pose(previous % 1, weights, this.#first);
|
|
222
|
+
const lastYaw = this.#pose(next % 1, weights, this.#last);
|
|
223
|
+
this.#cycle.set(0, 0, 0);
|
|
224
|
+
let cycleYaw = 0;
|
|
225
|
+
for (let i = 0; i < this.#samples.length; i += 1) {
|
|
226
|
+
const weight = weights[i] as number;
|
|
227
|
+
if (weight === 0) continue;
|
|
228
|
+
const sample = this.#samples[i] as IRootSample;
|
|
229
|
+
this.#cycle.addScaledVector(sample.cycle, weight);
|
|
230
|
+
cycleYaw += weight * sample.cycleYaw;
|
|
231
|
+
}
|
|
232
|
+
if (loops === 0) {
|
|
233
|
+
rotateYaw(this.proposal.translation.copy(this.#last).sub(this.#first), -firstYaw);
|
|
234
|
+
} else {
|
|
235
|
+
rotateYaw(this.proposal.translation.copy(this.#cycle).sub(this.#first), -firstYaw);
|
|
236
|
+
const full = loops - 1;
|
|
237
|
+
const turn = wrappedYaw(cycleYaw);
|
|
238
|
+
const denominator = Math.sin(turn / 2);
|
|
239
|
+
const factor = denominator === 0 ? full : Math.sin((full * turn) / 2) / denominator;
|
|
240
|
+
this.#local.copy(this.#cycle);
|
|
241
|
+
this.#local.x *= factor;
|
|
242
|
+
this.#local.z *= factor;
|
|
243
|
+
this.#local.y *= full;
|
|
244
|
+
rotateYaw(this.#local, cycleYaw - firstYaw + ((full - 1) * turn) / 2);
|
|
245
|
+
this.proposal.translation.add(this.#local);
|
|
246
|
+
rotateYaw(this.#last, loops * cycleYaw - firstYaw);
|
|
247
|
+
this.proposal.translation.add(this.#last);
|
|
248
|
+
}
|
|
249
|
+
this.proposal.yaw = lastYaw - firstYaw + loops * cycleYaw;
|
|
250
|
+
const parent = this.node.parent ?? this.node;
|
|
251
|
+
parent.getWorldQuaternion(this.#rotation);
|
|
252
|
+
const scale = uniformYawScale(parent.matrixWorld) as number;
|
|
253
|
+
this.proposal.translation.multiplyScalar(scale).applyQuaternion(this.#rotation);
|
|
254
|
+
animationFinite(this.proposal.translation.x, "root delta.x");
|
|
255
|
+
animationFinite(this.proposal.translation.y, "root delta.y");
|
|
256
|
+
animationFinite(this.proposal.translation.z, "root delta.z");
|
|
257
|
+
animationFinite(this.proposal.yaw, "root delta.yaw");
|
|
258
|
+
return this.proposal;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#pose(phase: number, weights: ArrayLike<number>, position: Vector3): number {
|
|
262
|
+
position.set(0, 0, 0);
|
|
263
|
+
let yaw = 0;
|
|
264
|
+
for (let i = 0; i < this.#samples.length; i += 1) {
|
|
265
|
+
const weight = weights[i] as number;
|
|
266
|
+
if (weight === 0) continue;
|
|
267
|
+
const sample = this.#samples[i] as IRootSample;
|
|
268
|
+
const time = phase * sample.duration;
|
|
269
|
+
if (sample.position !== undefined) {
|
|
270
|
+
this.#local.fromArray(sample.position.evaluate(time)).sub(sample.start);
|
|
271
|
+
position.addScaledVector(this.#local, weight);
|
|
272
|
+
}
|
|
273
|
+
yaw += weight * ((sample.yaw?.evaluate(time)[0] ?? 0) - sample.startYaw);
|
|
274
|
+
}
|
|
275
|
+
return yaw;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
dispose(): void {
|
|
279
|
+
this.#samples = [];
|
|
280
|
+
this.#buffers = 0;
|
|
281
|
+
this.#bufferBytes = 0;
|
|
282
|
+
}
|
|
283
|
+
}
|