@babylonjs/core 5.49.0 → 5.49.2

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 (133) hide show
  1. package/Engines/Native/nativeInterfaces.d.ts +1 -0
  2. package/Engines/Native/nativeInterfaces.js.map +1 -1
  3. package/Engines/Native/nativePipelineContext.d.ts +6 -2
  4. package/Engines/Native/nativePipelineContext.js +12 -3
  5. package/Engines/Native/nativePipelineContext.js.map +1 -1
  6. package/Engines/WebGPU/webgpuTextureHelper.js +2 -2
  7. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  8. package/Engines/WebGPU/webgpuTintWASM.js +1 -1
  9. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  10. package/Engines/engine.d.ts +53 -0
  11. package/Engines/nativeEngine.d.ts +2 -5
  12. package/Engines/nativeEngine.js +44 -12
  13. package/Engines/nativeEngine.js.map +1 -1
  14. package/Engines/thinEngine.js +2 -2
  15. package/Engines/thinEngine.js.map +1 -1
  16. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  17. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  18. package/Materials/PBR/pbrMaterial.decalMap.d.ts +12 -0
  19. package/Materials/PBR/pbrMaterial.decalMap.js +18 -0
  20. package/Materials/PBR/pbrMaterial.decalMap.js.map +1 -0
  21. package/Materials/Textures/renderTargetTexture.js +2 -4
  22. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  23. package/Materials/index.d.ts +2 -0
  24. package/Materials/index.js +2 -0
  25. package/Materials/index.js.map +1 -1
  26. package/Materials/material.decalMap.d.ts +3 -0
  27. package/Materials/material.decalMap.js +4 -0
  28. package/Materials/material.decalMap.js.map +1 -0
  29. package/Materials/material.decalMapConfiguration.d.ts +63 -0
  30. package/Materials/material.decalMapConfiguration.js +119 -0
  31. package/Materials/material.decalMapConfiguration.js.map +1 -0
  32. package/Materials/materialFlags.d.ts +6 -0
  33. package/Materials/materialFlags.js +14 -0
  34. package/Materials/materialFlags.js.map +1 -1
  35. package/Materials/standardMaterial.decalMap.d.ts +12 -0
  36. package/Materials/standardMaterial.decalMap.js +18 -0
  37. package/Materials/standardMaterial.decalMap.js.map +1 -0
  38. package/Materials/standardMaterial.js +1 -0
  39. package/Materials/standardMaterial.js.map +1 -1
  40. package/Maths/math.vector.d.ts +10 -0
  41. package/Maths/math.vector.js +14 -0
  42. package/Maths/math.vector.js.map +1 -1
  43. package/Meshes/abstractMesh.decalMap.d.ts +12 -0
  44. package/Meshes/abstractMesh.decalMap.js +12 -0
  45. package/Meshes/abstractMesh.decalMap.js.map +1 -0
  46. package/Meshes/index.d.ts +2 -0
  47. package/Meshes/index.js +2 -0
  48. package/Meshes/index.js.map +1 -1
  49. package/Meshes/meshUVSpaceRenderer.d.ts +94 -0
  50. package/Meshes/meshUVSpaceRenderer.js +141 -0
  51. package/Meshes/meshUVSpaceRenderer.js.map +1 -0
  52. package/Particles/gpuParticleSystem.js +1 -1
  53. package/Particles/gpuParticleSystem.js.map +1 -1
  54. package/Physics/v2/physicsAggregate.d.ts +4 -0
  55. package/Physics/v2/physicsAggregate.js +4 -4
  56. package/Physics/v2/physicsAggregate.js.map +1 -1
  57. package/Physics/v2/physicsBody.d.ts +18 -2
  58. package/Physics/v2/physicsBody.js +66 -1
  59. package/Physics/v2/physicsBody.js.map +1 -1
  60. package/Rendering/fluidRenderer/fluidRenderer.js +2 -1
  61. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
  62. package/Rendering/renderingManager.js +4 -2
  63. package/Rendering/renderingManager.js.map +1 -1
  64. package/Shaders/ShadersInclude/decalFragment.d.ts +5 -0
  65. package/Shaders/ShadersInclude/decalFragment.js +15 -0
  66. package/Shaders/ShadersInclude/decalFragment.js.map +1 -0
  67. package/Shaders/ShadersInclude/decalFragmentDeclaration.d.ts +5 -0
  68. package/Shaders/ShadersInclude/decalFragmentDeclaration.js +11 -0
  69. package/Shaders/ShadersInclude/decalFragmentDeclaration.js.map +1 -0
  70. package/Shaders/ShadersInclude/decalVertexDeclaration.d.ts +5 -0
  71. package/Shaders/ShadersInclude/decalVertexDeclaration.js +11 -0
  72. package/Shaders/ShadersInclude/decalVertexDeclaration.js.map +1 -0
  73. package/Shaders/ShadersInclude/defaultFragmentDeclaration.d.ts +1 -0
  74. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js +2 -0
  75. package/Shaders/ShadersInclude/defaultFragmentDeclaration.js.map +1 -1
  76. package/Shaders/ShadersInclude/defaultVertexDeclaration.d.ts +1 -0
  77. package/Shaders/ShadersInclude/defaultVertexDeclaration.js +2 -0
  78. package/Shaders/ShadersInclude/defaultVertexDeclaration.js.map +1 -1
  79. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.d.ts +1 -0
  80. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +4 -0
  81. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
  82. package/Shaders/ShadersInclude/pbrFragmentDeclaration.d.ts +1 -0
  83. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +2 -0
  84. package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
  85. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
  86. package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
  87. package/Shaders/ShadersInclude/pbrVertexDeclaration.d.ts +1 -0
  88. package/Shaders/ShadersInclude/pbrVertexDeclaration.js +2 -0
  89. package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
  90. package/Shaders/default.fragment.d.ts +1 -0
  91. package/Shaders/default.fragment.js +5 -0
  92. package/Shaders/default.fragment.js.map +1 -1
  93. package/Shaders/default.vertex.js +2 -0
  94. package/Shaders/default.vertex.js.map +1 -1
  95. package/Shaders/geometry.fragment.js +1 -1
  96. package/Shaders/geometry.fragment.js.map +1 -1
  97. package/Shaders/meshUVSpaceRenderer.fragment.d.ts +5 -0
  98. package/Shaders/meshUVSpaceRenderer.fragment.js +9 -0
  99. package/Shaders/meshUVSpaceRenderer.fragment.js.map +1 -0
  100. package/Shaders/meshUVSpaceRenderer.vertex.d.ts +15 -0
  101. package/Shaders/meshUVSpaceRenderer.vertex.js +34 -0
  102. package/Shaders/meshUVSpaceRenderer.vertex.js.map +1 -0
  103. package/Shaders/pbr.fragment.js +4 -0
  104. package/Shaders/pbr.fragment.js.map +1 -1
  105. package/Shaders/pbr.vertex.js +2 -0
  106. package/Shaders/pbr.vertex.js.map +1 -1
  107. package/Shaders/screenSpaceReflection2.fragment.js +1 -1
  108. package/Shaders/screenSpaceReflection2.fragment.js.map +1 -1
  109. package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
  110. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  111. package/Sprites/spriteManager.js +5 -3
  112. package/Sprites/spriteManager.js.map +1 -1
  113. package/Sprites/spriteSceneComponent.d.ts +1 -1
  114. package/Sprites/spriteSceneComponent.js +7 -4
  115. package/Sprites/spriteSceneComponent.js.map +1 -1
  116. package/XR/features/WebXRDepthSensing.d.ts +118 -0
  117. package/XR/features/WebXRDepthSensing.js +268 -0
  118. package/XR/features/WebXRDepthSensing.js.map +1 -0
  119. package/XR/features/index.d.ts +1 -0
  120. package/XR/features/index.js +1 -0
  121. package/XR/features/index.js.map +1 -1
  122. package/XR/native/nativeXRFrame.d.ts +1 -0
  123. package/XR/native/nativeXRFrame.js +4 -0
  124. package/XR/native/nativeXRFrame.js.map +1 -1
  125. package/XR/webXRCamera.d.ts +1 -0
  126. package/XR/webXRCamera.js +4 -0
  127. package/XR/webXRCamera.js.map +1 -1
  128. package/XR/webXRFeaturesManager.d.ts +4 -0
  129. package/XR/webXRFeaturesManager.js +4 -0
  130. package/XR/webXRFeaturesManager.js.map +1 -1
  131. package/assetContainer.js +13 -5
  132. package/assetContainer.js.map +1 -1
  133. package/package.json +1 -1
@@ -22,6 +22,7 @@ export class PhysicsAggregate {
22
22
  * The type of the physics aggregate
23
23
  */
24
24
  type, _options = { mass: 0 }, _scene) {
25
+ var _a;
25
26
  this.transformNode = transformNode;
26
27
  this.type = type;
27
28
  this._options = _options;
@@ -47,6 +48,7 @@ export class PhysicsAggregate {
47
48
  this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;
48
49
  this.body = new PhysicsBody(transformNode, this._scene);
49
50
  this._addSizeOptions();
51
+ this._options.center = (_a = _options.center) !== null && _a !== void 0 ? _a : this.body.getObjectCenterDelta();
50
52
  this.shape = new PhysicsShape({ type, parameters: this._options }, this._scene);
51
53
  this.material = new PhysicsMaterial(this._options.friction, this._options.restitution, this._scene);
52
54
  this.body.setShape(this.shape);
@@ -81,13 +83,11 @@ export class PhysicsAggregate {
81
83
  this._options.pointB = this._options.pointB ? this._options.pointB : new Vector3(0, impostorExtents.y * 0.5, 0);
82
84
  }
83
85
  break;
86
+ case ShapeType.MESH:
87
+ case ShapeType.CONVEX_HULL:
84
88
  case ShapeType.BOX:
85
89
  this._options.extents = this._options.extents ? this._options.extents : new Vector3(impostorExtents.x, impostorExtents.y, impostorExtents.z);
86
90
  break;
87
- case ShapeType.MESH:
88
- case ShapeType.CONVEX_HULL: {
89
- break;
90
- }
91
91
  }
92
92
  }
