@onerjs/core 8.47.8 → 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 +34 -67
- 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() {
|
|
@@ -242,47 +240,6 @@ export class PhysicsViewer {
|
|
|
242
240
|
// Get the transform to align the XYZ axes to the constraint axes
|
|
243
241
|
Quaternion.FromRotationMatrixToRef(Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]), parentTransformNode.rotationQuaternion);
|
|
244
242
|
Quaternion.FromRotationMatrixToRef(Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]), childTransformNode.rotationQuaternion);
|
|
245
|
-
// Sync angular constraint meshes with child body transform
|
|
246
|
-
const allDescendants = parentConstraintMesh.getDescendants(true);
|
|
247
|
-
for (const descendant of allDescendants) {
|
|
248
|
-
if (descendant.metadata?.childBody) {
|
|
249
|
-
const { childBody, axisNumber } = descendant.metadata;
|
|
250
|
-
if (childBody.transformNode) {
|
|
251
|
-
const childWorldMatrix = childBody.transformNode.getWorldMatrix();
|
|
252
|
-
const childWorldMatrixInverse = TmpVectors.Matrix[2];
|
|
253
|
-
childWorldMatrix.invertToRef(childWorldMatrixInverse);
|
|
254
|
-
childWorldMatrixInverse.multiplyToRef(childTransform, this._localMatrixCache);
|
|
255
|
-
const position = TmpVectors.Vector3[0];
|
|
256
|
-
const rotation = TmpVectors.Quaternion[0];
|
|
257
|
-
const scaling = TmpVectors.Vector3[1];
|
|
258
|
-
this._localMatrixCache.decompose(scaling, rotation, position);
|
|
259
|
-
position.addToRef(pivotB, this._tempVectorCache);
|
|
260
|
-
descendant.position.copyFrom(this._tempVectorCache);
|
|
261
|
-
const worldRotation = TmpVectors.Quaternion[1];
|
|
262
|
-
childBody.transformNode.getWorldMatrix().getRotationQuaternionToRef(worldRotation);
|
|
263
|
-
worldRotation.multiplyToRef(descendant.rotationQuaternion, TmpVectors.Quaternion[2]);
|
|
264
|
-
TmpVectors.Quaternion[2].copyFrom(descendant.rotationQuaternion);
|
|
265
|
-
const parentScaling = childBody.transformNode.absoluteScaling;
|
|
266
|
-
switch (axisNumber) {
|
|
267
|
-
case 0:
|
|
268
|
-
descendant.scaling.x = 1 / parentScaling.x;
|
|
269
|
-
descendant.scaling.y = 1 / parentScaling.z;
|
|
270
|
-
descendant.scaling.z = 1 / parentScaling.y;
|
|
271
|
-
break;
|
|
272
|
-
case 1:
|
|
273
|
-
descendant.scaling.x = 1 / parentScaling.z;
|
|
274
|
-
descendant.scaling.y = 1 / parentScaling.y;
|
|
275
|
-
descendant.scaling.z = 1 / parentScaling.x;
|
|
276
|
-
break;
|
|
277
|
-
case 2:
|
|
278
|
-
descendant.scaling.x = 1 / parentScaling.x;
|
|
279
|
-
descendant.scaling.y = 1 / parentScaling.z;
|
|
280
|
-
descendant.scaling.z = 1 / parentScaling.y;
|
|
281
|
-
break;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
243
|
}
|
|
287
244
|
}
|
|
288
245
|
/**
|
|
@@ -524,7 +481,6 @@ export class PhysicsViewer {
|
|
|
524
481
|
return;
|
|
525
482
|
}
|
|
526
483
|
let removed = false;
|
|
527
|
-
const utilityLayerScene = this._utilityLayer.utilityLayerScene;
|
|
528
484
|
for (let i = 0; i < this._numConstraints; i++) {
|
|
529
485
|
if (this._constraints[i] === constraint) {
|
|
530
486
|
const meshes = this._constraintMeshes[i];
|
|
@@ -532,7 +488,6 @@ export class PhysicsViewer {
|
|
|
532
488
|
continue;
|
|
533
489
|
}
|
|
534
490
|
for (const mesh of meshes) {
|
|
535
|
-
utilityLayerScene.removeMesh(mesh);
|
|
536
491
|
mesh.dispose();
|
|
537
492
|
}
|
|
538
493
|
this._constraints.splice(i, 1);
|
|
@@ -800,25 +755,40 @@ export class PhysicsViewer {
|
|
|
800
755
|
return matrix.copyFrom(tnode.getWorldMatrix());
|
|
801
756
|
}
|
|
802
757
|
}
|
|
803
|
-
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber,
|
|
758
|
+
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber, parent, scene) {
|
|
804
759
|
const arcAngle = (maxLimit - minLimit) / (Math.PI * 2);
|
|
805
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 };
|
|
806
763
|
mesh.material = this._getDebugAxisColoredMaterial(axisNumber, scene);
|
|
807
|
-
|
|
808
|
-
mesh.
|
|
764
|
+
parent.getWorldMatrix().decomposeToTransformNode(root);
|
|
765
|
+
mesh.parent = root;
|
|
766
|
+
const parentScaling = parent.absoluteScaling;
|
|
809
767
|
switch (axisNumber) {
|
|
810
768
|
case 0:
|
|
811
769
|
mesh.rotation.z = Math.PI * 0.5;
|
|
812
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;
|
|
813
775
|
break;
|
|
814
776
|
case 1:
|
|
815
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;
|
|
816
782
|
break;
|
|
817
783
|
case 2:
|
|
818
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;
|
|
819
789
|
break;
|
|
820
790
|
}
|
|
821
|
-
return
|
|
791
|
+
return root;
|
|
822
792
|
}
|
|
823
793
|
_createCage(parent, scene) {
|
|
824
794
|
const cage = MeshBuilder.CreateBox("cage", { size: 1 }, scene);
|
|
@@ -851,9 +821,6 @@ export class PhysicsViewer {
|
|
|
851
821
|
const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();
|
|
852
822
|
const parentedConstraintMeshes = [];
|
|
853
823
|
parentedConstraintMeshes.push(parentingMesh);
|
|
854
|
-
// Create a container for angular constraint meshes
|
|
855
|
-
const angularConstraintContainer = new TransformNode("angularConstraintContainer", utilityLayerScene);
|
|
856
|
-
angularConstraintContainer.parent = parentingMesh;
|
|
857
824
|
for (const bodyPairInfo of bodiesUsingConstraint) {
|
|
858
825
|
// Create a mesh to keep the pair of constraint axes
|
|
859
826
|
const parentOfPair = new TransformNode("parentOfPair", utilityLayerScene);
|
|
@@ -891,6 +858,7 @@ export class PhysicsViewer {
|
|
|
891
858
|
// Create axes for the constraint
|
|
892
859
|
const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);
|
|
893
860
|
parentAxes.xAxis.parent = parentTransformNode;
|
|
861
|
+
// parentAxes.xAxis.isPi
|
|
894
862
|
parentAxes.yAxis.parent = parentTransformNode;
|
|
895
863
|
parentAxes.zAxis.parent = parentTransformNode;
|
|
896
864
|
const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);
|
|
@@ -948,8 +916,7 @@ export class PhysicsViewer {
|
|
|
948
916
|
maxLimit = engine.getAxisMaxLimit(constraint, axis);
|
|
949
917
|
}
|
|
950
918
|
if (axisMode != 2 /* PhysicsConstraintAxisLimitMode.LOCKED */ && constraint.options.pivotB) {
|
|
951
|
-
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody,
|
|
952
|
-
mesh.parent = angularConstraintContainer;
|
|
919
|
+
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody.transformNode, utilityLayerScene);
|
|
953
920
|
mesh.position.copyFrom(constraint.options.pivotB);
|
|
954
921
|
parentedConstraintMeshes.push(mesh);
|
|
955
922
|
}
|