@babylonjs/core 6.38.1 → 6.40.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 (710) hide show
  1. package/Actions/action.js +3 -1
  2. package/Actions/action.js.map +1 -1
  3. package/Actions/condition.js +1 -0
  4. package/Actions/condition.js.map +1 -1
  5. package/Actions/directActions.d.ts +2 -2
  6. package/Actions/directActions.js +2 -2
  7. package/Actions/directActions.js.map +1 -1
  8. package/Animations/pathCursor.js +1 -0
  9. package/Animations/pathCursor.js.map +1 -1
  10. package/Animations/runtimeAnimation.js +1 -1
  11. package/Animations/runtimeAnimation.js.map +1 -1
  12. package/Audio/audioEngine.js +5 -0
  13. package/Audio/audioEngine.js.map +1 -1
  14. package/Behaviors/Cameras/autoRotationBehavior.d.ts +3 -0
  15. package/Behaviors/Cameras/autoRotationBehavior.js +3 -0
  16. package/Behaviors/Cameras/autoRotationBehavior.js.map +1 -1
  17. package/Behaviors/Meshes/pointerDragBehavior.d.ts +1 -0
  18. package/Behaviors/Meshes/pointerDragBehavior.js +2 -0
  19. package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
  20. package/Behaviors/Meshes/sixDofDragBehavior.js +14 -20
  21. package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
  22. package/Bones/bone.d.ts +2 -0
  23. package/Bones/bone.js +2 -0
  24. package/Bones/bone.js.map +1 -1
  25. package/Cameras/Inputs/BaseCameraPointersInput.d.ts +11 -11
  26. package/Cameras/Inputs/BaseCameraPointersInput.js +12 -12
  27. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  28. package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +9 -9
  29. package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -9
  30. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  31. package/Cameras/Inputs/followCameraKeyboardMoveInput.d.ts +3 -0
  32. package/Cameras/Inputs/followCameraKeyboardMoveInput.js +3 -0
  33. package/Cameras/Inputs/followCameraKeyboardMoveInput.js.map +1 -1
  34. package/Cameras/Inputs/freeCameraMouseInput.d.ts +1 -1
  35. package/Cameras/Inputs/freeCameraMouseInput.js +1 -1
  36. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  37. package/Cameras/VR/vrExperienceHelper.d.ts +2 -2
  38. package/Cameras/VR/vrExperienceHelper.js +2 -2
  39. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  40. package/Cameras/arcRotateCamera.d.ts +2 -0
  41. package/Cameras/arcRotateCamera.js +2 -0
  42. package/Cameras/arcRotateCamera.js.map +1 -1
  43. package/Cameras/camera.d.ts +2 -0
  44. package/Cameras/camera.js +4 -0
  45. package/Cameras/camera.js.map +1 -1
  46. package/Cameras/followCamera.d.ts +1 -0
  47. package/Cameras/followCamera.js +1 -0
  48. package/Cameras/followCamera.js.map +1 -1
  49. package/Culling/Octrees/octree.d.ts +4 -4
  50. package/Culling/Octrees/octree.js +4 -4
  51. package/Culling/Octrees/octree.js.map +1 -1
  52. package/Debug/debugLayer.d.ts +4 -1
  53. package/Debug/debugLayer.js +4 -1
  54. package/Debug/debugLayer.js.map +1 -1
  55. package/Debug/physicsViewer.d.ts +6 -1
  56. package/Debug/physicsViewer.js +6 -1
  57. package/Debug/physicsViewer.js.map +1 -1
  58. package/Decorators/nodeDecorator.d.ts +5 -4
  59. package/Decorators/nodeDecorator.js +5 -4
  60. package/Decorators/nodeDecorator.js.map +1 -1
  61. package/DeviceInput/eventFactory.d.ts +2 -0
  62. package/DeviceInput/eventFactory.js +3 -0
  63. package/DeviceInput/eventFactory.js.map +1 -1
  64. package/DeviceInput/webDeviceInputSystem.js +3 -0
  65. package/DeviceInput/webDeviceInputSystem.js.map +1 -1
  66. package/Engines/Extensions/engine.multiview.js +2 -0
  67. package/Engines/Extensions/engine.multiview.js.map +1 -1
  68. package/Engines/Native/nativeDataStream.d.ts +32 -0
  69. package/Engines/Native/nativeDataStream.js +32 -0
  70. package/Engines/Native/nativeDataStream.js.map +1 -1
  71. package/Engines/Native/nativePipelineContext.d.ts +0 -3
  72. package/Engines/Native/nativePipelineContext.js +0 -3
  73. package/Engines/Native/nativePipelineContext.js.map +1 -1
  74. package/Engines/Native/nativeRenderTargetWrapper.js +2 -0
  75. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
  76. package/Engines/WebGL/webGLHardwareTexture.js +1 -0
  77. package/Engines/WebGL/webGLHardwareTexture.js.map +1 -1
  78. package/Engines/WebGL/webGLPipelineContext.d.ts +0 -3
  79. package/Engines/WebGL/webGLPipelineContext.js +0 -3
  80. package/Engines/WebGL/webGLPipelineContext.js.map +1 -1
  81. package/Engines/WebGL/webGLRenderTargetWrapper.js +1 -0
  82. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  83. package/Engines/WebGPU/Extensions/engine.readTexture.js +1 -0
  84. package/Engines/WebGPU/Extensions/engine.readTexture.js.map +1 -1
  85. package/Engines/WebGPU/webgpuCacheBindGroups.d.ts +1 -0
  86. package/Engines/WebGPU/webgpuCacheBindGroups.js +1 -0
  87. package/Engines/WebGPU/webgpuCacheBindGroups.js.map +1 -1
  88. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +3 -0
  89. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  90. package/Engines/WebGPU/webgpuPipelineContext.d.ts +0 -3
  91. package/Engines/WebGPU/webgpuPipelineContext.js +0 -3
  92. package/Engines/WebGPU/webgpuPipelineContext.js.map +1 -1
  93. package/Engines/WebGPU/webgpuShaderProcessingContext.js +1 -0
  94. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  95. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.d.ts +1 -1
  96. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +11 -2
  97. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  98. package/Engines/WebGPU/webgpuTextureHelper.js +22 -0
  99. package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
  100. package/Engines/WebGPU/webgpuTextureManager.js +2 -1
  101. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  102. package/Engines/WebGPU/webgpuTintWASM.d.ts +1 -1
  103. package/Engines/WebGPU/webgpuTintWASM.js +5 -5
  104. package/Engines/WebGPU/webgpuTintWASM.js.map +1 -1
  105. package/Engines/engine.d.ts +1 -0
  106. package/Engines/engine.js +1 -0
  107. package/Engines/engine.js.map +1 -1
  108. package/Engines/nativeEngine.d.ts +4 -0
  109. package/Engines/nativeEngine.js +5 -0
  110. package/Engines/nativeEngine.js.map +1 -1
  111. package/Engines/thinEngine.js +7 -2
  112. package/Engines/thinEngine.js.map +1 -1
  113. package/Engines/webgpuEngine.d.ts +1 -1
  114. package/Engines/webgpuEngine.js +17 -1
  115. package/Engines/webgpuEngine.js.map +1 -1
  116. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +214 -2
  117. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +214 -6
  118. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  119. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +15 -0
  120. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +9 -0
  121. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  122. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +6 -6
  123. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  124. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +4 -0
  125. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +4 -0
  126. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  127. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +17 -1
  128. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +14 -1
  129. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
  130. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +9 -0
  131. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +9 -0
  132. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  133. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.d.ts +5 -0
  134. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js +5 -0
  135. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
  136. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +16 -1
  137. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +13 -1
  138. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  139. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +12 -1
  140. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +12 -1
  141. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  142. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.d.ts +18 -0
  143. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js +9 -0
  144. package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -1
  145. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +12 -0
  146. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +9 -0
  147. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  148. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +15 -1
  149. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +12 -1
  150. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  151. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +18 -2
  152. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +15 -4
  153. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  154. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +6 -0
  155. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +6 -0
  156. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  157. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +6 -0
  158. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +6 -0
  159. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  160. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +5 -2
  161. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +4 -1
  162. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  163. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +15 -1
  164. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +12 -1
  165. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  166. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +4 -1
  167. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -0
  168. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  169. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.d.ts +3 -0
  170. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +3 -0
  171. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
  172. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +3 -0
  173. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +3 -0
  174. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  175. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +3 -0
  176. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +3 -0
  177. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
  178. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +14 -1
  179. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +11 -1
  180. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  181. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +3 -0
  182. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +3 -0
  183. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
  184. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +3 -0
  185. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +3 -0
  186. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
  187. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +15 -2
  188. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +12 -4
  189. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  190. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.d.ts +14 -2
  191. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js +11 -4
  192. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
  193. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +15 -2
  194. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +12 -4
  195. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  196. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +3 -0
  197. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +3 -0
  198. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  199. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +6 -0
  200. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +6 -0
  201. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
  202. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +15 -2
  203. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +12 -3
  204. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
  205. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +18 -1
  206. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +15 -1
  207. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  208. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +6 -0
  209. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +6 -0
  210. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  211. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +14 -2
  212. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +11 -4
  213. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
  214. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +15 -1
  215. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +12 -1
  216. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  217. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +14 -1
  218. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +11 -1
  219. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  220. package/FlowGraph/flowGraph.d.ts +16 -8
  221. package/FlowGraph/flowGraph.js +13 -8
  222. package/FlowGraph/flowGraph.js.map +1 -1
  223. package/FlowGraph/flowGraphBlock.d.ts +54 -5
  224. package/FlowGraph/flowGraphBlock.js +50 -11
  225. package/FlowGraph/flowGraphBlock.js.map +1 -1
  226. package/FlowGraph/flowGraphConnection.d.ts +10 -6
  227. package/FlowGraph/flowGraphConnection.js +10 -6
  228. package/FlowGraph/flowGraphConnection.js.map +1 -1
  229. package/FlowGraph/flowGraphContext.d.ts +10 -8
  230. package/FlowGraph/flowGraphContext.js +10 -8
  231. package/FlowGraph/flowGraphContext.js.map +1 -1
  232. package/FlowGraph/flowGraphCoordinator.d.ts +27 -1
  233. package/FlowGraph/flowGraphCoordinator.js +18 -2
  234. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  235. package/FlowGraph/flowGraphDataConnection.d.ts +26 -1
  236. package/FlowGraph/flowGraphDataConnection.js +23 -1
  237. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  238. package/FlowGraph/flowGraphExecutionBlock.d.ts +27 -1
  239. package/FlowGraph/flowGraphExecutionBlock.js +22 -4
  240. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  241. package/FlowGraph/flowGraphRichTypes.d.ts +24 -1
  242. package/FlowGraph/flowGraphRichTypes.js +18 -1
  243. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  244. package/FlowGraph/flowGraphSignalConnection.d.ts +2 -0
  245. package/FlowGraph/flowGraphSignalConnection.js +2 -0
  246. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  247. package/Gamepads/gamepad.d.ts +2 -2
  248. package/Gamepads/gamepad.js +2 -2
  249. package/Gamepads/gamepad.js.map +1 -1
  250. package/Gamepads/gamepadSceneComponent.js +2 -0
  251. package/Gamepads/gamepadSceneComponent.js.map +1 -1
  252. package/Gizmos/axisScaleGizmo.d.ts +2 -0
  253. package/Gizmos/axisScaleGizmo.js +2 -0
  254. package/Gizmos/axisScaleGizmo.js.map +1 -1
  255. package/Gizmos/boundingBoxGizmo.d.ts +19 -0
  256. package/Gizmos/boundingBoxGizmo.js +36 -15
  257. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  258. package/Gizmos/cameraGizmo.js +1 -0
  259. package/Gizmos/cameraGizmo.js.map +1 -1
  260. package/Gizmos/gizmo.d.ts +4 -1
  261. package/Gizmos/gizmo.js +1 -0
  262. package/Gizmos/gizmo.js.map +1 -1
  263. package/Gizmos/gizmoManager.d.ts +18 -0
  264. package/Gizmos/gizmoManager.js +34 -0
  265. package/Gizmos/gizmoManager.js.map +1 -1
  266. package/Gizmos/lightGizmo.d.ts +1 -0
  267. package/Gizmos/lightGizmo.js +1 -0
  268. package/Gizmos/lightGizmo.js.map +1 -1
  269. package/Gizmos/planeRotationGizmo.d.ts +2 -0
  270. package/Gizmos/planeRotationGizmo.js +2 -0
  271. package/Gizmos/planeRotationGizmo.js.map +1 -1
  272. package/Gizmos/positionGizmo.d.ts +11 -0
  273. package/Gizmos/positionGizmo.js +19 -0
  274. package/Gizmos/positionGizmo.js.map +1 -1
  275. package/Gizmos/rotationGizmo.d.ts +14 -0
  276. package/Gizmos/rotationGizmo.js +14 -0
  277. package/Gizmos/rotationGizmo.js.map +1 -1
  278. package/Gizmos/scaleGizmo.d.ts +18 -1
  279. package/Gizmos/scaleGizmo.js +19 -1
  280. package/Gizmos/scaleGizmo.js.map +1 -1
  281. package/Helpers/environmentHelper.d.ts +4 -2
  282. package/Helpers/environmentHelper.js +4 -2
  283. package/Helpers/environmentHelper.js.map +1 -1
  284. package/Layers/effectLayer.d.ts +1 -0
  285. package/Layers/effectLayer.js +1 -0
  286. package/Layers/effectLayer.js.map +1 -1
  287. package/Layers/glowLayer.d.ts +3 -1
  288. package/Layers/glowLayer.js +3 -1
  289. package/Layers/glowLayer.js.map +1 -1
  290. package/Layers/highlightLayer.d.ts +3 -2
  291. package/Layers/highlightLayer.js +3 -2
  292. package/Layers/highlightLayer.js.map +1 -1
  293. package/Lights/light.d.ts +1 -1
  294. package/Lights/light.js +1 -1
  295. package/Lights/light.js.map +1 -1
  296. package/Loading/sceneLoader.d.ts +9 -0
  297. package/Loading/sceneLoader.js +11 -0
  298. package/Loading/sceneLoader.js.map +1 -1
  299. package/Materials/Background/backgroundMaterial.d.ts +2 -2
  300. package/Materials/Background/backgroundMaterial.js +2 -2
  301. package/Materials/Background/backgroundMaterial.js.map +1 -1
  302. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +72 -0
  303. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +230 -0
  304. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -0
  305. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +1 -1
  306. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -1
  307. package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +2 -2
  308. package/Materials/GreasedLine/greasedLinePluginMaterial.js +2 -2
  309. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  310. package/Materials/GreasedLine/greasedLineSimpleMaterial.d.ts +0 -1
  311. package/Materials/GreasedLine/greasedLineSimpleMaterial.js +0 -1
  312. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
  313. package/Materials/Node/Blocks/Dual/index.d.ts +1 -0
  314. package/Materials/Node/Blocks/Dual/index.js +1 -0
  315. package/Materials/Node/Blocks/Dual/index.js.map +1 -1
  316. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +7 -1
  317. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +6 -1
  318. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  319. package/Materials/Node/Blocks/Fragment/fragCoordBlock.js +1 -0
  320. package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
  321. package/Materials/Node/Blocks/Fragment/frontFacingBlock.js +1 -0
  322. package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
  323. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +1 -0
  324. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
  325. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +1 -1
  326. package/Materials/Node/Blocks/Input/prePassTextureBlock.js +1 -1
  327. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  328. package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +3 -1
  329. package/Materials/Node/Blocks/Teleport/teleportInBlock.js +3 -1
  330. package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  331. package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -0
  332. package/Materials/Node/Blocks/triPlanarBlock.js +1 -0
  333. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  334. package/Materials/Node/Blocks/worleyNoise3DBlock.d.ts +2 -0
  335. package/Materials/Node/Blocks/worleyNoise3DBlock.js +2 -0
  336. package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
  337. package/Materials/Node/nodeMaterial.d.ts +11 -3
  338. package/Materials/Node/nodeMaterial.js +15 -3
  339. package/Materials/Node/nodeMaterial.js.map +1 -1
  340. package/Materials/Node/nodeMaterialBlock.d.ts +3 -1
  341. package/Materials/Node/nodeMaterialBlock.js +4 -1
  342. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  343. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -0
  344. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  345. package/Materials/Node/nodeMaterialBuildStateSharedData.js +1 -0
  346. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  347. package/Materials/PBR/pbrBaseMaterial.d.ts +10 -9
  348. package/Materials/PBR/pbrBaseMaterial.js +10 -9
  349. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  350. package/Materials/PBR/pbrMaterial.d.ts +2 -1
  351. package/Materials/PBR/pbrMaterial.js +3 -2
  352. package/Materials/PBR/pbrMaterial.js.map +1 -1
  353. package/Materials/PBR/pbrMetallicRoughnessMaterial.d.ts +7 -4
  354. package/Materials/PBR/pbrMetallicRoughnessMaterial.js +7 -4
  355. package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
  356. package/Materials/PBR/pbrSpecularGlossinessMaterial.d.ts +7 -4
  357. package/Materials/PBR/pbrSpecularGlossinessMaterial.js +7 -4
  358. package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
  359. package/Materials/Textures/Loaders/envTextureLoader.js +1 -0
  360. package/Materials/Textures/Loaders/envTextureLoader.js.map +1 -1
  361. package/Materials/Textures/Loaders/hdrTextureLoader.js +1 -0
  362. package/Materials/Textures/Loaders/hdrTextureLoader.js.map +1 -1
  363. package/Materials/Textures/Loaders/tgaTextureLoader.js +1 -0
  364. package/Materials/Textures/Loaders/tgaTextureLoader.js.map +1 -1
  365. package/Materials/Textures/Packer/packer.d.ts +0 -1
  366. package/Materials/Textures/Packer/packer.js +0 -1
  367. package/Materials/Textures/Packer/packer.js.map +1 -1
  368. package/Materials/Textures/Procedurals/noiseProceduralTexture.d.ts +1 -1
  369. package/Materials/Textures/Procedurals/noiseProceduralTexture.js +1 -1
  370. package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
  371. package/Materials/Textures/baseTexture.js +3 -0
  372. package/Materials/Textures/baseTexture.js.map +1 -1
  373. package/Materials/Textures/colorGradingTexture.d.ts +4 -1
  374. package/Materials/Textures/colorGradingTexture.js +4 -1
  375. package/Materials/Textures/colorGradingTexture.js.map +1 -1
  376. package/Materials/Textures/equiRectangularCubeTexture.d.ts +1 -0
  377. package/Materials/Textures/equiRectangularCubeTexture.js +1 -0
  378. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  379. package/Materials/Textures/hdrCubeTexture.d.ts +3 -2
  380. package/Materials/Textures/hdrCubeTexture.js +3 -2
  381. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  382. package/Materials/Textures/htmlElementTexture.d.ts +1 -1
  383. package/Materials/Textures/htmlElementTexture.js +1 -1
  384. package/Materials/Textures/htmlElementTexture.js.map +1 -1
  385. package/Materials/Textures/multiRenderTarget.d.ts +1 -1
  386. package/Materials/Textures/multiRenderTarget.js +1 -1
  387. package/Materials/Textures/multiRenderTarget.js.map +1 -1
  388. package/Materials/Textures/texture.d.ts +4 -1
  389. package/Materials/Textures/texture.js +4 -1
  390. package/Materials/Textures/texture.js.map +1 -1
  391. package/Materials/Textures/thinRenderTargetTexture.d.ts +1 -1
  392. package/Materials/Textures/thinRenderTargetTexture.js +1 -1
  393. package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
  394. package/Materials/Textures/thinTexture.js +3 -0
  395. package/Materials/Textures/thinTexture.js.map +1 -1
  396. package/Materials/index.d.ts +1 -0
  397. package/Materials/index.js +1 -0
  398. package/Materials/index.js.map +1 -1
  399. package/Materials/material.d.ts +2 -1
  400. package/Materials/material.decalMapConfiguration.d.ts +0 -5
  401. package/Materials/material.decalMapConfiguration.js +5 -5
  402. package/Materials/material.decalMapConfiguration.js.map +1 -1
  403. package/Materials/material.js +3 -2
  404. package/Materials/material.js.map +1 -1
  405. package/Materials/materialHelper.d.ts +1 -1
  406. package/Materials/materialHelper.js +4 -3
  407. package/Materials/materialHelper.js.map +1 -1
  408. package/Materials/materialPluginManager.js +1 -0
  409. package/Materials/materialPluginManager.js.map +1 -1
  410. package/Materials/standardMaterial.d.ts +2 -2
  411. package/Materials/standardMaterial.js +3 -3
  412. package/Materials/standardMaterial.js.map +1 -1
  413. package/Materials/uniformBuffer.js +2 -1
  414. package/Materials/uniformBuffer.js.map +1 -1
  415. package/Maths/math.like.d.ts +3 -0
  416. package/Maths/math.like.js.map +1 -1
  417. package/Maths/math.path.d.ts +2 -1
  418. package/Maths/math.path.js +2 -1
  419. package/Maths/math.path.js.map +1 -1
  420. package/Maths/math.polar.d.ts +3 -2
  421. package/Maths/math.polar.js +8 -2
  422. package/Maths/math.polar.js.map +1 -1
  423. package/Maths/math.vector.d.ts +12 -5
  424. package/Maths/math.vector.js +12 -5
  425. package/Maths/math.vector.js.map +1 -1
  426. package/Meshes/Builders/hemisphereBuilder.js +1 -0
  427. package/Meshes/Builders/hemisphereBuilder.js.map +1 -1
  428. package/Meshes/Builders/textBuilder.d.ts +26 -5
  429. package/Meshes/Builders/textBuilder.js +26 -5
  430. package/Meshes/Builders/textBuilder.js.map +1 -1
  431. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +84 -0
  432. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +288 -0
  433. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -0
  434. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +2 -0
  435. package/Meshes/GreasedLine/greasedLineBaseMesh.js +2 -0
  436. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
  437. package/Meshes/GreasedLine/greasedLineRibbonMesh.d.ts +2 -0
  438. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +9 -0
  439. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  440. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -1
  441. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
  442. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  443. package/Meshes/Node/Blocks/geometryCurveBlock.d.ts +92 -0
  444. package/Meshes/Node/Blocks/geometryCurveBlock.js +292 -0
  445. package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -0
  446. package/Meshes/Node/Blocks/noiseBlock.d.ts +5 -3
  447. package/Meshes/Node/Blocks/noiseBlock.js +5 -3
  448. package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
  449. package/Meshes/Node/index.d.ts +1 -0
  450. package/Meshes/Node/index.js +1 -0
  451. package/Meshes/Node/index.js.map +1 -1
  452. package/Meshes/Node/nodeGeometry.d.ts +6 -2
  453. package/Meshes/Node/nodeGeometry.js +7 -2
  454. package/Meshes/Node/nodeGeometry.js.map +1 -1
  455. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +1 -0
  456. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  457. package/Meshes/Node/nodeGeometryBuildState.js +1 -0
  458. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  459. package/Meshes/abstractMesh.d.ts +1 -0
  460. package/Meshes/abstractMesh.js +3 -0
  461. package/Meshes/abstractMesh.js.map +1 -1
  462. package/Meshes/csg.d.ts +7 -1
  463. package/Meshes/csg.js +9 -1
  464. package/Meshes/csg.js.map +1 -1
  465. package/Meshes/geodesicMesh.d.ts +32 -1
  466. package/Meshes/geodesicMesh.js +17 -1
  467. package/Meshes/geodesicMesh.js.map +1 -1
  468. package/Meshes/index.d.ts +1 -0
  469. package/Meshes/index.js +1 -0
  470. package/Meshes/index.js.map +1 -1
  471. package/Meshes/instancedMesh.d.ts +34 -17
  472. package/Meshes/instancedMesh.js +34 -17
  473. package/Meshes/instancedMesh.js.map +1 -1
  474. package/Meshes/linesMesh.d.ts +6 -5
  475. package/Meshes/linesMesh.js +6 -5
  476. package/Meshes/linesMesh.js.map +1 -1
  477. package/Meshes/mesh.d.ts +1 -0
  478. package/Meshes/mesh.js +1 -0
  479. package/Meshes/mesh.js.map +1 -1
  480. package/Meshes/mesh.vertexData.d.ts +0 -145
  481. package/Meshes/mesh.vertexData.js +0 -145
  482. package/Meshes/mesh.vertexData.js.map +1 -1
  483. package/Meshes/transformNode.d.ts +1 -1
  484. package/Meshes/transformNode.js +19 -1
  485. package/Meshes/transformNode.js.map +1 -1
  486. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +1 -0
  487. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +1 -0
  488. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  489. package/Misc/HighDynamicRange/hdr.d.ts +1 -0
  490. package/Misc/HighDynamicRange/hdr.js +8 -0
  491. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  492. package/Misc/HighDynamicRange/panoramaToCubemap.d.ts +1 -0
  493. package/Misc/HighDynamicRange/panoramaToCubemap.js +3 -0
  494. package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
  495. package/Misc/assetsManager.d.ts +3 -0
  496. package/Misc/assetsManager.js +3 -0
  497. package/Misc/assetsManager.js.map +1 -1
  498. package/Misc/basis.js +1 -0
  499. package/Misc/basis.js.map +1 -1
  500. package/Misc/decorators.d.ts +2 -0
  501. package/Misc/decorators.js +3 -1
  502. package/Misc/decorators.js.map +1 -1
  503. package/Misc/fileTools.js +2 -0
  504. package/Misc/fileTools.js.map +1 -1
  505. package/Misc/filesInput.d.ts +7 -2
  506. package/Misc/filesInput.js +7 -2
  507. package/Misc/filesInput.js.map +1 -1
  508. package/Misc/greasedLineTools.d.ts +6 -1
  509. package/Misc/greasedLineTools.js +6 -1
  510. package/Misc/greasedLineTools.js.map +1 -1
  511. package/Misc/textureTools.d.ts +2 -0
  512. package/Misc/textureTools.js +2 -0
  513. package/Misc/textureTools.js.map +1 -1
  514. package/Misc/timer.d.ts +2 -1
  515. package/Misc/timer.js +1 -0
  516. package/Misc/timer.js.map +1 -1
  517. package/Misc/tools.d.ts +5 -1
  518. package/Misc/tools.js +9 -1
  519. package/Misc/tools.js.map +1 -1
  520. package/Misc/videoRecorder.d.ts +4 -1
  521. package/Misc/videoRecorder.js +11 -5
  522. package/Misc/videoRecorder.js.map +1 -1
  523. package/Misc/webRequest.d.ts +3 -0
  524. package/Misc/webRequest.js +4 -1
  525. package/Misc/webRequest.js.map +1 -1
  526. package/Morph/morphTargetManager.d.ts +11 -0
  527. package/Morph/morphTargetManager.js +22 -2
  528. package/Morph/morphTargetManager.js.map +1 -1
  529. package/Particles/EmitterTypes/customParticleEmitter.js +10 -2
  530. package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
  531. package/Particles/EmitterTypes/cylinderParticleEmitter.d.ts +3 -1
  532. package/Particles/EmitterTypes/cylinderParticleEmitter.js +7 -1
  533. package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
  534. package/Particles/IParticleSystem.d.ts +2 -2
  535. package/Particles/IParticleSystem.js.map +1 -1
  536. package/Particles/gpuParticleSystem.js +1 -0
  537. package/Particles/gpuParticleSystem.js.map +1 -1
  538. package/Particles/particleSystem.d.ts +1 -2
  539. package/Particles/particleSystem.js +5 -1
  540. package/Particles/particleSystem.js.map +1 -1
  541. package/Particles/solidParticleSystem.d.ts +1 -1
  542. package/Particles/solidParticleSystem.js +1 -1
  543. package/Particles/solidParticleSystem.js.map +1 -1
  544. package/Physics/physicsHelper.d.ts +3 -2
  545. package/Physics/physicsHelper.js +5 -4
  546. package/Physics/physicsHelper.js.map +1 -1
  547. package/Physics/physicsRaycastResult.d.ts +2 -1
  548. package/Physics/physicsRaycastResult.js +2 -1
  549. package/Physics/physicsRaycastResult.js.map +1 -1
  550. package/Physics/v1/Plugins/ammoJSPlugin.d.ts +5 -0
  551. package/Physics/v1/Plugins/ammoJSPlugin.js +6 -0
  552. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -1
  553. package/Physics/v1/physicsEngine.d.ts +2 -0
  554. package/Physics/v1/physicsEngine.js +2 -0
  555. package/Physics/v1/physicsEngine.js.map +1 -1
  556. package/Physics/v1/physicsImpostor.d.ts +2 -3
  557. package/Physics/v1/physicsImpostor.js +2 -3
  558. package/Physics/v1/physicsImpostor.js.map +1 -1
  559. package/Physics/v2/IPhysicsEnginePlugin.d.ts +1 -0
  560. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  561. package/Physics/v2/Plugins/havokPlugin.d.ts +61 -10
  562. package/Physics/v2/Plugins/havokPlugin.js +89 -10
  563. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  564. package/Physics/v2/physicsBody.d.ts +41 -3
  565. package/Physics/v2/physicsBody.js +42 -9
  566. package/Physics/v2/physicsBody.js.map +1 -1
  567. package/Physics/v2/physicsConstraint.d.ts +0 -2
  568. package/Physics/v2/physicsConstraint.js +0 -2
  569. package/Physics/v2/physicsConstraint.js.map +1 -1
  570. package/Physics/v2/physicsEngine.d.ts +5 -3
  571. package/Physics/v2/physicsEngine.js +6 -3
  572. package/Physics/v2/physicsEngine.js.map +1 -1
  573. package/Physics/v2/physicsShape.d.ts +2 -0
  574. package/Physics/v2/physicsShape.js +5 -0
  575. package/Physics/v2/physicsShape.js.map +1 -1
  576. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.d.ts +1 -1
  577. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js +1 -1
  578. package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
  579. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.d.ts +1 -1
  580. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js +1 -1
  581. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
  582. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +1 -1
  583. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +1 -1
  584. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  585. package/PostProcesses/motionBlurPostProcess.d.ts +1 -0
  586. package/PostProcesses/motionBlurPostProcess.js +1 -0
  587. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  588. package/PostProcesses/postProcess.d.ts +0 -1
  589. package/PostProcesses/postProcess.js +0 -1
  590. package/PostProcesses/postProcess.js.map +1 -1
  591. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +1 -1
  592. package/PostProcesses/volumetricLightScatteringPostProcess.js +1 -1
  593. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  594. package/Rendering/GlobalIllumination/giRSMManager.d.ts +2 -1
  595. package/Rendering/GlobalIllumination/giRSMManager.js +5 -2
  596. package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
  597. package/Rendering/depthRendererSceneComponent.js +1 -0
  598. package/Rendering/depthRendererSceneComponent.js.map +1 -1
  599. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +1 -1
  600. package/Rendering/fluidRenderer/fluidRenderingObject.js +1 -1
  601. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
  602. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +1 -1
  603. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +1 -1
  604. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
  605. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +1 -1
  606. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +1 -1
  607. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
  608. package/Rendering/geometryBufferRenderer.d.ts +2 -2
  609. package/Rendering/geometryBufferRenderer.js +2 -2
  610. package/Rendering/geometryBufferRenderer.js.map +1 -1
  611. package/Rendering/index.d.ts +0 -1
  612. package/Rendering/index.js +0 -1
  613. package/Rendering/index.js.map +1 -1
  614. package/Rendering/prePassRenderer.d.ts +2 -2
  615. package/Rendering/prePassRenderer.js +2 -2
  616. package/Rendering/prePassRenderer.js.map +1 -1
  617. package/Rendering/reflectiveShadowMap.d.ts +4 -0
  618. package/Rendering/reflectiveShadowMap.js +7 -0
  619. package/Rendering/reflectiveShadowMap.js.map +1 -1
  620. package/Rendering/renderingGroup.d.ts +0 -1
  621. package/Rendering/renderingGroup.js +3 -4
  622. package/Rendering/renderingGroup.js.map +1 -1
  623. package/Rendering/renderingManager.d.ts +2 -1
  624. package/Rendering/renderingManager.js +2 -1
  625. package/Rendering/renderingManager.js.map +1 -1
  626. package/Rendering/subSurfaceConfiguration.d.ts +1 -0
  627. package/Rendering/subSurfaceConfiguration.js +1 -0
  628. package/Rendering/subSurfaceConfiguration.js.map +1 -1
  629. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.d.ts +7 -0
  630. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +13 -0
  631. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -0
  632. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.d.ts +5 -0
  633. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +10 -0
  634. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -0
  635. package/Shaders/ShadersInclude/morphTargetsVertex.js +8 -5
  636. package/Shaders/ShadersInclude/morphTargetsVertex.js.map +1 -1
  637. package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +2 -0
  638. package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
  639. package/Shaders/gaussianSplatting.fragment.d.ts +11 -0
  640. package/Shaders/gaussianSplatting.fragment.js +27 -0
  641. package/Shaders/gaussianSplatting.fragment.js.map +1 -0
  642. package/Shaders/gaussianSplatting.vertex.d.ts +13 -0
  643. package/Shaders/gaussianSplatting.vertex.js +49 -0
  644. package/Shaders/gaussianSplatting.vertex.js.map +1 -0
  645. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js +5 -1
  646. package/ShadersWGSL/ShadersInclude/morphTargetsVertex.js.map +1 -1
  647. package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +2 -0
  648. package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
  649. package/XR/features/WebXRAbstractFeature.d.ts +7 -1
  650. package/XR/features/WebXRAbstractFeature.js +20 -4
  651. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  652. package/XR/features/WebXRAnchorSystem.d.ts +1 -0
  653. package/XR/features/WebXRAnchorSystem.js +1 -0
  654. package/XR/features/WebXRAnchorSystem.js.map +1 -1
  655. package/XR/features/WebXRControllerTeleportation.js +9 -2
  656. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  657. package/XR/features/WebXRDepthSensing.d.ts +1 -1
  658. package/XR/features/WebXRDepthSensing.js +1 -1
  659. package/XR/features/WebXRDepthSensing.js.map +1 -1
  660. package/XR/features/WebXREyeTracking.js +1 -1
  661. package/XR/features/WebXREyeTracking.js.map +1 -1
  662. package/XR/features/WebXRHandTracking.d.ts +4 -1
  663. package/XR/features/WebXRHandTracking.js +18 -4
  664. package/XR/features/WebXRHandTracking.js.map +1 -1
  665. package/XR/features/WebXRHitTest.js +1 -1
  666. package/XR/features/WebXRHitTest.js.map +1 -1
  667. package/XR/features/WebXRNearInteraction.d.ts +6 -3
  668. package/XR/features/WebXRNearInteraction.js +9 -4
  669. package/XR/features/WebXRNearInteraction.js.map +1 -1
  670. package/XR/features/WebXRPlaneDetector.d.ts +2 -0
  671. package/XR/features/WebXRPlaneDetector.js +2 -0
  672. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  673. package/XR/features/WebXRRawCameraAccess.d.ts +2 -0
  674. package/XR/features/WebXRRawCameraAccess.js +2 -0
  675. package/XR/features/WebXRRawCameraAccess.js.map +1 -1
  676. package/XR/features/WebXRSpaceWarp.d.ts +0 -27
  677. package/XR/features/WebXRSpaceWarp.js +0 -27
  678. package/XR/features/WebXRSpaceWarp.js.map +1 -1
  679. package/XR/index.d.ts +1 -0
  680. package/XR/index.js +1 -0
  681. package/XR/index.js.map +1 -1
  682. package/XR/motionController/webXROculusTouchMotionController.d.ts +1 -0
  683. package/XR/motionController/webXROculusTouchMotionController.js +1 -0
  684. package/XR/motionController/webXROculusTouchMotionController.js.map +1 -1
  685. package/XR/webXRCamera.d.ts +2 -0
  686. package/XR/webXRCamera.js +8 -6
  687. package/XR/webXRCamera.js.map +1 -1
  688. package/XR/webXRExperienceHelper.js +1 -0
  689. package/XR/webXRExperienceHelper.js.map +1 -1
  690. package/XR/webXRInput.js +1 -1
  691. package/XR/webXRInput.js.map +1 -1
  692. package/XR/webXRInputSource.d.ts +3 -1
  693. package/XR/webXRInputSource.js +6 -3
  694. package/XR/webXRInputSource.js.map +1 -1
  695. package/XR/webXRSessionManager.d.ts +13 -0
  696. package/XR/webXRSessionManager.js +21 -1
  697. package/XR/webXRSessionManager.js.map +1 -1
  698. package/assetContainer.d.ts +5 -2
  699. package/assetContainer.js +5 -2
  700. package/assetContainer.js.map +1 -1
  701. package/package.json +1 -1
  702. package/scene.d.ts +1 -0
  703. package/scene.js +11 -0
  704. package/scene.js.map +1 -1
  705. package/Rendering/GaussianSplatting/gaussianSplatting.d.ts +0 -81
  706. package/Rendering/GaussianSplatting/gaussianSplatting.js +0 -400
  707. package/Rendering/GaussianSplatting/gaussianSplatting.js.map +0 -1
  708. package/Rendering/GaussianSplatting/index.d.ts +0 -1
  709. package/Rendering/GaussianSplatting/index.js +0 -2
  710. package/Rendering/GaussianSplatting/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"filesInput.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/filesInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,OAAO,eAAe,CAAC,WAAW,CAAC;IACvC,CAAC;IAiCD;;;;;;;;;;;;OAYG;IACH,YACI,MAAc,EACd,KAAsB,EACtB,mBAAsE,EACtE,gBAAyE,EACzE,iCAAu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c,EAAE;oBACrB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACjF;YACL,CAAC,CAAC,CAAC;SACV;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;SACzD;IACL,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ISceneLoaderProgressEvent } from \"../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../Loading/sceneLoader\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport type { Nullable } from \"../types\";\r\n\r\n/**\r\n * Class used to help managing file picking and drag-n-drop\r\n */\r\nexport class FilesInput {\r\n /**\r\n * List of files ready to be loaded\r\n */\r\n public static get FilesToLoad() {\r\n return FilesInputStore.FilesToLoad;\r\n }\r\n\r\n /**\r\n * Callback called when a file is processed\r\n */\r\n public onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean = () => {\r\n return true;\r\n };\r\n\r\n public displayLoadingUI: boolean = true;\r\n\r\n /**\r\n * Function used when loading the scene file\r\n * @param sceneFile\r\n * @param onProgress\r\n */\r\n public loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene> = (sceneFile, onProgress) =>\r\n this.useAppend ? SceneLoader.AppendAsync(\"file:\", sceneFile, this._currentScene, onProgress) : SceneLoader.LoadAsync(\"file:\", sceneFile, this._engine, onProgress);\r\n\r\n private _engine: Engine;\r\n private _currentScene: Nullable<Scene>;\r\n private _sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>;\r\n private _progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>;\r\n private _additionalRenderLoopLogicCallback: Nullable<() => void>;\r\n private _textureLoadingCallback: Nullable<(remaining: number) => void>;\r\n private _startingProcessingFilesCallback: Nullable<(files?: File[]) => void>;\r\n private _onReloadCallback: Nullable<(sceneFile: File) => void>;\r\n private _errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>;\r\n private _elementToMonitor: HTMLElement;\r\n\r\n private _sceneFileToLoad: File;\r\n private _filesToLoad: File[];\r\n\r\n /**\r\n * Creates a new FilesInput\r\n * @param engine defines the rendering engine\r\n * @param scene defines the hosting scene\r\n * @param sceneLoadedCallback callback called when scene (files provided) is loaded\r\n * @param progressCallback callback called to track progress\r\n * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop\r\n * @param textureLoadingCallback callback called when a texture is loading\r\n * @param startingProcessingFilesCallback callback called when the system is about to process all files\r\n * @param onReloadCallback callback called when a reload is requested\r\n * @param errorCallback callback call if an error occurs\r\n * @param useAppend defines if the file loaded must be appended (true) or have the scene replaced (false, default behavior)\r\n */\r\n constructor(\r\n engine: Engine,\r\n scene: Nullable<Scene>,\r\n sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>,\r\n progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>,\r\n additionalRenderLoopLogicCallback: Nullable<() => void>,\r\n textureLoadingCallback: Nullable<(remaining: number) => void>,\r\n startingProcessingFilesCallback: Nullable<(files?: File[]) => void>,\r\n onReloadCallback: Nullable<(sceneFile: File) => void>,\r\n errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>,\r\n public readonly useAppend = false\r\n ) {\r\n this._engine = engine;\r\n this._currentScene = scene;\r\n\r\n this._sceneLoadedCallback = sceneLoadedCallback;\r\n this._progressCallback = progressCallback;\r\n this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;\r\n this._textureLoadingCallback = textureLoadingCallback;\r\n this._startingProcessingFilesCallback = startingProcessingFilesCallback;\r\n this._onReloadCallback = onReloadCallback;\r\n this._errorCallback = errorCallback;\r\n }\r\n\r\n private _dragEnterHandler: (e: any) => void;\r\n private _dragOverHandler: (e: any) => void;\r\n private _dropHandler: (e: any) => void;\r\n\r\n /**\r\n * Calls this function to listen to drag'n'drop events on a specific DOM element\r\n * @param elementToMonitor defines the DOM element to track\r\n */\r\n public monitorElementForDragNDrop(elementToMonitor: HTMLElement): void {\r\n if (elementToMonitor) {\r\n this._elementToMonitor = elementToMonitor;\r\n\r\n this._dragEnterHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dragOverHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dropHandler = (e) => {\r\n this._drop(e);\r\n };\r\n\r\n this._elementToMonitor.addEventListener(\"dragenter\", this._dragEnterHandler, false);\r\n this._elementToMonitor.addEventListener(\"dragover\", this._dragOverHandler, false);\r\n this._elementToMonitor.addEventListener(\"drop\", this._dropHandler, false);\r\n }\r\n }\r\n\r\n /** Gets the current list of files to load */\r\n public get filesToLoad() {\r\n return this._filesToLoad;\r\n }\r\n\r\n /**\r\n * Release all associated resources\r\n */\r\n public dispose() {\r\n if (!this._elementToMonitor) {\r\n return;\r\n }\r\n\r\n this._elementToMonitor.removeEventListener(\"dragenter\", this._dragEnterHandler);\r\n this._elementToMonitor.removeEventListener(\"dragover\", this._dragOverHandler);\r\n this._elementToMonitor.removeEventListener(\"drop\", this._dropHandler);\r\n }\r\n\r\n private _renderFunction(): void {\r\n if (this._additionalRenderLoopLogicCallback) {\r\n this._additionalRenderLoopLogicCallback();\r\n }\r\n\r\n if (this._currentScene) {\r\n if (this._textureLoadingCallback) {\r\n const remaining = this._currentScene.getWaitingItemsCount();\r\n\r\n if (remaining > 0) {\r\n this._textureLoadingCallback(remaining);\r\n }\r\n }\r\n this._currentScene.render();\r\n }\r\n }\r\n\r\n private _drag(e: DragEvent): void {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n }\r\n\r\n private _drop(eventDrop: DragEvent): void {\r\n eventDrop.stopPropagation();\r\n eventDrop.preventDefault();\r\n\r\n this.loadFiles(eventDrop);\r\n }\r\n\r\n private _traverseFolder(folder: any, files: Array<any>, remaining: { count: number }, callback: () => void) {\r\n const reader = folder.createReader();\r\n const relativePath = folder.fullPath.replace(/^\\//, \"\").replace(/(.+?)\\/?$/, \"$1/\");\r\n reader.readEntries((entries: any) => {\r\n remaining.count += entries.length;\r\n for (const entry of entries) {\r\n if (entry.isFile) {\r\n entry.file((file: any) => {\r\n file.correctName = relativePath + file.name;\r\n files.push(file);\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n } else if (entry.isDirectory) {\r\n this._traverseFolder(entry, files, remaining, callback);\r\n }\r\n }\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n }\r\n\r\n private _processFiles(files: Array<any>): void {\r\n for (let i = 0; i < files.length; i++) {\r\n const name = files[i].correctName.toLowerCase();\r\n const extension = name.split(\".\").pop();\r\n\r\n if (!this.onProcessFileCallback(files[i], name, extension, (sceneFile) => (this._sceneFileToLoad = sceneFile))) {\r\n continue;\r\n }\r\n\r\n if (SceneLoader.IsPluginForExtensionAvailable(\".\" + extension)) {\r\n this._sceneFileToLoad = files[i];\r\n }\r\n\r\n FilesInput.FilesToLoad[name] = files[i];\r\n }\r\n }\r\n\r\n /**\r\n * Load files from a drop event\r\n * @param event defines the drop event to use as source\r\n */\r\n public loadFiles(event: any): void {\r\n // Handling data transfer via drag'n'drop\r\n if (event && event.dataTransfer && event.dataTransfer.files) {\r\n this._filesToLoad = event.dataTransfer.files;\r\n }\r\n\r\n // Handling files from input files\r\n if (event && event.target && event.target.files) {\r\n this._filesToLoad = event.target.files;\r\n }\r\n\r\n if (!this._filesToLoad || this._filesToLoad.length === 0) {\r\n return;\r\n }\r\n\r\n if (this._startingProcessingFilesCallback) {\r\n this._startingProcessingFilesCallback(this._filesToLoad);\r\n }\r\n\r\n if (this._filesToLoad && this._filesToLoad.length > 0) {\r\n const files: File[] = [];\r\n const folders = [];\r\n const items = event.dataTransfer ? event.dataTransfer.items : null;\r\n\r\n for (let i = 0; i < this._filesToLoad.length; i++) {\r\n const fileToLoad: any = this._filesToLoad[i];\r\n const name = fileToLoad.name.toLowerCase();\r\n let entry;\r\n\r\n fileToLoad.correctName = name;\r\n\r\n if (items) {\r\n const item = items[i];\r\n if (item.getAsEntry) {\r\n entry = item.getAsEntry();\r\n } else if (item.webkitGetAsEntry) {\r\n entry = item.webkitGetAsEntry();\r\n }\r\n }\r\n\r\n if (!entry) {\r\n files.push(fileToLoad);\r\n } else {\r\n if (entry.isDirectory) {\r\n folders.push(entry);\r\n } else {\r\n files.push(fileToLoad);\r\n }\r\n }\r\n }\r\n\r\n if (folders.length === 0) {\r\n this._processFiles(files);\r\n this._processReload();\r\n } else {\r\n const remaining = { count: folders.length };\r\n for (const folder of folders) {\r\n this._traverseFolder(folder, files, remaining, () => {\r\n this._processFiles(files);\r\n\r\n if (remaining.count === 0) {\r\n this._processReload();\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _processReload() {\r\n if (this._onReloadCallback) {\r\n this._onReloadCallback(this._sceneFileToLoad);\r\n } else {\r\n this.reload();\r\n }\r\n }\r\n\r\n /**\r\n * Reload the current scene from the loaded files\r\n */\r\n public reload() {\r\n // If a scene file has been provided\r\n if (this._sceneFileToLoad) {\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n if (Logger.errorsCount > 0) {\r\n Logger.ClearLogCache();\r\n }\r\n this._engine.stopRenderLoop();\r\n }\r\n }\r\n\r\n SceneLoader.ShowLoadingScreen = false;\r\n if (this.displayLoadingUI) {\r\n this._engine.displayLoadingUI();\r\n }\r\n\r\n this.loadAsync(this._sceneFileToLoad, this._progressCallback)\r\n .then((scene) => {\r\n // if appending do nothing\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n this._currentScene.dispose();\r\n }\r\n\r\n this._currentScene = scene;\r\n\r\n // Wait for textures and shaders to be ready\r\n this._currentScene.executeWhenReady(() => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n this._engine.runRenderLoop(() => {\r\n this._renderFunction();\r\n });\r\n });\r\n } else {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n }\r\n if (this._sceneLoadedCallback && this._currentScene) {\r\n this._sceneLoadedCallback(this._sceneFileToLoad, this._currentScene);\r\n }\r\n })\r\n .catch((error) => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n if (this._errorCallback) {\r\n this._errorCallback(this._sceneFileToLoad, this._currentScene, error.message);\r\n }\r\n });\r\n } else {\r\n Logger.Error(\"Please provide a valid .babylon file.\");\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"filesInput.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/filesInput.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;OAEG;IACI,MAAM,KAAK,WAAW;QACzB,OAAO,eAAe,CAAC,WAAW,CAAC;IACvC,CAAC;IAsCD;;;;;;;;;;;;OAYG;IACH,YACI,MAAc,EACd,KAAsB,EACtB,mBAAsE,EACtE,gBAAyE,EACzE,iCAAuD,EACvD,sBAA6D,EAC7D,+BAAmE,EACnE,gBAAqD,EACrD,aAA2F,EAC3E,YAAY,KAAK;QAAjB,cAAS,GAAT,SAAS,CAAQ;QA3DrC;;;WAGG;QACI,0BAAqB,GAA4G,GAAG,EAAE;YACzI,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF;;WAEG;QACI,qBAAgB,GAAY,IAAI,CAAC;QAExC;;;;;WAKG;QACI,cAAS,GAA0G,CAAC,SAAS,EAAE,UAAU,EAAE,EAAE,CAChJ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,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C,aAAa,CAAC,OAAO,EAAE,CAAC;qBAChC;oBAED,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;oBAE3B,4CAA4C;oBAC5C,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE;wBACrC,IAAI,IAAI,CAAC,gBAAgB,EAAE;4BACvB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;yBAChC;wBACD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE;4BAC5B,IAAI,CAAC,eAAe,EAAE,CAAC;wBAC3B,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;iBACN;qBAAM;oBACH,IAAI,IAAI,CAAC,gBAAgB,EAAE;wBACvB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;qBAChC;iBACJ;gBACD,IAAI,IAAI,CAAC,oBAAoB,IAAI,IAAI,CAAC,aAAa,EAAE;oBACjD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;iBACxE;YACL,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACb,IAAI,IAAI,CAAC,gBAAgB,EAAE;oBACvB,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;iBAChC;gBACD,IAAI,IAAI,CAAC,cAAc,EAAE;oBACrB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;iBACjF;YACL,CAAC,CAAC,CAAC;SACV;aAAM;YACH,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;SACzD;IACL,CAAC;CACJ","sourcesContent":["import type { Engine } from \"../Engines/engine\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ISceneLoaderProgressEvent } from \"../Loading/sceneLoader\";\r\nimport { SceneLoader } from \"../Loading/sceneLoader\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport type { Nullable } from \"../types\";\r\n\r\n/**\r\n * Class used to help managing file picking and drag-n-drop\r\n */\r\nexport class FilesInput {\r\n /**\r\n * List of files ready to be loaded\r\n */\r\n public static get FilesToLoad() {\r\n return FilesInputStore.FilesToLoad;\r\n }\r\n\r\n /**\r\n * Callback called when a file is processed\r\n * @returns false to abort the process\r\n */\r\n public onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean = () => {\r\n return true;\r\n };\r\n\r\n /**\r\n * If a loading UI should be displayed while loading a file\r\n */\r\n public displayLoadingUI: boolean = true;\r\n\r\n /**\r\n * Function used when loading the scene file\r\n * @param sceneFile defines the file to load\r\n * @param onProgress onProgress callback called while loading the file\r\n * @returns a promise completing when the load is complete\r\n */\r\n public loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene> = (sceneFile, onProgress) =>\r\n this.useAppend ? SceneLoader.AppendAsync(\"file:\", sceneFile, this._currentScene, onProgress) : SceneLoader.LoadAsync(\"file:\", sceneFile, this._engine, onProgress);\r\n\r\n private _engine: Engine;\r\n private _currentScene: Nullable<Scene>;\r\n private _sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>;\r\n private _progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>;\r\n private _additionalRenderLoopLogicCallback: Nullable<() => void>;\r\n private _textureLoadingCallback: Nullable<(remaining: number) => void>;\r\n private _startingProcessingFilesCallback: Nullable<(files?: File[]) => void>;\r\n private _onReloadCallback: Nullable<(sceneFile: File) => void>;\r\n private _errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>;\r\n private _elementToMonitor: HTMLElement;\r\n\r\n private _sceneFileToLoad: File;\r\n private _filesToLoad: File[];\r\n\r\n /**\r\n * Creates a new FilesInput\r\n * @param engine defines the rendering engine\r\n * @param scene defines the hosting scene\r\n * @param sceneLoadedCallback callback called when scene (files provided) is loaded\r\n * @param progressCallback callback called to track progress\r\n * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop\r\n * @param textureLoadingCallback callback called when a texture is loading\r\n * @param startingProcessingFilesCallback callback called when the system is about to process all files\r\n * @param onReloadCallback callback called when a reload is requested\r\n * @param errorCallback callback call if an error occurs\r\n * @param useAppend defines if the file loaded must be appended (true) or have the scene replaced (false, default behavior)\r\n */\r\n constructor(\r\n engine: Engine,\r\n scene: Nullable<Scene>,\r\n sceneLoadedCallback: Nullable<(sceneFile: File, scene: Scene) => void>,\r\n progressCallback: Nullable<(progress: ISceneLoaderProgressEvent) => void>,\r\n additionalRenderLoopLogicCallback: Nullable<() => void>,\r\n textureLoadingCallback: Nullable<(remaining: number) => void>,\r\n startingProcessingFilesCallback: Nullable<(files?: File[]) => void>,\r\n onReloadCallback: Nullable<(sceneFile: File) => void>,\r\n errorCallback: Nullable<(sceneFile: File, scene: Nullable<Scene>, message: string) => void>,\r\n public readonly useAppend = false\r\n ) {\r\n this._engine = engine;\r\n this._currentScene = scene;\r\n\r\n this._sceneLoadedCallback = sceneLoadedCallback;\r\n this._progressCallback = progressCallback;\r\n this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;\r\n this._textureLoadingCallback = textureLoadingCallback;\r\n this._startingProcessingFilesCallback = startingProcessingFilesCallback;\r\n this._onReloadCallback = onReloadCallback;\r\n this._errorCallback = errorCallback;\r\n }\r\n\r\n private _dragEnterHandler: (e: any) => void;\r\n private _dragOverHandler: (e: any) => void;\r\n private _dropHandler: (e: any) => void;\r\n\r\n /**\r\n * Calls this function to listen to drag'n'drop events on a specific DOM element\r\n * @param elementToMonitor defines the DOM element to track\r\n */\r\n public monitorElementForDragNDrop(elementToMonitor: HTMLElement): void {\r\n if (elementToMonitor) {\r\n this._elementToMonitor = elementToMonitor;\r\n\r\n this._dragEnterHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dragOverHandler = (e) => {\r\n this._drag(e);\r\n };\r\n this._dropHandler = (e) => {\r\n this._drop(e);\r\n };\r\n\r\n this._elementToMonitor.addEventListener(\"dragenter\", this._dragEnterHandler, false);\r\n this._elementToMonitor.addEventListener(\"dragover\", this._dragOverHandler, false);\r\n this._elementToMonitor.addEventListener(\"drop\", this._dropHandler, false);\r\n }\r\n }\r\n\r\n /** Gets the current list of files to load */\r\n public get filesToLoad() {\r\n return this._filesToLoad;\r\n }\r\n\r\n /**\r\n * Release all associated resources\r\n */\r\n public dispose() {\r\n if (!this._elementToMonitor) {\r\n return;\r\n }\r\n\r\n this._elementToMonitor.removeEventListener(\"dragenter\", this._dragEnterHandler);\r\n this._elementToMonitor.removeEventListener(\"dragover\", this._dragOverHandler);\r\n this._elementToMonitor.removeEventListener(\"drop\", this._dropHandler);\r\n }\r\n\r\n private _renderFunction(): void {\r\n if (this._additionalRenderLoopLogicCallback) {\r\n this._additionalRenderLoopLogicCallback();\r\n }\r\n\r\n if (this._currentScene) {\r\n if (this._textureLoadingCallback) {\r\n const remaining = this._currentScene.getWaitingItemsCount();\r\n\r\n if (remaining > 0) {\r\n this._textureLoadingCallback(remaining);\r\n }\r\n }\r\n this._currentScene.render();\r\n }\r\n }\r\n\r\n private _drag(e: DragEvent): void {\r\n e.stopPropagation();\r\n e.preventDefault();\r\n }\r\n\r\n private _drop(eventDrop: DragEvent): void {\r\n eventDrop.stopPropagation();\r\n eventDrop.preventDefault();\r\n\r\n this.loadFiles(eventDrop);\r\n }\r\n\r\n private _traverseFolder(folder: any, files: Array<any>, remaining: { count: number }, callback: () => void) {\r\n const reader = folder.createReader();\r\n const relativePath = folder.fullPath.replace(/^\\//, \"\").replace(/(.+?)\\/?$/, \"$1/\");\r\n reader.readEntries((entries: any) => {\r\n remaining.count += entries.length;\r\n for (const entry of entries) {\r\n if (entry.isFile) {\r\n entry.file((file: any) => {\r\n file.correctName = relativePath + file.name;\r\n files.push(file);\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n } else if (entry.isDirectory) {\r\n this._traverseFolder(entry, files, remaining, callback);\r\n }\r\n }\r\n\r\n if (--remaining.count === 0) {\r\n callback();\r\n }\r\n });\r\n }\r\n\r\n private _processFiles(files: Array<any>): void {\r\n for (let i = 0; i < files.length; i++) {\r\n const name = files[i].correctName.toLowerCase();\r\n const extension = name.split(\".\").pop();\r\n\r\n if (!this.onProcessFileCallback(files[i], name, extension, (sceneFile) => (this._sceneFileToLoad = sceneFile))) {\r\n continue;\r\n }\r\n\r\n if (SceneLoader.IsPluginForExtensionAvailable(\".\" + extension)) {\r\n this._sceneFileToLoad = files[i];\r\n }\r\n\r\n FilesInput.FilesToLoad[name] = files[i];\r\n }\r\n }\r\n\r\n /**\r\n * Load files from a drop event\r\n * @param event defines the drop event to use as source\r\n */\r\n public loadFiles(event: any): void {\r\n // Handling data transfer via drag'n'drop\r\n if (event && event.dataTransfer && event.dataTransfer.files) {\r\n this._filesToLoad = event.dataTransfer.files;\r\n }\r\n\r\n // Handling files from input files\r\n if (event && event.target && event.target.files) {\r\n this._filesToLoad = event.target.files;\r\n }\r\n\r\n if (!this._filesToLoad || this._filesToLoad.length === 0) {\r\n return;\r\n }\r\n\r\n if (this._startingProcessingFilesCallback) {\r\n this._startingProcessingFilesCallback(this._filesToLoad);\r\n }\r\n\r\n if (this._filesToLoad && this._filesToLoad.length > 0) {\r\n const files: File[] = [];\r\n const folders = [];\r\n const items = event.dataTransfer ? event.dataTransfer.items : null;\r\n\r\n for (let i = 0; i < this._filesToLoad.length; i++) {\r\n const fileToLoad: any = this._filesToLoad[i];\r\n const name = fileToLoad.name.toLowerCase();\r\n let entry;\r\n\r\n fileToLoad.correctName = name;\r\n\r\n if (items) {\r\n const item = items[i];\r\n if (item.getAsEntry) {\r\n entry = item.getAsEntry();\r\n } else if (item.webkitGetAsEntry) {\r\n entry = item.webkitGetAsEntry();\r\n }\r\n }\r\n\r\n if (!entry) {\r\n files.push(fileToLoad);\r\n } else {\r\n if (entry.isDirectory) {\r\n folders.push(entry);\r\n } else {\r\n files.push(fileToLoad);\r\n }\r\n }\r\n }\r\n\r\n if (folders.length === 0) {\r\n this._processFiles(files);\r\n this._processReload();\r\n } else {\r\n const remaining = { count: folders.length };\r\n for (const folder of folders) {\r\n this._traverseFolder(folder, files, remaining, () => {\r\n this._processFiles(files);\r\n\r\n if (remaining.count === 0) {\r\n this._processReload();\r\n }\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _processReload() {\r\n if (this._onReloadCallback) {\r\n this._onReloadCallback(this._sceneFileToLoad);\r\n } else {\r\n this.reload();\r\n }\r\n }\r\n\r\n /**\r\n * Reload the current scene from the loaded files\r\n */\r\n public reload() {\r\n // If a scene file has been provided\r\n if (this._sceneFileToLoad) {\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n if (Logger.errorsCount > 0) {\r\n Logger.ClearLogCache();\r\n }\r\n this._engine.stopRenderLoop();\r\n }\r\n }\r\n\r\n SceneLoader.ShowLoadingScreen = false;\r\n if (this.displayLoadingUI) {\r\n this._engine.displayLoadingUI();\r\n }\r\n\r\n this.loadAsync(this._sceneFileToLoad, this._progressCallback)\r\n .then((scene) => {\r\n // if appending do nothing\r\n if (!this.useAppend) {\r\n if (this._currentScene) {\r\n this._currentScene.dispose();\r\n }\r\n\r\n this._currentScene = scene;\r\n\r\n // Wait for textures and shaders to be ready\r\n this._currentScene.executeWhenReady(() => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n this._engine.runRenderLoop(() => {\r\n this._renderFunction();\r\n });\r\n });\r\n } else {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n }\r\n if (this._sceneLoadedCallback && this._currentScene) {\r\n this._sceneLoadedCallback(this._sceneFileToLoad, this._currentScene);\r\n }\r\n })\r\n .catch((error) => {\r\n if (this.displayLoadingUI) {\r\n this._engine.hideLoadingUI();\r\n }\r\n if (this._errorCallback) {\r\n this._errorCallback(this._sceneFileToLoad, this._currentScene, error.message);\r\n }\r\n });\r\n } else {\r\n Logger.Error(\"Please provide a valid .babylon file.\");\r\n }\r\n }\r\n}\r\n"]}
