@babylonjs/core 7.1.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/Animations/animationGroup.d.ts +1 -1
  2. package/Animations/animationGroup.js +1 -1
  3. package/Animations/animationGroup.js.map +1 -1
  4. package/Compute/computeEffect.d.ts +0 -1
  5. package/Compute/computeEffect.js +40 -33
  6. package/Compute/computeEffect.js.map +1 -1
  7. package/Engines/Extensions/engine.computeShader.d.ts +25 -1
  8. package/Engines/Extensions/engine.computeShader.js +1 -1
  9. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  10. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +1 -2
  11. package/Engines/WebGL/webGLRenderTargetWrapper.js +2 -3
  12. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  13. package/Engines/WebGPU/Extensions/engine.computeShader.js +22 -0
  14. package/Engines/WebGPU/Extensions/engine.computeShader.js.map +1 -1
  15. package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -3
  16. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  17. package/Engines/WebGPU/webgpuComputePipelineContext.js +4 -2
  18. package/Engines/WebGPU/webgpuComputePipelineContext.js.map +1 -1
  19. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -0
  20. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +6 -1
  21. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  22. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  23. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  24. package/Engines/renderTargetWrapper.d.ts +6 -2
  25. package/Engines/renderTargetWrapper.js +9 -2
  26. package/Engines/renderTargetWrapper.js.map +1 -1
  27. package/Engines/thinEngine.js +2 -2
  28. package/Engines/thinEngine.js.map +1 -1
  29. package/Engines/webgpuEngine.js +4 -5
  30. package/Engines/webgpuEngine.js.map +1 -1
  31. package/Gizmos/axisScaleGizmo.js +6 -1
  32. package/Gizmos/axisScaleGizmo.js.map +1 -1
  33. package/Gizmos/boundingBoxGizmo.d.ts +2 -2
  34. package/Gizmos/boundingBoxGizmo.js +27 -17
  35. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  36. package/Gizmos/scaleGizmo.d.ts +6 -0
  37. package/Gizmos/scaleGizmo.js +10 -2
  38. package/Gizmos/scaleGizmo.js.map +1 -1
  39. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  40. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  41. package/Lights/Shadows/shadowGenerator.js +17 -2
  42. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  43. package/Materials/PBR/pbrBaseMaterial.js +1 -5
  44. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  45. package/Materials/PBR/pbrClearCoatConfiguration.d.ts +0 -1
  46. package/Materials/PBR/pbrClearCoatConfiguration.js +3 -12
  47. package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
  48. package/Materials/PBR/pbrIridescenceConfiguration.d.ts +1 -4
  49. package/Materials/PBR/pbrIridescenceConfiguration.js +5 -15
  50. package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
  51. package/Materials/PBR/pbrSheenConfiguration.d.ts +0 -1
  52. package/Materials/PBR/pbrSheenConfiguration.js +3 -12
  53. package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
  54. package/Materials/PBR/pbrSubSurfaceConfiguration.js +5 -17
  55. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  56. package/Materials/Textures/baseTexture.d.ts +0 -6
  57. package/Materials/Textures/baseTexture.js +0 -8
  58. package/Materials/Textures/baseTexture.js.map +1 -1
  59. package/Materials/Textures/renderTargetTexture.d.ts +2 -1
  60. package/Materials/Textures/renderTargetTexture.js +3 -2
  61. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  62. package/Materials/Textures/texture.d.ts +0 -6
  63. package/Materials/Textures/texture.js +0 -15
  64. package/Materials/Textures/texture.js.map +1 -1
  65. package/Materials/Textures/thinTexture.js +1 -1
  66. package/Materials/Textures/thinTexture.js.map +1 -1
  67. package/Maths/math.vector.d.ts +12 -0
  68. package/Maths/math.vector.js +17 -2
  69. package/Maths/math.vector.js.map +1 -1
  70. package/Maths/tensor.d.ts +13 -11
  71. package/Maths/tensor.js.map +1 -1
  72. package/Meshes/Builders/greasedLineBuilder.js +14 -0
  73. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  74. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +14 -3
  75. package/Meshes/GreasedLine/greasedLineBaseMesh.js +18 -2
  76. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  77. package/Meshes/GreasedLine/greasedLineMesh.js +3 -4
  78. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  79. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +10 -1
  80. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  81. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  82. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  83. package/Physics/v2/Plugins/havokPlugin.d.ts +7 -0
  84. package/Physics/v2/Plugins/havokPlugin.js +16 -0
  85. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  86. package/Physics/v2/physicsBody.d.ts +7 -1
  87. package/Physics/v2/physicsBody.js +10 -1
  88. package/Physics/v2/physicsBody.js.map +1 -1
  89. package/Physics/v2/physicsEngineComponent.d.ts +5 -0
  90. package/Physics/v2/physicsEngineComponent.js +13 -0
  91. package/Physics/v2/physicsEngineComponent.js.map +1 -1
  92. package/Rendering/depthPeelingRenderer.js +1 -1
  93. package/Rendering/depthPeelingRenderer.js.map +1 -1
  94. package/Rendering/fluidRenderer/fluidRenderer.js +1 -1
  95. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  96. package/Shaders/ShadersInclude/pbrBlockClearcoat.js +0 -4
  97. package/Shaders/ShadersInclude/pbrBlockClearcoat.js.map +1 -1
  98. package/Shaders/ShadersInclude/pbrBlockIridescence.js +0 -3
  99. package/Shaders/ShadersInclude/pbrBlockIridescence.js.map +1 -1
  100. package/Shaders/ShadersInclude/pbrBlockSheen.js +1 -5
  101. package/Shaders/ShadersInclude/pbrBlockSheen.js.map +1 -1
  102. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +2 -2
  103. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  104. package/Shaders/greasedLine.vertex.js +3 -3
  105. package/Shaders/greasedLine.vertex.js.map +1 -1
  106. package/Shaders/pbr.fragment.js +4 -4
  107. package/Shaders/pbr.fragment.js.map +1 -1
  108. package/XR/features/WebXRHandTracking.d.ts +5 -0
  109. package/XR/features/WebXRHandTracking.js +6 -0
  110. package/XR/features/WebXRHandTracking.js.map +1 -1
  111. package/XR/webXRCamera.js +4 -0
  112. package/XR/webXRCamera.js.map +1 -1
  113. package/package.json +1 -1
