@babylonjs/core 6.14.0 → 6.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,6 +143,10 @@ export class PhysicsViewer {
143
143
  this._getMeshDebugInertiaMatrixToRef(props, inertiaMatrixRef);
144
144
  (_a = body.transformNode.rotationQuaternion) === null || _a === void 0 ? void 0 : _a.toRotationMatrix(transformMatrixRef);
145
145
  transformMatrixRef.setTranslation(body.transformNode.position);
146
+ if (body.transformNode.parent) {
147
+ const parentTransform = body.transformNode.parent.computeWorldMatrix(true);
148
+ transformMatrixRef.multiplyToRef(parentTransform, transformMatrixRef);
149
+ }
146
150
  inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);
147
151
  inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);
148
152
  }
@@ -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,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAm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E;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;SAChC;QACD,IAAI,IAAI,CAAC,gBAAgB,EAAE;YACvB,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;SACnC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;SACrC;QACD,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SACjC;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,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;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 type { IPhysicsEnginePluginV2, 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 } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { 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\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 protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\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 _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\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 /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\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 this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\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; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\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 inertiaMatrixRef.multiplyToRef(transformMatrixRef, inertiaMatrixRef);\r\n inertiaMatrixRef.decomposeToTransformNode(inertiaMesh);\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.bind(this);\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.bind(this);\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\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.bind(this);\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 * 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 *\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>) {\r\n if (!body || !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._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 }\r\n\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !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._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 }\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 _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 childMeshes.forEach((m) => {\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);\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);\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 /**\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._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;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,aAAa;IAiCtB;;;OAGG;IACH,YAAY,KAAa;QApCzB,gBAAgB;QACN,eAAU,GAAqC,EAAE,CAAC;QAC5D,gBAAgB;QACN,YAAO,GAAkC,EAAE,CAAC;QACtD,gBAAgB;QACN,YAAO,GAAiC,EAAE,CAAC;QAC3C,mBAAc,GAAiC,EAAE,CAAC;QAC5D,gBAAgB;QACN,gBAAW,GAAkC,EAAE,CAAC;QAC1D,gBAAgB;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,IAAI,IAAI,CAAC,cAAc,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;SACjC;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,aAAa,EAAE;YACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;SAC7B;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 type { IPhysicsEnginePluginV2, 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 } from \"../Meshes/Builders/capsuleBuilder\";\r\nimport { 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\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 protected _inertiaBodies: Array<Nullable<PhysicsBody>> = [];\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 _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _numBodies = 0;\r\n protected _numInertiaBodies = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => void;\r\n private _inertiaRenderFunction: () => void;\r\n private _utilityLayer: Nullable<UtilityLayerRenderer>;\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 /**\r\n * Creates a new PhysicsViewer\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(scene?: Scene) {\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 this._utilityLayer = new UtilityLayerRenderer(this._scene, false);\r\n this._utilityLayer.pickUtilitySceneFirst = false;\r\n this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;\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; i++) {\r\n const body = this._bodies[i];\r\n const transform = this._bodyMeshes[i];\r\n if (body && transform) {\r\n plugin.syncTransform(body, transform);\r\n }\r\n }\r\n }\r\n\r\n protected _updateInertiaMeshes(): void {\r\n for (let i = 0; i < this._numInertiaBodies; i++) {\r\n const body = this._inertiaBodies[i];\r\n const mesh = this._inertiaMeshes[i];\r\n if (body && mesh) {\r\n this._updateDebugInertia(body, mesh);\r\n }\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 /**\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.bind(this);\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.bind(this);\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\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.bind(this);\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 * 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 *\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>) {\r\n if (!body || !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._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 }\r\n\r\n public hideInertia(body: Nullable<PhysicsBody>) {\r\n if (!body || !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._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 }\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 _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 childMeshes.forEach((m) => {\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);\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);\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 /**\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._utilityLayer) {\r\n this._utilityLayer.dispose();\r\n this._utilityLayer = null;\r\n }\r\n }\r\n}\r\n"]}
@@ -169,10 +169,10 @@ export class NativeEngine extends Engine {
169
169
  colorBufferFloat: false,
170
170
  textureFloat: true,
171
171
  textureFloatLinearFiltering: false,
172
- textureFloatRender: false,
173
- textureHalfFloat: false,
174
- textureHalfFloatLinearFiltering: false,
175
- textureHalfFloatRender: false,
172
+ textureFloatRender: true,
173
+ textureHalfFloat: true,
174
+ textureHalfFloatLinearFiltering: true,
175
+ textureHalfFloatRender: true,
176
176
  textureLOD: true,
177
177
  texelFetch: false,
178
178
  drawBuffersExtension: false,
@@ -1464,13 +1464,14 @@ export class NativeEngine extends Engine {
1464
1464
  throw new Error("wrapWebGLTexture is not supported, use wrapNativeTexture instead.");
1465
1465
  }
1466
1466
  _createDepthStencilTexture(size, options, rtWrapper) {
1467
+ var _a, _b;
1467
1468
  // TODO: handle other options?
1468
1469
  const generateStencil = options.generateStencil || false;
1469
1470
  const samples = options.samples || 1;
1470
1471
  const nativeRTWrapper = rtWrapper;
1471
1472
  const texture = new InternalTexture(this, InternalTextureSource.DepthStencil);
1472
- const width = size.width || size;
1473
- const height = size.height || size;
1473
+ const width = (_a = size.width) !== null && _a !== void 0 ? _a : size;
1474
+ const height = (_b = size.height) !== null && _b !== void 0 ? _b : size;
1474
1475
  const framebuffer = this._engine.createFrameBuffer(texture._hardwareTexture.underlyingResource, width, height, generateStencil, true, samples);
1475
1476
  nativeRTWrapper._framebufferDepthStencil = framebuffer;
1476
1477
  return texture;
@@ -1650,7 +1651,7 @@ export class NativeEngine extends Engine {
1650
1651
  }
1651
1652
  /** @internal */
