@babylonjs/core 6.19.1 → 6.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/Actions/actionManager.js +2 -2
  2. package/Actions/actionManager.js.map +1 -1
  3. package/Animations/runtimeAnimation.js +2 -2
  4. package/Animations/runtimeAnimation.js.map +1 -1
  5. package/Cameras/Inputs/flyCameraMouseInput.js +2 -7
  6. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  7. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js +2 -7
  8. package/Cameras/Inputs/freeCameraKeyboardMoveInput.js.map +1 -1
  9. package/Cameras/Inputs/freeCameraMouseInput.js +4 -14
  10. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  11. package/Cameras/Inputs/freeCameraTouchInput.js +2 -1
  12. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  13. package/Cameras/arcRotateCamera.js +2 -7
  14. package/Cameras/arcRotateCamera.js.map +1 -1
  15. package/Cameras/camera.d.ts +2 -0
  16. package/Cameras/camera.js +8 -0
  17. package/Cameras/camera.js.map +1 -1
  18. package/Compute/computeShader.d.ts +15 -0
  19. package/Compute/computeShader.js +39 -0
  20. package/Compute/computeShader.js.map +1 -1
  21. package/Debug/physicsViewer.d.ts +33 -0
  22. package/Debug/physicsViewer.js +205 -0
  23. package/Debug/physicsViewer.js.map +1 -1
  24. package/Engines/Extensions/engine.computeShader.d.ts +2 -1
  25. package/Engines/Extensions/engine.computeShader.js +1 -0
  26. package/Engines/Extensions/engine.computeShader.js.map +1 -1
  27. package/Engines/WebGPU/webgpuComputeContext.js +15 -0
  28. package/Engines/WebGPU/webgpuComputeContext.js.map +1 -1
  29. package/Engines/thinEngine.js +2 -2
  30. package/Engines/thinEngine.js.map +1 -1
  31. package/FlowGraph/Blocks/Data/flowGraphAddBlock.d.ts +23 -0
  32. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js +18 -0
  33. package/FlowGraph/Blocks/Data/flowGraphAddBlock.js.map +1 -0
  34. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +30 -0
  35. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +22 -0
  36. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -0
  37. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +33 -0
  38. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +30 -0
  39. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -0
  40. package/FlowGraph/Blocks/Data/index.d.ts +3 -1
  41. package/FlowGraph/Blocks/Data/index.js +3 -1
  42. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  43. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +12 -10
  44. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +25 -29
  45. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  46. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +25 -0
  47. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +31 -0
  48. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -0
  49. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +3 -7
  50. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +11 -11
  51. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  52. package/FlowGraph/Blocks/Event/index.d.ts +1 -0
  53. package/FlowGraph/Blocks/Event/index.js +1 -0
  54. package/FlowGraph/Blocks/Event/index.js.map +1 -1
  55. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.d.ts +24 -0
  56. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js +23 -0
  57. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +1 -0
  58. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.d.ts +10 -13
  59. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js +28 -22
  60. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +1 -1
  61. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +5 -5
  62. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +8 -6
  63. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  64. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.d.ts +56 -0
  65. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js +66 -0
  66. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +1 -0
  67. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +18 -0
  68. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +19 -0
  69. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -0
  70. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +26 -0
  71. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +36 -0
  72. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -0
  73. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +23 -0
  74. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +25 -0
  75. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.d.ts +16 -0
  77. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js +18 -0
  78. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +1 -0
  79. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.d.ts +32 -0
  80. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js +62 -0
  81. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +1 -0
  82. package/FlowGraph/Blocks/Execution/index.d.ts +7 -0
  83. package/FlowGraph/Blocks/Execution/index.js +7 -0
  84. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  85. package/FlowGraph/flowGraph.d.ts +42 -12
  86. package/FlowGraph/flowGraph.js +37 -23
  87. package/FlowGraph/flowGraph.js.map +1 -1
  88. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +29 -0
  89. package/FlowGraph/flowGraphAsyncExecutionBlock.js +21 -0
  90. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -0
  91. package/FlowGraph/flowGraphBlock.d.ts +9 -11
  92. package/FlowGraph/flowGraphBlock.js +12 -8
  93. package/FlowGraph/flowGraphBlock.js.map +1 -1
  94. package/FlowGraph/flowGraphConnection.d.ts +17 -7
  95. package/FlowGraph/flowGraphConnection.js +26 -9
  96. package/FlowGraph/flowGraphConnection.js.map +1 -1
  97. package/FlowGraph/flowGraphContext.d.ts +102 -0
  98. package/FlowGraph/flowGraphContext.js +111 -0
  99. package/FlowGraph/flowGraphContext.js.map +1 -0
  100. package/FlowGraph/flowGraphCustomEvent.d.ts +5 -0
  101. package/FlowGraph/flowGraphCustomEvent.js +2 -0
  102. package/FlowGraph/flowGraphCustomEvent.js.map +1 -0
  103. package/FlowGraph/flowGraphDataConnection.d.ts +10 -2
  104. package/FlowGraph/flowGraphDataConnection.js +16 -8
  105. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  106. package/FlowGraph/flowGraphEventBlock.d.ts +5 -12
  107. package/FlowGraph/flowGraphEventBlock.js +5 -5
  108. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  109. package/FlowGraph/flowGraphEventCoordinator.d.ts +23 -0
  110. package/FlowGraph/flowGraphEventCoordinator.js +37 -0
  111. package/FlowGraph/flowGraphEventCoordinator.js.map +1 -0
  112. package/FlowGraph/flowGraphExecutionBlock.d.ts +5 -5
  113. package/FlowGraph/flowGraphExecutionBlock.js +3 -3
  114. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  115. package/FlowGraph/flowGraphRichTypes.d.ts +28 -0
  116. package/FlowGraph/flowGraphRichTypes.js +43 -0
  117. package/FlowGraph/flowGraphRichTypes.js.map +1 -0
  118. package/FlowGraph/flowGraphSignalConnection.d.ts +7 -1
  119. package/FlowGraph/flowGraphSignalConnection.js +11 -4
  120. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  121. package/FlowGraph/flowGraphVariableDefinitions.d.ts +12 -0
  122. package/FlowGraph/flowGraphVariableDefinitions.js +22 -0
  123. package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -0
  124. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +10 -2
  125. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +8 -2
  126. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
  127. package/FlowGraph/index.d.ts +3 -0
  128. package/FlowGraph/index.js +3 -0
  129. package/FlowGraph/index.js.map +1 -1
  130. package/Materials/Node/nodeMaterial.d.ts +2 -1
  131. package/Materials/Node/nodeMaterial.js +26 -2
  132. package/Materials/Node/nodeMaterial.js.map +1 -1
  133. package/Materials/PBR/pbrBaseMaterial.d.ts +1 -0
  134. package/Materials/PBR/pbrBaseMaterial.js +1 -0
  135. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  136. package/Materials/Textures/videoTexture.d.ts +5 -0
  137. package/Materials/Textures/videoTexture.js +6 -0
  138. package/Materials/Textures/videoTexture.js.map +1 -1
  139. package/Materials/materialHelper.js +1 -0
  140. package/Materials/materialHelper.js.map +1 -1
  141. package/Materials/standardMaterial.d.ts +1 -0
  142. package/Materials/standardMaterial.js +1 -0
  143. package/Materials/standardMaterial.js.map +1 -1
  144. package/Materials/uniformBuffer.d.ts +7 -0
  145. package/Materials/uniformBuffer.js +8 -0
  146. package/Materials/uniformBuffer.js.map +1 -1
  147. package/Maths/math.vector.d.ts +5 -0
  148. package/Maths/math.vector.js +7 -0
  149. package/Maths/math.vector.js.map +1 -1
  150. package/Meshes/Node/Blocks/Instances/instantiateBlock.d.ts +11 -5
  151. package/Meshes/Node/Blocks/Instances/instantiateBlock.js +20 -10
  152. package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
  153. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +15 -9
  154. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +20 -11
  155. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  156. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +15 -9
  157. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +20 -11
  158. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  159. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +15 -9
  160. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +20 -11
  161. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  162. package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +12 -0
  163. package/Meshes/Node/Blocks/Set/setColorsBlock.js +62 -27
  164. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  165. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +7 -0
  166. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +19 -0
  167. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
  168. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +12 -0
  169. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +62 -27
  170. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  171. package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +12 -0
  172. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +54 -19
  173. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  174. package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +12 -0
  175. package/Meshes/Node/Blocks/Set/setTangentsBlock.js +62 -27
  176. package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
  177. package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +5 -0
  178. package/Meshes/Node/Blocks/Set/setUVsBlock.js +65 -46
  179. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  180. package/Meshes/Node/Blocks/debugBlock.js +5 -1
  181. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  182. package/Meshes/Node/Blocks/geometryInputBlock.js +1 -0
  183. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  184. package/Meshes/Node/Blocks/intFloatConverterBlock.js +2 -2
  185. package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
  186. package/Meshes/Node/Blocks/mapRangeBlock.js +8 -1
  187. package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
  188. package/Meshes/Node/Blocks/mathBlock.js +1 -0
  189. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  190. package/Meshes/Node/Blocks/matrixComposeBlock.d.ts +30 -0
  191. package/Meshes/Node/Blocks/matrixComposeBlock.js +55 -0
  192. package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -0
  193. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +3 -1
  194. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +2 -0
  195. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  196. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.d.ts +10 -0
  197. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js +2 -0
  198. package/Meshes/Node/Interfaces/nodeGeometryInstancingContext.js.map +1 -0
  199. package/Meshes/Node/index.d.ts +1 -0
  200. package/Meshes/Node/index.js +1 -0
  201. package/Meshes/Node/index.js.map +1 -1
  202. package/Meshes/Node/nodeGeometry.js +2 -2
  203. package/Meshes/Node/nodeGeometry.js.map +1 -1
  204. package/Meshes/Node/nodeGeometryBuildState.d.ts +5 -0
  205. package/Meshes/Node/nodeGeometryBuildState.js +20 -0
  206. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  207. package/Meshes/abstractMesh.js +4 -1
  208. package/Meshes/abstractMesh.js.map +1 -1
  209. package/Meshes/geometry.js +10 -10
  210. package/Meshes/geometry.js.map +1 -1
  211. package/Meshes/mesh.js +7 -5
  212. package/Meshes/mesh.js.map +1 -1
  213. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js +2 -1
  214. package/Misc/PerformanceViewer/performanceViewerCollectionStrategies.js.map +1 -1
  215. package/Misc/dumpTools.js +3 -2
  216. package/Misc/dumpTools.js.map +1 -1
  217. package/Misc/equirectangularCapture.d.ts +39 -0
  218. package/Misc/equirectangularCapture.js +56 -0
  219. package/Misc/equirectangularCapture.js.map +1 -0
  220. package/Misc/index.d.ts +1 -0
  221. package/Misc/index.js +1 -0
  222. package/Misc/index.js.map +1 -1
  223. package/Physics/v2/IPhysicsEnginePlugin.d.ts +10 -0
  224. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  225. package/Physics/v2/Plugins/havokPlugin.d.ts +8 -1
  226. package/Physics/v2/Plugins/havokPlugin.js +34 -0
  227. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  228. package/Physics/v2/physicsConstraint.d.ts +11 -1
  229. package/Physics/v2/physicsConstraint.js +7 -0
  230. package/Physics/v2/physicsConstraint.js.map +1 -1
  231. package/Rendering/prePassRenderer.d.ts +6 -0
  232. package/Rendering/prePassRenderer.js +14 -0
  233. package/Rendering/prePassRenderer.js.map +1 -1
  234. package/Shaders/default.fragment.js +4 -0
  235. package/Shaders/default.fragment.js.map +1 -1
  236. package/Shaders/equirectangularPanorama.fragment.d.ts +5 -0
  237. package/Shaders/equirectangularPanorama.fragment.js +17 -0
  238. package/Shaders/equirectangularPanorama.fragment.js.map +1 -0
  239. package/Shaders/pbr.fragment.js +4 -0
  240. package/Shaders/pbr.fragment.js.map +1 -1
  241. package/package.json +1 -1
  242. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.d.ts +0 -34
  243. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js +0 -29
  244. package/FlowGraph/Blocks/Data/flowGraphBinaryOpBlocks.js.map +0 -1