@@ -49,7 +49,7 @@ export declare class PhysicsBody {
49
49
  */
50
50
  disablePreStep: boolean;
51
51
  /**
52
- * Disable sync from physics to transformNode. This value is set to true at body creation when the body is not dynamic.
52
+ * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.
53
53
  */
54
54
  disableSync: boolean;
55
55
  /**
@@ -290,6 +290,12 @@ export declare class PhysicsBody {
290
290
  * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.
291
291
  */
292
292
  applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void;
293
+ /**
294
+ * Add torque to a physics body
295
+ * @param angularImpulse The angular impulse vector.
296
+ * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.
297
+ */
298
+ applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void;
293
299
  /**
294
300
  * Applies a force to the physics object.
295
301
  *
@@ -44,7 +44,7 @@ export class PhysicsBody {
44
44
  */
45
45
  this.disablePreStep = true;
46
46
  /**
47
- * Disable sync from physics to transformNode. This value is set to true at body creation when the body is not dynamic.
47
+ * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.
48
48
  */
49
49
  this.disableSync = false;
50
50
  this._isDisposed = false;
@@ -189,6 +189,7 @@ export class PhysicsBody {
189
189
  * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.
190
190
  */
191
191
  setMotionType(motionType, instanceIndex) {
192
+ this.disableSync = motionType != PhysicsMotionType.DYNAMIC;
192
193
  this._physicsPlugin.setMotionType(this, motionType, instanceIndex);
193
194
  }
194
195
  /**
@@ -372,6 +373,14 @@ export class PhysicsBody {
372
373
  applyImpulse(impulse, location, instanceIndex) {
373
374
  this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);
374
375
  }
376
+ /**
377
+ * Add torque to a physics body
378
+ * @param angularImpulse The angular impulse vector.
379
+ * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.
380
+ */
381
+ applyAngularImpulse(angularImpulse, instanceIndex) {
382
+ this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);
383
+ }
375
384
  /**
376
385
  * Applies a force to the physics object.
377
386
  *
@@ -1 +1 @@
1
- {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAO7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IAqDpB;;;;;;;;;;;;;OAaG;IACH,YAAY,aAA4B,EAAE,UAA6B,EAAE,YAAqB,EAAE,KAAY;QAlE5G;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC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GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _motionType: PhysicsMotionType;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n this._motionType = motionType;\r\n\r\n // only dynamic body needs sync from physics to transformNode\r\n this.disableSync = motionType != PhysicsMotionType.DYNAMIC;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._motionType;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,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B,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;SACpC;QACD,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;CACJ","sourcesContent":["import type { IBasePhysicsCollisionEvent, IPhysicsCollisionEvent, IPhysicsEnginePluginV2, PhysicsMassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport { PhysicsMotionType } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion, TmpVectors } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { Bone } from \"core/Bones/bone\";\r\nimport { Space } from \"core/Maths/math.axis\";\r\nimport type { Observable, Observer } from \"../../Misc/observable\";\r\nimport type { Node } from \"../../node\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { AbstractMesh } from \"../../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\n\r\n/**\r\n * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows\r\n * the user to set the mass and velocity of the body, which can then be used to calculate the\r\n * motion of the body in the physics engine.\r\n */\r\nexport class PhysicsBody {\r\n /**\r\n * V2 Physics plugin private data for single Transform\r\n */\r\n public _pluginData: any = undefined;\r\n /**\r\n * V2 Physics plugin private data for instances\r\n */\r\n public _pluginDataInstances: Array<any> = [];\r\n /**\r\n * The V2 plugin used to create and manage this Physics Body\r\n */\r\n private _physicsPlugin: IPhysicsEnginePluginV2;\r\n /**\r\n * The engine used to create and manage this Physics Body\r\n */\r\n private _physicsEngine: PhysicsEngine;\r\n /**\r\n * If the collision callback is enabled\r\n */\r\n private _collisionCBEnabled: boolean = false;\r\n /**\r\n * If the collision ended callback is enabled\r\n */\r\n private _collisionEndedCBEnabled: boolean = false;\r\n /**\r\n * The transform node associated with this Physics Body\r\n */\r\n transformNode: TransformNode;\r\n /**\r\n * Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation.\r\n * True by default for maximum performance.\r\n */\r\n disablePreStep: boolean = true;\r\n\r\n /**\r\n * Disable sync from physics to transformNode. This value is set to true at body creation or at motionType setting when the body is not dynamic.\r\n */\r\n disableSync: boolean = false;\r\n\r\n /**\r\n * Physics engine will try to make this body sleeping and not active\r\n */\r\n public startAsleep: boolean;\r\n\r\n private _nodeDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n private _isDisposed = false;\r\n\r\n private _shape: Nullable<PhysicsShape> = null;\r\n\r\n private _motionType: PhysicsMotionType;\r\n\r\n /**\r\n * Constructs a new physics body for the given node.\r\n * @param transformNode - The Transform Node to construct the physics body for. For better performance, it is advised that this node does not have a parent.\r\n * @param motionType - The motion type of the physics body. The options are:\r\n * - PhysicsMotionType.STATIC - Static bodies are not moving and unaffected by forces or collisions. They are good for level boundaries or terrain.\r\n * - PhysicsMotionType.DYNAMIC - Dynamic bodies are fully simulated. They can move and collide with other objects.\r\n * - PhysicsMotionType.ANIMATED - They behave like dynamic bodies, but they won't be affected by other bodies, but still push other bodies out of the way.\r\n * @param startsAsleep - Whether the physics body should start in a sleeping state (not a guarantee). Defaults to false.\r\n * @param scene - The scene containing the physics engine.\r\n *\r\n * This code is useful for creating a physics body for a given Transform Node in a scene.\r\n * It checks the version of the physics engine and the physics plugin, and initializes the body accordingly.\r\n * It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.\r\n */\r\n constructor(transformNode: TransformNode, motionType: PhysicsMotionType, startsAsleep: boolean, scene: Scene) {\r\n if (!scene) {\r\n return;\r\n }\r\n const physicsEngine = scene.getPhysicsEngine() as PhysicsEngine;\r\n if (!physicsEngine) {\r\n throw new Error(\"No Physics Engine available.\");\r\n }\r\n this._physicsEngine = physicsEngine;\r\n if (physicsEngine.getPluginVersion() != 2) {\r\n throw new Error(\"Plugin version is incorrect. Expected version 2.\");\r\n }\r\n const physicsPlugin = physicsEngine.getPhysicsPlugin();\r\n if (!physicsPlugin) {\r\n throw new Error(\"No Physics Plugin available.\");\r\n }\r\n\r\n this._physicsPlugin = physicsPlugin as IPhysicsEnginePluginV2;\r\n if (!transformNode.rotationQuaternion) {\r\n transformNode.rotationQuaternion = Quaternion.FromEulerAngles(transformNode.rotation.x, transformNode.rotation.y, transformNode.rotation.z);\r\n }\r\n\r\n this.startAsleep = startsAsleep;\r\n\r\n this._motionType = motionType;\r\n\r\n // only dynamic body needs sync from physics to transformNode\r\n this.disableSync = motionType != PhysicsMotionType.DYNAMIC;\r\n\r\n // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, motionType, m);\r\n } else {\r\n // single instance\r\n if (transformNode.parent) {\r\n // Force computation of world matrix so that the parent transforms are correctly reflected in absolutePosition/absoluteRotationQuaternion.\r\n transformNode.computeWorldMatrix(true);\r\n }\r\n this._physicsPlugin.initBody(this, motionType, transformNode.absolutePosition, transformNode.absoluteRotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\r\n\r\n this._nodeDisposeObserver = transformNode.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n /**\r\n * Returns the string \"PhysicsBody\".\r\n * @returns \"PhysicsBody\"\r\n */\r\n public getClassName() {\r\n return \"PhysicsBody\";\r\n }\r\n\r\n /**\r\n * Clone the PhysicsBody to a new body and assign it to the transformNode parameter\r\n * @param transformNode transformNode that will be used for the cloned PhysicsBody\r\n * @returns the newly cloned PhysicsBody\r\n */\r\n public clone(transformNode: TransformNode): PhysicsBody {\r\n const clonedBody = new PhysicsBody(transformNode, this.getMotionType(), this.startAsleep, this.transformNode.getScene());\r\n clonedBody.shape = this.shape;\r\n clonedBody.setMassProperties(this.getMassProperties());\r\n clonedBody.setLinearDamping(this.getLinearDamping());\r\n clonedBody.setAngularDamping(this.getAngularDamping());\r\n return clonedBody;\r\n }\r\n\r\n /**\r\n * If a physics body is connected to an instanced node, update the number physic instances to match the number of node instances.\r\n */\r\n public updateBodyInstances() {\r\n const m = this.transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.updateBodyInstances(this, m);\r\n }\r\n }\r\n\r\n /**\r\n * This returns the number of internal instances of the physics body\r\n */\r\n public get numInstances(): number {\r\n return this._pluginDataInstances.length;\r\n }\r\n\r\n /**\r\n * Get the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n */\r\n public get motionType(): PhysicsMotionType {\r\n return this._motionType;\r\n }\r\n\r\n /**\r\n * Sets the shape of the physics body.\r\n * @param shape - The shape of the physics body.\r\n *\r\n * This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior.\r\n * The shape is used to calculate the body's mass, inertia, and other properties.\r\n */\r\n public set shape(shape: Nullable<PhysicsShape>) {\r\n this._shape = shape;\r\n if (shape) {\r\n this._physicsPlugin.setShape(this, shape);\r\n }\r\n }\r\n\r\n /**\r\n * Retrieves the physics shape associated with this object.\r\n *\r\n * @returns The physics shape associated with this object, or `undefined` if no\r\n * shape is associated.\r\n *\r\n * This method is useful for retrieving the physics shape associated with this object,\r\n * which can be used to apply physical forces to the object or to detect collisions.\r\n */\r\n public get shape(): Nullable<PhysicsShape> {\r\n return this._shape;\r\n }\r\n\r\n /**\r\n * Sets the event mask for the physics engine.\r\n *\r\n * @param eventMask - A bitmask that determines which events will be sent to the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the event mask for.\r\n *\r\n * This method is useful for setting the event mask for the physics engine, which determines which events\r\n * will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.\r\n */\r\n public setEventMask(eventMask: number, instanceIndex?: number) {\r\n this._physicsPlugin.setEventMask(this, eventMask, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the event mask for.\r\n * @returns The event mask of the physics engine.\r\n *\r\n * This method is useful for getting the event mask of the physics engine,\r\n * which is used to determine which events the engine will respond to.\r\n * This is important for ensuring that the engine is responding to the correct events and not\r\n * wasting resources on unnecessary events.\r\n */\r\n public getEventMask(instanceIndex?: number): number {\r\n return this._physicsPlugin.getEventMask(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param motionType - The motion type to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the motion type for.\r\n */\r\n public setMotionType(motionType: PhysicsMotionType, instanceIndex?: number) {\r\n this.disableSync = motionType != PhysicsMotionType.DYNAMIC;\r\n this._physicsPlugin.setMotionType(this, motionType, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the motion type of the physics body. Can be STATIC, DYNAMIC, or ANIMATED.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the motion type for.\r\n * @returns The motion type of the physics body.\r\n */\r\n public getMotionType(instanceIndex?: number): PhysicsMotionType {\r\n return this._physicsPlugin.getMotionType(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Computes the mass properties of the physics object, based on the set of physics shapes this body uses.\r\n * This method is useful for computing the initial mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass; these values are important for accurately simulating the physics of the\r\n * object in the physics engine, and computing values based on the shape will provide you with reasonable\r\n * initial values, which you can then customize.\r\n * @param instanceIndex - The index of the instance to compute the mass properties for.\r\n * @returns The mass properties of the object.\r\n */\r\n public computeMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.computeMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the mass properties of the physics object.\r\n *\r\n * @param massProps - The mass properties to set.\r\n * @param instanceIndex - The index of the instance to set the mass properties for. If not defined, the mass properties will be set for all instances.\r\n *\r\n * This method is useful for setting the mass properties of a physics object, such as its mass,\r\n * inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.\r\n */\r\n public setMassProperties(massProps: PhysicsMassProperties, instanceIndex?: number): void {\r\n this._physicsPlugin.setMassProperties(this, massProps, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the mass properties for.\r\n * @returns The mass properties of the object.\r\n *\r\n * This method is useful for physics simulations, as it allows the user to\r\n * retrieve the mass properties of the object, such as its mass, center of mass,\r\n * and moment of inertia. This information is necessary for accurate physics\r\n * simulations.\r\n */\r\n public getMassProperties(instanceIndex?: number): PhysicsMassProperties {\r\n return this._physicsPlugin.getMassProperties(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear damping of the physics body.\r\n *\r\n * @param damping - The linear damping value.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear damping for.\r\n *\r\n * This method is useful for controlling the linear damping of the physics body,\r\n * which is the rate at which the body's velocity decreases over time. This is useful for simulating\r\n * the effects of air resistance or other forms of friction.\r\n */\r\n public setLinearDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setLinearDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear damping for.\r\n * @returns The linear damping of the physics body.\r\n *\r\n * This method is useful for retrieving the linear damping of the physics body, which is the amount of\r\n * resistance the body has to linear motion. This is useful for simulating realistic physics behavior\r\n * in a game.\r\n */\r\n public getLinearDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getLinearDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the angular damping of the physics body.\r\n * @param damping The angular damping of the body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular damping for.\r\n *\r\n * This method is useful for controlling the angular velocity of a physics body.\r\n * By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction.\r\n * This can be used to create realistic physical behavior in a physics engine.\r\n */\r\n public setAngularDamping(damping: number, instanceIndex?: number) {\r\n this._physicsPlugin.setAngularDamping(this, damping, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular damping for.\r\n *\r\n * @returns The angular damping of the physics body.\r\n *\r\n * This method is useful for getting the angular damping of the physics body,\r\n * which is the rate of reduction of the angular velocity over time.\r\n * This is important for simulating realistic physics behavior in a game.\r\n */\r\n public getAngularDamping(instanceIndex?: number): number {\r\n return this._physicsPlugin.getAngularDamping(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Sets the linear velocity of the physics object.\r\n * @param linVel - The linear velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the linear velocity for.\r\n *\r\n * This method is useful for setting the linear velocity of a physics object,\r\n * which is necessary for simulating realistic physics in a game engine.\r\n * By setting the linear velocity, the physics object will move in the direction and speed specified by the vector.\r\n * This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.\r\n */\r\n public setLinearVelocity(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body and stores it in the given vector3.\r\n * @param linVel - The vector3 to store the linear velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocityToRef(linVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getLinearVelocityToRef(this, linVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the linear velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the linear velocity for.\r\n * @returns The linear velocity of the physics body.\r\n *\r\n * This method is useful for getting the linear velocity of a physics body in a physics engine.\r\n * This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.\r\n */\r\n public getLinearVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getLinearVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Sets the angular velocity of the physics object.\r\n * @param angVel - The angular velocity to set.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to set the angular velocity for.\r\n *\r\n * This method is useful for setting the angular velocity of a physics object, which is necessary for\r\n * simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object,\r\n * which is important for simulating realistic motion.\r\n */\r\n public setAngularVelocity(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body and stores it in the given vector3.\r\n * @param angVel - The vector3 to store the angular velocity in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocityToRef(angVel: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.getAngularVelocityToRef(this, angVel, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the angular velocity of the physics body as a new vector3.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the angular velocity for.\r\n * @returns The angular velocity of the physics body.\r\n *\r\n * This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's\r\n * rotational speed. This information can be used to create realistic physics simulations.\r\n */\r\n public getAngularVelocity(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n this.getAngularVelocityToRef(ref, instanceIndex);\r\n return ref;\r\n }\r\n\r\n /**\r\n * Applies an impulse to the physics object.\r\n *\r\n * @param impulse The impulse vector.\r\n * @param location The location of the impulse.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n *\r\n * This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyImpulse(impulse: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Add torque to a physics body\r\n * @param angularImpulse The angular impulse vector.\r\n * @param instanceIndex For a instanced body, the instance to where the impulse should be applied. If not specified, the impulse is applied to all instances.\r\n */\r\n public applyAngularImpulse(angularImpulse: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyAngularImpulse(this, angularImpulse, instanceIndex);\r\n }\r\n\r\n /**\r\n * Applies a force to the physics object.\r\n *\r\n * @param force The force vector.\r\n * @param location The location of the force.\r\n * @param instanceIndex For a instanced body, the instance to where the force should be applied. If not specified, the force is applied to all instances.\r\n *\r\n * This method is useful for applying a force to a physics object, which can be used to simulate physical forces such as gravity,\r\n * collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.\r\n */\r\n public applyForce(force: Vector3, location: Vector3, instanceIndex?: number): void {\r\n this._physicsPlugin.applyForce(this, force, location, instanceIndex);\r\n }\r\n\r\n /**\r\n * Retrieves the geometry of the body from the physics plugin.\r\n *\r\n * @returns The geometry of the body.\r\n *\r\n * This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.\r\n */\r\n public getGeometry(): {} {\r\n return this._physicsPlugin.getBodyGeometry(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified for when a collision starts or continues for this PhysicsBody\r\n * @returns Observable\r\n */\r\n public getCollisionObservable(): Observable<IPhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionObservable(this);\r\n }\r\n\r\n /**\r\n * Returns an observable that will be notified when the body has finished colliding with another body\r\n * @returns\r\n */\r\n public getCollisionEndedObservable(): Observable<IBasePhysicsCollisionEvent> {\r\n return this._physicsPlugin.getCollisionEndedObservable(this);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and notifies the observable\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n this._collisionCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Enable or disable collision ended callback for this PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision ended will rise a collision event and notifies the observable\r\n */\r\n public setCollisionEndedCallbackEnabled(enabled: boolean): void {\r\n this._collisionEndedCBEnabled = enabled;\r\n this._physicsPlugin.setCollisionEndedCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorld(instanceIndex?: number): Vector3 {\r\n const ref = new Vector3();\r\n return this.getObjectCenterWorldToRef(ref, instanceIndex);\r\n }\r\n\r\n /**\r\n * Get the center of the object in world space.\r\n * @param ref - The vector3 to store the result in.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to get the center for.\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenterWorldToRef(ref: Vector3, instanceIndex?: number): Vector3 {\r\n if (this._pluginDataInstances?.length > 0) {\r\n const index = instanceIndex || 0;\r\n const matrixData = (this.transformNode as Mesh)._thinInstanceDataStorage.matrixData;\r\n if (matrixData) {\r\n ref.set(matrixData[index * 16 + 12], matrixData[index * 16 + 13], matrixData[index * 16 + 14]);\r\n }\r\n } else {\r\n ref.copyFrom(this.transformNode.position);\r\n }\r\n return ref;\r\n }\r\n\r\n /**\r\n * Adds a constraint to the physics engine.\r\n *\r\n * @param childBody - The body to which the constraint will be applied.\r\n * @param constraint - The constraint to be applied.\r\n * @param instanceIndex - If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n * @param childInstanceIndex - If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.\r\n *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint, instanceIndex, childInstanceIndex);\r\n }\r\n\r\n /**\r\n * Sync with a bone\r\n * @param bone The bone that the impostor will be synced to.\r\n * @param boneMesh The mesh that the bone is influencing.\r\n * @param jointPivot The pivot of the joint / bone in local space.\r\n * @param distToJoint Optional distance from the impostor to the joint.\r\n * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.\r\n * @param boneAxis Optional vector3 axis the bone is aligned with\r\n */\r\n public syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3) {\r\n const mesh = this.transformNode;\r\n\r\n if (mesh.rotationQuaternion) {\r\n if (adjustRotation) {\r\n const tempQuat = TmpVectors.Quaternion[0];\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);\r\n tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);\r\n } else {\r\n bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);\r\n }\r\n }\r\n\r\n const pos = TmpVectors.Vector3[0];\r\n const boneDir = TmpVectors.Vector3[1];\r\n\r\n if (!boneAxis) {\r\n boneAxis = TmpVectors.Vector3[2];\r\n boneAxis.x = 0;\r\n boneAxis.y = 1;\r\n boneAxis.z = 0;\r\n }\r\n\r\n bone.getDirectionToRef(boneAxis, boneMesh, boneDir);\r\n bone.getAbsolutePositionToRef(boneMesh, pos);\r\n\r\n if ((distToJoint === undefined || distToJoint === null) && jointPivot) {\r\n distToJoint = jointPivot.length();\r\n }\r\n\r\n if (distToJoint !== undefined && distToJoint !== null) {\r\n pos.x += boneDir.x * distToJoint;\r\n pos.y += boneDir.y * distToJoint;\r\n pos.z += boneDir.z * distToJoint;\r\n }\r\n\r\n mesh.setAbsolutePosition(pos);\r\n }\r\n\r\n /**\r\n * Executes a callback on the body or all of the instances of a body\r\n * @param callback the callback to execute\r\n */\r\n public iterateOverAllInstances(callback: (body: PhysicsBody, instanceIndex?: number) => void) {\r\n if (this._pluginDataInstances?.length > 0) {\r\n for (let i = 0; i < this._pluginDataInstances.length; i++) {\r\n callback(this, i);\r\n }\r\n } else {\r\n callback(this, undefined);\r\n }\r\n }\r\n\r\n /**\r\n * Sets the gravity factor of the physics body\r\n * @param factor the gravity factor to set\r\n * @param instanceIndex the instance of the body to set, if undefined all instances will be set\r\n */\r\n public setGravityFactor(factor: number, instanceIndex?: number) {\r\n this._physicsPlugin.setGravityFactor(this, factor, instanceIndex);\r\n }\r\n\r\n /**\r\n * Gets the gravity factor of the physics body\r\n * @param instanceIndex the instance of the body to get, if undefined the value of first instance will be returned\r\n * @returns the gravity factor\r\n */\r\n public getGravityFactor(instanceIndex?: number): number {\r\n return this._physicsPlugin.getGravityFactor(this, instanceIndex);\r\n }\r\n\r\n /**\r\n * Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target\r\n * @param position The target position\r\n * @param rotation The target rotation\r\n * @param instanceIndex The index of the instance in an instanced body\r\n */\r\n public setTargetTransform(position: Vector3, rotation: Quaternion, instanceIndex?: number) {\r\n this._physicsPlugin.setTargetTransform(this, position, rotation, instanceIndex);\r\n }\r\n\r\n /**\r\n * Returns if the body has been disposed.\r\n * @returns true if disposed, false otherwise.\r\n */\r\n public get isDisposed() {\r\n return this._isDisposed;\r\n }\r\n\r\n /**\r\n * Disposes the body from the physics engine.\r\n *\r\n * This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.\r\n */\r\n public dispose() {\r\n if (this._isDisposed) {\r\n return;\r\n }\r\n // Disable collisions CB so it doesn't fire when the body is disposed\r\n if (this._collisionCBEnabled) {\r\n this.setCollisionCallbackEnabled(false);\r\n }\r\n if (this._collisionEndedCBEnabled) {\r\n this.setCollisionEndedCallbackEnabled(false);\r\n }\r\n if (this._nodeDisposeObserver) {\r\n this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);\r\n this._nodeDisposeObserver = null;\r\n }\r\n this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this.transformNode.physicsBody = null;\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n this._isDisposed = true;\r\n this.shape = null;\r\n }\r\n}\r\n"]}
@@ -26,6 +26,11 @@ declare module "../../Meshes/transformNode" {
26
26
  * @returns the current mesh
27
27
  */
28
28
  applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;
29
+ /** Apply a physic angular impulse to the mesh
30
+ * @param angularImpulse defines the torque to apply
31
+ * @returns the current mesh
32
+ */
33
+ applyAngularImpulse(angularImpulse: Vector3): TransformNode;
29
34
  /** @internal */
30
35
  _disposePhysicsObserver: Nullable<Observer<Node>>;
31
36
  }
@@ -46,4 +46,17 @@ TransformNode.prototype.applyImpulse = function (force, contactPoint) {
46
46
  this.physicsBody.applyImpulse(force, contactPoint);
47
47
  return this;
48
48
  };
49
+ /**
50
+ * Apply a physic angular impulse to the mesh
51
+ * @param angularImpulse defines the torque to apply
52
+ * @returns the current mesh
53
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine
54
+ */
55
+ TransformNode.prototype.applyAngularImpulse = function (angularImpulse) {
56
+ if (!this.physicsBody) {
57
+ throw new Error("No Physics Body for TransformNode");
58
+ }
59
+ this.physicsBody.applyAngularImpulse(angularImpulse);
60
+ return this;
61
+ };
49
62
  //# sourceMappingURL=physicsEngineComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,iCAAiC,CAAC;AAiCzC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE;IAC1D,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,UAA+B,KAA4B;QAC5D,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC7D,UAAU;gBACV,IAAI,IAAI,CAAC,WAAW,EAAE;oBAClB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAC,iBAAiB,CAAC,CAAC;oBAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC3B;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,aAAa,CAAC,SAAS,CAAC,cAAc,GAAG;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,aAAa,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IAClF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\nimport \"../joinedPhysicsEngineComponent\";\r\n\r\ndeclare module \"../../Meshes/transformNode\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface TransformNode {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsBody\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics body\r\n * @returns a physics body or null\r\n */\r\nTransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nTransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n"]}
1
+ {"version":3,"file":"physicsEngineComponent.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsEngineComponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAI3D,OAAO,iCAAiC,CAAC;AAuCzC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,EAAE;IAC1D,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IACD,GAAG,EAAE,UAA+B,KAA4B;QAC5D,IAAI,IAAI,CAAC,YAAY,KAAK,KAAK,EAAE;YAC7B,OAAO;SACV;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE;YAC9B,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;QAE1B,IAAI,KAAK,EAAE;YACP,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC7D,UAAU;gBACV,IAAI,IAAI,CAAC,WAAW,EAAE;oBAClB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAC,iBAAiB,CAAC,CAAC;oBAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC3B;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;IACD,UAAU,EAAE,IAAI;IAChB,YAAY,EAAE,IAAI;CACrB,CAAC,CAAC;AAEH;;;GAGG;AACH,aAAa,CAAC,SAAS,CAAC,cAAc,GAAG;IACrC,OAAO,IAAI,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,aAAa,CAAC,SAAS,CAAC,YAAY,GAAG,UAAU,KAAc,EAAE,YAAqB;IAClF,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,aAAa,CAAC,SAAS,CAAC,mBAAmB,GAAG,UAAU,cAAuB;IAC3E,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;KACxD;IACD,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;IACrD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport type { Vector3 } from \"../../Maths/math.vector\";\r\nimport { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { Node } from \"../../node\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\nimport \"../joinedPhysicsEngineComponent\";\r\n\r\ndeclare module \"../../Meshes/transformNode\" {\r\n /**\r\n *\r\n */\r\n /** @internal */\r\n export interface TransformNode {\r\n /** @internal */\r\n _physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n * @see\r\n */\r\n physicsBody: Nullable<PhysicsBody>;\r\n\r\n /**\r\n *\r\n */\r\n getPhysicsBody(): Nullable<PhysicsBody>;\r\n\r\n /** Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n */\r\n applyImpulse(force: Vector3, contactPoint: Vector3): TransformNode;\r\n\r\n /** Apply a physic angular impulse to the mesh\r\n * @param angularImpulse defines the torque to apply\r\n * @returns the current mesh\r\n */\r\n applyAngularImpulse(angularImpulse: Vector3): TransformNode;\r\n\r\n /** @internal */\r\n _disposePhysicsObserver: Nullable<Observer<Node>>;\r\n }\r\n}\r\n\r\nObject.defineProperty(TransformNode.prototype, \"physicsBody\", {\r\n get: function (this: TransformNode) {\r\n return this._physicsBody;\r\n },\r\n set: function (this: TransformNode, value: Nullable<PhysicsBody>) {\r\n if (this._physicsBody === value) {\r\n return;\r\n }\r\n if (this._disposePhysicsObserver) {\r\n this.onDisposeObservable.remove(this._disposePhysicsObserver);\r\n }\r\n\r\n this._physicsBody = value;\r\n\r\n if (value) {\r\n this._disposePhysicsObserver = this.onDisposeObservable.add(() => {\r\n // Physics\r\n if (this.physicsBody) {\r\n this.physicsBody.dispose(/*!doNotRecurse*/);\r\n this.physicsBody = null;\r\n }\r\n });\r\n }\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\n/**\r\n * Gets the current physics body\r\n * @returns a physics body or null\r\n */\r\nTransformNode.prototype.getPhysicsBody = function (): Nullable<PhysicsBody> {\r\n return this.physicsBody;\r\n};\r\n\r\n/**\r\n * Apply a physic impulse to the mesh\r\n * @param force defines the force to apply\r\n * @param contactPoint defines where to apply the force\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nTransformNode.prototype.applyImpulse = function (force: Vector3, contactPoint: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyImpulse(force, contactPoint);\r\n return this;\r\n};\r\n\r\n/**\r\n * Apply a physic angular impulse to the mesh\r\n * @param angularImpulse defines the torque to apply\r\n * @returns the current mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nTransformNode.prototype.applyAngularImpulse = function (angularImpulse: Vector3): TransformNode {\r\n if (!this.physicsBody) {\r\n throw new Error(\"No Physics Body for TransformNode\");\r\n }\r\n this.physicsBody.applyAngularImpulse(angularImpulse);\r\n return this;\r\n};\r\n"]}
@@ -242,7 +242,7 @@ export class DepthPeelingRenderer {
242
242
  this._thinTextures[6].dispose();
243
243
  }
244
244
  this._thinTextures[6] = new ThinTexture(this._blendBackTexture);
245
- prePassRenderer.defaultRT.renderTarget._shareDepth(this._depthMrts[0].renderTarget);
245
+ prePassRenderer.defaultRT.renderTarget.shareDepth(this._depthMrts[0].renderTarget);
246
246
  }
247
247
  return true;
248
248
  }
