@zephyr3d/scene 0.9.6 → 0.9.8
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/dist/animation/animationset.js +52 -55
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +92 -32
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +71 -27
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +4 -3
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/skeleton.js +7 -10
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/app/engine.js +3 -9
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +47 -16
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +3 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +346 -7
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +7 -3
- package/dist/avatar/wardrobe.js.map +1 -1
- package/dist/camera/camera.js +240 -34
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1350 -622
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +23 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +178 -23
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +4 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +2 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +100 -27
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +1 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +276 -65
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -3
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +2 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/mtoon.js +574 -0
- package/dist/material/mtoon.js.map +1 -0
- package/dist/material/pbrblueprint.js +494 -331
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +118 -100
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +45 -15
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +812 -0
- package/dist/material/subsurfaceprofile.js.map +1 -0
- package/dist/material/unlit.js +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/compositor.js +46 -11
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/ssr.js +413 -87
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +1053 -0
- package/dist/posteffect/sss.js.map +1 -0
- package/dist/posteffect/taa.js +61 -60
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +63 -12
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +1 -5
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +2 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +2 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +2 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/lightpass.js +105 -18
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/render_queue.js +51 -8
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +73 -59
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +8 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +481 -95
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +55 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +10 -4
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sky.js +31 -1
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +23 -5
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +4 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -1
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +11 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +21 -3
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +29 -14
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +5 -2
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +5 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +3 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +6 -5
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +4 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +2 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -2
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +4 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +26 -393
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/esm.js +112 -12
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +2 -2
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +19 -10
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +58 -7
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +6 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +229 -0
- package/dist/shadow/shadow_region.js.map +1 -0
- package/dist/shadow/shadowmapper.js +67 -59
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +45 -19
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +8 -8
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +31 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +1 -17
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +66 -98
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +5 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -1
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +249 -54
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +37 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +42 -3
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1112 -646
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +7 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +31 -12
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -1
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +3 -1
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +18 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +5 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +3 -1
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -1
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +6 -0
- package/dist/utility/textures/ltcdata.js.map +1 -0
- package/dist/utility/textures/ltclut.js +61 -0
- package/dist/utility/textures/ltclut.js.map +1 -0
- package/dist/values.js +9 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EPSILON } from './types.js';
|
|
2
2
|
import { buildConstraints, buildSurfaceFaces } from './constraints.js';
|
|
3
|
-
import { simulate, applyAngleLimits, applyResult } from './solver.js';
|
|
3
|
+
import { simulate, applyAngleLimits, applyResult, extractLocalTwist } from './solver.js';
|
|
4
4
|
import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@zephyr3d/base';
|
|
5
5
|
|
|
6
6
|
// High-level orchestrator - SPCRJointDynamicsController API
|
|
@@ -46,6 +46,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
46
46
|
_colliderHandleToIndex = new Map();
|
|
47
47
|
_flatPlaneHandleToIndex = new Map();
|
|
48
48
|
_grabberHandleToIndex = new Map();
|
|
49
|
+
_lastOutputLocalRotations = [];
|
|
49
50
|
_baseSystemScale = 1;
|
|
50
51
|
_currentSystemScale = 1;
|
|
51
52
|
_basePointParentLengths = [];
|
|
@@ -84,8 +85,13 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
84
85
|
this._baseConstraintLengths = this._constraints.map((constraint)=>constraint.length);
|
|
85
86
|
// Flatten bone hierarchy to point list, build parent map
|
|
86
87
|
const allPoints = [];
|
|
88
|
+
const visitedPoints = new Set();
|
|
87
89
|
this._parentMap = new Map(); // child index -> parent index
|
|
88
90
|
const walk = (node)=>{
|
|
91
|
+
if (visitedPoints.has(node.index)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
visitedPoints.add(node.index);
|
|
89
95
|
allPoints.push(node);
|
|
90
96
|
for (const c of node.children){
|
|
91
97
|
this._parentMap.set(c.index, node.index);
|
|
@@ -95,6 +101,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
95
101
|
for (const r of rootPoints){
|
|
96
102
|
walk(r);
|
|
97
103
|
}
|
|
104
|
+
allPoints.sort((a, b)=>a.index - b.index);
|
|
98
105
|
this._allPoints = allPoints;
|
|
99
106
|
this._maxPointDepth = allPoints.length > 0 ? Math.max(...allPoints.map((p)=>p.depth)) : 0;
|
|
100
107
|
// Compute boneAxis from transforms: local-space direction to first child
|
|
@@ -119,6 +126,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
119
126
|
this._basePointParentLengths = this._pointsR.map((point)=>point.parentLength);
|
|
120
127
|
this._pointsRW = allPoints.map(()=>this._createPointRW());
|
|
121
128
|
this._positionsToTransform = new Array(allPoints.length).fill(Vector3.zero());
|
|
129
|
+
this._clearOutputTransformCache();
|
|
122
130
|
// Initialize colliders
|
|
123
131
|
this._collidersR = colliders.map((c)=>c.r);
|
|
124
132
|
this._collidersRW = colliders.map((c)=>this._createColliderRW(c.transform));
|
|
@@ -180,9 +188,11 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
180
188
|
}
|
|
181
189
|
const blendRatio = this._computeBlendRatio();
|
|
182
190
|
this._updateScaleDependentParameters();
|
|
191
|
+
const rootSlideLimit = this._config.rootSlideLimit < 0 ? -1 : this._config.rootSlideLimit * this._currentSystemScale;
|
|
183
192
|
// Capture current transforms
|
|
184
193
|
const rootPos = this._rootTransform.getWorldPosition();
|
|
185
194
|
const rootRot = this._rootTransform.getWorldRotation();
|
|
195
|
+
const inputLocalRotations = this._getInputLocalRotations();
|
|
186
196
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
187
197
|
this._pointsRW[i].positionPreviousTransform = this._pointsRW[i].positionCurrentTransform.clone();
|
|
188
198
|
this._pointsRW[i].positionCurrentTransform = this._pointTransforms[i].getWorldPosition();
|
|
@@ -206,7 +216,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
206
216
|
subSteps: this._config.subSteps,
|
|
207
217
|
rootPosition: rootPos,
|
|
208
218
|
previousRootPosition: this._previousRootPosition,
|
|
209
|
-
rootSlideLimit
|
|
219
|
+
rootSlideLimit,
|
|
210
220
|
rootRotation: rootRot,
|
|
211
221
|
previousRootRotation: this._previousRootRotation,
|
|
212
222
|
rootRotateLimit: this._config.rootRotateLimit,
|
|
@@ -232,12 +242,14 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
232
242
|
}
|
|
233
243
|
// Apply results
|
|
234
244
|
const transformRots = this._pointTransforms.map((t)=>t.getWorldRotation());
|
|
235
|
-
const transformLocalRots =
|
|
236
|
-
const
|
|
245
|
+
const transformLocalRots = inputLocalRotations;
|
|
246
|
+
const sceneParentRots = this._pointTransforms.map((t)=>this._getSceneParentWorldRotation(t));
|
|
247
|
+
const outputs = applyResult(this._pointsR, this._pointsRW, this._positionsToTransform, blendRatio, transformRots, transformLocalRots, this._config.preserveTwist, sceneParentRots);
|
|
237
248
|
for(let i = 0; i < outputs.length; i++){
|
|
238
249
|
this._pointTransforms[i].setWorldPosition(outputs[i].position);
|
|
239
250
|
this._pointTransforms[i].setWorldRotation(outputs[i].rotation);
|
|
240
251
|
}
|
|
252
|
+
this._lastOutputLocalRotations = this._pointTransforms.map((t)=>t.getLocalRotation());
|
|
241
253
|
this._previousRootPosition = rootPos;
|
|
242
254
|
this._previousRootRotation = rootRot;
|
|
243
255
|
}
|
|
@@ -247,8 +259,9 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
247
259
|
* output back to the transforms.
|
|
248
260
|
*/ getResults() {
|
|
249
261
|
const transformRots = this._pointTransforms.map((t)=>t.getWorldRotation());
|
|
250
|
-
const transformLocalRots = this.
|
|
251
|
-
const
|
|
262
|
+
const transformLocalRots = this._getInputLocalRotations();
|
|
263
|
+
const sceneParentRots = this._pointTransforms.map((t)=>this._getSceneParentWorldRotation(t));
|
|
264
|
+
const outputs = applyResult(this._pointsR, this._pointsRW, this._positionsToTransform, this._config.blendRatio, transformRots, transformLocalRots, this._config.preserveTwist, sceneParentRots);
|
|
252
265
|
return outputs.map((o)=>({
|
|
253
266
|
position: o.position,
|
|
254
267
|
rotation: o.rotation
|
|
@@ -299,6 +312,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
299
312
|
* @param config - Complete controller configuration to apply.
|
|
300
313
|
*/ setConfig(config) {
|
|
301
314
|
this._config = this._sanitizeControllerConfig(this._cloneControllerConfig(config));
|
|
315
|
+
this._clearOutputTransformCache();
|
|
302
316
|
this._refreshCachedSimulationConfig();
|
|
303
317
|
}
|
|
304
318
|
/**
|
|
@@ -362,6 +376,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
362
376
|
}
|
|
363
377
|
if (typeof config.preserveTwist === 'boolean') {
|
|
364
378
|
this._config.preserveTwist = config.preserveTwist;
|
|
379
|
+
this._clearOutputTransformCache();
|
|
365
380
|
}
|
|
366
381
|
if (config.angleLimitConfig) {
|
|
367
382
|
if (typeof config.angleLimitConfig.angleLimit === 'number') {
|
|
@@ -438,28 +453,62 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
438
453
|
}
|
|
439
454
|
}
|
|
440
455
|
/**
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
* next simulation step.
|
|
456
|
+
* Resets all physics state after teleportation.
|
|
457
|
+
* @deprecated Use {@link JointDynamicsSystemController.reset}. This method is kept as a compatibility alias.
|
|
444
458
|
*/ warp() {
|
|
445
|
-
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
this._previousRootPosition = this._rootTransform.getWorldPosition();
|
|
449
|
-
this._previousRootRotation = this._rootTransform.getWorldRotation();
|
|
459
|
+
this.reset();
|
|
450
460
|
}
|
|
451
461
|
/**
|
|
452
462
|
* Resets all physics state.
|
|
453
|
-
*
|
|
454
|
-
*
|
|
463
|
+
* Simulated points, transform history, root-motion history, grab state and wave phase are
|
|
464
|
+
* snapped back to the current scene transforms. Runtime configuration and fixed/released
|
|
465
|
+
* point weights are preserved.
|
|
455
466
|
*/ reset() {
|
|
456
467
|
for(let i = 0; i < this._pointsRW.length; i++){
|
|
457
468
|
const pos = this._pointTransforms[i].getWorldPosition();
|
|
458
|
-
this._pointsRW[i]
|
|
459
|
-
|
|
460
|
-
|
|
469
|
+
const ptRW = this._pointsRW[i];
|
|
470
|
+
ptRW.positionCurrent = pos.clone();
|
|
471
|
+
ptRW.positionPrevious = pos.clone();
|
|
472
|
+
ptRW.positionCurrentTransform = pos.clone();
|
|
473
|
+
ptRW.positionPreviousTransform = pos.clone();
|
|
474
|
+
ptRW.positionToTransform = pos.clone();
|
|
475
|
+
this._positionsToTransform[i] = pos.clone();
|
|
476
|
+
ptRW.fakeWindDirection = Vector3.axisPZ();
|
|
477
|
+
ptRW.grabberIndex = -1;
|
|
478
|
+
ptRW.grabberDistance = 0;
|
|
479
|
+
ptRW.friction = 0;
|
|
480
|
+
}
|
|
481
|
+
for(let i = 0; i < this._pointsRW.length; i++){
|
|
482
|
+
const parent = this._pointsR[i]?.parent ?? -1;
|
|
483
|
+
if (parent !== -1) {
|
|
484
|
+
const direction = Vector3.sub(this._pointsRW[i].positionCurrent, this._pointsRW[parent].positionCurrent);
|
|
485
|
+
this._pointsRW[i].directionPrevious = direction.magnitudeSq > EPSILON ? direction : Vector3.axisPZ();
|
|
486
|
+
} else {
|
|
487
|
+
this._pointsRW[i].directionPrevious = Vector3.axisPZ();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
for(let i = 0; i < this._collidersRW.length; i++){
|
|
491
|
+
const transform = this._colliderTransforms[i];
|
|
492
|
+
const pos = transform.getWorldPosition();
|
|
493
|
+
const rot = transform.getWorldRotation();
|
|
494
|
+
const scale = transform.getWorldScale();
|
|
495
|
+
const colRW = this._collidersRW[i];
|
|
496
|
+
colRW.positionCurrentTransform = pos.clone();
|
|
497
|
+
colRW.positionPreviousTransform = pos.clone();
|
|
498
|
+
colRW.directionCurrentTransform = rot.clone();
|
|
499
|
+
colRW.directionPreviousTransform = rot.clone();
|
|
500
|
+
colRW.worldScale = scale.clone();
|
|
501
|
+
colRW.worldToLocal = Matrix4x4.compose(scale, rot, pos).inplaceInvertAffine();
|
|
502
|
+
}
|
|
503
|
+
for(let i = 0; i < this._grabbersRW.length; i++){
|
|
504
|
+
this._grabbersRW[i].position = this._grabberTransforms[i].getWorldPosition();
|
|
505
|
+
}
|
|
506
|
+
if (this._rootTransform) {
|
|
507
|
+
this._previousRootPosition = this._rootTransform.getWorldPosition();
|
|
508
|
+
this._previousRootRotation = this._rootTransform.getWorldRotation();
|
|
461
509
|
}
|
|
462
510
|
this._fakeWaveCounter = 0;
|
|
511
|
+
this._clearOutputTransformCache();
|
|
463
512
|
}
|
|
464
513
|
/**
|
|
465
514
|
* Releases a fixed point so it becomes dynamic, for example when cloth is detached.
|
|
@@ -862,6 +911,28 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
862
911
|
const scale = this._rootTransform.getWorldScale();
|
|
863
912
|
return Math.max((Math.abs(scale.x) + Math.abs(scale.y) + Math.abs(scale.z)) / 3, EPSILON);
|
|
864
913
|
}
|
|
914
|
+
_getSceneParentWorldRotation(transform) {
|
|
915
|
+
const parent = transform.node?.parent;
|
|
916
|
+
if (!parent) {
|
|
917
|
+
return undefined;
|
|
918
|
+
}
|
|
919
|
+
const rotation = new Quaternion();
|
|
920
|
+
parent.worldMatrix.decompose(null, rotation, null);
|
|
921
|
+
return rotation;
|
|
922
|
+
}
|
|
923
|
+
_clearOutputTransformCache() {
|
|
924
|
+
this._lastOutputLocalRotations = [];
|
|
925
|
+
}
|
|
926
|
+
_getInputLocalRotations() {
|
|
927
|
+
return this._pointTransforms.map((transform, index)=>{
|
|
928
|
+
const localRotation = transform.getLocalRotation();
|
|
929
|
+
const lastOutput = this._lastOutputLocalRotations[index];
|
|
930
|
+
if (lastOutput && Quaternion.angleBetween(localRotation, lastOutput) <= EPSILON && this._pointsR[index]) {
|
|
931
|
+
return this._pointsR[index].initialLocalRotation.clone();
|
|
932
|
+
}
|
|
933
|
+
return localRotation;
|
|
934
|
+
});
|
|
935
|
+
}
|
|
865
936
|
_updateScaleDependentParameters(force = false) {
|
|
866
937
|
const systemScale = this._getSystemUniformScale();
|
|
867
938
|
const scaleChanged = Math.abs(systemScale - this._currentSystemScale) > EPSILON;
|
|
@@ -878,14 +949,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
878
949
|
}
|
|
879
950
|
this._refreshPointParameters();
|
|
880
951
|
if (scaleChanged) {
|
|
881
|
-
|
|
882
|
-
const pos = this._pointTransforms[i].getWorldPosition();
|
|
883
|
-
this._pointsRW[i].positionCurrent = pos.clone();
|
|
884
|
-
this._pointsRW[i].positionPrevious = pos.clone();
|
|
885
|
-
this._pointsRW[i].positionCurrentTransform = pos.clone();
|
|
886
|
-
this._pointsRW[i].positionPreviousTransform = pos.clone();
|
|
887
|
-
}
|
|
888
|
-
this.warp();
|
|
952
|
+
this.reset();
|
|
889
953
|
}
|
|
890
954
|
}
|
|
891
955
|
_refreshPointParameters() {
|
|
@@ -945,11 +1009,7 @@ import { Vector3, Quaternion, Matrix4x4, clamp01, InterpolatorScalar } from '@ze
|
|
|
945
1009
|
boneAxis,
|
|
946
1010
|
initialLocalScale: initLocalScale,
|
|
947
1011
|
initialLocalRotation: initLocalRot,
|
|
948
|
-
initialLocalTwist: (
|
|
949
|
-
const tw = new Quaternion();
|
|
950
|
-
initLocalRot.decomposeSwingTwist(boneAxis, undefined, tw);
|
|
951
|
-
return tw;
|
|
952
|
-
})(),
|
|
1012
|
+
initialLocalTwist: extractLocalTwist(initLocalRot, boneAxis),
|
|
953
1013
|
initialLocalPosition: initLocalPos
|
|
954
1014
|
};
|
|
955
1015
|
this._applyConfigToPoint(point, node);
|