@babylonjs/core 5.40.1 → 5.41.0

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.
Files changed (47) hide show
  1. package/Debug/physicsViewer.d.ts +12 -0
  2. package/Debug/physicsViewer.js +45 -0
  3. package/Debug/physicsViewer.js.map +1 -1
  4. package/Engines/thinEngine.js +2 -2
  5. package/Engines/thinEngine.js.map +1 -1
  6. package/Gizmos/axisDragGizmo.d.ts +13 -1
  7. package/Gizmos/axisDragGizmo.js +22 -12
  8. package/Gizmos/axisDragGizmo.js.map +1 -1
  9. package/Gizmos/axisScaleGizmo.d.ts +13 -4
  10. package/Gizmos/axisScaleGizmo.js +23 -15
  11. package/Gizmos/axisScaleGizmo.js.map +1 -1
  12. package/Gizmos/boundingBoxGizmo.d.ts +8 -3
  13. package/Gizmos/boundingBoxGizmo.js +35 -30
  14. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  15. package/Gizmos/gizmo.d.ts +1 -1
  16. package/Gizmos/gizmo.js +3 -3
  17. package/Gizmos/gizmo.js.map +1 -1
  18. package/Gizmos/planeDragGizmo.d.ts +12 -0
  19. package/Gizmos/planeDragGizmo.js +12 -0
  20. package/Gizmos/planeDragGizmo.js.map +1 -1
  21. package/Gizmos/planeRotationGizmo.d.ts +12 -0
  22. package/Gizmos/planeRotationGizmo.js +12 -0
  23. package/Gizmos/planeRotationGizmo.js.map +1 -1
  24. package/Gizmos/scaleGizmo.d.ts +12 -0
  25. package/Gizmos/scaleGizmo.js +12 -0
  26. package/Gizmos/scaleGizmo.js.map +1 -1
  27. package/Materials/Textures/baseTexture.d.ts +2 -0
  28. package/Materials/Textures/baseTexture.js.map +1 -1
  29. package/Materials/material.d.ts +2 -0
  30. package/Materials/material.js.map +1 -1
  31. package/Physics/v2/IPhysicsEnginePlugin.d.ts +7 -3
  32. package/Physics/v2/IPhysicsEnginePlugin.js +1 -0
  33. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  34. package/Physics/v2/physicsBody.d.ts +11 -1
  35. package/Physics/v2/physicsBody.js +23 -2
  36. package/Physics/v2/physicsBody.js.map +1 -1
  37. package/Physics/v2/physicsEngine.d.ts +15 -4
  38. package/Physics/v2/physicsEngine.js +23 -8
  39. package/Physics/v2/physicsEngine.js.map +1 -1
  40. package/Physics/v2/physicsShape.d.ts +1 -1
  41. package/Physics/v2/physicsShape.js +3 -3
  42. package/Physics/v2/physicsShape.js.map +1 -1
  43. package/XR/features/WebXRControllerTeleportation.js +2 -0
  44. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  45. package/node.d.ts +2 -0
  46. package/node.js.map +1 -1
  47. package/package.json +1 -1
@@ -5,6 +5,7 @@ import { Mesh } from "../Meshes/mesh";
5
5
  import type { IPhysicsEnginePlugin as IPhysicsEnginePluginV1 } from "../Physics/v1/IPhysicsEnginePlugin";
6
6
  import type { IPhysicsEnginePluginV2 } from "../Physics/v2/IPhysicsEnginePlugin";
7
7
  import { PhysicsImpostor } from "../Physics/v1/physicsImpostor";
8
+ import type { PhysicsBody } from "../Physics/v2/physicsBody";
8
9
  /**
9
10
  * Used to show the physics impostor around the specific mesh
10
11
  */