@@ -1 +1 @@
1
- {"version":3,"file":"depthPeelingRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/depthPeelingRenderer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,MAAM,EA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CAAY;AAC9B,+BAAU,GAAG,CAAC,AAAJ,CAAK;AACf,+BAAU,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["/**\r\n * Implementation based on https://medium.com/@shrekshao_71662/dual-depth-peeling-implementation-in-webgl-11baa061ba4b\r\n */\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { MultiRenderTarget } from \"../Materials/Textures/multiRenderTarget\";\r\nimport type { InternalTextureCreationOptions } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Scene } from \"../scene\";\r\nimport { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { PrePassEffectConfiguration } from \"./prePassEffectConfiguration\";\r\nimport type { PrePassRenderer } from \"./prePassRenderer\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport { Material } from \"../Materials/material\";\r\n\r\nimport \"../Shaders/postprocess.vertex\";\r\nimport \"../Shaders/oitFinal.fragment\";\r\nimport \"../Shaders/oitBackBlend.fragment\";\r\n\r\nclass DepthPeelingEffectConfiguration implements PrePassEffectConfiguration {\r\n /**\r\n * Is this effect enabled\r\n */\r\n public enabled = true;\r\n\r\n /**\r\n * Name of the configuration\r\n */\r\n public name = \"depthPeeling\";\r\n\r\n /**\r\n * Textures that should be present in the MRT for this effect to work\r\n */\r\n public readonly texturesRequired: number[] = [Constants.PREPASS_COLOR_TEXTURE_TYPE];\r\n}\r\n\r\n/**\r\n * The depth peeling renderer that performs\r\n * Order independant transparency (OIT).\r\n * This should not be instanciated directly, as it is part of a scene component\r\n */\r\nexport class DepthPeelingRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _depthMrts: MultiRenderTarget[];\r\n private _thinTextures: ThinTexture[] = [];\r\n private _colorMrts: MultiRenderTarget[];\r\n private _blendBackMrt: MultiRenderTarget;\r\n private _outputRT: RenderTargetTexture;\r\n\r\n private _blendBackEffectWrapper: EffectWrapper;\r\n private _blendBackEffectWrapperPingPong: EffectWrapper;\r\n private _finalEffectWrapper: EffectWrapper;\r\n private _effectRenderer: EffectRenderer;\r\n\r\n private _currentPingPongState: number = 0;\r\n private _prePassEffectConfiguration: DepthPeelingEffectConfiguration;\r\n\r\n private _blendBackTexture: InternalTexture;\r\n private _layoutCacheFormat = [[true], [true, true], [true, true, true]];\r\n private _layoutCache: number[][] = [];\r\n private _renderPassIds: number[];\r\n private _candidateSubMeshes: SmartArray<SubMesh> = new SmartArray(10);\r\n private _excludedSubMeshes: SmartArray<SubMesh> = new SmartArray(10);\r\n private _excludedMeshes: number[] = [];\r\n\r\n private static _DEPTH_CLEAR_VALUE = -99999.0;\r\n private static _MIN_DEPTH = 0;\r\n private static _MAX_DEPTH = 1;\r\n\r\n private _colorCache = [\r\n new Color4(DepthPeelingRenderer._DEPTH_CLEAR_VALUE, DepthPeelingRenderer._DEPTH_CLEAR_VALUE, 0, 0),\r\n new Color4(-DepthPeelingRenderer._MIN_DEPTH, DepthPeelingRenderer._MAX_DEPTH, 0, 0),\r\n new Color4(0, 0, 0, 0),\r\n ];\r\n\r\n private _passCount: number;\r\n /**\r\n * Number of depth peeling passes. As we are using dual depth peeling, each pass two levels of transparency are processed.\r\n */\r\n public get passCount(): number {\r\n return this._passCount;\r\n }\r\n\r\n public set passCount(count: number) {\r\n if (this._passCount === count) {\r\n return;\r\n }\r\n this._passCount = count;\r\n this._createRenderPassIds();\r\n }\r\n\r\n private _useRenderPasses: boolean;\r\n /**\r\n * Instructs the renderer to use render passes. It is an optimization that makes the rendering faster for some engines (like WebGPU) but that consumes more memory, so it is disabled by default.\r\n */\r\n public get useRenderPasses() {\r\n return this._useRenderPasses;\r\n }\r\n\r\n public set useRenderPasses(usePasses: boolean) {\r\n if (this._useRenderPasses === usePasses) {\r\n return;\r\n }\r\n this._useRenderPasses = usePasses;\r\n this._createRenderPassIds();\r\n }\r\n\r\n /**\r\n * Add a mesh in the exclusion list to prevent it to be handled by the depth peeling renderer\r\n * @param mesh The mesh to exclude from the depth peeling renderer\r\n */\r\n public addExcludedMesh(mesh: AbstractMesh): void {\r\n if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {\r\n this._excludedMeshes.push(mesh.uniqueId);\r\n }\r\n }\r\n\r\n /**\r\n * Remove a mesh from the exclusion list of the depth peeling renderer\r\n * @param mesh The mesh to remove\r\n */\r\n public removeExcludedMesh(mesh: AbstractMesh): void {\r\n const index = this._excludedMeshes.indexOf(mesh.uniqueId);\r\n if (index !== -1) {\r\n this._excludedMeshes.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the depth peeling renderer\r\n * @param scene Scene to attach to\r\n * @param passCount Number of depth layers to peel\r\n * @returns The depth peeling renderer\r\n */\r\n constructor(scene: Scene, passCount: number = 5) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._passCount = passCount;\r\n\r\n // We need a depth texture for opaque\r\n if (!scene.enablePrePassRenderer()) {\r\n Logger.Warn(\"Depth peeling for order independant transparency could not enable PrePass, aborting.\");\r\n return;\r\n }\r\n\r\n for (let i = 0; i < this._layoutCacheFormat.length; ++i) {\r\n this._layoutCache[i] = this._engine.buildTextureLayout(this._layoutCacheFormat[i]);\r\n }\r\n\r\n this._renderPassIds = [];\r\n this.useRenderPasses = false;\r\n\r\n this._prePassEffectConfiguration = new DepthPeelingEffectConfiguration();\r\n this._createTextures();\r\n this._createEffects();\r\n }\r\n\r\n private _createRenderPassIds(): void {\r\n this._releaseRenderPassIds();\r\n if (this._useRenderPasses) {\r\n for (let i = 0; i < this._passCount + 1; ++i) {\r\n if (!this._renderPassIds[i]) {\r\n this._renderPassIds[i] = this._engine.createRenderPassId(`DepthPeelingRenderer - pass #${i}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _releaseRenderPassIds(): void {\r\n for (let i = 0; i < this._renderPassIds.length; ++i) {\r\n this._engine.releaseRenderPassId(this._renderPassIds[i]);\r\n }\r\n this._renderPassIds = [];\r\n }\r\n\r\n private _createTextures() {\r\n const size = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n };\r\n\r\n // 2 for ping pong\r\n this._depthMrts = [\r\n new MultiRenderTarget(\"depthPeelingDepth0MRT\", size, 3, this._scene, undefined, [\r\n \"depthPeelingDepth0MRT_depth\",\r\n \"depthPeelingDepth0MRT_frontColor\",\r\n \"depthPeelingDepth0MRT_backColor\",\r\n ]),\r\n new MultiRenderTarget(\"depthPeelingDepth1MRT\", size, 3, this._scene, undefined, [\r\n \"depthPeelingDepth1MRT_depth\",\r\n \"depthPeelingDepth1MRT_frontColor\",\r\n \"depthPeelingDepth1MRT_backColor\",\r\n ]),\r\n ];\r\n this._colorMrts = [\r\n new MultiRenderTarget(\"depthPeelingColor0MRT\", size, 2, this._scene, { generateDepthBuffer: false }, [\r\n \"depthPeelingColor0MRT_frontColor\",\r\n \"depthPeelingColor0MRT_backColor\",\r\n ]),\r\n new MultiRenderTarget(\"depthPeelingColor1MRT\", size, 2, this._scene, { generateDepthBuffer: false }, [\r\n \"depthPeelingColor1MRT_frontColor\",\r\n \"depthPeelingColor1MRT_backColor\",\r\n ]),\r\n ];\r\n this._blendBackMrt = new MultiRenderTarget(\"depthPeelingBackMRT\", size, 1, this._scene, { generateDepthBuffer: false }, [\"depthPeelingBackMRT_blendBack\"]);\r\n this._outputRT = new RenderTargetTexture(\"depthPeelingOutputRTT\", size, this._scene, false);\r\n\r\n // 0 is a depth texture\r\n // 1 is a color texture\r\n const optionsArray = [\r\n {\r\n format: Constants.TEXTUREFORMAT_RG, // For MSAA we need RGBA\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n type: this._engine.getCaps().textureFloatLinearFiltering ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_HALF_FLOAT,\r\n label: \"DepthPeelingRenderer-DepthTexture\",\r\n } as InternalTextureCreationOptions,\r\n {\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT, // For MSAA we need FLOAT\r\n label: \"DepthPeelingRenderer-ColorTexture\",\r\n } as InternalTextureCreationOptions,\r\n ];\r\n\r\n for (let i = 0; i < 2; i++) {\r\n const depthTexture = this._engine._createInternalTexture(size, optionsArray[0], false);\r\n const frontColorTexture = this._engine._createInternalTexture(size, optionsArray[1], false);\r\n const backColorTexture = this._engine._createInternalTexture(size, optionsArray[1], false);\r\n\r\n this._depthMrts[i].setInternalTexture(depthTexture, 0);\r\n this._depthMrts[i].setInternalTexture(frontColorTexture, 1);\r\n this._depthMrts[i].setInternalTexture(backColorTexture, 2);\r\n this._colorMrts[i].setInternalTexture(frontColorTexture, 0);\r\n this._colorMrts[i].setInternalTexture(backColorTexture, 1);\r\n\r\n this._thinTextures.push(new ThinTexture(depthTexture), new ThinTexture(frontColorTexture), new ThinTexture(backColorTexture));\r\n }\r\n }\r\n\r\n // TODO : explore again MSAA with depth peeling when\r\n // we are able to fetch individual samples in a multisampled renderbuffer\r\n // public set samples(value: number) {\r\n // for (let i = 0; i < 2; i++) {\r\n // this._depthMrts[i].samples = value;\r\n // this._colorMrts[i].samples = value;\r\n // }\r\n // this._scene.prePassRenderer!.samples = value;\r\n // }\r\n\r\n private _disposeTextures() {\r\n for (let i = 0; i < this._thinTextures.length; i++) {\r\n if (i === 6) {\r\n // Do not dispose the shared texture with the prepass\r\n continue;\r\n }\r\n this._thinTextures[i].dispose();\r\n }\r\n\r\n for (let i = 0; i < 2; i++) {\r\n this._depthMrts[i].dispose(true);\r\n this._colorMrts[i].dispose(true);\r\n this._blendBackMrt.dispose(true);\r\n }\r\n this._outputRT.dispose();\r\n\r\n this._thinTextures = [];\r\n this._colorMrts = [];\r\n this._depthMrts = [];\r\n }\r\n\r\n private _updateTextures() {\r\n if (this._depthMrts[0].getSize().width !== this._engine.getRenderWidth() || this._depthMrts[0].getSize().height !== this._engine.getRenderHeight()) {\r\n this._disposeTextures();\r\n this._createTextures();\r\n }\r\n return this._updateTextureReferences();\r\n }\r\n\r\n private _updateTextureReferences() {\r\n const prePassRenderer = this._scene.prePassRenderer;\r\n\r\n if (!prePassRenderer) {\r\n return false;\r\n }\r\n\r\n // Retrieve opaque color texture\r\n const textureIndex = prePassRenderer.getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE);\r\n const prePassTexture = prePassRenderer.defaultRT.textures?.length ? prePassRenderer.defaultRT.textures[textureIndex].getInternalTexture() : null;\r\n\r\n if (!prePassTexture) {\r\n return false;\r\n }\r\n\r\n if (this._blendBackTexture !== prePassTexture) {\r\n this._blendBackTexture = prePassTexture;\r\n this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0);\r\n\r\n if (this._thinTextures[6]) {\r\n this._thinTextures[6].dispose();\r\n }\r\n this._thinTextures[6] = new ThinTexture(this._blendBackTexture);\r\n\r\n prePassRenderer.defaultRT.renderTarget!._shareDepth(this._depthMrts[0].renderTarget!);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _createEffects() {\r\n this._blendBackEffectWrapper = new EffectWrapper({\r\n fragmentShader: \"oitBackBlend\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n this._blendBackEffectWrapperPingPong = new EffectWrapper({\r\n fragmentShader: \"oitBackBlend\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n\r\n this._finalEffectWrapper = new EffectWrapper({\r\n fragmentShader: \"oitFinal\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uFrontColor\", \"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n }\r\n\r\n /**\r\n * Links to the prepass renderer\r\n * @param prePassRenderer The scene PrePassRenderer\r\n */\r\n public setPrePassRenderer(prePassRenderer: PrePassRenderer) {\r\n prePassRenderer.addEffectConfiguration(this._prePassEffectConfiguration);\r\n }\r\n\r\n /**\r\n * Binds depth peeling textures on an effect\r\n * @param effect The effect to bind textures on\r\n */\r\n public bind(effect: Effect) {\r\n effect.setTexture(\"oitDepthSampler\", this._thinTextures[this._currentPingPongState * 3]);\r\n effect.setTexture(\"oitFrontColorSampler\", this._thinTextures[this._currentPingPongState * 3 + 1]);\r\n }\r\n\r\n private _renderSubMeshes(transparentSubMeshes: SmartArray<SubMesh>) {\r\n let mapMaterialContext: { [uniqueId: number]: IMaterialContext | undefined };\r\n if (this._useRenderPasses) {\r\n mapMaterialContext = {};\r\n }\r\n for (let j = 0; j < transparentSubMeshes.length; j++) {\r\n const material = transparentSubMeshes.data[j].getMaterial();\r\n let previousShaderHotSwapping = true;\r\n let previousBFC = false;\r\n\r\n const subMesh = transparentSubMeshes.data[j];\r\n let drawWrapper: DrawWrapper | undefined;\r\n let firstDraw = false;\r\n\r\n if (this._useRenderPasses) {\r\n drawWrapper = subMesh._getDrawWrapper();\r\n firstDraw = !drawWrapper;\r\n }\r\n\r\n if (material) {\r\n previousShaderHotSwapping = material.allowShaderHotSwapping;\r\n previousBFC = material.backFaceCulling;\r\n material.allowShaderHotSwapping = false;\r\n material.backFaceCulling = false;\r\n }\r\n\r\n subMesh.render(false);\r\n\r\n if (firstDraw) {\r\n // first time we draw this submesh: we replace the material context\r\n drawWrapper = subMesh._getDrawWrapper()!; // we are sure it is now non empty as we just rendered the submesh\r\n if (drawWrapper.materialContext) {\r\n let newMaterialContext = mapMaterialContext![drawWrapper.materialContext.uniqueId];\r\n if (!newMaterialContext) {\r\n newMaterialContext = mapMaterialContext![drawWrapper.materialContext.uniqueId] = this._engine.createMaterialContext();\r\n }\r\n subMesh._getDrawWrapper()!.materialContext = newMaterialContext;\r\n }\r\n }\r\n\r\n if (material) {\r\n material.allowShaderHotSwapping = previousShaderHotSwapping;\r\n material.backFaceCulling = previousBFC;\r\n }\r\n }\r\n }\r\n\r\n private _finalCompose(writeId: number) {\r\n const output = this._scene.prePassRenderer?.setCustomOutput(this._outputRT);\r\n if (output) {\r\n this._engine.bindFramebuffer(this._outputRT.renderTarget!);\r\n } else {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n this._engine.applyStates();\r\n\r\n this._engine.enableEffect(this._finalEffectWrapper._drawWrapper);\r\n this._finalEffectWrapper.effect.setTexture(\"uFrontColor\", this._thinTextures[writeId * 3 + 1]);\r\n this._finalEffectWrapper.effect.setTexture(\"uBackColor\", this._thinTextures[6]);\r\n this._effectRenderer.render(this._finalEffectWrapper);\r\n }\r\n\r\n /**\r\n * Checks if the depth peeling renderer is ready to render transparent meshes\r\n * @returns true if the depth peeling renderer is ready to render the transparent meshes\r\n */\r\n public isReady() {\r\n return (\r\n this._blendBackEffectWrapper.effect.isReady() &&\r\n this._blendBackEffectWrapperPingPong.effect.isReady() &&\r\n this._finalEffectWrapper.effect.isReady() &&\r\n this._updateTextures()\r\n );\r\n }\r\n\r\n /**\r\n * Renders transparent submeshes with depth peeling\r\n * @param transparentSubMeshes List of transparent meshes to render\r\n * @returns The array of submeshes that could not be handled by this renderer\r\n */\r\n public render(transparentSubMeshes: SmartArray<SubMesh>): SmartArray<SubMesh> {\r\n this._candidateSubMeshes.length = 0;\r\n this._excludedSubMeshes.length = 0;\r\n if (!this.isReady()) {\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n if (this._scene.activeCamera) {\r\n this._engine.setViewport(this._scene.activeCamera.viewport);\r\n }\r\n\r\n for (let i = 0; i < transparentSubMeshes.length; i++) {\r\n const subMesh = transparentSubMeshes.data[i];\r\n const material = subMesh.getMaterial();\r\n const fillMode = material && subMesh.getRenderingMesh()._getRenderingFillMode(material.fillMode);\r\n\r\n if (\r\n material &&\r\n (fillMode === Material.TriangleFanDrawMode || fillMode === Material.TriangleFillMode || fillMode === Material.TriangleStripDrawMode) &&\r\n this._excludedMeshes.indexOf(subMesh.getMesh().uniqueId) === -1\r\n ) {\r\n this._candidateSubMeshes.push(subMesh);\r\n } else {\r\n this._excludedSubMeshes.push(subMesh);\r\n }\r\n }\r\n\r\n if (!this._candidateSubMeshes.length) {\r\n this._engine.bindFramebuffer(this._colorMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget!);\r\n\r\n this._finalCompose(1);\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n const currentRenderPassId = this._engine.currentRenderPassId;\r\n\r\n (this._scene.prePassRenderer! as any)._enabled = false;\r\n\r\n if (this._useRenderPasses) {\r\n this._engine.currentRenderPassId = this._renderPassIds[0];\r\n }\r\n\r\n // Clears\r\n this._engine.bindFramebuffer(this._depthMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[0], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._depthMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[1], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget!);\r\n\r\n // Draw depth for first pass\r\n this._engine.bindFramebuffer(this._depthMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_ONEONE_ONEONE); // in WebGPU, when using MIN or MAX equation, the src / dst color factors should not use SRC_ALPHA and the src / dst alpha factors must be 1 else WebGPU will throw a validation error\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_MAX);\r\n this._engine.depthCullingState.depthMask = false;\r\n this._engine.depthCullingState.depthTest = true;\r\n this._engine.applyStates();\r\n\r\n this._currentPingPongState = 1;\r\n // Render\r\n this._renderSubMeshes(this._candidateSubMeshes);\r\n this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget!);\r\n\r\n this._scene.resetCachedMaterial();\r\n\r\n // depth peeling ping-pong\r\n let readId = 0;\r\n let writeId = 0;\r\n\r\n for (let i = 0; i < this._passCount; i++) {\r\n readId = i % 2;\r\n writeId = 1 - readId;\r\n this._currentPingPongState = readId;\r\n\r\n if (this._useRenderPasses) {\r\n this._engine.currentRenderPassId = this._renderPassIds[i + 1];\r\n }\r\n\r\n if (this._scene.activeCamera) {\r\n this._engine.setViewport(this._scene.activeCamera.viewport);\r\n }\r\n\r\n // Clears\r\n this._engine.bindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[0], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[writeId].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[2]);\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_ONEONE_ONEONE); // the value does not matter (as MAX operation does not use them) but the src and dst color factors should not use SRC_ALPHA else WebGPU will throw a validation error\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_MAX);\r\n this._engine.depthCullingState.depthTest = false;\r\n this._engine.applyStates();\r\n\r\n // Render\r\n this._renderSubMeshes(this._candidateSubMeshes);\r\n this._engine.unBindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n\r\n this._scene.resetCachedMaterial();\r\n\r\n // Back color\r\n this._engine.bindFramebuffer(this._blendBackMrt.renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_ADD);\r\n this._engine.setAlphaMode(Constants.ALPHA_LAYER_ACCUMULATE);\r\n this._engine.applyStates();\r\n\r\n const blendBackEffectWrapper = writeId === 0 || !this._useRenderPasses ? this._blendBackEffectWrapper : this._blendBackEffectWrapperPingPong;\r\n this._engine.enableEffect(blendBackEffectWrapper._drawWrapper);\r\n blendBackEffectWrapper.effect.setTexture(\"uBackColor\", this._thinTextures[writeId * 3 + 2]);\r\n this._effectRenderer.render(blendBackEffectWrapper);\r\n this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget!);\r\n }\r\n\r\n this._engine.currentRenderPassId = currentRenderPassId;\r\n\r\n // Final composition on default FB\r\n this._finalCompose(writeId);\r\n\r\n (this._scene.prePassRenderer! as any)._enabled = true;\r\n this._engine.depthCullingState.depthMask = true;\r\n this._engine.depthCullingState.depthTest = true;\r\n\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n /**\r\n * Disposes the depth peeling renderer and associated ressources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._blendBackEffectWrapper.dispose();\r\n this._finalEffectWrapper.dispose();\r\n this._effectRenderer.dispose();\r\n this._releaseRenderPassIds();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"depthPeelingRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/depthPeelingRenderer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAI5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,+BAA+B,CAAC;AACvC,OAAO,8BAA8B,CAAC;AACtC,OAAO,kCAAkC,CAAC;AAE1C,MAAM,+BAA+B;IAArC;QACI;;WAEG;QACI,YAAO,GAAG,IAAI,CAAC;QAEtB;;WAEG;QACI,SAAI,GAAG,cAAc,CAAC;QAE7B;;WAEG;QACa,qBAAgB,GAAa,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;IACxF,CAAC;CAAA;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAoC7B;;OAEG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;IAED,IAAW,SAAS,CAAC,KAAa;QAC9B,IAAI,IAAI,CAAC,UAAU,KAAK,KAAK,EAAE;YAC3B,OAAO;SACV;QACD,IAAI,CAAC,UAAU,GAAG,KAAK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D,kCAAkC;QAClC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAE3B,IAAI,CAAC,MAAM,CAAC,eAAwB,CAAC,QAAQ,GAAG,IAAI,CAAC;QACtD,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;QAEhD,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxB,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;QACvC,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QACnC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,EAAE,CAAC;IACjC,CAAC;;AAjhBc,uCAAkB,GAAG,CAAC,OAAO,AAAX,CAAY;AAC9B,+BAAU,GAAG,CAAC,AAAJ,CAAK;AACf,+BAAU,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["/**\r\n * Implementation based on https://medium.com/@shrekshao_71662/dual-depth-peeling-implementation-in-webgl-11baa061ba4b\r\n */\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Engine } from \"../Engines/engine\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { MultiRenderTarget } from \"../Materials/Textures/multiRenderTarget\";\r\nimport type { InternalTextureCreationOptions } from \"../Materials/Textures/textureCreationOptions\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { SubMesh } from \"../Meshes/subMesh\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport type { Scene } from \"../scene\";\r\nimport { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { PrePassEffectConfiguration } from \"./prePassEffectConfiguration\";\r\nimport type { PrePassRenderer } from \"./prePassRenderer\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { IMaterialContext } from \"../Engines/IMaterialContext\";\r\nimport type { DrawWrapper } from \"../Materials/drawWrapper\";\r\nimport { Material } from \"../Materials/material\";\r\n\r\nimport \"../Shaders/postprocess.vertex\";\r\nimport \"../Shaders/oitFinal.fragment\";\r\nimport \"../Shaders/oitBackBlend.fragment\";\r\n\r\nclass DepthPeelingEffectConfiguration implements PrePassEffectConfiguration {\r\n /**\r\n * Is this effect enabled\r\n */\r\n public enabled = true;\r\n\r\n /**\r\n * Name of the configuration\r\n */\r\n public name = \"depthPeeling\";\r\n\r\n /**\r\n * Textures that should be present in the MRT for this effect to work\r\n */\r\n public readonly texturesRequired: number[] = [Constants.PREPASS_COLOR_TEXTURE_TYPE];\r\n}\r\n\r\n/**\r\n * The depth peeling renderer that performs\r\n * Order independant transparency (OIT).\r\n * This should not be instanciated directly, as it is part of a scene component\r\n */\r\nexport class DepthPeelingRenderer {\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _depthMrts: MultiRenderTarget[];\r\n private _thinTextures: ThinTexture[] = [];\r\n private _colorMrts: MultiRenderTarget[];\r\n private _blendBackMrt: MultiRenderTarget;\r\n private _outputRT: RenderTargetTexture;\r\n\r\n private _blendBackEffectWrapper: EffectWrapper;\r\n private _blendBackEffectWrapperPingPong: EffectWrapper;\r\n private _finalEffectWrapper: EffectWrapper;\r\n private _effectRenderer: EffectRenderer;\r\n\r\n private _currentPingPongState: number = 0;\r\n private _prePassEffectConfiguration: DepthPeelingEffectConfiguration;\r\n\r\n private _blendBackTexture: InternalTexture;\r\n private _layoutCacheFormat = [[true], [true, true], [true, true, true]];\r\n private _layoutCache: number[][] = [];\r\n private _renderPassIds: number[];\r\n private _candidateSubMeshes: SmartArray<SubMesh> = new SmartArray(10);\r\n private _excludedSubMeshes: SmartArray<SubMesh> = new SmartArray(10);\r\n private _excludedMeshes: number[] = [];\r\n\r\n private static _DEPTH_CLEAR_VALUE = -99999.0;\r\n private static _MIN_DEPTH = 0;\r\n private static _MAX_DEPTH = 1;\r\n\r\n private _colorCache = [\r\n new Color4(DepthPeelingRenderer._DEPTH_CLEAR_VALUE, DepthPeelingRenderer._DEPTH_CLEAR_VALUE, 0, 0),\r\n new Color4(-DepthPeelingRenderer._MIN_DEPTH, DepthPeelingRenderer._MAX_DEPTH, 0, 0),\r\n new Color4(0, 0, 0, 0),\r\n ];\r\n\r\n private _passCount: number;\r\n /**\r\n * Number of depth peeling passes. As we are using dual depth peeling, each pass two levels of transparency are processed.\r\n */\r\n public get passCount(): number {\r\n return this._passCount;\r\n }\r\n\r\n public set passCount(count: number) {\r\n if (this._passCount === count) {\r\n return;\r\n }\r\n this._passCount = count;\r\n this._createRenderPassIds();\r\n }\r\n\r\n private _useRenderPasses: boolean;\r\n /**\r\n * Instructs the renderer to use render passes. It is an optimization that makes the rendering faster for some engines (like WebGPU) but that consumes more memory, so it is disabled by default.\r\n */\r\n public get useRenderPasses() {\r\n return this._useRenderPasses;\r\n }\r\n\r\n public set useRenderPasses(usePasses: boolean) {\r\n if (this._useRenderPasses === usePasses) {\r\n return;\r\n }\r\n this._useRenderPasses = usePasses;\r\n this._createRenderPassIds();\r\n }\r\n\r\n /**\r\n * Add a mesh in the exclusion list to prevent it to be handled by the depth peeling renderer\r\n * @param mesh The mesh to exclude from the depth peeling renderer\r\n */\r\n public addExcludedMesh(mesh: AbstractMesh): void {\r\n if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {\r\n this._excludedMeshes.push(mesh.uniqueId);\r\n }\r\n }\r\n\r\n /**\r\n * Remove a mesh from the exclusion list of the depth peeling renderer\r\n * @param mesh The mesh to remove\r\n */\r\n public removeExcludedMesh(mesh: AbstractMesh): void {\r\n const index = this._excludedMeshes.indexOf(mesh.uniqueId);\r\n if (index !== -1) {\r\n this._excludedMeshes.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Instanciates the depth peeling renderer\r\n * @param scene Scene to attach to\r\n * @param passCount Number of depth layers to peel\r\n * @returns The depth peeling renderer\r\n */\r\n constructor(scene: Scene, passCount: number = 5) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._passCount = passCount;\r\n\r\n // We need a depth texture for opaque\r\n if (!scene.enablePrePassRenderer()) {\r\n Logger.Warn(\"Depth peeling for order independant transparency could not enable PrePass, aborting.\");\r\n return;\r\n }\r\n\r\n for (let i = 0; i < this._layoutCacheFormat.length; ++i) {\r\n this._layoutCache[i] = this._engine.buildTextureLayout(this._layoutCacheFormat[i]);\r\n }\r\n\r\n this._renderPassIds = [];\r\n this.useRenderPasses = false;\r\n\r\n this._prePassEffectConfiguration = new DepthPeelingEffectConfiguration();\r\n this._createTextures();\r\n this._createEffects();\r\n }\r\n\r\n private _createRenderPassIds(): void {\r\n this._releaseRenderPassIds();\r\n if (this._useRenderPasses) {\r\n for (let i = 0; i < this._passCount + 1; ++i) {\r\n if (!this._renderPassIds[i]) {\r\n this._renderPassIds[i] = this._engine.createRenderPassId(`DepthPeelingRenderer - pass #${i}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _releaseRenderPassIds(): void {\r\n for (let i = 0; i < this._renderPassIds.length; ++i) {\r\n this._engine.releaseRenderPassId(this._renderPassIds[i]);\r\n }\r\n this._renderPassIds = [];\r\n }\r\n\r\n private _createTextures() {\r\n const size = {\r\n width: this._engine.getRenderWidth(),\r\n height: this._engine.getRenderHeight(),\r\n };\r\n\r\n // 2 for ping pong\r\n this._depthMrts = [\r\n new MultiRenderTarget(\"depthPeelingDepth0MRT\", size, 3, this._scene, undefined, [\r\n \"depthPeelingDepth0MRT_depth\",\r\n \"depthPeelingDepth0MRT_frontColor\",\r\n \"depthPeelingDepth0MRT_backColor\",\r\n ]),\r\n new MultiRenderTarget(\"depthPeelingDepth1MRT\", size, 3, this._scene, undefined, [\r\n \"depthPeelingDepth1MRT_depth\",\r\n \"depthPeelingDepth1MRT_frontColor\",\r\n \"depthPeelingDepth1MRT_backColor\",\r\n ]),\r\n ];\r\n this._colorMrts = [\r\n new MultiRenderTarget(\"depthPeelingColor0MRT\", size, 2, this._scene, { generateDepthBuffer: false }, [\r\n \"depthPeelingColor0MRT_frontColor\",\r\n \"depthPeelingColor0MRT_backColor\",\r\n ]),\r\n new MultiRenderTarget(\"depthPeelingColor1MRT\", size, 2, this._scene, { generateDepthBuffer: false }, [\r\n \"depthPeelingColor1MRT_frontColor\",\r\n \"depthPeelingColor1MRT_backColor\",\r\n ]),\r\n ];\r\n this._blendBackMrt = new MultiRenderTarget(\"depthPeelingBackMRT\", size, 1, this._scene, { generateDepthBuffer: false }, [\"depthPeelingBackMRT_blendBack\"]);\r\n this._outputRT = new RenderTargetTexture(\"depthPeelingOutputRTT\", size, this._scene, false);\r\n\r\n // 0 is a depth texture\r\n // 1 is a color texture\r\n const optionsArray = [\r\n {\r\n format: Constants.TEXTUREFORMAT_RG, // For MSAA we need RGBA\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n type: this._engine.getCaps().textureFloatLinearFiltering ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_HALF_FLOAT,\r\n label: \"DepthPeelingRenderer-DepthTexture\",\r\n } as InternalTextureCreationOptions,\r\n {\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n type: Constants.TEXTURETYPE_HALF_FLOAT, // For MSAA we need FLOAT\r\n label: \"DepthPeelingRenderer-ColorTexture\",\r\n } as InternalTextureCreationOptions,\r\n ];\r\n\r\n for (let i = 0; i < 2; i++) {\r\n const depthTexture = this._engine._createInternalTexture(size, optionsArray[0], false);\r\n const frontColorTexture = this._engine._createInternalTexture(size, optionsArray[1], false);\r\n const backColorTexture = this._engine._createInternalTexture(size, optionsArray[1], false);\r\n\r\n this._depthMrts[i].setInternalTexture(depthTexture, 0);\r\n this._depthMrts[i].setInternalTexture(frontColorTexture, 1);\r\n this._depthMrts[i].setInternalTexture(backColorTexture, 2);\r\n this._colorMrts[i].setInternalTexture(frontColorTexture, 0);\r\n this._colorMrts[i].setInternalTexture(backColorTexture, 1);\r\n\r\n this._thinTextures.push(new ThinTexture(depthTexture), new ThinTexture(frontColorTexture), new ThinTexture(backColorTexture));\r\n }\r\n }\r\n\r\n // TODO : explore again MSAA with depth peeling when\r\n // we are able to fetch individual samples in a multisampled renderbuffer\r\n // public set samples(value: number) {\r\n // for (let i = 0; i < 2; i++) {\r\n // this._depthMrts[i].samples = value;\r\n // this._colorMrts[i].samples = value;\r\n // }\r\n // this._scene.prePassRenderer!.samples = value;\r\n // }\r\n\r\n private _disposeTextures() {\r\n for (let i = 0; i < this._thinTextures.length; i++) {\r\n if (i === 6) {\r\n // Do not dispose the shared texture with the prepass\r\n continue;\r\n }\r\n this._thinTextures[i].dispose();\r\n }\r\n\r\n for (let i = 0; i < 2; i++) {\r\n this._depthMrts[i].dispose(true);\r\n this._colorMrts[i].dispose(true);\r\n this._blendBackMrt.dispose(true);\r\n }\r\n this._outputRT.dispose();\r\n\r\n this._thinTextures = [];\r\n this._colorMrts = [];\r\n this._depthMrts = [];\r\n }\r\n\r\n private _updateTextures() {\r\n if (this._depthMrts[0].getSize().width !== this._engine.getRenderWidth() || this._depthMrts[0].getSize().height !== this._engine.getRenderHeight()) {\r\n this._disposeTextures();\r\n this._createTextures();\r\n }\r\n return this._updateTextureReferences();\r\n }\r\n\r\n private _updateTextureReferences() {\r\n const prePassRenderer = this._scene.prePassRenderer;\r\n\r\n if (!prePassRenderer) {\r\n return false;\r\n }\r\n\r\n // Retrieve opaque color texture\r\n const textureIndex = prePassRenderer.getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE);\r\n const prePassTexture = prePassRenderer.defaultRT.textures?.length ? prePassRenderer.defaultRT.textures[textureIndex].getInternalTexture() : null;\r\n\r\n if (!prePassTexture) {\r\n return false;\r\n }\r\n\r\n if (this._blendBackTexture !== prePassTexture) {\r\n this._blendBackTexture = prePassTexture;\r\n this._blendBackMrt.setInternalTexture(this._blendBackTexture, 0);\r\n\r\n if (this._thinTextures[6]) {\r\n this._thinTextures[6].dispose();\r\n }\r\n this._thinTextures[6] = new ThinTexture(this._blendBackTexture);\r\n\r\n prePassRenderer.defaultRT.renderTarget!.shareDepth(this._depthMrts[0].renderTarget!);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _createEffects() {\r\n this._blendBackEffectWrapper = new EffectWrapper({\r\n fragmentShader: \"oitBackBlend\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n this._blendBackEffectWrapperPingPong = new EffectWrapper({\r\n fragmentShader: \"oitBackBlend\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n\r\n this._finalEffectWrapper = new EffectWrapper({\r\n fragmentShader: \"oitFinal\",\r\n useShaderStore: true,\r\n engine: this._engine,\r\n samplerNames: [\"uFrontColor\", \"uBackColor\"],\r\n uniformNames: [],\r\n });\r\n\r\n this._effectRenderer = new EffectRenderer(this._engine);\r\n }\r\n\r\n /**\r\n * Links to the prepass renderer\r\n * @param prePassRenderer The scene PrePassRenderer\r\n */\r\n public setPrePassRenderer(prePassRenderer: PrePassRenderer) {\r\n prePassRenderer.addEffectConfiguration(this._prePassEffectConfiguration);\r\n }\r\n\r\n /**\r\n * Binds depth peeling textures on an effect\r\n * @param effect The effect to bind textures on\r\n */\r\n public bind(effect: Effect) {\r\n effect.setTexture(\"oitDepthSampler\", this._thinTextures[this._currentPingPongState * 3]);\r\n effect.setTexture(\"oitFrontColorSampler\", this._thinTextures[this._currentPingPongState * 3 + 1]);\r\n }\r\n\r\n private _renderSubMeshes(transparentSubMeshes: SmartArray<SubMesh>) {\r\n let mapMaterialContext: { [uniqueId: number]: IMaterialContext | undefined };\r\n if (this._useRenderPasses) {\r\n mapMaterialContext = {};\r\n }\r\n for (let j = 0; j < transparentSubMeshes.length; j++) {\r\n const material = transparentSubMeshes.data[j].getMaterial();\r\n let previousShaderHotSwapping = true;\r\n let previousBFC = false;\r\n\r\n const subMesh = transparentSubMeshes.data[j];\r\n let drawWrapper: DrawWrapper | undefined;\r\n let firstDraw = false;\r\n\r\n if (this._useRenderPasses) {\r\n drawWrapper = subMesh._getDrawWrapper();\r\n firstDraw = !drawWrapper;\r\n }\r\n\r\n if (material) {\r\n previousShaderHotSwapping = material.allowShaderHotSwapping;\r\n previousBFC = material.backFaceCulling;\r\n material.allowShaderHotSwapping = false;\r\n material.backFaceCulling = false;\r\n }\r\n\r\n subMesh.render(false);\r\n\r\n if (firstDraw) {\r\n // first time we draw this submesh: we replace the material context\r\n drawWrapper = subMesh._getDrawWrapper()!; // we are sure it is now non empty as we just rendered the submesh\r\n if (drawWrapper.materialContext) {\r\n let newMaterialContext = mapMaterialContext![drawWrapper.materialContext.uniqueId];\r\n if (!newMaterialContext) {\r\n newMaterialContext = mapMaterialContext![drawWrapper.materialContext.uniqueId] = this._engine.createMaterialContext();\r\n }\r\n subMesh._getDrawWrapper()!.materialContext = newMaterialContext;\r\n }\r\n }\r\n\r\n if (material) {\r\n material.allowShaderHotSwapping = previousShaderHotSwapping;\r\n material.backFaceCulling = previousBFC;\r\n }\r\n }\r\n }\r\n\r\n private _finalCompose(writeId: number) {\r\n const output = this._scene.prePassRenderer?.setCustomOutput(this._outputRT);\r\n if (output) {\r\n this._engine.bindFramebuffer(this._outputRT.renderTarget!);\r\n } else {\r\n this._engine.restoreDefaultFramebuffer();\r\n }\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n this._engine.applyStates();\r\n\r\n this._engine.enableEffect(this._finalEffectWrapper._drawWrapper);\r\n this._finalEffectWrapper.effect.setTexture(\"uFrontColor\", this._thinTextures[writeId * 3 + 1]);\r\n this._finalEffectWrapper.effect.setTexture(\"uBackColor\", this._thinTextures[6]);\r\n this._effectRenderer.render(this._finalEffectWrapper);\r\n }\r\n\r\n /**\r\n * Checks if the depth peeling renderer is ready to render transparent meshes\r\n * @returns true if the depth peeling renderer is ready to render the transparent meshes\r\n */\r\n public isReady() {\r\n return (\r\n this._blendBackEffectWrapper.effect.isReady() &&\r\n this._blendBackEffectWrapperPingPong.effect.isReady() &&\r\n this._finalEffectWrapper.effect.isReady() &&\r\n this._updateTextures()\r\n );\r\n }\r\n\r\n /**\r\n * Renders transparent submeshes with depth peeling\r\n * @param transparentSubMeshes List of transparent meshes to render\r\n * @returns The array of submeshes that could not be handled by this renderer\r\n */\r\n public render(transparentSubMeshes: SmartArray<SubMesh>): SmartArray<SubMesh> {\r\n this._candidateSubMeshes.length = 0;\r\n this._excludedSubMeshes.length = 0;\r\n if (!this.isReady()) {\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n if (this._scene.activeCamera) {\r\n this._engine.setViewport(this._scene.activeCamera.viewport);\r\n }\r\n\r\n for (let i = 0; i < transparentSubMeshes.length; i++) {\r\n const subMesh = transparentSubMeshes.data[i];\r\n const material = subMesh.getMaterial();\r\n const fillMode = material && subMesh.getRenderingMesh()._getRenderingFillMode(material.fillMode);\r\n\r\n if (\r\n material &&\r\n (fillMode === Material.TriangleFanDrawMode || fillMode === Material.TriangleFillMode || fillMode === Material.TriangleStripDrawMode) &&\r\n this._excludedMeshes.indexOf(subMesh.getMesh().uniqueId) === -1\r\n ) {\r\n this._candidateSubMeshes.push(subMesh);\r\n } else {\r\n this._excludedSubMeshes.push(subMesh);\r\n }\r\n }\r\n\r\n if (!this._candidateSubMeshes.length) {\r\n this._engine.bindFramebuffer(this._colorMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget!);\r\n\r\n this._finalCompose(1);\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n const currentRenderPassId = this._engine.currentRenderPassId;\r\n\r\n (this._scene.prePassRenderer! as any)._enabled = false;\r\n\r\n if (this._useRenderPasses) {\r\n this._engine.currentRenderPassId = this._renderPassIds[0];\r\n }\r\n\r\n // Clears\r\n this._engine.bindFramebuffer(this._depthMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[0], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._depthMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[1], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[1].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[0].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[1].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[1].renderTarget!);\r\n\r\n // Draw depth for first pass\r\n this._engine.bindFramebuffer(this._depthMrts[0].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_ONEONE_ONEONE); // in WebGPU, when using MIN or MAX equation, the src / dst color factors should not use SRC_ALPHA and the src / dst alpha factors must be 1 else WebGPU will throw a validation error\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_MAX);\r\n this._engine.depthCullingState.depthMask = false;\r\n this._engine.depthCullingState.depthTest = true;\r\n this._engine.applyStates();\r\n\r\n this._currentPingPongState = 1;\r\n // Render\r\n this._renderSubMeshes(this._candidateSubMeshes);\r\n this._engine.unBindFramebuffer(this._depthMrts[0].renderTarget!);\r\n\r\n this._scene.resetCachedMaterial();\r\n\r\n // depth peeling ping-pong\r\n let readId = 0;\r\n let writeId = 0;\r\n\r\n for (let i = 0; i < this._passCount; i++) {\r\n readId = i % 2;\r\n writeId = 1 - readId;\r\n this._currentPingPongState = readId;\r\n\r\n if (this._useRenderPasses) {\r\n this._engine.currentRenderPassId = this._renderPassIds[i + 1];\r\n }\r\n\r\n if (this._scene.activeCamera) {\r\n this._engine.setViewport(this._scene.activeCamera.viewport);\r\n }\r\n\r\n // Clears\r\n this._engine.bindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.clear(this._colorCache[0], true, false, false);\r\n this._engine.unBindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._colorMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[1]);\r\n this._engine.clear(this._colorCache[2], true, false, false);\r\n this._engine.unBindFramebuffer(this._colorMrts[writeId].renderTarget!);\r\n\r\n this._engine.bindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[2]);\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_ONEONE_ONEONE); // the value does not matter (as MAX operation does not use them) but the src and dst color factors should not use SRC_ALPHA else WebGPU will throw a validation error\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_MAX);\r\n this._engine.depthCullingState.depthTest = false;\r\n this._engine.applyStates();\r\n\r\n // Render\r\n this._renderSubMeshes(this._candidateSubMeshes);\r\n this._engine.unBindFramebuffer(this._depthMrts[writeId].renderTarget!);\r\n\r\n this._scene.resetCachedMaterial();\r\n\r\n // Back color\r\n this._engine.bindFramebuffer(this._blendBackMrt.renderTarget!);\r\n this._engine.bindAttachments(this._layoutCache[0]);\r\n this._engine.setAlphaEquation(Constants.ALPHA_EQUATION_ADD);\r\n this._engine.setAlphaMode(Constants.ALPHA_LAYER_ACCUMULATE);\r\n this._engine.applyStates();\r\n\r\n const blendBackEffectWrapper = writeId === 0 || !this._useRenderPasses ? this._blendBackEffectWrapper : this._blendBackEffectWrapperPingPong;\r\n this._engine.enableEffect(blendBackEffectWrapper._drawWrapper);\r\n blendBackEffectWrapper.effect.setTexture(\"uBackColor\", this._thinTextures[writeId * 3 + 2]);\r\n this._effectRenderer.render(blendBackEffectWrapper);\r\n this._engine.unBindFramebuffer(this._blendBackMrt.renderTarget!);\r\n }\r\n\r\n this._engine.currentRenderPassId = currentRenderPassId;\r\n\r\n // Final composition on default FB\r\n this._finalCompose(writeId);\r\n\r\n (this._scene.prePassRenderer! as any)._enabled = true;\r\n this._engine.depthCullingState.depthMask = true;\r\n this._engine.depthCullingState.depthTest = true;\r\n\r\n return this._excludedSubMeshes;\r\n }\r\n\r\n /**\r\n * Disposes the depth peeling renderer and associated ressources\r\n */\r\n public dispose() {\r\n this._disposeTextures();\r\n this._blendBackEffectWrapper.dispose();\r\n this._finalEffectWrapper.dispose();\r\n this._effectRenderer.dispose();\r\n this._releaseRenderPassIds();\r\n }\r\n}\r\n"]}
@@ -298,7 +298,7 @@ export class FluidRenderer {
298
298
  if (!copyDepthTexture) {
299
299
  copyDepthTexture = copyDepthTextures[key] = new FluidRenderingDepthTextureCopy(this._engine, thicknessTexture.width, thicknessTexture.height);
300
300
  }
301
- copyDepthTexture.depthRTWrapper._shareDepth(thicknessRT);
301
+ copyDepthTexture.depthRTWrapper.shareDepth(thicknessRT);
302
302
  }
303
303
  }
304
304
  });