@@ -29,6 +29,7 @@ export declare class GreasedLineTools {
29
29
  * @param p1 point1 position of the face
30
30
  * @param p2 point2 position of the face
31
31
  * @param p3 point3 position of the face
32
+ * @param points array of points to search in
32
33
  * @returns original points or null if any edge length is zero
33
34
  */
34
35
  static OmitDuplicatesPredicate(p1: Vector3, p2: Vector3, p3: Vector3, points: Vector3[][]): Vector3[][] | null;
@@ -125,6 +126,7 @@ export declare class GreasedLineTools {
125
126
  * @param lineSegments segments of the line
126
127
  * @param lineLength total length of the line
127
128
  * @param visbility normalized value of visibility
129
+ * @param localSpace if true the result will be in local space (default is false)
128
130
  * @returns world space coordinate of the last visible piece of the line
129
131
  */
130
132
  static GetPositionOnLineByVisibility(lineSegments: {
@@ -188,6 +190,9 @@ export declare class GreasedLineTools {
188
190
  * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
189
191
  * @param name name of the texture
190
192
  * @param colors Uint8Array of colors
193
+ * @param colorsSampling sampling mode of the created texture
194
+ * @param scene Scene
195
+ * @returns the colors texture
191
196
  */
192
197
  static CreateColorsTexture(name: string, colors: Color3[], colorsSampling: number, scene: Scene): RawTexture;
193
198
  /**
@@ -203,7 +208,7 @@ export declare class GreasedLineTools {
203
208
  static DisposeEmptyColorsTexture(): void;
204
209
  /**
205
210
  * Converts boolean to number.
206
- * @param bool
211
+ * @param bool the bool value
207
212
  * @returns 1 if true, 0 if false.
208
213
  */
209
214
  static BooleanToNumber(bool?: boolean): 0 | 1;
@@ -77,6 +77,7 @@ export class GreasedLineTools {
77
77
  * @param p1 point1 position of the face
78
78
  * @param p2 point2 position of the face
79
79
  * @param p3 point3 position of the face
80
+ * @param points array of points to search in
80
81
  * @returns original points or null if any edge length is zero
81
82
  */
82
83
  static OmitDuplicatesPredicate(p1, p2, p3, points) {
@@ -318,6 +319,7 @@ export class GreasedLineTools {
318
319
  * @param lineSegments segments of the line
319
320
  * @param lineLength total length of the line
320
321
  * @param visbility normalized value of visibility
322
+ * @param localSpace if true the result will be in local space (default is false)
321
323
  * @returns world space coordinate of the last visible piece of the line
322
324
  */
323
325
  static GetPositionOnLineByVisibility(lineSegments, lineLength, visbility, localSpace = false) {
@@ -443,6 +445,9 @@ export class GreasedLineTools {
443
445
  * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
444
446
  * @param name name of the texture
445
447
  * @param colors Uint8Array of colors
448
+ * @param colorsSampling sampling mode of the created texture
449
+ * @param scene Scene
450
+ * @returns the colors texture
446
451
  */
447
452
  static CreateColorsTexture(name, colors, colorsSampling, scene) {
448
453
  const colorsArray = GreasedLineTools.Color3toRGBAUint8(colors);
@@ -474,7 +479,7 @@ export class GreasedLineTools {
474
479
  }
475
480
  /**
476
481
  * Converts boolean to number.
477
- * @param bool
482
+ * @param bool the bool value
478
483
  * @returns 1 if true, 0 if false.
479
484
  */
480
485
  static BooleanToNumber(bool) {
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/greasedLineTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAItE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AAEnG;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,MAAyB;QACjD,IAAI,MAAM,CAAC,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CAAC,CAAC;QACnI,aAAa,CAAC,IAAI,GAAG,IAAI,CAAC;QAC1B,OAAO,aAAa,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,yBAAyB,CAAC,KAAY;QAChD,IAAI,CAAC,2BAA2B,CAAC,kBAAkB,EAAE;YACjD,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;YACtC,2BAA2B,CAAC,kBAAkB,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;YAC/J,2BAA2B,CAAC,kBAAkB,CAAC,IAAI,GAAG,uBAAuB,CAAC;SACjF;QAED,OAAO,2BAA2B,CAAC,kBAAkB,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,yBAAyB;;QACnC,MAAA,2BAA2B,CAAC,kBAAkB,0CAAE,OAAO,EAAE,CAAC;QAC1D,2BAA2B,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,eAAe,CAAC,IAAc;QACxC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACJ","sourcesContent":["import { Curve3 } from \"../Maths/math.path\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { IFontData } from \"../Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"../Meshes/Builders/textBuilder\";\r\nimport type { FloatArray, IndicesArray } from \"../types\";\r\nimport type { GreasedLinePoints } from \"../Meshes/GreasedLine/greasedLineBaseMesh\";\r\nimport type { Color3 } from \"../Maths/math.color\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { GreasedLineMaterialDefaults } from \"../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Converts GreasedLinePoints to number[][]\r\n * @param points GreasedLinePoints\r\n * @returns number[][] with x, y, z coordinates of the points, like [[x, y, z, x, y, z, ...], [x, y, z, ...]]\r\n */\r\n public static ConvertPoints(points: GreasedLinePoints): number[][] {\r\n if (points.length && Array.isArray(points) && typeof points[0] === \"number\") {\r\n return [<number[]>points];\r\n } else if (points.length && Array.isArray(points[0]) && typeof points[0][0] === \"number\") {\r\n return <number[][]>points;\r\n } else if (points.length && !Array.isArray(points[0]) && points[0] instanceof Vector3) {\r\n const positions: number[] = [];\r\n for (let j = 0; j < points.length; j++) {\r\n const p = points[j] as Vector3;\r\n positions.push(p.x, p.y, p.z);\r\n }\r\n return [positions];\r\n } else if (points.length > 0 && Array.isArray(points[0]) && points[0].length > 0 && points[0][0] instanceof Vector3) {\r\n const positions: number[][] = [];\r\n const vectorPoints = points as Vector3[][];\r\n vectorPoints.forEach((p) => {\r\n positions.push(p.flatMap((p2) => [p2.x, p2.y, p2.z]));\r\n });\r\n return positions;\r\n } else if (points instanceof Float32Array) {\r\n return [Array.from(points)];\r\n } else if (points.length && points[0] instanceof Float32Array) {\r\n const positions: number[][] = [];\r\n points.forEach((p) => {\r\n positions.push(Array.from(p as Float32Array));\r\n });\r\n return positions;\r\n }\r\n\r\n return [];\r\n }\r\n\r\n /**\r\n * Omit zero length lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitZeroLengthPredicate(p1: Vector3, p2: Vector3, p3: Vector3) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (p2.subtract(p1).lengthSquared() > 0) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (p3.subtract(p2).lengthSquared() > 0) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (p1.subtract(p3).lengthSquared() > 0) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n /**\r\n * Omit duplicate lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitDuplicatesPredicate(p1: Vector3, p2: Vector3, p3: Vector3, points: Vector3[][]) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (!GreasedLineTools._SearchInPoints(p1, p2, points)) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (!GreasedLineTools._SearchInPoints(p2, p3, points)) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (!GreasedLineTools._SearchInPoints(p3, p1, points)) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n private static _SearchInPoints(p1: Vector3, p2: Vector3, points: Vector3[][]) {\r\n for (const ps of points) {\r\n for (let i = 0; i < ps.length; i++) {\r\n if (ps[i]?.equals(p1)) {\r\n // find the first point\r\n // if it has a sibling of p2 the line already exists\r\n if (ps[i + 1]?.equals(p2) || ps[i - 1]?.equals(p2)) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param predicate predicate function which decides whether to include the mesh triangle/face in the ouput\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(\r\n meshes: AbstractMesh[],\r\n predicate?: (\r\n p1: Vector3,\r\n p2: Vector3,\r\n p3: Vector3,\r\n points: Vector3[][],\r\n indiceIndex: number,\r\n vertexIndex: number,\r\n mesh: AbstractMesh,\r\n meshIndex: number,\r\n vertices: FloatArray,\r\n indices: IndicesArray\r\n ) => Vector3[][]\r\n ) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m, meshIndex) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (predicate) {\r\n const pointsFromPredicate = predicate(p1, p2, p3, points, i, vi1, m, meshIndex, vertices, indices);\r\n if (pointsFromPredicate) {\r\n for (const p of pointsFromPredicate) {\r\n points.push(p);\r\n }\r\n }\r\n } else {\r\n points.push([p1, p2], [p2, p3], [p3, p1]);\r\n }\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[] | number[][]) {\r\n if (Array.isArray(points[0])) {\r\n const array: Vector3[][] = [];\r\n const inputArray = points as number[][];\r\n for (const subInputArray of inputArray) {\r\n const subArray: Vector3[] = [];\r\n for (let i = 0; i < subInputArray.length; i += 3) {\r\n subArray.push(new Vector3(subInputArray[i], subInputArray[i + 1], subInputArray[i + 2]));\r\n }\r\n array.push(subArray);\r\n }\r\n return array;\r\n }\r\n\r\n const inputArray = points as number[];\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < inputArray.length; i += 3) {\r\n array.push(new Vector3(inputArray[i], inputArray[i + 1], inputArray[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data) as Vector3[];\r\n } else {\r\n points = data as Vector3[];\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines =\r\n what[0] instanceof Vector3\r\n ? GreasedLineTools.GetLineSegments(what as Vector3[])\r\n : typeof what[0] === \"number\"\r\n ? GreasedLineTools.GetLineSegments(GreasedLineTools.ToVector3Array(what as number[]) as Vector3[])\r\n : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[] | number[], segmentCount: number): Vector3[] {\r\n const points = <Vector3[]>(typeof what[0] === \"number\" ? GreasedLineTools.ToVector3Array(<number[]>what) : what);\r\n const segmentLength = GreasedLineTools.GetLineLength(points) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(points, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n\r\n /**\r\n * Gets 3D positions of points from a text and font\r\n * @param text Text\r\n * @param size Size of the font\r\n * @param resolution Resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param z z coordinate\r\n * @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.\r\n * @returns number[][] of 3D positions\r\n */\r\n public static GetPointsFromText(text: string, size: number, resolution: number, fontData: IFontData, z = 0, includeInner = true) {\r\n const allPoints = [];\r\n const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);\r\n\r\n for (const sp of shapePaths) {\r\n for (const p of sp.paths) {\r\n const points = [];\r\n const points2d = p.getPoints();\r\n for (const p2d of points2d) {\r\n points.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(points);\r\n }\r\n\r\n if (includeInner) {\r\n for (const h of sp.holes) {\r\n const holes = [];\r\n const points2d = h.getPoints();\r\n for (const p2d of points2d) {\r\n holes.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(holes);\r\n }\r\n }\r\n }\r\n\r\n return allPoints;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n public static Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n */\r\n public static CreateColorsTexture(name: string, colors: Color3[], colorsSampling: number, scene: Scene) {\r\n const colorsArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n const colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, true, colorsSampling);\r\n colorsTexture.name = name;\r\n return colorsTexture;\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n * @returns empty colors texture\r\n */\r\n public static PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n\r\n return GreasedLineMaterialDefaults.EmptyColorsTexture;\r\n }\r\n\r\n /**\r\n * Diposes the shared empty colors texture\r\n */\r\n public static DisposeEmptyColorsTexture() {\r\n GreasedLineMaterialDefaults.EmptyColorsTexture?.dispose();\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool\r\n * @returns 1 if true, 0 if false.\r\n */\r\n public static BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/greasedLineTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAA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../Buffers/buffer\";\r\nimport { TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { IFontData } from \"../Meshes/Builders/textBuilder\";\r\nimport { CreateTextShapePaths } from \"../Meshes/Builders/textBuilder\";\r\nimport type { FloatArray, IndicesArray } from \"../types\";\r\nimport type { GreasedLinePoints } from \"../Meshes/GreasedLine/greasedLineBaseMesh\";\r\nimport type { Color3 } from \"../Maths/math.color\";\r\nimport { RawTexture } from \"../Materials/Textures/rawTexture\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Engine } from \"../Engines/engine\";\r\nimport { GreasedLineMaterialDefaults } from \"../Materials/GreasedLine/greasedLineMaterialDefaults\";\r\n\r\n/**\r\n * Tool functions for GreasedLine\r\n */\r\nexport class GreasedLineTools {\r\n /**\r\n * Converts GreasedLinePoints to number[][]\r\n * @param points GreasedLinePoints\r\n * @returns number[][] with x, y, z coordinates of the points, like [[x, y, z, x, y, z, ...], [x, y, z, ...]]\r\n */\r\n public static ConvertPoints(points: GreasedLinePoints): number[][] {\r\n if (points.length && Array.isArray(points) && typeof points[0] === \"number\") {\r\n return [<number[]>points];\r\n } else if (points.length && Array.isArray(points[0]) && typeof points[0][0] === \"number\") {\r\n return <number[][]>points;\r\n } else if (points.length && !Array.isArray(points[0]) && points[0] instanceof Vector3) {\r\n const positions: number[] = [];\r\n for (let j = 0; j < points.length; j++) {\r\n const p = points[j] as Vector3;\r\n positions.push(p.x, p.y, p.z);\r\n }\r\n return [positions];\r\n } else if (points.length > 0 && Array.isArray(points[0]) && points[0].length > 0 && points[0][0] instanceof Vector3) {\r\n const positions: number[][] = [];\r\n const vectorPoints = points as Vector3[][];\r\n vectorPoints.forEach((p) => {\r\n positions.push(p.flatMap((p2) => [p2.x, p2.y, p2.z]));\r\n });\r\n return positions;\r\n } else if (points instanceof Float32Array) {\r\n return [Array.from(points)];\r\n } else if (points.length && points[0] instanceof Float32Array) {\r\n const positions: number[][] = [];\r\n points.forEach((p) => {\r\n positions.push(Array.from(p as Float32Array));\r\n });\r\n return positions;\r\n }\r\n\r\n return [];\r\n }\r\n\r\n /**\r\n * Omit zero length lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitZeroLengthPredicate(p1: Vector3, p2: Vector3, p3: Vector3) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (p2.subtract(p1).lengthSquared() > 0) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (p3.subtract(p2).lengthSquared() > 0) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (p1.subtract(p3).lengthSquared() > 0) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n /**\r\n * Omit duplicate lines predicate for the MeshesToLines function\r\n * @param p1 point1 position of the face\r\n * @param p2 point2 position of the face\r\n * @param p3 point3 position of the face\r\n * @param points array of points to search in\r\n * @returns original points or null if any edge length is zero\r\n */\r\n public static OmitDuplicatesPredicate(p1: Vector3, p2: Vector3, p3: Vector3, points: Vector3[][]) {\r\n const fileredPoints = [];\r\n // edge1\r\n if (!GreasedLineTools._SearchInPoints(p1, p2, points)) {\r\n fileredPoints.push([p1, p2]);\r\n }\r\n // edge2\r\n if (!GreasedLineTools._SearchInPoints(p2, p3, points)) {\r\n fileredPoints.push([p2, p3]);\r\n }\r\n // edge3\r\n if (!GreasedLineTools._SearchInPoints(p3, p1, points)) {\r\n fileredPoints.push([p3, p1]);\r\n }\r\n return fileredPoints.length === 0 ? null : fileredPoints;\r\n }\r\n\r\n private static _SearchInPoints(p1: Vector3, p2: Vector3, points: Vector3[][]) {\r\n for (const ps of points) {\r\n for (let i = 0; i < ps.length; i++) {\r\n if (ps[i]?.equals(p1)) {\r\n // find the first point\r\n // if it has a sibling of p2 the line already exists\r\n if (ps[i + 1]?.equals(p2) || ps[i - 1]?.equals(p2)) {\r\n return true;\r\n }\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Gets mesh triangles as line positions\r\n * @param meshes array of meshes\r\n * @param predicate predicate function which decides whether to include the mesh triangle/face in the ouput\r\n * @returns array of arrays of points\r\n */\r\n public static MeshesToLines(\r\n meshes: AbstractMesh[],\r\n predicate?: (\r\n p1: Vector3,\r\n p2: Vector3,\r\n p3: Vector3,\r\n points: Vector3[][],\r\n indiceIndex: number,\r\n vertexIndex: number,\r\n mesh: AbstractMesh,\r\n meshIndex: number,\r\n vertices: FloatArray,\r\n indices: IndicesArray\r\n ) => Vector3[][]\r\n ) {\r\n const points: Vector3[][] = [];\r\n\r\n meshes.forEach((m, meshIndex) => {\r\n const vertices = m.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = m.getIndices();\r\n if (vertices && indices) {\r\n for (let i = 0, ii = 0; i < indices.length; i++) {\r\n const vi1 = indices[ii++] * 3;\r\n const vi2 = indices[ii++] * 3;\r\n const vi3 = indices[ii++] * 3;\r\n\r\n const p1 = new Vector3(vertices[vi1], vertices[vi1 + 1], vertices[vi1 + 2]);\r\n const p2 = new Vector3(vertices[vi2], vertices[vi2 + 1], vertices[vi2 + 2]);\r\n const p3 = new Vector3(vertices[vi3], vertices[vi3 + 1], vertices[vi3 + 2]);\r\n\r\n if (predicate) {\r\n const pointsFromPredicate = predicate(p1, p2, p3, points, i, vi1, m, meshIndex, vertices, indices);\r\n if (pointsFromPredicate) {\r\n for (const p of pointsFromPredicate) {\r\n points.push(p);\r\n }\r\n }\r\n } else {\r\n points.push([p1, p2], [p2, p3], [p3, p1]);\r\n }\r\n }\r\n }\r\n });\r\n\r\n return points;\r\n }\r\n\r\n /**\r\n * Converts number coordinates to Vector3s\r\n * @param points number array of x, y, z, x, y z, ... coordinates\r\n * @returns Vector3 array\r\n */\r\n public static ToVector3Array(points: number[] | number[][]) {\r\n if (Array.isArray(points[0])) {\r\n const array: Vector3[][] = [];\r\n const inputArray = points as number[][];\r\n for (const subInputArray of inputArray) {\r\n const subArray: Vector3[] = [];\r\n for (let i = 0; i < subInputArray.length; i += 3) {\r\n subArray.push(new Vector3(subInputArray[i], subInputArray[i + 1], subInputArray[i + 2]));\r\n }\r\n array.push(subArray);\r\n }\r\n return array;\r\n }\r\n\r\n const inputArray = points as number[];\r\n const array: Vector3[] = [];\r\n for (let i = 0; i < inputArray.length; i += 3) {\r\n array.push(new Vector3(inputArray[i], inputArray[i + 1], inputArray[i + 2]));\r\n }\r\n return array;\r\n }\r\n\r\n /**\r\n * Gets a number array from a Vector3 array.\r\n * You can you for example to convert your Vector3[] offsets to the required number[] for the offsets option.\r\n * @param points Vector3 array\r\n * @returns an array of x, y, z coordinates as numbers [x, y, z, x, y, z, x, y, z, ....]\r\n */\r\n public static ToNumberArray(points: Vector3[]) {\r\n return points.flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n * Calculates the sum of points of every line and the number of points in each line.\r\n * This function is useful when you are drawing multiple lines in one mesh and you want\r\n * to know the counts. For example for creating an offsets table.\r\n * @param points point array\r\n * @returns points count info\r\n */\r\n public static GetPointsCountInfo(points: number[][]): { total: number; counts: number[] } {\r\n const counts = new Array(points.length);\r\n let total = 0;\r\n for (let n = points.length; n--; ) {\r\n counts[n] = points[n].length / 3;\r\n total += counts[n];\r\n }\r\n return { total, counts };\r\n }\r\n\r\n /**\r\n * Gets the length of the line counting all it's segments length\r\n * @param data array of line points\r\n * @returns length of the line\r\n */\r\n public static GetLineLength(data: Vector3[] | number[]): number {\r\n if (data.length === 0) {\r\n return 0;\r\n }\r\n\r\n let points: Vector3[];\r\n if (typeof data[0] === \"number\") {\r\n points = GreasedLineTools.ToVector3Array(<number[]>data) as Vector3[];\r\n } else {\r\n points = data as Vector3[];\r\n }\r\n\r\n const tmp = TmpVectors.Vector3[0];\r\n let length = 0;\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n length += point2.subtractToRef(point1, tmp).length();\r\n }\r\n return length;\r\n }\r\n\r\n /**\r\n * Divides a segment into smaller segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param point1 first point of the line\r\n * @param point2 second point of the line\r\n * @param segmentCount number of segments we want to have in the divided line\r\n * @returns\r\n */\r\n public static SegmentizeSegmentByCount(point1: Vector3, point2: Vector3, segmentCount: number): Vector3[] {\r\n const dividedLinePoints: Vector3[] = [];\r\n const diff = point2.subtract(point1);\r\n const divisor = TmpVectors.Vector3[0];\r\n divisor.setAll(segmentCount);\r\n const segmentVector = TmpVectors.Vector3[1];\r\n diff.divideToRef(divisor, segmentVector);\r\n\r\n let nextPoint = point1.clone();\r\n dividedLinePoints.push(nextPoint);\r\n for (let index = 0; index < segmentCount; index++) {\r\n nextPoint = nextPoint.clone();\r\n dividedLinePoints.push(nextPoint.addInPlace(segmentVector));\r\n }\r\n\r\n return dividedLinePoints;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentLength length of each segment of the resulting line (distance between two line points)\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentLength(what: Vector3[] | number[] | { point1: Vector3; point2: Vector3; length: number }[], segmentLength: number): Vector3[] {\r\n const subLines =\r\n what[0] instanceof Vector3\r\n ? GreasedLineTools.GetLineSegments(what as Vector3[])\r\n : typeof what[0] === \"number\"\r\n ? GreasedLineTools.GetLineSegments(GreasedLineTools.ToVector3Array(what as number[]) as Vector3[])\r\n : (what as { point1: Vector3; point2: Vector3; length: number }[]);\r\n const points: Vector3[] = [];\r\n subLines.forEach((s) => {\r\n if (s.length > segmentLength) {\r\n const segments = GreasedLineTools.SegmentizeSegmentByCount(s.point1, s.point2, Math.ceil(s.length / segmentLength));\r\n segments.forEach((seg) => {\r\n points.push(seg);\r\n });\r\n } else {\r\n points.push(s.point1);\r\n points.push(s.point2);\r\n }\r\n });\r\n return points;\r\n }\r\n\r\n /**\r\n * Divides a line into segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param what line points\r\n * @param segmentCount number of segments\r\n * @returns line point\r\n */\r\n public static SegmentizeLineBySegmentCount(what: Vector3[] | number[], segmentCount: number): Vector3[] {\r\n const points = <Vector3[]>(typeof what[0] === \"number\" ? GreasedLineTools.ToVector3Array(<number[]>what) : what);\r\n const segmentLength = GreasedLineTools.GetLineLength(points) / segmentCount;\r\n return GreasedLineTools.SegmentizeLineBySegmentLength(points, segmentLength);\r\n }\r\n /**\r\n * Gets line segments.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns segments information of the line segment including starting point, ending point and the distance between them\r\n */\r\n public static GetLineSegments(points: Vector3[]): { point1: Vector3; point2: Vector3; length: number }[] {\r\n const segments = [];\r\n for (let index = 0; index < points.length - 1; index++) {\r\n const point1 = points[index];\r\n const point2 = points[index + 1];\r\n const length = point2.subtract(point1).length();\r\n segments.push({ point1, point2, length });\r\n }\r\n\r\n return segments;\r\n }\r\n\r\n /**\r\n * Gets the minimum and the maximum length of a line segment in the line.\r\n * A segment is a part of the line between it's two points.\r\n * @param points line points\r\n * @returns\r\n */\r\n public static GetMinMaxSegmentLength(points: Vector3[]): { min: number; max: number } {\r\n const subLines = GreasedLineTools.GetLineSegments(points);\r\n const sorted = subLines.sort((s) => s.length);\r\n return {\r\n min: sorted[0].length,\r\n max: sorted[sorted.length - 1].length,\r\n };\r\n }\r\n\r\n /**\r\n * Finds the last visible position in world space of the line according to the visibility parameter\r\n * @param lineSegments segments of the line\r\n * @param lineLength total length of the line\r\n * @param visbility normalized value of visibility\r\n * @param localSpace if true the result will be in local space (default is false)\r\n * @returns world space coordinate of the last visible piece of the line\r\n */\r\n public static GetPositionOnLineByVisibility(lineSegments: { point1: Vector3; point2: Vector3; length: number }[], lineLength: number, visbility: number, localSpace = false) {\r\n const lengthVisibilityRatio = lineLength * visbility;\r\n let sumSegmentLengths = 0;\r\n let segmentIndex = 0;\r\n\r\n const lineSegmentsLength = lineSegments.length;\r\n for (let i = 0; i < lineSegmentsLength; i++) {\r\n if (lengthVisibilityRatio <= sumSegmentLengths + lineSegments[i].length) {\r\n segmentIndex = i;\r\n break;\r\n }\r\n sumSegmentLengths += lineSegments[i].length;\r\n }\r\n\r\n const s = (lengthVisibilityRatio - sumSegmentLengths) / lineSegments[segmentIndex].length;\r\n\r\n lineSegments[segmentIndex].point2.subtractToRef(lineSegments[segmentIndex].point1, TmpVectors.Vector3[0]);\r\n TmpVectors.Vector3[1] = TmpVectors.Vector3[0].multiplyByFloats(s, s, s);\r\n if (!localSpace) {\r\n TmpVectors.Vector3[1].addInPlace(lineSegments[segmentIndex].point1);\r\n }\r\n\r\n return TmpVectors.Vector3[1].clone();\r\n }\r\n\r\n /**\r\n * Creates lines in a shape of circle/arc.\r\n * A segment is a part of the line between it's two points.\r\n * @param radiusX radiusX of the circle\r\n * @param segments number of segments in the circle\r\n * @param z z coordinate of the points. Defaults to 0.\r\n * @param radiusY radiusY of the circle - you can draw an oval if using different values\r\n * @param segmentAngle angle offset of the segments. Defaults to Math.PI * 2 / segments. Change this value to draw a part of the circle.\r\n * @returns line points\r\n */\r\n public static GetCircleLinePoints(radiusX: number, segments: number, z = 0, radiusY = radiusX, segmentAngle = (Math.PI * 2) / segments) {\r\n const points: Vector3[] = [];\r\n for (let i = 0; i <= segments; i++) {\r\n points.push(new Vector3(Math.cos(i * segmentAngle) * radiusX, Math.sin(i * segmentAngle) * radiusY, z));\r\n }\r\n return points;\r\n }\r\n\r\n /**\r\n * Gets line points in a shape of a bezier curve\r\n * @param p0 bezier point0\r\n * @param p1 bezier point1\r\n * @param p2 bezier point2\r\n * @param segments number of segments in the curve\r\n * @returns\r\n */\r\n public static GetBezierLinePoints(p0: Vector3, p1: Vector3, p2: Vector3, segments: number) {\r\n return Curve3.CreateQuadraticBezier(p0, p1, p2, segments)\r\n .getPoints()\r\n .flatMap((v) => [v.x, v.y, v.z]);\r\n }\r\n\r\n /**\r\n *\r\n * @param position position of the arrow cap (mainly you want to create a triangle, set widthUp and widthDown to the same value and omit widthStartUp and widthStartDown)\r\n * @param direction direction which the arrow points to\r\n * @param length length (size) of the arrow cap itself\r\n * @param widthUp the arrow width above the line\r\n * @param widthDown the arrow width belove the line\r\n * @param widthStartUp the arrow width at the start of the arrow above the line. In most scenarios this is 0.\r\n * @param widthStartDown the arrow width at the start of the arrow below the line. In most scenarios this is 0.\r\n * @returns\r\n */\r\n public static GetArrowCap(position: Vector3, direction: Vector3, length: number, widthUp: number, widthDown: number, widthStartUp = 0, widthStartDown = 0) {\r\n const points = [position.clone(), position.add(direction.multiplyByFloats(length, length, length))];\r\n const widths = [widthUp, widthDown, widthStartUp, widthStartDown];\r\n\r\n return {\r\n points,\r\n widths,\r\n };\r\n }\r\n\r\n /**\r\n * Gets 3D positions of points from a text and font\r\n * @param text Text\r\n * @param size Size of the font\r\n * @param resolution Resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param z z coordinate\r\n * @param includeInner include the inner parts of the font in the result. Default true. If false, only the outlines will be returned.\r\n * @returns number[][] of 3D positions\r\n */\r\n public static GetPointsFromText(text: string, size: number, resolution: number, fontData: IFontData, z = 0, includeInner = true) {\r\n const allPoints = [];\r\n const shapePaths = CreateTextShapePaths(text, size, resolution, fontData);\r\n\r\n for (const sp of shapePaths) {\r\n for (const p of sp.paths) {\r\n const points = [];\r\n const points2d = p.getPoints();\r\n for (const p2d of points2d) {\r\n points.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(points);\r\n }\r\n\r\n if (includeInner) {\r\n for (const h of sp.holes) {\r\n const holes = [];\r\n const points2d = h.getPoints();\r\n for (const p2d of points2d) {\r\n holes.push(p2d.x, p2d.y, z);\r\n }\r\n allPoints.push(holes);\r\n }\r\n }\r\n }\r\n\r\n return allPoints;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n public static Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n * @param colorsSampling sampling mode of the created texture\r\n * @param scene Scene\r\n * @returns the colors texture\r\n */\r\n public static CreateColorsTexture(name: string, colors: Color3[], colorsSampling: number, scene: Scene) {\r\n const colorsArray = GreasedLineTools.Color3toRGBAUint8(colors);\r\n const colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, true, colorsSampling);\r\n colorsTexture.name = name;\r\n return colorsTexture;\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n * @returns empty colors texture\r\n */\r\n public static PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!GreasedLineMaterialDefaults.EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n GreasedLineMaterialDefaults.EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n\r\n return GreasedLineMaterialDefaults.EmptyColorsTexture;\r\n }\r\n\r\n /**\r\n * Diposes the shared empty colors texture\r\n */\r\n public static DisposeEmptyColorsTexture() {\r\n GreasedLineMaterialDefaults.EmptyColorsTexture?.dispose();\r\n GreasedLineMaterialDefaults.EmptyColorsTexture = null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool the bool value\r\n * @returns 1 if true, 0 if false.\r\n */\r\n public static BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n}\r\n"]}
@@ -19,6 +19,8 @@ export declare function CreateResizedCopy(texture: Texture, width: number, heigh
19
19
  * @param type type of the output texture. If not provided, use the one from internalTexture
20
20
  * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
21
21
  * @param format format of the output texture. If not provided, use the one from internalTexture
22
+ * @param width width of the output texture. If not provided, use the one from internalTexture
23
+ * @param height height of the output texture. If not provided, use the one from internalTexture
22
24
  * @returns a promise with the internalTexture having its texture replaced by the result of the processing
23
25
  */
24
26
  export declare function ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number, width?: number, height?: number): Promise<InternalTexture>;
@@ -55,6 +55,8 @@ export function CreateResizedCopy(texture, width, height, useBilinearMode = true
55
55
  * @param type type of the output texture. If not provided, use the one from internalTexture
56
56
  * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture
57
57
  * @param format format of the output texture. If not provided, use the one from internalTexture
58
+ * @param width width of the output texture. If not provided, use the one from internalTexture
59
+ * @param height height of the output texture. If not provided, use the one from internalTexture
58
60
  * @returns a promise with the internalTexture having its texture replaced by the result of the processing
59
61
  */
60
62
  export function ApplyPostProcess(postProcessName, internalTexture, scene, type, samplingMode, format, width, height) {
@@ -1 +1 @@
1
- {"version":3,"file":"textureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/textureTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAA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YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;;;;;OAOG;IACH,iBAAiB;IAEjB;;;;;;;;;OASG;IACH,gBAAgB;IAChB;;;;OAIG;IACH,WAAW;IAEX;;;;OAIG;IACH,aAAa;IAEb;;;;;;;;;;OAUG;IACH,mBAAmB;CACtB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { PassPostProcess } from \"../PostProcesses/passPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\nexport function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode: boolean = true): Texture {\r\n const scene = <Scene>texture.getScene();\r\n const engine = scene.getEngine();\r\n\r\n const rtt = new RenderTargetTexture(\r\n \"resized\" + texture.name,\r\n { width: width, height: height },\r\n scene,\r\n !texture.noMipmap,\r\n true,\r\n (<InternalTexture>texture._texture).type,\r\n false,\r\n texture.samplingMode,\r\n false\r\n );\r\n\r\n rtt.wrapU = texture.wrapU;\r\n rtt.wrapV = texture.wrapV;\r\n rtt.uOffset = texture.uOffset;\r\n rtt.vOffset = texture.vOffset;\r\n rtt.uScale = texture.uScale;\r\n rtt.vScale = texture.vScale;\r\n rtt.uAng = texture.uAng;\r\n rtt.vAng = texture.vAng;\r\n rtt.wAng = texture.wAng;\r\n rtt.coordinatesIndex = texture.coordinatesIndex;\r\n rtt.level = texture.level;\r\n rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;\r\n (<InternalTexture>rtt._texture).isReady = false;\r\n\r\n texture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n const passPostProcess = new PassPostProcess(\r\n \"pass\",\r\n 1,\r\n null,\r\n useBilinearMode ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,\r\n engine,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n passPostProcess.externalTextureSamplerBinding = true;\r\n passPostProcess.getEffect().executeWhenCompiled(() => {\r\n passPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n };\r\n\r\n const internalTexture = rtt.renderTarget;\r\n\r\n if (internalTexture) {\r\n scene.postProcessManager.directRender([passPostProcess], internalTexture);\r\n\r\n engine.unBindFramebuffer(internalTexture);\r\n rtt.disposeFramebufferObjects();\r\n passPostProcess.dispose();\r\n\r\n rtt.getInternalTexture()!.isReady = true;\r\n }\r\n });\r\n\r\n return rtt;\r\n}\r\n\r\n/**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\nexport function ApplyPostProcess(\r\n postProcessName: string,\r\n internalTexture: InternalTexture,\r\n scene: Scene,\r\n type?: number,\r\n samplingMode?: number,\r\n format?: number,\r\n width?: number,\r\n height?: number\r\n): Promise<InternalTexture> {\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n\r\n internalTexture.isReady = false;\r\n\r\n samplingMode = samplingMode ?? internalTexture.samplingMode;\r\n type = type ?? internalTexture.type;\r\n format = format ?? internalTexture.format;\r\n width = width ?? internalTexture.width;\r\n height = height ?? internalTexture.height;\r\n\r\n if (type === -1) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n // Create the post process\r\n const postProcess = new PostProcess(\"postprocess\", postProcessName, null, null, 1, null, samplingMode, engine, false, undefined, type, undefined, null, false, format);\r\n postProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const encodedTexture = engine.createRenderTargetTexture(\r\n { width: width as number, height: height as number },\r\n {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode,\r\n type,\r\n format,\r\n }\r\n );\r\n\r\n postProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n postProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n scene.postProcessManager.directRender([postProcess!], encodedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (postProcess) {\r\n postProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n encodedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.type = type!;\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.isReady = true;\r\n\r\n resolve(internalTexture);\r\n });\r\n });\r\n}\r\n\r\n// ref: http://stackoverflow.com/questions/32633585/how-do-you-convert-to-half-floats-in-javascript\r\nlet floatView: Float32Array;\r\nlet int32View: Int32Array;\r\n/**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\nexport function ToHalfFloat(value: number): number {\r\n if (!floatView) {\r\n floatView = new Float32Array(1);\r\n int32View = new Int32Array(floatView.buffer);\r\n }\r\n\r\n floatView[0] = value;\r\n const x = int32View[0];\r\n\r\n let bits = (x >> 16) & 0x8000; /* Get the sign */\r\n let m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */\r\n const e = (x >> 23) & 0xff; /* Using int is faster here */\r\n\r\n /* If zero, or denormal, or exponent underflows too much for a denormal\r\n * half, return signed zero. */\r\n if (e < 103) {\r\n return bits;\r\n }\r\n\r\n /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */\r\n if (e > 142) {\r\n bits |= 0x7c00;\r\n /* If exponent was 0xff and one mantissa bit was set, it means NaN,\r\n * not Inf, so make sure we set one mantissa bit too. */\r\n bits |= (e == 255 ? 0 : 1) && x & 0x007fffff;\r\n return bits;\r\n }\r\n\r\n /* If exponent underflows but not too much, return a denormal */\r\n if (e < 113) {\r\n m |= 0x0800;\r\n /* Extra rounding may overflow and set mantissa to 0 and exponent\r\n * to 1, which is OK. */\r\n bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);\r\n return bits;\r\n }\r\n\r\n bits |= ((e - 112) << 10) | (m >> 1);\r\n bits += m & 1;\r\n return bits;\r\n}\r\n\r\n/**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\nexport function FromHalfFloat(value: number): number {\r\n const s = (value & 0x8000) >> 15;\r\n const e = (value & 0x7c00) >> 10;\r\n const f = value & 0x03ff;\r\n\r\n if (e === 0) {\r\n return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));\r\n } else if (e == 0x1f) {\r\n return f ? NaN : (s ? -1 : 1) * Infinity;\r\n }\r\n\r\n return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));\r\n}\r\n\r\nconst ProcessAsync = async (texture: BaseTexture, width: number, height: number, face: number, lod: number): Promise<Uint8Array> => {\r\n const scene = texture.getScene()!;\r\n const engine = scene.getEngine();\r\n\r\n let lodPostProcess: PostProcess;\r\n\r\n if (!texture.isCube) {\r\n lodPostProcess = new PostProcess(\"lod\", \"lod\", [\"lod\", \"gamma\"], null, 1.0, null, Texture.NEAREST_NEAREST_MIPNEAREST, engine);\r\n } else {\r\n const faceDefines = [\"#define POSITIVEX\", \"#define NEGATIVEX\", \"#define POSITIVEY\", \"#define NEGATIVEY\", \"#define POSITIVEZ\", \"#define NEGATIVEZ\"];\r\n lodPostProcess = new PostProcess(\"lodCube\", \"lodCube\", [\"lod\", \"gamma\"], null, 1.0, null, Texture.NEAREST_NEAREST_MIPNEAREST, engine, false, faceDefines[face]);\r\n }\r\n\r\n await new Promise((resolve) => {\r\n lodPostProcess.getEffect().executeWhenCompiled(() => {\r\n resolve(0);\r\n });\r\n });\r\n\r\n const rtt = new RenderTargetTexture(\"temp\", { width: width, height: height }, scene, false);\r\n\r\n lodPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n effect.setFloat(\"lod\", lod);\r\n effect.setBool(\"gamma\", texture.gammaSpace);\r\n };\r\n\r\n const internalTexture = texture.getInternalTexture();\r\n\r\n try {\r\n if (rtt.renderTarget && internalTexture) {\r\n const samplingMode = internalTexture.samplingMode;\r\n if (lod !== 0) {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST_MIPNEAREST);\r\n } else {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST);\r\n }\r\n\r\n scene.postProcessManager.directRender([lodPostProcess], rtt.renderTarget, true);\r\n texture.updateSamplingMode(samplingMode);\r\n\r\n //Reading datas from WebGL\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n const data = new Uint8Array(bufferView.buffer, 0, bufferView.byteLength);\r\n\r\n // Unbind\r\n engine.unBindFramebuffer(rtt.renderTarget);\r\n\r\n return data;\r\n } else {\r\n throw Error(\"Render to texture failed.\");\r\n }\r\n } finally {\r\n rtt.dispose();\r\n lodPostProcess.dispose();\r\n }\r\n};\r\n\r\n/**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\nexport async function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face: number = 0, lod: number = 0): Promise<Uint8Array> {\r\n if (!texture.isReady() && texture._texture) {\r\n await new Promise((resolve, reject) => {\r\n if (texture._texture === null) {\r\n reject(0);\r\n return;\r\n }\r\n texture._texture.onLoadedObservable.addOnce(() => {\r\n resolve(0);\r\n });\r\n });\r\n }\r\n return await ProcessAsync(texture, width, height, face, lod);\r\n}\r\n\r\n/**\r\n * Class used to host texture specific utilities\r\n */\r\nexport const TextureTools = {\r\n /**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\n CreateResizedCopy,\r\n\r\n /**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n ApplyPostProcess,\r\n /**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\n ToHalfFloat,\r\n\r\n /**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\n FromHalfFloat,\r\n\r\n /**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param channels a filter for which of the RGBA channels to return in the result\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\n GetTextureDataAsync,\r\n};\r\n"]}
1
+ {"version":3,"file":"textureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/textureTools.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,KAAa,EAAE,MAAc,EAAE,kBAA2B,IAAI;IAC9G,MAAM,KAAK,GAAU,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAEjC,MAAM,GAAG,GAAG,IAAI,mBAAmB,CAC/B,SAAS,GAAG,OAAO,CAAC,IAAI,EACxB,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAChC,KAAK,EACL,CAAC,OAAO,CAAC,QAAQ,EACjB,IAAI,EACc,OAAO,CAAC,QAAS,CAAC,IAAI,EACxC,KAAK,EACL,OAAO,CAAC,YAAY,EACpB,KAAK,CACR,CAAC;IAEF,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,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AAC;KAC5B;AACL,CAAC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAoB,EAAE,KAAa,EAAE,MAAc,EAAE,OAAe,CAAC,EAAE,MAAc,CAAC;IAC5H,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,OAAO,CAAC,QAAQ,EAAE;QACxC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAClC,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,EAAE;gBAC3B,MAAM,CAAC,CAAC,CAAC,CAAC;gBACV,OAAO;aACV;YACD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,EAAE;gBAC7C,OAAO,CAAC,CAAC,CAAC,CAAC;YACf,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;KACN;IACD,OAAO,MAAM,YAAY,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;AACjE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB;;;;;;;OAOG;IACH,iBAAiB;IAEjB;;;;;;;;;OASG;IACH,gBAAgB;IAChB;;;;OAIG;IACH,WAAW;IAEX;;;;OAIG;IACH,aAAa;IAEb;;;;;;;;;;OAUG;IACH,mBAAmB;CACtB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport { PassPostProcess } from \"../PostProcesses/passPostProcess\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport type { Engine } from \"../Engines/engine\";\r\n\r\n/**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\nexport function CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode: boolean = true): Texture {\r\n const scene = <Scene>texture.getScene();\r\n const engine = scene.getEngine();\r\n\r\n const rtt = new RenderTargetTexture(\r\n \"resized\" + texture.name,\r\n { width: width, height: height },\r\n scene,\r\n !texture.noMipmap,\r\n true,\r\n (<InternalTexture>texture._texture).type,\r\n false,\r\n texture.samplingMode,\r\n false\r\n );\r\n\r\n rtt.wrapU = texture.wrapU;\r\n rtt.wrapV = texture.wrapV;\r\n rtt.uOffset = texture.uOffset;\r\n rtt.vOffset = texture.vOffset;\r\n rtt.uScale = texture.uScale;\r\n rtt.vScale = texture.vScale;\r\n rtt.uAng = texture.uAng;\r\n rtt.vAng = texture.vAng;\r\n rtt.wAng = texture.wAng;\r\n rtt.coordinatesIndex = texture.coordinatesIndex;\r\n rtt.level = texture.level;\r\n rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;\r\n (<InternalTexture>rtt._texture).isReady = false;\r\n\r\n texture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n texture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n const passPostProcess = new PassPostProcess(\r\n \"pass\",\r\n 1,\r\n null,\r\n useBilinearMode ? Texture.BILINEAR_SAMPLINGMODE : Texture.NEAREST_SAMPLINGMODE,\r\n engine,\r\n false,\r\n Constants.TEXTURETYPE_UNSIGNED_INT\r\n );\r\n passPostProcess.externalTextureSamplerBinding = true;\r\n passPostProcess.getEffect().executeWhenCompiled(() => {\r\n passPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n };\r\n\r\n const internalTexture = rtt.renderTarget;\r\n\r\n if (internalTexture) {\r\n scene.postProcessManager.directRender([passPostProcess], internalTexture);\r\n\r\n engine.unBindFramebuffer(internalTexture);\r\n rtt.disposeFramebufferObjects();\r\n passPostProcess.dispose();\r\n\r\n rtt.getInternalTexture()!.isReady = true;\r\n }\r\n });\r\n\r\n return rtt;\r\n}\r\n\r\n/**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @param width width of the output texture. If not provided, use the one from internalTexture\r\n * @param height height of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\nexport function ApplyPostProcess(\r\n postProcessName: string,\r\n internalTexture: InternalTexture,\r\n scene: Scene,\r\n type?: number,\r\n samplingMode?: number,\r\n format?: number,\r\n width?: number,\r\n height?: number\r\n): Promise<InternalTexture> {\r\n // Gets everything ready.\r\n const engine = internalTexture.getEngine() as Engine;\r\n\r\n internalTexture.isReady = false;\r\n\r\n samplingMode = samplingMode ?? internalTexture.samplingMode;\r\n type = type ?? internalTexture.type;\r\n format = format ?? internalTexture.format;\r\n width = width ?? internalTexture.width;\r\n height = height ?? internalTexture.height;\r\n\r\n if (type === -1) {\r\n type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n }\r\n\r\n return new Promise((resolve) => {\r\n // Create the post process\r\n const postProcess = new PostProcess(\"postprocess\", postProcessName, null, null, 1, null, samplingMode, engine, false, undefined, type, undefined, null, false, format);\r\n postProcess.externalTextureSamplerBinding = true;\r\n\r\n // Hold the output of the decoding.\r\n const encodedTexture = engine.createRenderTargetTexture(\r\n { width: width as number, height: height as number },\r\n {\r\n generateDepthBuffer: false,\r\n generateMipMaps: false,\r\n generateStencilBuffer: false,\r\n samplingMode,\r\n type,\r\n format,\r\n }\r\n );\r\n\r\n postProcess.getEffect().executeWhenCompiled(() => {\r\n // PP Render Pass\r\n postProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", internalTexture);\r\n effect.setFloat2(\"scale\", 1, 1);\r\n };\r\n scene.postProcessManager.directRender([postProcess!], encodedTexture, true);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n engine._releaseTexture(internalTexture);\r\n if (postProcess) {\r\n postProcess.dispose();\r\n }\r\n\r\n // Internal Swap\r\n encodedTexture._swapAndDie(internalTexture);\r\n\r\n // Ready to get rolling again.\r\n internalTexture.type = type!;\r\n internalTexture.format = Constants.TEXTUREFORMAT_RGBA;\r\n internalTexture.isReady = true;\r\n\r\n resolve(internalTexture);\r\n });\r\n });\r\n}\r\n\r\n// ref: http://stackoverflow.com/questions/32633585/how-do-you-convert-to-half-floats-in-javascript\r\nlet floatView: Float32Array;\r\nlet int32View: Int32Array;\r\n/**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\nexport function ToHalfFloat(value: number): number {\r\n if (!floatView) {\r\n floatView = new Float32Array(1);\r\n int32View = new Int32Array(floatView.buffer);\r\n }\r\n\r\n floatView[0] = value;\r\n const x = int32View[0];\r\n\r\n let bits = (x >> 16) & 0x8000; /* Get the sign */\r\n let m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */\r\n const e = (x >> 23) & 0xff; /* Using int is faster here */\r\n\r\n /* If zero, or denormal, or exponent underflows too much for a denormal\r\n * half, return signed zero. */\r\n if (e < 103) {\r\n return bits;\r\n }\r\n\r\n /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */\r\n if (e > 142) {\r\n bits |= 0x7c00;\r\n /* If exponent was 0xff and one mantissa bit was set, it means NaN,\r\n * not Inf, so make sure we set one mantissa bit too. */\r\n bits |= (e == 255 ? 0 : 1) && x & 0x007fffff;\r\n return bits;\r\n }\r\n\r\n /* If exponent underflows but not too much, return a denormal */\r\n if (e < 113) {\r\n m |= 0x0800;\r\n /* Extra rounding may overflow and set mantissa to 0 and exponent\r\n * to 1, which is OK. */\r\n bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);\r\n return bits;\r\n }\r\n\r\n bits |= ((e - 112) << 10) | (m >> 1);\r\n bits += m & 1;\r\n return bits;\r\n}\r\n\r\n/**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\nexport function FromHalfFloat(value: number): number {\r\n const s = (value & 0x8000) >> 15;\r\n const e = (value & 0x7c00) >> 10;\r\n const f = value & 0x03ff;\r\n\r\n if (e === 0) {\r\n return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));\r\n } else if (e == 0x1f) {\r\n return f ? NaN : (s ? -1 : 1) * Infinity;\r\n }\r\n\r\n return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + f / Math.pow(2, 10));\r\n}\r\n\r\nconst ProcessAsync = async (texture: BaseTexture, width: number, height: number, face: number, lod: number): Promise<Uint8Array> => {\r\n const scene = texture.getScene()!;\r\n const engine = scene.getEngine();\r\n\r\n let lodPostProcess: PostProcess;\r\n\r\n if (!texture.isCube) {\r\n lodPostProcess = new PostProcess(\"lod\", \"lod\", [\"lod\", \"gamma\"], null, 1.0, null, Texture.NEAREST_NEAREST_MIPNEAREST, engine);\r\n } else {\r\n const faceDefines = [\"#define POSITIVEX\", \"#define NEGATIVEX\", \"#define POSITIVEY\", \"#define NEGATIVEY\", \"#define POSITIVEZ\", \"#define NEGATIVEZ\"];\r\n lodPostProcess = new PostProcess(\"lodCube\", \"lodCube\", [\"lod\", \"gamma\"], null, 1.0, null, Texture.NEAREST_NEAREST_MIPNEAREST, engine, false, faceDefines[face]);\r\n }\r\n\r\n await new Promise((resolve) => {\r\n lodPostProcess.getEffect().executeWhenCompiled(() => {\r\n resolve(0);\r\n });\r\n });\r\n\r\n const rtt = new RenderTargetTexture(\"temp\", { width: width, height: height }, scene, false);\r\n\r\n lodPostProcess.onApply = function (effect) {\r\n effect.setTexture(\"textureSampler\", texture);\r\n effect.setFloat(\"lod\", lod);\r\n effect.setBool(\"gamma\", texture.gammaSpace);\r\n };\r\n\r\n const internalTexture = texture.getInternalTexture();\r\n\r\n try {\r\n if (rtt.renderTarget && internalTexture) {\r\n const samplingMode = internalTexture.samplingMode;\r\n if (lod !== 0) {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST_MIPNEAREST);\r\n } else {\r\n texture.updateSamplingMode(Texture.NEAREST_NEAREST);\r\n }\r\n\r\n scene.postProcessManager.directRender([lodPostProcess], rtt.renderTarget, true);\r\n texture.updateSamplingMode(samplingMode);\r\n\r\n //Reading datas from WebGL\r\n const bufferView = await engine.readPixels(0, 0, width, height);\r\n const data = new Uint8Array(bufferView.buffer, 0, bufferView.byteLength);\r\n\r\n // Unbind\r\n engine.unBindFramebuffer(rtt.renderTarget);\r\n\r\n return data;\r\n } else {\r\n throw Error(\"Render to texture failed.\");\r\n }\r\n } finally {\r\n rtt.dispose();\r\n lodPostProcess.dispose();\r\n }\r\n};\r\n\r\n/**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\nexport async function GetTextureDataAsync(texture: BaseTexture, width: number, height: number, face: number = 0, lod: number = 0): Promise<Uint8Array> {\r\n if (!texture.isReady() && texture._texture) {\r\n await new Promise((resolve, reject) => {\r\n if (texture._texture === null) {\r\n reject(0);\r\n return;\r\n }\r\n texture._texture.onLoadedObservable.addOnce(() => {\r\n resolve(0);\r\n });\r\n });\r\n }\r\n return await ProcessAsync(texture, width, height, face, lod);\r\n}\r\n\r\n/**\r\n * Class used to host texture specific utilities\r\n */\r\nexport const TextureTools = {\r\n /**\r\n * Uses the GPU to create a copy texture rescaled at a given size\r\n * @param texture Texture to copy from\r\n * @param width defines the desired width\r\n * @param height defines the desired height\r\n * @param useBilinearMode defines if bilinear mode has to be used\r\n * @returns the generated texture\r\n */\r\n CreateResizedCopy,\r\n\r\n /**\r\n * Apply a post process to a texture\r\n * @param postProcessName name of the fragment post process\r\n * @param internalTexture the texture to encode\r\n * @param scene the scene hosting the texture\r\n * @param type type of the output texture. If not provided, use the one from internalTexture\r\n * @param samplingMode sampling mode to use to sample the source texture. If not provided, use the one from internalTexture\r\n * @param format format of the output texture. If not provided, use the one from internalTexture\r\n * @returns a promise with the internalTexture having its texture replaced by the result of the processing\r\n */\r\n ApplyPostProcess,\r\n /**\r\n * Converts a number to half float\r\n * @param value number to convert\r\n * @returns converted number\r\n */\r\n ToHalfFloat,\r\n\r\n /**\r\n * Converts a half float to a number\r\n * @param value half float to convert\r\n * @returns converted half float\r\n */\r\n FromHalfFloat,\r\n\r\n /**\r\n * Gets the data of the specified texture by rendering it to an intermediate RGBA texture and retrieving the bytes from it.\r\n * This is convienent to get 8-bit RGBA values for a texture in a GPU compressed format.\r\n * @param texture the source texture\r\n * @param width the width of the result, which does not have to match the source texture width\r\n * @param height the height of the result, which does not have to match the source texture height\r\n * @param face if the texture has multiple faces, the face index to use for the source\r\n * @param channels a filter for which of the RGBA channels to return in the result\r\n * @param lod if the texture has multiple LODs, the lod index to use for the source\r\n * @returns the 8-bit texture data\r\n */\r\n GetTextureDataAsync,\r\n};\r\n"]}
package/Misc/timer.d.ts CHANGED
@@ -88,8 +88,9 @@ export declare enum TimerState {
88
88
  * A simple version of the timer. Will take options and start the timer immediately after calling it
89
89
  *
90
90
  * @param options options with which to initialize this timer
91
+ * @returns an observer that can be used to stop the timer
91
92
  */
92
- export declare function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
93
+ export declare function setAndStartTimer<T = any>(options: ITimerOptions<T>): Nullable<Observer<T>>;
93
94
  /**
94
95
  * An advanced implementation of a timer class
95
96
  */
package/Misc/timer.js CHANGED
@@ -21,6 +21,7 @@ export var TimerState;
21
21
  * A simple version of the timer. Will take options and start the timer immediately after calling it
22
22
  *
23
23
  * @param options options with which to initialize this timer
24
+ * @returns an observer that can be used to stop the timer
24
25
  */
25
26
  export function setAndStartTimer(options) {
26
27
  var _a;
package/Misc/timer.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/timer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAuEhD;;GAEG;AACH,MAAM,CAAN,IAAY,UAaX;AAbD,WAAY,UAAU;IAClB;;OAEG;IACH,2CAAI,CAAA;IACJ;;OAEG;IACH,iDAAO,CAAA;IACP;;OAEG;IACH,6CAAK,CAAA;AACT,CAAC,EAbW,UAAU,KAAV,UAAU,QAarB;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA2B;;IACxD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,OAAO,CAAC,oBAAoB,GAAG,MAAA,OAAO,CAAC,oBAAoB,mCAAI,EAAE,CAAC;IAClE,MAAM,QAAQ,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAC1C,CAAC,OAAY,EAAE,EAAE;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,KAAK,GAAG,GAAG,GAAG,SAAS,CAAC;QACxB,MAAM,IAAI,GAAoB;YAC1B,SAAS;YACT,WAAW,EAAE,GAAG;YAChB,SAAS,EAAE,KAAK;YAChB,YAAY,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO;YACrC,OAAO;SACV,CAAC;QACF,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,OAAO,CAAC,cAA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;QACvB,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAoBO,KAAK,CAAC,IAAmB,EAAE,UAAmB,KAAK;QACvD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACvD;aAAM;YACH,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACrD;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable } from \"../scene\";\r\n\r\n/**\r\n * Construction options for a timer\r\n */\r\nexport interface ITimerOptions<T> {\r\n /**\r\n * Time-to-end\r\n */\r\n timeout: number;\r\n /**\r\n * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.\r\n * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if\r\n * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time\r\n */\r\n contextObservable: Observable<T>;\r\n /**\r\n * Optional parameters when adding an observer to the observable\r\n */\r\n observableParameters?: {\r\n mask?: number;\r\n insertFirst?: boolean;\r\n scope?: any;\r\n };\r\n /**\r\n * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!\r\n */\r\n breakCondition?: (data?: ITimerData<T>) => boolean;\r\n /**\r\n * Will be triggered when the time condition has met\r\n */\r\n onEnded?: (data: ITimerData<any>) => void;\r\n /**\r\n * Will be triggered when the break condition has met (prematurely ended)\r\n */\r\n onAborted?: (data: ITimerData<any>) => void;\r\n /**\r\n * Optional function to execute on each tick (or count)\r\n */\r\n onTick?: (data: ITimerData<any>) => void;\r\n}\r\n\r\n/**\r\n * An interface defining the data sent by the timer\r\n */\r\nexport interface ITimerData<T> {\r\n /**\r\n * When did it start\r\n */\r\n startTime: number;\r\n /**\r\n * Time now\r\n */\r\n currentTime: number;\r\n /**\r\n * Time passed since started\r\n */\r\n deltaTime: number;\r\n /**\r\n * How much is completed, in [0.0...1.0].\r\n * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls\r\n */\r\n completeRate: number;\r\n /**\r\n * What the registered observable sent in the last count\r\n */\r\n payload: T;\r\n}\r\n\r\n/**\r\n * The current state of the timer\r\n */\r\nexport enum TimerState {\r\n /**\r\n * Timer initialized, not yet started\r\n */\r\n INIT,\r\n /**\r\n * Timer started and counting\r\n */\r\n STARTED,\r\n /**\r\n * Timer ended (whether aborted or time reached)\r\n */\r\n ENDED,\r\n}\r\n\r\n/**\r\n * A simple version of the timer. Will take options and start the timer immediately after calling it\r\n *\r\n * @param options options with which to initialize this timer\r\n */\r\nexport function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>> {\r\n let timer = 0;\r\n const startTime = Date.now();\r\n options.observableParameters = options.observableParameters ?? {};\r\n const observer = options.contextObservable.add(\r\n (payload: any) => {\r\n const now = Date.now();\r\n timer = now - startTime;\r\n const data: ITimerData<any> = {\r\n startTime,\r\n currentTime: now,\r\n deltaTime: timer,\r\n completeRate: timer / options.timeout,\r\n payload,\r\n };\r\n options.onTick && options.onTick(data);\r\n if (options.breakCondition && options.breakCondition()) {\r\n options.contextObservable.remove(observer);\r\n options.onAborted && options.onAborted(data);\r\n }\r\n if (timer >= options.timeout) {\r\n options.contextObservable.remove(observer);\r\n options.onEnded && options.onEnded(data);\r\n }\r\n },\r\n options.observableParameters.mask,\r\n options.observableParameters.insertFirst,\r\n options.observableParameters.scope\r\n );\r\n return observer;\r\n}\r\n\r\n/**\r\n * An advanced implementation of a timer class\r\n */\r\nexport class AdvancedTimer<T = any> implements IDisposable {\r\n /**\r\n * Will notify each time the timer calculates the remaining time\r\n */\r\n public onEachCountObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer was aborted due to the break condition\r\n */\r\n public onTimerAbortedObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer ended successfully\r\n */\r\n public onTimerEndedObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer state has changed\r\n */\r\n public onStateChangedObservable: Observable<TimerState> = new Observable();\r\n\r\n private _observer: Nullable<Observer<T>> = null;\r\n private _contextObservable: Observable<T>;\r\n private _observableParameters: {\r\n mask?: number;\r\n insertFirst?: boolean;\r\n scope?: any;\r\n };\r\n private _startTime: number;\r\n private _timer: number;\r\n private _state: TimerState;\r\n private _breakCondition: (data: ITimerData<T>) => boolean;\r\n private _timeToEnd: number;\r\n private _breakOnNextTick: boolean = false;\r\n\r\n /**\r\n * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.\r\n * @param options construction options for this advanced timer\r\n */\r\n constructor(options: ITimerOptions<T>) {\r\n this._setState(TimerState.INIT);\r\n this._contextObservable = options.contextObservable;\r\n this._observableParameters = options.observableParameters ?? {};\r\n this._breakCondition = options.breakCondition ?? (() => false);\r\n this._timeToEnd = options.timeout;\r\n if (options.onEnded) {\r\n this.onTimerEndedObservable.add(options.onEnded);\r\n }\r\n if (options.onTick) {\r\n this.onEachCountObservable.add(options.onTick);\r\n }\r\n if (options.onAborted) {\r\n this.onTimerAbortedObservable.add(options.onAborted);\r\n }\r\n }\r\n\r\n /**\r\n * set a breaking condition for this timer. Default is to never break during count\r\n * @param predicate the new break condition. Returns true to break, false otherwise\r\n */\r\n public set breakCondition(predicate: (data: ITimerData<T>) => boolean) {\r\n this._breakCondition = predicate;\r\n }\r\n\r\n /**\r\n * Reset ALL associated observables in this advanced timer\r\n */\r\n public clearObservables() {\r\n this.onEachCountObservable.clear();\r\n this.onTimerAbortedObservable.clear();\r\n this.onTimerEndedObservable.clear();\r\n this.onStateChangedObservable.clear();\r\n }\r\n\r\n /**\r\n * Will start a new iteration of this timer. Only one instance of this timer can run at a time.\r\n *\r\n * @param timeToEnd how much time to measure until timer ended\r\n */\r\n public start(timeToEnd: number = this._timeToEnd) {\r\n if (this._state === TimerState.STARTED) {\r\n throw new Error(\"Timer already started. Please stop it before starting again\");\r\n }\r\n this._timeToEnd = timeToEnd;\r\n this._startTime = Date.now();\r\n this._timer = 0;\r\n this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope);\r\n this._setState(TimerState.STARTED);\r\n }\r\n\r\n /**\r\n * Will force a stop on the next tick.\r\n */\r\n public stop() {\r\n if (this._state !== TimerState.STARTED) {\r\n return;\r\n }\r\n this._breakOnNextTick = true;\r\n }\r\n\r\n /**\r\n * Dispose this timer, clearing all resources\r\n */\r\n public dispose() {\r\n if (this._observer) {\r\n this._contextObservable.remove(this._observer);\r\n }\r\n this.clearObservables();\r\n }\r\n\r\n private _setState(newState: TimerState) {\r\n this._state = newState;\r\n this.onStateChangedObservable.notifyObservers(this._state);\r\n }\r\n\r\n private _tick = (payload: T) => {\r\n const now = Date.now();\r\n this._timer = now - this._startTime;\r\n const data: ITimerData<T> = {\r\n startTime: this._startTime,\r\n currentTime: now,\r\n deltaTime: this._timer,\r\n completeRate: this._timer / this._timeToEnd,\r\n payload,\r\n };\r\n const shouldBreak = this._breakOnNextTick || this._breakCondition(data);\r\n if (shouldBreak || this._timer >= this._timeToEnd) {\r\n this._stop(data, shouldBreak);\r\n } else {\r\n this.onEachCountObservable.notifyObservers(data);\r\n }\r\n };\r\n\r\n private _stop(data: ITimerData<T>, aborted: boolean = false) {\r\n this._contextObservable.remove(this._observer);\r\n this._setState(TimerState.ENDED);\r\n if (aborted) {\r\n this.onTimerAbortedObservable.notifyObservers(data);\r\n } else {\r\n this.onTimerEndedObservable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"timer.js","sourceRoot":"","sources":["../../../../dev/core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E;YACT,IAAI,CAAC,wBAAwB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACvD;aAAM;YACH,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;SACrD;IACL,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IDisposable } from \"../scene\";\r\n\r\n/**\r\n * Construction options for a timer\r\n */\r\nexport interface ITimerOptions<T> {\r\n /**\r\n * Time-to-end\r\n */\r\n timeout: number;\r\n /**\r\n * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.\r\n * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if\r\n * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time\r\n */\r\n contextObservable: Observable<T>;\r\n /**\r\n * Optional parameters when adding an observer to the observable\r\n */\r\n observableParameters?: {\r\n mask?: number;\r\n insertFirst?: boolean;\r\n scope?: any;\r\n };\r\n /**\r\n * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!\r\n */\r\n breakCondition?: (data?: ITimerData<T>) => boolean;\r\n /**\r\n * Will be triggered when the time condition has met\r\n */\r\n onEnded?: (data: ITimerData<any>) => void;\r\n /**\r\n * Will be triggered when the break condition has met (prematurely ended)\r\n */\r\n onAborted?: (data: ITimerData<any>) => void;\r\n /**\r\n * Optional function to execute on each tick (or count)\r\n */\r\n onTick?: (data: ITimerData<any>) => void;\r\n}\r\n\r\n/**\r\n * An interface defining the data sent by the timer\r\n */\r\nexport interface ITimerData<T> {\r\n /**\r\n * When did it start\r\n */\r\n startTime: number;\r\n /**\r\n * Time now\r\n */\r\n currentTime: number;\r\n /**\r\n * Time passed since started\r\n */\r\n deltaTime: number;\r\n /**\r\n * How much is completed, in [0.0...1.0].\r\n * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls\r\n */\r\n completeRate: number;\r\n /**\r\n * What the registered observable sent in the last count\r\n */\r\n payload: T;\r\n}\r\n\r\n/**\r\n * The current state of the timer\r\n */\r\nexport enum TimerState {\r\n /**\r\n * Timer initialized, not yet started\r\n */\r\n INIT,\r\n /**\r\n * Timer started and counting\r\n */\r\n STARTED,\r\n /**\r\n * Timer ended (whether aborted or time reached)\r\n */\r\n ENDED,\r\n}\r\n\r\n/**\r\n * A simple version of the timer. Will take options and start the timer immediately after calling it\r\n *\r\n * @param options options with which to initialize this timer\r\n * @returns an observer that can be used to stop the timer\r\n */\r\nexport function setAndStartTimer<T = any>(options: ITimerOptions<T>): Nullable<Observer<T>> {\r\n let timer = 0;\r\n const startTime = Date.now();\r\n options.observableParameters = options.observableParameters ?? {};\r\n const observer = options.contextObservable.add(\r\n (payload: any) => {\r\n const now = Date.now();\r\n timer = now - startTime;\r\n const data: ITimerData<any> = {\r\n startTime,\r\n currentTime: now,\r\n deltaTime: timer,\r\n completeRate: timer / options.timeout,\r\n payload,\r\n };\r\n options.onTick && options.onTick(data);\r\n if (options.breakCondition && options.breakCondition()) {\r\n options.contextObservable.remove(observer);\r\n options.onAborted && options.onAborted(data);\r\n }\r\n if (timer >= options.timeout) {\r\n options.contextObservable.remove(observer);\r\n options.onEnded && options.onEnded(data);\r\n }\r\n },\r\n options.observableParameters.mask,\r\n options.observableParameters.insertFirst,\r\n options.observableParameters.scope\r\n );\r\n return observer;\r\n}\r\n\r\n/**\r\n * An advanced implementation of a timer class\r\n */\r\nexport class AdvancedTimer<T = any> implements IDisposable {\r\n /**\r\n * Will notify each time the timer calculates the remaining time\r\n */\r\n public onEachCountObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer was aborted due to the break condition\r\n */\r\n public onTimerAbortedObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer ended successfully\r\n */\r\n public onTimerEndedObservable: Observable<ITimerData<T>> = new Observable();\r\n /**\r\n * Will trigger when the timer state has changed\r\n */\r\n public onStateChangedObservable: Observable<TimerState> = new Observable();\r\n\r\n private _observer: Nullable<Observer<T>> = null;\r\n private _contextObservable: Observable<T>;\r\n private _observableParameters: {\r\n mask?: number;\r\n insertFirst?: boolean;\r\n scope?: any;\r\n };\r\n private _startTime: number;\r\n private _timer: number;\r\n private _state: TimerState;\r\n private _breakCondition: (data: ITimerData<T>) => boolean;\r\n private _timeToEnd: number;\r\n private _breakOnNextTick: boolean = false;\r\n\r\n /**\r\n * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.\r\n * @param options construction options for this advanced timer\r\n */\r\n constructor(options: ITimerOptions<T>) {\r\n this._setState(TimerState.INIT);\r\n this._contextObservable = options.contextObservable;\r\n this._observableParameters = options.observableParameters ?? {};\r\n this._breakCondition = options.breakCondition ?? (() => false);\r\n this._timeToEnd = options.timeout;\r\n if (options.onEnded) {\r\n this.onTimerEndedObservable.add(options.onEnded);\r\n }\r\n if (options.onTick) {\r\n this.onEachCountObservable.add(options.onTick);\r\n }\r\n if (options.onAborted) {\r\n this.onTimerAbortedObservable.add(options.onAborted);\r\n }\r\n }\r\n\r\n /**\r\n * set a breaking condition for this timer. Default is to never break during count\r\n * @param predicate the new break condition. Returns true to break, false otherwise\r\n */\r\n public set breakCondition(predicate: (data: ITimerData<T>) => boolean) {\r\n this._breakCondition = predicate;\r\n }\r\n\r\n /**\r\n * Reset ALL associated observables in this advanced timer\r\n */\r\n public clearObservables() {\r\n this.onEachCountObservable.clear();\r\n this.onTimerAbortedObservable.clear();\r\n this.onTimerEndedObservable.clear();\r\n this.onStateChangedObservable.clear();\r\n }\r\n\r\n /**\r\n * Will start a new iteration of this timer. Only one instance of this timer can run at a time.\r\n *\r\n * @param timeToEnd how much time to measure until timer ended\r\n */\r\n public start(timeToEnd: number = this._timeToEnd) {\r\n if (this._state === TimerState.STARTED) {\r\n throw new Error(\"Timer already started. Please stop it before starting again\");\r\n }\r\n this._timeToEnd = timeToEnd;\r\n this._startTime = Date.now();\r\n this._timer = 0;\r\n this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope);\r\n this._setState(TimerState.STARTED);\r\n }\r\n\r\n /**\r\n * Will force a stop on the next tick.\r\n */\r\n public stop() {\r\n if (this._state !== TimerState.STARTED) {\r\n return;\r\n }\r\n this._breakOnNextTick = true;\r\n }\r\n\r\n /**\r\n * Dispose this timer, clearing all resources\r\n */\r\n public dispose() {\r\n if (this._observer) {\r\n this._contextObservable.remove(this._observer);\r\n }\r\n this.clearObservables();\r\n }\r\n\r\n private _setState(newState: TimerState) {\r\n this._state = newState;\r\n this.onStateChangedObservable.notifyObservers(this._state);\r\n }\r\n\r\n private _tick = (payload: T) => {\r\n const now = Date.now();\r\n this._timer = now - this._startTime;\r\n const data: ITimerData<T> = {\r\n startTime: this._startTime,\r\n currentTime: now,\r\n deltaTime: this._timer,\r\n completeRate: this._timer / this._timeToEnd,\r\n payload,\r\n };\r\n const shouldBreak = this._breakOnNextTick || this._breakCondition(data);\r\n if (shouldBreak || this._timer >= this._timeToEnd) {\r\n this._stop(data, shouldBreak);\r\n } else {\r\n this.onEachCountObservable.notifyObservers(data);\r\n }\r\n };\r\n\r\n private _stop(data: ITimerData<T>, aborted: boolean = false) {\r\n this._contextObservable.remove(this._observer);\r\n this._setState(TimerState.ENDED);\r\n if (aborted) {\r\n this.onTimerAbortedObservable.notifyObservers(data);\r\n } else {\r\n this.onTimerEndedObservable.notifyObservers(data);\r\n }\r\n }\r\n}\r\n"]}