@@ -52,8 +52,9 @@ export class PerfCollectionStrategy {
52
52
  const wrapper = new PressureObserverWrapper();
53
53
  wrapper.observe("cpu");
54
54
  wrapper.onPressureChanged.add((update) => {
55
+ var _a, _b;
55
56
  for (const record of update) {
56
- if ((factor && record.factors.includes(factor)) || (!factor && record.factors.length === 0)) {
57
+ if ((factor && record.factors.includes(factor)) || (!factor && ((_b = (_a = record.factors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) === 0)) {
57
58
  // Let s consider each step being 25% of the total pressure.
58
59
  switch (record.state) {
59
60
  case "nominal":
@@ -1 +1 @@
1
- {"version":3,"file":"performanceViewerCollectionStrategies.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/PerformanceViewer/performanceViewerCollectionStrategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAoBrE,8BAA8B;AAC9B,MAAM,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAMpC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;OAGG;IACI,MAAM,CAAC,WAAW;QACrB,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,GAA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AG,QAAQ,EAAE,CAAC,CAAC;gBACxF,OAAO,EAAE,GAAG,EAAE;oBACV,qBAAqB,CAAC,OAAO,EAAE,CAAC;gBACpC,CAAC;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { EngineInstrumentation } from \"../../Instrumentation/engineInstrumentation\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { PrecisionDate } from \"../precisionDate\";\r\nimport { SceneInstrumentation } from \"../../Instrumentation/sceneInstrumentation\";\r\nimport { PressureObserverWrapper } from \"../pressureObserverWrapper\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Defines the general structure of what is necessary for a collection strategy.\r\n */\r\nexport interface IPerfViewerCollectionStrategy {\r\n /**\r\n * The id of the strategy.\r\n */\r\n id: string;\r\n /**\r\n * Function which gets the data for the strategy.\r\n */\r\n getData: () => number;\r\n /**\r\n * Function which does any necessary cleanup. Called when performanceViewerCollector.dispose() is called.\r\n */\r\n dispose: () => void;\r\n}\r\n// Dispose which does nothing.\r\nconst defaultDisposeImpl = () => {};\r\n\r\n/**\r\n * Initializer callback for a strategy\r\n */\r\nexport type PerfStrategyInitialization = (scene: Scene) => IPerfViewerCollectionStrategy;\r\n/**\r\n * Defines the predefined strategies used in the performance viewer.\r\n */\r\nexport class PerfCollectionStrategy {\r\n /**\r\n * Gets the initializer for the strategy used for collection of fps metrics\r\n * @returns the initializer for the fps strategy\r\n */\r\n public static FpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engine = scene.getEngine();\r\n return {\r\n id: \"FPS\",\r\n getData: () => engine.getFps(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of thermal utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the thermal utilization strategy\r\n */\r\n public static ThermalStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Thermal utilization\", \"thermal\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of power supply utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the power supply utilization strategy\r\n */\r\n public static PowerSupplyStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Power supply utilization\", \"power-supply\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of pressure metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the pressure strategy\r\n */\r\n public static PressureStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Pressure\");\r\n }\r\n\r\n private static _PressureStrategy(name: string, factor: Nullable<PressureFactor> = null): PerfStrategyInitialization {\r\n return () => {\r\n let value = 0;\r\n\r\n const wrapper = new PressureObserverWrapper();\r\n wrapper.observe(\"cpu\");\r\n\r\n wrapper.onPressureChanged.add((update) => {\r\n for (const record of update) {\r\n if ((factor && record.factors.includes(factor)) || (!factor && record.factors.length === 0)) {\r\n // Let s consider each step being 25% of the total pressure.\r\n switch (record.state) {\r\n case \"nominal\":\r\n value = 0;\r\n break;\r\n case \"fair\":\r\n value = 0.25;\r\n break;\r\n case \"serious\":\r\n value = 0.5;\r\n break;\r\n case \"critical\":\r\n value = 1;\r\n break;\r\n }\r\n }\r\n }\r\n });\r\n return {\r\n id: name,\r\n getData: () => value,\r\n dispose: () => wrapper.dispose(),\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total meshes metrics.\r\n * @returns the initializer for the total meshes strategy\r\n */\r\n public static TotalMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total meshes\",\r\n getData: () => scene.meshes.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active meshes metrics.\r\n * @returns the initializer for the active meshes strategy\r\n */\r\n public static ActiveMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active meshes\",\r\n getData: () => scene.getActiveMeshes().length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active indices metrics.\r\n * @returns the initializer for the active indices strategy\r\n */\r\n public static ActiveIndicesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active indices\",\r\n getData: () => scene.getActiveIndices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active faces metrics.\r\n * @returns the initializer for the active faces strategy\r\n */\r\n public static ActiveFacesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active faces\",\r\n getData: () => scene.getActiveIndices() / 3,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active bones metrics.\r\n * @returns the initializer for the active bones strategy\r\n */\r\n public static ActiveBonesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active bones\",\r\n getData: () => scene.getActiveBones(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active particles metrics.\r\n * @returns the initializer for the active particles strategy\r\n */\r\n public static ActiveParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active particles\",\r\n getData: () => scene.getActiveParticles(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of draw calls metrics.\r\n * @returns the initializer for the draw calls strategy\r\n */\r\n public static DrawCallsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let drawCalls = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n scene.getEngine()._drawCalls.fetchNewFrame();\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n drawCalls = scene.getEngine()._drawCalls.current;\r\n });\r\n\r\n return {\r\n id: \"Draw calls\",\r\n getData: () => drawCalls,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total lights metrics.\r\n * @returns the initializer for the total lights strategy\r\n */\r\n public static TotalLightsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total lights\",\r\n getData: () => scene.lights.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total vertices metrics.\r\n * @returns the initializer for the total vertices strategy\r\n */\r\n public static TotalVerticesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total vertices\",\r\n getData: () => scene.getTotalVertices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total materials metrics.\r\n * @returns the initializer for the total materials strategy\r\n */\r\n public static TotalMaterialsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total materials\",\r\n getData: () => scene.materials.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total textures metrics.\r\n * @returns the initializer for the total textures strategy\r\n */\r\n public static TotalTexturesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total textures\",\r\n getData: () => scene.textures.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of absolute fps metrics.\r\n * @returns the initializer for the absolute fps strategy\r\n */\r\n public static AbsoluteFpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const sceneInstrumentation = new SceneInstrumentation(scene);\r\n sceneInstrumentation.captureFrameTime = true;\r\n\r\n return {\r\n id: \"Absolute FPS\",\r\n getData: () => {\r\n return 1000.0 / sceneInstrumentation.frameTimeCounter.lastSecAverage;\r\n },\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of meshes selection time metrics.\r\n * @returns the initializer for the meshes selection time strategy\r\n */\r\n public static MeshesSelectionStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeActiveMeshesObserver = scene.onBeforeActiveMeshesEvaluationObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterActiveMeshesObserver = scene.onAfterActiveMeshesEvaluationObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Meshes Selection\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeActiveMeshesEvaluationObservable.remove(onBeforeActiveMeshesObserver);\r\n scene.onAfterActiveMeshesEvaluationObservable.remove(onAfterActiveMeshesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render targets time metrics.\r\n * @returns the initializer for the render targets time strategy\r\n */\r\n public static RenderTargetsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeRenderTargetsObserver = scene.onBeforeRenderTargetsRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderTargetsObserver = scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render Targets\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeRenderTargetsRenderObservable.remove(onBeforeRenderTargetsObserver);\r\n scene.onAfterRenderTargetsRenderObservable.remove(onAfterRenderTargetsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of particles time metrics.\r\n * @returns the initializer for the particles time strategy\r\n */\r\n public static ParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeParticlesObserver = scene.onBeforeParticlesRenderingObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterParticlesObserver = scene.onAfterParticlesRenderingObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Particles\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeParticlesRenderingObservable.remove(onBeforeParticlesObserver);\r\n scene.onAfterParticlesRenderingObservable.remove(onAfterParticlesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of sprites time metrics.\r\n * @returns the initializer for the sprites time strategy\r\n */\r\n public static SpritesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeSpritesObserver = scene.onBeforeSpritesRenderingObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterSpritesObserver = scene.onAfterSpritesRenderingObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Sprites\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeSpritesRenderingObservable?.remove(onBeforeSpritesObserver);\r\n scene.onAfterSpritesRenderingObservable?.remove(onAfterSpritesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of animations time metrics.\r\n * @returns the initializer for the animations time strategy\r\n */\r\n public static AnimationsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterAnimationsObserver = scene.onAfterAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Animations\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterAnimationsObservable.remove(onAfterAnimationsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of physics time metrics.\r\n * @returns the initializer for the physics time strategy\r\n */\r\n public static PhysicsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforePhysicsObserver = scene.onBeforePhysicsObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterPhysicsObserver = scene.onAfterPhysicsObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Physics\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforePhysicsObservable?.remove(onBeforePhysicsObserver);\r\n scene.onAfterPhysicsObservable?.remove(onAfterPhysicsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render time metrics.\r\n * @returns the initializer for the render time strategy\r\n */\r\n public static RenderStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeDrawPhaseObserver = scene.onBeforeDrawPhaseObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterDrawPhaseObserver = scene.onAfterDrawPhaseObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeDrawPhaseObservable.remove(onBeforeDrawPhaseObserver);\r\n scene.onAfterDrawPhaseObservable.remove(onAfterDrawPhaseObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total frame time metrics.\r\n * @returns the initializer for the total frame time strategy\r\n */\r\n public static FrameTotalStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Frame Total\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of inter-frame time metrics.\r\n * @returns the initializer for the inter-frame time strategy\r\n */\r\n public static InterFrameStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n return {\r\n id: \"Inter-frame\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of gpu frame time metrics.\r\n * @returns the initializer for the gpu frame time strategy\r\n */\r\n public static GpuFrameTimeStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engineInstrumentation = new EngineInstrumentation(scene.getEngine());\r\n engineInstrumentation.captureGPUFrameTime = true;\r\n return {\r\n id: \"GPU frame time\",\r\n getData: () => Math.max(engineInstrumentation.gpuFrameTimeCounter.current * 0.000001, 0),\r\n dispose: () => {\r\n engineInstrumentation.dispose();\r\n },\r\n };\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"performanceViewerCollectionStrategies.js","sourceRoot":"","sources":["../../../../../dev/core/src/Misc/PerformanceViewer/performanceViewerCollectionStrategies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AAEpF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAoBrE,8BAA8B;AAC9B,MAAM,kBAAkB,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAMpC;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAC/B;;;OAGG;IACI,MAAM,CAAC,WAAW;QACrB,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;gBACH,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE;gBAC9B,OAAO,EAAE,kBAAkB;aAC9B,CAAC;QACN,CAAC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe;QACzB,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,mBAAmB;QAC7B,OAAO,IAAI,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,cAAc,C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;YAElB,MAAM,0BAA0B,GAAG,KAAK,CAAC,4BAA4B,CAAC,GAAG,CAAC,GAAG,EAAE;gBAC3E,SAAS,GAAG,aAAa,CAAC,GAAG,GAAG,SAAS,CAAC;YAC9C,CAAC,CAAC,CAAC;YAEH,MAAM,qBAAqB,GAAG,KAAK,CAAC,uBAAuB,CAAC,GAAG,CAAC,GAAG,EAAE;gBACjE,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC;YAClC,CAAC,CAAC,CAAC;YAEH,OAAO;gBACH,EAAE,EAAE,aAAa;gBACjB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;gBACxB,OAAO,EAAE,GAAG,EAAE;oBACV,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;oBACtE,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;gBAChE,CAAC;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,oBAAoB;QAC9B,OAAO,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;YAC3E,qBAAqB,CAAC,mBAAmB,GAAG,IAAI,CAAC;YACjD,OAAO;gBACH,EAAE,EAAE,gBAAgB;gBACpB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,OAAO,GAAG,QAAQ,EAAE,CAAC,CAAC;gBACxF,OAAO,EAAE,GAAG,EAAE;oBACV,qBAAqB,CAAC,OAAO,EAAE,CAAC;gBACpC,CAAC;aACJ,CAAC;QACN,CAAC,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { EngineInstrumentation } from \"../../Instrumentation/engineInstrumentation\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { PrecisionDate } from \"../precisionDate\";\r\nimport { SceneInstrumentation } from \"../../Instrumentation/sceneInstrumentation\";\r\nimport { PressureObserverWrapper } from \"../pressureObserverWrapper\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n/**\r\n * Defines the general structure of what is necessary for a collection strategy.\r\n */\r\nexport interface IPerfViewerCollectionStrategy {\r\n /**\r\n * The id of the strategy.\r\n */\r\n id: string;\r\n /**\r\n * Function which gets the data for the strategy.\r\n */\r\n getData: () => number;\r\n /**\r\n * Function which does any necessary cleanup. Called when performanceViewerCollector.dispose() is called.\r\n */\r\n dispose: () => void;\r\n}\r\n// Dispose which does nothing.\r\nconst defaultDisposeImpl = () => {};\r\n\r\n/**\r\n * Initializer callback for a strategy\r\n */\r\nexport type PerfStrategyInitialization = (scene: Scene) => IPerfViewerCollectionStrategy;\r\n/**\r\n * Defines the predefined strategies used in the performance viewer.\r\n */\r\nexport class PerfCollectionStrategy {\r\n /**\r\n * Gets the initializer for the strategy used for collection of fps metrics\r\n * @returns the initializer for the fps strategy\r\n */\r\n public static FpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engine = scene.getEngine();\r\n return {\r\n id: \"FPS\",\r\n getData: () => engine.getFps(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of thermal utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the thermal utilization strategy\r\n */\r\n public static ThermalStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Thermal utilization\", \"thermal\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of power supply utilization metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the power supply utilization strategy\r\n */\r\n public static PowerSupplyStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Power supply utilization\", \"power-supply\");\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of pressure metrics.\r\n * Needs the experimental pressure API.\r\n * @returns the initializer for the pressure strategy\r\n */\r\n public static PressureStrategy(): PerfStrategyInitialization {\r\n return this._PressureStrategy(\"Pressure\");\r\n }\r\n\r\n private static _PressureStrategy(name: string, factor: Nullable<PressureFactor> = null): PerfStrategyInitialization {\r\n return () => {\r\n let value = 0;\r\n\r\n const wrapper = new PressureObserverWrapper();\r\n wrapper.observe(\"cpu\");\r\n\r\n wrapper.onPressureChanged.add((update) => {\r\n for (const record of update) {\r\n if ((factor && record.factors.includes(factor)) || (!factor && (record.factors?.length ?? 0) === 0)) {\r\n // Let s consider each step being 25% of the total pressure.\r\n switch (record.state) {\r\n case \"nominal\":\r\n value = 0;\r\n break;\r\n case \"fair\":\r\n value = 0.25;\r\n break;\r\n case \"serious\":\r\n value = 0.5;\r\n break;\r\n case \"critical\":\r\n value = 1;\r\n break;\r\n }\r\n }\r\n }\r\n });\r\n return {\r\n id: name,\r\n getData: () => value,\r\n dispose: () => wrapper.dispose(),\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total meshes metrics.\r\n * @returns the initializer for the total meshes strategy\r\n */\r\n public static TotalMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total meshes\",\r\n getData: () => scene.meshes.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active meshes metrics.\r\n * @returns the initializer for the active meshes strategy\r\n */\r\n public static ActiveMeshesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active meshes\",\r\n getData: () => scene.getActiveMeshes().length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active indices metrics.\r\n * @returns the initializer for the active indices strategy\r\n */\r\n public static ActiveIndicesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active indices\",\r\n getData: () => scene.getActiveIndices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active faces metrics.\r\n * @returns the initializer for the active faces strategy\r\n */\r\n public static ActiveFacesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active faces\",\r\n getData: () => scene.getActiveIndices() / 3,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active bones metrics.\r\n * @returns the initializer for the active bones strategy\r\n */\r\n public static ActiveBonesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active bones\",\r\n getData: () => scene.getActiveBones(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of active particles metrics.\r\n * @returns the initializer for the active particles strategy\r\n */\r\n public static ActiveParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Active particles\",\r\n getData: () => scene.getActiveParticles(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of draw calls metrics.\r\n * @returns the initializer for the draw calls strategy\r\n */\r\n public static DrawCallsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let drawCalls = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n scene.getEngine()._drawCalls.fetchNewFrame();\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n drawCalls = scene.getEngine()._drawCalls.current;\r\n });\r\n\r\n return {\r\n id: \"Draw calls\",\r\n getData: () => drawCalls,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total lights metrics.\r\n * @returns the initializer for the total lights strategy\r\n */\r\n public static TotalLightsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total lights\",\r\n getData: () => scene.lights.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total vertices metrics.\r\n * @returns the initializer for the total vertices strategy\r\n */\r\n public static TotalVerticesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total vertices\",\r\n getData: () => scene.getTotalVertices(),\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total materials metrics.\r\n * @returns the initializer for the total materials strategy\r\n */\r\n public static TotalMaterialsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total materials\",\r\n getData: () => scene.materials.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total textures metrics.\r\n * @returns the initializer for the total textures strategy\r\n */\r\n public static TotalTexturesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n return {\r\n id: \"Total textures\",\r\n getData: () => scene.textures.length,\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of absolute fps metrics.\r\n * @returns the initializer for the absolute fps strategy\r\n */\r\n public static AbsoluteFpsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const sceneInstrumentation = new SceneInstrumentation(scene);\r\n sceneInstrumentation.captureFrameTime = true;\r\n\r\n return {\r\n id: \"Absolute FPS\",\r\n getData: () => {\r\n return 1000.0 / sceneInstrumentation.frameTimeCounter.lastSecAverage;\r\n },\r\n dispose: defaultDisposeImpl,\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of meshes selection time metrics.\r\n * @returns the initializer for the meshes selection time strategy\r\n */\r\n public static MeshesSelectionStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeActiveMeshesObserver = scene.onBeforeActiveMeshesEvaluationObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterActiveMeshesObserver = scene.onAfterActiveMeshesEvaluationObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Meshes Selection\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeActiveMeshesEvaluationObservable.remove(onBeforeActiveMeshesObserver);\r\n scene.onAfterActiveMeshesEvaluationObservable.remove(onAfterActiveMeshesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render targets time metrics.\r\n * @returns the initializer for the render targets time strategy\r\n */\r\n public static RenderTargetsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeRenderTargetsObserver = scene.onBeforeRenderTargetsRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderTargetsObserver = scene.onAfterRenderTargetsRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render Targets\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeRenderTargetsRenderObservable.remove(onBeforeRenderTargetsObserver);\r\n scene.onAfterRenderTargetsRenderObservable.remove(onAfterRenderTargetsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of particles time metrics.\r\n * @returns the initializer for the particles time strategy\r\n */\r\n public static ParticlesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeParticlesObserver = scene.onBeforeParticlesRenderingObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterParticlesObserver = scene.onAfterParticlesRenderingObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Particles\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeParticlesRenderingObservable.remove(onBeforeParticlesObserver);\r\n scene.onAfterParticlesRenderingObservable.remove(onAfterParticlesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of sprites time metrics.\r\n * @returns the initializer for the sprites time strategy\r\n */\r\n public static SpritesStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeSpritesObserver = scene.onBeforeSpritesRenderingObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterSpritesObserver = scene.onAfterSpritesRenderingObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Sprites\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeSpritesRenderingObservable?.remove(onBeforeSpritesObserver);\r\n scene.onAfterSpritesRenderingObservable?.remove(onAfterSpritesObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of animations time metrics.\r\n * @returns the initializer for the animations time strategy\r\n */\r\n public static AnimationsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterAnimationsObserver = scene.onAfterAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Animations\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterAnimationsObservable.remove(onAfterAnimationsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of physics time metrics.\r\n * @returns the initializer for the physics time strategy\r\n */\r\n public static PhysicsStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforePhysicsObserver = scene.onBeforePhysicsObservable?.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterPhysicsObserver = scene.onAfterPhysicsObservable?.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Physics\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforePhysicsObservable?.remove(onBeforePhysicsObserver);\r\n scene.onAfterPhysicsObservable?.remove(onAfterPhysicsObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of render time metrics.\r\n * @returns the initializer for the render time strategy\r\n */\r\n public static RenderStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeDrawPhaseObserver = scene.onBeforeDrawPhaseObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterDrawPhaseObserver = scene.onAfterDrawPhaseObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Render\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeDrawPhaseObservable.remove(onBeforeDrawPhaseObserver);\r\n scene.onAfterDrawPhaseObservable.remove(onAfterDrawPhaseObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of total frame time metrics.\r\n * @returns the initializer for the total frame time strategy\r\n */\r\n public static FrameTotalStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n return {\r\n id: \"Frame Total\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of inter-frame time metrics.\r\n * @returns the initializer for the inter-frame time strategy\r\n */\r\n public static InterFrameStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n let startTime = PrecisionDate.Now;\r\n let timeTaken = 0;\r\n\r\n const onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(() => {\r\n timeTaken = PrecisionDate.Now - startTime;\r\n });\r\n\r\n const onAfterRenderObserver = scene.onAfterRenderObservable.add(() => {\r\n startTime = PrecisionDate.Now;\r\n });\r\n\r\n return {\r\n id: \"Inter-frame\",\r\n getData: () => timeTaken,\r\n dispose: () => {\r\n scene.onBeforeAnimationsObservable.remove(onBeforeAnimationsObserver);\r\n scene.onAfterRenderObservable.remove(onAfterRenderObserver);\r\n },\r\n };\r\n };\r\n }\r\n\r\n /**\r\n * Gets the initializer for the strategy used for collection of gpu frame time metrics.\r\n * @returns the initializer for the gpu frame time strategy\r\n */\r\n public static GpuFrameTimeStrategy(): PerfStrategyInitialization {\r\n return (scene) => {\r\n const engineInstrumentation = new EngineInstrumentation(scene.getEngine());\r\n engineInstrumentation.captureGPUFrameTime = true;\r\n return {\r\n id: \"GPU frame time\",\r\n getData: () => Math.max(engineInstrumentation.gpuFrameTimeCounter.current * 0.000001, 0),\r\n dispose: () => {\r\n engineInstrumentation.dispose();\r\n },\r\n };\r\n };\r\n }\r\n}\r\n"]}
package/Misc/dumpTools.js CHANGED
@@ -10,7 +10,7 @@ import { Scalar } from "../Maths/math.scalar.js";
10
10
  export class DumpTools {
11
11
  static _CreateDumpRenderer() {
12
12
  if (!DumpTools._DumpToolsEngine) {
13
- let canvas = new OffscreenCanvas(100, 100); // will be resized later
13
+ let canvas;
14
14
  let engine = null;
15
15
  const options = {
16
16
  preserveDrawingBuffer: true,
@@ -22,10 +22,11 @@ export class DumpTools {
22
22
  failIfMajorPerformanceCaveat: false,
23
23
  };
24
24
  try {
25
+ canvas = new OffscreenCanvas(100, 100); // will be resized later
25
26
  engine = new ThinEngine(canvas, false, options);
26
27
  }
27
28
  catch (e) {
28
- // The browser does not support WebGL context in OffscreenCanvas, fallback on a regular canvas
29
+ // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas
29
30
  canvas = document.createElement("canvas");
30
31
  engine = new ThinEngine(canvas, false, options);
31
32
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,SAAS;IAGV,MAAM,CAAC,mBAAmB;QAC9B,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;YAC7B,IAAI,MAAM,GAAwC,IAAI,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB;YACzG,IAAI,MAAM,GAAyB,IAAI,CAAC;YACxC,MAAM,O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,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SACnG;QAED,OAAO,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,OAAO;QACjB,IAAI,SAAS,CAAC,gBAAgB,EAAE;YAC5B,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC7C,SAAS,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YAC9C,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SAC/C;QACD,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACtC,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;IAC9C,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport type { Nullable } from \"../types\";\r\n\r\nimport { passPixelShader } from \"../Shaders/pass.fragment\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\n\r\ntype DumpToolsEngine = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n};\r\n\r\n/**\r\n * Class containing a set of static utilities functions to dump data from a canvas\r\n */\r\nexport class DumpTools {\r\n private static _DumpToolsEngine: Nullable<DumpToolsEngine>;\r\n\r\n private static _CreateDumpRenderer(): DumpToolsEngine {\r\n if (!DumpTools._DumpToolsEngine) {\r\n let canvas: HTMLCanvasElement | OffscreenCanvas = new OffscreenCanvas(100, 100); // will be resized later\r\n let engine: Nullable<ThinEngine> = null;\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n try {\r\n engine = new ThinEngine(canvas, false, options);\r\n } catch (e) {\r\n // The browser does not support WebGL context in OffscreenCanvas, fallback on a regular canvas\r\n canvas = document.createElement(\"canvas\");\r\n engine = new ThinEngine(canvas, false, options);\r\n }\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n const renderer = new EffectRenderer(engine);\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n DumpTools._DumpToolsEngine = {\r\n canvas,\r\n engine,\r\n renderer,\r\n wrapper,\r\n };\r\n }\r\n return DumpTools._DumpToolsEngine!;\r\n }\r\n\r\n /**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n public static async DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: Engine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n ) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\n public static DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ): Promise<string | ArrayBuffer> {\r\n return new Promise((resolve) => {\r\n DumpTools.DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\r\n });\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n public static DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ) {\r\n const renderer = DumpTools._CreateDumpRenderer();\r\n renderer.engine.setSize(width, height, true);\r\n\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Scalar.Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n // Create the image\r\n const texture = renderer.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n renderer.renderer.setViewport();\r\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\r\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n renderer.renderer.draw();\r\n\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n renderer.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n if (successCallback) {\r\n successCallback(arrayBuffer);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\r\n }\r\n\r\n texture.dispose();\r\n }\r\n\r\n /**\r\n * Dispose the dump tools associated resources\r\n */\r\n public static Dispose() {\r\n if (DumpTools._DumpToolsEngine) {\r\n DumpTools._DumpToolsEngine.wrapper.dispose();\r\n DumpTools._DumpToolsEngine.renderer.dispose();\r\n DumpTools._DumpToolsEngine.engine.dispose();\r\n }\r\n DumpTools._DumpToolsEngine = null;\r\n }\r\n}\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpTools.DumpData;\r\n Tools.DumpDataAsync = DumpTools.DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpTools.DumpFramebuffer;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
1
+ {"version":3,"file":"dumpTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/dumpTools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,SAAS;IAGV,MAAM,CAAC,mBAAmB;QAC9B,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;YAC7B,IAAI,MAA2C,CAAC;YAChD,IAAI,MAAM,GAAyB,IAAI,CAAC;YACxC,MAAM,OAAO,GAAG;gBACZ,qBAAqB,EAAE,IAAI;gBAC3B,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,IAAI;gBACX,kBAAkB,EAAE,KAAK;gBACzB,SAAS,EAAE,KAAK;gBAChB,4BAA4B,EAAE,KAAK;aACtC,CAAC;YACF,IAAI;gBACA,MAAM,GAAG,IAAI,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,wBAAwB;gBAChE,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;aACnD;YAAC,OAAO,CAAC,EAAE;gBACR,wHAAwH;gBACx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,OAAO,EAAE,CAAC;SAC/C;QACD,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC;IACtC,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE;IACzB,+BAA+B;IAC/B,KAAK,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC;IACpC,KAAK,CAAC,aAAa,GAAG,SAAS,CAAC,aAAa,CAAC;IAC9C,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,eAAe,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,EAAE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\nimport { _WarnImport } from \"./devTools\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\nimport { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport { Tools } from \"./tools\";\r\nimport type { Nullable } from \"../types\";\r\n\r\nimport { passPixelShader } from \"../Shaders/pass.fragment\";\r\nimport { Scalar } from \"../Maths/math.scalar\";\r\n\r\ntype DumpToolsEngine = {\r\n canvas: HTMLCanvasElement | OffscreenCanvas;\r\n engine: ThinEngine;\r\n renderer: EffectRenderer;\r\n wrapper: EffectWrapper;\r\n};\r\n\r\n/**\r\n * Class containing a set of static utilities functions to dump data from a canvas\r\n */\r\nexport class DumpTools {\r\n private static _DumpToolsEngine: Nullable<DumpToolsEngine>;\r\n\r\n private static _CreateDumpRenderer(): DumpToolsEngine {\r\n if (!DumpTools._DumpToolsEngine) {\r\n let canvas: HTMLCanvasElement | OffscreenCanvas;\r\n let engine: Nullable<ThinEngine> = null;\r\n const options = {\r\n preserveDrawingBuffer: true,\r\n depth: false,\r\n stencil: false,\r\n alpha: true,\r\n premultipliedAlpha: false,\r\n antialias: false,\r\n failIfMajorPerformanceCaveat: false,\r\n };\r\n try {\r\n canvas = new OffscreenCanvas(100, 100); // will be resized later\r\n engine = new ThinEngine(canvas, false, options);\r\n } catch (e) {\r\n // The browser either does not support OffscreenCanvas or WebGL context in OffscreenCanvas, fallback on a regular canvas\r\n canvas = document.createElement(\"canvas\");\r\n engine = new ThinEngine(canvas, false, options);\r\n }\r\n engine.getCaps().parallelShaderCompile = undefined;\r\n const renderer = new EffectRenderer(engine);\r\n const wrapper = new EffectWrapper({\r\n engine,\r\n name: passPixelShader.name,\r\n fragmentShader: passPixelShader.shader,\r\n samplerNames: [\"textureSampler\"],\r\n });\r\n DumpTools._DumpToolsEngine = {\r\n canvas,\r\n engine,\r\n renderer,\r\n wrapper,\r\n };\r\n }\r\n return DumpTools._DumpToolsEngine!;\r\n }\r\n\r\n /**\r\n * Dumps the current bound framebuffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param engine defines the hosting engine\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a void promise\r\n */\r\n public static async DumpFramebuffer(\r\n width: number,\r\n height: number,\r\n engine: Engine,\r\n successCallback?: (data: string) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n quality?: number\r\n ) {\r\n // Read the contents of the framebuffer\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n\r\n const data = new Uint8Array(bufferView.buffer);\r\n\r\n DumpTools.DumpData(width, height, data, successCallback as (data: string | ArrayBuffer) => void, mimeType, fileName, true, undefined, quality);\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n * @returns a promise that resolve to the final data\r\n */\r\n public static DumpDataAsync(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ): Promise<string | ArrayBuffer> {\r\n return new Promise((resolve) => {\r\n DumpTools.DumpData(width, height, data, (result) => resolve(result), mimeType, fileName, invertY, toArrayBuffer, quality);\r\n });\r\n }\r\n\r\n /**\r\n * Dumps an array buffer\r\n * @param width defines the rendering width\r\n * @param height defines the rendering height\r\n * @param data the data array\r\n * @param successCallback defines the callback triggered once the data are available\r\n * @param mimeType defines the mime type of the result\r\n * @param fileName defines the filename to download. If present, the result will automatically be downloaded\r\n * @param invertY true to invert the picture in the Y dimension\r\n * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string\r\n * @param quality The quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.\r\n */\r\n public static DumpData(\r\n width: number,\r\n height: number,\r\n data: ArrayBufferView,\r\n successCallback?: (data: string | ArrayBuffer) => void,\r\n mimeType = \"image/png\",\r\n fileName?: string,\r\n invertY = false,\r\n toArrayBuffer = false,\r\n quality?: number\r\n ) {\r\n const renderer = DumpTools._CreateDumpRenderer();\r\n renderer.engine.setSize(width, height, true);\r\n\r\n // Convert if data are float32\r\n if (data instanceof Float32Array) {\r\n const data2 = new Uint8Array(data.length);\r\n let n = data.length;\r\n while (n--) {\r\n const v = data[n];\r\n data2[n] = Math.round(Scalar.Clamp(v) * 255);\r\n }\r\n data = data2;\r\n }\r\n\r\n // Create the image\r\n const texture = renderer.engine.createRawTexture(data, width, height, Constants.TEXTUREFORMAT_RGBA, false, !invertY, Constants.TEXTURE_NEAREST_NEAREST);\r\n\r\n renderer.renderer.setViewport();\r\n renderer.renderer.applyEffectWrapper(renderer.wrapper);\r\n renderer.wrapper.effect._bindTexture(\"textureSampler\", texture);\r\n renderer.renderer.draw();\r\n\r\n if (toArrayBuffer) {\r\n Tools.ToBlob(\r\n renderer.canvas,\r\n (blob) => {\r\n const fileReader = new FileReader();\r\n fileReader.onload = (event: any) => {\r\n const arrayBuffer = event.target!.result as ArrayBuffer;\r\n if (successCallback) {\r\n successCallback(arrayBuffer);\r\n }\r\n };\r\n fileReader.readAsArrayBuffer(blob!);\r\n },\r\n mimeType,\r\n quality\r\n );\r\n } else {\r\n Tools.EncodeScreenshotCanvasData(renderer.canvas, successCallback, mimeType, fileName, quality);\r\n }\r\n\r\n texture.dispose();\r\n }\r\n\r\n /**\r\n * Dispose the dump tools associated resources\r\n */\r\n public static Dispose() {\r\n if (DumpTools._DumpToolsEngine) {\r\n DumpTools._DumpToolsEngine.wrapper.dispose();\r\n DumpTools._DumpToolsEngine.renderer.dispose();\r\n DumpTools._DumpToolsEngine.engine.dispose();\r\n }\r\n DumpTools._DumpToolsEngine = null;\r\n }\r\n}\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n // References the dependencies.\r\n Tools.DumpData = DumpTools.DumpData;\r\n Tools.DumpDataAsync = DumpTools.DumpDataAsync;\r\n Tools.DumpFramebuffer = DumpTools.DumpFramebuffer;\r\n};\r\n\r\ninitSideEffects();\r\n"]}
@@ -0,0 +1,39 @@
1
+ import type { Scene } from "../scene";
2
+ import { ReflectionProbe } from "../Probes/reflectionProbe";
3
+ import type { AbstractMesh } from "../Meshes/abstractMesh";
4
+ import type { Vector3 } from "../Maths/math.vector";
5
+ import "../Shaders/equirectangularPanorama.fragment";
6
+ /**
7
+ * Interface containing options related to equirectangular capture of the current scene
8
+ */
9
+ export interface EquiRectangularCaptureOptions {
10
+ /**
11
+ * This option relates to smallest dimension of the given equirectangular capture
12
+ * Giving a 512px size would result in an image that 512 x 1024px
13
+ */
14
+ size: number;
15
+ /**
16
+ * Optional function to map which meshes should get rendered on the equirectangular map
17
+ * This is specifically helpful when you have certain meshes that you want to skip, especially ground
18
+ */
19
+ meshesFilter?: (mesh: AbstractMesh) => boolean;
20
+ /**
21
+ * Optional argument to specify filename, passing this would auto download the given file
22
+ */
23
+ filename?: string;
24
+ /**
25
+ * Optional argument to specify position in 3D Space from where the equirectangular capture should be taken, if not specified, it would take the position of the scene's active camera or else origin
26
+ */
27
+ position?: Vector3;
28
+ /**
29
+ * Optional argument to specify probe with which the equirectangular image is generated
30
+ * When passing this, size and position arguments are ignored
31
+ */
32
+ probe?: ReflectionProbe;
33
+ }
34
+ /**
35
+ * @param scene This refers to the scene which would be rendered in the given equirectangular capture
36
+ * @param options This refers to the options for a given equirectangular capture
37
+ * @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified
38
+ */
39
+ export declare function captureEquirectangularFromScene(scene: Scene, options: EquiRectangularCaptureOptions): Promise<ArrayBufferView | null>;
@@ -0,0 +1,56 @@
1
+ import { ReflectionProbe } from "../Probes/reflectionProbe.js";
2
+ import { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture.js";
3
+ import { CustomProceduralTexture } from "../Materials/Textures/Procedurals/customProceduralTexture.js";
4
+ import { DumpTools } from "./dumpTools.js";
5
+ import "../Shaders/equirectangularPanorama.fragment.js";
6
+ /**
7
+ * @param scene This refers to the scene which would be rendered in the given equirectangular capture
8
+ * @param options This refers to the options for a given equirectangular capture
9
+ * @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified
10
+ */
11
+ export async function captureEquirectangularFromScene(scene, options) {
12
+ var _a, _b;
13
+ const probe = (_a = options.probe) !== null && _a !== void 0 ? _a : new ReflectionProbe("tempProbe", options.size, scene);
14
+ const wasProbeProvided = !!options.probe;
15
+ if (!wasProbeProvided) {
16
+ if (options.position) {
17
+ probe.position = options.position.clone();
18
+ }
19
+ else if (scene.activeCamera) {
20
+ probe.position = scene.activeCamera.position.clone();
21
+ }
22
+ }
23
+ const meshesToConsider = options.meshesFilter ? scene.meshes.filter(options.meshesFilter) : scene.meshes;
24
+ (_b = probe.renderList) === null || _b === void 0 ? void 0 : _b.push(...meshesToConsider);
25
+ probe.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
26
+ probe.cubeTexture.render();
27
+ const dumpTexture = new CustomProceduralTexture("tempProceduralTexture", "equirectangularPanorama", { width: options.size * 2, height: options.size }, scene);
28
+ dumpTexture.setTexture("cubeMap", probe.cubeTexture);
29
+ return new Promise((resolve, reject) => {
30
+ dumpTexture.onGeneratedObservable.addOnce(() => {
31
+ const pixelDataPromise = dumpTexture.readPixels();
32
+ if (!pixelDataPromise) {
33
+ reject(new Error("No Pixel Data found on procedural texture"));
34
+ dumpTexture.dispose();
35
+ if (!wasProbeProvided) {
36
+ probe.dispose();
37
+ }
38
+ return;
39
+ }
40
+ pixelDataPromise.then((pixelData) => {
41
+ dumpTexture.dispose();
42
+ if (!wasProbeProvided) {
43
+ probe.dispose();
44
+ }
45
+ if (options.filename) {
46
+ DumpTools.DumpData(options.size * 2, options.size, pixelData, undefined, "image/png", options.filename);
47
+ resolve(null);
48
+ }
49
+ else {
50
+ resolve(pixelData);
51
+ }
52
+ });
53
+ });
54
+ });
55
+ }
56
+ //# sourceMappingURL=equirectangularCapture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equirectangularCapture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/equirectangularCapture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,mBAAmB,E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KAAK,CAAC,CAAC;IAC9J,WAAW,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACrD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,WAAW,CAAC,qBAAqB,CAAC,OAAO,CAAC,GAAG,EAAE;YAC3C,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,EAAE,CAAC;YAClD,IAAI,CAAC,gBAAgB,EAAE;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC,CAAC;gBAC/D,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,IAAI,CAAC,gBAAgB,EAAE;oBACnB,KAAK,CAAC,OAAO,EAAE,CAAC;iBACnB;gBACD,OAAO;aACV;YACD,gBAAgB,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAChC,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,IAAI,CAAC,gBAAgB,EAAE;oBACnB,KAAK,CAAC,OAAO,EAAE,CAAC;iBACnB;gBACD,IAAI,OAAO,CAAC,QAAQ,EAAE;oBAClB,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACxG,OAAO,CAAC,IAAI,CAAC,CAAC;iBACjB;qBAAM;oBACH,OAAO,CAAC,SAAS,CAAC,CAAC;iBACtB;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { Scene } from \"../scene\";\r\nimport { ReflectionProbe } from \"../Probes/reflectionProbe\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { CustomProceduralTexture } from \"../Materials/Textures/Procedurals/customProceduralTexture\";\r\nimport { DumpTools } from \"./dumpTools\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport \"../Shaders/equirectangularPanorama.fragment\";\r\n\r\n/**\r\n * Interface containing options related to equirectangular capture of the current scene\r\n */\r\nexport interface EquiRectangularCaptureOptions {\r\n /**\r\n * This option relates to smallest dimension of the given equirectangular capture\r\n * Giving a 512px size would result in an image that 512 x 1024px\r\n */\r\n size: number;\r\n /**\r\n * Optional function to map which meshes should get rendered on the equirectangular map\r\n * This is specifically helpful when you have certain meshes that you want to skip, especially ground\r\n */\r\n meshesFilter?: (mesh: AbstractMesh) => boolean;\r\n /**\r\n * Optional argument to specify filename, passing this would auto download the given file\r\n */\r\n filename?: string;\r\n\r\n /**\r\n * Optional argument to specify position in 3D Space from where the equirectangular capture should be taken, if not specified, it would take the position of the scene's active camera or else origin\r\n */\r\n position?: Vector3;\r\n\r\n /**\r\n * Optional argument to specify probe with which the equirectangular image is generated\r\n * When passing this, size and position arguments are ignored\r\n */\r\n probe?: ReflectionProbe;\r\n}\r\n\r\n/**\r\n * @param scene This refers to the scene which would be rendered in the given equirectangular capture\r\n * @param options This refers to the options for a given equirectangular capture\r\n * @returns the requested capture's pixel-data or auto downloads the file if options.filename is specified\r\n */\r\nexport async function captureEquirectangularFromScene(scene: Scene, options: EquiRectangularCaptureOptions): Promise<ArrayBufferView | null> {\r\n const probe: ReflectionProbe = options.probe ?? new ReflectionProbe(\"tempProbe\", options.size, scene);\r\n const wasProbeProvided = !!options.probe;\r\n if (!wasProbeProvided) {\r\n if (options.position) {\r\n probe.position = options.position.clone();\r\n } else if (scene.activeCamera) {\r\n probe.position = scene.activeCamera.position.clone();\r\n }\r\n }\r\n const meshesToConsider = options.meshesFilter ? scene.meshes.filter(options.meshesFilter) : scene.meshes;\r\n probe.renderList?.push(...meshesToConsider);\r\n probe.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;\r\n probe.cubeTexture.render();\r\n const dumpTexture = new CustomProceduralTexture(\"tempProceduralTexture\", \"equirectangularPanorama\", { width: options.size * 2, height: options.size }, scene);\r\n dumpTexture.setTexture(\"cubeMap\", probe.cubeTexture);\r\n return new Promise((resolve, reject) => {\r\n dumpTexture.onGeneratedObservable.addOnce(() => {\r\n const pixelDataPromise = dumpTexture.readPixels();\r\n if (!pixelDataPromise) {\r\n reject(new Error(\"No Pixel Data found on procedural texture\"));\r\n dumpTexture.dispose();\r\n if (!wasProbeProvided) {\r\n probe.dispose();\r\n }\r\n return;\r\n }\r\n pixelDataPromise.then((pixelData) => {\r\n dumpTexture.dispose();\r\n if (!wasProbeProvided) {\r\n probe.dispose();\r\n }\r\n if (options.filename) {\r\n DumpTools.DumpData(options.size * 2, options.size, pixelData, undefined, \"image/png\", options.filename);\r\n resolve(null);\r\n } else {\r\n resolve(pixelData);\r\n }\r\n });\r\n });\r\n });\r\n}\r\n"]}
package/Misc/index.d.ts CHANGED
@@ -63,3 +63,4 @@ export * from "./observableCoroutine";
63
63
  export * from "./copyTextureToTexture";
64
64
  export * from "./dumpTools";
65
65
  export * from "./greasedLineTools";
66
+ export * from "./equirectangularCapture";
package/Misc/index.js CHANGED
@@ -65,4 +65,5 @@ export * from "./observableCoroutine.js";
65
65
  export * from "./copyTextureToTexture.js";
66
66
  export * from "./dumpTools.js";
67
67
  export * from "./greasedLineTools.js";
68
+ export * from "./equirectangularCapture.js";
68
69
  //# sourceMappingURL=index.js.map
package/Misc/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B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iB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iBAAiB,CAAC;AAChC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\n"]}
@@ -262,6 +262,15 @@ export declare enum PhysicsMotionType {
262
262
  ANIMATED = 1,
263
263
  DYNAMIC = 2
264
264
  }
265
+ /**
266
+ * Represents a pair of bodies connected by a constraint.
267
+ */
268
+ export type ConstrainedBodyPair = {
269
+ parentBody: PhysicsBody;
270
+ parentBodyIndex: number;
271
+ childBody: PhysicsBody;
272
+ childBodyIndex: number;
273
+ };
265
274
  /** @internal */
266
275
  export interface IPhysicsEnginePluginV2 {
267
276
  /**
@@ -351,6 +360,7 @@ export interface IPhysicsEnginePluginV2 {
351
360
  setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;
352
361
  getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;
353
362
  disposeConstraint(constraint: PhysicsConstraint): void;
363
+ getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];
354
364
  raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;
355
365
  dispose(): void;
356
366
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbW,8BAA8B,KAA9B,8BAA8B,QAazC;AAED,2GAA2G;AAC3G,MAAM,CAAN,IAAY,qB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C,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAyLD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"IPhysicsEnginePlugin.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/IPhysicsEnginePlugin.ts"],"names":[],"mappings":"AAYA,6CAA6C;AAC7C,MAAM,CAAN,IAAY,8BAaX;AAbD,WAAY,8BAA8B;IACtC;;OAEG;IACH,mFAAI,CAAA;IACJ;;OAEG;IACH,yFAAO,CAAA;IACP;;OAEG;IACH,uFAAM,CAAA;AACV,CAAC,EAbW,8BAA8B,KAA9B,8BAA8B,QA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IACzC,uDAAmC,CAAA;IACnC,qDAAiC,CAAA;AACrC,CAAC,EANW,gBAAgB,KAAhB,gBAAgB,QAM3B;AAyLD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IACzB,6DAAM,CAAA;IACN,iEAAQ,CAAA;IACR,+DAAO,CAAA;AACX,CAAC,EAJW,iBAAiB,KAAjB,iBAAiB,QAI5B","sourcesContent":["import type { Vector3, Quaternion } from \"../../Maths/math.vector\";\r\nimport type { IRaycastQuery, PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\nimport type { PhysicsShape } from \"./physicsShape\";\r\nimport type { PhysicsConstraint } from \"./physicsConstraint\";\r\nimport type { BoundingBox } from \"../../Culling/boundingBox\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { PhysicsMaterial } from \"./physicsMaterial\";\r\nimport type { Mesh } from \"../../Meshes/mesh\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\n\r\n/** How a specific axis can be constrained */\r\nexport enum PhysicsConstraintAxisLimitMode {\r\n /*\r\n * The axis is not restricted at all\r\n */\r\n FREE,\r\n /*\r\n * The axis has a minimum/maximum limit\r\n */\r\n LIMITED,\r\n /*\r\n * The axis allows no relative movement of the pivots\r\n */\r\n LOCKED,\r\n}\r\n\r\n/** The constraint specific axis to use when setting Friction, `ConstraintAxisLimitMode`, max force, ... */\r\nexport enum PhysicsConstraintAxis {\r\n /*\r\n * Translation along the primary axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n LINEAR_X,\r\n /*\r\n * Translation along the second axis of the constraint (i.e. the\r\n * direction specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Y,\r\n /*\r\n * Translation along the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n LINEAR_Z,\r\n /*\r\n * Rotation around the primary axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.axisA/axisB)\r\n */\r\n ANGULAR_X,\r\n /*\r\n * Rotation around the second axis of the constraint (i.e. the\r\n * axis specified by PhysicsConstraintParameters.perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Y,\r\n /*\r\n * Rotation around the third axis of the constraint. This axis is\r\n * computed from the cross product of axisA/axisB and perpAxisA/perpAxisB)\r\n */\r\n ANGULAR_Z,\r\n /*\r\n * A 3D distance limit; similar to specifying the LINEAR_X/Y/Z axes\r\n * individually, but the distance calculation uses all three axes\r\n * simultaneously, instead of individually.\r\n */\r\n LINEAR_DISTANCE,\r\n}\r\n\r\n/** Type of Constraint */\r\nexport enum PhysicsConstraintType {\r\n /**\r\n * A ball and socket constraint will attempt to line up the pivot\r\n * positions in each body, and have no restrictions on rotation\r\n */\r\n BALL_AND_SOCKET = 1,\r\n /**\r\n * A distance constraint will attempt to keep the pivot locations\r\n * within a specified distance.\r\n */\r\n DISTANCE = 2,\r\n /**\r\n * A hinge constraint will keep the pivot positions aligned as well\r\n * as two angular axes. The remaining angular axis will be free to rotate.\r\n */\r\n HINGE = 3,\r\n /**\r\n * A slider constraint allows bodies to translate along one axis and\r\n * rotate about the same axis. The remaining two axes are locked in\r\n * place\r\n */\r\n SLIDER = 4,\r\n /**\r\n * A lock constraint will attempt to keep the pivots completely lined\r\n * up between both bodies, allowing no relative movement.\r\n */\r\n LOCK = 5,\r\n /*\r\n * A prismatic will lock the rotations of the bodies, and allow translation\r\n * only along one axis\r\n */\r\n PRISMATIC = 6,\r\n /*\r\n * A generic constraint; this starts with no limits on how the bodies can\r\n * move relative to each other, but limits can be added via the PhysicsConstraint\r\n * interfaces. This can be used to specify a large variety of constraints\r\n */\r\n SIX_DOF = 7,\r\n}\r\n\r\n/** Type of Shape */\r\nexport enum PhysicsShapeType {\r\n SPHERE,\r\n CAPSULE,\r\n CYLINDER,\r\n BOX,\r\n CONVEX_HULL,\r\n CONTAINER,\r\n MESH,\r\n HEIGHTFIELD,\r\n}\r\n\r\n/** Optional motor which attempts to move a body at a specific velocity, or at a specific position */\r\nexport enum PhysicsConstraintMotorType {\r\n NONE,\r\n VELOCITY,\r\n POSITION,\r\n}\r\n\r\nexport enum PhysicsEventType {\r\n COLLISION_STARTED = \"COLLISION_STARTED\",\r\n COLLISION_CONTINUED = \"COLLISION_CONTINUED\",\r\n COLLISION_FINISHED = \"COLLISION_FINISHED\",\r\n TRIGGER_ENTERED = \"TRIGGER_ENTERED\",\r\n TRIGGER_EXITED = \"TRIGGER_EXITED\",\r\n}\r\n\r\n/**\r\n * Base collision object\r\n */\r\nexport interface IBasePhysicsCollisionEvent {\r\n /**\r\n * 1st physics body that collided\r\n */\r\n collider: PhysicsBody;\r\n /**\r\n * 2nd physics body that collided\r\n */\r\n collidedAgainst: PhysicsBody;\r\n /**\r\n * index in instances array for the collider\r\n */\r\n colliderIndex: number;\r\n /**\r\n * index in instances array for the collidedAgainst\r\n */\r\n collidedAgainstIndex: number;\r\n /**\r\n * Event type\r\n */\r\n type: PhysicsEventType;\r\n}\r\n\r\n/**\r\n * Collision object that is the parameter when notification for collision fires.\r\n */\r\nexport interface IPhysicsCollisionEvent extends IBasePhysicsCollisionEvent {\r\n /**\r\n * World position where the collision occured\r\n */\r\n point: Nullable<Vector3>;\r\n /**\r\n * Penetration distance\r\n */\r\n distance: number;\r\n /**\r\n * Impulse value computed by the solver response\r\n */\r\n impulse: number;\r\n /**\r\n * Collision world normal direction\r\n */\r\n normal: Nullable<Vector3>;\r\n}\r\n\r\n/**\r\n * Parameters used to describe the Shape\r\n */\r\nexport interface PhysicsShapeParameters {\r\n /**\r\n * Shape center position\r\n */\r\n center?: Vector3;\r\n /**\r\n * Radius for cylinder, shape and capsule\r\n */\r\n radius?: number;\r\n /**\r\n * First point position that defines the cylinder or capsule\r\n */\r\n pointA?: Vector3;\r\n /**\r\n * Second point position that defines the cylinder or capsule\r\n */\r\n pointB?: Vector3;\r\n /**\r\n * Shape orientation\r\n */\r\n rotation?: Quaternion;\r\n /**\r\n * Dimesion extention for the box\r\n */\r\n extents?: Vector3;\r\n /**\r\n * Mesh used for Mesh shape or convex hull. It can be different than the mesh the body is attached to.\r\n */\r\n mesh?: Mesh;\r\n /**\r\n * Use children hierarchy\r\n */\r\n includeChildMeshes?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe a Constraint\r\n */\r\nexport interface PhysicsConstraintParameters {\r\n /**\r\n * Location of the constraint pivot in the space of first body\r\n */\r\n pivotA?: Vector3;\r\n /**\r\n * Location of the constraint pivot in the space of the second body\r\n */\r\n pivotB?: Vector3;\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisA?: Vector3;\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_X/ANGULAR_X limits.\r\n */\r\n axisB?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the first body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisA?: Vector3;\r\n\r\n /**\r\n * An axis in the space of the second body which determines how\r\n * distances/angles are measured for LINEAR_Y/ANGULAR_Y limits.\r\n */\r\n perpAxisB?: Vector3;\r\n\r\n /**\r\n * The maximum distance that can seperate the two pivots.\r\n * Only used for DISTANCE constraints\r\n */\r\n maxDistance?: number;\r\n\r\n /**\r\n * Determines if the connected bodies should collide. Generally,\r\n * it is preferable to set this to false, especially if the constraint\r\n * positions the bodies so that they overlap. Otherwise, the constraint\r\n * will \"fight\" the collision detection and may cause jitter.\r\n */\r\n collision?: boolean;\r\n}\r\n\r\n/**\r\n * Parameters used to describe mass and inertia of the Physics Body\r\n */\r\nexport interface PhysicsMassProperties {\r\n /**\r\n * The center of mass, in local space. This is The\r\n * point the body will rotate around when applying\r\n * an angular velocity.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n centerOfMass?: Vector3;\r\n /**\r\n * The total mass of this object, in kilograms. This\r\n * affects how easy it is to move the body. A value\r\n * of zero will be used as an infinite mass.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n mass?: number;\r\n /**\r\n * The principal moments of inertia of this object\r\n * for a unit mass. This determines how easy it is\r\n * for the body to rotate. A value of zero on any\r\n * axis will be used as infinite interia about that\r\n * axis.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertia?: Vector3;\r\n /**\r\n * The rotation rotating from inertia major axis space\r\n * to parent space (i.e., the rotation which, when\r\n * applied to the 3x3 inertia tensor causes the inertia\r\n * tensor to become a diagonal matrix). This determines\r\n * how the values of inertia are aligned with the parent\r\n * object.\r\n *\r\n * If not provided, the physics engine will compute\r\n * an appropriate value.\r\n */\r\n inertiaOrientation?: Quaternion;\r\n}\r\n\r\n/**\r\n * Indicates how the body will behave.\r\n */\r\nexport enum PhysicsMotionType {\r\n STATIC,\r\n ANIMATED,\r\n DYNAMIC,\r\n}\r\n\r\n/**\r\n * Represents a pair of bodies connected by a constraint.\r\n */\r\nexport type ConstrainedBodyPair = { parentBody: PhysicsBody; parentBodyIndex: number; childBody: PhysicsBody; childBodyIndex: number };\r\n\r\n/** @internal */\r\nexport interface IPhysicsEnginePluginV2 {\r\n /**\r\n * Physics plugin world instance\r\n */\r\n world: any;\r\n /**\r\n * Physics plugin name\r\n */\r\n name: string;\r\n\r\n /**\r\n * Collision observable\r\n */\r\n onCollisionObservable: Observable<IPhysicsCollisionEvent>;\r\n\r\n setGravity(gravity: Vector3): void;\r\n setTimeStep(timeStep: number): void;\r\n getTimeStep(): number;\r\n executeStep(delta: number, bodies: Array<PhysicsBody>): void; //not forgetting pre and post events\r\n getPluginVersion(): number;\r\n\r\n // body\r\n initBody(body: PhysicsBody, motionType: PhysicsMotionType, position: Vector3, orientation: Quaternion): void;\r\n initBodyInstances(body: PhysicsBody, motionType: PhysicsMotionType, mesh: Mesh): void;\r\n updateBodyInstances(body: PhysicsBody, mesh: Mesh): void;\r\n removeBody(body: PhysicsBody): void;\r\n sync(body: PhysicsBody): void;\r\n syncTransform(body: PhysicsBody, transformNode: TransformNode): void;\r\n setShape(body: PhysicsBody, shape: Nullable<PhysicsShape>): void;\r\n getShape(body: PhysicsBody): Nullable<PhysicsShape>;\r\n getShapeType(shape: PhysicsShape): PhysicsShapeType;\r\n setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void;\r\n getEventMask(body: PhysicsBody, instanceIndex?: number): number;\r\n setMotionType(body: PhysicsBody, motionType: PhysicsMotionType, instanceIndex?: number): void;\r\n getMotionType(body: PhysicsBody, instanceIndex?: number): PhysicsMotionType;\r\n computeMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setMassProperties(body: PhysicsBody, massProps: PhysicsMassProperties, instanceIndex?: number): void;\r\n getMassProperties(body: PhysicsBody, instanceIndex?: number): PhysicsMassProperties;\r\n setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getLinearDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void;\r\n getAngularDamping(body: PhysicsBody, instanceIndex?: number): number;\r\n setLinearVelocity(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n getLinearVelocityToRef(body: PhysicsBody, linVel: Vector3, instanceIndex?: number): void;\r\n applyImpulse(body: PhysicsBody, impulse: Vector3, location: Vector3, instanceIndex?: number): void;\r\n applyForce(body: PhysicsBody, force: Vector3, location: Vector3, instanceIndex?: number): void;\r\n setAngularVelocity(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getAngularVelocityToRef(body: PhysicsBody, angVel: Vector3, instanceIndex?: number): void;\r\n getBodyGeometry(body: PhysicsBody): {};\r\n disposeBody(body: PhysicsBody): void;\r\n setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean, instanceIndex?: number): void;\r\n addConstraint(body: PhysicsBody, childBody: PhysicsBody, constraint: PhysicsConstraint, instanceIndex?: number, childInstanceIndex?: number): void;\r\n getCollisionObservable(body: PhysicsBody, instanceIndex?: number): Observable<IPhysicsCollisionEvent>;\r\n getCollisionEndedObservable(body: PhysicsBody, instanceIndex?: number): Observable<IBasePhysicsCollisionEvent>;\r\n setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void;\r\n getGravityFactor(body: PhysicsBody, instanceIndex?: number): number;\r\n setTargetTransform(body: PhysicsBody, position: Vector3, rotation: Quaternion, instanceIndex?: number): void;\r\n\r\n // shape\r\n initShape(shape: PhysicsShape, type: PhysicsShapeType, options: PhysicsShapeParameters): void;\r\n setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void;\r\n getShapeFilterMembershipMask(shape: PhysicsShape): number;\r\n setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void;\r\n getShapeFilterCollideMask(shape: PhysicsShape): number;\r\n setMaterial(shape: PhysicsShape, material: PhysicsMaterial): void;\r\n setDensity(shape: PhysicsShape, density: number): void;\r\n getDensity(shape: PhysicsShape): number;\r\n addChild(shape: PhysicsShape, newChild: PhysicsShape, translation?: Vector3, rotation?: Quaternion, scale?: Vector3): void;\r\n removeChild(shape: PhysicsShape, childIndex: number): void;\r\n getNumChildren(shape: PhysicsShape): number;\r\n getBoundingBox(shape: PhysicsShape): BoundingBox;\r\n disposeShape(shape: PhysicsShape): void;\r\n setTrigger(shape: PhysicsShape, isTrigger: boolean): void;\r\n\r\n // constraint\r\n initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody): void;\r\n setEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getEnabled(constraint: PhysicsConstraint): boolean;\r\n setCollisionsEnabled(constraint: PhysicsConstraint, isEnabled: boolean): void;\r\n getCollisionsEnabled(constraint: PhysicsConstraint): boolean;\r\n setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void;\r\n getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void;\r\n getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintAxisLimitMode>;\r\n setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, minLimit: number): void;\r\n getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void;\r\n getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void;\r\n getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<PhysicsConstraintMotorType>;\r\n setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void;\r\n getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void;\r\n getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): Nullable<number>;\r\n disposeConstraint(constraint: PhysicsConstraint): void;\r\n getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];\r\n\r\n // raycast\r\n raycast(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void;\r\n\r\n dispose(): void;\r\n}\r\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Quaternion, Vector3 } from "../../../Maths/math.vector";
2
2
  import { PhysicsShapeType, PhysicsMotionType, PhysicsConstraintMotorType, PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode } from "../IPhysicsEnginePlugin";
3
- import type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent, IBasePhysicsCollisionEvent } from "../IPhysicsEnginePlugin";
3
+ import type { PhysicsShapeParameters, IPhysicsEnginePluginV2, PhysicsMassProperties, IPhysicsCollisionEvent, IBasePhysicsCollisionEvent, ConstrainedBodyPair } from "../IPhysicsEnginePlugin";
4
4
  import type { IRaycastQuery, PhysicsRaycastResult } from "../../physicsRaycastResult";
5
5
  import type { PhysicsBody } from "../physicsBody";
6
6
  import type { PhysicsConstraint } from "../physicsConstraint";
@@ -44,6 +44,7 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
44
44
  private _bodies;
45
45
  private _bodyBuffer;
46
46
  private _bodyCollisionObservable;
47
+ private _constraintToBodyIdPair;
47
48
  private _bodyCollisionEndedObservable;
48
49
  /**
49
50
  * Observable for collision started and collision continued events
@@ -513,6 +514,12 @@ export declare class HavokPlugin implements IPhysicsEnginePluginV2 {
513
514
  * This function is useful for setting up a physics constraint in a physics engine.
514
515
  */
515
516
  initConstraint(constraint: PhysicsConstraint, body: PhysicsBody, childBody: PhysicsBody, instanceIndex?: number, childInstanceIndex?: number): void;
517
+ /**
518
+ * Get a list of all the pairs of bodies that are connected by this constraint.
519
+ * @param constraint the constraint to search from
520
+ * @returns a list of parent, child pairs
521
+ */
522
+ getBodiesUsingConstraint(constraint: PhysicsConstraint): ConstrainedBodyPair[];
516
523
  /**
517
524
  * Adds a constraint to the physics engine.
518
525
  *