93
93
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,SAAS,EAA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AAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;oBACjH,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;iBACnH;gBACD,MAAM;YACV,KAAK,SAAS,CAAC,GAAG;gBACd,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC;gBAC7I,MAAM;YACV,KAAK,SAAS,CAAC,IAAI,CAAC;YACpB,KAAK,SAAS,CAAC,WAAW,CAAC,CAAC;gBACxB,MAAM;aACT;SACJ;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n /**\r\n * The native options of the physics aggregate\r\n */\r\n nativeOptions?: any;\r\n /**\r\n * Specifies if the parent should be ignored\r\n */\r\n ignoreParent?: boolean;\r\n /**\r\n * Specifies if bi-directional transformations should be disabled\r\n */\r\n disableBidirectionalTransformation?: boolean;\r\n /**\r\n * The pressure inside the physics aggregate, soft object only\r\n */\r\n pressure?: number;\r\n /**\r\n * The stiffness the physics aggregate, soft object only\r\n */\r\n stiffness?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex velocities, soft object only\r\n */\r\n velocityIterations?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex positions, soft object only\r\n */\r\n positionIterations?: number;\r\n /**\r\n * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only\r\n * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right\r\n * Add to fix multiple points\r\n */\r\n fixedPoints?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n margin?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n damping?: number;\r\n /**\r\n * The path for a rope based on an extrusion\r\n */\r\n path?: any;\r\n /**\r\n * The shape of an extrusion used for a rope based on an extrusion\r\n */\r\n shape?: any;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: number,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n if (this.transformNode.parent && this._options.mass !== 0) {\r\n Logger.Warn(\"A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.\");\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n this.body = new PhysicsBody(transformNode, this._scene);\r\n this._addSizeOptions();\r\n this.shape = new PhysicsShape({ type, parameters: this._options as any }, this._scene);\r\n\r\n this.material = new PhysicsMaterial(this._options.friction, this._options.restitution, this._scene);\r\n this.body.setShape(this.shape);\r\n this.shape.setMaterial(this.material);\r\n this.body.setMassProperties({ centerOfMass: new Vector3(0, 0, 0), mass: this._options.mass, inertia: new Vector3(1, 1, 1), inertiaOrientation: Quaternion.Identity() });\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n const impostorExtents = this.body.getObjectExtents();\r\n\r\n switch (this.type) {\r\n case ShapeType.SPHERE:\r\n if (Scalar.WithinEpsilon(impostorExtents.x, impostorExtents.y, 0.0001) && Scalar.WithinEpsilon(impostorExtents.x, impostorExtents.z, 0.0001)) {\r\n this._options.radius = this._options.radius ? this._options.radius : impostorExtents.x / 2;\r\n } else {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes.\");\r\n }\r\n break;\r\n case ShapeType.CAPSULE:\r\n {\r\n const capRadius = impostorExtents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, -impostorExtents.y * 0.5 + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, impostorExtents.y * 0.5 - capRadius, 0);\r\n }\r\n break;\r\n case ShapeType.CYLINDER:\r\n {\r\n const capRadius = impostorExtents.x / 2;\r\n this._options.radius = this._options.radius ? this._options.radius : capRadius;\r\n this._options.pointA = this._options.pointA ? this._options.pointA : new Vector3(0, -impostorExtents.y * 0.5, 0);\r\n this._options.pointB = this._options.pointB ? this._options.pointB : new Vector3(0, impostorExtents.y * 0.5, 0);\r\n }\r\n break;\r\n case ShapeType.BOX:\r\n this._options.extents = this._options.extents ? this._options.extents : new Vector3(impostorExtents.x, impostorExtents.y, impostorExtents.z);\r\n break;\r\n case ShapeType.MESH:\r\n case ShapeType.CONVEX_HULL: {\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n this.body.dispose();\r\n this.material.dispose();\r\n this.shape.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsAggregate.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsAggregate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,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CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACJ","sourcesContent":["import { PhysicsBody } from \"./physicsBody\";\r\nimport { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport { PhysicsShape } from \"./physicsShape\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport { Quaternion, Vector3 } from \"../../Maths/math.vector\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport { ShapeType } from \"./IPhysicsEnginePlugin\";\r\n\r\n/**\r\n * The interface for the physics aggregate parameters\r\n */\r\nexport interface PhysicsAggregateParameters {\r\n /**\r\n * The mass of the physics aggregate\r\n */\r\n mass: number;\r\n /**\r\n * The friction of the physics aggregate\r\n */\r\n friction?: number;\r\n /**\r\n * The coefficient of restitution of the physics aggregate\r\n */\r\n restitution?: number;\r\n /**\r\n * The native options of the physics aggregate\r\n */\r\n nativeOptions?: any;\r\n /**\r\n * Specifies if the parent should be ignored\r\n */\r\n ignoreParent?: boolean;\r\n /**\r\n * Specifies if bi-directional transformations should be disabled\r\n */\r\n disableBidirectionalTransformation?: boolean;\r\n /**\r\n * The pressure inside the physics aggregate, soft object only\r\n */\r\n pressure?: number;\r\n /**\r\n * The stiffness the physics aggregate, soft object only\r\n */\r\n stiffness?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex velocities, soft object only\r\n */\r\n velocityIterations?: number;\r\n /**\r\n * The number of iterations used in maintaining consistent vertex positions, soft object only\r\n */\r\n positionIterations?: number;\r\n /**\r\n * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only\r\n * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right\r\n * Add to fix multiple points\r\n */\r\n fixedPoints?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n margin?: number;\r\n /**\r\n * The collision margin around a soft object\r\n */\r\n damping?: number;\r\n /**\r\n * The path for a rope based on an extrusion\r\n */\r\n path?: any;\r\n /**\r\n * The shape of an extrusion used for a rope based on an extrusion\r\n */\r\n shape?: any;\r\n\r\n /**\r\n * Radius for sphere, cylinder and capsule\r\n */\r\n radius?: number;\r\n\r\n /**\r\n * Starting point for cylinder/capsule\r\n */\r\n pointA?: Vector3;\r\n\r\n /**\r\n * Ending point for cylinder/capsule\r\n */\r\n pointB?: Vector3;\r\n\r\n /**\r\n * Extents for box\r\n */\r\n extents?: Vector3;\r\n\r\n /**\r\n * mesh local center\r\n */\r\n center?: Vector3;\r\n}\r\n/**\r\n * Helper class to create and interact with a PhysicsAggregate.\r\n * This is a transition object that works like Physics Plugin V1 Impostors.\r\n * This helper instanciate all mandatory physics objects to get a body/shape and material.\r\n * It's less efficient that handling body and shapes independently but for prototyping or\r\n * a small numbers of physics objects, it's good enough.\r\n */\r\nexport class PhysicsAggregate {\r\n /**\r\n * The body that is associated with this aggregate\r\n */\r\n public body: PhysicsBody;\r\n\r\n /**\r\n * The shape that is associated with this aggregate\r\n */\r\n public shape: PhysicsShape;\r\n\r\n /**\r\n * The material that is associated with this aggregate\r\n */\r\n public material: PhysicsMaterial;\r\n\r\n constructor(\r\n /**\r\n * The physics-enabled object used as the physics aggregate\r\n */\r\n public transformNode: TransformNode,\r\n /**\r\n * The type of the physics aggregate\r\n */\r\n public type: number,\r\n private _options: PhysicsAggregateParameters = { mass: 0 },\r\n private _scene?: Scene\r\n ) {\r\n //sanity check!\r\n if (!this.transformNode) {\r\n Logger.Error(\"No object was provided. A physics object is obligatory\");\r\n return;\r\n }\r\n if (this.transformNode.parent && this._options.mass !== 0) {\r\n Logger.Warn(\"A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur.\");\r\n }\r\n\r\n // Legacy support for old syntax.\r\n if (!this._scene && transformNode.getScene) {\r\n this._scene = transformNode.getScene();\r\n }\r\n\r\n if (!this._scene) {\r\n return;\r\n }\r\n\r\n //default options params\r\n this._options.mass = _options.mass === void 0 ? 0 : _options.mass;\r\n this._options.friction = _options.friction === void 0 ? 0.2 : _options.friction;\r\n this._options.restitution = _options.restitution === void 0 ? 0.2 : _options.restitution;\r\n\r\n this.body = new PhysicsBody(transformNode, this._scene);\r\n this._addSizeOptions();\r\n this._options.center = _options.center ?? this.body.getObjectCenterDelta();\r\n this.shape = new PhysicsShape({ type, parameters: this._options as any }, this._scene);\r\n\r\n this.material = new PhysicsMaterial(this._options.friction, this._options.restitution, this._scene);\r\n this.body.setShape(this.shape);\r\n this.shape.setMaterial(this.material);\r\n this.body.setMassProperties({ centerOfMass: new Vector3(0, 0, 0), mass: this._options.mass, inertia: new Vector3(1, 1, 1), inertiaOrientation: Quaternion.Identity() });\r\n }\r\n\r\n private _addSizeOptions(): void {\r\n const impostorExtents = this.body.getObjectExtents();\r\n\r\n switch (this.type) {\r\n case ShapeType.SPHERE:\r\n if (Scalar.WithinEpsilon(impostorExtents.x, impostorExtents.y, 0.0001) && Scalar.WithinEpsilon(impostorExtents.x, impostorExtents.z, 0.0001)) {\r\n this._options.radius = this._options.radius ? this._options.radius : impostorExtents.x / 2;\r\n } else {\r\n Logger.Warn(\"Non uniform scaling is unsupported for sphere shapes.\");\r\n }\r\n break;\r\n case ShapeType.CAPSULE:\r\n {\r\n const capRadius = impostorExtents.x / 2;\r\n this._options.radius = this._options.radius ?? capRadius;\r\n this._options.pointA = this._options.pointA ?? new Vector3(0, -impostorExtents.y * 0.5 + capRadius, 0);\r\n this._options.pointB = this._options.pointB ?? new Vector3(0, impostorExtents.y * 0.5 - capRadius, 0);\r\n }\r\n break;\r\n case ShapeType.CYLINDER:\r\n {\r\n const capRadius = impostorExtents.x / 2;\r\n this._options.radius = this._options.radius ? this._options.radius : capRadius;\r\n this._options.pointA = this._options.pointA ? this._options.pointA : new Vector3(0, -impostorExtents.y * 0.5, 0);\r\n this._options.pointB = this._options.pointB ? this._options.pointB : new Vector3(0, impostorExtents.y * 0.5, 0);\r\n }\r\n break;\r\n case ShapeType.MESH:\r\n case ShapeType.CONVEX_HULL:\r\n case ShapeType.BOX:\r\n this._options.extents = this._options.extents ? this._options.extents : new Vector3(impostorExtents.x, impostorExtents.y, impostorExtents.z);\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Releases the body, shape and material\r\n */\r\n public dispose(): void {\r\n this.body.dispose();\r\n this.material.dispose();\r\n this.shape.dispose();\r\n }\r\n}\r\n"]}
@@ -1,10 +1,11 @@
1
1
  import type { MassProperties } from "./IPhysicsEnginePlugin";
2
2
  import type { PhysicsShape } from "./physicsShape";
3
- import { Vector3 } from "../../Maths/math.vector";
3
+ import { Vector3, Quaternion } from "../../Maths/math.vector";
4
4
  import type { Scene } from "../../scene";
5
- import type { TransformNode } from "../../Meshes";
5
+ import type { TransformNode, AbstractMesh } from "../../Meshes";
6
6
  import type { Nullable } from "../../types.js";
7
7
  import type { PhysicsConstraint } from "./physicsConstraint";
8
+ import type { Bone } from "../../Bones/bone.js";
8
9
  /**
9
10
  * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows
10
11
  * the user to set the mass and velocity of the body, which can then be used to calculate the
@@ -253,6 +254,11 @@ export declare class PhysicsBody {
253
254
  * @returns the object extents
254
255
  */
255
256
  getObjectExtents(): Vector3;
257
+ /**
258
+ * returns the delta between the object bounding box center and the mesh origin
259
+ * @returns delta between object bounding box center and origin
260
+ */
261
+ getObjectCenterDelta(): Vector3;
256
262
  /**
257
263
  * @returns geometric center of the associated mesh
258
264
  */
@@ -265,6 +271,16 @@ export declare class PhysicsBody {
265
271
  *
266
272
  */
267
273
  addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void;
274
+ /**
275
+ * Sync with a bone
276
+ * @param bone The bone that the impostor will be synced to.
277
+ * @param boneMesh The mesh that the bone is influencing.
278
+ * @param jointPivot The pivot of the joint / bone in local space.
279
+ * @param distToJoint Optional distance from the impostor to the joint.
280
+ * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
281
+ * @param boneAxis Optional vector3 axis the bone is aligned with
282
+ */
283
+ syncWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
268
284
  /**
269
285
  * Disposes the body from the physics engine.
270
286
  *
@@ -1,4 +1,5 @@
1
- import { Vector3, Quaternion } from "../../Maths/math.vector.js";
1
+ import { Vector3, Quaternion, TmpVectors } from "../../Maths/math.vector.js";
2
+ import { Space } from "../../Maths/math.axis.js";
2
3
  /**
3
4
  * PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows
4
5
  * the user to set the mass and velocity of the body, which can then be used to calculate the
@@ -325,6 +326,7 @@ export class PhysicsBody {
325
326
  if (worldMatrix) {
326
327
  worldMatrix.decompose(scaling, undefined, undefined);
327
328
  }
329
+ tmAbstractMesh.refreshBoundingInfo();
328
330
  const boundingInfo = tmAbstractMesh.getBoundingInfo();
329
331
  // get the global scaling of the object
330
332
  const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);
@@ -341,6 +343,28 @@ export class PhysicsBody {
341
343
  return PhysicsBody._DEFAULT_OBJECT_SIZE;
342
344
  }
343
345
  }
346
+ /**
347
+ * returns the delta between the object bounding box center and the mesh origin
348
+ * @returns delta between object bounding box center and origin
349
+ */
350
+ getObjectCenterDelta() {
351
+ const tmAbstractMesh = this.transformNode;
352
+ if (tmAbstractMesh.getBoundingInfo) {
353
+ const delta = new Vector3();
354
+ const boundingInfo = tmAbstractMesh.getBoundingInfo();
355
+ this.transformNode.computeWorldMatrix(true);
356
+ tmAbstractMesh.refreshBoundingInfo();
357
+ delta.copyFrom(boundingInfo.boundingBox.centerWorld);
358
+ delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());
359
+ delta.x /= tmAbstractMesh.scaling.x;
360
+ delta.y /= tmAbstractMesh.scaling.y;
361
+ delta.z /= tmAbstractMesh.scaling.z;
362
+ return delta;
363
+ }
364
+ else {
365
+ return Vector3.Zero();
366
+ }
367
+ }
344
368
  /**
345
369
  * @returns geometric center of the associated mesh
346
370
  */
@@ -358,6 +382,47 @@ export class PhysicsBody {
358
382
  addConstraint(childBody, constraint) {
359
383
  this._physicsPlugin.addConstraint(this, childBody, constraint);
360
384
  }
385
+ /**
386
+ * Sync with a bone
387
+ * @param bone The bone that the impostor will be synced to.
388
+ * @param boneMesh The mesh that the bone is influencing.
389
+ * @param jointPivot The pivot of the joint / bone in local space.
390
+ * @param distToJoint Optional distance from the impostor to the joint.
391
+ * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
392
+ * @param boneAxis Optional vector3 axis the bone is aligned with
393
+ */
394
+ syncWithBone(bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
395
+ const mesh = this.transformNode;
396
+ if (mesh.rotationQuaternion) {
397
+ if (adjustRotation) {
398
+ const tempQuat = TmpVectors.Quaternion[0];
399
+ bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, tempQuat);
400
+ tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
401
+ }
402
+ else {
403
+ bone.getRotationQuaternionToRef(Space.WORLD, boneMesh, mesh.rotationQuaternion);
404
+ }
405
+ }
406
+ const pos = TmpVectors.Vector3[0];
407
+ const boneDir = TmpVectors.Vector3[1];
408
+ if (!boneAxis) {
409
+ boneAxis = TmpVectors.Vector3[2];
410
+ boneAxis.x = 0;
411
+ boneAxis.y = 1;
412
+ boneAxis.z = 0;
413
+ }
414
+ bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
415
+ bone.getAbsolutePositionToRef(boneMesh, pos);
416
+ if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
417
+ distToJoint = jointPivot.length();
418
+ }
419
+ if (distToJoint !== undefined && distToJoint !== null) {
420
+ pos.x += boneDir.x * distToJoint;
421
+ pos.y += boneDir.y * distToJoint;
422
+ pos.z += boneDir.z * distToJoint;
423
+ }
424
+ mesh.setAbsolutePosition(pos);
425
+ }
361
426
  /**
362
427
  * Disposes the body from the physics engine.
363
428
  *
@@ -1 +1 @@
1
- {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAM9D;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;;;;;;OAQG;IACH,YAAY,aAA4B,EAAE,KAAY;QAtCtD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAa7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAe3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,cAAc,GAAG,aAAuC,CAAC;QAC9D,IAAI,CAAC,aAAa,CAAC,kBAAkB,EAAE;YACnC,aAAa,CAAC,kBAAkB,GAAG,UAAU,CAAC,eAAe,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC/I;QACD,aAAa;QACb,MAAM,CAAC,GAAG,aAA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,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,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,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;;AA5Xc,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } from \"./IPhysicsEnginePlugin\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { PhysicsEngine } from \"./physicsEngine\";\r\nimport type { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\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 * 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 private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\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.\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, 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 // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\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 * 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 setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\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 getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\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 *\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): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\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(): number {\r\n return this._physicsPlugin.getEventMask(this);\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 *\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: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\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(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\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 *\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): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\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(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\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 *\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): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\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(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\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 *\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): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\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 *\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 public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\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 *\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): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\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 *\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): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\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 *\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): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\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 *\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): void {\r\n this._physicsPlugin.applyForce(this, force, location);\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 * Register a collision callback that is called when the body collides\r\n * Filtering by body is inefficient. It's more preferable to register a collision callback for the entire world\r\n * and do the filtering on the user side.\r\n */\r\n public registerOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.registerOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Unregister a collision callback that is called when the body collides\r\n */\r\n public unregisterOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.unregisterOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * `registerOnCollide` method will enable collision callback and `unregisterOnCollide` will disable them.\r\n * Registering a collision callback on the plugin and enabling collision per body is faster than\r\n * registering callback per PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and call the callback\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n // TODO\r\n return new Vector3(0, 0, 0);\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 *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\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 this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsBody.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Physics/v2/physicsBody.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO1E,OAAO,EAAE,KAAK,EAAE,iCAA6B;AAC7C;;;;GAIG;AACH,MAAM,OAAO,WAAW;IA8BpB;;;;;;;;OAQG;IACH,YAAY,aAA4B,EAAE,KAAY;QAtCtD;;WAEG;QACI,gBAAW,GAAQ,SAAS,CAAC;QACpC;;WAEG;QACI,yBAAoB,GAAe,EAAE,CAAC;QAa7C;;;WAGG;QACH,mBAAc,GAAY,IAAI,CAAC;QAe3B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO;SACV;QACD,MAAM,aAAa,GAAG,KAAK,CAAC,gBAAgB,EAAmB,CAAC;QAChE,IAAI,CAAC,aAAa,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACvE;QACD,MAAM,aAAa,GAAG,aAAa,CAAC,gBAAgB,EAAE,CAAC;QACvD,IAAI,CAAC,aAAa,EAAE;YAChB,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AAK,IAAI,EAAE;YACnD,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;YACjC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;YACjC,GAAG,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC;SACpC;QAED,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,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,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;;AAncc,gCAAoB,GAAY,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACrD,gCAAoB,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["import type { IPhysicsEnginePluginV2, MassProperties } 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 { Mesh, TransformNode, AbstractMesh } from \"../../Meshes\";\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\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 * 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 private static _DEFAULT_OBJECT_SIZE: Vector3 = new Vector3(1, 1, 1);\r\n private static _IDENTITY_QUATERNION = Quaternion.Identity();\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.\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, 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 // instances?\r\n const m = transformNode as Mesh;\r\n if (m.hasThinInstances) {\r\n this._physicsPlugin.initBodyInstances(this, m);\r\n } else {\r\n // single instance\r\n this._physicsPlugin.initBody(this, transformNode.position, transformNode.rotationQuaternion);\r\n }\r\n this.transformNode = transformNode;\r\n transformNode.physicsBody = this;\r\n physicsEngine.addBody(this);\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 * 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 setShape(shape: PhysicsShape): void {\r\n this._physicsPlugin.setShape(this, shape);\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 getShape(): PhysicsShape | undefined {\r\n return this._physicsPlugin.getShape(this);\r\n }\r\n\r\n /**\r\n * Sets the filter group of the physics body.\r\n * @param group - The filter group of the physics body.\r\n *\r\n * This method is useful for setting the filter group of the physics body.\r\n * The filter group is used to determine which bodies should collide with each other.\r\n * This allows for more control over the physics engine and can be used to create more realistic simulations.\r\n */\r\n public setFilterGroup(group: number): void {\r\n this._physicsPlugin.setFilterGroup(this, group);\r\n }\r\n\r\n /**\r\n * Gets the filter group of the physics engine.\r\n *\r\n * @returns The filter group of the physics engine.\r\n *\r\n * This method is useful for getting the filter group of the physics engine,\r\n * which is used to determine which objects will interact with each other.\r\n * This is important for creating realistic physics simulations.\r\n */\r\n public getFilterGroup(): number {\r\n return this._physicsPlugin.getFilterGroup(this);\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 *\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): void {\r\n this._physicsPlugin.setEventMask(this, eventMask);\r\n }\r\n\r\n /**\r\n * Gets the event mask of the physics engine.\r\n *\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(): number {\r\n return this._physicsPlugin.getEventMask(this);\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 *\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: MassProperties): void {\r\n this._physicsPlugin.setMassProperties(this, massProps);\r\n }\r\n\r\n /**\r\n * Retrieves the mass properties of the object.\r\n *\r\n * @returns The mass properties of the object, or `undefined` if the physics\r\n * plugin does not support mass properties.\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(): MassProperties | undefined {\r\n return this._physicsPlugin.getMassProperties(this);\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 *\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): void {\r\n this._physicsPlugin.setLinearDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the linear damping of the physics body.\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(): number {\r\n return this._physicsPlugin.getLinearDamping(this);\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 *\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): void {\r\n this._physicsPlugin.setAngularDamping(this, damping);\r\n }\r\n\r\n /**\r\n * Gets the angular damping of the physics body.\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(): number {\r\n return this._physicsPlugin.getAngularDamping(this);\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 *\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): void {\r\n this._physicsPlugin.setLinearVelocity(this, linVel);\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 *\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 public getLinearVelocityToRef(linVel: Vector3): void {\r\n return this._physicsPlugin.getLinearVelocityToRef(this, linVel);\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 *\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): void {\r\n this._physicsPlugin.setAngularVelocity(this, angVel);\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 *\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): void {\r\n return this._physicsPlugin.getAngularVelocityToRef(this, angVel);\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 *\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): void {\r\n this._physicsPlugin.applyImpulse(this, impulse, location);\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 *\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): void {\r\n this._physicsPlugin.applyForce(this, force, location);\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 * Register a collision callback that is called when the body collides\r\n * Filtering by body is inefficient. It's more preferable to register a collision callback for the entire world\r\n * and do the filtering on the user side.\r\n */\r\n public registerOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.registerOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Unregister a collision callback that is called when the body collides\r\n */\r\n public unregisterOnCollide(func: (collider: PhysicsBody, collidedAgainst: PhysicsBody, point: Nullable<Vector3>) => void): void {\r\n return this._physicsPlugin.unregisterOnBodyCollide(this, func);\r\n }\r\n\r\n /**\r\n * Enable or disable collision callback for this PhysicsBody.\r\n * `registerOnCollide` method will enable collision callback and `unregisterOnCollide` will disable them.\r\n * Registering a collision callback on the plugin and enabling collision per body is faster than\r\n * registering callback per PhysicsBody.\r\n * @param enabled true if PhysicsBody's collision will rise a collision event and call the callback\r\n */\r\n public setCollisionCallbackEnabled(enabled: boolean): void {\r\n return this._physicsPlugin.setCollisionCallbackEnabled(this, enabled);\r\n }\r\n\r\n /**\r\n * Gets the object extents\r\n * @returns the object extents\r\n */\r\n public getObjectExtents(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const q = this.transformNode.rotationQuaternion;\r\n const scaling = this.transformNode.scaling.clone();\r\n //reset rotation\r\n this.transformNode.rotationQuaternion = PhysicsBody._IDENTITY_QUATERNION;\r\n //calculate the world matrix with no rotation\r\n const worldMatrix = this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n if (worldMatrix) {\r\n worldMatrix.decompose(scaling, undefined, undefined);\r\n }\r\n tmAbstractMesh.refreshBoundingInfo();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n // get the global scaling of the object\r\n const size = boundingInfo.boundingBox.extendSize.scale(2).multiplyInPlace(scaling);\r\n size.x = Math.abs(size.x);\r\n size.y = Math.abs(size.y);\r\n size.z = Math.abs(size.z);\r\n //bring back the rotation\r\n this.transformNode.rotationQuaternion = q;\r\n //calculate the world matrix with the new rotation\r\n this.transformNode.computeWorldMatrix && this.transformNode.computeWorldMatrix(true);\r\n return size;\r\n } else {\r\n return PhysicsBody._DEFAULT_OBJECT_SIZE;\r\n }\r\n }\r\n\r\n /**\r\n * returns the delta between the object bounding box center and the mesh origin\r\n * @returns delta between object bounding box center and origin\r\n */\r\n public getObjectCenterDelta(): Vector3 {\r\n const tmAbstractMesh = this.transformNode as AbstractMesh;\r\n if (tmAbstractMesh.getBoundingInfo) {\r\n const delta = new Vector3();\r\n const boundingInfo = tmAbstractMesh.getBoundingInfo();\r\n this.transformNode.computeWorldMatrix(true);\r\n tmAbstractMesh.refreshBoundingInfo();\r\n delta.copyFrom(boundingInfo.boundingBox.centerWorld);\r\n delta.subtractInPlace(tmAbstractMesh.getAbsolutePosition());\r\n delta.x /= tmAbstractMesh.scaling.x;\r\n delta.y /= tmAbstractMesh.scaling.y;\r\n delta.z /= tmAbstractMesh.scaling.z;\r\n return delta;\r\n } else {\r\n return Vector3.Zero();\r\n }\r\n }\r\n\r\n /**\r\n * @returns geometric center of the associated mesh\r\n */\r\n public getObjectCenter(): Vector3 {\r\n // TODO\r\n return new Vector3(0, 0, 0);\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 *\r\n */\r\n public addConstraint(childBody: PhysicsBody, constraint: PhysicsConstraint): void {\r\n this._physicsPlugin.addConstraint(this, childBody, constraint);\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 * 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 this._physicsEngine.removeBody(this);\r\n this._physicsPlugin.removeBody(this);\r\n this._physicsPlugin.disposeBody(this);\r\n this._pluginData = null;\r\n this._pluginDataInstances.length = 0;\r\n }\r\n}\r\n"]}
@@ -1,5 +1,6 @@
1
1
  import { Scene } from "../../scene.js";