@@ -14,10 +15,16 @@ export declare class PhysicsViewer {
14
15
  /** @internal */
15
16
  protected _meshes: Array<Nullable<AbstractMesh>>;
16
17
  /** @internal */
18
+ protected _bodies: Array<Nullable<PhysicsBody>>;
19
+ /** @internal */
20
+ protected _bodyMeshes: Array<Nullable<AbstractMesh>>;
21
+ /** @internal */
17
22
  protected _scene: Nullable<Scene>;
18
23
  /** @internal */
19
24
  protected _numMeshes: number;
20
25
  /** @internal */
26
+ protected _numBodies: number;
27
+ /** @internal */
21
28
  protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;
22
29
  private _renderFunction;
23
30
  private _utilityLayer;
@@ -41,6 +48,10 @@ export declare class PhysicsViewer {
41
48
  * @returns the new debug mesh used to render the impostor
42
49
  */
43
50
  showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
51
+ /**
52
+ *
53
+ */
54
+ showBody(body: PhysicsBody): Nullable<AbstractMesh>;
44
55
  /**
45
56
  * Hides a specified physic impostor
46
57
  * @param impostor defines the impostor to hide
@@ -53,6 +64,7 @@ export declare class PhysicsViewer {
53
64
  private _getDebugCylinderMesh;
54
65
  private _getDebugMeshMesh;
55
66
  private _getDebugMesh;
67
+ private _getDebugBodyMesh;
56
68
  /** Releases all resources */
57
69
  dispose(): void;
58
70
  }
@@ -10,6 +10,7 @@ import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer.js";
10
10
  import { CreateCylinder } from "../Meshes/Builders/cylinderBuilder.js";
11
11
  import { CreateCapsule } from "../Meshes/Builders/capsuleBuilder.js";
12
12
  import { Logger } from "../Misc/logger.js";
13
+ import { VertexData } from "../Meshes/mesh.vertexData.js";
13
14
  /**
14
15
  * Used to show the physics impostor around the specific mesh
15
16
  */
@@ -24,7 +25,13 @@ export class PhysicsViewer {
24
25
  /** @internal */
25
26
  this._meshes = [];
26
27
  /** @internal */
28
+ this._bodies = [];
29
+ /** @internal */
30
+ this._bodyMeshes = [];
31
+ /** @internal */
27
32
  this._numMeshes = 0;
33
+ /** @internal */
34
+ this._numBodies = 0;
28
35
  this._debugMeshMeshes = new Array();
29
36
  this._scene = scene || EngineStore.LastCreatedScene;
30
37
  if (!this._scene) {
@@ -87,6 +94,30 @@ export class PhysicsViewer {
87
94
  }
88
95
  return debugMesh;
89
96
  }
97
+ /**
98
+ *
99
+ */
100
+ showBody(body) {
101
+ if (!this._scene) {
102
+ return null;
103
+ }
104
+ for (let i = 0; i < this._numBodies; i++) {
105
+ if (this._bodies[i] == body) {
106
+ return null;
107
+ }
108
+ }
109
+ const debugMesh = this._getDebugBodyMesh(body);
110
+ if (debugMesh) {
111
+ this._bodies[this._numBodies] = body;
112
+ this._bodyMeshes[this._numBodies] = debugMesh;
113
+ if (this._numBodies === 0) {
114
+ this._renderFunction = this._updateDebugMeshes.bind(this);
115
+ this._scene.registerBeforeRender(this._renderFunction);
116
+ }
117
+ this._numBodies++;
118
+ }
119
+ return debugMesh;
120
+ }
90
121
  /**
91
122
  * Hides a specified physic impostor
92
123
  * @param impostor defines the impostor to hide
@@ -274,6 +305,20 @@ export class PhysicsViewer {
274
305
  }
275
306
  return mesh;
276
307
  }
308
+ _getDebugBodyMesh(body) {
309
+ if (!this._utilityLayer) {
310
+ return null;
311
+ }
312
+ const utilityLayerScene = this._utilityLayer.utilityLayerScene;
313
+ const mesh = new Mesh("custom", utilityLayerScene);
314
+ const vertexData = new VertexData();
315
+ const geometry = body.getGeometry();
316
+ vertexData.positions = geometry.positions;
317
+ vertexData.indices = geometry.indices;
318
+ vertexData.applyToMesh(mesh);
319
+ mesh.material = this._getDebugMaterial(utilityLayerScene);
320
+ return mesh;
321
+ }
277
322
  /** Releases all resources */
278
323
  dispose() {
279
324
  const count = this._numMeshes;
@@ -1 +1 @@
1
- {"version":3,"file":"physicsViewer.js","sourceRoot":"","sources":["../../../../lts/core/generated/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,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,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,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,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 { Quaternion, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3 } 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 } 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\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 _scene: Nullable<Scene>;\r\n /** @internal */\r\n protected _numMeshes = 0;\r\n /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => 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 _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 /** @internal */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\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 && plugin.getPluginVersion() === 1) {\r\n (plugin as IPhysicsEnginePluginV1).syncMeshWithImpostor(mesh, impostor);\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.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 * Hides a specified physic impostor\r\n * @param impostor defines the impostor to hide\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 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 _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 /** Releases all resources */\r\n public dispose() {\r\n const count = this._numMeshes;\r\n for (let index = 0; index < count; index++) {\r\n this.hideImpostor(this._impostors[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":["../../../../lts/core/generated/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,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,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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AC;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 { Quaternion, Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3 } 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 } 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\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 _bodyMeshes: 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 /** @internal */\r\n protected _physicsEnginePlugin: IPhysicsEnginePluginV1 | IPhysicsEnginePluginV2 | null;\r\n private _renderFunction: () => 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 _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 /** @internal */\r\n protected _updateDebugMeshes(): void {\r\n const plugin = this._physicsEnginePlugin;\r\n\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 && plugin.getPluginVersion() === 1) {\r\n (plugin as IPhysicsEnginePluginV1).syncMeshWithImpostor(mesh, impostor);\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.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 *\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 * Hides a specified physic impostor\r\n * @param impostor defines the impostor to hide\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 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 _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 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 mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\r\n }\r\n\r\n /** Releases all resources */\r\n public dispose() {\r\n const count = this._numMeshes;\r\n for (let index = 0; index < count; index++) {\r\n this.hideImpostor(this._impostors[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"]}
@@ -401,13 +401,13 @@ export class ThinEngine {
401
401
  */
402
402
  // Not mixed with Version for tooling purpose.
403
403
  static get NpmPackage() {
404
- return "babylonjs@5.40.1";
404
+ return "babylonjs@5.41.0";
405
405
  }
406
406
  /**
407
407
  * Returns the current version of the framework
408
408
  */
409
409
  static get Version() {
410
- return "5.40.1";
410
+ return "5.41.0";
411
411
  }
412
412
  /**
413
413
  * Returns a string describing the current engine