@onerjs/core 8.47.9 → 8.48.1
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/Debug/physicsViewer.d.ts +4 -8
- package/Debug/physicsViewer.js +41 -83
- package/Debug/physicsViewer.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +4 -0
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +101 -62
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js +39 -25
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.js.map +1 -1
- package/Rendering/depthRenderer.js +6 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/package.json +1 -1
package/Debug/physicsViewer.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { PhysicsImpostor } from "../Physics/v1/physicsImpostor.js";
|
|
|
9
9
|
import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer.js";
|
|
10
10
|
import { type PhysicsBody } from "../Physics/v2/physicsBody.js";
|
|
11
11
|
import { type PhysicsConstraint } from "../Physics/v2/physicsConstraint.js";
|
|
12
|
+
import { TransformNode } from "../Meshes/transformNode.js";
|
|
12
13
|
import "../Physics/joinedPhysicsEngineComponent.js";
|
|
13
14
|
/**
|
|
14
15
|
* Used to show the physics impostor around the specific mesh
|
|
@@ -29,7 +30,7 @@ export declare class PhysicsViewer {
|
|
|
29
30
|
/** @internal */
|
|
30
31
|
protected _inertiaMeshes: Array<Nullable<AbstractMesh>>;
|
|
31
32
|
/** @internal */
|
|
32
|
-
protected _constraintMeshes: Array<Nullable<Array<
|
|
33
|
+
protected _constraintMeshes: Array<Nullable<Array<TransformNode>>>;
|
|
33
34
|
/** @internal */
|
|
34
35
|
protected _scene: Nullable<Scene>;
|
|
35
36
|
/** @internal */
|
|
@@ -56,11 +57,6 @@ export declare class PhysicsViewer {
|
|
|
56
57
|
private _debugMeshMeshes;
|
|
57
58
|
private _constraintAxesSize;
|
|
58
59
|
private _constraintAngularSize;
|
|
59
|
-
private _localMatrixCache;
|
|
60
|
-
private _tempVectorCache;
|
|
61
|
-
private _inertiaMatrixCache;
|
|
62
|
-
private _transformMatrixCache;
|
|
63
|
-
private _finalMatrixCache;
|
|
64
60
|
/**
|
|
65
61
|
* Creates a new PhysicsViewer
|
|
66
62
|
* @param scene defines the hosting scene
|
|
@@ -101,7 +97,7 @@ export declare class PhysicsViewer {
|
|
|
101
97
|
* @param scaling
|
|
102
98
|
*/
|
|
103
99
|
protected _makeScalingUnitInPlace(scaling: Vector3): void;
|
|
104
|
-
protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh:
|
|
100
|
+
protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: TransformNode): void;
|
|
105
101
|
/**
|
|
106
102
|
* Renders a specified physic impostor
|
|
107
103
|
* @param impostor defines the impostor to render
|
|
@@ -130,7 +126,7 @@ export declare class PhysicsViewer {
|
|
|
130
126
|
* @param constraint the physics constraint to show
|
|
131
127
|
* @returns the debug mesh, or null if the constraint is already shown
|
|
132
128
|
*/
|
|
133
|
-
showConstraint(constraint: PhysicsConstraint): Nullable<
|
|
129
|
+
showConstraint(constraint: PhysicsConstraint): Nullable<TransformNode>;
|
|
134
130
|
/**
|
|
135
131
|
* Hides an impostor from the scene.
|
|
136
132
|
* @param impostor - The impostor to hide.
|
package/Debug/physicsViewer.js
CHANGED
|
@@ -55,11 +55,6 @@ export class PhysicsViewer {
|
|
|
55
55
|
this._debugMeshMeshes = new Array();
|
|
56
56
|
this._constraintAxesSize = 0.4;
|
|
57
57
|
this._constraintAngularSize = 0.4;
|
|
58
|
-
this._localMatrixCache = Matrix.Identity();
|
|
59
|
-
this._tempVectorCache = Vector3.Zero();
|
|
60
|
-
this._inertiaMatrixCache = Matrix.Identity();
|
|
61
|
-
this._transformMatrixCache = Matrix.Identity();
|
|
62
|
-
this._finalMatrixCache = Matrix.Identity();
|
|
63
58
|
this._scene = scene || EngineStore.LastCreatedScene;
|
|
64
59
|
if (!this._scene) {
|
|
65
60
|
return;
|
|
@@ -161,30 +156,33 @@ export class PhysicsViewer {
|
|
|
161
156
|
}
|
|
162
157
|
}
|
|
163
158
|
_updateDebugInertia(body, inertiaMesh) {
|
|
159
|
+
const inertiaMatrixRef = Matrix.Identity();
|
|
160
|
+
const transformMatrixRef = Matrix.Identity();
|
|
161
|
+
const finalMatrixRef = Matrix.Identity();
|
|
164
162
|
if (body._pluginDataInstances.length) {
|
|
165
163
|
const inertiaAsMesh = inertiaMesh;
|
|
166
164
|
const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData;
|
|
167
165
|
const bodyTransformMatrixData = body.transformNode._thinInstanceDataStorage.matrixData;
|
|
168
166
|
for (let i = 0; i < body._pluginDataInstances.length; i++) {
|
|
169
167
|
const props = body.getMassProperties(i);
|
|
170
|
-
this._getMeshDebugInertiaMatrixToRef(props,
|
|
171
|
-
Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16,
|
|
172
|
-
|
|
173
|
-
|
|
168
|
+
this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);
|
|
169
|
+
Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);
|
|
170
|
+
inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);
|
|
171
|
+
finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);
|
|
174
172
|
}
|
|
175
173
|
inertiaAsMesh.thinInstanceBufferUpdated("matrix");
|
|
176
174
|
}
|
|
177
175
|
else {
|
|
178
176
|
const props = body.getMassProperties();
|
|
179
|
-
this._getMeshDebugInertiaMatrixToRef(props,
|
|
180
|
-
body.transformNode.rotationQuaternion?.toRotationMatrix(
|
|
181
|
-
|
|
177
|
+
this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);
|
|
178
|
+
body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);
|
|
179
|
+
transformMatrixRef.setTranslation(body.transformNode.position);
|
|
182
180
|
if (body.transformNode.parent) {
|
|
183
181
|
const parentTransform = body.transformNode.parent.computeWorldMatrix(true);
|
|
184
|
-
|
|
182
|
+
transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);
|
|
185
183
|
}
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);
|
|
185
|
+
inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
_updateDebugConstraints() {
|
|
@@ -221,18 +219,11 @@ export class PhysicsViewer {
|
|
|
221
219
|
if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {
|
|
222
220
|
return;
|
|
223
221
|
}
|
|
224
|
-
const
|
|
225
|
-
for (const parentConstraintMesh of
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// Get the direct children of parentOfPair
|
|
230
|
-
const directChildren = parentConstraintMesh.getChildren((node) => node instanceof TransformNode, true);
|
|
231
|
-
const parentCoordSystemNode = directChildren.find((child) => child.name === "parentCoordSystem");
|
|
232
|
-
const childCoordSystemNode = directChildren.find((child) => child.name === "childCoordSystem");
|
|
233
|
-
if (!parentCoordSystemNode || !childCoordSystemNode) {
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
222
|
+
const descendants = parentingMesh.getDescendants(true);
|
|
223
|
+
for (const parentConstraintMesh of descendants) {
|
|
224
|
+
// Get the parent transform
|
|
225
|
+
const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0];
|
|
226
|
+
const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1];
|
|
236
227
|
const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;
|
|
237
228
|
const { childBody, childBodyIndex } = childCoordSystemNode.metadata;
|
|
238
229
|
const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);
|
|
@@ -242,56 +233,13 @@ export class PhysicsViewer {
|
|
|
242
233
|
childTransform.decomposeToTransformNode(childCoordSystemNode);
|
|
243
234
|
this._makeScalingUnitInPlace(childCoordSystemNode.scaling);
|
|
244
235
|
// Create a transform node and set its matrix
|
|
245
|
-
const
|
|
246
|
-
const parentTransformNode = parentTransformNodeChildren[0];
|
|
236
|
+
const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0];
|
|
247
237
|
parentTransformNode.position.copyFrom(pivotA);
|
|
248
|
-
const
|
|
249
|
-
const childTransformNode = childTransformNodeChildren[0];
|
|
238
|
+
const childTransformNode = childCoordSystemNode.getDescendants(true)[0];
|
|
250
239
|
childTransformNode.position.copyFrom(pivotB);
|
|
251
240
|
// Get the transform to align the XYZ axes to the constraint axes
|
|
252
241
|
Quaternion.FromRotationMatrixToRef(Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]), parentTransformNode.rotationQuaternion);
|
|
253
242
|
Quaternion.FromRotationMatrixToRef(Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]), childTransformNode.rotationQuaternion);
|
|
254
|
-
// Sync angular constraint meshes with child body transform
|
|
255
|
-
const allDescendants = parentConstraintMesh.getDescendants(true);
|
|
256
|
-
for (const descendant of allDescendants) {
|
|
257
|
-
if (descendant.metadata?.childBody) {
|
|
258
|
-
const { childBody, axisNumber } = descendant.metadata;
|
|
259
|
-
if (childBody.transformNode) {
|
|
260
|
-
const childWorldMatrix = childBody.transformNode.getWorldMatrix();
|
|
261
|
-
const childWorldMatrixInverse = TmpVectors.Matrix[2];
|
|
262
|
-
childWorldMatrix.invertToRef(childWorldMatrixInverse);
|
|
263
|
-
childWorldMatrixInverse.multiplyToRef(childTransform, this._localMatrixCache);
|
|
264
|
-
const position = TmpVectors.Vector3[0];
|
|
265
|
-
const rotation = TmpVectors.Quaternion[0];
|
|
266
|
-
const scaling = TmpVectors.Vector3[1];
|
|
267
|
-
this._localMatrixCache.decompose(scaling, rotation, position);
|
|
268
|
-
position.addToRef(pivotB, this._tempVectorCache);
|
|
269
|
-
descendant.position.copyFrom(this._tempVectorCache);
|
|
270
|
-
const worldRotation = TmpVectors.Quaternion[1];
|
|
271
|
-
childBody.transformNode.getWorldMatrix().getRotationQuaternionToRef(worldRotation);
|
|
272
|
-
worldRotation.multiplyToRef(descendant.rotationQuaternion, TmpVectors.Quaternion[2]);
|
|
273
|
-
TmpVectors.Quaternion[2].copyFrom(descendant.rotationQuaternion);
|
|
274
|
-
const parentScaling = childBody.transformNode.absoluteScaling;
|
|
275
|
-
switch (axisNumber) {
|
|
276
|
-
case 0:
|
|
277
|
-
descendant.scaling.x = 1 / parentScaling.x;
|
|
278
|
-
descendant.scaling.y = 1 / parentScaling.z;
|
|
279
|
-
descendant.scaling.z = 1 / parentScaling.y;
|
|
280
|
-
break;
|
|
281
|
-
case 1:
|
|
282
|
-
descendant.scaling.x = 1 / parentScaling.z;
|
|
283
|
-
descendant.scaling.y = 1 / parentScaling.y;
|
|
284
|
-
descendant.scaling.z = 1 / parentScaling.x;
|
|
285
|
-
break;
|
|
286
|
-
case 2:
|
|
287
|
-
descendant.scaling.x = 1 / parentScaling.x;
|
|
288
|
-
descendant.scaling.y = 1 / parentScaling.z;
|
|
289
|
-
descendant.scaling.z = 1 / parentScaling.y;
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
243
|
}
|
|
296
244
|
}
|
|
297
245
|
/**
|
|
@@ -533,7 +481,6 @@ export class PhysicsViewer {
|
|
|
533
481
|
return;
|
|
534
482
|
}
|
|
535
483
|
let removed = false;
|
|
536
|
-
const utilityLayerScene = this._utilityLayer.utilityLayerScene;
|
|
537
484
|
for (let i = 0; i < this._numConstraints; i++) {
|
|
538
485
|
if (this._constraints[i] === constraint) {
|
|
539
486
|
const meshes = this._constraintMeshes[i];
|
|
@@ -541,7 +488,6 @@ export class PhysicsViewer {
|
|
|
541
488
|
continue;
|
|
542
489
|
}
|
|
543
490
|
for (const mesh of meshes) {
|
|
544
|
-
utilityLayerScene.removeMesh(mesh);
|
|
545
491
|
mesh.dispose();
|
|
546
492
|
}
|
|
547
493
|
this._constraints.splice(i, 1);
|
|
@@ -809,25 +755,40 @@ export class PhysicsViewer {
|
|
|
809
755
|
return matrix.copyFrom(tnode.getWorldMatrix());
|
|
810
756
|
}
|
|
811
757
|
}
|
|
812
|
-
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber,
|
|
758
|
+
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber, parent, scene) {
|
|
813
759
|
const arcAngle = (maxLimit - minLimit) / (Math.PI * 2);
|
|
814
760
|
const mesh = MeshBuilder.CreateCylinder("ConstraintCylinder", { height: 0.0001, diameter: 3 * this._constraintAngularSize, arc: arcAngle }, scene);
|
|
761
|
+
const root = new TransformNode("angular_root", scene);
|
|
762
|
+
root.metadata = { bodyNode: parent };
|
|
815
763
|
mesh.material = this._getDebugAxisColoredMaterial(axisNumber, scene);
|
|
816
|
-
|
|
817
|
-
mesh.
|
|
764
|
+
parent.getWorldMatrix().decomposeToTransformNode(root);
|
|
765
|
+
mesh.parent = root;
|
|
766
|
+
const parentScaling = parent.absoluteScaling;
|
|
818
767
|
switch (axisNumber) {
|
|
819
768
|
case 0:
|
|
820
769
|
mesh.rotation.z = Math.PI * 0.5;
|
|
821
770
|
mesh.rotation.x = -minLimit + Math.PI * 0.5;
|
|
771
|
+
// scaling on y,z
|
|
772
|
+
mesh.scaling.x = 1 / parentScaling.x;
|
|
773
|
+
mesh.scaling.y = 1 / parentScaling.z;
|
|
774
|
+
mesh.scaling.z = 1 / parentScaling.y;
|
|
822
775
|
break;
|
|
823
776
|
case 1:
|
|
824
777
|
mesh.rotation.y = Math.PI * 1.5 + minLimit;
|
|
778
|
+
// flip x,z
|
|
779
|
+
mesh.scaling.x = 1 / parentScaling.z;
|
|
780
|
+
mesh.scaling.y = 1 / parentScaling.y;
|
|
781
|
+
mesh.scaling.z = 1 / parentScaling.x;
|
|
825
782
|
break;
|
|
826
783
|
case 2:
|
|
827
784
|
mesh.rotation.x = Math.PI * 0.5;
|
|
785
|
+
// flip z,y
|
|
786
|
+
mesh.scaling.x = 1 / parentScaling.x;
|
|
787
|
+
mesh.scaling.y = 1 / parentScaling.z;
|
|
788
|
+
mesh.scaling.z = 1 / parentScaling.y;
|
|
828
789
|
break;
|
|
829
790
|
}
|
|
830
|
-
return
|
|
791
|
+
return root;
|
|
831
792
|
}
|
|
832
793
|
_createCage(parent, scene) {
|
|
833
794
|
const cage = MeshBuilder.CreateBox("cage", { size: 1 }, scene);
|
|
@@ -864,9 +825,6 @@ export class PhysicsViewer {
|
|
|
864
825
|
// Create a mesh to keep the pair of constraint axes
|
|
865
826
|
const parentOfPair = new TransformNode("parentOfPair", utilityLayerScene);
|
|
866
827
|
parentOfPair.parent = parentingMesh;
|
|
867
|
-
// Create a container for angular constraint meshes within this pair
|
|
868
|
-
const angularConstraintContainer = new TransformNode("angularConstraintContainer", utilityLayerScene);
|
|
869
|
-
angularConstraintContainer.parent = parentOfPair;
|
|
870
828
|
const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;
|
|
871
829
|
// Get the parent transform
|
|
872
830
|
const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);
|
|
@@ -900,6 +858,7 @@ export class PhysicsViewer {
|
|
|
900
858
|
// Create axes for the constraint
|
|
901
859
|
const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);
|
|
902
860
|
parentAxes.xAxis.parent = parentTransformNode;
|
|
861
|
+
// parentAxes.xAxis.isPi
|
|
903
862
|
parentAxes.yAxis.parent = parentTransformNode;
|
|
904
863
|
parentAxes.zAxis.parent = parentTransformNode;
|
|
905
864
|
const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);
|
|
@@ -957,8 +916,7 @@ export class PhysicsViewer {
|
|
|
957
916
|
maxLimit = engine.getAxisMaxLimit(constraint, axis);
|
|
958
917
|
}
|
|
959
918
|
if (axisMode != 2 /* PhysicsConstraintAxisLimitMode.LOCKED */ && constraint.options.pivotB) {
|
|
960
|
-
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody,
|
|
961
|
-
mesh.parent = angularConstraintContainer;
|
|
919
|
+
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody.transformNode, utilityLayerScene);
|
|
962
920
|
mesh.position.copyFrom(constraint.options.pivotB);
|
|
963
921
|
parentedConstraintMeshes.push(mesh);
|
|
964
922
|
}
|