2
2
  import { SceneComponentConstants } from "../../sceneComponent.js";
3
+
3
4
  import { FluidRenderingObjectParticleSystem } from "./fluidRenderingObjectParticleSystem.js";
4
5
  import { FluidRenderingTargetRenderer } from "./fluidRenderingTargetRenderer.js";
5
6
  import { FluidRenderingObjectCustomParticles } from "./fluidRenderingObjectCustomParticles.js";
@@ -277,7 +278,7 @@ export class FluidRenderer {
277
278
  firstPostProcess.onSizeChangedObservable.add(() => {
278
279
  var _a;
279
280
  if (!firstPostProcess.inputTexture.depthStencilTexture) {
280
- firstPostProcess.inputTexture.createDepthStencilTexture(0, true, this._engine.isStencilEnable, targetRenderers[0].samples);
281
+ firstPostProcess.inputTexture.createDepthStencilTexture(0, true, this._engine.isStencilEnable, targetRenderers[0].samples, this._engine.isStencilEnable ? 13 : 14);
281
282
  }
282
283
  for (const targetRenderer of targetRenderers) {
283
284
  const thicknessRT = (_a = targetRenderer._thicknessRenderTarget) === null || _a === void 0 ? void 0 : _a.renderTarget;
@@ -1 +1 @@
1
- {"version":3,"file":"fluidRenderer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/fluidRenderer/fluidRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,uBAAmB;AAOnC,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAK9D,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,kDAAkD,CAAC;AAC1D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,wDAAwD,CAAC;AAChE,OAAO,oDAAoD,CAAC;AAC5D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,mDAAmD,CAAC;AAC3D,OAAO,6CAA6C,CAAC;AAyBrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE;IACpD,GAAG,EAAE;QACD,OAAO,IAAI,CAAC,cAAc,CA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AC,MAAM,EAAE,EAAE,CAAC,EAAE;YAClD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACrC;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClC,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;gBACjC,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;aACpC;QACL,CAAC,CAAC,CAAC;QAEF,IAAI,CAAC,aAAoD,GAAG,EAAE,CAAC;QAC/D,IAAI,CAAC,eAAkD,GAAG,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import { Scene } from \"core/scene\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { IParticleSystem } from \"core/Particles/IParticleSystem\";\r\nimport type { ISceneComponent } from \"core/sceneComponent\";\r\nimport { SceneComponentConstants } from \"core/sceneComponent\";\r\nimport type { SmartArrayNoDuplicate } from \"core/Misc/smartArray\";\r\nimport type { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\n\r\nimport type { FluidRenderingObject } from \"./fluidRenderingObject\";\r\nimport { FluidRenderingObjectParticleSystem } from \"./fluidRenderingObjectParticleSystem\";\r\nimport { FluidRenderingTargetRenderer } from \"./fluidRenderingTargetRenderer\";\r\nimport { FluidRenderingObjectCustomParticles } from \"./fluidRenderingObjectCustomParticles\";\r\nimport { FluidRenderingDepthTextureCopy } from \"./fluidRenderingDepthTextureCopy\";\r\n\r\nimport \"../../Shaders/fluidRenderingParticleDepth.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleDepth.fragment\";\r\nimport \"../../Shaders/fluidRenderingParticleThickness.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleThickness.fragment\";\r\nimport \"../../Shaders/fluidRenderingParticleDiffuse.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleDiffuse.fragment\";\r\nimport \"../../Shaders/fluidRenderingBilateralBlur.fragment\";\r\nimport \"../../Shaders/fluidRenderingStandardBlur.fragment\";\r\nimport \"../../Shaders/fluidRenderingRender.fragment\";\r\n\r\ndeclare module \"core/abstractScene\" {\r\n export interface AbstractScene {\r\n /** @internal (Backing field) */\r\n _fluidRenderer: Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Gets or Sets the fluid renderer associated to the scene.\r\n */\r\n fluidRenderer: Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Enables the fluid renderer and associates it with the scene\r\n * @returns the FluidRenderer\r\n */\r\n enableFluidRenderer(): Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Disables the fluid renderer associated with the scene\r\n */\r\n disableFluidRenderer(): void;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"fluidRenderer\", {\r\n get: function (this: Scene) {\r\n return this._fluidRenderer;\r\n },\r\n set: function (this: Scene, value: Nullable<FluidRenderer>) {\r\n this._fluidRenderer = value;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.enableFluidRenderer = function (): Nullable<FluidRenderer> {\r\n if (this._fluidRenderer) {\r\n return this._fluidRenderer;\r\n }\r\n\r\n this._fluidRenderer = new FluidRenderer(this);\r\n\r\n return this._fluidRenderer;\r\n};\r\n\r\nScene.prototype.disableFluidRenderer = function (): void {\r\n this._fluidRenderer?.dispose();\r\n this._fluidRenderer = null;\r\n};\r\n\r\ntype CameraMapForFluidRendering = [Array<FluidRenderingTargetRenderer>, { [key: string]: FluidRenderingDepthTextureCopy }];\r\n\r\nfunction IsParticleSystemObject(obj: FluidRenderingObject): obj is FluidRenderingObjectParticleSystem {\r\n return !!(obj as FluidRenderingObjectParticleSystem).particleSystem;\r\n}\r\n\r\n/**\r\n * Defines the fluid renderer scene component responsible to render objects as fluids\r\n */\r\nexport class FluidRendererSceneComponent implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_FLUIDRENDERER;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._gatherActiveCameraRenderTargetsStage.registerStep(\r\n SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER,\r\n this,\r\n this._gatherActiveCameraRenderTargets\r\n );\r\n this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_FLUIDRENDERER, this, this._afterCameraDraw);\r\n }\r\n\r\n private _gatherActiveCameraRenderTargets(_renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>): void {\r\n this.scene.fluidRenderer?._prepareRendering();\r\n }\r\n\r\n private _afterCameraDraw(camera: Camera) {\r\n this.scene.fluidRenderer?._render(camera);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n if (this.scene._fluidRenderer) {\r\n // Release resources first\r\n this.scene.disableFluidRenderer();\r\n\r\n // Re-enable\r\n this.scene.enableFluidRenderer();\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources\r\n */\r\n public dispose(): void {\r\n this.scene.disableFluidRenderer();\r\n }\r\n}\r\n\r\n/**\r\n * An object rendered as a fluid.\r\n * It consists of the object itself as well as the render target renderer (which is used to generate the textures (render target) needed for fluid rendering)\r\n */\r\nexport interface IFluidRenderingRenderObject {\r\n /** object rendered as a fluid */\r\n object: FluidRenderingObject;\r\n /** target renderer used to render the fluid object */\r\n targetRenderer: FluidRenderingTargetRenderer;\r\n}\r\n\r\n/**\r\n * Class responsible for fluid rendering.\r\n * It is implementing the method described in https://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf\r\n */\r\nexport class FluidRenderer {\r\n /** @internal */\r\n public static _SceneComponentInitialization(scene: Scene) {\r\n let component = scene._getComponent(SceneComponentConstants.NAME_FLUIDRENDERER) as FluidRendererSceneComponent;\r\n if (!component) {\r\n component = new FluidRendererSceneComponent(scene);\r\n scene._addComponent(component);\r\n }\r\n }\r\n\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _onEngineResizeObserver: Nullable<Observer<Engine>>;\r\n private _cameras: Map<Camera, CameraMapForFluidRendering>;\r\n\r\n /** Retrieves all the render objects managed by the class */\r\n public readonly renderObjects: Array<IFluidRenderingRenderObject>;\r\n\r\n /** Retrieves all the render target renderers managed by the class */\r\n public readonly targetRenderers: FluidRenderingTargetRenderer[];\r\n\r\n /**\r\n * Initializes the class\r\n * @param scene Scene in which the objects are part of\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._onEngineResizeObserver = null;\r\n this.renderObjects = [];\r\n this.targetRenderers = [];\r\n this._cameras = new Map();\r\n\r\n FluidRenderer._SceneComponentInitialization(this._scene);\r\n\r\n this._onEngineResizeObserver = this._engine.onResizeObservable.add(() => {\r\n this._initialize();\r\n });\r\n }\r\n\r\n /**\r\n * Reinitializes the class\r\n * Can be used if you change the object priority (FluidRenderingObject.priority), to make sure the objects are rendered in the right order\r\n */\r\n public recreate(): void {\r\n this._sortRenderingObjects();\r\n this._initialize();\r\n }\r\n\r\n /**\r\n * Gets the render object corresponding to a particle system (null if the particle system is not rendered as a fluid)\r\n * @param ps The particle system\r\n * @returns the render object corresponding to this particle system if any, otherwise null\r\n */\r\n public getRenderObjectFromParticleSystem(ps: IParticleSystem): Nullable<IFluidRenderingRenderObject> {\r\n const index = this._getParticleSystemIndex(ps);\r\n return index !== -1 ? this.renderObjects[index] : null;\r\n }\r\n\r\n /**\r\n * Adds a particle system to the fluid renderer.\r\n * Note that you should not normally call this method directly, as you can simply use the renderAsFluid property of the ParticleSystem/GPUParticleSystem class\r\n * @param ps particle system\r\n * @param generateDiffuseTexture True if you want to generate a diffuse texture from the particle system and use it as part of the fluid rendering (default: false)\r\n * @param targetRenderer The target renderer used to display the particle system as a fluid. If not provided, the method will create a new one\r\n * @param camera The camera used by the target renderer (if the target renderer is created by the method)\r\n * @returns the render object corresponding to the particle system\r\n */\r\n public addParticleSystem(ps: IParticleSystem, generateDiffuseTexture?: boolean, targetRenderer?: FluidRenderingTargetRenderer, camera?: Camera): IFluidRenderingRenderObject {\r\n const object = new FluidRenderingObjectParticleSystem(this._scene, ps);\r\n\r\n object.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this));\r\n\r\n if (!targetRenderer) {\r\n targetRenderer = new FluidRenderingTargetRenderer(this._scene, camera);\r\n this.targetRenderers.push(targetRenderer);\r\n }\r\n\r\n if (!targetRenderer._onUseVelocityChanged.hasObservers()) {\r\n targetRenderer._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this));\r\n }\r\n\r\n if (generateDiffuseTexture !== undefined) {\r\n targetRenderer.generateDiffuseTexture = generateDiffuseTexture;\r\n }\r\n\r\n const renderObject = { object, targetRenderer };\r\n\r\n this.renderObjects.push(renderObject);\r\n\r\n this._sortRenderingObjects();\r\n\r\n this._setParticleSizeForRenderTargets();\r\n\r\n return renderObject;\r\n }\r\n\r\n /**\r\n * Adds a custom particle set to the fluid renderer.\r\n * @param buffers The list of buffers (should contain at least a \"position\" buffer!)\r\n * @param numParticles Number of particles in each buffer\r\n * @param generateDiffuseTexture True if you want to generate a diffuse texture from buffers and use it as part of the fluid rendering (default: false). For the texture to be generated correctly, you need a \"color\" buffer in the set!\r\n * @param targetRenderer The target renderer used to display the particle system as a fluid. If not provided, the method will create a new one\r\n * @param camera The camera used by the target renderer (if the target renderer is created by the method)\r\n * @returns the render object corresponding to the custom particle set\r\n */\r\n public addCustomParticles(\r\n buffers: { [key: string]: FloatArray },\r\n numParticles: number,\r\n generateDiffuseTexture?: boolean,\r\n targetRenderer?: FluidRenderingTargetRenderer,\r\n camera?: Camera\r\n ): IFluidRenderingRenderObject {\r\n const object = new FluidRenderingObjectCustomParticles(this._scene, buffers, numParticles);\r\n\r\n object.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this));\r\n\r\n if (!targetRenderer) {\r\n targetRenderer = new FluidRenderingTargetRenderer(this._scene, camera);\r\n this.targetRenderers.push(targetRenderer);\r\n }\r\n\r\n if (!targetRenderer._onUseVelocityChanged.hasObservers()) {\r\n targetRenderer._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this));\r\n }\r\n\r\n if (generateDiffuseTexture !== undefined) {\r\n targetRenderer.generateDiffuseTexture = generateDiffuseTexture;\r\n }\r\n\r\n const renderObject = { object, targetRenderer };\r\n\r\n this.renderObjects.push(renderObject);\r\n\r\n this._sortRenderingObjects();\r\n\r\n this._setParticleSizeForRenderTargets();\r\n\r\n return renderObject;\r\n }\r\n\r\n /**\r\n * Removes a render object from the fluid renderer\r\n * @param renderObject the render object to remove\r\n * @param removeUnusedTargetRenderer True to remove/dispose of the target renderer if it's not used anymore (default: true)\r\n * @returns True if the render object has been found and released, else false\r\n */\r\n public removeRenderObject(renderObject: IFluidRenderingRenderObject, removeUnusedTargetRenderer = true): boolean {\r\n const index = this.renderObjects.indexOf(renderObject);\r\n if (index === -1) {\r\n return false;\r\n }\r\n\r\n renderObject.object.dispose();\r\n\r\n this.renderObjects.splice(index, 1);\r\n\r\n if (removeUnusedTargetRenderer && this._removeUnusedTargetRenderers()) {\r\n this._initialize();\r\n } else {\r\n this._setParticleSizeForRenderTargets();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _sortRenderingObjects(): void {\r\n this.renderObjects.sort((a, b) => {\r\n return a.object.priority < b.object.priority ? -1 : a.object.priority > b.object.priority ? 1 : 0;\r\n });\r\n }\r\n\r\n private _removeUnusedTargetRenderers(): boolean {\r\n const indexes: { [id: number]: boolean } = {};\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const targetRenderer = this.renderObjects[i].targetRenderer;\r\n indexes[this.targetRenderers.indexOf(targetRenderer)] = true;\r\n }\r\n\r\n let removed = false;\r\n const newList: Array<FluidRenderingTargetRenderer> = [];\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n if (!indexes[i]) {\r\n this.targetRenderers[i].dispose();\r\n removed = true;\r\n } else {\r\n newList.push(this.targetRenderers[i]);\r\n }\r\n }\r\n\r\n if (removed) {\r\n this.targetRenderers.length = 0;\r\n this.targetRenderers.push(...newList);\r\n }\r\n\r\n return removed;\r\n }\r\n\r\n private _getParticleSystemIndex(ps: IParticleSystem): number {\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const obj = this.renderObjects[i].object;\r\n if (IsParticleSystemObject(obj) && obj.particleSystem === ps) {\r\n return i;\r\n }\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n private _initialize(): void {\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n this.targetRenderers[i].dispose();\r\n }\r\n\r\n const cameras: Map<Camera, CameraMapForFluidRendering> = new Map();\r\n\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n const targetRenderer = this.targetRenderers[i];\r\n\r\n targetRenderer._initialize();\r\n\r\n if (targetRenderer.camera && targetRenderer._renderPostProcess) {\r\n let list = cameras.get(targetRenderer.camera);\r\n if (!list) {\r\n list = [[], {}];\r\n cameras.set(targetRenderer.camera, list);\r\n }\r\n list[0].push(targetRenderer);\r\n targetRenderer.camera.attachPostProcess(targetRenderer._renderPostProcess, i);\r\n }\r\n }\r\n\r\n let iterator = cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = cameras.get(camera)!;\r\n\r\n const firstPostProcess = camera._getFirstPostProcess();\r\n if (!firstPostProcess) {\r\n continue;\r\n }\r\n\r\n const [targetRenderers, copyDepthTextures] = list;\r\n\r\n firstPostProcess.onSizeChangedObservable.add(() => {\r\n if (!firstPostProcess.inputTexture.depthStencilTexture) {\r\n firstPostProcess.inputTexture.createDepthStencilTexture(0, true, this._engine.isStencilEnable, targetRenderers[0].samples);\r\n }\r\n for (const targetRenderer of targetRenderers) {\r\n const thicknessRT = targetRenderer._thicknessRenderTarget?.renderTarget;\r\n const thicknessTexture = thicknessRT?.texture;\r\n if (thicknessRT && thicknessTexture) {\r\n const key = thicknessTexture.width + \"_\" + thicknessTexture.height;\r\n let copyDepthTexture = copyDepthTextures[key];\r\n if (!copyDepthTexture) {\r\n copyDepthTexture = copyDepthTextures[key] = new FluidRenderingDepthTextureCopy(this._engine, thicknessTexture.width, thicknessTexture.height);\r\n }\r\n copyDepthTexture.depthRTWrapper._shareDepth(thicknessRT);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Dispose the CopyDepthTexture instances that we don't need anymore\r\n iterator = this._cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = this._cameras.get(camera)!;\r\n\r\n const copyDepthTextures = list[1];\r\n\r\n const list2 = cameras.get(camera);\r\n if (!list2) {\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n } else {\r\n for (const key in copyDepthTextures) {\r\n if (!list2[1][key]) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._cameras.clear();\r\n this._cameras = cameras;\r\n\r\n this._setParticleSizeForRenderTargets();\r\n }\r\n\r\n private _setParticleSizeForRenderTargets(): void {\r\n const particleSizes = new Map<FluidRenderingTargetRenderer, number>();\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const renderingObject = this.renderObjects[i];\r\n let curSize = particleSizes.get(renderingObject.targetRenderer);\r\n if (curSize === undefined) {\r\n curSize = 0;\r\n }\r\n particleSizes.set(renderingObject.targetRenderer, Math.max(curSize, renderingObject.object.particleSize));\r\n }\r\n\r\n particleSizes.forEach((particleSize, targetRenderer) => {\r\n if (targetRenderer._depthRenderTarget) {\r\n targetRenderer._depthRenderTarget.particleSize = particleSize;\r\n }\r\n });\r\n }\r\n\r\n private _setUseVelocityForRenderObject(): void {\r\n for (const renderingObject of this.renderObjects) {\r\n renderingObject.object.useVelocity = renderingObject.targetRenderer.useVelocity;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _prepareRendering(): void {\r\n for (const renderer of this.targetRenderers) {\r\n if (renderer.needInitialization) {\r\n this._initialize();\r\n return;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _render(forCamera?: Camera): void {\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n if (!forCamera || this.targetRenderers[i].camera === forCamera) {\r\n this.targetRenderers[i]._clearTargets();\r\n }\r\n }\r\n\r\n const iterator = this._cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = this._cameras.get(camera)!;\r\n if (forCamera && camera !== forCamera) {\r\n continue;\r\n }\r\n\r\n const firstPostProcess = camera._getFirstPostProcess();\r\n if (!firstPostProcess) {\r\n continue;\r\n }\r\n\r\n const sourceCopyDepth = firstPostProcess.inputTexture?.depthStencilTexture;\r\n if (sourceCopyDepth) {\r\n const [targetRenderers, copyDepthTextures] = list;\r\n for (const targetRenderer of targetRenderers) {\r\n targetRenderer._bgDepthTexture = sourceCopyDepth;\r\n }\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].copy(sourceCopyDepth);\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const renderingObject = this.renderObjects[i];\r\n if (!forCamera || renderingObject.targetRenderer.camera === forCamera) {\r\n renderingObject.targetRenderer._render(renderingObject.object);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of all the ressources used by the class\r\n */\r\n public dispose(): void {\r\n this._engine.onResizeObservable.remove(this._onEngineResizeObserver);\r\n this._onEngineResizeObserver = null;\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n this.renderObjects[i].object.dispose();\r\n }\r\n\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n this.targetRenderers[i].dispose();\r\n }\r\n\r\n this._cameras.forEach((list) => {\r\n const copyDepthTextures = list[1];\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n });\r\n\r\n (this.renderObjects as Array<IFluidRenderingRenderObject>) = [];\r\n (this.targetRenderers as FluidRenderingTargetRenderer[]) = [];\r\n this._cameras.clear();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"fluidRenderer.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/fluidRenderer/fluidRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,uBAAmB;AAOnC,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAG9D,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAGnD,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAC5F,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,OAAO,kDAAkD,CAAC;AAC1D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,wDAAwD,CAAC;AAChE,OAAO,oDAAoD,CAAC;AAC5D,OAAO,sDAAsD,CAAC;AAC9D,OAAO,oDAAoD,CAAC;AAC5D,OAAO,mDAAmD,CAAC;AAC3D,OAAO,6CAA6C,CAAC;AAyBrD,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,eAAe,EAAE;IACpD,GAAG,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I,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC1C;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAClD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;SACrC;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAClC,KAAK,MAAM,GAAG,IAAI,iBAAiB,EAAE;gBACjC,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;aACpC;QACL,CAAC,CAAC,CAAC;QAEF,IAAI,CAAC,aAAoD,GAAG,EAAE,CAAC;QAC/D,IAAI,CAAC,eAAkD,GAAG,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACJ","sourcesContent":["import { Scene } from \"core/scene\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { IParticleSystem } from \"core/Particles/IParticleSystem\";\r\nimport type { ISceneComponent } from \"core/sceneComponent\";\r\nimport { SceneComponentConstants } from \"core/sceneComponent\";\r\nimport type { SmartArrayNoDuplicate } from \"core/Misc/smartArray\";\r\nimport type { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\nimport type { FluidRenderingObject } from \"./fluidRenderingObject\";\r\nimport { FluidRenderingObjectParticleSystem } from \"./fluidRenderingObjectParticleSystem\";\r\nimport { FluidRenderingTargetRenderer } from \"./fluidRenderingTargetRenderer\";\r\nimport { FluidRenderingObjectCustomParticles } from \"./fluidRenderingObjectCustomParticles\";\r\nimport { FluidRenderingDepthTextureCopy } from \"./fluidRenderingDepthTextureCopy\";\r\n\r\nimport \"../../Shaders/fluidRenderingParticleDepth.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleDepth.fragment\";\r\nimport \"../../Shaders/fluidRenderingParticleThickness.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleThickness.fragment\";\r\nimport \"../../Shaders/fluidRenderingParticleDiffuse.vertex\";\r\nimport \"../../Shaders/fluidRenderingParticleDiffuse.fragment\";\r\nimport \"../../Shaders/fluidRenderingBilateralBlur.fragment\";\r\nimport \"../../Shaders/fluidRenderingStandardBlur.fragment\";\r\nimport \"../../Shaders/fluidRenderingRender.fragment\";\r\n\r\ndeclare module \"core/abstractScene\" {\r\n export interface AbstractScene {\r\n /** @internal (Backing field) */\r\n _fluidRenderer: Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Gets or Sets the fluid renderer associated to the scene.\r\n */\r\n fluidRenderer: Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Enables the fluid renderer and associates it with the scene\r\n * @returns the FluidRenderer\r\n */\r\n enableFluidRenderer(): Nullable<FluidRenderer>;\r\n\r\n /**\r\n * Disables the fluid renderer associated with the scene\r\n */\r\n disableFluidRenderer(): void;\r\n }\r\n}\r\n\r\nObject.defineProperty(Scene.prototype, \"fluidRenderer\", {\r\n get: function (this: Scene) {\r\n return this._fluidRenderer;\r\n },\r\n set: function (this: Scene, value: Nullable<FluidRenderer>) {\r\n this._fluidRenderer = value;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nScene.prototype.enableFluidRenderer = function (): Nullable<FluidRenderer> {\r\n if (this._fluidRenderer) {\r\n return this._fluidRenderer;\r\n }\r\n\r\n this._fluidRenderer = new FluidRenderer(this);\r\n\r\n return this._fluidRenderer;\r\n};\r\n\r\nScene.prototype.disableFluidRenderer = function (): void {\r\n this._fluidRenderer?.dispose();\r\n this._fluidRenderer = null;\r\n};\r\n\r\ntype CameraMapForFluidRendering = [Array<FluidRenderingTargetRenderer>, { [key: string]: FluidRenderingDepthTextureCopy }];\r\n\r\nfunction IsParticleSystemObject(obj: FluidRenderingObject): obj is FluidRenderingObjectParticleSystem {\r\n return !!(obj as FluidRenderingObjectParticleSystem).particleSystem;\r\n}\r\n\r\n/**\r\n * Defines the fluid renderer scene component responsible to render objects as fluids\r\n */\r\nexport class FluidRendererSceneComponent implements ISceneComponent {\r\n /**\r\n * The component name helpful to identify the component in the list of scene components.\r\n */\r\n public readonly name = SceneComponentConstants.NAME_FLUIDRENDERER;\r\n\r\n /**\r\n * The scene the component belongs to.\r\n */\r\n public scene: Scene;\r\n\r\n /**\r\n * Creates a new instance of the component for the given scene\r\n * @param scene Defines the scene to register the component in\r\n */\r\n constructor(scene: Scene) {\r\n this.scene = scene;\r\n }\r\n\r\n /**\r\n * Registers the component in a given scene\r\n */\r\n public register(): void {\r\n this.scene._gatherActiveCameraRenderTargetsStage.registerStep(\r\n SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_FLUIDRENDERER,\r\n this,\r\n this._gatherActiveCameraRenderTargets\r\n );\r\n this.scene._afterCameraDrawStage.registerStep(SceneComponentConstants.STEP_AFTERCAMERADRAW_FLUIDRENDERER, this, this._afterCameraDraw);\r\n }\r\n\r\n private _gatherActiveCameraRenderTargets(_renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>): void {\r\n this.scene.fluidRenderer?._prepareRendering();\r\n }\r\n\r\n private _afterCameraDraw(camera: Camera) {\r\n this.scene.fluidRenderer?._render(camera);\r\n }\r\n\r\n /**\r\n * Rebuilds the elements related to this component in case of\r\n * context lost for instance.\r\n */\r\n public rebuild(): void {\r\n if (this.scene._fluidRenderer) {\r\n // Release resources first\r\n this.scene.disableFluidRenderer();\r\n\r\n // Re-enable\r\n this.scene.enableFluidRenderer();\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the component and the associated resources\r\n */\r\n public dispose(): void {\r\n this.scene.disableFluidRenderer();\r\n }\r\n}\r\n\r\n/**\r\n * An object rendered as a fluid.\r\n * It consists of the object itself as well as the render target renderer (which is used to generate the textures (render target) needed for fluid rendering)\r\n */\r\nexport interface IFluidRenderingRenderObject {\r\n /** object rendered as a fluid */\r\n object: FluidRenderingObject;\r\n /** target renderer used to render the fluid object */\r\n targetRenderer: FluidRenderingTargetRenderer;\r\n}\r\n\r\n/**\r\n * Class responsible for fluid rendering.\r\n * It is implementing the method described in https://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf\r\n */\r\nexport class FluidRenderer {\r\n /** @internal */\r\n public static _SceneComponentInitialization(scene: Scene) {\r\n let component = scene._getComponent(SceneComponentConstants.NAME_FLUIDRENDERER) as FluidRendererSceneComponent;\r\n if (!component) {\r\n component = new FluidRendererSceneComponent(scene);\r\n scene._addComponent(component);\r\n }\r\n }\r\n\r\n private _scene: Scene;\r\n private _engine: Engine;\r\n private _onEngineResizeObserver: Nullable<Observer<Engine>>;\r\n private _cameras: Map<Camera, CameraMapForFluidRendering>;\r\n\r\n /** Retrieves all the render objects managed by the class */\r\n public readonly renderObjects: Array<IFluidRenderingRenderObject>;\r\n\r\n /** Retrieves all the render target renderers managed by the class */\r\n public readonly targetRenderers: FluidRenderingTargetRenderer[];\r\n\r\n /**\r\n * Initializes the class\r\n * @param scene Scene in which the objects are part of\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._onEngineResizeObserver = null;\r\n this.renderObjects = [];\r\n this.targetRenderers = [];\r\n this._cameras = new Map();\r\n\r\n FluidRenderer._SceneComponentInitialization(this._scene);\r\n\r\n this._onEngineResizeObserver = this._engine.onResizeObservable.add(() => {\r\n this._initialize();\r\n });\r\n }\r\n\r\n /**\r\n * Reinitializes the class\r\n * Can be used if you change the object priority (FluidRenderingObject.priority), to make sure the objects are rendered in the right order\r\n */\r\n public recreate(): void {\r\n this._sortRenderingObjects();\r\n this._initialize();\r\n }\r\n\r\n /**\r\n * Gets the render object corresponding to a particle system (null if the particle system is not rendered as a fluid)\r\n * @param ps The particle system\r\n * @returns the render object corresponding to this particle system if any, otherwise null\r\n */\r\n public getRenderObjectFromParticleSystem(ps: IParticleSystem): Nullable<IFluidRenderingRenderObject> {\r\n const index = this._getParticleSystemIndex(ps);\r\n return index !== -1 ? this.renderObjects[index] : null;\r\n }\r\n\r\n /**\r\n * Adds a particle system to the fluid renderer.\r\n * Note that you should not normally call this method directly, as you can simply use the renderAsFluid property of the ParticleSystem/GPUParticleSystem class\r\n * @param ps particle system\r\n * @param generateDiffuseTexture True if you want to generate a diffuse texture from the particle system and use it as part of the fluid rendering (default: false)\r\n * @param targetRenderer The target renderer used to display the particle system as a fluid. If not provided, the method will create a new one\r\n * @param camera The camera used by the target renderer (if the target renderer is created by the method)\r\n * @returns the render object corresponding to the particle system\r\n */\r\n public addParticleSystem(ps: IParticleSystem, generateDiffuseTexture?: boolean, targetRenderer?: FluidRenderingTargetRenderer, camera?: Camera): IFluidRenderingRenderObject {\r\n const object = new FluidRenderingObjectParticleSystem(this._scene, ps);\r\n\r\n object.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this));\r\n\r\n if (!targetRenderer) {\r\n targetRenderer = new FluidRenderingTargetRenderer(this._scene, camera);\r\n this.targetRenderers.push(targetRenderer);\r\n }\r\n\r\n if (!targetRenderer._onUseVelocityChanged.hasObservers()) {\r\n targetRenderer._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this));\r\n }\r\n\r\n if (generateDiffuseTexture !== undefined) {\r\n targetRenderer.generateDiffuseTexture = generateDiffuseTexture;\r\n }\r\n\r\n const renderObject = { object, targetRenderer };\r\n\r\n this.renderObjects.push(renderObject);\r\n\r\n this._sortRenderingObjects();\r\n\r\n this._setParticleSizeForRenderTargets();\r\n\r\n return renderObject;\r\n }\r\n\r\n /**\r\n * Adds a custom particle set to the fluid renderer.\r\n * @param buffers The list of buffers (should contain at least a \"position\" buffer!)\r\n * @param numParticles Number of particles in each buffer\r\n * @param generateDiffuseTexture True if you want to generate a diffuse texture from buffers and use it as part of the fluid rendering (default: false). For the texture to be generated correctly, you need a \"color\" buffer in the set!\r\n * @param targetRenderer The target renderer used to display the particle system as a fluid. If not provided, the method will create a new one\r\n * @param camera The camera used by the target renderer (if the target renderer is created by the method)\r\n * @returns the render object corresponding to the custom particle set\r\n */\r\n public addCustomParticles(\r\n buffers: { [key: string]: FloatArray },\r\n numParticles: number,\r\n generateDiffuseTexture?: boolean,\r\n targetRenderer?: FluidRenderingTargetRenderer,\r\n camera?: Camera\r\n ): IFluidRenderingRenderObject {\r\n const object = new FluidRenderingObjectCustomParticles(this._scene, buffers, numParticles);\r\n\r\n object.onParticleSizeChanged.add(this._setParticleSizeForRenderTargets.bind(this));\r\n\r\n if (!targetRenderer) {\r\n targetRenderer = new FluidRenderingTargetRenderer(this._scene, camera);\r\n this.targetRenderers.push(targetRenderer);\r\n }\r\n\r\n if (!targetRenderer._onUseVelocityChanged.hasObservers()) {\r\n targetRenderer._onUseVelocityChanged.add(this._setUseVelocityForRenderObject.bind(this));\r\n }\r\n\r\n if (generateDiffuseTexture !== undefined) {\r\n targetRenderer.generateDiffuseTexture = generateDiffuseTexture;\r\n }\r\n\r\n const renderObject = { object, targetRenderer };\r\n\r\n this.renderObjects.push(renderObject);\r\n\r\n this._sortRenderingObjects();\r\n\r\n this._setParticleSizeForRenderTargets();\r\n\r\n return renderObject;\r\n }\r\n\r\n /**\r\n * Removes a render object from the fluid renderer\r\n * @param renderObject the render object to remove\r\n * @param removeUnusedTargetRenderer True to remove/dispose of the target renderer if it's not used anymore (default: true)\r\n * @returns True if the render object has been found and released, else false\r\n */\r\n public removeRenderObject(renderObject: IFluidRenderingRenderObject, removeUnusedTargetRenderer = true): boolean {\r\n const index = this.renderObjects.indexOf(renderObject);\r\n if (index === -1) {\r\n return false;\r\n }\r\n\r\n renderObject.object.dispose();\r\n\r\n this.renderObjects.splice(index, 1);\r\n\r\n if (removeUnusedTargetRenderer && this._removeUnusedTargetRenderers()) {\r\n this._initialize();\r\n } else {\r\n this._setParticleSizeForRenderTargets();\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _sortRenderingObjects(): void {\r\n this.renderObjects.sort((a, b) => {\r\n return a.object.priority < b.object.priority ? -1 : a.object.priority > b.object.priority ? 1 : 0;\r\n });\r\n }\r\n\r\n private _removeUnusedTargetRenderers(): boolean {\r\n const indexes: { [id: number]: boolean } = {};\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const targetRenderer = this.renderObjects[i].targetRenderer;\r\n indexes[this.targetRenderers.indexOf(targetRenderer)] = true;\r\n }\r\n\r\n let removed = false;\r\n const newList: Array<FluidRenderingTargetRenderer> = [];\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n if (!indexes[i]) {\r\n this.targetRenderers[i].dispose();\r\n removed = true;\r\n } else {\r\n newList.push(this.targetRenderers[i]);\r\n }\r\n }\r\n\r\n if (removed) {\r\n this.targetRenderers.length = 0;\r\n this.targetRenderers.push(...newList);\r\n }\r\n\r\n return removed;\r\n }\r\n\r\n private _getParticleSystemIndex(ps: IParticleSystem): number {\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const obj = this.renderObjects[i].object;\r\n if (IsParticleSystemObject(obj) && obj.particleSystem === ps) {\r\n return i;\r\n }\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n private _initialize(): void {\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n this.targetRenderers[i].dispose();\r\n }\r\n\r\n const cameras: Map<Camera, CameraMapForFluidRendering> = new Map();\r\n\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n const targetRenderer = this.targetRenderers[i];\r\n\r\n targetRenderer._initialize();\r\n\r\n if (targetRenderer.camera && targetRenderer._renderPostProcess) {\r\n let list = cameras.get(targetRenderer.camera);\r\n if (!list) {\r\n list = [[], {}];\r\n cameras.set(targetRenderer.camera, list);\r\n }\r\n list[0].push(targetRenderer);\r\n targetRenderer.camera.attachPostProcess(targetRenderer._renderPostProcess, i);\r\n }\r\n }\r\n\r\n let iterator = cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = cameras.get(camera)!;\r\n\r\n const firstPostProcess = camera._getFirstPostProcess();\r\n if (!firstPostProcess) {\r\n continue;\r\n }\r\n\r\n const [targetRenderers, copyDepthTextures] = list;\r\n\r\n firstPostProcess.onSizeChangedObservable.add(() => {\r\n if (!firstPostProcess.inputTexture.depthStencilTexture) {\r\n firstPostProcess.inputTexture.createDepthStencilTexture(\r\n 0,\r\n true,\r\n this._engine.isStencilEnable,\r\n targetRenderers[0].samples,\r\n this._engine.isStencilEnable ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT\r\n );\r\n }\r\n for (const targetRenderer of targetRenderers) {\r\n const thicknessRT = targetRenderer._thicknessRenderTarget?.renderTarget;\r\n const thicknessTexture = thicknessRT?.texture;\r\n if (thicknessRT && thicknessTexture) {\r\n const key = thicknessTexture.width + \"_\" + thicknessTexture.height;\r\n let copyDepthTexture = copyDepthTextures[key];\r\n if (!copyDepthTexture) {\r\n copyDepthTexture = copyDepthTextures[key] = new FluidRenderingDepthTextureCopy(this._engine, thicknessTexture.width, thicknessTexture.height);\r\n }\r\n copyDepthTexture.depthRTWrapper._shareDepth(thicknessRT);\r\n }\r\n }\r\n });\r\n }\r\n\r\n // Dispose the CopyDepthTexture instances that we don't need anymore\r\n iterator = this._cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = this._cameras.get(camera)!;\r\n\r\n const copyDepthTextures = list[1];\r\n\r\n const list2 = cameras.get(camera);\r\n if (!list2) {\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n } else {\r\n for (const key in copyDepthTextures) {\r\n if (!list2[1][key]) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n this._cameras.clear();\r\n this._cameras = cameras;\r\n\r\n this._setParticleSizeForRenderTargets();\r\n }\r\n\r\n private _setParticleSizeForRenderTargets(): void {\r\n const particleSizes = new Map<FluidRenderingTargetRenderer, number>();\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const renderingObject = this.renderObjects[i];\r\n let curSize = particleSizes.get(renderingObject.targetRenderer);\r\n if (curSize === undefined) {\r\n curSize = 0;\r\n }\r\n particleSizes.set(renderingObject.targetRenderer, Math.max(curSize, renderingObject.object.particleSize));\r\n }\r\n\r\n particleSizes.forEach((particleSize, targetRenderer) => {\r\n if (targetRenderer._depthRenderTarget) {\r\n targetRenderer._depthRenderTarget.particleSize = particleSize;\r\n }\r\n });\r\n }\r\n\r\n private _setUseVelocityForRenderObject(): void {\r\n for (const renderingObject of this.renderObjects) {\r\n renderingObject.object.useVelocity = renderingObject.targetRenderer.useVelocity;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _prepareRendering(): void {\r\n for (const renderer of this.targetRenderers) {\r\n if (renderer.needInitialization) {\r\n this._initialize();\r\n return;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _render(forCamera?: Camera): void {\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n if (!forCamera || this.targetRenderers[i].camera === forCamera) {\r\n this.targetRenderers[i]._clearTargets();\r\n }\r\n }\r\n\r\n const iterator = this._cameras.keys();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const camera = key.value;\r\n const list = this._cameras.get(camera)!;\r\n if (forCamera && camera !== forCamera) {\r\n continue;\r\n }\r\n\r\n const firstPostProcess = camera._getFirstPostProcess();\r\n if (!firstPostProcess) {\r\n continue;\r\n }\r\n\r\n const sourceCopyDepth = firstPostProcess.inputTexture?.depthStencilTexture;\r\n if (sourceCopyDepth) {\r\n const [targetRenderers, copyDepthTextures] = list;\r\n for (const targetRenderer of targetRenderers) {\r\n targetRenderer._bgDepthTexture = sourceCopyDepth;\r\n }\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].copy(sourceCopyDepth);\r\n }\r\n }\r\n }\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n const renderingObject = this.renderObjects[i];\r\n if (!forCamera || renderingObject.targetRenderer.camera === forCamera) {\r\n renderingObject.targetRenderer._render(renderingObject.object);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Disposes of all the ressources used by the class\r\n */\r\n public dispose(): void {\r\n this._engine.onResizeObservable.remove(this._onEngineResizeObserver);\r\n this._onEngineResizeObserver = null;\r\n\r\n for (let i = 0; i < this.renderObjects.length; ++i) {\r\n this.renderObjects[i].object.dispose();\r\n }\r\n\r\n for (let i = 0; i < this.targetRenderers.length; ++i) {\r\n this.targetRenderers[i].dispose();\r\n }\r\n\r\n this._cameras.forEach((list) => {\r\n const copyDepthTextures = list[1];\r\n for (const key in copyDepthTextures) {\r\n copyDepthTextures[key].dispose();\r\n }\r\n });\r\n\r\n (this.renderObjects as Array<IFluidRenderingRenderObject>) = [];\r\n (this.targetRenderers as FluidRenderingTargetRenderer[]) = [];\r\n this._cameras.clear();\r\n }\r\n}\r\n"]}
@@ -33,8 +33,10 @@ export class RenderingManager {
33
33
  }
34
34
  }
35
35
  }
36
- for (const spriteManager of this._scene.spriteManagers) {
37
- spriteManager._wasDispatched = false;
36
+ if (this._scene.spriteManagers) {
37
+ for (const spriteManager of this._scene.spriteManagers) {
38
+ spriteManager._wasDispatched = false;
39
+ }
38
40
  }
39
41
  for (const particleSystem of this._scene.particleSystems) {
40
42
  particleSystem._wasDispatched = false;