@babylonjs/core 5.17.1 → 5.20.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 (159) hide show
  1. package/Debug/debugLayer.d.ts +36 -0
  2. package/Debug/debugLayer.js.map +1 -1
  3. package/DeviceInput/InputDevices/deviceSource.d.ts +1 -1
  4. package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
  5. package/DeviceInput/InputDevices/deviceSourceManager.d.ts +1 -1
  6. package/DeviceInput/InputDevices/deviceSourceManager.js +1 -1
  7. package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
  8. package/DeviceInput/{Helpers/eventFactory.d.ts → eventFactory.d.ts} +4 -4
  9. package/DeviceInput/{Helpers/eventFactory.js → eventFactory.js} +2 -2
  10. package/DeviceInput/eventFactory.js.map +1 -0
  11. package/DeviceInput/{InputDevices/inputInterfaces.d.ts → inputInterfaces.d.ts} +2 -2
  12. package/DeviceInput/{InputDevices/inputInterfaces.js → inputInterfaces.js} +0 -0
  13. package/DeviceInput/inputInterfaces.js.map +1 -0
  14. package/DeviceInput/{InputDevices/internalDeviceSourceManager.d.ts → internalDeviceSourceManager.d.ts} +7 -7
  15. package/DeviceInput/{InputDevices/internalDeviceSourceManager.js → internalDeviceSourceManager.js} +2 -2
  16. package/DeviceInput/internalDeviceSourceManager.js.map +1 -0
  17. package/DeviceInput/{InputDevices/nativeDeviceInputSystem.d.ts → nativeDeviceInputSystem.d.ts} +2 -2
  18. package/DeviceInput/{InputDevices/nativeDeviceInputSystem.js → nativeDeviceInputSystem.js} +2 -2
  19. package/DeviceInput/nativeDeviceInputSystem.js.map +1 -0
  20. package/DeviceInput/{InputDevices/webDeviceInputSystem.d.ts → webDeviceInputSystem.d.ts} +3 -3
  21. package/DeviceInput/{InputDevices/webDeviceInputSystem.js → webDeviceInputSystem.js} +4 -4
  22. package/DeviceInput/webDeviceInputSystem.js.map +1 -0
  23. package/Engines/Extensions/engine.query.js +5 -1
  24. package/Engines/Extensions/engine.query.js.map +1 -1
  25. package/Engines/Extensions/engine.transformFeedback.js +5 -1
  26. package/Engines/Extensions/engine.transformFeedback.js.map +1 -1
  27. package/Engines/Extensions/engine.views.d.ts +13 -0
  28. package/Engines/Extensions/engine.views.js +16 -1
  29. package/Engines/Extensions/engine.views.js.map +1 -1
  30. package/Engines/Native/nativeInterfaces.d.ts +1 -1
  31. package/Engines/Native/nativeInterfaces.js.map +1 -1
  32. package/Engines/engine.d.ts +15 -240
  33. package/Engines/engineFeatures.d.ts +2 -0
  34. package/Engines/engineFeatures.js.map +1 -1
  35. package/Engines/nativeEngine.js +1 -0
  36. package/Engines/nativeEngine.js.map +1 -1
  37. package/Engines/nullEngine.js +1 -0
  38. package/Engines/nullEngine.js.map +1 -1
  39. package/Engines/thinEngine.d.ts +1 -1
  40. package/Engines/thinEngine.js +14 -4
  41. package/Engines/thinEngine.js.map +1 -1
  42. package/Engines/webgpuEngine.js +1 -0
  43. package/Engines/webgpuEngine.js.map +1 -1
  44. package/Gizmos/axisDragGizmo.d.ts +31 -9
  45. package/Gizmos/axisDragGizmo.js.map +1 -1
  46. package/Gizmos/axisScaleGizmo.d.ts +46 -14
  47. package/Gizmos/axisScaleGizmo.js.map +1 -1
  48. package/Gizmos/boundingBoxGizmo.d.ts +94 -19
  49. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  50. package/Gizmos/cameraGizmo.d.ts +23 -6
  51. package/Gizmos/cameraGizmo.js.map +1 -1
  52. package/Gizmos/gizmo.d.ts +48 -6
  53. package/Gizmos/gizmo.js.map +1 -1
  54. package/Gizmos/gizmoManager.d.ts +25 -17
  55. package/Gizmos/gizmoManager.js.map +1 -1
  56. package/Gizmos/lightGizmo.d.ts +25 -8
  57. package/Gizmos/lightGizmo.js.map +1 -1
  58. package/Gizmos/planeDragGizmo.d.ts +30 -9
  59. package/Gizmos/planeDragGizmo.js.map +1 -1
  60. package/Gizmos/planeRotationGizmo.d.ts +45 -15
  61. package/Gizmos/planeRotationGizmo.js.map +1 -1
  62. package/Gizmos/positionGizmo.d.ts +53 -17
  63. package/Gizmos/positionGizmo.js +1 -1
  64. package/Gizmos/positionGizmo.js.map +1 -1
  65. package/Gizmos/rotationGizmo.d.ts +35 -10
  66. package/Gizmos/rotationGizmo.js.map +1 -1
  67. package/Gizmos/scaleGizmo.d.ts +49 -18
  68. package/Gizmos/scaleGizmo.js.map +1 -1
  69. package/Loading/Plugins/babylonFileLoader.js +16 -4
  70. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  71. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +39 -0
  72. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +97 -0
  73. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -0
  74. package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
  75. package/Materials/Node/Blocks/Fragment/index.js +1 -0
  76. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  77. package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +18 -0
  78. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +85 -1
  79. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  80. package/Materials/Node/nodeMaterial.d.ts +6 -0
  81. package/Materials/Node/nodeMaterial.js +11 -0
  82. package/Materials/Node/nodeMaterial.js.map +1 -1
  83. package/Materials/Textures/Procedurals/proceduralTexture.js +5 -1
  84. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  85. package/Materials/Textures/renderTargetTexture.js +3 -0
  86. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  87. package/Materials/Textures/texture.js +9 -5
  88. package/Materials/Textures/texture.js.map +1 -1
  89. package/Materials/index.d.ts +1 -0
  90. package/Materials/index.js +1 -0
  91. package/Materials/index.js.map +1 -1
  92. package/Maths/math.vector.d.ts +134 -8
  93. package/Maths/math.vector.js +168 -36
  94. package/Maths/math.vector.js.map +1 -1
  95. package/Meshes/Compression/dracoCompression.js +1 -1
  96. package/Meshes/Compression/dracoCompression.js.map +1 -1
  97. package/Meshes/groundMesh.js +1 -1
  98. package/Meshes/groundMesh.js.map +1 -1
  99. package/Meshes/mesh.js +1 -0
  100. package/Meshes/mesh.js.map +1 -1
  101. package/Meshes/transformNode.js +1 -0
  102. package/Meshes/transformNode.js.map +1 -1
  103. package/Misc/assetsManager.d.ts +9 -0
  104. package/Misc/assetsManager.js +3 -1
  105. package/Misc/assetsManager.js.map +1 -1
  106. package/Misc/basis.js +10 -4
  107. package/Misc/basis.js.map +1 -1
  108. package/Misc/computePressure.d.ts +9 -3
  109. package/Misc/computePressure.js +13 -5
  110. package/Misc/computePressure.js.map +1 -1
  111. package/Misc/fileTools.js +2 -2
  112. package/Misc/fileTools.js.map +1 -1
  113. package/Misc/iInspectable.d.ts +12 -2
  114. package/Misc/iInspectable.js +4 -0
  115. package/Misc/iInspectable.js.map +1 -1
  116. package/Misc/khronosTextureContainer2.js +1 -1
  117. package/Misc/khronosTextureContainer2.js.map +1 -1
  118. package/Misc/sceneSerializer.js +1 -1
  119. package/Misc/sceneSerializer.js.map +1 -1
  120. package/Misc/tools.d.ts +2 -2
  121. package/Misc/tools.js +4 -1
  122. package/Misc/tools.js.map +1 -1
  123. package/Offline/database.js +6 -8
  124. package/Offline/database.js.map +1 -1
  125. package/Particles/solidParticleSystem.d.ts +1 -0
  126. package/Particles/solidParticleSystem.js +4 -1
  127. package/Particles/solidParticleSystem.js.map +1 -1
  128. package/Physics/Plugins/ammoJSPlugin.d.ts +2 -2
  129. package/Physics/Plugins/ammoJSPlugin.js +29 -29
  130. package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
  131. package/Physics/Plugins/cannonJSPlugin.d.ts +2 -2
  132. package/Physics/Plugins/cannonJSPlugin.js +26 -26
  133. package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
  134. package/Physics/Plugins/oimoJSPlugin.js +9 -11
  135. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  136. package/Physics/physicsImpostor.d.ts +6 -6
  137. package/Physics/physicsImpostor.js +15 -8
  138. package/Physics/physicsImpostor.js.map +1 -1
  139. package/Shaders/sprites.fragment.js +1 -1
  140. package/Shaders/sprites.fragment.js.map +1 -1
  141. package/Sprites/spriteRenderer.js +1 -1
  142. package/Sprites/spriteRenderer.js.map +1 -1
  143. package/XR/webXRDefaultExperience.d.ts +10 -0
  144. package/XR/webXRDefaultExperience.js +2 -12
  145. package/XR/webXRDefaultExperience.js.map +1 -1
  146. package/XR/webXRExperienceHelper.js +12 -12
  147. package/XR/webXRExperienceHelper.js.map +1 -1
  148. package/node.d.ts +2 -0
  149. package/node.js +2 -0
  150. package/node.js.map +1 -1
  151. package/package.json +1 -1
  152. package/scene.d.ts +1 -1
  153. package/scene.js +5 -3
  154. package/scene.js.map +1 -1
  155. package/DeviceInput/Helpers/eventFactory.js.map +0 -1
  156. package/DeviceInput/InputDevices/inputInterfaces.js.map +0 -1
  157. package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +0 -1
  158. package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +0 -1
  159. package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"physicsImpostor.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/physicsImpostor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAMtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA6K3C,IAAI,CAAC,sBA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A8B3C,wBAAQ,GAAc,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,wBAAQ,GAAe,UAAU,CAAC,QAAQ,EAAE,CAAC;IA8+B5D,gBAAgB;IAChB;;OAEG;IACW,0BAAU,GAAG,CAAC,CAAC;IAC7B;;OAEG;IACW,8BAAc,GAAG,CAAC,CAAC;IACjC;;OAEG;IACW,2BAAW,GAAG,CAAC,CAAC;IAC9B;;OAEG;IACW,6BAAa,GAAG,CAAC,CAAC;IAChC;;OAEG;IACW,4BAAY,GAAG,CAAC,CAAC;IAC/B;;OAEG;IACW,+BAAe,GAAG,CAAC,CAAC;IAClC;;OAEG;IACW,gCAAgB,GAAG,CAAC,CAAC;IACnC;;OAEG;IACW,gCAAgB,GAAG,CAAC,CAAC;IACnC;;OAEG;IACW,iCAAiB,GAAG,CAAC,CAAC;IACpC;;OAEG;IACW,kCAAkB,GAAG,EAAE,CAAC;IACtC;;OAEG;IACW,8BAAc,GAAG,GAAG,CAAC;IACnC;;OAEG;IACW,4BAAY,GAAG,GAAG,CAAC;IACjC;;OAEG;IACW,6BAAa,GAAG,GAAG,CAAC;IAClC;;OAEG;IACW,gCAAgB,GAAG,GAAG,CAAC;IACzC,sBAAC;CAAA,AA/kCD,IA+kCC;SA/kCY,eAAe","sourcesContent":["import type { Nullable, IndicesArray } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, Quaternion } from \"../Maths/math.vector\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Bone } from \"../Bones/bone\";\r\nimport type { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { IPhysicsEngine } from \"./IPhysicsEngine\";\r\nimport type { PhysicsJointData } from \"./physicsJoint\";\r\nimport { PhysicsJoint } from \"./physicsJoint\";\r\nimport { Space } from \"../Maths/math.axis\";\r\n\r\n/**\r\n * The interface for the physics imposter parameters\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport interface PhysicsImpostorParameters {\r\n /**\r\n * The mass of the physics imposter\r\n */\r\n mass: number;\r\n /**\r\n * The friction of the physics imposter\r\n */\r\n friction?: number;\r\n /**\r\n * The coefficient of restitution of the physics imposter\r\n */\r\n restitution?: number;\r\n /**\r\n * The native options of the physics imposter\r\n */\r\n nativeOptions?: any;\r\n /**\r\n * Specifies if the parent should be ignored\r\n */\r\n ignoreParent?: boolean;\r\n /**\r\n * Specifies if bi-directional transformations should be disabled\r\n */\r\n disableBidirectionalTransformation?: boolean;\r\n /**\r\n * The pressure inside the physics imposter, soft object only\r\n */\r\n pressure?: number;\r\n /**\r\n * The stiffness the physics imposter, soft object only\r\n */\r\n stiffness?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex velocities, soft object only\r\n */\r\n velocityIterations?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex positions, soft object only\r\n */\r\n positionIterations?: number;\r\n /**\r\n * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only\r\n * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right\r\n * Add to fix multiple points\r\n */\r\n fixedPoints?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n margin?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n damping?: number;\r\n /**\r\n * The path for a rope based on an extrusion\r\n */\r\n path?: any;\r\n /**\r\n * The shape of an extrusion used for a rope based on an extrusion\r\n */\r\n shape?: any;\r\n}\r\n\r\n/**\r\n * Interface for a physics-enabled object\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport interface IPhysicsEnabledObject {\r\n /**\r\n * The position of the physics-enabled object\r\n */\r\n position: Vector3;\r\n /**\r\n * The rotation of the physics-enabled object\r\n */\r\n rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * The scale of the physics-enabled object\r\n */\r\n scaling: Vector3;\r\n /**\r\n * The rotation of the physics-enabled object\r\n */\r\n rotation?: Vector3;\r\n /**\r\n * The parent of the physics-enabled object\r\n */\r\n parent?: any;\r\n /**\r\n * The bounding info of the physics-enabled object\r\n * @returns The bounding info of the physics-enabled object\r\n */\r\n getBoundingInfo(): BoundingInfo;\r\n /**\r\n * Computes the world matrix\r\n * @param force Specifies if the world matrix should be computed by force\r\n * @returns A world matrix\r\n */\r\n computeWorldMatrix(force: boolean): Matrix;\r\n /**\r\n * Gets the world matrix\r\n * @returns A world matrix\r\n */\r\n getWorldMatrix?(): Matrix;\r\n /**\r\n * Gets the child meshes\r\n * @param directDescendantsOnly Specifies if only direct-descendants should be obtained\r\n * @returns An array of abstract meshes\r\n */\r\n getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;\r\n /**\r\n * Gets the vertex data\r\n * @param kind The type of vertex data\r\n * @returns A nullable array of numbers, or a float32 array\r\n */\r\n getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;\r\n /**\r\n * Gets the indices from the mesh\r\n * @returns A nullable array of index arrays\r\n */\r\n getIndices?(): Nullable<IndicesArray>;\r\n /**\r\n * Gets the scene from the mesh\r\n * @returns the indices array or null\r\n */\r\n getScene?(): Scene;\r\n /**\r\n * Gets the absolute position from the mesh\r\n * @returns the absolute position\r\n */\r\n getAbsolutePosition(): Vector3;\r\n /**\r\n * Gets the absolute pivot point from the mesh\r\n * @returns the absolute pivot point\r\n */\r\n getAbsolutePivotPoint(): Vector3;\r\n /**\r\n * Rotates the mesh\r\n * @param axis The axis of rotation\r\n * @param amount The amount of rotation\r\n * @param space The space of the rotation\r\n * @returns The rotation transform node\r\n */\r\n rotate(axis: Vector3, amount: number, space?: Space): TransformNode;\r\n /**\r\n * Translates the mesh\r\n * @param axis The axis of translation\r\n * @param distance The distance of translation\r\n * @param space The space of the translation\r\n * @returns The transform node\r\n */\r\n translate(axis: Vector3, distance: number, space?: Space): TransformNode;\r\n /**\r\n * Sets the absolute position of the mesh\r\n * @param absolutePosition The absolute position of the mesh\r\n * @returns The transform node\r\n */\r\n setAbsolutePosition(absolutePosition: Vector3): TransformNode;\r\n /**\r\n * Gets the class name of the mesh\r\n * @returns The class name\r\n */\r\n getClassName(): string;\r\n}\r\n\r\nMesh._PhysicsImpostorParser = function (scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor {\r\n return new PhysicsImpostor(\r\n physicObject,\r\n jsonObject.physicsImpostor,\r\n {\r\n mass: jsonObject.physicsMass,\r\n friction: jsonObject.physicsFriction,\r\n restitution: jsonObject.physicsRestitution,\r\n },\r\n scene\r\n );\r\n};\r\n\r\n/**\r\n * Represents a physics imposter\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport class PhysicsImpostor {\r\n /**\r\n * The default object size of the imposter\r\n */\r\n public static DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * The identity quaternion of the imposter\r\n */\r\n public static IDENTITY_QUATERNION = Quaternion.Identity();\r\n\r\n /** @hidden */\r\n public _pluginData: any = {};\r\n\r\n private _physicsEngine: Nullable<IPhysicsEngine>;\r\n //The native cannon/oimo/energy physics body object.\r\n private _physicsBody: any;\r\n private _bodyUpdateRequired: boolean = false;\r\n\r\n private _onBeforePhysicsStepCallbacks = new Array<(impostor: PhysicsImpostor) => void>();\r\n private _onAfterPhysicsStepCallbacks = new Array<(impostor: PhysicsImpostor) => void>();\r\n /** @hidden */\r\n public _onPhysicsCollideCallbacks: Array<{\r\n callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;\r\n otherImpostors: Array<PhysicsImpostor>;\r\n }> = [];\r\n\r\n private _deltaPosition: Vector3 = Vector3.Zero();\r\n private _deltaRotation: Quaternion;\r\n private _deltaRotationConjugated: Quaternion;\r\n\r\n /** @hidden */\r\n public _isFromLine: boolean;\r\n\r\n //If set, this is this impostor's parent\r\n private _parent: Nullable<PhysicsImpostor>;\r\n\r\n private _isDisposed = false;\r\n\r\n private static _TmpVecs: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n private static _TmpQuat: Quaternion = Quaternion.Identity();\r\n\r\n /**\r\n * Specifies if the physics imposter is disposed\r\n */\r\n get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets the mass of the physics imposter\r\n */\r\n get mass(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;\r\n }\r\n\r\n set mass(value: number) {\r\n this.setMass(value);\r\n }\r\n\r\n /**\r\n * Gets the coefficient of friction\r\n */\r\n get friction(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;\r\n }\r\n\r\n /**\r\n * Sets the coefficient of friction\r\n */\r\n set friction(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);\r\n }\r\n\r\n /**\r\n * Gets the coefficient of restitution\r\n */\r\n get restitution(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;\r\n }\r\n\r\n /**\r\n * Sets the coefficient of restitution\r\n */\r\n set restitution(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);\r\n }\r\n\r\n /**\r\n * Gets the pressure of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get pressure(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPressure) {\r\n return 0;\r\n }\r\n return plugin.getBodyPressure!(this);\r\n }\r\n\r\n /**\r\n * Sets the pressure of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set pressure(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPressure) {\r\n return;\r\n }\r\n plugin.setBodyPressure!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get stiffness(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyStiffness) {\r\n return 0;\r\n }\r\n return plugin.getBodyStiffness!(this);\r\n }\r\n\r\n /**\r\n * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set stiffness(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyStiffness) {\r\n return;\r\n }\r\n plugin.setBodyStiffness!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get velocityIterations(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyVelocityIterations) {\r\n return 0;\r\n }\r\n return plugin.getBodyVelocityIterations!(this);\r\n }\r\n\r\n /**\r\n * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set velocityIterations(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyVelocityIterations) {\r\n return;\r\n }\r\n plugin.setBodyVelocityIterations!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get positionIterations(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyPositionIterations) {\r\n return 0;\r\n }\r\n return plugin.getBodyPositionIterations!(this);\r\n }\r\n\r\n /**\r\n * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set positionIterations(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPositionIterations) {\r\n return;\r\n }\r\n plugin.setBodyPositionIterations!(this, value);\r\n }\r\n\r\n /**\r\n * The unique id of the physics imposter\r\n * set by the physics engine when adding this impostor to the array\r\n */\r\n public uniqueId: number;\r\n\r\n /**\r\n * @hidden\r\n */\r\n public soft: boolean = false;\r\n\r\n /**\r\n * @hidden\r\n */\r\n public segments: number = 0;\r\n\r\n private _joints: Array<{\r\n joint: PhysicsJoint;\r\n otherImpostor: PhysicsImpostor;\r\n }>;\r\n\r\n /**\r\n * Initializes the physics imposter\r\n * @param object The physics-enabled object used as the physics imposter\r\n * @param type The type of the physics imposter. Types are available as static members of this class.\r\n * @param _options The options for the physics imposter\r\n * @param _scene The Babylon scene\r\n */\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics imposter\r\n */\r\n public object: IPhysicsEnabledObject,\r\n /**\r\n * The type of the physics imposter\r\n */\r\n public type: number,\r\n private _options: PhysicsImpostorParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.object) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n if (this.object.parent && _options.mass !== 0) {\r\n Logger.Warn(\"A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.\");\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && object.getScene) {\r\n this._scene = object.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n if (this.type > 100) {\r\n this.soft = true;\r\n }\r\n\r\n this._physicsEngine = this._scene.getPhysicsEngine();\r\n if (!this._physicsEngine) {\r\n Logger.Error(\"Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.\");\r\n } else {\r\n //set the object's quaternion, if not set\r\n if (!this.object.rotationQuaternion) {\r\n if (this.object.rotation) {\r\n this.object.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);\r\n } else {\r\n this.object.rotationQuaternion = new Quaternion();\r\n }\r\n }\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n if (this.soft) {\r\n //softbody mass must be above 0;\r\n this._options.mass = this._options.mass > 0 ? this._options.mass : 1;\r\n this._options.pressure = _options.pressure === void 0 ? 200 : _options.pressure;\r\n this._options.stiffness = _options.stiffness === void 0 ? 1 : _options.stiffness;\r\n this._options.velocityIterations = _options.velocityIterations === void 0 ? 20 : _options.velocityIterations;\r\n this._options.positionIterations = _options.positionIterations === void 0 ? 20 : _options.positionIterations;\r\n this._options.fixedPoints = _options.fixedPoints === void 0 ? 0 : _options.fixedPoints;\r\n this._options.margin = _options.margin === void 0 ? 0 : _options.margin;\r\n this._options.damping = _options.damping === void 0 ? 0 : _options.damping;\r\n this._options.path = _options.path === void 0 ? null : _options.path;\r\n this._options.shape = _options.shape === void 0 ? null : _options.shape;\r\n }\r\n this._joints = [];\r\n //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.\r\n if (!this.object.parent || this._options.ignoreParent) {\r\n this._init();\r\n } else if (this.object.parent.physicsImpostor) {\r\n Logger.Warn(\"You must affect impostors to children before affecting impostor to parent.\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * This function will completely initialize this impostor.\r\n * It will create a new body - but only if this mesh has no parent.\r\n * If it has, this impostor will not be used other than to define the impostor\r\n * of the child mesh.\r\n * @hidden\r\n */\r\n public _init() {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._physicsEngine.removeImpostor(this);\r\n this.physicsBody = null;\r\n this._parent = this._parent || this._getPhysicsParent();\r\n if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {\r\n this._physicsEngine.addImpostor(this);\r\n }\r\n }\r\n\r\n private _getPhysicsParent(): Nullable<PhysicsImpostor> {\r\n if (this.object.parent instanceof AbstractMesh) {\r\n const parentMesh: AbstractMesh = <AbstractMesh>this.object.parent;\r\n return parentMesh.physicsImpostor;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Should a new body be generated.\r\n * @returns boolean specifying if body initialization is required\r\n */\r\n public isBodyInitRequired(): boolean {\r\n return this._bodyUpdateRequired || (!this._physicsBody && (!this._parent || !!this._options.ignoreParent));\r\n }\r\n\r\n /**\r\n * Sets the updated scaling\r\n */\r\n public setScalingUpdated() {\r\n this.forceUpdate();\r\n }\r\n\r\n /**\r\n * Force a regeneration of this or the parent's impostor's body.\r\n * Use under cautious - This will remove all joints already implemented.\r\n */\r\n public forceUpdate() {\r\n this._init();\r\n if (this.parent && !this._options.ignoreParent) {\r\n this.parent.forceUpdate();\r\n }\r\n }\r\n\r\n /*public get mesh(): AbstractMesh {\r\n return this._mesh;\r\n }*/\r\n\r\n /**\r\n * Gets the body that holds this impostor. Either its own, or its parent.\r\n */\r\n public get physicsBody(): any {\r\n return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody;\r\n }\r\n\r\n /**\r\n * Get the parent of the physics imposter\r\n * @returns Physics imposter or null\r\n */\r\n public get parent(): Nullable<PhysicsImpostor> {\r\n return !this._options.ignoreParent && this._parent ? this._parent : null;\r\n }\r\n\r\n /**\r\n * Sets the parent of the physics imposter\r\n */\r\n public set parent(value: Nullable<PhysicsImpostor>) {\r\n this._parent = value;\r\n }\r\n\r\n /**\r\n * Set the physics body. Used mainly by the physics engine/plugin\r\n */\r\n public set physicsBody(physicsBody: any) {\r\n if (this._physicsBody && this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);\r\n }\r\n this._physicsBody = physicsBody;\r\n this.resetUpdateFlags();\r\n }\r\n\r\n /**\r\n * Resets the update flags\r\n */\r\n public resetUpdateFlags() {\r\n this._bodyUpdateRequired = false;\r\n }\r\n\r\n /**\r\n * Gets the object extend size\r\n * @returns the object extend size\r\n */\r\n public getObjectExtendSize(): Vector3 {\r\n if (this.object.getBoundingInfo) {\r\n const q = this.object.rotationQuaternion;\r\n const scaling = this.object.scaling.clone();\r\n //reset rotation\r\n this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n const boundingInfo = this.object.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.object.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsImpostor.DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the object center\r\n * @returns The object center\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if (this.object.getBoundingInfo) {\r\n const boundingInfo = this.object.getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.object.position;\r\n }\r\n }\r\n\r\n /**\r\n * Get a specific parameter from the options parameters\r\n * @param paramName The object parameter name\r\n * @returns The object parameter\r\n */\r\n public getParam(paramName: string): any {\r\n return (<any>this._options)[paramName];\r\n }\r\n\r\n /**\r\n * Sets a specific parameter in the options given to the physics plugin\r\n * @param paramName The parameter name\r\n * @param value The value of the parameter\r\n */\r\n public setParam(paramName: string, value: number) {\r\n (<any>this._options)[paramName] = value;\r\n this._bodyUpdateRequired = true;\r\n }\r\n\r\n /**\r\n * Specifically change the body's mass option. Won't recreate the physics body object\r\n * @param mass The mass of the physics imposter\r\n */\r\n public setMass(mass: number) {\r\n if (this.getParam(\"mass\") !== mass) {\r\n this.setParam(\"mass\", mass);\r\n }\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the linear velocity\r\n * @returns linear velocity or null\r\n */\r\n public getLinearVelocity(): Nullable<Vector3> {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the linear velocity\r\n * @param velocity linear velocity or null\r\n */\r\n public setLinearVelocity(velocity: Nullable<Vector3>) {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the angular velocity\r\n * @returns angular velocity or null\r\n */\r\n public getAngularVelocity(): Nullable<Vector3> {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the angular velocity\r\n * @param velocity The velocity or null\r\n */\r\n public setAngularVelocity(velocity: Nullable<Vector3>) {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);\r\n }\r\n }\r\n\r\n /**\r\n * Execute a function with the physics plugin native code\r\n * Provide a function the will have two variables - the world object and the physics body object\r\n * @param func The function to execute with the physics plugin native code\r\n */\r\n\r\n public executeNativeFunction(func: (world: any, physicsBody: any) => void) {\r\n if (this._physicsEngine) {\r\n func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);\r\n }\r\n }\r\n\r\n /**\r\n * Register a function that will be executed before the physics world is stepping forward\r\n * @param func The function to execute before the physics world is stepped forward\r\n */\r\n public registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n this._onBeforePhysicsStepCallbacks.push(func);\r\n }\r\n\r\n /**\r\n * Unregister a function that will be executed before the physics world is stepping forward\r\n * @param func The function to execute before the physics world is stepped forward\r\n */\r\n public unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n const index = this._onBeforePhysicsStepCallbacks.indexOf(func);\r\n\r\n if (index > -1) {\r\n this._onBeforePhysicsStepCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n /**\r\n * Register a function that will be executed after the physics step\r\n * @param func The function to execute after physics step\r\n */\r\n public registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n this._onAfterPhysicsStepCallbacks.push(func);\r\n }\r\n\r\n /**\r\n * Unregisters a function that will be executed after the physics step\r\n * @param func The function to execute after physics step\r\n */\r\n public unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n const index = this._onAfterPhysicsStepCallbacks.indexOf(func);\r\n\r\n if (index > -1) {\r\n this._onAfterPhysicsStepCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n /**\r\n * register a function that will be executed when this impostor collides against a different body\r\n * @param collideAgainst Physics imposter, or array of physics imposters to collide against\r\n * @param func Callback that is executed on collision\r\n */\r\n public registerOnPhysicsCollide(\r\n collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>,\r\n func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void\r\n ): void {\r\n const collidedAgainstList: Array<PhysicsImpostor> = collideAgainst instanceof Array ? <Array<PhysicsImpostor>>collideAgainst : [<PhysicsImpostor>collideAgainst];\r\n this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });\r\n }\r\n\r\n /**\r\n * Unregisters the physics imposter on contact\r\n * @param collideAgainst The physics object to collide against\r\n * @param func Callback to execute on collision\r\n */\r\n public unregisterOnPhysicsCollide(\r\n collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>,\r\n func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>, point: Nullable<Vector3>) => void\r\n ): void {\r\n const collidedAgainstList: Array<PhysicsImpostor> = collideAgainst instanceof Array ? <Array<PhysicsImpostor>>collideAgainst : [<PhysicsImpostor>collideAgainst];\r\n let index = -1;\r\n const found = this._onPhysicsCollideCallbacks.some((cbDef, idx) => {\r\n if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {\r\n // chcek the arrays match\r\n const sameList = cbDef.otherImpostors.every((impostor) => {\r\n return collidedAgainstList.indexOf(impostor) > -1;\r\n });\r\n if (sameList) {\r\n index = idx;\r\n }\r\n return sameList;\r\n }\r\n return false;\r\n });\r\n\r\n if (found) {\r\n this._onPhysicsCollideCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n //temp variables for parent rotation calculations\r\n //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];\r\n private _tmpQuat: Quaternion = new Quaternion();\r\n private _tmpQuat2: Quaternion = new Quaternion();\r\n\r\n /**\r\n * Get the parent rotation\r\n * @returns The parent rotation\r\n */\r\n public getParentsRotation(): Quaternion {\r\n let parent = this.object.parent;\r\n this._tmpQuat.copyFromFloats(0, 0, 0, 1);\r\n while (parent) {\r\n if (parent.rotationQuaternion) {\r\n this._tmpQuat2.copyFrom(parent.rotationQuaternion);\r\n } else {\r\n Quaternion.RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);\r\n }\r\n this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);\r\n parent = parent.parent;\r\n }\r\n return this._tmpQuat;\r\n }\r\n\r\n /**\r\n * this function is executed by the physics engine.\r\n */\r\n public beforeStep = () => {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this.object.translate(this._deltaPosition, -1);\r\n this._deltaRotationConjugated &&\r\n this.object.rotationQuaternion &&\r\n this.object.rotationQuaternion.multiplyToRef(this._deltaRotationConjugated, this.object.rotationQuaternion);\r\n this.object.computeWorldMatrix(false);\r\n if (this.object.parent && this.object.rotationQuaternion) {\r\n this.getParentsRotation();\r\n this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this._tmpQuat);\r\n } else {\r\n this._tmpQuat.copyFrom(this.object.rotationQuaternion || new Quaternion());\r\n }\r\n if (!this._options.disableBidirectionalTransformation) {\r\n this.object.rotationQuaternion &&\r\n this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(this, /*bInfo.boundingBox.centerWorld*/ this.object.getAbsolutePosition(), this._tmpQuat);\r\n }\r\n\r\n this._onBeforePhysicsStepCallbacks.forEach((func) => {\r\n func(this);\r\n });\r\n };\r\n\r\n /**\r\n * this function is executed by the physics engine\r\n */\r\n public afterStep = () => {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._onAfterPhysicsStepCallbacks.forEach((func) => {\r\n func(this);\r\n });\r\n\r\n this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this);\r\n // object has now its world rotation. needs to be converted to local.\r\n if (this.object.parent && this.object.rotationQuaternion) {\r\n this.getParentsRotation();\r\n this._tmpQuat.conjugateInPlace();\r\n this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this.object.rotationQuaternion);\r\n }\r\n // take the position set and make it the absolute position of this object.\r\n this.object.setAbsolutePosition(this.object.position);\r\n this._deltaRotation && this.object.rotationQuaternion && this.object.rotationQuaternion.multiplyToRef(this._deltaRotation, this.object.rotationQuaternion);\r\n this.object.translate(this._deltaPosition, 1);\r\n };\r\n\r\n /**\r\n * Legacy collision detection event support\r\n */\r\n public onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void> = null;\r\n\r\n /**\r\n * event and body object due to cannon's event-based architecture.\r\n * @param e\r\n * @param e.body\r\n * @param e.point\r\n */\r\n public onCollide = (e: { body: any; point: Nullable<Vector3> }) => {\r\n if (!this._onPhysicsCollideCallbacks.length && !this.onCollideEvent) {\r\n return;\r\n }\r\n\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body);\r\n if (otherImpostor) {\r\n // Legacy collision detection event support\r\n if (this.onCollideEvent) {\r\n this.onCollideEvent(this, otherImpostor);\r\n }\r\n this._onPhysicsCollideCallbacks\r\n .filter((obj) => {\r\n return obj.otherImpostors.indexOf(<PhysicsImpostor>otherImpostor) !== -1;\r\n })\r\n .forEach((obj) => {\r\n obj.callback(this, <PhysicsImpostor>otherImpostor, e.point);\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Apply a force\r\n * @param force The force to apply\r\n * @param contactPoint The contact point for the force\r\n * @returns The physics imposter\r\n */\r\n public applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Apply an impulse\r\n * @param force The impulse force\r\n * @param contactPoint The contact point for the impulse force\r\n * @returns The physics imposter\r\n */\r\n public applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * A help function to create a joint\r\n * @param otherImpostor A physics imposter used to create a joint\r\n * @param jointType The type of joint\r\n * @param jointData The data for the joint\r\n * @returns The physics imposter\r\n */\r\n public createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor {\r\n const joint = new PhysicsJoint(jointType, jointData);\r\n this.addJoint(otherImpostor, joint);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a joint to this impostor with a different impostor\r\n * @param otherImpostor A physics imposter used to add a joint\r\n * @param joint The joint to add\r\n * @returns The physics imposter\r\n */\r\n public addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor {\r\n this._joints.push({\r\n otherImpostor: otherImpostor,\r\n joint: joint,\r\n });\r\n\r\n if (this._physicsEngine) {\r\n this._physicsEngine.addJoint(this, otherImpostor, joint);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Add an anchor to a cloth impostor\r\n * @param otherImpostor rigid impostor to anchor to\r\n * @param width ratio across width from 0 to 1\r\n * @param height ratio up height from 0 to 1\r\n * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch\r\n * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false\r\n * @returns impostor the soft imposter\r\n */\r\n public addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor {\r\n if (!this._physicsEngine) {\r\n return this;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.appendAnchor) {\r\n return this;\r\n }\r\n if (this._physicsEngine) {\r\n plugin.appendAnchor!(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a hook to a rope impostor\r\n * @param otherImpostor rigid impostor to anchor to\r\n * @param length ratio across rope from 0 to 1\r\n * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch\r\n * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false\r\n * @returns impostor the rope imposter\r\n */\r\n public addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor {\r\n if (!this._physicsEngine) {\r\n return this;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.appendAnchor) {\r\n return this;\r\n }\r\n if (this._physicsEngine) {\r\n plugin.appendHook!(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Will keep this body still, in a sleep mode.\r\n * @returns the physics imposter\r\n */\r\n public sleep(): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().sleepBody(this);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Wake the body up.\r\n * @returns The physics imposter\r\n */\r\n public wakeUp(): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the physics imposter\r\n * @param newObject The physics imposter clones to this physics-enabled object\r\n * @returns A nullable physics imposter\r\n */\r\n public clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor> {\r\n if (!newObject) {\r\n return null;\r\n }\r\n return new PhysicsImpostor(newObject, this.type, this._options, this._scene);\r\n }\r\n\r\n /**\r\n * Disposes the physics imposter\r\n */\r\n public dispose(/*disposeChildren: boolean = true*/) {\r\n //no dispose if no physics engine is available.\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._joints.forEach((j) => {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.removeJoint(this, j.otherImpostor, j.joint);\r\n }\r\n });\r\n //dispose the physics body\r\n this._physicsEngine.removeImpostor(this);\r\n if (this.parent) {\r\n this.parent.forceUpdate();\r\n } else {\r\n /*this._object.getChildMeshes().forEach(function(mesh) {\r\n if (mesh.physicsImpostor) {\r\n if (disposeChildren) {\r\n mesh.physicsImpostor.dispose();\r\n mesh.physicsImpostor = null;\r\n }\r\n }\r\n })*/\r\n }\r\n\r\n this._isDisposed = true;\r\n }\r\n\r\n /**\r\n * Sets the delta position\r\n * @param position The delta position amount\r\n */\r\n public setDeltaPosition(position: Vector3) {\r\n this._deltaPosition.copyFrom(position);\r\n }\r\n\r\n /**\r\n * Sets the delta rotation\r\n * @param rotation The delta rotation amount\r\n */\r\n public setDeltaRotation(rotation: Quaternion) {\r\n if (!this._deltaRotation) {\r\n this._deltaRotation = new Quaternion();\r\n }\r\n this._deltaRotation.copyFrom(rotation);\r\n this._deltaRotationConjugated = this._deltaRotation.conjugate();\r\n }\r\n\r\n /**\r\n * Gets the box size of the physics imposter and stores the result in the input parameter\r\n * @param result Stores the box size\r\n * @returns The physics imposter\r\n */\r\n public getBoxSizeToRef(result: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the radius of the physics imposter\r\n * @returns Radius of the physics imposter\r\n */\r\n public getRadius(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;\r\n }\r\n\r\n /**\r\n * Sync a bone with this impostor\r\n * @param bone The bone to sync to the impostor.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n */\r\n public syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion) {\r\n const tempVec = PhysicsImpostor._TmpVecs[0];\r\n const mesh = <AbstractMesh>this.object;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = PhysicsImpostor._TmpQuat;\r\n mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);\r\n bone.setRotationQuaternion(tempQuat, Space.WORLD, boneMesh);\r\n } else {\r\n bone.setRotationQuaternion(mesh.rotationQuaternion, Space.WORLD, boneMesh);\r\n }\r\n }\r\n\r\n tempVec.x = 0;\r\n tempVec.y = 0;\r\n tempVec.z = 0;\r\n\r\n if (jointPivot) {\r\n tempVec.x = jointPivot.x;\r\n tempVec.y = jointPivot.y;\r\n tempVec.z = jointPivot.z;\r\n\r\n bone.getDirectionToRef(tempVec, boneMesh, tempVec);\r\n\r\n if (distToJoint === undefined || distToJoint === null) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n tempVec.x *= distToJoint;\r\n tempVec.y *= distToJoint;\r\n tempVec.z *= distToJoint;\r\n }\r\n\r\n if (bone.getParent()) {\r\n tempVec.addInPlace(mesh.getAbsolutePosition());\r\n bone.setAbsolutePosition(tempVec, boneMesh);\r\n } else {\r\n boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());\r\n boneMesh.position.x -= tempVec.x;\r\n boneMesh.position.y -= tempVec.y;\r\n boneMesh.position.z -= tempVec.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sync impostor to a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = <AbstractMesh>this.object;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = PhysicsImpostor._TmpQuat;\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = PhysicsImpostor._TmpVecs[0];\r\n const boneDir = PhysicsImpostor._TmpVecs[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = PhysicsImpostor._TmpVecs[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n //Impostor types\r\n /**\r\n * No-Imposter type\r\n */\r\n public static NoImpostor = 0;\r\n /**\r\n * Sphere-Imposter type\r\n */\r\n public static SphereImpostor = 1;\r\n /**\r\n * Box-Imposter type\r\n */\r\n public static BoxImpostor = 2;\r\n /**\r\n * Plane-Imposter type\r\n */\r\n public static PlaneImpostor = 3;\r\n /**\r\n * Mesh-imposter type (Only available to objects with vertices data)\r\n */\r\n public static MeshImpostor = 4;\r\n /**\r\n * Capsule-Impostor type (Ammo.js plugin only)\r\n */\r\n public static CapsuleImpostor = 6;\r\n /**\r\n * Cylinder-Imposter type\r\n */\r\n public static CylinderImpostor = 7;\r\n /**\r\n * Particle-Imposter type\r\n */\r\n public static ParticleImpostor = 8;\r\n /**\r\n * Heightmap-Imposter type\r\n */\r\n public static HeightmapImpostor = 9;\r\n /**\r\n * ConvexHull-Impostor type (Ammo.js plugin only)\r\n */\r\n public static ConvexHullImpostor = 10;\r\n /**\r\n * Custom-Imposter type (Ammo.js plugin only)\r\n */\r\n public static CustomImpostor = 100;\r\n /**\r\n * Rope-Imposter type\r\n */\r\n public static RopeImpostor = 101;\r\n /**\r\n * Cloth-Imposter type\r\n */\r\n public static ClothImpostor = 102;\r\n /**\r\n * Softbody-Imposter type\r\n */\r\n public static SoftbodyImpostor = 103;\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsImpostor.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/physic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G,CAAC,CAAC;IACnC;;OAEG;IACW,iCAAiB,GAAG,CAAC,CAAC;IACpC;;OAEG;IACW,kCAAkB,GAAG,EAAE,CAAC;IACtC;;OAEG;IACW,8BAAc,GAAG,GAAG,CAAC;IACnC;;OAEG;IACW,4BAAY,GAAG,GAAG,CAAC;IACjC;;OAEG;IACW,6BAAa,GAAG,GAAG,CAAC;IAClC;;OAEG;IACW,gCAAgB,GAAG,GAAG,CAAC;IACzC,sBAAC;CAAA,AAplCD,IAolCC;SAplCY,eAAe","sourcesContent":["import type { Nullable, IndicesArray } from \"../types\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { ArrayTools } from \"../Misc/arrayTools\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, Quaternion } from \"../Maths/math.vector\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Bone } from \"../Bones/bone\";\r\nimport type { BoundingInfo } from \"../Culling/boundingInfo\";\r\nimport type { IPhysicsEngine } from \"./IPhysicsEngine\";\r\nimport type { PhysicsJointData } from \"./physicsJoint\";\r\nimport { PhysicsJoint } from \"./physicsJoint\";\r\nimport { Space } from \"../Maths/math.axis\";\r\n\r\n/**\r\n * The interface for the physics imposter parameters\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport interface PhysicsImpostorParameters {\r\n /**\r\n * The mass of the physics imposter\r\n */\r\n mass: number;\r\n /**\r\n * The friction of the physics imposter\r\n */\r\n friction?: number;\r\n /**\r\n * The coefficient of restitution of the physics imposter\r\n */\r\n restitution?: number;\r\n /**\r\n * The native options of the physics imposter\r\n */\r\n nativeOptions?: any;\r\n /**\r\n * Specifies if the parent should be ignored\r\n */\r\n ignoreParent?: boolean;\r\n /**\r\n * Specifies if bi-directional transformations should be disabled\r\n */\r\n disableBidirectionalTransformation?: boolean;\r\n /**\r\n * The pressure inside the physics imposter, soft object only\r\n */\r\n pressure?: number;\r\n /**\r\n * The stiffness the physics imposter, soft object only\r\n */\r\n stiffness?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex velocities, soft object only\r\n */\r\n velocityIterations?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex positions, soft object only\r\n */\r\n positionIterations?: number;\r\n /**\r\n * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only\r\n * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right\r\n * Add to fix multiple points\r\n */\r\n fixedPoints?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n margin?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n damping?: number;\r\n /**\r\n * The path for a rope based on an extrusion\r\n */\r\n path?: any;\r\n /**\r\n * The shape of an extrusion used for a rope based on an extrusion\r\n */\r\n shape?: any;\r\n}\r\n\r\n/**\r\n * Interface for a physics-enabled object\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport interface IPhysicsEnabledObject {\r\n /**\r\n * The position of the physics-enabled object\r\n */\r\n position: Vector3;\r\n /**\r\n * The rotation of the physics-enabled object\r\n */\r\n rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * The scale of the physics-enabled object\r\n */\r\n scaling: Vector3;\r\n /**\r\n * The rotation of the physics-enabled object\r\n */\r\n rotation?: Vector3;\r\n /**\r\n * The parent of the physics-enabled object\r\n */\r\n parent?: any;\r\n /**\r\n * The bounding info of the physics-enabled object\r\n * @returns The bounding info of the physics-enabled object\r\n */\r\n getBoundingInfo(): BoundingInfo;\r\n /**\r\n * Computes the world matrix\r\n * @param force Specifies if the world matrix should be computed by force\r\n * @returns A world matrix\r\n */\r\n computeWorldMatrix(force: boolean): Matrix;\r\n /**\r\n * Gets the world matrix\r\n * @returns A world matrix\r\n */\r\n getWorldMatrix?(): Matrix;\r\n /**\r\n * Gets the child meshes\r\n * @param directDescendantsOnly Specifies if only direct-descendants should be obtained\r\n * @returns An array of abstract meshes\r\n */\r\n getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;\r\n /**\r\n * Gets the vertex data\r\n * @param kind The type of vertex data\r\n * @returns A nullable array of numbers, or a float32 array\r\n */\r\n getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;\r\n /**\r\n * Gets the indices from the mesh\r\n * @returns A nullable array of index arrays\r\n */\r\n getIndices?(): Nullable<IndicesArray>;\r\n /**\r\n * Gets the scene from the mesh\r\n * @returns the indices array or null\r\n */\r\n getScene?(): Scene;\r\n /**\r\n * Gets the absolute position from the mesh\r\n * @returns the absolute position\r\n */\r\n getAbsolutePosition(): Vector3;\r\n /**\r\n * Gets the absolute pivot point from the mesh\r\n * @returns the absolute pivot point\r\n */\r\n getAbsolutePivotPoint(): Vector3;\r\n /**\r\n * Rotates the mesh\r\n * @param axis The axis of rotation\r\n * @param amount The amount of rotation\r\n * @param space The space of the rotation\r\n * @returns The rotation transform node\r\n */\r\n rotate(axis: Vector3, amount: number, space?: Space): TransformNode;\r\n /**\r\n * Translates the mesh\r\n * @param axis The axis of translation\r\n * @param distance The distance of translation\r\n * @param space The space of the translation\r\n * @returns The transform node\r\n */\r\n translate(axis: Vector3, distance: number, space?: Space): TransformNode;\r\n /**\r\n * Sets the absolute position of the mesh\r\n * @param absolutePosition The absolute position of the mesh\r\n * @returns The transform node\r\n */\r\n setAbsolutePosition(absolutePosition: Vector3): TransformNode;\r\n /**\r\n * Gets the class name of the mesh\r\n * @returns The class name\r\n */\r\n getClassName(): string;\r\n}\r\n\r\nMesh._PhysicsImpostorParser = function (scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor {\r\n return new PhysicsImpostor(\r\n physicObject,\r\n jsonObject.physicsImpostor,\r\n {\r\n mass: jsonObject.physicsMass,\r\n friction: jsonObject.physicsFriction,\r\n restitution: jsonObject.physicsRestitution,\r\n },\r\n scene\r\n );\r\n};\r\n\r\n/**\r\n * Represents a physics imposter\r\n * @see https://doc.babylonjs.com/how_to/using_the_physics_engine\r\n */\r\nexport class PhysicsImpostor {\r\n /**\r\n * The default object size of the imposter\r\n */\r\n public static DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n\r\n /**\r\n * The identity quaternion of the imposter\r\n */\r\n public static IDENTITY_QUATERNION = Quaternion.Identity();\r\n\r\n /** @hidden */\r\n public _pluginData: any = {};\r\n\r\n private _physicsEngine: Nullable<IPhysicsEngine>;\r\n //The native cannon/oimo/energy physics body object.\r\n private _physicsBody: any;\r\n private _bodyUpdateRequired: boolean = false;\r\n\r\n private _onBeforePhysicsStepCallbacks = new Array<(impostor: PhysicsImpostor) => void>();\r\n private _onAfterPhysicsStepCallbacks = new Array<(impostor: PhysicsImpostor) => void>();\r\n /** @hidden */\r\n public _onPhysicsCollideCallbacks: Array<{\r\n callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;\r\n otherImpostors: Array<PhysicsImpostor>;\r\n }> = [];\r\n\r\n private _deltaPosition: Vector3 = Vector3.Zero();\r\n private _deltaRotation: Quaternion;\r\n private _deltaRotationConjugated: Quaternion;\r\n\r\n /** @hidden */\r\n public _isFromLine: boolean;\r\n\r\n //If set, this is this impostor's parent\r\n private _parent: Nullable<PhysicsImpostor>;\r\n\r\n private _isDisposed = false;\r\n\r\n private static _TmpVecs: Vector3[] = ArrayTools.BuildArray(3, Vector3.Zero);\r\n private static _TmpQuat: Quaternion = Quaternion.Identity();\r\n\r\n /**\r\n * Specifies if the physics imposter is disposed\r\n */\r\n get isDisposed(): boolean {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Gets the mass of the physics imposter\r\n */\r\n get mass(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;\r\n }\r\n\r\n set mass(value: number) {\r\n this.setMass(value);\r\n }\r\n\r\n /**\r\n * Gets the coefficient of friction\r\n */\r\n get friction(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;\r\n }\r\n\r\n /**\r\n * Sets the coefficient of friction\r\n */\r\n set friction(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);\r\n }\r\n\r\n /**\r\n * Gets the coefficient of restitution\r\n */\r\n get restitution(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;\r\n }\r\n\r\n /**\r\n * Sets the coefficient of restitution\r\n */\r\n set restitution(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);\r\n }\r\n\r\n /**\r\n * Gets the pressure of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get pressure(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPressure) {\r\n return 0;\r\n }\r\n return plugin.getBodyPressure!(this);\r\n }\r\n\r\n /**\r\n * Sets the pressure of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set pressure(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPressure) {\r\n return;\r\n }\r\n plugin.setBodyPressure!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get stiffness(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyStiffness) {\r\n return 0;\r\n }\r\n return plugin.getBodyStiffness!(this);\r\n }\r\n\r\n /**\r\n * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set stiffness(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyStiffness) {\r\n return;\r\n }\r\n plugin.setBodyStiffness!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get velocityIterations(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyVelocityIterations) {\r\n return 0;\r\n }\r\n return plugin.getBodyVelocityIterations!(this);\r\n }\r\n\r\n /**\r\n * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set velocityIterations(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyVelocityIterations) {\r\n return;\r\n }\r\n plugin.setBodyVelocityIterations!(this, value);\r\n }\r\n\r\n /**\r\n * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n get positionIterations(): number {\r\n if (!this._physicsEngine) {\r\n return 0;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.getBodyPositionIterations) {\r\n return 0;\r\n }\r\n return plugin.getBodyPositionIterations!(this);\r\n }\r\n\r\n /**\r\n * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin\r\n */\r\n set positionIterations(value: number) {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.setBodyPositionIterations) {\r\n return;\r\n }\r\n plugin.setBodyPositionIterations!(this, value);\r\n }\r\n\r\n /**\r\n * The unique id of the physics imposter\r\n * set by the physics engine when adding this impostor to the array\r\n */\r\n public uniqueId: number;\r\n\r\n /**\r\n * @hidden\r\n */\r\n public soft: boolean = false;\r\n\r\n /**\r\n * @hidden\r\n */\r\n public segments: number = 0;\r\n\r\n private _joints: Array<{\r\n joint: PhysicsJoint;\r\n otherImpostor: PhysicsImpostor;\r\n }>;\r\n\r\n /**\r\n * Initializes the physics imposter\r\n * @param object The physics-enabled object used as the physics imposter\r\n * @param type The type of the physics imposter. Types are available as static members of this class.\r\n * @param _options The options for the physics imposter\r\n * @param _scene The Babylon scene\r\n */\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics imposter\r\n */\r\n public object: IPhysicsEnabledObject,\r\n /**\r\n * The type of the physics imposter\r\n */\r\n public type: number,\r\n private _options: PhysicsImpostorParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.object) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n if (this.object.parent && _options.mass !== 0) {\r\n Logger.Warn(\"A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.\");\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && object.getScene) {\r\n this._scene = object.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n if (this.type > 100) {\r\n this.soft = true;\r\n }\r\n\r\n this._physicsEngine = this._scene.getPhysicsEngine();\r\n if (!this._physicsEngine) {\r\n Logger.Error(\"Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.\");\r\n } else {\r\n //set the object's quaternion, if not set\r\n if (!this.object.rotationQuaternion) {\r\n if (this.object.rotation) {\r\n this.object.rotationQuaternion = Quaternion.RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);\r\n } else {\r\n this.object.rotationQuaternion = new Quaternion();\r\n }\r\n }\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n if (this.soft) {\r\n //softbody mass must be above 0;\r\n this._options.mass = this._options.mass > 0 ? this._options.mass : 1;\r\n this._options.pressure = _options.pressure === void 0 ? 200 : _options.pressure;\r\n this._options.stiffness = _options.stiffness === void 0 ? 1 : _options.stiffness;\r\n this._options.velocityIterations = _options.velocityIterations === void 0 ? 20 : _options.velocityIterations;\r\n this._options.positionIterations = _options.positionIterations === void 0 ? 20 : _options.positionIterations;\r\n this._options.fixedPoints = _options.fixedPoints === void 0 ? 0 : _options.fixedPoints;\r\n this._options.margin = _options.margin === void 0 ? 0 : _options.margin;\r\n this._options.damping = _options.damping === void 0 ? 0 : _options.damping;\r\n this._options.path = _options.path === void 0 ? null : _options.path;\r\n this._options.shape = _options.shape === void 0 ? null : _options.shape;\r\n }\r\n this._joints = [];\r\n //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.\r\n if (!this.object.parent || this._options.ignoreParent) {\r\n this._init();\r\n } else if (this.object.parent.physicsImpostor) {\r\n Logger.Warn(\"You must affect impostors to children before affecting impostor to parent.\");\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * This function will completely initialize this impostor.\r\n * It will create a new body - but only if this mesh has no parent.\r\n * If it has, this impostor will not be used other than to define the impostor\r\n * of the child mesh.\r\n * @hidden\r\n */\r\n public _init() {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._physicsEngine.removeImpostor(this);\r\n this.physicsBody = null;\r\n this._parent = this._parent || this._getPhysicsParent();\r\n if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {\r\n this._physicsEngine.addImpostor(this);\r\n }\r\n }\r\n\r\n private _getPhysicsParent(): Nullable<PhysicsImpostor> {\r\n if (this.object.parent instanceof AbstractMesh) {\r\n const parentMesh: AbstractMesh = <AbstractMesh>this.object.parent;\r\n return parentMesh.physicsImpostor;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Should a new body be generated.\r\n * @returns boolean specifying if body initialization is required\r\n */\r\n public isBodyInitRequired(): boolean {\r\n return this._bodyUpdateRequired || (!this._physicsBody && (!this._parent || !!this._options.ignoreParent));\r\n }\r\n\r\n /**\r\n * Sets the updated scaling\r\n */\r\n public setScalingUpdated() {\r\n this.forceUpdate();\r\n }\r\n\r\n /**\r\n * Force a regeneration of this or the parent's impostor's body.\r\n * Use with caution - This will remove all previously-instantiated joints.\r\n */\r\n public forceUpdate() {\r\n this._init();\r\n if (this.parent && !this._options.ignoreParent) {\r\n this.parent.forceUpdate();\r\n }\r\n }\r\n\r\n /*public get mesh(): AbstractMesh {\r\n return this._mesh;\r\n }*/\r\n\r\n /**\r\n * Gets the body that holds this impostor. Either its own, or its parent.\r\n */\r\n public get physicsBody(): any {\r\n return this._parent && !this._options.ignoreParent ? this._parent.physicsBody : this._physicsBody;\r\n }\r\n\r\n /**\r\n * Get the parent of the physics imposter\r\n * @returns Physics imposter or null\r\n */\r\n public get parent(): Nullable<PhysicsImpostor> {\r\n return !this._options.ignoreParent && this._parent ? this._parent : null;\r\n }\r\n\r\n /**\r\n * Sets the parent of the physics imposter\r\n */\r\n public set parent(value: Nullable<PhysicsImpostor>) {\r\n this._parent = value;\r\n }\r\n\r\n /**\r\n * Set the physics body. Used mainly by the physics engine/plugin\r\n */\r\n public set physicsBody(physicsBody: any) {\r\n if (this._physicsBody && this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);\r\n }\r\n this._physicsBody = physicsBody;\r\n this.resetUpdateFlags();\r\n }\r\n\r\n /**\r\n * Resets the update flags\r\n */\r\n public resetUpdateFlags() {\r\n this._bodyUpdateRequired = false;\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n if (this.object.getBoundingInfo) {\r\n const q = this.object.rotationQuaternion;\r\n const scaling = this.object.scaling.clone();\r\n //reset rotation\r\n this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n const boundingInfo = this.object.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.object.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsImpostor.DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the object center\r\n * @returns The object center\r\n */\r\n public getObjectCenter(): Vector3 {\r\n if (this.object.getBoundingInfo) {\r\n const boundingInfo = this.object.getBoundingInfo();\r\n return boundingInfo.boundingBox.centerWorld;\r\n } else {\r\n return this.object.position;\r\n }\r\n }\r\n\r\n /**\r\n * Get a specific parameter from the options parameters\r\n * @param paramName The object parameter name\r\n * @returns The object parameter\r\n */\r\n public getParam(paramName: string): any {\r\n return (<any>this._options)[paramName];\r\n }\r\n\r\n /**\r\n * Sets a specific parameter in the options given to the physics plugin\r\n * @param paramName The parameter name\r\n * @param value The value of the parameter\r\n */\r\n public setParam(paramName: string, value: number) {\r\n (<any>this._options)[paramName] = value;\r\n this._bodyUpdateRequired = true;\r\n }\r\n\r\n /**\r\n * Specifically change the body's mass. Won't recreate the physics body object\r\n * @param mass The mass of the physics imposter\r\n */\r\n public setMass(mass: number) {\r\n if (this.getParam(\"mass\") !== mass) {\r\n this.setParam(\"mass\", mass);\r\n }\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the linear velocity\r\n * @returns linear velocity or null\r\n */\r\n public getLinearVelocity(): Nullable<Vector3> {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the linear velocity\r\n * @param velocity linear velocity or null\r\n */\r\n public setLinearVelocity(velocity: Nullable<Vector3>) {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the angular velocity\r\n * @returns angular velocity or null\r\n */\r\n public getAngularVelocity(): Nullable<Vector3> {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the angular velocity\r\n * @param velocity The velocity or null\r\n */\r\n public setAngularVelocity(velocity: Nullable<Vector3>) {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);\r\n }\r\n }\r\n\r\n /**\r\n * Execute a function with the physics plugin native code\r\n * Provide a function the will have two variables - the world object and the physics body object\r\n * @param func The function to execute with the physics plugin native code\r\n */\r\n public executeNativeFunction(func: (world: any, physicsBody: any) => void) {\r\n if (this._physicsEngine) {\r\n func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);\r\n }\r\n }\r\n\r\n /**\r\n * Register a function that will be executed before the physics world is stepping forward\r\n * @param func The function to execute before the physics world is stepped forward\r\n */\r\n public registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n this._onBeforePhysicsStepCallbacks.push(func);\r\n }\r\n\r\n /**\r\n * Unregister a function that will be executed before the physics world is stepping forward\r\n * @param func The function to execute before the physics world is stepped forward\r\n */\r\n public unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n const index = this._onBeforePhysicsStepCallbacks.indexOf(func);\r\n\r\n if (index > -1) {\r\n this._onBeforePhysicsStepCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n /**\r\n * Register a function that will be executed after the physics step\r\n * @param func The function to execute after physics step\r\n */\r\n public registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n this._onAfterPhysicsStepCallbacks.push(func);\r\n }\r\n\r\n /**\r\n * Unregisters a function that will be executed after the physics step\r\n * @param func The function to execute after physics step\r\n */\r\n public unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void {\r\n const index = this._onAfterPhysicsStepCallbacks.indexOf(func);\r\n\r\n if (index > -1) {\r\n this._onAfterPhysicsStepCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n /**\r\n * register a function that will be executed when this impostor collides against a different body\r\n * @param collideAgainst Physics imposter, or array of physics imposters to collide against\r\n * @param func Callback that is executed on collision\r\n */\r\n public registerOnPhysicsCollide(\r\n collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>,\r\n func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void\r\n ): void {\r\n const collidedAgainstList: Array<PhysicsImpostor> = collideAgainst instanceof Array ? <Array<PhysicsImpostor>>collideAgainst : [<PhysicsImpostor>collideAgainst];\r\n this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });\r\n }\r\n\r\n /**\r\n * Unregisters the physics imposter's collision callback\r\n * @param collideAgainst The physics object to collide against\r\n * @param func Callback to execute on collision\r\n */\r\n public unregisterOnPhysicsCollide(\r\n collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>,\r\n func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>, point: Nullable<Vector3>) => void\r\n ): void {\r\n const collidedAgainstList: Array<PhysicsImpostor> = collideAgainst instanceof Array ? <Array<PhysicsImpostor>>collideAgainst : [<PhysicsImpostor>collideAgainst];\r\n let index = -1;\r\n const found = this._onPhysicsCollideCallbacks.some((cbDef, idx) => {\r\n if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {\r\n // chcek the arrays match\r\n const sameList = cbDef.otherImpostors.every((impostor) => {\r\n return collidedAgainstList.indexOf(impostor) > -1;\r\n });\r\n if (sameList) {\r\n index = idx;\r\n }\r\n return sameList;\r\n }\r\n return false;\r\n });\r\n\r\n if (found) {\r\n this._onPhysicsCollideCallbacks.splice(index, 1);\r\n } else {\r\n Logger.Warn(\"Function to remove was not found\");\r\n }\r\n }\r\n\r\n //temp variables for parent rotation calculations\r\n //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];\r\n private _tmpQuat: Quaternion = new Quaternion();\r\n private _tmpQuat2: Quaternion = new Quaternion();\r\n\r\n /**\r\n * Get the parent rotation\r\n * @returns The parent rotation\r\n */\r\n public getParentsRotation(): Quaternion {\r\n let parent = this.object.parent;\r\n this._tmpQuat.copyFromFloats(0, 0, 0, 1);\r\n while (parent) {\r\n if (parent.rotationQuaternion) {\r\n this._tmpQuat2.copyFrom(parent.rotationQuaternion);\r\n } else {\r\n Quaternion.RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);\r\n }\r\n this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);\r\n parent = parent.parent;\r\n }\r\n return this._tmpQuat;\r\n }\r\n\r\n /**\r\n * this function is executed by the physics engine.\r\n */\r\n public beforeStep = () => {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this.object.translate(this._deltaPosition, -1);\r\n this._deltaRotationConjugated &&\r\n this.object.rotationQuaternion &&\r\n this.object.rotationQuaternion.multiplyToRef(this._deltaRotationConjugated, this.object.rotationQuaternion);\r\n this.object.computeWorldMatrix(false);\r\n if (this.object.parent && this.object.rotationQuaternion) {\r\n this.getParentsRotation();\r\n this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this._tmpQuat);\r\n } else {\r\n this._tmpQuat.copyFrom(this.object.rotationQuaternion || new Quaternion());\r\n }\r\n if (!this._options.disableBidirectionalTransformation) {\r\n this.object.rotationQuaternion &&\r\n this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(this, /*bInfo.boundingBox.centerWorld*/ this.object.getAbsolutePosition(), this._tmpQuat);\r\n }\r\n\r\n this._onBeforePhysicsStepCallbacks.forEach((func) => {\r\n func(this);\r\n });\r\n };\r\n\r\n /**\r\n * this function is executed by the physics engine\r\n */\r\n public afterStep = () => {\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._onAfterPhysicsStepCallbacks.forEach((func) => {\r\n func(this);\r\n });\r\n\r\n this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this);\r\n // object has now its world rotation. needs to be converted to local.\r\n if (this.object.parent && this.object.rotationQuaternion) {\r\n this.getParentsRotation();\r\n this._tmpQuat.conjugateInPlace();\r\n this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this.object.rotationQuaternion);\r\n }\r\n // take the position set and make it the absolute position of this object.\r\n this.object.setAbsolutePosition(this.object.position);\r\n if (this._deltaRotation) {\r\n this.object.rotationQuaternion && this.object.rotationQuaternion.multiplyToRef(this._deltaRotation, this.object.rotationQuaternion);\r\n this._deltaPosition.applyRotationQuaternionToRef(this._deltaRotation, PhysicsImpostor._TmpVecs[0]);\r\n this.object.translate(PhysicsImpostor._TmpVecs[0], 1);\r\n } else {\r\n this.object.translate(this._deltaPosition, 1);\r\n }\r\n this.object.computeWorldMatrix(true);\r\n };\r\n\r\n /**\r\n * Legacy collision detection event support\r\n */\r\n public onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void> = null;\r\n\r\n /**\r\n * event and body object due to cannon's event-based architecture.\r\n * @param e\r\n * @param e.body\r\n * @param e.point\r\n */\r\n public onCollide = (e: { body: any; point: Nullable<Vector3> }) => {\r\n if (!this._onPhysicsCollideCallbacks.length && !this.onCollideEvent) {\r\n return;\r\n }\r\n\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n const otherImpostor = this._physicsEngine.getImpostorWithPhysicsBody(e.body);\r\n if (otherImpostor) {\r\n // Legacy collision detection event support\r\n if (this.onCollideEvent) {\r\n this.onCollideEvent(this, otherImpostor);\r\n }\r\n this._onPhysicsCollideCallbacks\r\n .filter((obj) => {\r\n return obj.otherImpostors.indexOf(<PhysicsImpostor>otherImpostor) !== -1;\r\n })\r\n .forEach((obj) => {\r\n obj.callback(this, <PhysicsImpostor>otherImpostor, e.point);\r\n });\r\n }\r\n };\r\n\r\n /**\r\n * Apply a force\r\n * @param force The force to apply\r\n * @param contactPoint The contact point for the force\r\n * @returns The physics imposter\r\n */\r\n public applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Apply an impulse\r\n * @param force The impulse force\r\n * @param contactPoint The contact point for the impulse force\r\n * @returns The physics imposter\r\n */\r\n public applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * A help function to create a joint\r\n * @param otherImpostor A physics imposter used to create a joint\r\n * @param jointType The type of joint\r\n * @param jointData The data for the joint\r\n * @returns The physics imposter\r\n */\r\n public createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor {\r\n const joint = new PhysicsJoint(jointType, jointData);\r\n this.addJoint(otherImpostor, joint);\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a joint to this impostor with a different impostor\r\n * @param otherImpostor A physics imposter used to add a joint\r\n * @param joint The joint to add\r\n * @returns The physics imposter\r\n */\r\n public addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor {\r\n this._joints.push({\r\n otherImpostor: otherImpostor,\r\n joint: joint,\r\n });\r\n\r\n if (this._physicsEngine) {\r\n this._physicsEngine.addJoint(this, otherImpostor, joint);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Add an anchor to a cloth impostor\r\n * @param otherImpostor rigid impostor to anchor to\r\n * @param width ratio across width from 0 to 1\r\n * @param height ratio up height from 0 to 1\r\n * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch\r\n * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false\r\n * @returns impostor the soft imposter\r\n */\r\n public addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor {\r\n if (!this._physicsEngine) {\r\n return this;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.appendAnchor) {\r\n return this;\r\n }\r\n if (this._physicsEngine) {\r\n plugin.appendAnchor!(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Add a hook to a rope impostor\r\n * @param otherImpostor rigid impostor to anchor to\r\n * @param length ratio across rope from 0 to 1\r\n * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch\r\n * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false\r\n * @returns impostor the rope imposter\r\n */\r\n public addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor {\r\n if (!this._physicsEngine) {\r\n return this;\r\n }\r\n const plugin = this._physicsEngine.getPhysicsPlugin();\r\n if (!plugin.appendAnchor) {\r\n return this;\r\n }\r\n if (this._physicsEngine) {\r\n plugin.appendHook!(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Will keep this body still, in a sleep mode.\r\n * @returns the physics imposter\r\n */\r\n public sleep(): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().sleepBody(this);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Wake the body up.\r\n * @returns The physics imposter\r\n */\r\n public wakeUp(): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Clones the physics imposter\r\n * @param newObject The physics imposter clones to this physics-enabled object\r\n * @returns A nullable physics imposter\r\n */\r\n public clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor> {\r\n if (!newObject) {\r\n return null;\r\n }\r\n return new PhysicsImpostor(newObject, this.type, this._options, this._scene);\r\n }\r\n\r\n /**\r\n * Disposes the physics imposter\r\n */\r\n public dispose(/*disposeChildren: boolean = true*/) {\r\n //no dispose if no physics engine is available.\r\n if (!this._physicsEngine) {\r\n return;\r\n }\r\n\r\n this._joints.forEach((j) => {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.removeJoint(this, j.otherImpostor, j.joint);\r\n }\r\n });\r\n //dispose the physics body\r\n this._physicsEngine.removeImpostor(this);\r\n if (this.parent) {\r\n this.parent.forceUpdate();\r\n } else {\r\n /*this._object.getChildMeshes().forEach(function(mesh) {\r\n if (mesh.physicsImpostor) {\r\n if (disposeChildren) {\r\n mesh.physicsImpostor.dispose();\r\n mesh.physicsImpostor = null;\r\n }\r\n }\r\n })*/\r\n }\r\n\r\n this._isDisposed = true;\r\n }\r\n\r\n /**\r\n * Sets the delta position\r\n * @param position The delta position amount\r\n */\r\n public setDeltaPosition(position: Vector3) {\r\n this._deltaPosition.copyFrom(position);\r\n }\r\n\r\n /**\r\n * Sets the delta rotation\r\n * @param rotation The delta rotation amount\r\n */\r\n public setDeltaRotation(rotation: Quaternion) {\r\n if (!this._deltaRotation) {\r\n this._deltaRotation = new Quaternion();\r\n }\r\n this._deltaRotation.copyFrom(rotation);\r\n this._deltaRotationConjugated = this._deltaRotation.conjugate();\r\n }\r\n\r\n /**\r\n * Gets the box size of the physics imposter and stores the result in the input parameter\r\n * @param result Stores the box size\r\n * @returns The physics imposter\r\n */\r\n public getBoxSizeToRef(result: Vector3): PhysicsImpostor {\r\n if (this._physicsEngine) {\r\n this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Gets the radius of the physics imposter\r\n * @returns Radius of the physics imposter\r\n */\r\n public getRadius(): number {\r\n return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;\r\n }\r\n\r\n /**\r\n * Sync a bone with this impostor\r\n * @param bone The bone to sync to the impostor.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n */\r\n public syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion) {\r\n const tempVec = PhysicsImpostor._TmpVecs[0];\r\n const mesh = <AbstractMesh>this.object;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = PhysicsImpostor._TmpQuat;\r\n mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);\r\n bone.setRotationQuaternion(tempQuat, Space.WORLD, boneMesh);\r\n } else {\r\n bone.setRotationQuaternion(mesh.rotationQuaternion, Space.WORLD, boneMesh);\r\n }\r\n }\r\n\r\n tempVec.x = 0;\r\n tempVec.y = 0;\r\n tempVec.z = 0;\r\n\r\n if (jointPivot) {\r\n tempVec.x = jointPivot.x;\r\n tempVec.y = jointPivot.y;\r\n tempVec.z = jointPivot.z;\r\n\r\n bone.getDirectionToRef(tempVec, boneMesh, tempVec);\r\n\r\n if (distToJoint === undefined || distToJoint === null) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n tempVec.x *= distToJoint;\r\n tempVec.y *= distToJoint;\r\n tempVec.z *= distToJoint;\r\n }\r\n\r\n if (bone.getParent()) {\r\n tempVec.addInPlace(mesh.getAbsolutePosition());\r\n bone.setAbsolutePosition(tempVec, boneMesh);\r\n } else {\r\n boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());\r\n boneMesh.position.x -= tempVec.x;\r\n boneMesh.position.y -= tempVec.y;\r\n boneMesh.position.z -= tempVec.z;\r\n }\r\n }\r\n\r\n /**\r\n * Sync impostor to a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = <AbstractMesh>this.object;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = PhysicsImpostor._TmpQuat;\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = PhysicsImpostor._TmpVecs[0];\r\n const boneDir = PhysicsImpostor._TmpVecs[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = PhysicsImpostor._TmpVecs[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n //Impostor types\r\n /**\r\n * No-Imposter type\r\n */\r\n public static NoImpostor = 0;\r\n /**\r\n * Sphere-Imposter type\r\n */\r\n public static SphereImpostor = 1;\r\n /**\r\n * Box-Imposter type\r\n */\r\n public static BoxImpostor = 2;\r\n /**\r\n * Plane-Imposter type\r\n */\r\n public static PlaneImpostor = 3;\r\n /**\r\n * Mesh-imposter type (Only available to objects with vertices data)\r\n */\r\n public static MeshImpostor = 4;\r\n /**\r\n * Capsule-Impostor type (Ammo.js plugin only)\r\n */\r\n public static CapsuleImpostor = 6;\r\n /**\r\n * Cylinder-Imposter type\r\n */\r\n public static CylinderImpostor = 7;\r\n /**\r\n * Particle-Imposter type\r\n */\r\n public static ParticleImpostor = 8;\r\n /**\r\n * Heightmap-Imposter type\r\n */\r\n public static HeightmapImpostor = 9;\r\n /**\r\n * ConvexHull-Impostor type (Ammo.js plugin only)\r\n */\r\n public static ConvexHullImpostor = 10;\r\n /**\r\n * Custom-Imposter type (Ammo.js plugin only)\r\n */\r\n public static CustomImpostor = 100;\r\n /**\r\n * Rope-Imposter type\r\n */\r\n public static RopeImpostor = 101;\r\n /**\r\n * Cloth-Imposter type\r\n */\r\n public static ClothImpostor = 102;\r\n /**\r\n * Softbody-Imposter type\r\n */\r\n public static SoftbodyImpostor = 103;\r\n}\r\n"]}
