@babylonjs/core 5.48.0 → 5.49.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 (70) hide show
  1. package/Behaviors/Meshes/pointerDragBehavior.js +1 -1
  2. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  3. package/Bones/skeleton.js +1 -1
  4. package/Bones/skeleton.js.map +1 -1
  5. package/Debug/physicsViewer.js +4 -0
  6. package/Debug/physicsViewer.js.map +1 -1
  7. package/Engines/Native/nativeInterfaces.d.ts +0 -1
  8. package/Engines/Native/nativeInterfaces.js.map +1 -1
  9. package/Engines/engine.d.ts +3 -1
  10. package/Engines/engine.js +14 -5
  11. package/Engines/engine.js.map +1 -1
  12. package/Engines/engineStore.d.ts +6 -0
  13. package/Engines/engineStore.js +6 -0
  14. package/Engines/engineStore.js.map +1 -1
  15. package/Engines/nativeEngine.d.ts +3 -2
  16. package/Engines/nativeEngine.js +9 -5
  17. package/Engines/nativeEngine.js.map +1 -1
  18. package/Engines/thinEngine.d.ts +4 -3
  19. package/Engines/thinEngine.js +11 -13
  20. package/Engines/thinEngine.js.map +1 -1
  21. package/Helpers/environmentHelper.d.ts +1 -0
  22. package/Helpers/environmentHelper.js +6 -5
  23. package/Helpers/environmentHelper.js.map +1 -1
  24. package/Inputs/scene.inputManager.js +1 -1
  25. package/Inputs/scene.inputManager.js.map +1 -1
  26. package/Loading/Plugins/babylonFileLoader.js +1 -0
  27. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  28. package/Materials/Background/backgroundMaterial.js +1 -1
  29. package/Materials/Background/backgroundMaterial.js.map +1 -1
  30. package/Materials/Node/Blocks/Input/inputBlock.js +8 -8
  31. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  32. package/Materials/Textures/thinTexture.d.ts +4 -2
  33. package/Materials/Textures/thinTexture.js +5 -2
  34. package/Materials/Textures/thinTexture.js.map +1 -1
  35. package/Materials/material.js +5 -0
  36. package/Materials/material.js.map +1 -1
  37. package/Materials/materialHelper.js +1 -1
  38. package/Materials/materialHelper.js.map +1 -1
  39. package/Materials/materialPluginBase.js +3 -0
  40. package/Materials/materialPluginBase.js.map +1 -1
  41. package/Materials/pushMaterial.d.ts +2 -1
  42. package/Materials/pushMaterial.js +4 -0
  43. package/Materials/pushMaterial.js.map +1 -1
  44. package/Maths/math.color.d.ts +20 -12
  45. package/Maths/math.color.js +85 -31
  46. package/Maths/math.color.js.map +1 -1
  47. package/Misc/decorators.js +2 -2
  48. package/Misc/decorators.js.map +1 -1
  49. package/Misc/fileTools.js +3 -0
  50. package/Misc/fileTools.js.map +1 -1
  51. package/Misc/khronosTextureContainer2.d.ts +3 -3
  52. package/Misc/khronosTextureContainer2.js +4 -3
  53. package/Misc/khronosTextureContainer2.js.map +1 -1
  54. package/Misc/observable.d.ts +18 -1
  55. package/Misc/observable.js +28 -2
  56. package/Misc/observable.js.map +1 -1
  57. package/Physics/v2/IPhysicsEnginePlugin.d.ts +3 -0
  58. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  59. package/Physics/v2/physicsAggregate.js +1 -1
  60. package/Physics/v2/physicsAggregate.js.map +1 -1
  61. package/Physics/v2/physicsBody.d.ts +12 -0
  62. package/Physics/v2/physicsBody.js +19 -0
  63. package/Physics/v2/physicsBody.js.map +1 -1
  64. package/Physics/v2/physicsShape.d.ts +24 -4
  65. package/Physics/v2/physicsShape.js +24 -13
  66. package/Physics/v2/physicsShape.js.map +1 -1
  67. package/package.json +1 -1
  68. package/scene.d.ts +1 -1
  69. package/scene.js +47 -46
  70. package/scene.js.map +1 -1
