@threenative/core 0.3.3 → 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 +2019 -59
- package/dist/{assets-CYKk2WTu.d.ts → assets-CqvE429w.d.ts} +45 -3
- package/dist/{audio-7i3Xl0l3.d.ts → audio-DIJE5HTr.d.ts} +43 -3
- package/dist/{canvas-layer-C1SnMoJ-.d.ts → canvas-layer-C1-5CviZ.d.ts} +5 -1
- package/dist/{game-D_6r-k4Y.d.ts → game-Bj8G1wmD.d.ts} +242 -17
- package/dist/hot.d.ts +5 -5
- package/dist/index.d.ts +1131 -105
- package/dist/index.js +15201 -4782
- package/dist/model-lod-BDAUYgsS.d.ts +197 -0
- package/dist/playtest.d.ts +6 -4
- package/dist/playtest.js +84 -11
- 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-Cy4qeBOA.d.ts → renderer-9yEo9hPa.d.ts} +676 -21
- package/dist/terrain-jobs-worker.d.ts +2 -0
- package/dist/terrain-jobs-worker.js +130 -0
- package/dist/ui-layer.d.ts +5 -3
- package/dist/ui-layer.js +59 -8
- package/dist/world.d.ts +1596 -17
- package/dist/world.js +17035 -521
- package/gpl/fixtures/make_world_fixture.py +184 -0
- package/gpl/recipes/_common.py +11 -0
- package/gpl/recipes/decimate.py +11 -5
- package/gpl/recipes/export_world.py +699 -0
- package/mcp/blender-server.mjs +61 -4
- package/mcp/blender.mjs +3 -4
- package/mcp/engine-server.mjs +55 -21
- 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 +8246 -389
- package/scripts/apply-three-patch.mjs +123 -41
- 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
- package/dist/gpu-readback-CMklJs6r.d.ts +0 -112
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BufferGeometry,
|
|
3
|
+
type Camera,
|
|
4
|
+
InstancedBufferAttribute,
|
|
5
|
+
InstancedMesh,
|
|
6
|
+
Matrix4,
|
|
7
|
+
Sphere,
|
|
8
|
+
Vector3,
|
|
9
|
+
} from "three";
|
|
10
|
+
import {
|
|
11
|
+
DISCRETE_LOD_DEFAULT_HYSTERESIS,
|
|
12
|
+
type IModelLodController,
|
|
13
|
+
biasedLodDistance,
|
|
14
|
+
conservativeViewDepth,
|
|
15
|
+
lodChainOf,
|
|
16
|
+
registerModelLodController,
|
|
17
|
+
selectLodLevel,
|
|
18
|
+
} from "./model-lod.js";
|
|
19
|
+
|
|
20
|
+
/** Shared with WorldCells: an instanced prop's projected error budget, in raster pixels. */
|
|
21
|
+
export const INSTANCED_LOD_MAX_PIXEL_ERROR = 4;
|
|
22
|
+
|
|
23
|
+
export interface IInstancedLodOptions {
|
|
24
|
+
/** Baked-chain selection is automatic. `false` leaves detail to the caller. */
|
|
25
|
+
readonly autoLod?: false | { readonly maxPixelError?: number; readonly hysteresis?: number };
|
|
26
|
+
/** Authored distance levels win over the baked chain. Missing geometries report once at build. */
|
|
27
|
+
readonly lods?: readonly {
|
|
28
|
+
readonly distance: number;
|
|
29
|
+
readonly geometry: BufferGeometry | undefined;
|
|
30
|
+
}[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Split a broad instance set along its measured longest axis; each leaf owns stable public slots. */
|
|
34
|
+
function spatialPartitions(mesh: InstancedMesh): number[][] {
|
|
35
|
+
const limit = Math.ceil(Math.sqrt(mesh.count));
|
|
36
|
+
const matrices = mesh.instanceMatrix.array;
|
|
37
|
+
const groups: number[][] = [];
|
|
38
|
+
const split = (indices: number[]): void => {
|
|
39
|
+
if (indices.length <= limit) {
|
|
40
|
+
groups.push(indices);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
let axis = 12;
|
|
44
|
+
let extent = -1;
|
|
45
|
+
for (const component of [12, 13, 14]) {
|
|
46
|
+
let min = Number.POSITIVE_INFINITY;
|
|
47
|
+
let max = Number.NEGATIVE_INFINITY;
|
|
48
|
+
for (const index of indices) {
|
|
49
|
+
const value = matrices[index * 16 + component] as number;
|
|
50
|
+
min = Math.min(min, value);
|
|
51
|
+
max = Math.max(max, value);
|
|
52
|
+
}
|
|
53
|
+
if (max - min > extent) {
|
|
54
|
+
extent = max - min;
|
|
55
|
+
axis = component;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
indices.sort(
|
|
59
|
+
(a, b) => (matrices[a * 16 + axis] as number) - (matrices[b * 16 + axis] as number),
|
|
60
|
+
);
|
|
61
|
+
const middle = Math.floor(indices.length / 2);
|
|
62
|
+
split(indices.slice(0, middle));
|
|
63
|
+
split(indices.slice(middle));
|
|
64
|
+
};
|
|
65
|
+
split(Array.from({ length: mesh.count }, (_, index) => index));
|
|
66
|
+
return groups;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Attach to the engine's existing LOD tracker; the returned mesh retains every public instance slot. */
|
|
70
|
+
export function attachInstancedLod(mesh: InstancedMesh, options: IInstancedLodOptions): void {
|
|
71
|
+
if (
|
|
72
|
+
options.autoLod !== undefined &&
|
|
73
|
+
options.autoLod !== false &&
|
|
74
|
+
(options.autoLod === null || typeof options.autoLod !== "object")
|
|
75
|
+
)
|
|
76
|
+
throw new Error("InstancedBatch.autoLod must be false or selection options.");
|
|
77
|
+
const policy = options.autoLod === false ? undefined : options.autoLod;
|
|
78
|
+
const budget = policy?.maxPixelError ?? INSTANCED_LOD_MAX_PIXEL_ERROR;
|
|
79
|
+
const hysteresis = policy?.hysteresis ?? DISCRETE_LOD_DEFAULT_HYSTERESIS;
|
|
80
|
+
if (
|
|
81
|
+
!Number.isFinite(budget) ||
|
|
82
|
+
budget <= 0 ||
|
|
83
|
+
!Number.isFinite(hysteresis) ||
|
|
84
|
+
hysteresis < 0 ||
|
|
85
|
+
hysteresis >= 1
|
|
86
|
+
)
|
|
87
|
+
throw new Error(
|
|
88
|
+
"InstancedBatch.autoLod requires positive maxPixelError and hysteresis in [0, 1).",
|
|
89
|
+
);
|
|
90
|
+
if (options.autoLod === false && options.lods === undefined) return;
|
|
91
|
+
const chain = lodChainOf(mesh.geometry);
|
|
92
|
+
const levels = [mesh.geometry];
|
|
93
|
+
const distances = [0];
|
|
94
|
+
if (options.lods !== undefined) {
|
|
95
|
+
let previous = 0;
|
|
96
|
+
let failed = 0;
|
|
97
|
+
for (const rung of options.lods) {
|
|
98
|
+
if (!Number.isFinite(rung.distance) || rung.distance <= previous)
|
|
99
|
+
throw new Error("InstancedBatch.lods distances must be positive and strictly increasing.");
|
|
100
|
+
previous = rung.distance;
|
|
101
|
+
if (
|
|
102
|
+
rung.geometry === undefined ||
|
|
103
|
+
(rung.geometry.index?.count ?? rung.geometry.getAttribute("position")?.count ?? 0) < 3
|
|
104
|
+
) {
|
|
105
|
+
failed += 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
levels.push(rung.geometry);
|
|
109
|
+
distances.push(rung.distance);
|
|
110
|
+
}
|
|
111
|
+
if (failed > 0)
|
|
112
|
+
console.warn(
|
|
113
|
+
`TN_INSTANCED_LOD_FAILED: '${mesh.name || "unnamed"}' skipped ${failed} unavailable authored levels; ${levels.length} usable levels remain.`,
|
|
114
|
+
);
|
|
115
|
+
} else if (chain !== undefined) {
|
|
116
|
+
levels.splice(0, 1, ...chain.levels);
|
|
117
|
+
}
|
|
118
|
+
if (levels.length < 2) {
|
|
119
|
+
const triangles =
|
|
120
|
+
(mesh.geometry.index?.count ?? mesh.geometry.getAttribute("position")?.count ?? 0) / 3;
|
|
121
|
+
if (options.lods === undefined && triangles * mesh.count > 1_000_000)
|
|
122
|
+
console.warn(
|
|
123
|
+
`TN_INSTANCED_LOD_UNAVAILABLE: '${mesh.name || "unnamed"}' draws ${Math.floor(triangles * mesh.count)} triangles without a baked AutoLOD chain; cook the model or supply lods.`,
|
|
124
|
+
);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const base = levels[0] as BufferGeometry;
|
|
128
|
+
// Preparation may replace a normal/UV attribute after cloning; index-only rungs share its final streams.
|
|
129
|
+
if (options.lods === undefined)
|
|
130
|
+
for (const level of levels)
|
|
131
|
+
for (const [name, attribute] of Object.entries(base.attributes))
|
|
132
|
+
level.setAttribute(name, attribute);
|
|
133
|
+
base.computeBoundingSphere();
|
|
134
|
+
const local = base.boundingSphere?.clone() ?? new Sphere();
|
|
135
|
+
// A zero-range carrier keeps original matrices/indices queryable without drawing them twice.
|
|
136
|
+
// Children draw the partitions; they share the game's geometries and never own their disposal.
|
|
137
|
+
const carrier = new BufferGeometry();
|
|
138
|
+
for (const [name, attribute] of Object.entries(base.attributes))
|
|
139
|
+
carrier.setAttribute(name, attribute);
|
|
140
|
+
carrier.boundingBox = base.boundingBox;
|
|
141
|
+
carrier.boundingSphere = base.boundingSphere;
|
|
142
|
+
carrier.setIndex([]);
|
|
143
|
+
carrier.setDrawRange(0, 0);
|
|
144
|
+
mesh.geometry = carrier;
|
|
145
|
+
const groups = spatialPartitions(mesh);
|
|
146
|
+
const spareCapacity = mesh.instanceMatrix.count - mesh.count;
|
|
147
|
+
const partitionOf = new Uint32Array(mesh.instanceMatrix.count);
|
|
148
|
+
groups.forEach((indices, partition) => {
|
|
149
|
+
for (const index of indices) partitionOf[index] = partition;
|
|
150
|
+
});
|
|
151
|
+
const states = new Uint16Array(mesh.instanceMatrix.count);
|
|
152
|
+
const cameraPosition = new Vector3();
|
|
153
|
+
const matrix = new Matrix4();
|
|
154
|
+
const world = new Matrix4();
|
|
155
|
+
const sphere = new Sphere();
|
|
156
|
+
let children: InstancedMesh[] = [];
|
|
157
|
+
let triangles = 0;
|
|
158
|
+
function ensureChildren(): void {
|
|
159
|
+
if (children.length > 0) return;
|
|
160
|
+
children = groups.flatMap((indices, partition) =>
|
|
161
|
+
levels.map((geometry, index) => {
|
|
162
|
+
const child = new InstancedMesh(
|
|
163
|
+
geometry,
|
|
164
|
+
mesh.material,
|
|
165
|
+
indices.length + (partition === 0 ? spareCapacity : 0),
|
|
166
|
+
);
|
|
167
|
+
child.name = `${mesh.name || "unnamed"}:cell${partition}:lod${index}`;
|
|
168
|
+
child.count = 0;
|
|
169
|
+
child.castShadow = mesh.castShadow;
|
|
170
|
+
child.receiveShadow = mesh.receiveShadow;
|
|
171
|
+
child.layers.mask = mesh.layers.mask;
|
|
172
|
+
// Zero-count partitions stay visible: projection keys must not churn as detail changes.
|
|
173
|
+
child.visible = true;
|
|
174
|
+
child.frustumCulled = true;
|
|
175
|
+
child.raycast = (): void => {}; // Render partitions have no public placement identity.
|
|
176
|
+
mesh.add(child);
|
|
177
|
+
return child;
|
|
178
|
+
}),
|
|
179
|
+
);
|
|
180
|
+
mesh.geometry = carrier;
|
|
181
|
+
}
|
|
182
|
+
const controller: IModelLodController = {
|
|
183
|
+
base,
|
|
184
|
+
get triangles() {
|
|
185
|
+
return triangles;
|
|
186
|
+
},
|
|
187
|
+
update(camera: Camera, viewportHeight: number): void {
|
|
188
|
+
ensureChildren();
|
|
189
|
+
triangles = 0;
|
|
190
|
+
mesh.updateWorldMatrix(true, false);
|
|
191
|
+
camera.getWorldPosition(cameraPosition);
|
|
192
|
+
for (const child of children) {
|
|
193
|
+
child.count = 0;
|
|
194
|
+
child.material = mesh.material;
|
|
195
|
+
child.layers.mask = mesh.layers.mask;
|
|
196
|
+
child.castShadow = mesh.castShadow;
|
|
197
|
+
child.receiveShadow = mesh.receiveShadow;
|
|
198
|
+
child.matrixWorld.copy(mesh.matrixWorld);
|
|
199
|
+
}
|
|
200
|
+
for (let index = 0; index < mesh.count; index += 1) {
|
|
201
|
+
mesh.getMatrixAt(index, matrix);
|
|
202
|
+
world.multiplyMatrices(mesh.matrixWorld, matrix);
|
|
203
|
+
sphere.copy(local).applyMatrix4(world);
|
|
204
|
+
const view = conservativeViewDepth(
|
|
205
|
+
camera,
|
|
206
|
+
sphere.center,
|
|
207
|
+
sphere.radius,
|
|
208
|
+
(camera as Camera & { near?: number }).near ?? 0,
|
|
209
|
+
);
|
|
210
|
+
let level = 0;
|
|
211
|
+
if (options.lods !== undefined) {
|
|
212
|
+
const distance = biasedLodDistance(cameraPosition.distanceTo(sphere.center));
|
|
213
|
+
while (level + 1 < distances.length && distance >= (distances[level + 1] as number))
|
|
214
|
+
level += 1;
|
|
215
|
+
} else if (chain !== undefined) {
|
|
216
|
+
// Project local error at world scale without copying the chain's errors per placement.
|
|
217
|
+
const scale = world.getMaxScaleOnAxis();
|
|
218
|
+
level = selectLodLevel(
|
|
219
|
+
chain.errors,
|
|
220
|
+
states[index] ?? 0,
|
|
221
|
+
budget / Math.max(scale, Number.EPSILON),
|
|
222
|
+
hysteresis,
|
|
223
|
+
[
|
|
224
|
+
{
|
|
225
|
+
camera,
|
|
226
|
+
viewportHeight,
|
|
227
|
+
depth: biasedLodDistance(view.depth),
|
|
228
|
+
degenerate: view.degenerate,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
states[index] = level;
|
|
234
|
+
const child = children[
|
|
235
|
+
(partitionOf[index] as number) * levels.length + level
|
|
236
|
+
] as InstancedMesh;
|
|
237
|
+
child.setMatrixAt(child.count, matrix);
|
|
238
|
+
if (mesh.instanceColor !== null) {
|
|
239
|
+
const color =
|
|
240
|
+
child.instanceColor ??
|
|
241
|
+
new InstancedBufferAttribute(new Float32Array(child.instanceMatrix.count * 3), 3);
|
|
242
|
+
child.instanceColor = color;
|
|
243
|
+
for (let component = 0; component < 3; component += 1)
|
|
244
|
+
color.array[child.count * 3 + component] = mesh.instanceColor.array[
|
|
245
|
+
index * 3 + component
|
|
246
|
+
] as number;
|
|
247
|
+
color.needsUpdate = true;
|
|
248
|
+
}
|
|
249
|
+
child.count += 1;
|
|
250
|
+
}
|
|
251
|
+
for (const child of children) {
|
|
252
|
+
child.instanceMatrix.needsUpdate = true;
|
|
253
|
+
if (child.count > 0) child.computeBoundingSphere();
|
|
254
|
+
triangles +=
|
|
255
|
+
((child.geometry.index?.count ?? child.geometry.getAttribute("position")?.count ?? 0) /
|
|
256
|
+
3) *
|
|
257
|
+
child.count;
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
release(): void {
|
|
261
|
+
for (const child of children) {
|
|
262
|
+
mesh.remove(child);
|
|
263
|
+
child.dispose();
|
|
264
|
+
}
|
|
265
|
+
children = [];
|
|
266
|
+
mesh.geometry = base;
|
|
267
|
+
triangles = 0;
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
const raycast = mesh.raycast.bind(mesh);
|
|
271
|
+
mesh.raycast = (raycaster, intersects): void => {
|
|
272
|
+
const geometry = mesh.geometry;
|
|
273
|
+
mesh.geometry = base;
|
|
274
|
+
try {
|
|
275
|
+
raycast(raycaster, intersects);
|
|
276
|
+
} finally {
|
|
277
|
+
mesh.geometry = geometry;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
registerModelLodController(mesh, controller);
|
|
281
|
+
ensureChildren();
|
|
282
|
+
mesh.addEventListener("dispose", () => controller.release());
|
|
283
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type BufferGeometry,
|
|
3
|
+
type InstancedMesh,
|
|
4
|
+
type Material,
|
|
5
|
+
type Matrix4,
|
|
6
|
+
Object3D,
|
|
7
|
+
Quaternion,
|
|
8
|
+
Vector3,
|
|
9
|
+
} from "three";
|
|
10
|
+
import { type IInstancedLodOptions, attachInstancedLod } from "./instanced-batch-lod.js";
|
|
11
|
+
import { pooledMesh } from "./render/mesh-pool.js";
|
|
12
|
+
|
|
13
|
+
/** The axis a unit-height geometry is laid out along, and the axis {@link InstancedBatch.span} rotates from. */
|
|
14
|
+
const UP = new Vector3(0, 1, 0);
|
|
15
|
+
/** Shorter than this and `from` and `to` are the same point, so there is no direction to face. */
|
|
16
|
+
const MIN_SPAN = 1e-5;
|
|
17
|
+
|
|
18
|
+
/** One instance's transform, in the units the geometry was authored in. */
|
|
19
|
+
export interface IInstancedPlacement {
|
|
20
|
+
/** World position of the instance's origin, as `[x, y, z]`. */
|
|
21
|
+
readonly position: readonly [number, number, number];
|
|
22
|
+
/** Euler rotation in radians, as `[x, y, z]`. Default none. */
|
|
23
|
+
readonly rotation?: readonly [number, number, number];
|
|
24
|
+
/** Per-axis scale as `[x, y, z]`, or one number for all three. Default 1. */
|
|
25
|
+
readonly scale?: readonly [number, number, number] | number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IInstancedBatchOptions extends IInstancedLodOptions {
|
|
29
|
+
/** The shape every instance draws, supplied by the game. */
|
|
30
|
+
readonly geometry: BufferGeometry;
|
|
31
|
+
/**
|
|
32
|
+
* The surface every instance draws with, supplied by the game and used by reference — recolour
|
|
33
|
+
* it and the whole batch recolours. Required: collapsing the draws is the engine's job, what
|
|
34
|
+
* the props look like never is.
|
|
35
|
+
*/
|
|
36
|
+
readonly material: Material;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IInstancedBatchBuildOptions {
|
|
40
|
+
/** Passed straight to the built mesh. Default `false`, as in Three.js. */
|
|
41
|
+
readonly castShadow?: boolean;
|
|
42
|
+
/** Name on the built mesh, so a capture or a scene dump can tell one batch from another. */
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
/** Added to this object when the batch builds. Omit to take the mesh and place it yourself. */
|
|
45
|
+
readonly parent?: Object3D;
|
|
46
|
+
/** Passed straight to the built mesh. Default `false`, as in Three.js. */
|
|
47
|
+
readonly receiveShadow?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* An existing mesh to refill instead of creating one: used when it draws this batch's geometry
|
|
50
|
+
* and material and holds at least this many instances. Reusing matters on WebGPU, where three
|
|
51
|
+
* keys an instanced mesh's compiled node program by the mesh itself — every new InstancedMesh
|
|
52
|
+
* rebuilds its shader, and a streamed world creating hundreds a cell stalls on it.
|
|
53
|
+
*/
|
|
54
|
+
readonly into?: InstancedMesh;
|
|
55
|
+
/** Instance slots to allocate when a new mesh is created, so later refills fit. Default: count. */
|
|
56
|
+
readonly capacity?: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Collapses many copies of one shape into a single draw, without knowing the count up front.
|
|
61
|
+
*
|
|
62
|
+
* `new InstancedMesh(geometry, material, count)` needs `count` before anything has been placed, so
|
|
63
|
+
* a procedural builder either walks its own layout twice, over-allocates and fixes `.count`
|
|
64
|
+
* afterwards, or gathers transforms into an array first. This is that array, with the
|
|
65
|
+
* `Object3D`-scratch-and-`updateMatrix` dance and the post-fill bookkeeping — `instanceMatrix`
|
|
66
|
+
* invalidation and a bounding sphere the culler can use — done once instead of at every site.
|
|
67
|
+
*
|
|
68
|
+
* It decides nothing about how the result looks: the shape, the surface and every transform are
|
|
69
|
+
* the game's, and the built mesh is handed back so the game can keep animating instances by index.
|
|
70
|
+
*/
|
|
71
|
+
export class InstancedBatch {
|
|
72
|
+
readonly geometry: BufferGeometry;
|
|
73
|
+
readonly material: Material;
|
|
74
|
+
readonly #matrices: Matrix4[] = [];
|
|
75
|
+
readonly #scratch = new Object3D();
|
|
76
|
+
readonly #direction = new Vector3();
|
|
77
|
+
readonly #midpoint = new Vector3();
|
|
78
|
+
readonly #rotation = new Quaternion();
|
|
79
|
+
#built = false;
|
|
80
|
+
#mesh: InstancedMesh | undefined;
|
|
81
|
+
readonly #options: IInstancedBatchOptions;
|
|
82
|
+
|
|
83
|
+
constructor(options: IInstancedBatchOptions) {
|
|
84
|
+
if (options === undefined || options === null)
|
|
85
|
+
throw new Error("InstancedBatch requires geometry and material options.");
|
|
86
|
+
if (options.geometry === undefined || options.geometry === null)
|
|
87
|
+
throw new Error("InstancedBatch.geometry is required.");
|
|
88
|
+
if (options.material === undefined || options.material === null)
|
|
89
|
+
throw new Error("InstancedBatch.material is required; the batch never chooses one.");
|
|
90
|
+
this.geometry = options.geometry;
|
|
91
|
+
this.material = options.material;
|
|
92
|
+
this.#options = options;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** How many instances have been placed so far. */
|
|
96
|
+
get count(): number {
|
|
97
|
+
return this.#matrices.length;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Writes every placed matrix into `target` (a mesh's `instanceMatrix.array`), starting at instance
|
|
102
|
+
* `offset`, and returns how many were written. For a caller that packs several batches into one
|
|
103
|
+
* shared instance buffer instead of building a mesh per batch.
|
|
104
|
+
*/
|
|
105
|
+
writeMatrices(target: Float32Array, offset: number): number {
|
|
106
|
+
for (let index = 0; index < this.#matrices.length; index += 1)
|
|
107
|
+
(this.#matrices[index] as Matrix4).toArray(target, (offset + index) * 16);
|
|
108
|
+
return this.#matrices.length;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The built mesh, or `undefined` before {@link build} — never a guess. */
|
|
112
|
+
get mesh(): InstancedMesh | undefined {
|
|
113
|
+
return this.#mesh;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* True when this batch holds element-for-element the matrices of `other`.
|
|
118
|
+
*
|
|
119
|
+
* A refilter rebuilds a cell's batch from the same run in the same order, so "did the answer
|
|
120
|
+
* change" is exactly this question, and comparing is what lets the swap skip a rebuild that came
|
|
121
|
+
* back identical instead of writing, clearing and compacting records the buffer already holds.
|
|
122
|
+
*/
|
|
123
|
+
equals(other: InstancedBatch | undefined): boolean {
|
|
124
|
+
if (other === undefined || this.#matrices.length !== other.#matrices.length) return false;
|
|
125
|
+
for (let index = 0; index < this.#matrices.length; index += 1) {
|
|
126
|
+
const mine = (this.#matrices[index] as Matrix4).elements;
|
|
127
|
+
const theirs = (other.#matrices[index] as Matrix4).elements;
|
|
128
|
+
for (let field = 0; field < 16; field += 1) if (mine[field] !== theirs[field]) return false;
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Records one instance from a matrix the game composed itself, and returns its instance index.
|
|
135
|
+
*
|
|
136
|
+
* The matrix is copied, so the caller may reuse a single scratch `Matrix4` across every call.
|
|
137
|
+
*/
|
|
138
|
+
add(matrix: Matrix4): number {
|
|
139
|
+
this.#assertOpen("add");
|
|
140
|
+
if (matrix === undefined || matrix === null)
|
|
141
|
+
throw new Error("InstancedBatch.add requires a Matrix4.");
|
|
142
|
+
this.#matrices.push(matrix.clone());
|
|
143
|
+
return this.#matrices.length - 1;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Records one instance from position, scale and Euler rotation, and returns its instance index. */
|
|
147
|
+
place(placement: IInstancedPlacement): number {
|
|
148
|
+
this.#assertOpen("place");
|
|
149
|
+
if (placement === undefined || placement === null)
|
|
150
|
+
throw new Error("InstancedBatch.place requires a placement.");
|
|
151
|
+
const [x, y, z] = requireTriple(placement.position, "InstancedBatch.place position");
|
|
152
|
+
const scale = placement.scale ?? 1;
|
|
153
|
+
const [sx, sy, sz] =
|
|
154
|
+
typeof scale === "number"
|
|
155
|
+
? requireScalar(scale)
|
|
156
|
+
: requireTriple(scale, "InstancedBatch.place scale");
|
|
157
|
+
const [rx, ry, rz] =
|
|
158
|
+
placement.rotation === undefined
|
|
159
|
+
? ([0, 0, 0] as const)
|
|
160
|
+
: requireTriple(placement.rotation, "InstancedBatch.place rotation");
|
|
161
|
+
this.#scratch.position.set(x, y, z);
|
|
162
|
+
this.#scratch.quaternion.identity();
|
|
163
|
+
this.#scratch.rotation.set(rx, ry, rz);
|
|
164
|
+
this.#scratch.scale.set(sx, sy, sz);
|
|
165
|
+
this.#scratch.updateMatrix();
|
|
166
|
+
this.#matrices.push(this.#scratch.matrix.clone());
|
|
167
|
+
return this.#matrices.length - 1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Records one instance stretched between two points, and returns its instance index.
|
|
172
|
+
*
|
|
173
|
+
* Chains, tie rods, railing bars, struts and cables are all "from A to B" rather than "at P with
|
|
174
|
+
* rotation R". Deriving the orientation here is what keeps every caller from hand-computing an
|
|
175
|
+
* Euler angle that goes wrong the moment one endpoint moves.
|
|
176
|
+
*/
|
|
177
|
+
span(
|
|
178
|
+
from: readonly [number, number, number],
|
|
179
|
+
to: readonly [number, number, number],
|
|
180
|
+
radius: number,
|
|
181
|
+
): number {
|
|
182
|
+
this.#assertOpen("span");
|
|
183
|
+
const [fx, fy, fz] = requireTriple(from, "InstancedBatch.span from");
|
|
184
|
+
const [tx, ty, tz] = requireTriple(to, "InstancedBatch.span to");
|
|
185
|
+
if (!Number.isFinite(radius) || radius <= 0)
|
|
186
|
+
throw new Error("InstancedBatch.span radius must be a positive finite number.");
|
|
187
|
+
this.#direction.set(tx - fx, ty - fy, tz - fz);
|
|
188
|
+
const length = this.#direction.length();
|
|
189
|
+
// Fail closed rather than skip. `place` and `span` return the index a game animates by, so a
|
|
190
|
+
// silently dropped instance shifts every later index and the caller's own bookkeeping with it.
|
|
191
|
+
if (length < MIN_SPAN)
|
|
192
|
+
throw new Error(
|
|
193
|
+
"InstancedBatch.span endpoints are the same point, so there is no direction.",
|
|
194
|
+
);
|
|
195
|
+
this.#direction.divideScalar(length);
|
|
196
|
+
this.#rotation.setFromUnitVectors(UP, this.#direction);
|
|
197
|
+
this.#midpoint.set((fx + tx) / 2, (fy + ty) / 2, (fz + tz) / 2);
|
|
198
|
+
this.#scratch.position.copy(this.#midpoint);
|
|
199
|
+
this.#scratch.rotation.set(0, 0, 0);
|
|
200
|
+
this.#scratch.quaternion.copy(this.#rotation);
|
|
201
|
+
this.#scratch.scale.set(radius, length, radius);
|
|
202
|
+
this.#scratch.updateMatrix();
|
|
203
|
+
this.#matrices.push(this.#scratch.matrix.clone());
|
|
204
|
+
return this.#matrices.length - 1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Turns everything placed so far into one `InstancedMesh`, and returns it.
|
|
209
|
+
*
|
|
210
|
+
* Returns `undefined` when nothing was placed. That is deliberate: `new InstancedMesh(g, m, 0)`
|
|
211
|
+
* satisfies every type check and draws nothing, so a builder whose layout produced no instances
|
|
212
|
+
* would look identical to one that worked. `undefined` puts that case in the caller's types.
|
|
213
|
+
*/
|
|
214
|
+
build(options: IInstancedBatchBuildOptions = {}): InstancedMesh | undefined {
|
|
215
|
+
if (this.#built)
|
|
216
|
+
throw new Error("InstancedBatch.build was already called; the instance count is fixed.");
|
|
217
|
+
this.#built = true;
|
|
218
|
+
const count = this.#matrices.length;
|
|
219
|
+
if (count === 0) return undefined;
|
|
220
|
+
const into = options.into;
|
|
221
|
+
// A mesh with no `into` comes from the pool, so three keeps the node it built for this uuid the
|
|
222
|
+
// last time anything drew these instances; `visible`/`frustumCulled` are set because a pooled
|
|
223
|
+
// mesh is parked with both off.
|
|
224
|
+
const mesh =
|
|
225
|
+
into !== undefined &&
|
|
226
|
+
into.geometry === this.geometry &&
|
|
227
|
+
into.material === this.material &&
|
|
228
|
+
into.instanceMatrix.count >= count
|
|
229
|
+
? into
|
|
230
|
+
: pooledMesh(this.geometry, this.material, Math.max(count, options.capacity ?? count));
|
|
231
|
+
mesh.count = count;
|
|
232
|
+
mesh.visible = true;
|
|
233
|
+
mesh.frustumCulled = true;
|
|
234
|
+
if (options.name !== undefined) mesh.name = options.name;
|
|
235
|
+
for (let index = 0; index < this.#matrices.length; index += 1) {
|
|
236
|
+
mesh.setMatrixAt(index, this.#matrices[index] as Matrix4);
|
|
237
|
+
}
|
|
238
|
+
mesh.instanceMatrix.needsUpdate = true;
|
|
239
|
+
mesh.castShadow = options.castShadow ?? false;
|
|
240
|
+
mesh.receiveShadow = options.receiveShadow ?? false;
|
|
241
|
+
// Without this the batch is culled against the bounds of a single un-transformed copy, so a
|
|
242
|
+
// spread-out batch pops out of view long before it leaves the frustum.
|
|
243
|
+
mesh.computeBoundingSphere();
|
|
244
|
+
this.#mesh = mesh;
|
|
245
|
+
attachInstancedLod(mesh, this.#options);
|
|
246
|
+
options.parent?.add(mesh);
|
|
247
|
+
return mesh;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
#assertOpen(method: string): void {
|
|
251
|
+
if (this.#built)
|
|
252
|
+
throw new Error(
|
|
253
|
+
`InstancedBatch.${method} after build(): an InstancedMesh has a fixed instance count.`,
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function requireScalar(value: number): readonly [number, number, number] {
|
|
259
|
+
if (!Number.isFinite(value))
|
|
260
|
+
throw new Error("InstancedBatch.place scale must be a finite number.");
|
|
261
|
+
return [value, value, value];
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function requireTriple(
|
|
265
|
+
value: readonly [number, number, number] | undefined,
|
|
266
|
+
label: string,
|
|
267
|
+
): readonly [number, number, number] {
|
|
268
|
+
if (value === undefined || value === null || value.length !== 3)
|
|
269
|
+
throw new Error(`${label} must be a [x, y, z] triple.`);
|
|
270
|
+
const [x, y, z] = value;
|
|
271
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z))
|
|
272
|
+
throw new Error(`${label} must be three finite numbers.`);
|
|
273
|
+
return [x, y, z];
|
|
274
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type Object3D, Quaternion, Vector3 } from "three";
|
|
2
|
+
|
|
3
|
+
interface ITransformHistory {
|
|
4
|
+
readonly object: Object3D;
|
|
5
|
+
readonly previousPosition: Vector3;
|
|
6
|
+
readonly previousRotation: Quaternion;
|
|
7
|
+
readonly currentPosition: Vector3;
|
|
8
|
+
readonly currentRotation: Quaternion;
|
|
9
|
+
readonly savedPosition: Vector3;
|
|
10
|
+
readonly savedRotation: Quaternion;
|
|
11
|
+
references: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Draw-only transforms: simulation and queries always retain the solved tick pose. */
|
|
15
|
+
export class PhysicsInterpolation {
|
|
16
|
+
readonly enabled: boolean;
|
|
17
|
+
readonly overrideSource: "default" | "defineGame";
|
|
18
|
+
readonly #objects = new Map<Object3D, ITransformHistory>();
|
|
19
|
+
#lastReport = "";
|
|
20
|
+
|
|
21
|
+
constructor(enabled?: boolean) {
|
|
22
|
+
if (enabled !== undefined && typeof enabled !== "boolean")
|
|
23
|
+
throw new Error("physicsInterpolation must be a boolean.");
|
|
24
|
+
this.enabled = enabled ?? true;
|
|
25
|
+
this.overrideSource = enabled === undefined ? "default" : "defineGame";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
track(object: Object3D): () => void {
|
|
29
|
+
if (object?.isObject3D !== true) throw new Error("interpolate requires a THREE.Object3D.");
|
|
30
|
+
let history = this.#objects.get(object);
|
|
31
|
+
if (history === undefined) {
|
|
32
|
+
history = {
|
|
33
|
+
object,
|
|
34
|
+
previousPosition: object.position.clone(),
|
|
35
|
+
previousRotation: object.quaternion.clone(),
|
|
36
|
+
currentPosition: object.position.clone(),
|
|
37
|
+
currentRotation: object.quaternion.clone(),
|
|
38
|
+
savedPosition: new Vector3(),
|
|
39
|
+
savedRotation: new Quaternion(),
|
|
40
|
+
references: 0,
|
|
41
|
+
};
|
|
42
|
+
this.#objects.set(object, history);
|
|
43
|
+
}
|
|
44
|
+
history.references += 1;
|
|
45
|
+
let active = true;
|
|
46
|
+
return () => {
|
|
47
|
+
if (!active) return;
|
|
48
|
+
active = false;
|
|
49
|
+
history.references -= 1;
|
|
50
|
+
if (history.references === 0 && this.#objects.get(object) === history)
|
|
51
|
+
this.#objects.delete(object);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
reset(object: Object3D): void {
|
|
56
|
+
const history = this.#objects.get(object);
|
|
57
|
+
if (history === undefined) return;
|
|
58
|
+
history.previousPosition.copy(object.position);
|
|
59
|
+
history.previousRotation.copy(object.quaternion);
|
|
60
|
+
history.currentPosition.copy(object.position);
|
|
61
|
+
history.currentRotation.copy(object.quaternion);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
clear(): void {
|
|
65
|
+
this.#objects.clear();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
beginTick(): void {
|
|
69
|
+
for (const history of this.#objects.values()) {
|
|
70
|
+
history.previousPosition.copy(history.object.position);
|
|
71
|
+
history.previousRotation.copy(history.object.quaternion);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
endTick(): void {
|
|
76
|
+
for (const history of this.#objects.values()) {
|
|
77
|
+
history.currentPosition.copy(history.object.position);
|
|
78
|
+
history.currentRotation.copy(history.object.quaternion);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
render<T>(alpha: number, draw: () => T): T {
|
|
83
|
+
if (!Number.isFinite(alpha) || alpha < 0 || alpha > 1)
|
|
84
|
+
throw new Error("Interpolation alpha must be in [0, 1].");
|
|
85
|
+
const report = JSON.stringify({
|
|
86
|
+
enabled: this.enabled,
|
|
87
|
+
overrideSource: this.overrideSource,
|
|
88
|
+
trackedObjects: this.#objects.size,
|
|
89
|
+
});
|
|
90
|
+
if (report !== this.#lastReport) {
|
|
91
|
+
this.#lastReport = report;
|
|
92
|
+
console.info(`TN_PHYSICS_INTERPOLATION:${report}`);
|
|
93
|
+
}
|
|
94
|
+
if (!this.enabled || alpha === 1) return draw();
|
|
95
|
+
// Retain the exact participants even if Scene.render changes scenes or unregisters a body.
|
|
96
|
+
const histories = [...this.#objects.values()];
|
|
97
|
+
try {
|
|
98
|
+
for (const history of histories) {
|
|
99
|
+
const { object } = history;
|
|
100
|
+
// An edit outside the fixed update is a discontinuity, never a new tick to blend across.
|
|
101
|
+
if (
|
|
102
|
+
!object.position.equals(history.currentPosition) ||
|
|
103
|
+
!object.quaternion.equals(history.currentRotation)
|
|
104
|
+
)
|
|
105
|
+
this.reset(object);
|
|
106
|
+
history.savedPosition.copy(object.position);
|
|
107
|
+
history.savedRotation.copy(object.quaternion);
|
|
108
|
+
object.position.lerpVectors(history.previousPosition, history.currentPosition, alpha);
|
|
109
|
+
object.quaternion.slerpQuaternions(
|
|
110
|
+
history.previousRotation,
|
|
111
|
+
history.currentRotation,
|
|
112
|
+
alpha,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return draw();
|
|
116
|
+
} finally {
|
|
117
|
+
for (const history of histories) {
|
|
118
|
+
if (
|
|
119
|
+
history.object.position.equals(history.savedPosition) &&
|
|
120
|
+
history.object.quaternion.equals(history.savedRotation)
|
|
121
|
+
)
|
|
122
|
+
continue;
|
|
123
|
+
history.object.position.copy(history.savedPosition);
|
|
124
|
+
history.object.quaternion.copy(history.savedRotation);
|
|
125
|
+
history.object.updateMatrix();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|