@@ -4,7 +4,7 @@ import "./ShadersInclude/fogFragmentDeclaration.js";
4
4
  import "./ShadersInclude/fogFragment.js";
5
5
  import "./ShadersInclude/imageProcessingCompatibility.js";
6
6
  var name = "spritesPixelShader";
7
- var shader = "uniform bool alphaTest;\nvarying vec4 vColor;\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
7
+ var shader = "uniform bool alphaTest;\nvarying vec4 vColor;\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\nif (float(alphaTest) != 0.)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}";
8
8
  // Sideeffect
9
9
  ShaderStore.ShadersStore[name] = shader;
10
10
  /** @hidden */
@@ -1 +1 @@
1
- {"version":3,"file":"sprites.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/sprites.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AACtC,OAAO,+CAA+C,CAAC;AAEvD,IAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,IAAM,MAAM,GAAG,2cAmBb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAM,kBAAkB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/imageProcessingCompatibility\";\n\nconst name = \"spritesPixelShader\";\nconst shader = `uniform bool alphaTest;\rvarying vec4 vColor;\rvarying vec2 vUV;\runiform sampler2D diffuseSampler;\r#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\r#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\rif (alphaTest) \r{\rif (color.a<0.95)\rdiscard;\r}\rcolor*=vColor;\r#include<fogFragment>\ngl_FragColor=color;\r#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const spritesPixelShader = { name, shader };\n"]}
1
+ {"version":3,"file":"sprites.fragment.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Shaders/sprites.fragment.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,yCAAyC,CAAC;AACjD,OAAO,8BAA8B,CAAC;AACtC,OAAO,+CAA+C,CAAC;AAEvD,IAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,IAAM,MAAM,GAAG,udAmBb,CAAC;AACH,aAAa;AACb,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AACxC,cAAc;AACd,MAAM,CAAC,IAAM,kBAAkB,GAAG,EAAE,IAAI,MAAA,EAAE,MAAM,QAAA,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../Engines/shaderStore\";\nimport \"./ShadersInclude/fogFragmentDeclaration\";\nimport \"./ShadersInclude/fogFragment\";\nimport \"./ShadersInclude/imageProcessingCompatibility\";\n\nconst name = \"spritesPixelShader\";\nconst shader = `uniform bool alphaTest;\rvarying vec4 vColor;\rvarying vec2 vUV;\runiform sampler2D diffuseSampler;\r#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\r#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\rif (float(alphaTest) != 0.)\r{\rif (color.a<0.95)\rdiscard;\r}\rcolor*=vColor;\r#include<fogFragment>\ngl_FragColor=color;\r#include<imageProcessingCompatibility>\n#define CUSTOM_FRAGMENT_MAIN_END\n}`;\n// Sideeffect\nShaderStore.ShadersStore[name] = shader;\n/** @hidden */\nexport const spritesPixelShader = { name, shader };\n"]}
@@ -48,7 +48,7 @@ var SpriteRenderer = /** @class */ (function () {
48
48
  this._capacity = capacity;
49
49
  this._epsilon = epsilon;
50
50
  this._engine = engine;
51
- this._useInstancing = engine.getCaps().instancedArrays;
51
+ this._useInstancing = engine.getCaps().instancedArrays && engine._features.supportSpriteInstancing;
52
52
  this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;
53
53
  this._scene = scene;
54
54
  this._drawWrapperBase = new DrawWrapper(engine);
@@ -1 +1 @@
1
- {"version":3,"file":"spriteRenderer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Sprites/spriteRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOvD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,4CAA4C,CAAC;AAEpD,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH;IAoEI;;;;;;OAMG;IACH,wBAAY,MAAkB,EAAE,QAAgB,EAAE,OAAsB,EAAE,KAA6B;QAArD,wBAAA,EAAA,cAAsB;QAAE,sBAAA,EAAA,YAA6B;QA3DvG;;;;WAIG;QACI,cAAS,GAAG,SAAS,CAAC,aAAa,CAAC;QAE3C;;;WAGG;QACI,mBAAc,GAAG,IAAI,CAAC;QAE7B;;;;WAIG;QACI,sBAAiB,GAAY,KAAK,CAAC;QAE1C;;WAEG;QACI,eAAU,GAAG,IAAI,CAAC;QAUR,YAAO,GAAY,KAAK,CA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AAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACzD,IAAI,CAAC,kBAAmB,GAAG,IAAI,CAAC;SACzC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAQ,GAAG,IAAI,CAAC;SAC9B;QACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IACL,qBAAC;AAAD,CAAC,AA7bD,IA6bC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { IMatrixLike } from \"../Maths/math.like\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"../Buffers/buffer\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { ThinSprite } from \"./thinSprite\";\r\nimport type { ISize } from \"../Maths/math.size\";\r\n\r\ndeclare type ThinTexture = import(\"../Materials/Textures/thinTexture\").ThinTexture;\r\ndeclare type Scene = import(\"../scene\").Scene;\r\n\r\nimport \"../Engines/Extensions/engine.alpha\";\r\nimport \"../Engines/Extensions/engine.dynamicBuffer\";\r\n\r\nimport \"../Shaders/sprites.fragment\";\r\nimport \"../Shaders/sprites.vertex\";\r\n\r\n/**\r\n * Class used to render sprites.\r\n *\r\n * It can be used either to render Sprites or ThinSprites with ThinEngine only.\r\n */\r\nexport class SpriteRenderer {\r\n /**\r\n * Defines the texture of the spritesheet\r\n */\r\n public texture: Nullable<ThinTexture>;\r\n\r\n /**\r\n * Defines the default width of a cell in the spritesheet\r\n */\r\n public cellWidth: number;\r\n\r\n /**\r\n * Defines the default height of a cell in the spritesheet\r\n */\r\n public cellHeight: number;\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be any of\r\n * the static Constants.ALPHA_x properties provided in this class.\r\n * Default value is Constants.ALPHA_COMBINE\r\n */\r\n public blendMode = Constants.ALPHA_COMBINE;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if alpha mode is automatically\r\n * reset.\r\n */\r\n public autoResetAlpha = true;\r\n\r\n /**\r\n * Disables writing to the depth buffer when rendering the sprites.\r\n * It can be handy to disable depth writing when using textures without alpha channel\r\n * and setting some specific blend modes.\r\n */\r\n public disableDepthWrite: boolean = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the manager must consider scene fog when rendering\r\n */\r\n public fogEnabled = true;\r\n\r\n /**\r\n * Gets the capacity of the manager\r\n */\r\n public get capacity() {\r\n return this._capacity;\r\n }\r\n\r\n private readonly _engine: ThinEngine;\r\n private readonly _useVAO: boolean = false;\r\n private readonly _useInstancing: boolean = false;\r\n private readonly _scene: Nullable<Scene>;\r\n\r\n private readonly _capacity: number;\r\n private readonly _epsilon: number;\r\n\r\n private _vertexBufferSize: number;\r\n private _vertexData: Float32Array;\r\n private _buffer: Buffer;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _indexBuffer: DataBuffer;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _drawWrapperFog: DrawWrapper;\r\n private _drawWrapperDepth: DrawWrapper;\r\n private _drawWrapperFogDepth: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n\r\n /**\r\n * Creates a new sprite Renderer\r\n * @param engine defines the engine the renderer works with\r\n * @param capacity defines the maximum allowed number of sprites\r\n * @param epsilon defines the epsilon value to align texture (0.01 by default)\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(engine: ThinEngine, capacity: number, epsilon: number = 0.01, scene: Nullable<Scene> = null) {\r\n this._capacity = capacity;\r\n this._epsilon = epsilon;\r\n\r\n this._engine = engine;\r\n this._useInstancing = engine.getCaps().instancedArrays;\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n this._scene = scene;\r\n this._drawWrapperBase = new DrawWrapper(engine);\r\n this._drawWrapperFog = new DrawWrapper(engine);\r\n this._drawWrapperDepth = new DrawWrapper(engine, false);\r\n this._drawWrapperFogDepth = new DrawWrapper(engine, false);\r\n\r\n if (!this._useInstancing) {\r\n this._buildIndexBuffer();\r\n }\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperFog.drawContext) {\r\n this._drawWrapperFog.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperDepth.drawContext) {\r\n this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperFogDepth.drawContext) {\r\n this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing;\r\n }\r\n\r\n // VBO\r\n // 18 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellLeft, cellTop, cellWidth, cellHeight, color r, color g, color b, color a)\r\n // 16 when using instances\r\n this._vertexBufferSize = this._useInstancing ? 16 : 18;\r\n this._vertexData = new Float32Array(capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));\r\n this._buffer = new Buffer(engine, this._vertexData, true, this._vertexBufferSize);\r\n\r\n const positions = this._buffer.createVertexBuffer(VertexBuffer.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing);\r\n const options = this._buffer.createVertexBuffer(\"options\", 4, 2, this._vertexBufferSize, this._useInstancing);\r\n\r\n let offset = 6;\r\n let offsets: VertexBuffer;\r\n\r\n if (this._useInstancing) {\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n offsets = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n } else {\r\n offsets = this._buffer.createVertexBuffer(\"offsets\", offset, 2, this._vertexBufferSize, this._useInstancing);\r\n offset += 2;\r\n }\r\n\r\n const inverts = this._buffer.createVertexBuffer(\"inverts\", offset, 2, this._vertexBufferSize, this._useInstancing);\r\n const cellInfo = this._buffer.createVertexBuffer(\"cellInfo\", offset + 2, 4, this._vertexBufferSize, this._useInstancing);\r\n const colors = this._buffer.createVertexBuffer(VertexBuffer.ColorKind, offset + 6, 4, this._vertexBufferSize, this._useInstancing);\r\n\r\n this._vertexBuffers[VertexBuffer.PositionKind] = positions;\r\n this._vertexBuffers[\"options\"] = options;\r\n this._vertexBuffers[\"offsets\"] = offsets;\r\n this._vertexBuffers[\"inverts\"] = inverts;\r\n this._vertexBuffers[\"cellInfo\"] = cellInfo;\r\n this._vertexBuffers[VertexBuffer.ColorKind] = colors;\r\n\r\n // Effects\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n \"sprites\",\r\n [VertexBuffer.PositionKind, \"options\", \"offsets\", \"inverts\", \"cellInfo\", VertexBuffer.ColorKind],\r\n [\"view\", \"projection\", \"textureInfos\", \"alphaTest\"],\r\n [\"diffuseSampler\"],\r\n \"\"\r\n );\r\n\r\n this._drawWrapperDepth.effect = this._drawWrapperBase.effect;\r\n this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext;\r\n\r\n if (this._scene) {\r\n this._drawWrapperFog.effect = this._scene\r\n .getEngine()\r\n .createEffect(\r\n \"sprites\",\r\n [VertexBuffer.PositionKind, \"options\", \"offsets\", \"inverts\", \"cellInfo\", VertexBuffer.ColorKind],\r\n [\"view\", \"projection\", \"textureInfos\", \"alphaTest\", \"vFogInfos\", \"vFogColor\"],\r\n [\"diffuseSampler\"],\r\n \"#define FOG\"\r\n );\r\n this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect;\r\n this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext;\r\n }\r\n }\r\n\r\n /**\r\n * Render all child sprites\r\n * @param sprites defines the list of sprites to render\r\n * @param deltaTime defines the time since last frame\r\n * @param viewMatrix defines the viewMatrix to use to render the sprites\r\n * @param projectionMatrix defines the projectionMatrix to use to render the sprites\r\n * @param customSpriteUpdate defines a custom function to update the sprites data before they render\r\n */\r\n public render(\r\n sprites: ThinSprite[],\r\n deltaTime: number,\r\n viewMatrix: IMatrixLike,\r\n projectionMatrix: IMatrixLike,\r\n customSpriteUpdate: Nullable<(sprite: ThinSprite, baseSize: ISize) => void> = null\r\n ): void {\r\n if (!this.texture || !this.texture.isReady() || !sprites.length) {\r\n return;\r\n }\r\n\r\n let drawWrapper = this._drawWrapperBase;\r\n let drawWrapperDepth = this._drawWrapperDepth;\r\n let shouldRenderFog = false;\r\n if (this.fogEnabled && this._scene && this._scene.fogEnabled && this._scene.fogMode !== 0) {\r\n drawWrapper = this._drawWrapperFog;\r\n drawWrapperDepth = this._drawWrapperFogDepth;\r\n shouldRenderFog = true;\r\n }\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n\r\n const engine = this._engine;\r\n const useRightHandedSystem = !!(this._scene && this._scene.useRightHandedSystem);\r\n const baseSize = this.texture.getBaseSize();\r\n\r\n // Sprites\r\n const max = Math.min(this._capacity, sprites.length);\r\n\r\n let offset = 0;\r\n let noSprite = true;\r\n for (let index = 0; index < max; index++) {\r\n const sprite = sprites[index];\r\n if (!sprite || !sprite.isVisible) {\r\n continue;\r\n }\r\n\r\n noSprite = false;\r\n sprite._animate(deltaTime);\r\n\r\n this._appendSpriteVertex(offset++, sprite, 0, 0, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n if (!this._useInstancing) {\r\n this._appendSpriteVertex(offset++, sprite, 1, 0, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n this._appendSpriteVertex(offset++, sprite, 1, 1, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n this._appendSpriteVertex(offset++, sprite, 0, 1, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n }\r\n }\r\n\r\n if (noSprite) {\r\n return;\r\n }\r\n\r\n this._buffer.update(this._vertexData);\r\n\r\n const culling = !!engine.depthCullingState.cull;\r\n const zOffset = engine.depthCullingState.zOffset;\r\n const zOffsetUnits = engine.depthCullingState.zOffsetUnits;\r\n\r\n engine.setState(culling, zOffset, false, false, undefined, undefined, zOffsetUnits);\r\n\r\n // Render\r\n engine.enableEffect(drawWrapper);\r\n\r\n effect.setTexture(\"diffuseSampler\", this.texture);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n\r\n // Scene Info\r\n if (shouldRenderFog) {\r\n const scene = this._scene!;\r\n\r\n // Fog\r\n effect.setFloat4(\"vFogInfos\", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);\r\n effect.setColor3(\"vFogColor\", scene.fogColor);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n // Draw order\r\n engine.depthCullingState.depthFunc = engine.useReverseDepthBuffer ? Constants.GEQUAL : Constants.LEQUAL;\r\n if (!this.disableDepthWrite) {\r\n effect.setBool(\"alphaTest\", true);\r\n engine.setColorWrite(false);\r\n engine.enableEffect(drawWrapperDepth);\r\n if (this._useInstancing) {\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, offset);\r\n } else {\r\n engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, (offset / 4) * 6);\r\n }\r\n engine.enableEffect(drawWrapper);\r\n engine.setColorWrite(true);\r\n effect.setBool(\"alphaTest\", false);\r\n }\r\n\r\n engine.setAlphaMode(this.blendMode);\r\n if (this._useInstancing) {\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, offset);\r\n } else {\r\n engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, (offset / 4) * 6);\r\n }\r\n\r\n if (this.autoResetAlpha) {\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n }\r\n\r\n // Restore Right Handed\r\n if (useRightHandedSystem) {\r\n this._scene!.getEngine().setState(culling, zOffset, false, true, undefined, undefined, zOffsetUnits);\r\n }\r\n\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n private _appendSpriteVertex(\r\n index: number,\r\n sprite: ThinSprite,\r\n offsetX: number,\r\n offsetY: number,\r\n baseSize: ISize,\r\n useRightHandedSystem: boolean,\r\n customSpriteUpdate: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>\r\n ): void {\r\n let arrayOffset = index * this._vertexBufferSize;\r\n\r\n if (offsetX === 0) {\r\n offsetX = this._epsilon;\r\n } else if (offsetX === 1) {\r\n offsetX = 1 - this._epsilon;\r\n }\r\n\r\n if (offsetY === 0) {\r\n offsetY = this._epsilon;\r\n } else if (offsetY === 1) {\r\n offsetY = 1 - this._epsilon;\r\n }\r\n\r\n if (customSpriteUpdate) {\r\n customSpriteUpdate(sprite, baseSize);\r\n } else {\r\n if (!sprite.cellIndex) {\r\n sprite.cellIndex = 0;\r\n }\r\n\r\n const rowSize = baseSize.width / this.cellWidth;\r\n const offset = (sprite.cellIndex / rowSize) >> 0;\r\n sprite._xOffset = ((sprite.cellIndex - offset * rowSize) * this.cellWidth) / baseSize.width;\r\n sprite._yOffset = (offset * this.cellHeight) / baseSize.height;\r\n sprite._xSize = this.cellWidth;\r\n sprite._ySize = this.cellHeight;\r\n }\r\n\r\n // Positions\r\n this._vertexData[arrayOffset] = sprite.position.x;\r\n this._vertexData[arrayOffset + 1] = sprite.position.y;\r\n this._vertexData[arrayOffset + 2] = sprite.position.z;\r\n this._vertexData[arrayOffset + 3] = sprite.angle;\r\n // Options\r\n this._vertexData[arrayOffset + 4] = sprite.width;\r\n this._vertexData[arrayOffset + 5] = sprite.height;\r\n\r\n if (!this._useInstancing) {\r\n this._vertexData[arrayOffset + 6] = offsetX;\r\n this._vertexData[arrayOffset + 7] = offsetY;\r\n } else {\r\n arrayOffset -= 2;\r\n }\r\n\r\n // Inverts according to Right Handed\r\n if (useRightHandedSystem) {\r\n this._vertexData[arrayOffset + 8] = sprite.invertU ? 0 : 1;\r\n } else {\r\n this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;\r\n }\r\n\r\n this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;\r\n\r\n this._vertexData[arrayOffset + 10] = sprite._xOffset;\r\n this._vertexData[arrayOffset + 11] = sprite._yOffset;\r\n this._vertexData[arrayOffset + 12] = sprite._xSize / baseSize.width;\r\n this._vertexData[arrayOffset + 13] = sprite._ySize / baseSize.height;\r\n\r\n // Color\r\n this._vertexData[arrayOffset + 14] = sprite.color.r;\r\n this._vertexData[arrayOffset + 15] = sprite.color.g;\r\n this._vertexData[arrayOffset + 16] = sprite.color.b;\r\n this._vertexData[arrayOffset + 17] = sprite.color.a;\r\n }\r\n\r\n private _buildIndexBuffer(): void {\r\n const indices = [];\r\n let index = 0;\r\n for (let count = 0; count < this._capacity; count++) {\r\n indices.push(index);\r\n indices.push(index + 1);\r\n indices.push(index + 2);\r\n indices.push(index);\r\n indices.push(index + 2);\r\n indices.push(index + 3);\r\n index += 4;\r\n }\r\n\r\n this._indexBuffer = this._engine.createIndexBuffer(indices);\r\n }\r\n\r\n /**\r\n * Rebuilds the renderer (after a context lost, for eg)\r\n */\r\n public rebuild(): void {\r\n if (this._indexBuffer) {\r\n this._buildIndexBuffer();\r\n }\r\n\r\n if (this._useVAO) {\r\n this._vertexArrayObject = undefined as any;\r\n }\r\n\r\n this._buffer._rebuild();\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = <VertexBuffer>this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n\r\n this._spriteBuffer?._rebuild();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._buffer) {\r\n this._buffer.dispose();\r\n (<any>this._buffer) = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n (<any>this._spriteBuffer) = null;\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this._engine._releaseBuffer(this._indexBuffer);\r\n (<any>this._indexBuffer) = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n this._engine.releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n\r\n if (this.texture) {\r\n this.texture.dispose();\r\n (<any>this.texture) = null;\r\n }\r\n this._drawWrapperBase.dispose();\r\n this._drawWrapperFog.dispose();\r\n this._drawWrapperDepth.dispose();\r\n this._drawWrapperFogDepth.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"spriteRenderer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Sprites/spriteRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAOvD,OAAO,oCAAoC,CAAC;AAC5C,OAAO,4CAA4C,CAAC;AAEpD,OAAO,6BAA6B,CAAC;AACrC,OAAO,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH;IAoEI;;;;;;OAMG;IACH,wBAAY,MAAkB,EAAE,QAAgB,EAAE,OAAsB,EAAE,KAA6B;QAArD,wBAAA,EAAA,cAAsB;QAAE,sBAAA,EAAA,YAA6B;QA3DvG;;;;WAIG;QACI,cAAS,GAAG,SAAS,CAAC,aAAa,CAAC;QAE3C;;;WAGG;QACI,mBAAc,GAAG,IAAI,CA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,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACzC,IAAI,CAAC,YAAa,GAAG,IAAI,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACzD,IAAI,CAAC,kBAAmB,GAAG,IAAI,CAAC;SACzC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAQ,GAAG,IAAI,CAAC;SAC9B;QACD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IACL,qBAAC;AAAD,CAAC,AA7bD,IA6bC","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { IMatrixLike } from \"../Maths/math.like\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"../Buffers/buffer\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport type { ThinSprite } from \"./thinSprite\";\r\nimport type { ISize } from \"../Maths/math.size\";\r\n\r\ndeclare type ThinTexture = import(\"../Materials/Textures/thinTexture\").ThinTexture;\r\ndeclare type Scene = import(\"../scene\").Scene;\r\n\r\nimport \"../Engines/Extensions/engine.alpha\";\r\nimport \"../Engines/Extensions/engine.dynamicBuffer\";\r\n\r\nimport \"../Shaders/sprites.fragment\";\r\nimport \"../Shaders/sprites.vertex\";\r\n\r\n/**\r\n * Class used to render sprites.\r\n *\r\n * It can be used either to render Sprites or ThinSprites with ThinEngine only.\r\n */\r\nexport class SpriteRenderer {\r\n /**\r\n * Defines the texture of the spritesheet\r\n */\r\n public texture: Nullable<ThinTexture>;\r\n\r\n /**\r\n * Defines the default width of a cell in the spritesheet\r\n */\r\n public cellWidth: number;\r\n\r\n /**\r\n * Defines the default height of a cell in the spritesheet\r\n */\r\n public cellHeight: number;\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be any of\r\n * the static Constants.ALPHA_x properties provided in this class.\r\n * Default value is Constants.ALPHA_COMBINE\r\n */\r\n public blendMode = Constants.ALPHA_COMBINE;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if alpha mode is automatically\r\n * reset.\r\n */\r\n public autoResetAlpha = true;\r\n\r\n /**\r\n * Disables writing to the depth buffer when rendering the sprites.\r\n * It can be handy to disable depth writing when using textures without alpha channel\r\n * and setting some specific blend modes.\r\n */\r\n public disableDepthWrite: boolean = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the manager must consider scene fog when rendering\r\n */\r\n public fogEnabled = true;\r\n\r\n /**\r\n * Gets the capacity of the manager\r\n */\r\n public get capacity() {\r\n return this._capacity;\r\n }\r\n\r\n private readonly _engine: ThinEngine;\r\n private readonly _useVAO: boolean = false;\r\n private readonly _useInstancing: boolean = false;\r\n private readonly _scene: Nullable<Scene>;\r\n\r\n private readonly _capacity: number;\r\n private readonly _epsilon: number;\r\n\r\n private _vertexBufferSize: number;\r\n private _vertexData: Float32Array;\r\n private _buffer: Buffer;\r\n private _vertexBuffers: { [key: string]: VertexBuffer } = {};\r\n private _spriteBuffer: Nullable<Buffer>;\r\n private _indexBuffer: DataBuffer;\r\n private _drawWrapperBase: DrawWrapper;\r\n private _drawWrapperFog: DrawWrapper;\r\n private _drawWrapperDepth: DrawWrapper;\r\n private _drawWrapperFogDepth: DrawWrapper;\r\n private _vertexArrayObject: WebGLVertexArrayObject;\r\n\r\n /**\r\n * Creates a new sprite Renderer\r\n * @param engine defines the engine the renderer works with\r\n * @param capacity defines the maximum allowed number of sprites\r\n * @param epsilon defines the epsilon value to align texture (0.01 by default)\r\n * @param scene defines the hosting scene\r\n */\r\n constructor(engine: ThinEngine, capacity: number, epsilon: number = 0.01, scene: Nullable<Scene> = null) {\r\n this._capacity = capacity;\r\n this._epsilon = epsilon;\r\n\r\n this._engine = engine;\r\n this._useInstancing = engine.getCaps().instancedArrays && engine._features.supportSpriteInstancing;\r\n this._useVAO = engine.getCaps().vertexArrayObject && !engine.disableVertexArrayObjects;\r\n this._scene = scene;\r\n this._drawWrapperBase = new DrawWrapper(engine);\r\n this._drawWrapperFog = new DrawWrapper(engine);\r\n this._drawWrapperDepth = new DrawWrapper(engine, false);\r\n this._drawWrapperFogDepth = new DrawWrapper(engine, false);\r\n\r\n if (!this._useInstancing) {\r\n this._buildIndexBuffer();\r\n }\r\n\r\n if (this._drawWrapperBase.drawContext) {\r\n this._drawWrapperBase.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperFog.drawContext) {\r\n this._drawWrapperFog.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperDepth.drawContext) {\r\n this._drawWrapperDepth.drawContext.useInstancing = this._useInstancing;\r\n }\r\n if (this._drawWrapperFogDepth.drawContext) {\r\n this._drawWrapperFogDepth.drawContext.useInstancing = this._useInstancing;\r\n }\r\n\r\n // VBO\r\n // 18 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellLeft, cellTop, cellWidth, cellHeight, color r, color g, color b, color a)\r\n // 16 when using instances\r\n this._vertexBufferSize = this._useInstancing ? 16 : 18;\r\n this._vertexData = new Float32Array(capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));\r\n this._buffer = new Buffer(engine, this._vertexData, true, this._vertexBufferSize);\r\n\r\n const positions = this._buffer.createVertexBuffer(VertexBuffer.PositionKind, 0, 4, this._vertexBufferSize, this._useInstancing);\r\n const options = this._buffer.createVertexBuffer(\"options\", 4, 2, this._vertexBufferSize, this._useInstancing);\r\n\r\n let offset = 6;\r\n let offsets: VertexBuffer;\r\n\r\n if (this._useInstancing) {\r\n const spriteData = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);\r\n this._spriteBuffer = new Buffer(engine, spriteData, false, 2);\r\n offsets = this._spriteBuffer.createVertexBuffer(\"offsets\", 0, 2);\r\n } else {\r\n offsets = this._buffer.createVertexBuffer(\"offsets\", offset, 2, this._vertexBufferSize, this._useInstancing);\r\n offset += 2;\r\n }\r\n\r\n const inverts = this._buffer.createVertexBuffer(\"inverts\", offset, 2, this._vertexBufferSize, this._useInstancing);\r\n const cellInfo = this._buffer.createVertexBuffer(\"cellInfo\", offset + 2, 4, this._vertexBufferSize, this._useInstancing);\r\n const colors = this._buffer.createVertexBuffer(VertexBuffer.ColorKind, offset + 6, 4, this._vertexBufferSize, this._useInstancing);\r\n\r\n this._vertexBuffers[VertexBuffer.PositionKind] = positions;\r\n this._vertexBuffers[\"options\"] = options;\r\n this._vertexBuffers[\"offsets\"] = offsets;\r\n this._vertexBuffers[\"inverts\"] = inverts;\r\n this._vertexBuffers[\"cellInfo\"] = cellInfo;\r\n this._vertexBuffers[VertexBuffer.ColorKind] = colors;\r\n\r\n // Effects\r\n this._drawWrapperBase.effect = this._engine.createEffect(\r\n \"sprites\",\r\n [VertexBuffer.PositionKind, \"options\", \"offsets\", \"inverts\", \"cellInfo\", VertexBuffer.ColorKind],\r\n [\"view\", \"projection\", \"textureInfos\", \"alphaTest\"],\r\n [\"diffuseSampler\"],\r\n \"\"\r\n );\r\n\r\n this._drawWrapperDepth.effect = this._drawWrapperBase.effect;\r\n this._drawWrapperDepth.materialContext = this._drawWrapperBase.materialContext;\r\n\r\n if (this._scene) {\r\n this._drawWrapperFog.effect = this._scene\r\n .getEngine()\r\n .createEffect(\r\n \"sprites\",\r\n [VertexBuffer.PositionKind, \"options\", \"offsets\", \"inverts\", \"cellInfo\", VertexBuffer.ColorKind],\r\n [\"view\", \"projection\", \"textureInfos\", \"alphaTest\", \"vFogInfos\", \"vFogColor\"],\r\n [\"diffuseSampler\"],\r\n \"#define FOG\"\r\n );\r\n this._drawWrapperFogDepth.effect = this._drawWrapperFog.effect;\r\n this._drawWrapperFogDepth.materialContext = this._drawWrapperFog.materialContext;\r\n }\r\n }\r\n\r\n /**\r\n * Render all child sprites\r\n * @param sprites defines the list of sprites to render\r\n * @param deltaTime defines the time since last frame\r\n * @param viewMatrix defines the viewMatrix to use to render the sprites\r\n * @param projectionMatrix defines the projectionMatrix to use to render the sprites\r\n * @param customSpriteUpdate defines a custom function to update the sprites data before they render\r\n */\r\n public render(\r\n sprites: ThinSprite[],\r\n deltaTime: number,\r\n viewMatrix: IMatrixLike,\r\n projectionMatrix: IMatrixLike,\r\n customSpriteUpdate: Nullable<(sprite: ThinSprite, baseSize: ISize) => void> = null\r\n ): void {\r\n if (!this.texture || !this.texture.isReady() || !sprites.length) {\r\n return;\r\n }\r\n\r\n let drawWrapper = this._drawWrapperBase;\r\n let drawWrapperDepth = this._drawWrapperDepth;\r\n let shouldRenderFog = false;\r\n if (this.fogEnabled && this._scene && this._scene.fogEnabled && this._scene.fogMode !== 0) {\r\n drawWrapper = this._drawWrapperFog;\r\n drawWrapperDepth = this._drawWrapperFogDepth;\r\n shouldRenderFog = true;\r\n }\r\n\r\n const effect = drawWrapper.effect!;\r\n\r\n // Check\r\n if (!effect.isReady()) {\r\n return;\r\n }\r\n\r\n const engine = this._engine;\r\n const useRightHandedSystem = !!(this._scene && this._scene.useRightHandedSystem);\r\n const baseSize = this.texture.getBaseSize();\r\n\r\n // Sprites\r\n const max = Math.min(this._capacity, sprites.length);\r\n\r\n let offset = 0;\r\n let noSprite = true;\r\n for (let index = 0; index < max; index++) {\r\n const sprite = sprites[index];\r\n if (!sprite || !sprite.isVisible) {\r\n continue;\r\n }\r\n\r\n noSprite = false;\r\n sprite._animate(deltaTime);\r\n\r\n this._appendSpriteVertex(offset++, sprite, 0, 0, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n if (!this._useInstancing) {\r\n this._appendSpriteVertex(offset++, sprite, 1, 0, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n this._appendSpriteVertex(offset++, sprite, 1, 1, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n this._appendSpriteVertex(offset++, sprite, 0, 1, baseSize, useRightHandedSystem, customSpriteUpdate);\r\n }\r\n }\r\n\r\n if (noSprite) {\r\n return;\r\n }\r\n\r\n this._buffer.update(this._vertexData);\r\n\r\n const culling = !!engine.depthCullingState.cull;\r\n const zOffset = engine.depthCullingState.zOffset;\r\n const zOffsetUnits = engine.depthCullingState.zOffsetUnits;\r\n\r\n engine.setState(culling, zOffset, false, false, undefined, undefined, zOffsetUnits);\r\n\r\n // Render\r\n engine.enableEffect(drawWrapper);\r\n\r\n effect.setTexture(\"diffuseSampler\", this.texture);\r\n effect.setMatrix(\"view\", viewMatrix);\r\n effect.setMatrix(\"projection\", projectionMatrix);\r\n\r\n // Scene Info\r\n if (shouldRenderFog) {\r\n const scene = this._scene!;\r\n\r\n // Fog\r\n effect.setFloat4(\"vFogInfos\", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);\r\n effect.setColor3(\"vFogColor\", scene.fogColor);\r\n }\r\n\r\n if (this._useVAO) {\r\n if (!this._vertexArrayObject) {\r\n this._vertexArrayObject = engine.recordVertexArrayObject(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n engine.bindVertexArrayObject(this._vertexArrayObject, this._indexBuffer);\r\n } else {\r\n // VBOs\r\n engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);\r\n }\r\n\r\n // Draw order\r\n engine.depthCullingState.depthFunc = engine.useReverseDepthBuffer ? Constants.GEQUAL : Constants.LEQUAL;\r\n if (!this.disableDepthWrite) {\r\n effect.setBool(\"alphaTest\", true);\r\n engine.setColorWrite(false);\r\n engine.enableEffect(drawWrapperDepth);\r\n if (this._useInstancing) {\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, offset);\r\n } else {\r\n engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, (offset / 4) * 6);\r\n }\r\n engine.enableEffect(drawWrapper);\r\n engine.setColorWrite(true);\r\n effect.setBool(\"alphaTest\", false);\r\n }\r\n\r\n engine.setAlphaMode(this.blendMode);\r\n if (this._useInstancing) {\r\n engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, offset);\r\n } else {\r\n engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, (offset / 4) * 6);\r\n }\r\n\r\n if (this.autoResetAlpha) {\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n }\r\n\r\n // Restore Right Handed\r\n if (useRightHandedSystem) {\r\n this._scene!.getEngine().setState(culling, zOffset, false, true, undefined, undefined, zOffsetUnits);\r\n }\r\n\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n private _appendSpriteVertex(\r\n index: number,\r\n sprite: ThinSprite,\r\n offsetX: number,\r\n offsetY: number,\r\n baseSize: ISize,\r\n useRightHandedSystem: boolean,\r\n customSpriteUpdate: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>\r\n ): void {\r\n let arrayOffset = index * this._vertexBufferSize;\r\n\r\n if (offsetX === 0) {\r\n offsetX = this._epsilon;\r\n } else if (offsetX === 1) {\r\n offsetX = 1 - this._epsilon;\r\n }\r\n\r\n if (offsetY === 0) {\r\n offsetY = this._epsilon;\r\n } else if (offsetY === 1) {\r\n offsetY = 1 - this._epsilon;\r\n }\r\n\r\n if (customSpriteUpdate) {\r\n customSpriteUpdate(sprite, baseSize);\r\n } else {\r\n if (!sprite.cellIndex) {\r\n sprite.cellIndex = 0;\r\n }\r\n\r\n const rowSize = baseSize.width / this.cellWidth;\r\n const offset = (sprite.cellIndex / rowSize) >> 0;\r\n sprite._xOffset = ((sprite.cellIndex - offset * rowSize) * this.cellWidth) / baseSize.width;\r\n sprite._yOffset = (offset * this.cellHeight) / baseSize.height;\r\n sprite._xSize = this.cellWidth;\r\n sprite._ySize = this.cellHeight;\r\n }\r\n\r\n // Positions\r\n this._vertexData[arrayOffset] = sprite.position.x;\r\n this._vertexData[arrayOffset + 1] = sprite.position.y;\r\n this._vertexData[arrayOffset + 2] = sprite.position.z;\r\n this._vertexData[arrayOffset + 3] = sprite.angle;\r\n // Options\r\n this._vertexData[arrayOffset + 4] = sprite.width;\r\n this._vertexData[arrayOffset + 5] = sprite.height;\r\n\r\n if (!this._useInstancing) {\r\n this._vertexData[arrayOffset + 6] = offsetX;\r\n this._vertexData[arrayOffset + 7] = offsetY;\r\n } else {\r\n arrayOffset -= 2;\r\n }\r\n\r\n // Inverts according to Right Handed\r\n if (useRightHandedSystem) {\r\n this._vertexData[arrayOffset + 8] = sprite.invertU ? 0 : 1;\r\n } else {\r\n this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;\r\n }\r\n\r\n this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;\r\n\r\n this._vertexData[arrayOffset + 10] = sprite._xOffset;\r\n this._vertexData[arrayOffset + 11] = sprite._yOffset;\r\n this._vertexData[arrayOffset + 12] = sprite._xSize / baseSize.width;\r\n this._vertexData[arrayOffset + 13] = sprite._ySize / baseSize.height;\r\n\r\n // Color\r\n this._vertexData[arrayOffset + 14] = sprite.color.r;\r\n this._vertexData[arrayOffset + 15] = sprite.color.g;\r\n this._vertexData[arrayOffset + 16] = sprite.color.b;\r\n this._vertexData[arrayOffset + 17] = sprite.color.a;\r\n }\r\n\r\n private _buildIndexBuffer(): void {\r\n const indices = [];\r\n let index = 0;\r\n for (let count = 0; count < this._capacity; count++) {\r\n indices.push(index);\r\n indices.push(index + 1);\r\n indices.push(index + 2);\r\n indices.push(index);\r\n indices.push(index + 2);\r\n indices.push(index + 3);\r\n index += 4;\r\n }\r\n\r\n this._indexBuffer = this._engine.createIndexBuffer(indices);\r\n }\r\n\r\n /**\r\n * Rebuilds the renderer (after a context lost, for eg)\r\n */\r\n public rebuild(): void {\r\n if (this._indexBuffer) {\r\n this._buildIndexBuffer();\r\n }\r\n\r\n if (this._useVAO) {\r\n this._vertexArrayObject = undefined as any;\r\n }\r\n\r\n this._buffer._rebuild();\r\n\r\n for (const key in this._vertexBuffers) {\r\n const vertexBuffer = <VertexBuffer>this._vertexBuffers[key];\r\n vertexBuffer._rebuild();\r\n }\r\n\r\n this._spriteBuffer?._rebuild();\r\n }\r\n\r\n /**\r\n * Release associated resources\r\n */\r\n public dispose(): void {\r\n if (this._buffer) {\r\n this._buffer.dispose();\r\n (<any>this._buffer) = null;\r\n }\r\n\r\n if (this._spriteBuffer) {\r\n this._spriteBuffer.dispose();\r\n (<any>this._spriteBuffer) = null;\r\n }\r\n\r\n if (this._indexBuffer) {\r\n this._engine._releaseBuffer(this._indexBuffer);\r\n (<any>this._indexBuffer) = null;\r\n }\r\n\r\n if (this._vertexArrayObject) {\r\n this._engine.releaseVertexArrayObject(this._vertexArrayObject);\r\n (<any>this._vertexArrayObject) = null;\r\n }\r\n\r\n if (this.texture) {\r\n this.texture.dispose();\r\n (<any>this.texture) = null;\r\n }\r\n this._drawWrapperBase.dispose();\r\n this._drawWrapperFog.dispose();\r\n this._drawWrapperDepth.dispose();\r\n this._drawWrapperFogDepth.dispose();\r\n }\r\n}\r\n"]}
@@ -4,12 +4,14 @@ import type { IWebXRInputOptions } from "./webXRInput";
4
4
  import { WebXRInput } from "./webXRInput";
5
5
  import type { IWebXRControllerPointerSelectionOptions } from "./features/WebXRControllerPointerSelection";
6
6
  import { WebXRControllerPointerSelection } from "./features/WebXRControllerPointerSelection";
7
+ import type { IWebXRNearInteractionOptions } from "./features/WebXRNearInteraction";
7
8
  import { WebXRNearInteraction } from "./features/WebXRNearInteraction";
8
9
  import type { WebXRRenderTarget } from "./webXRTypes";
9
10
  import type { WebXREnterExitUIOptions } from "./webXREnterExitUI";
10
11
  import { WebXREnterExitUI } from "./webXREnterExitUI";
11
12
  import type { AbstractMesh } from "../Meshes/abstractMesh";
12
13
  import type { WebXRManagedOutputCanvasOptions } from "./webXRManagedOutputCanvas";
14
+ import type { IWebXRTeleportationOptions } from "./features/WebXRControllerTeleportation";
13
15
  import { WebXRMotionControllerTeleportation } from "./features/WebXRControllerTeleportation";
14
16
  /**
15
17
  * Options for the default xr helper
@@ -51,6 +53,14 @@ export declare class WebXRDefaultExperienceOptions {
51
53
  * optional configuration for pointer selection
52
54
  */
53
55
  pointerSelectionOptions?: IWebXRControllerPointerSelectionOptions;
56
+ /**
57
+ * optional configuration for near interaction
58
+ */
59
+ nearInteractionOptions?: IWebXRNearInteractionOptions;
60
+ /**
61
+ * optional configuration for teleportation
62
+ */
63
+ teleportationOptions?: IWebXRTeleportationOptions;
54
64
  /**
55
65
  * optional configuration for the output canvas
56
66
  */
@@ -63,23 +63,13 @@ var WebXRDefaultExperience = /** @class */ (function () {
63
63
  result.pointerSelection = (result.baseExperience.featuresManager.enableFeature(WebXRControllerPointerSelection.Name, options.useStablePlugins ? "stable" : "latest", pointerSelectionOptions));
64
64
  if (!options.disableTeleportation) {
65
65
  // Add default teleportation, including rotation
66
- result.teleportation = result.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, options.useStablePlugins ? "stable" : "latest", {
67
- floorMeshes: options.floorMeshes,
68
- xrInput: result.input,
69
- renderingGroupId: options.renderingGroupId,
70
- });
66
+ result.teleportation = result.baseExperience.featuresManager.enableFeature(WebXRMotionControllerTeleportation.Name, options.useStablePlugins ? "stable" : "latest", __assign({ floorMeshes: options.floorMeshes, xrInput: result.input, renderingGroupId: options.renderingGroupId }, options.teleportationOptions));
71
67
  result.teleportation.setSelectionFeature(result.pointerSelection);
72
68
  }
73
69
  }
74
70
  if (!options.disableNearInteraction) {
75
71
  // Add default pointer selection
76
- result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? "stable" : "latest", {
77
- xrInput: result.input,
78
- farInteractionFeature: result.pointerSelection,
79
- renderingGroupId: options.renderingGroupId,
80
- useUtilityLayer: true,
81
- enableNearInteractionOnAllControllers: true,
82
- });
72
+ result.nearInteraction = result.baseExperience.featuresManager.enableFeature(WebXRNearInteraction.Name, options.useStablePlugins ? "stable" : "latest", __assign({ xrInput: result.input, farInteractionFeature: result.pointerSelection, renderingGroupId: options.renderingGroupId, useUtilityLayer: true, enableNearInteractionOnAllControllers: true }, options.nearInteractionOptions));
83
73
  }
84
74
  // Create the WebXR output target
85
75
  result.renderTarget = result.baseExperience.sessionManager.getWebXRRenderTarget(options.outputCanvasOptions);