@onerjs/core 8.47.6 → 8.47.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/Debug/physicsViewer.d.ts
CHANGED
|
@@ -56,6 +56,11 @@ export declare class PhysicsViewer {
|
|
|
56
56
|
private _debugMeshMeshes;
|
|
57
57
|
private _constraintAxesSize;
|
|
58
58
|
private _constraintAngularSize;
|
|
59
|
+
private _localMatrixCache;
|
|
60
|
+
private _tempVectorCache;
|
|
61
|
+
private _inertiaMatrixCache;
|
|
62
|
+
private _transformMatrixCache;
|
|
63
|
+
private _finalMatrixCache;
|
|
59
64
|
/**
|
|
60
65
|
* Creates a new PhysicsViewer
|
|
61
66
|
* @param scene defines the hosting scene
|
package/Debug/physicsViewer.js
CHANGED
|
@@ -55,6 +55,11 @@ 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();
|
|
58
63
|
this._scene = scene || EngineStore.LastCreatedScene;
|
|
59
64
|
if (!this._scene) {
|
|
60
65
|
return;
|
|
@@ -156,33 +161,30 @@ export class PhysicsViewer {
|
|
|
156
161
|
}
|
|
157
162
|
}
|
|
158
163
|
_updateDebugInertia(body, inertiaMesh) {
|
|
159
|
-
const inertiaMatrixRef = Matrix.Identity();
|
|
160
|
-
const transformMatrixRef = Matrix.Identity();
|
|
161
|
-
const finalMatrixRef = Matrix.Identity();
|
|
162
164
|
if (body._pluginDataInstances.length) {
|
|
163
165
|
const inertiaAsMesh = inertiaMesh;
|
|
164
166
|
const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData;
|
|
165
167
|
const bodyTransformMatrixData = body.transformNode._thinInstanceDataStorage.matrixData;
|
|
166
168
|
for (let i = 0; i < body._pluginDataInstances.length; i++) {
|
|
167
169
|
const props = body.getMassProperties(i);
|
|
168
|
-
this._getMeshDebugInertiaMatrixToRef(props,
|
|
169
|
-
Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
this._getMeshDebugInertiaMatrixToRef(props, this._inertiaMatrixCache);
|
|
171
|
+
Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, this._transformMatrixCache);
|
|
172
|
+
this._inertiaMatrixCache.multiplyToRef(this._transformMatrixCache, this._finalMatrixCache);
|
|
173
|
+
this._finalMatrixCache.copyToArray(inertiaMeshMatrixData, i * 16);
|
|
172
174
|
}
|
|
173
175
|
inertiaAsMesh.thinInstanceBufferUpdated("matrix");
|
|
174
176
|
}
|
|
175
177
|
else {
|
|
176
178
|
const props = body.getMassProperties();
|
|
177
|
-
this._getMeshDebugInertiaMatrixToRef(props,
|
|
178
|
-
body.transformNode.rotationQuaternion?.toRotationMatrix(
|
|
179
|
-
|
|
179
|
+
this._getMeshDebugInertiaMatrixToRef(props, this._inertiaMatrixCache);
|
|
180
|
+
body.transformNode.rotationQuaternion?.toRotationMatrix(this._transformMatrixCache);
|
|
181
|
+
this._transformMatrixCache.setTranslation(body.transformNode.position);
|
|
180
182
|
if (body.transformNode.parent) {
|
|
181
183
|
const parentTransform = body.transformNode.parent.computeWorldMatrix(true);
|
|
182
|
-
|
|
184
|
+
this._transformMatrixCache.multiplyToRef(parentTransform, this._transformMatrixCache);
|
|
183
185
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
this._inertiaMatrixCache.multiplyToRef(this._transformMatrixCache, this._inertiaMatrixCache);
|
|
187
|
+
this._inertiaMatrixCache.decomposeToTransformNode(inertiaMesh);
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
_updateDebugConstraints() {
|
|
@@ -240,6 +242,47 @@ export class PhysicsViewer {
|
|
|
240
242
|
// Get the transform to align the XYZ axes to the constraint axes
|
|
241
243
|
Quaternion.FromRotationMatrixToRef(Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]), parentTransformNode.rotationQuaternion);
|
|
242
244
|
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
|
+
}
|
|
243
286
|
}
|
|
244
287
|
}
|
|
245
288
|
/**
|
|
@@ -757,34 +800,22 @@ export class PhysicsViewer {
|
|
|
757
800
|
return matrix.copyFrom(tnode.getWorldMatrix());
|
|
758
801
|
}
|
|
759
802
|
}
|
|
760
|
-
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber,
|
|
803
|
+
_createAngularConstraintMesh(minLimit, maxLimit, axisNumber, childBody, childBodyIndex, scene) {
|
|
761
804
|
const arcAngle = (maxLimit - minLimit) / (Math.PI * 2);
|
|
762
805
|
const mesh = MeshBuilder.CreateCylinder("ConstraintCylinder", { height: 0.0001, diameter: 3 * this._constraintAngularSize, arc: arcAngle }, scene);
|
|
763
806
|
mesh.material = this._getDebugAxisColoredMaterial(axisNumber, scene);
|
|
764
|
-
mesh.
|
|
765
|
-
|
|
807
|
+
mesh.metadata = { childBody, childBodyIndex, axisNumber, minLimit };
|
|
808
|
+
mesh.rotationQuaternion = Quaternion.Identity();
|
|
766
809
|
switch (axisNumber) {
|
|
767
810
|
case 0:
|
|
768
811
|
mesh.rotation.z = Math.PI * 0.5;
|
|
769
812
|
mesh.rotation.x = -minLimit + Math.PI * 0.5;
|
|
770
|
-
// scaling on y,z
|
|
771
|
-
mesh.scaling.x = 1 / parentScaling.x;
|
|
772
|
-
mesh.scaling.y = 1 / parentScaling.z;
|
|
773
|
-
mesh.scaling.z = 1 / parentScaling.y;
|
|
774
813
|
break;
|
|
775
814
|
case 1:
|
|
776
815
|
mesh.rotation.y = Math.PI * 1.5 + minLimit;
|
|
777
|
-
// flip x,z
|
|
778
|
-
mesh.scaling.x = 1 / parentScaling.z;
|
|
779
|
-
mesh.scaling.y = 1 / parentScaling.y;
|
|
780
|
-
mesh.scaling.z = 1 / parentScaling.x;
|
|
781
816
|
break;
|
|
782
817
|
case 2:
|
|
783
818
|
mesh.rotation.x = Math.PI * 0.5;
|
|
784
|
-
// flip z,y
|
|
785
|
-
mesh.scaling.x = 1 / parentScaling.x;
|
|
786
|
-
mesh.scaling.y = 1 / parentScaling.z;
|
|
787
|
-
mesh.scaling.z = 1 / parentScaling.y;
|
|
788
819
|
break;
|
|
789
820
|
}
|
|
790
821
|
return mesh;
|
|
@@ -820,6 +851,9 @@ export class PhysicsViewer {
|
|
|
820
851
|
const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();
|
|
821
852
|
const parentedConstraintMeshes = [];
|
|
822
853
|
parentedConstraintMeshes.push(parentingMesh);
|
|
854
|
+
// Create a container for angular constraint meshes
|
|
855
|
+
const angularConstraintContainer = new TransformNode("angularConstraintContainer", utilityLayerScene);
|
|
856
|
+
angularConstraintContainer.parent = parentingMesh;
|
|
823
857
|
for (const bodyPairInfo of bodiesUsingConstraint) {
|
|
824
858
|
// Create a mesh to keep the pair of constraint axes
|
|
825
859
|
const parentOfPair = new TransformNode("parentOfPair", utilityLayerScene);
|
|
@@ -914,7 +948,8 @@ export class PhysicsViewer {
|
|
|
914
948
|
maxLimit = engine.getAxisMaxLimit(constraint, axis);
|
|
915
949
|
}
|
|
916
950
|
if (axisMode != 2 /* PhysicsConstraintAxisLimitMode.LOCKED */ && constraint.options.pivotB) {
|
|
917
|
-
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody
|
|
951
|
+
const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody, childBodyIndex, utilityLayerScene);
|
|
952
|
+
mesh.parent = angularConstraintContainer;
|
|
918
953
|
mesh.position.copyFrom(constraint.options.pivotB);
|
|
919
954
|
parentedConstraintMeshes.push(mesh);
|
|
920
955
|
}
|
|
@@ -939,6 +974,9 @@ export class PhysicsViewer {
|
|
|
939
974
|
for (let index = this._numInertiaBodies - 1; index >= 0; index--) {
|
|
940
975
|
this.hideInertia(this._inertiaBodies[0]);
|
|
941
976
|
}
|
|
977
|
+
for (let index = this._numConstraints - 1; index >= 0; index--) {
|
|
978
|
+
this.hideConstraint(this._constraints[0]);
|
|
979
|
+
}
|
|
942
980
|
if (this._debugBoxMesh) {
|
|
943
981
|
this._debugBoxMesh.dispose();
|
|
944
982
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug/physicsViewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EA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C9C,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type Nullable } from \"../types\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport { type Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { type IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport { PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode, type IPhysicsEnginePluginV2, type PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { type ICreateCapsuleOptions, CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { type PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport { type PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\nimport \"../Physics/joinedPhysicsEngineComponent\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<Array<AbstractMesh>>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n private _ownUtilityLayer = false;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n private _constraintAngularSize = 0.4;\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n * @param size Physics V2 size scalar\r\n * @param utilityLayer The utility layer the viewer will be added to\r\n */\r\n constructor(scene?: Scene, size?: number, utilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n if (utilityLayer) {\r\n this._utilityLayer = utilityLayer;\r\n } else {\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n this._ownUtilityLayer = true;\r\n }\r\n if (size) {\r\n this._constraintAxesSize = 0.4 * size;\r\n this._constraintAngularSize = 0.4 * size;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; ) {\r\n const body = this._bodies[i];\r\n if (body && body.isDisposed && this.hideBody(body)) {\r\n continue;\r\n }\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n i++;\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; ) {\r\n const body = this._inertiaBodies[i];\r\n if (body && body.isDisposed && this.hideInertia(body)) {\r\n continue;\r\n }\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n i++;\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n const inertiaMatrixRef = Matrix.Identity();\r\n const transformMatrixRef = Matrix.Identity();\r\n const finalMatrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, transformMatrixRef);\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, finalMatrixRef);\r\n finalMatrixRef.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(transformMatrixRef);\r\n transformMatrixRef.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);\r\n }\r\n inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh[0]);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n const descendants = parentingMesh.getDescendants(true);\r\n for (const parentConstraintMesh of descendants) {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body the physics body used to get the inertia\r\n * @returns the debug mesh used to show the inertia, or null if the body is already shown\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh ? debugMesh[0] : null;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n * @returns true if body actually removed\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>): boolean {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return false;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n return removed;\r\n }\r\n\r\n /**\r\n * Hides a body's inertia from the viewer utility layer\r\n * @param body the body to hide\r\n * @returns true if inertia actually removed\r\n */\r\n public hideInertia(body: Nullable<PhysicsBody>): boolean {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return false;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n return removed;\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const meshes = this._constraintMeshes[i];\r\n\r\n if (!meshes) {\r\n continue;\r\n }\r\n\r\n for (const mesh of meshes) {\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n }\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugAxisColoredMaterial(axisNumber: number, scene: Scene): Material {\r\n const material = new StandardMaterial(\"\", scene);\r\n material.emissiveColor = axisNumber == 0 ? Color3.Red() : axisNumber == 1 ? Color3.Green() : Color3.Blue();\r\n material.disableLighting = true;\r\n return material;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n for (const m of childMeshes) {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n }\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _createAngularConstraintMesh(minLimit: number, maxLimit: number, axisNumber: number, parent: TransformNode, scene: Scene): AbstractMesh {\r\n const arcAngle = (maxLimit - minLimit) / (Math.PI * 2);\r\n const mesh = MeshBuilder.CreateCylinder(\"ConstraintCylinder\", { height: 0.0001, diameter: 3 * this._constraintAngularSize, arc: arcAngle }, scene);\r\n mesh.material = this._getDebugAxisColoredMaterial(axisNumber, scene);\r\n mesh.parent = parent;\r\n const parentScaling = parent.absoluteScaling;\r\n switch (axisNumber) {\r\n case 0:\r\n mesh.rotation.z = Math.PI * 0.5;\r\n mesh.rotation.x = -minLimit + Math.PI * 0.5;\r\n // scaling on y,z\r\n mesh.scaling.x = 1 / parentScaling.x;\r\n mesh.scaling.y = 1 / parentScaling.z;\r\n mesh.scaling.z = 1 / parentScaling.y;\r\n break;\r\n case 1:\r\n mesh.rotation.y = Math.PI * 1.5 + minLimit;\r\n // flip x,z\r\n mesh.scaling.x = 1 / parentScaling.z;\r\n mesh.scaling.y = 1 / parentScaling.y;\r\n mesh.scaling.z = 1 / parentScaling.x;\r\n break;\r\n case 2:\r\n mesh.rotation.x = Math.PI * 0.5;\r\n // flip z,y\r\n mesh.scaling.x = 1 / parentScaling.x;\r\n mesh.scaling.y = 1 / parentScaling.z;\r\n mesh.scaling.z = 1 / parentScaling.y;\r\n break;\r\n }\r\n return mesh;\r\n }\r\n\r\n private _createCage(parent: TransformNode, scene: Scene): AbstractMesh {\r\n const cage = MeshBuilder.CreateBox(\"cage\", { size: 1 }, scene);\r\n cage.setPivotPoint(new Vector3(-0.5, -0.5, -0.5));\r\n const transparentMaterial = new StandardMaterial(\"cage_material\", scene);\r\n transparentMaterial.alpha = 0; // Fully transparent\r\n cage.material = transparentMaterial;\r\n\r\n cage.enableEdgesRendering();\r\n cage.edgesWidth = 4.0;\r\n cage.edgesColor = new Color4(1, 1, 1, 1);\r\n cage.parent = parent;\r\n return cage;\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<Array<AbstractMesh>> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n const parentedConstraintMeshes = [];\r\n parentedConstraintMeshes.push(parentingMesh);\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n\r\n // constrain vis\r\n const engine = this._physicsEnginePlugin! as IPhysicsEnginePluginV2;\r\n\r\n const constraintAxisAngular = [PhysicsConstraintAxis.ANGULAR_X, PhysicsConstraintAxis.ANGULAR_Y, PhysicsConstraintAxis.ANGULAR_Z];\r\n const constraintAxisLinear = [PhysicsConstraintAxis.LINEAR_X, PhysicsConstraintAxis.LINEAR_Y, PhysicsConstraintAxis.LINEAR_Z];\r\n const constraintAxis = [constraintAxisAngular, constraintAxisLinear];\r\n\r\n // count axis. Angular and Linear\r\n const lockCount = [0, 0];\r\n for (let angularLinear = 0; angularLinear < 2; angularLinear++) {\r\n for (let axis = 0; axis < 3; axis++) {\r\n const constraintAxisValue = constraintAxis[angularLinear][axis];\r\n const axisMode = engine.getAxisMode(constraint, constraintAxisValue);\r\n if (axisMode == PhysicsConstraintAxisLimitMode.LOCKED) {\r\n lockCount[angularLinear]++;\r\n }\r\n }\r\n }\r\n\r\n // Any free/limited Linear axis\r\n if (lockCount[1] != 3) {\r\n const cage = this._createCage(parentTransformNode, utilityLayerScene);\r\n\r\n const min = TmpVectors.Vector3[0];\r\n const max = TmpVectors.Vector3[1];\r\n const limited = [false, false, false];\r\n\r\n limited[0] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_X) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n limited[1] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_Y) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n limited[2] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_Z) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n\r\n min.x = limited[0] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_X)! : 0;\r\n max.x = limited[0] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_X)! : 0;\r\n min.y = limited[1] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_Y)! : 0;\r\n max.y = limited[1] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_Y)! : 0;\r\n min.z = limited[2] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_Z)! : 0;\r\n max.z = limited[2] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_Z)! : 0;\r\n\r\n cage.position.x = min.x + 0.5;\r\n cage.position.y = min.y + 0.5;\r\n cage.position.z = min.z + 0.5;\r\n\r\n cage.scaling.x = max.x - min.x + Epsilon;\r\n cage.scaling.y = max.y - min.y + Epsilon;\r\n cage.scaling.z = max.z - min.z + Epsilon;\r\n parentedConstraintMeshes.push(cage);\r\n }\r\n\r\n // Angular\r\n if (lockCount[0] != 3) {\r\n for (let axisIndex = 0; axisIndex < 3; axisIndex++) {\r\n const axis = constraintAxisAngular[axisIndex];\r\n const axisMode = engine.getAxisMode(constraint, axis);\r\n let minLimit = 0;\r\n let maxLimit = Math.PI * 2;\r\n if (axisMode == PhysicsConstraintAxisLimitMode.LIMITED) {\r\n minLimit = engine.getAxisMinLimit(constraint, axis)!;\r\n maxLimit = engine.getAxisMaxLimit(constraint, axis)!;\r\n }\r\n if (axisMode != PhysicsConstraintAxisLimitMode.LOCKED && constraint.options.pivotB) {\r\n const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody.transformNode, utilityLayerScene);\r\n mesh.position.copyFrom(constraint.options.pivotB);\r\n parentedConstraintMeshes.push(mesh);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return parentedConstraintMeshes;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._ownUtilityLayer && this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../dev/core/src/Debug/physicsViewer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAGjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAA8B,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAElD,OAAO,yCAAyC,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,aAAa;IAmDtB;;;;;OAKG;IACH,YAAY,KAAa,EAAE,IAAa,EAAE,eAAqC,oBAAoB,CAAC,mBAAmB;QAxDvH,gBAAgB;Q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BAAgB,EAAE,CAAC;YACxB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QACpC,CAAC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC1B,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QACtC,CAAC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QAEjC,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9C,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { type Nullable } from \"../types\";\r\nimport { type Scene } from \"../scene\";\r\nimport { type AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateSphere } from \"../Meshes/Builders/sphereBuilder\";\r\nimport { Matrix, Quaternion, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport { type Material } from \"../Materials/material\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport { type IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from \"../Physics/v1/IPhysicsEnginePlugin\";\r\nimport { PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode, type IPhysicsEnginePluginV2, type PhysicsMassProperties } from \"../Physics/v2/IPhysicsEnginePlugin\";\r\nimport { PhysicsImpostor } from \"../Physics/v1/physicsImpostor\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { type ICreateCapsuleOptions, CreateCapsule } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { type PhysicsBody } from \"../Physics/v2/physicsBody\";\r\nimport { VertexData } from \"../Meshes/mesh.vertexData\";\r\nimport { MeshBuilder } from \"../Meshes/meshBuilder\";\r\nimport { type PhysicsConstraint } from \"../Physics/v2/physicsConstraint\";\r\nimport { AxesViewer } from \"./axesViewer\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\n\r\nimport \"../Physics/joinedPhysicsEngineComponent\";\r\n\r\n/**\r\n * Used to show the physics impostor around the specific mesh\r\n */\r\nexport class PhysicsViewer {\r\n /** @internal */\r\n protected _impostors: Array<Nullable<PhysicsImpostor>> = [];\r\n /** @internal */\r\n protected _meshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _bodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\r\n /** @internal */\r\n protected _constraints: Array<Nullable<PhysicsConstraint>> = [];\r\n /** @internal */\r\n protected _bodyMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _inertiaMeshes: Array<Nullable<AbstractMesh>> = [];\r\n /** @internal */\r\n protected _constraintMeshes: Array<Nullable<Array<AbstractMesh>>> = [];\r\n /** @internal */\r\n protected _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n /** @internal */\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _numConstraints = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _constraintRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\r\n private _ownUtilityLayer = false;\r\n\r\n private _debugBoxMesh: Mesh;\r\n private _debugSphereMesh: Mesh;\r\n private _debugCapsuleMesh: Mesh;\r\n private _debugCylinderMesh: Mesh;\r\n private _debugMaterial: StandardMaterial;\r\n private _debugInertiaMaterial: StandardMaterial;\r\n private _debugMeshMeshes = new Array<Mesh>();\r\n\r\n private _constraintAxesSize = 0.4;\r\n private _constraintAngularSize = 0.4;\r\n private _localMatrixCache = Matrix.Identity();\r\n private _tempVectorCache = Vector3.Zero();\r\n private _inertiaMatrixCache = Matrix.Identity();\r\n private _transformMatrixCache = Matrix.Identity();\r\n private _finalMatrixCache = Matrix.Identity();\r\n\r\n /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n * @param size Physics V2 size scalar\r\n * @param utilityLayer The utility layer the viewer will be added to\r\n */\r\n constructor(scene?: Scene, size?: number, utilityLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer) {\r\n this._scene = scene || EngineStore.LastCreatedScene;\r\n if (!this._scene) {\r\n return;\r\n }\r\n const physicEngine = this._scene.getPhysicsEngine();\r\n\r\n if (physicEngine) {\r\n this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();\r\n }\r\n\r\n if (utilityLayer) {\r\n this._utilityLayer = utilityLayer;\r\n } else {\r\n this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\r\n this._ownUtilityLayer = true;\r\n }\r\n if (size) {\r\n this._constraintAxesSize = 0.4 * size;\r\n this._constraintAngularSize = 0.4 * size;\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This code is useful for synchronizing the debug meshes of the physics engine with the physics impostor and mesh.\r\n * It checks if the impostor is disposed and if the plugin version is 1, then it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes are up to date with the physics engine.\r\n */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\r\n if (plugin?.getPluginVersion() === 1) {\r\n this._updateDebugMeshesV1();\r\n } else {\r\n this._updateDebugMeshesV2();\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine.\r\n *\r\n * This method is useful for synchronizing the debug meshes with the physics impostors.\r\n * It iterates through the impostors and meshes, and if the plugin version is 1, it syncs the mesh with the impostor.\r\n * This ensures that the debug meshes accurately reflect the physics impostors, which is important for debugging the physics engine.\r\n */\r\n protected _updateDebugMeshesV1(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV1;\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n const impostor = this._impostors[i];\r\n\r\n if (!impostor) {\r\n continue;\r\n }\r\n\r\n if (impostor.isDisposed) {\r\n this.hideImpostor(this._impostors[i--]);\r\n } else {\r\n if (impostor.type === PhysicsImpostor.MeshImpostor) {\r\n continue;\r\n }\r\n const mesh = this._meshes[i];\r\n\r\n if (mesh && plugin) {\r\n plugin.syncMeshWithImpostor(mesh, impostor);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Updates the debug meshes of the physics engine for V2 plugin.\r\n *\r\n * This method is useful for synchronizing the debug meshes of the physics engine with the current state of the bodies.\r\n * It iterates through the bodies array and updates the debug meshes with the current transform of each body.\r\n * This ensures that the debug meshes accurately reflect the current state of the physics engine.\r\n */\r\n protected _updateDebugMeshesV2(): void {\r\n const plugin = this._physicsEnginePlugin as IPhysicsEnginePluginV2;\r\n for (let i = 0; i < this._numBodies; ) {\r\n const body = this._bodies[i];\r\n if (body && body.isDisposed && this.hideBody(body)) {\r\n continue;\r\n }\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n i++;\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; ) {\r\n const body = this._inertiaBodies[i];\r\n if (body && body.isDisposed && this.hideInertia(body)) {\r\n continue;\r\n }\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\r\n i++;\r\n }\r\n }\r\n\r\n protected _updateDebugInertia(body: PhysicsBody, inertiaMesh: AbstractMesh): void {\r\n if (body._pluginDataInstances.length) {\r\n const inertiaAsMesh = inertiaMesh as Mesh;\r\n const inertiaMeshMatrixData = inertiaAsMesh._thinInstanceDataStorage.matrixData!;\r\n const bodyTransformMatrixData = (body.transformNode as Mesh)._thinInstanceDataStorage.matrixData!;\r\n for (let i = 0; i < body._pluginDataInstances.length; i++) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, this._inertiaMatrixCache);\r\n Matrix.FromArrayToRef(bodyTransformMatrixData, i * 16, this._transformMatrixCache);\r\n this._inertiaMatrixCache.multiplyToRef(this._transformMatrixCache, this._finalMatrixCache);\r\n this._finalMatrixCache.copyToArray(inertiaMeshMatrixData, i * 16);\r\n }\r\n inertiaAsMesh.thinInstanceBufferUpdated(\"matrix\");\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, this._inertiaMatrixCache);\r\n body.transformNode.rotationQuaternion?.toRotationMatrix(this._transformMatrixCache);\r\n this._transformMatrixCache.setTranslation(body.transformNode.position);\r\n if (body.transformNode.parent) {\r\n const parentTransform = body.transformNode.parent.computeWorldMatrix(true);\r\n this._transformMatrixCache.multiplyToRef(parentTransform, this._transformMatrixCache);\r\n }\r\n this._inertiaMatrixCache.multiplyToRef(this._transformMatrixCache, this._inertiaMatrixCache);\r\n this._inertiaMatrixCache.decomposeToTransformNode(inertiaMesh);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraints() {\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n const constraint = this._constraints[i];\r\n const mesh = this._constraintMeshes[i];\r\n if (constraint && mesh) {\r\n this._updateDebugConstraint(constraint, mesh[0]);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Given a scaling vector, make all of its components\r\n * 1, preserving the sign\r\n * @param scaling\r\n */\r\n protected _makeScalingUnitInPlace(scaling: Vector3) {\r\n if (Math.abs(scaling.x - 1) > Epsilon) {\r\n scaling.x = 1 * Math.sign(scaling.x);\r\n }\r\n if (Math.abs(scaling.y - 1) > Epsilon) {\r\n scaling.y = 1 * Math.sign(scaling.y);\r\n }\r\n if (Math.abs(scaling.z - 1) > Epsilon) {\r\n scaling.z = 1 * Math.sign(scaling.z);\r\n }\r\n }\r\n\r\n protected _updateDebugConstraint(constraint: PhysicsConstraint, parentingMesh: AbstractMesh) {\r\n if (!constraint._initOptions) {\r\n return;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return;\r\n }\r\n\r\n const descendants = parentingMesh.getDescendants(true);\r\n for (const parentConstraintMesh of descendants) {\r\n // Get the parent transform\r\n const parentCoordSystemNode = parentConstraintMesh.getDescendants(true)[0] as TransformNode;\r\n const childCoordSystemNode = parentConstraintMesh.getDescendants(true)[1] as TransformNode;\r\n\r\n const { parentBody, parentBodyIndex } = parentCoordSystemNode.metadata;\r\n const { childBody, childBodyIndex } = childCoordSystemNode.metadata;\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n this._makeScalingUnitInPlace(parentCoordSystemNode.scaling);\r\n\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n this._makeScalingUnitInPlace(childCoordSystemNode.scaling);\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = parentCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n parentTransformNode.position.copyFrom(pivotA);\r\n\r\n const childTransformNode = childCoordSystemNode.getDescendants(true)[0] as TransformNode;\r\n childTransformNode.position.copyFrom(pivotB);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisA, perpAxisA, Vector3.CrossToRef(axisA, perpAxisA, TmpVectors.Vector3[0]), TmpVectors.Matrix[0]),\r\n parentTransformNode.rotationQuaternion!\r\n );\r\n Quaternion.FromRotationMatrixToRef(\r\n Matrix.FromXYZAxesToRef(axisB, perpAxisB, Vector3.CrossToRef(axisB, perpAxisB, TmpVectors.Vector3[1]), TmpVectors.Matrix[1]),\r\n childTransformNode.rotationQuaternion!\r\n );\r\n\r\n // Sync angular constraint meshes with child body transform\r\n const allDescendants = parentConstraintMesh.getDescendants(true);\r\n for (const descendant of allDescendants) {\r\n if ((descendant as AbstractMesh).metadata?.childBody) {\r\n const { childBody, axisNumber } = (descendant as AbstractMesh).metadata;\r\n if (childBody.transformNode) {\r\n const childWorldMatrix = childBody.transformNode.getWorldMatrix();\r\n const childWorldMatrixInverse = TmpVectors.Matrix[2];\r\n childWorldMatrix.invertToRef(childWorldMatrixInverse);\r\n\r\n childWorldMatrixInverse.multiplyToRef(childTransform, this._localMatrixCache);\r\n\r\n const position = TmpVectors.Vector3[0];\r\n const rotation = TmpVectors.Quaternion[0];\r\n const scaling = TmpVectors.Vector3[1];\r\n\r\n this._localMatrixCache.decompose(scaling, rotation, position);\r\n\r\n position.addToRef(pivotB, this._tempVectorCache);\r\n (descendant as AbstractMesh).position.copyFrom(this._tempVectorCache);\r\n const worldRotation = TmpVectors.Quaternion[1];\r\n childBody.transformNode.getWorldMatrix().getRotationQuaternionToRef(worldRotation);\r\n worldRotation.multiplyToRef((descendant as AbstractMesh).rotationQuaternion!, TmpVectors.Quaternion[2]);\r\n TmpVectors.Quaternion[2].copyFrom((descendant as AbstractMesh).rotationQuaternion!);\r\n\r\n const parentScaling = childBody.transformNode.absoluteScaling;\r\n switch (axisNumber) {\r\n case 0:\r\n (descendant as AbstractMesh).scaling.x = 1 / parentScaling.x;\r\n (descendant as AbstractMesh).scaling.y = 1 / parentScaling.z;\r\n (descendant as AbstractMesh).scaling.z = 1 / parentScaling.y;\r\n break;\r\n case 1:\r\n (descendant as AbstractMesh).scaling.x = 1 / parentScaling.z;\r\n (descendant as AbstractMesh).scaling.y = 1 / parentScaling.y;\r\n (descendant as AbstractMesh).scaling.z = 1 / parentScaling.x;\r\n break;\r\n case 2:\r\n (descendant as AbstractMesh).scaling.x = 1 / parentScaling.x;\r\n (descendant as AbstractMesh).scaling.y = 1 / parentScaling.z;\r\n (descendant as AbstractMesh).scaling.z = 1 / parentScaling.y;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Renders a specified physic impostor\r\n * @param impostor defines the impostor to render\r\n * @param targetMesh defines the mesh represented by the impostor\r\n * @returns the new debug mesh used to render the impostor\r\n */\r\n public showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugMesh(impostor, targetMesh);\r\n\r\n if (debugMesh) {\r\n this._impostors[this._numMeshes] = impostor;\r\n this._meshes[this._numMeshes] = debugMesh;\r\n\r\n if (this._numMeshes === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numMeshes++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics body.\r\n * @param body The physics body to show.\r\n * @returns The debug mesh, or null if the body is already shown.\r\n *\r\n * This function is useful for visualizing the physics body in the scene.\r\n * It creates a debug mesh for the given body and adds it to the scene.\r\n * It also registers a before render function to update the debug mesh position and rotation.\r\n */\r\n public showBody(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugBodyMesh(body);\r\n\r\n if (debugMesh) {\r\n this._bodies[this._numBodies] = body;\r\n this._bodyMeshes[this._numBodies] = debugMesh;\r\n\r\n if (this._numBodies === 0) {\r\n this._renderFunction = () => this._updateDebugMeshes();\r\n this._scene.registerBeforeRender(this._renderFunction);\r\n }\r\n\r\n this._numBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug box corresponding to the inertia of a given body\r\n * @param body the physics body used to get the inertia\r\n * @returns the debug mesh used to show the inertia, or null if the body is already shown\r\n */\r\n public showInertia(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] == body) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugInertiaMesh(body);\r\n if (debugMesh) {\r\n this._inertiaBodies[this._numInertiaBodies] = body;\r\n this._inertiaMeshes[this._numInertiaBodies] = debugMesh;\r\n\r\n if (this._numInertiaBodies === 0) {\r\n this._inertiaRenderFunction = () => this._updateInertiaMeshes();\r\n this._scene.registerBeforeRender(this._inertiaRenderFunction);\r\n }\r\n\r\n this._numInertiaBodies++;\r\n }\r\n\r\n return debugMesh;\r\n }\r\n\r\n /**\r\n * Shows a debug mesh for a given physics constraint.\r\n * @param constraint the physics constraint to show\r\n * @returns the debug mesh, or null if the constraint is already shown\r\n */\r\n public showConstraint(constraint: PhysicsConstraint): Nullable<AbstractMesh> {\r\n if (!this._scene) {\r\n return null;\r\n }\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] == constraint) {\r\n return null;\r\n }\r\n }\r\n\r\n const debugMesh = this._getDebugConstraintMesh(constraint);\r\n if (debugMesh) {\r\n this._constraints[this._numConstraints] = constraint;\r\n this._constraintMeshes[this._numConstraints] = debugMesh;\r\n\r\n if (this._numConstraints === 0) {\r\n this._constraintRenderFunction = () => this._updateDebugConstraints();\r\n this._scene.registerBeforeRender(this._constraintRenderFunction);\r\n }\r\n\r\n this._numConstraints++;\r\n }\r\n\r\n return debugMesh ? debugMesh[0] : null;\r\n }\r\n\r\n /**\r\n * Hides an impostor from the scene.\r\n * @param impostor - The impostor to hide.\r\n *\r\n * This method is useful for hiding an impostor from the scene. It removes the\r\n * impostor from the utility layer scene, disposes the mesh, and removes the\r\n * impostor from the list of impostors. If the impostor is the last one in the\r\n * list, it also unregisters the render function.\r\n */\r\n public hideImpostor(impostor: Nullable<PhysicsImpostor>) {\r\n if (!impostor || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numMeshes; i++) {\r\n if (this._impostors[i] == impostor) {\r\n const mesh = this._meshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n const index = this._debugMeshMeshes.indexOf(mesh as Mesh);\r\n if (index > -1) {\r\n this._debugMeshMeshes.splice(index, 1);\r\n }\r\n\r\n this._numMeshes--;\r\n if (this._numMeshes > 0) {\r\n this._meshes[i] = this._meshes[this._numMeshes];\r\n this._impostors[i] = this._impostors[this._numMeshes];\r\n this._meshes[this._numMeshes] = null;\r\n this._impostors[this._numMeshes] = null;\r\n } else {\r\n this._meshes[0] = null;\r\n this._impostors[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numMeshes === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n }\r\n\r\n /**\r\n * Hides a body from the physics engine.\r\n * @param body - The body to hide.\r\n * @returns true if body actually removed\r\n *\r\n * This function is useful for hiding a body from the physics engine.\r\n * It removes the body from the utility layer scene and disposes the mesh associated with it.\r\n * It also unregisters the render function if the number of bodies is 0.\r\n * This is useful for hiding a body from the physics engine without deleting it.\r\n */\r\n public hideBody(body: Nullable<PhysicsBody>): boolean {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return false;\r\n }\r\n\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numBodies; i++) {\r\n if (this._bodies[i] === body) {\r\n const mesh = this._bodyMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._numBodies--;\r\n if (this._numBodies > 0) {\r\n this._bodyMeshes[i] = this._bodyMeshes[this._numBodies];\r\n this._bodies[i] = this._bodies[this._numBodies];\r\n this._bodyMeshes[this._numBodies] = null;\r\n this._bodies[this._numBodies] = null;\r\n } else {\r\n this._bodyMeshes[0] = null;\r\n this._bodies[0] = null;\r\n }\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._renderFunction);\r\n }\r\n return removed;\r\n }\r\n\r\n /**\r\n * Hides a body's inertia from the viewer utility layer\r\n * @param body the body to hide\r\n * @returns true if inertia actually removed\r\n */\r\n public hideInertia(body: Nullable<PhysicsBody>): boolean {\r\n if (!body || !this._scene || !this._utilityLayer) {\r\n return false;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n if (this._inertiaBodies[i] === body) {\r\n const mesh = this._inertiaMeshes[i];\r\n\r\n if (!mesh) {\r\n continue;\r\n }\r\n\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n\r\n this._inertiaBodies.splice(i, 1);\r\n this._inertiaMeshes.splice(i, 1);\r\n\r\n this._numInertiaBodies--;\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numInertiaBodies === 0) {\r\n this._scene.unregisterBeforeRender(this._inertiaRenderFunction);\r\n }\r\n return removed;\r\n }\r\n\r\n /**\r\n * Hide a physics constraint from the viewer utility layer\r\n * @param constraint the constraint to hide\r\n */\r\n public hideConstraint(constraint: Nullable<PhysicsConstraint>) {\r\n if (!constraint || !this._scene || !this._utilityLayer) {\r\n return;\r\n }\r\n let removed = false;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n for (let i = 0; i < this._numConstraints; i++) {\r\n if (this._constraints[i] === constraint) {\r\n const meshes = this._constraintMeshes[i];\r\n\r\n if (!meshes) {\r\n continue;\r\n }\r\n\r\n for (const mesh of meshes) {\r\n utilityLayerScene.removeMesh(mesh);\r\n mesh.dispose();\r\n }\r\n\r\n this._constraints.splice(i, 1);\r\n this._constraintMeshes.splice(i, 1);\r\n\r\n this._numConstraints--;\r\n\r\n if (this._numConstraints > 0) {\r\n this._constraints[i] = this._constraints[this._numConstraints];\r\n this._constraintMeshes[i] = this._constraintMeshes[this._numConstraints];\r\n this._constraints[this._numConstraints] = null;\r\n this._constraintMeshes[this._numConstraints] = null;\r\n } else {\r\n this._constraints[0] = null;\r\n this._constraintMeshes[0] = null;\r\n }\r\n\r\n removed = true;\r\n break;\r\n }\r\n }\r\n\r\n if (removed && this._numConstraints === 0) {\r\n this._scene.unregisterBeforeRender(this._constraintRenderFunction);\r\n }\r\n }\r\n\r\n private _getDebugMaterial(scene: Scene): Material {\r\n if (!this._debugMaterial) {\r\n this._debugMaterial = new StandardMaterial(\"\", scene);\r\n this._debugMaterial.wireframe = true;\r\n this._debugMaterial.emissiveColor = Color3.White();\r\n this._debugMaterial.disableLighting = true;\r\n }\r\n\r\n return this._debugMaterial;\r\n }\r\n\r\n private _getDebugInertiaMaterial(scene: Scene): Material {\r\n if (!this._debugInertiaMaterial) {\r\n this._debugInertiaMaterial = new StandardMaterial(\"\", scene);\r\n this._debugInertiaMaterial.disableLighting = true;\r\n this._debugInertiaMaterial.alpha = 0.0;\r\n }\r\n\r\n return this._debugInertiaMaterial;\r\n }\r\n\r\n private _getDebugAxisColoredMaterial(axisNumber: number, scene: Scene): Material {\r\n const material = new StandardMaterial(\"\", scene);\r\n material.emissiveColor = axisNumber == 0 ? Color3.Red() : axisNumber == 1 ? Color3.Green() : Color3.Blue();\r\n material.disableLighting = true;\r\n return material;\r\n }\r\n\r\n private _getDebugBoxMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugBoxMesh) {\r\n this._debugBoxMesh = CreateBox(\"physicsBodyBoxViewMesh\", { size: 1 }, scene);\r\n this._debugBoxMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugBoxMesh.material = this._getDebugMaterial(scene);\r\n this._debugBoxMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugBoxMesh.createInstance(\"physicsBodyBoxViewInstance\");\r\n }\r\n\r\n private _getDebugSphereMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugSphereMesh) {\r\n this._debugSphereMesh = CreateSphere(\"physicsBodySphereViewMesh\", { diameter: 1 }, scene);\r\n this._debugSphereMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugSphereMesh.material = this._getDebugMaterial(scene);\r\n this._debugSphereMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugSphereMesh.createInstance(\"physicsBodySphereViewInstance\");\r\n }\r\n\r\n private _getDebugCapsuleMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCapsuleMesh) {\r\n this._debugCapsuleMesh = CreateCapsule(\"physicsBodyCapsuleViewMesh\", { height: 1 } as ICreateCapsuleOptions, scene);\r\n this._debugCapsuleMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCapsuleMesh.material = this._getDebugMaterial(scene);\r\n this._debugCapsuleMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCapsuleMesh.createInstance(\"physicsBodyCapsuleViewInstance\");\r\n }\r\n\r\n private _getDebugCylinderMesh(scene: Scene): AbstractMesh {\r\n if (!this._debugCylinderMesh) {\r\n this._debugCylinderMesh = CreateCylinder(\"physicsBodyCylinderViewMesh\", { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);\r\n this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();\r\n this._debugCylinderMesh.material = this._getDebugMaterial(scene);\r\n this._debugCylinderMesh.setEnabled(false);\r\n }\r\n\r\n return this._debugCylinderMesh.createInstance(\"physicsBodyCylinderViewInstance\");\r\n }\r\n\r\n private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {\r\n const wireframeOver = new Mesh(mesh.name, scene, null, mesh);\r\n wireframeOver.setParent(mesh);\r\n wireframeOver.position = Vector3.Zero();\r\n wireframeOver.material = this._getDebugMaterial(scene);\r\n\r\n this._debugMeshMeshes.push(wireframeOver);\r\n\r\n return wireframeOver;\r\n }\r\n\r\n private _getDebugMesh(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n // Only create child impostor debug meshes when evaluating the parent\r\n if (targetMesh && targetMesh.parent && (targetMesh.parent as Mesh).physicsImpostor) {\r\n return null;\r\n }\r\n\r\n let mesh: Nullable<AbstractMesh> = null;\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n if (!impostor.physicsBody) {\r\n Logger.Warn(\"Unable to get physicsBody of impostor. It might be initialized later by its parent's impostor.\");\r\n return null;\r\n }\r\n switch (impostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n impostor.getBoxSizeToRef(mesh.scaling);\r\n break;\r\n case PhysicsImpostor.SphereImpostor: {\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n const radius = impostor.getRadius();\r\n mesh.scaling.x = radius * 2;\r\n mesh.scaling.y = radius * 2;\r\n mesh.scaling.z = radius * 2;\r\n break;\r\n }\r\n case PhysicsImpostor.CapsuleImpostor: {\r\n mesh = this._getDebugCapsuleMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * 2 * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * 2 * impostor.object.scaling.z;\r\n break;\r\n }\r\n case PhysicsImpostor.MeshImpostor:\r\n if (targetMesh) {\r\n mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);\r\n }\r\n break;\r\n case PhysicsImpostor.NoImpostor:\r\n if (targetMesh) {\r\n // Handle compound impostors\r\n const childMeshes = targetMesh.getChildMeshes().filter((c) => {\r\n return c.physicsImpostor ? 1 : 0;\r\n });\r\n for (const m of childMeshes) {\r\n if (m.physicsImpostor && m.getClassName() === \"Mesh\") {\r\n const boundingInfo = m.getBoundingInfo();\r\n const min = boundingInfo.boundingBox.minimum;\r\n const max = boundingInfo.boundingBox.maximum;\r\n switch (m.physicsImpostor.type) {\r\n case PhysicsImpostor.BoxImpostor:\r\n mesh = this._getDebugBoxMesh(utilityLayerScene);\r\n mesh.position.copyFrom(min);\r\n mesh.position.addInPlace(max);\r\n mesh.position.scaleInPlace(0.5);\r\n break;\r\n case PhysicsImpostor.SphereImpostor:\r\n mesh = this._getDebugSphereMesh(utilityLayerScene);\r\n break;\r\n case PhysicsImpostor.CylinderImpostor:\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n break;\r\n default:\r\n mesh = null;\r\n break;\r\n }\r\n if (mesh) {\r\n mesh.scaling.x = max.x - min.x;\r\n mesh.scaling.y = max.y - min.y;\r\n mesh.scaling.z = max.z - min.z;\r\n mesh.parent = m;\r\n }\r\n }\r\n }\r\n } else {\r\n Logger.Warn(\"No target mesh parameter provided for NoImpostor. Skipping.\");\r\n }\r\n mesh = null;\r\n break;\r\n case PhysicsImpostor.CylinderImpostor: {\r\n mesh = this._getDebugCylinderMesh(utilityLayerScene);\r\n const bi = impostor.object.getBoundingInfo();\r\n mesh.scaling.x = (bi.boundingBox.maximum.x - bi.boundingBox.minimum.x) * impostor.object.scaling.x;\r\n mesh.scaling.y = (bi.boundingBox.maximum.y - bi.boundingBox.minimum.y) * impostor.object.scaling.y;\r\n mesh.scaling.z = (bi.boundingBox.maximum.z - bi.boundingBox.minimum.z) * impostor.object.scaling.z;\r\n break;\r\n }\r\n }\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Creates a debug mesh for a given physics body\r\n * @param body The physics body to create the debug mesh for\r\n * @returns The created debug mesh or null if the utility layer is not available\r\n *\r\n * This code is useful for creating a debug mesh for a given physics body.\r\n * It creates a Mesh object with a VertexData object containing the positions and indices\r\n * of the geometry of the body. The mesh is then assigned a debug material from the utility layer scene.\r\n * This allows for visualizing the physics body in the scene.\r\n */\r\n private _getDebugBodyMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n const mesh = new Mesh(\"custom\", utilityLayerScene);\r\n const vertexData = new VertexData();\r\n const geometry = body.getGeometry() as any;\r\n vertexData.positions = geometry.positions;\r\n vertexData.indices = geometry.indices;\r\n vertexData.applyToMesh(mesh);\r\n if (body._pluginDataInstances) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n mesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n }\r\n mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n private _getMeshDebugInertiaMatrixToRef(massProps: PhysicsMassProperties, matrix: Matrix) {\r\n const orientation = massProps.inertiaOrientation ?? Quaternion.Identity();\r\n const inertiaLocal = massProps.inertia ?? Vector3.Zero();\r\n const center = massProps.centerOfMass ?? Vector3.Zero();\r\n\r\n const betaSqrd = (inertiaLocal.x - inertiaLocal.y + inertiaLocal.z) * 6;\r\n const beta = Math.sqrt(Math.max(betaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const gammaSqrd = inertiaLocal.x * 12 - betaSqrd;\r\n const gamma = Math.sqrt(Math.max(gammaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const alphaSqrd = inertiaLocal.z * 12 - betaSqrd;\r\n const alpha = Math.sqrt(Math.max(alphaSqrd, 0)); // Safety check for zeroed elements!\r\n\r\n const extents = TmpVectors.Vector3[0];\r\n extents.set(alpha, beta, gamma);\r\n\r\n const scaling = Matrix.ScalingToRef(extents.x, extents.y, extents.z, TmpVectors.Matrix[0]);\r\n const rotation = orientation.toRotationMatrix(TmpVectors.Matrix[1]);\r\n const translation = Matrix.TranslationToRef(center.x, center.y, center.z, TmpVectors.Matrix[2]);\r\n\r\n scaling.multiplyToRef(rotation, matrix);\r\n matrix.multiplyToRef(translation, matrix);\r\n\r\n return matrix;\r\n }\r\n\r\n private _getDebugInertiaMesh(body: PhysicsBody): Nullable<AbstractMesh> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n // The base inertia mesh is going to be a 1x1 cube that's scaled and rotated according to the inertia\r\n const inertiaBoxMesh = MeshBuilder.CreateBox(\"custom\", { size: 1 }, utilityLayerScene);\r\n const matrixRef = Matrix.Identity();\r\n if (body._pluginDataInstances.length) {\r\n const instanceBuffer = new Float32Array(body._pluginDataInstances.length * 16);\r\n for (let i = 0; i < body._pluginDataInstances.length; ++i) {\r\n const props = body.getMassProperties(i);\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.copyToArray(instanceBuffer, i * 16);\r\n }\r\n inertiaBoxMesh.thinInstanceSetBuffer(\"matrix\", instanceBuffer, 16, false);\r\n } else {\r\n const props = body.getMassProperties();\r\n this._getMeshDebugInertiaMatrixToRef(props, matrixRef);\r\n matrixRef.decomposeToTransformNode(inertiaBoxMesh);\r\n }\r\n inertiaBoxMesh.enableEdgesRendering();\r\n inertiaBoxMesh.edgesWidth = 2.0;\r\n inertiaBoxMesh.edgesColor = new Color4(1, 0, 1, 1);\r\n inertiaBoxMesh.material = this._getDebugInertiaMaterial(utilityLayerScene);\r\n\r\n return inertiaBoxMesh;\r\n }\r\n\r\n private _getTransformFromBodyToRef(body: PhysicsBody, matrix: Matrix, instanceIndex?: number) {\r\n const tnode = body.transformNode;\r\n if (instanceIndex && instanceIndex >= 0) {\r\n return Matrix.FromArrayToRef((tnode as Mesh)._thinInstanceDataStorage.matrixData!, instanceIndex, matrix);\r\n } else {\r\n return matrix.copyFrom(tnode.getWorldMatrix());\r\n }\r\n }\r\n\r\n private _createAngularConstraintMesh(minLimit: number, maxLimit: number, axisNumber: number, childBody: PhysicsBody, childBodyIndex: number, scene: Scene): AbstractMesh {\r\n const arcAngle = (maxLimit - minLimit) / (Math.PI * 2);\r\n const mesh = MeshBuilder.CreateCylinder(\"ConstraintCylinder\", { height: 0.0001, diameter: 3 * this._constraintAngularSize, arc: arcAngle }, scene);\r\n mesh.material = this._getDebugAxisColoredMaterial(axisNumber, scene);\r\n mesh.metadata = { childBody, childBodyIndex, axisNumber, minLimit };\r\n mesh.rotationQuaternion = Quaternion.Identity();\r\n switch (axisNumber) {\r\n case 0:\r\n mesh.rotation.z = Math.PI * 0.5;\r\n mesh.rotation.x = -minLimit + Math.PI * 0.5;\r\n break;\r\n case 1:\r\n mesh.rotation.y = Math.PI * 1.5 + minLimit;\r\n break;\r\n case 2:\r\n mesh.rotation.x = Math.PI * 0.5;\r\n break;\r\n }\r\n return mesh;\r\n }\r\n\r\n private _createCage(parent: TransformNode, scene: Scene): AbstractMesh {\r\n const cage = MeshBuilder.CreateBox(\"cage\", { size: 1 }, scene);\r\n cage.setPivotPoint(new Vector3(-0.5, -0.5, -0.5));\r\n const transparentMaterial = new StandardMaterial(\"cage_material\", scene);\r\n transparentMaterial.alpha = 0; // Fully transparent\r\n cage.material = transparentMaterial;\r\n\r\n cage.enableEdgesRendering();\r\n cage.edgesWidth = 4.0;\r\n cage.edgesColor = new Color4(1, 1, 1, 1);\r\n cage.parent = parent;\r\n return cage;\r\n }\r\n\r\n private _getDebugConstraintMesh(constraint: PhysicsConstraint): Nullable<Array<AbstractMesh>> {\r\n if (!this._utilityLayer) {\r\n return null;\r\n }\r\n const utilityLayerScene = this._utilityLayer.utilityLayerScene;\r\n\r\n if (!constraint._initOptions) {\r\n return null;\r\n }\r\n\r\n // Get constraint pivot and axes\r\n const { pivotA, pivotB, axisA, axisB, perpAxisA, perpAxisB } = constraint._initOptions;\r\n\r\n if (!pivotA || !pivotB || !axisA || !axisB || !perpAxisA || !perpAxisB) {\r\n return null;\r\n }\r\n\r\n // Create a mesh to parent all the constraint debug meshes to\r\n const parentingMesh = new Mesh(\"parentingDebugConstraint\", utilityLayerScene);\r\n\r\n // First, get a reference to all physic bodies that are using this constraint\r\n const bodiesUsingConstraint = constraint.getBodiesUsingConstraint();\r\n\r\n const parentedConstraintMeshes = [];\r\n parentedConstraintMeshes.push(parentingMesh);\r\n\r\n // Create a container for angular constraint meshes\r\n const angularConstraintContainer = new TransformNode(\"angularConstraintContainer\", utilityLayerScene);\r\n angularConstraintContainer.parent = parentingMesh;\r\n\r\n for (const bodyPairInfo of bodiesUsingConstraint) {\r\n // Create a mesh to keep the pair of constraint axes\r\n const parentOfPair = new TransformNode(\"parentOfPair\", utilityLayerScene);\r\n parentOfPair.parent = parentingMesh;\r\n\r\n const { parentBody, parentBodyIndex, childBody, childBodyIndex } = bodyPairInfo;\r\n // Get the parent transform\r\n\r\n const parentTransform = this._getTransformFromBodyToRef(parentBody, TmpVectors.Matrix[0], parentBodyIndex);\r\n const childTransform = this._getTransformFromBodyToRef(childBody, TmpVectors.Matrix[1], childBodyIndex);\r\n\r\n const parentCoordSystemNode = new TransformNode(\"parentCoordSystem\", utilityLayerScene);\r\n // parentCoordSystemNode.parent = parentingMesh;\r\n parentCoordSystemNode.parent = parentOfPair;\r\n // Save parent and index here to be able to get the transform on update\r\n parentCoordSystemNode.metadata = { parentBody, parentBodyIndex };\r\n parentTransform.decomposeToTransformNode(parentCoordSystemNode);\r\n\r\n const childCoordSystemNode = new TransformNode(\"childCoordSystem\", utilityLayerScene);\r\n // childCoordSystemNode.parent = parentingMesh;\r\n childCoordSystemNode.parent = parentOfPair;\r\n // Save child and index here to be able to get the transform on update\r\n childCoordSystemNode.metadata = { childBody, childBodyIndex };\r\n childTransform.decomposeToTransformNode(childCoordSystemNode);\r\n\r\n // Get the transform to align the XYZ axes to the constraint axes\r\n const rotTransformParent = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisA, perpAxisA, axisA.cross(perpAxisA), TmpVectors.Matrix[0]));\r\n const rotTransformChild = Quaternion.FromRotationMatrix(Matrix.FromXYZAxesToRef(axisB, perpAxisB, axisB.cross(perpAxisB), TmpVectors.Matrix[0]));\r\n\r\n const translateTransformParent = pivotA;\r\n const translateTransformChild = pivotB;\r\n\r\n // Create a transform node and set its matrix\r\n const parentTransformNode = new TransformNode(\"constraint_parent\", utilityLayerScene);\r\n parentTransformNode.position.copyFrom(translateTransformParent);\r\n parentTransformNode.rotationQuaternion = rotTransformParent;\r\n parentTransformNode.parent = parentCoordSystemNode;\r\n\r\n const childTransformNode = new TransformNode(\"constraint_child\", utilityLayerScene);\r\n childTransformNode.parent = childCoordSystemNode;\r\n childTransformNode.position.copyFrom(translateTransformChild);\r\n childTransformNode.rotationQuaternion = rotTransformChild;\r\n\r\n // Create axes for the constraint\r\n const parentAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n parentAxes.xAxis.parent = parentTransformNode;\r\n parentAxes.yAxis.parent = parentTransformNode;\r\n parentAxes.zAxis.parent = parentTransformNode;\r\n\r\n const childAxes = new AxesViewer(utilityLayerScene, this._constraintAxesSize);\r\n childAxes.xAxis.parent = childTransformNode;\r\n childAxes.yAxis.parent = childTransformNode;\r\n childAxes.zAxis.parent = childTransformNode;\r\n\r\n // constrain vis\r\n const engine = this._physicsEnginePlugin! as IPhysicsEnginePluginV2;\r\n\r\n const constraintAxisAngular = [PhysicsConstraintAxis.ANGULAR_X, PhysicsConstraintAxis.ANGULAR_Y, PhysicsConstraintAxis.ANGULAR_Z];\r\n const constraintAxisLinear = [PhysicsConstraintAxis.LINEAR_X, PhysicsConstraintAxis.LINEAR_Y, PhysicsConstraintAxis.LINEAR_Z];\r\n const constraintAxis = [constraintAxisAngular, constraintAxisLinear];\r\n\r\n // count axis. Angular and Linear\r\n const lockCount = [0, 0];\r\n for (let angularLinear = 0; angularLinear < 2; angularLinear++) {\r\n for (let axis = 0; axis < 3; axis++) {\r\n const constraintAxisValue = constraintAxis[angularLinear][axis];\r\n const axisMode = engine.getAxisMode(constraint, constraintAxisValue);\r\n if (axisMode == PhysicsConstraintAxisLimitMode.LOCKED) {\r\n lockCount[angularLinear]++;\r\n }\r\n }\r\n }\r\n\r\n // Any free/limited Linear axis\r\n if (lockCount[1] != 3) {\r\n const cage = this._createCage(parentTransformNode, utilityLayerScene);\r\n\r\n const min = TmpVectors.Vector3[0];\r\n const max = TmpVectors.Vector3[1];\r\n const limited = [false, false, false];\r\n\r\n limited[0] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_X) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n limited[1] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_Y) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n limited[2] = engine.getAxisMode(constraint, PhysicsConstraintAxis.LINEAR_Z) == PhysicsConstraintAxisLimitMode.LIMITED;\r\n\r\n min.x = limited[0] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_X)! : 0;\r\n max.x = limited[0] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_X)! : 0;\r\n min.y = limited[1] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_Y)! : 0;\r\n max.y = limited[1] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_Y)! : 0;\r\n min.z = limited[2] ? engine.getAxisMinLimit(constraint, PhysicsConstraintAxis.LINEAR_Z)! : 0;\r\n max.z = limited[2] ? engine.getAxisMaxLimit(constraint, PhysicsConstraintAxis.LINEAR_Z)! : 0;\r\n\r\n cage.position.x = min.x + 0.5;\r\n cage.position.y = min.y + 0.5;\r\n cage.position.z = min.z + 0.5;\r\n\r\n cage.scaling.x = max.x - min.x + Epsilon;\r\n cage.scaling.y = max.y - min.y + Epsilon;\r\n cage.scaling.z = max.z - min.z + Epsilon;\r\n parentedConstraintMeshes.push(cage);\r\n }\r\n\r\n // Angular\r\n if (lockCount[0] != 3) {\r\n for (let axisIndex = 0; axisIndex < 3; axisIndex++) {\r\n const axis = constraintAxisAngular[axisIndex];\r\n const axisMode = engine.getAxisMode(constraint, axis);\r\n let minLimit = 0;\r\n let maxLimit = Math.PI * 2;\r\n if (axisMode == PhysicsConstraintAxisLimitMode.LIMITED) {\r\n minLimit = engine.getAxisMinLimit(constraint, axis)!;\r\n maxLimit = engine.getAxisMaxLimit(constraint, axis)!;\r\n }\r\n if (axisMode != PhysicsConstraintAxisLimitMode.LOCKED && constraint.options.pivotB) {\r\n const mesh = this._createAngularConstraintMesh(minLimit, maxLimit, axisIndex, childBody, childBodyIndex, utilityLayerScene);\r\n mesh.parent = angularConstraintContainer;\r\n mesh.position.copyFrom(constraint.options.pivotB);\r\n parentedConstraintMeshes.push(mesh);\r\n }\r\n }\r\n }\r\n }\r\n\r\n return parentedConstraintMeshes;\r\n }\r\n\r\n /**\r\n * Clean up physics debug display\r\n */\r\n public dispose() {\r\n // impostors\r\n for (let index = this._numMeshes - 1; index >= 0; index--) {\r\n this.hideImpostor(this._impostors[0]);\r\n }\r\n // bodies\r\n for (let index = this._numBodies - 1; index >= 0; index--) {\r\n this.hideBody(this._bodies[0]);\r\n }\r\n // inertia\r\n for (let index = this._numInertiaBodies - 1; index >= 0; index--) {\r\n this.hideInertia(this._inertiaBodies[0]);\r\n }\r\n\r\n for (let index = this._numConstraints - 1; index >= 0; index--) {\r\n this.hideConstraint(this._constraints[0]);\r\n }\r\n\r\n if (this._debugBoxMesh) {\r\n this._debugBoxMesh.dispose();\r\n }\r\n if (this._debugSphereMesh) {\r\n this._debugSphereMesh.dispose();\r\n }\r\n if (this._debugCylinderMesh) {\r\n this._debugCylinderMesh.dispose();\r\n }\r\n if (this._debugMaterial) {\r\n this._debugMaterial.dispose();\r\n }\r\n\r\n this._impostors.length = 0;\r\n this._scene = null;\r\n this._physicsEnginePlugin = null;\r\n\r\n if (this._ownUtilityLayer && this._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -62,6 +62,7 @@ export declare class PhysicsBody {
|
|
|
62
62
|
private _isDisposed;
|
|
63
63
|
private _shape;
|
|
64
64
|
private _prestepType;
|
|
65
|
+
private _isAttached;
|
|
65
66
|
/**
|
|
66
67
|
* Constructs a new physics body for the given node.
|
|
67
68
|
* @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.
|
|
@@ -55,6 +55,7 @@ export class PhysicsBody {
|
|
|
55
55
|
this._isDisposed = false;
|
|
56
56
|
this._shape = null;
|
|
57
57
|
this._prestepType = PhysicsPrestepType.DISABLED;
|
|
58
|
+
this._isAttached = false;
|
|
58
59
|
if (!scene) {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
@@ -92,28 +93,33 @@ export class PhysicsBody {
|
|
|
92
93
|
}
|
|
93
94
|
//Attach the body to the physics engine
|
|
94
95
|
attach() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
else {
|
|
101
|
-
// single instance
|
|
102
|
-
if (this.transformNode.parent) {
|
|
103
|
-
// Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.
|
|
104
|
-
this.transformNode.computeWorldMatrix(true);
|
|
96
|
+
if (!this._isAttached) {
|
|
97
|
+
// instances?
|
|
98
|
+
const m = this.transformNode;
|
|
99
|
+
if (m.hasThinInstances) {
|
|
100
|
+
this._physicsPlugin.initBodyInstances(this, this._motionType, m);
|
|
105
101
|
}
|
|
106
|
-
|
|
102
|
+
else {
|
|
103
|
+
// single instance
|
|
104
|
+
if (this.transformNode.parent) {
|
|
105
|
+
// Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.
|
|
106
|
+
this.transformNode.computeWorldMatrix(true);
|
|
107
|
+
}
|
|
108
|
+
this._physicsPlugin.initBody(this, this._motionType, this.transformNode.absolutePosition, this.transformNode.absoluteRotationQuaternion);
|
|
109
|
+
}
|
|
110
|
+
this.transformNode.physicsBody = this;
|
|
111
|
+
this._physicsEngine.addBody(this);
|
|
112
|
+
this._isAttached = true;
|
|
107
113
|
}
|
|
108
|
-
this.transformNode.physicsBody = this;
|
|
109
|
-
this._physicsEngine.addBody(this);
|
|
110
114
|
}
|
|
111
115
|
//Detach the body from the physics engine
|
|
112
116
|
detach() {
|
|
113
|
-
this.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
if (this._isAttached) {
|
|
118
|
+
this._physicsEngine.removeBody(this);
|
|
119
|
+
this._physicsPlugin.removeBody(this);
|
|
120
|
+
this.transformNode.physicsBody = null;
|
|
121
|
+
this._isAttached = false;
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
/**
|
|
119
125
|
* Clone the PhysicsBody to a new body and assign it to the transformNode parameter
|
|
@@ -633,6 +639,7 @@ export class PhysicsBody {
|
|
|
633
639
|
this._nodeDisposeObserver = null;
|
|
634
640
|
}
|
|
635
641
|
this.detach();
|
|
642
|
+
this._physicsPlugin.disposeBody(this);
|
|
636
643
|
this._pluginData = null;
|
|
637
644
|
this._pluginDataInstances.length = 0;
|
|
638
645
|
this._isDisposed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,kBAAkB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAED,IAAW,cAAc,CAAC,KAAc;QACpC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC;IAC1F,CAAC;IAmBD;;;;;;;;;;;;;OAaG;IACH,YACI,aAA4B,EACpB,WAA8B,EACtC,YAAqB,EACrB,KAAY;QAFJ,gBAAW,GAAX,WAAW,CAAmB;QA1E1C;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAS7C;;WAEG;QACK,wBAAmB,GAAY,KAAK,CAAC;QAC7C;;WAEG;QACK,6BAAwB,GAAY,KAAK,CAAC;QAkBlD;;WAEG;QACH,gBAAW,GAAY,KAAK,CAAC;QASrB,gBAAW,GAAG,KAAK,CAAC;QAEpB,WAAM,GAA2B,IAAI,CAAC;QAEtC,iBAAY,GAAuB,kBAAkB,CAAC,QAAQ,CAAC;QAqBnE,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,OAAO;QACX,CAAC;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAA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C,CAAC;IACpF,CAAC;IAED;;;OAGG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;QACX,CAAC;QACD,qEAAqE;QACrE,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import {\r\n type IBasePhysicsCollisionEvent,\r\n type IPhysicsCollisionEvent,\r\n type IPhysicsEnginePluginV2,\r\n type PhysicsMassProperties,\r\n PhysicsMotionType,\r\n PhysicsPrestepType,\r\n} from \"./IPhysicsEnginePlugin\";\r\nimport { type PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type PhysicsEngine } from \"./physicsEngine\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type PhysicsConstraint } from \"./physicsConstraint\";\r\nimport { type Bone } from \"../../Bones/bone\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\nimport { type Observable, type Observer } from \"../../Misc/observable\";\r\nimport { type Node } from \"../../node\";\r\nimport { type Mesh } from \"../../Meshes/mesh\";\r\nimport { type AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { type TransformNode } from \"../../Meshes/transformNode\";\r\nimport { type BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param _motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(\r\n transformNode: TransformNode,\r\n private _motionType: PhysicsMotionType,\r\n startsAsleep: boolean,\r\n scene: Scene\r\n ) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = this._motionType == PhysicsMotionType.STATIC;\r\n\r\n this.transformNode = transformNode;\r\n\r\n this.attach();\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n //Attach the body to the physics engine\r\n public attach() {\r\n // instances?\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, this._motionType, m);\r\n } else {\r\n // single instance\r\n if (this.transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n this.transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, this._motionType, this.transformNode.absolutePosition, this.transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode.physicsBody = this;\r\n this._physicsEngine.addBody(this);\r\n }\r\n\r\n //Detach the body from the physics engine\r\n public detach() {\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for. If body is instanced but instanceIndex is undefined, the motion type will be set for all instances.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = instanceIndex === undefined && motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a torque to the physics body.\r\n *\r\n * @param torque The torque vector.\r\n * @param instanceIndex For a instanced body, the instance to where the torque should be applied. If not specified, the torque is applied to all instances.\r\n *\r\n * This method is useful for applying a torque to a physics body, which can be used to simulate rotational forces such as motors,\r\n * angular momentum, and rotational dynamics. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyTorque(torque: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyTorque(this, torque, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(instanceIndex?: number): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionEndedObservable(instanceIndex?: number): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.detach();\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,kBAAkB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc1E;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,YAAY,IAAI,kBAAkB,CAAC,QA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C;QACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,CAAC,gCAAgC,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import {\r\n type IBasePhysicsCollisionEvent,\r\n type IPhysicsCollisionEvent,\r\n type IPhysicsEnginePluginV2,\r\n type PhysicsMassProperties,\r\n PhysicsMotionType,\r\n PhysicsPrestepType,\r\n} from \"./IPhysicsEnginePlugin\";\r\nimport { type PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type PhysicsEngine } from \"./physicsEngine\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { type PhysicsConstraint } from \"./physicsConstraint\";\r\nimport { type Bone } from \"../../Bones/bone\";\r\nimport { Space } from \"../../Maths/math.axis\";\r\nimport { type Observable, type Observer } from \"../../Misc/observable\";\r\nimport { type Node } from \"../../node\";\r\nimport { type Mesh } from \"../../Meshes/mesh\";\r\nimport { type AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport { type TransformNode } from \"../../Meshes/transformNode\";\r\nimport { type BoundingBox } from \"../../Culling/boundingBox\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n public get disablePreStep(): boolean {\r\n return this._prestepType == PhysicsPrestepType.DISABLED;\r\n }\r\n\r\n public set disablePreStep(value: boolean) {\r\n this._prestepType = value ? PhysicsPrestepType.DISABLED : PhysicsPrestepType.TELEPORT;\r\n }\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _prestepType: PhysicsPrestepType = PhysicsPrestepType.DISABLED;\r\n private _isAttached = false;\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param _motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(\r\n transformNode: TransformNode,\r\n private _motionType: PhysicsMotionType,\r\n startsAsleep: boolean,\r\n scene: Scene\r\n ) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n // only dynamic and animated body needs sync from physics to transformNode\r\n this.disableSync = this._motionType == PhysicsMotionType.STATIC;\r\n\r\n this.transformNode = transformNode;\r\n\r\n this.attach();\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n //Attach the body to the physics engine\r\n public attach() {\r\n if (!this._isAttached) {\r\n // instances?\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, this._motionType, m);\r\n } else {\r\n // single instance\r\n if (this.transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n this.transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, this._motionType, this.transformNode.absolutePosition, this.transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode.physicsBody = this;\r\n this._physicsEngine.addBody(this);\r\n this._isAttached = true;\r\n }\r\n }\r\n\r\n //Detach the body from the physics engine\r\n public detach() {\r\n if (this._isAttached) {\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._isAttached = false;\r\n }\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this);\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Returns the bounding box of the physics body.\r\n * @returns The bounding box of the physics body.\r\n */\r\n public getBoundingBox(): BoundingBox {\r\n return this._physicsPlugin.getBodyBoundingBox(this);\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for. If body is instanced but instanceIndex is undefined, the motion type will be set for all instances.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = instanceIndex === undefined && motionType == PhysicsMotionType.STATIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the prestep type of the body\r\n * @param prestepType prestep type provided by PhysicsPrestepType\r\n */\r\n public setPrestepType(prestepType: PhysicsPrestepType): void {\r\n this._prestepType = prestepType;\r\n }\r\n\r\n /**\r\n * Get the current prestep type of the body\r\n * @returns the type of prestep associated with the body and its instance index\r\n */\r\n public getPrestepType(): PhysicsPrestepType {\r\n return this._prestepType;\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a torque to the physics body.\r\n *\r\n * @param torque The torque vector.\r\n * @param instanceIndex For a instanced body, the instance to where the torque should be applied. If not specified, the torque is applied to all instances.\r\n *\r\n * This method is useful for applying a torque to a physics body, which can be used to simulate rotational forces such as motors,\r\n * angular momentum, and rotational dynamics. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyTorque(torque: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyTorque(this, torque, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): object {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(instanceIndex?: number): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @param instanceIndex - optionally, the index of the instance in the body\r\n * @returns Observable\r\n */\r\n public getCollisionEndedObservable(instanceIndex?: number): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this.detach();\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
|