1652
1653
  _createInternalTexture(size, options, _delayGPUTextureCreation = true, source = InternalTextureSource.Unknown) {
1653
- var _a;
1654
+ var _a, _b, _c;
1654
1655
  let generateMipMaps = false;
1655
1656
  let type = 0;
1656
1657
  let samplingMode = 3;
@@ -1684,8 +1685,8 @@ export class NativeEngine extends Engine {
1684
1685
  Logger.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE");
1685
1686
  }
1686
1687
  const texture = new InternalTexture(this, source);
1687
- const width = size.width || size;
1688
- const height = size.height || size;
1688
+ const width = (_b = size.width) !== null && _b !== void 0 ? _b : size;
1689
+ const height = (_c = size.height) !== null && _c !== void 0 ? _c : size;
1689
1690
  const layers = size.layers || 0;
1690
1691
  if (layers !== 0) {
1691
1692
  throw new Error("Texture layers are not supported in Babylon Native");
@@ -1712,7 +1713,7 @@ export class NativeEngine extends Engine {
1712
1713
  return texture;
1713
1714
  }
1714
1715
  createRenderTargetTexture(size, options) {
1715
- var _a, _b;
1716
+ var _a, _b, _c, _d;
1716
1717
  const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size);
1717
1718
  let generateDepthBuffer = true;
1718
1719
  let generateStencilBuffer = false;
@@ -1727,8 +1728,8 @@ export class NativeEngine extends Engine {
1727
1728
  samples = (_b = options.samples) !== null && _b !== void 0 ? _b : 1;
1728
1729
  }
1729
1730
  const texture = colorAttachment || (noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget));
1730
- const width = size.width || size;
1731
- const height = size.height || size;
1731
+ const width = (_c = size.width) !== null && _c !== void 0 ? _c : size;
1732
+ const height = (_d = size.height) !== null && _d !== void 0 ? _d : size;
1732
1733
  const framebuffer = this._engine.createFrameBuffer(texture ? texture._hardwareTexture.underlyingResource : null, width, height, generateStencilBuffer, generateDepthBuffer, samples);
1733
1734
  rtWrapper._framebuffer = framebuffer;
1734
1735
  rtWrapper._generateDepthBuffer = generateDepthBuffer;