@@ -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,E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AAG,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;YACvD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;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 { 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 /**\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 /**\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 * 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 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 /**\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 mesh.material = this._getDebugMaterial(utilityLayerScene);\r\n return mesh;\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\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,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AC,CAAC;SACzC;QACD,SAAS;QACT,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;YACvD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;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 { 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 /**\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 /**\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 * 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 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 /**\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 /**\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\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"]}
@@ -40,7 +40,6 @@ export interface INativeEngine {
40
40
  createFrameBuffer(texture: Nullable<NativeTexture>, width: number, height: number, generateStencilBuffer: boolean, generateDepthBuffer: boolean): NativeFramebuffer;
41
41
  getRenderWidth(): number;
42
42
  getRenderHeight(): number;
43
- getHardwareScalingLevel(): number;
44
43
  setHardwareScalingLevel(level: number): void;
45
44
  setViewPort(x: number, y: number, width: number, height: number): void;
46
45
  setCommandDataStream(dataStream: NativeDataStream): void;
@@ -1 +1 @@
1
- {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(texture: Nullable<NativeTexture>, width: number, height: number, generateStencilBuffer: boolean, generateDepthBuffer: boolean): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n getHardwareScalingLevel(): number;\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(texture: Nullable<NativeTexture>, width: number, height: number, generateStencilBuffer: boolean, generateDepthBuffer: boolean): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
@@ -827,9 +827,11 @@ export declare class Engine extends ThinEngine {
827
827
  /**
828
828
  * Wraps an external web gl texture in a Babylon texture.
829
829
  * @param texture defines the external texture
830
+ * @param hasMipMaps defines whether the external texture has mip maps (default: false)
831
+ * @param samplingMode defines the sampling mode for the external texture (default: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE)
830
832
  * @returns the babylon internal texture
831
833
  */
832
- wrapWebGLTexture(texture: WebGLTexture): InternalTexture;
834
+ wrapWebGLTexture(texture: WebGLTexture, hasMipMaps?: boolean, samplingMode?: number): InternalTexture;
833
835
  /**
834
836
  * @internal
835
837
  */
package/Engines/engine.js CHANGED
@@ -839,7 +839,7 @@ export class Engine extends ThinEngine {
839
839
  _renderLoop() {
840
840
  if (!this._contextWasLost) {
841
841
  let shouldRender = true;
842
- if (!this.renderEvenInBackground && this._windowIsBackground) {
842
+ if (this.isDisposed || (!this.renderEvenInBackground && this._windowIsBackground)) {
843
843
  shouldRender = false;
844
844
  }
845
845
  if (shouldRender) {
@@ -1163,13 +1163,17 @@ export class Engine extends ThinEngine {
1163
1163
  /**
1164
1164
  * Wraps an external web gl texture in a Babylon texture.
1165
1165
  * @param texture defines the external texture
1166
+ * @param hasMipMaps defines whether the external texture has mip maps (default: false)
1167
+ * @param samplingMode defines the sampling mode for the external texture (default: 3)
1166
1168
  * @returns the babylon internal texture
1167
1169
  */
1168
- wrapWebGLTexture(texture) {
1170
+ wrapWebGLTexture(texture, hasMipMaps = false, samplingMode = 3) {
1169
1171
  const hardwareTexture = new WebGLHardwareTexture(texture, this._gl);
1170
1172
  const internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
1171
1173
  internalTexture._hardwareTexture = hardwareTexture;
1172
1174
  internalTexture.isReady = true;
1175
+ internalTexture.useMipMaps = hasMipMaps;
1176
+ this.updateTextureSamplingMode(samplingMode, internalTexture);
1173
1177
  return internalTexture;
1174
1178
  }
1175
1179
  /**
@@ -1317,7 +1321,7 @@ export class Engine extends ThinEngine {
1317
1321
  this._virtualScenes[0].dispose();
1318
1322
  }
1319
1323
  // Release audio engine
1320
- if (Engine.Instances.length === 1 && Engine.audioEngine) {
1324
+ if (EngineStore.Instances.length === 1 && Engine.audioEngine) {
1321
1325
  Engine.audioEngine.dispose();
1322
1326
  Engine.audioEngine = null;
1323
1327
  }
@@ -1347,9 +1351,14 @@ export class Engine extends ThinEngine {
1347
1351
  }
1348
1352
  super.dispose();
1349
1353
  // Remove from Instances
1350
- const index = Engine.Instances.indexOf(this);
1354
+ const index = EngineStore.Instances.indexOf(this);
1351
1355
  if (index >= 0) {
1352
- Engine.Instances.splice(index, 1);
1356
+ EngineStore.Instances.splice(index, 1);
1357
+ }
1358
+ // no more engines left in the engine store? Notify!
1359
+ if (!Engine.Instances.length) {
1360
+ EngineStore.OnEnginesDisposedObservable.notifyObservers(this);
1361
+ EngineStore.OnEnginesDisposedObservable.clear();
1353
1362
  }
1354
1363
  // Observables
1355
1364
  this.onResizeObservable.clear();