@babylonjs/core 6.23.1 → 6.25.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 (344) hide show
  1. package/Buffers/buffer.align.d.ts +25 -0
  2. package/Buffers/buffer.align.js +120 -0
  3. package/Buffers/buffer.align.js.map +1 -0
  4. package/Buffers/buffer.d.ts +15 -3
  5. package/Buffers/buffer.js +27 -7
  6. package/Buffers/buffer.js.map +1 -1
  7. package/Buffers/index.d.ts +1 -0
  8. package/Buffers/index.js +1 -0
  9. package/Buffers/index.js.map +1 -1
  10. package/Cameras/Inputs/BaseCameraPointersInput.js +0 -3
  11. package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
  12. package/Cameras/Inputs/flyCameraMouseInput.js +1 -4
  13. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  14. package/Cameras/Inputs/freeCameraMouseInput.js +0 -6
  15. package/Cameras/Inputs/freeCameraMouseInput.js.map +1 -1
  16. package/Cameras/RigModes/index.d.ts +0 -1
  17. package/Cameras/RigModes/index.js +0 -1
  18. package/Cameras/RigModes/index.js.map +1 -1
  19. package/Cameras/RigModes/vrRigMode.js +1 -1
  20. package/Cameras/RigModes/vrRigMode.js.map +1 -1
  21. package/Cameras/VR/index.d.ts +0 -1
  22. package/Cameras/VR/index.js +0 -1
  23. package/Cameras/VR/index.js.map +1 -1
  24. package/Cameras/VR/vrExperienceHelper.d.ts +7 -66
  25. package/Cameras/VR/vrExperienceHelper.js +17 -702
  26. package/Cameras/VR/vrExperienceHelper.js.map +1 -1
  27. package/Cameras/camera.d.ts +15 -20
  28. package/Cameras/camera.js +41 -36
  29. package/Cameras/camera.js.map +1 -1
  30. package/Cameras/targetCamera.js +1 -1
  31. package/Cameras/targetCamera.js.map +1 -1
  32. package/Engines/Extensions/index.d.ts +0 -1
  33. package/Engines/Extensions/index.js +0 -1
  34. package/Engines/Extensions/index.js.map +1 -1
  35. package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +4 -0
  36. package/Engines/WebGL/webGLRenderTargetWrapper.js +4 -0
  37. package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
  38. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +8 -7
  39. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  40. package/Engines/WebGPU/webgpuCacheSampler.js +1 -1
  41. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  42. package/Engines/constants.d.ts +0 -4
  43. package/Engines/constants.js +0 -4
  44. package/Engines/constants.js.map +1 -1
  45. package/Engines/engine.d.ts +38 -258
  46. package/Engines/engine.js +0 -65
  47. package/Engines/engine.js.map +1 -1
  48. package/Engines/engineFactory.js +9 -14
  49. package/Engines/engineFactory.js.map +1 -1
  50. package/Engines/engineFeatures.d.ts +2 -0
  51. package/Engines/engineFeatures.js.map +1 -1
  52. package/Engines/nativeEngine.js +1 -0
  53. package/Engines/nativeEngine.js.map +1 -1
  54. package/Engines/nullEngine.js +1 -0
  55. package/Engines/nullEngine.js.map +1 -1
  56. package/Engines/thinEngine.d.ts +22 -5
  57. package/Engines/thinEngine.js +55 -22
  58. package/Engines/thinEngine.js.map +1 -1
  59. package/Engines/webgpuEngine.d.ts +1 -0
  60. package/Engines/webgpuEngine.js +4 -2
  61. package/Engines/webgpuEngine.js.map +1 -1
  62. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +9 -8
  63. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +34 -16
  64. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +1 -1
  65. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.d.ts +4 -3
  66. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js +14 -6
  67. package/FlowGraph/Blocks/Data/Logic/flowGraphLogicBlocks.js.map +1 -1
  68. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.d.ts +19 -14
  69. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js +64 -27
  70. package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js.map +1 -1
  71. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +39 -41
  72. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +152 -74
  73. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
  74. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.d.ts +12 -12
  75. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js +42 -21
  76. package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js.map +1 -1
  77. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.d.ts +17 -14
  78. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js +62 -26
  79. package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js.map +1 -1
  80. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.d.ts +13 -10
  81. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js +46 -18
  82. package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js.map +1 -1
  83. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.d.ts +4 -1
  84. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +6 -2
  85. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  86. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.d.ts +3 -1
  87. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +7 -2
  88. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.d.ts +5 -3
  90. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +10 -5
  91. package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
  92. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +4 -1
  93. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +6 -2
  94. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  95. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.d.ts +3 -1
  96. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js +7 -2
  97. package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
  98. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +3 -1
  99. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +7 -2
  100. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  101. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.d.ts +4 -1
  102. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +6 -2
  103. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  104. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +6 -2
  105. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +12 -3
  106. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  107. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +5 -3
  108. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +11 -6
  109. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  110. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.d.ts +1 -0
  111. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js +7 -2
  112. package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
  113. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.d.ts +1 -0
  114. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js +7 -2
  115. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  116. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +3 -1
  117. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +7 -2
  118. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
  119. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +3 -1
  120. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +8 -3
  121. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  122. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.d.ts +3 -1
  123. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +7 -2
  124. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  125. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.d.ts +3 -1
  126. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +7 -2
  127. package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
  128. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.d.ts +3 -1
  129. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +7 -2
  130. package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
  131. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.d.ts +3 -1
  132. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +7 -2
  133. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
  134. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +3 -1
  135. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +7 -2
  136. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
  137. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +3 -1
  138. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +7 -2
  139. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
  140. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +3 -1
  141. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +7 -2
  142. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  143. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +3 -1
  144. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +7 -2
  145. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
  146. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.d.ts +3 -1
  147. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +7 -2
  148. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
  149. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +6 -3
  150. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +22 -16
  151. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
  152. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +7 -4
  153. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +15 -10
  154. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
  155. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +3 -1
  156. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +7 -2
  157. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  158. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.d.ts +3 -1
  159. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +8 -3
  160. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
  161. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +7 -4
  162. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +14 -7
  163. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
  164. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +5 -3
  165. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +9 -4
  166. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
  167. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.d.ts +3 -1
  168. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +7 -2
  169. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  170. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.d.ts +3 -1
  171. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +8 -3
  172. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
  173. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +3 -1
  174. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +7 -2
  175. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  176. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +3 -1
  177. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +7 -2
  178. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  179. package/FlowGraph/flowGraph.d.ts +41 -3
  180. package/FlowGraph/flowGraph.js +135 -0
  181. package/FlowGraph/flowGraph.js.map +1 -1
  182. package/FlowGraph/flowGraphAsyncExecutionBlock.d.ts +2 -1
  183. package/FlowGraph/flowGraphAsyncExecutionBlock.js +2 -2
  184. package/FlowGraph/flowGraphAsyncExecutionBlock.js.map +1 -1
  185. package/FlowGraph/flowGraphBlock.d.ts +15 -3
  186. package/FlowGraph/flowGraphBlock.js +50 -7
  187. package/FlowGraph/flowGraphBlock.js.map +1 -1
  188. package/FlowGraph/flowGraphConnection.d.ts +34 -4
  189. package/FlowGraph/flowGraphConnection.js +49 -3
  190. package/FlowGraph/flowGraphConnection.js.map +1 -1
  191. package/FlowGraph/flowGraphContext.d.ts +25 -5
  192. package/FlowGraph/flowGraphContext.js +86 -4
  193. package/FlowGraph/flowGraphContext.js.map +1 -1
  194. package/FlowGraph/flowGraphCoordinator.d.ts +7 -1
  195. package/FlowGraph/flowGraphCoordinator.js +18 -2
  196. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  197. package/FlowGraph/flowGraphDataConnection.d.ts +4 -11
  198. package/FlowGraph/flowGraphDataConnection.js +16 -14
  199. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  200. package/FlowGraph/flowGraphExecutionBlock.d.ts +8 -3
  201. package/FlowGraph/flowGraphExecutionBlock.js +37 -6
  202. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  203. package/FlowGraph/flowGraphRichTypes.d.ts +5 -9
  204. package/FlowGraph/flowGraphRichTypes.js +29 -44
  205. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  206. package/FlowGraph/flowGraphSignalConnection.js +2 -0
  207. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  208. package/FlowGraph/flowGraphVariableDefinitions.d.ts +22 -2
  209. package/FlowGraph/flowGraphVariableDefinitions.js +29 -0
  210. package/FlowGraph/flowGraphVariableDefinitions.js.map +1 -1
  211. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.d.ts +2 -1
  212. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js +2 -2
  213. package/FlowGraph/flowGraphWithOnDoneExecutionBlock.js.map +1 -1
  214. package/Gamepads/gamepadManager.js +0 -5
  215. package/Gamepads/gamepadManager.js.map +1 -1
  216. package/Gamepads/index.d.ts +0 -1
  217. package/Gamepads/index.js +0 -2
  218. package/Gamepads/index.js.map +1 -1
  219. package/Gizmos/gizmo.js +1 -4
  220. package/Gizmos/gizmo.js.map +1 -1
  221. package/Materials/GreasedLine/greasedLineMaterialDefaults.d.ts +24 -0
  222. package/Materials/GreasedLine/greasedLineMaterialDefaults.js +19 -0
  223. package/Materials/GreasedLine/greasedLineMaterialDefaults.js.map +1 -0
  224. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +243 -0
  225. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js +55 -0
  226. package/Materials/GreasedLine/greasedLineMaterialInterfaces.js.map +1 -0
  227. package/Materials/GreasedLine/greasedLinePluginMaterial.d.ts +253 -0
  228. package/Materials/{greasedLinePluginMaterial.js → GreasedLine/greasedLinePluginMaterial.js} +148 -205
  229. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -0
  230. package/Materials/{greasedLineSimpleMaterial.d.ts → GreasedLine/greasedLineSimpleMaterial.d.ts} +20 -48
  231. package/Materials/{greasedLineSimpleMaterial.js → GreasedLine/greasedLineSimpleMaterial.js} +74 -91
  232. package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -0
  233. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +1 -1
  234. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  235. package/Materials/Textures/texture.js +1 -0
  236. package/Materials/Textures/texture.js.map +1 -1
  237. package/Materials/index.d.ts +4 -1
  238. package/Materials/index.js +4 -1
  239. package/Materials/index.js.map +1 -1
  240. package/Maths/math.vector.d.ts +32 -22
  241. package/Maths/math.vector.js +54 -43
  242. package/Maths/math.vector.js.map +1 -1
  243. package/Meshes/Builders/greasedLineBuilder.d.ts +7 -6
  244. package/Meshes/Builders/greasedLineBuilder.js +65 -31
  245. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  246. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +216 -0
  247. package/Meshes/GreasedLine/greasedLineBaseMesh.js +247 -0
  248. package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -0
  249. package/Meshes/GreasedLine/greasedLineMesh.d.ts +92 -0
  250. package/Meshes/{greasedLineMesh.js → GreasedLine/greasedLineMesh.js} +29 -223
  251. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -0
  252. package/Meshes/GreasedLine/greasedLineRibbonMesh.d.ts +107 -0
  253. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +462 -0
  254. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -0
  255. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +9 -2
  256. package/Meshes/Node/Blocks/Sources/meshBlock.js +17 -5
  257. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  258. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +15 -0
  259. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +50 -1
  260. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  261. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +5 -5
  262. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
  263. package/Meshes/Node/nodeGeometry.d.ts +1 -2
  264. package/Meshes/Node/nodeGeometry.js +3 -4
  265. package/Meshes/Node/nodeGeometry.js.map +1 -1
  266. package/Meshes/Node/nodeGeometryBlock.d.ts +1 -2
  267. package/Meshes/Node/nodeGeometryBlock.js +1 -2
  268. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  269. package/Meshes/geometry.js +6 -12
  270. package/Meshes/geometry.js.map +1 -1
  271. package/Meshes/index.d.ts +3 -1
  272. package/Meshes/index.js +3 -1
  273. package/Meshes/index.js.map +1 -1
  274. package/Meshes/mesh.d.ts +4 -0
  275. package/Meshes/mesh.js +7 -0
  276. package/Meshes/mesh.js.map +1 -1
  277. package/Misc/deepCopier.js +3 -0
  278. package/Misc/deepCopier.js.map +1 -1
  279. package/Misc/greasedLineTools.d.ts +52 -5
  280. package/Misc/greasedLineTools.js +180 -10
  281. package/Misc/greasedLineTools.js.map +1 -1
  282. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js +9 -2
  283. package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
  284. package/PostProcesses/motionBlurPostProcess.js +4 -1
  285. package/PostProcesses/motionBlurPostProcess.js.map +1 -1
  286. package/PostProcesses/postProcess.js +1 -6
  287. package/PostProcesses/postProcess.js.map +1 -1
  288. package/Rendering/geometryBufferRenderer.js +4 -0
  289. package/Rendering/geometryBufferRenderer.js.map +1 -1
  290. package/Shaders/greasedLine.fragment.js +2 -5
  291. package/Shaders/greasedLine.fragment.js.map +1 -1
  292. package/Shaders/greasedLine.vertex.js +15 -4
  293. package/Shaders/greasedLine.vertex.js.map +1 -1
  294. package/XR/webXRDefaultExperience.d.ts +1 -1
  295. package/XR/webXRDefaultExperience.js +1 -1
  296. package/XR/webXRDefaultExperience.js.map +1 -1
  297. package/package.json +1 -1
  298. package/scene.d.ts +17 -10
  299. package/scene.js +25 -30
  300. package/scene.js.map +1 -1
  301. package/Cameras/RigModes/webVRRigMode.d.ts +0 -5
  302. package/Cameras/RigModes/webVRRigMode.js +0 -34
  303. package/Cameras/RigModes/webVRRigMode.js.map +0 -1
  304. package/Cameras/VR/webVRCamera.d.ts +0 -316
  305. package/Cameras/VR/webVRCamera.js +0 -618
  306. package/Cameras/VR/webVRCamera.js.map +0 -1
  307. package/Engines/Extensions/engine.webVR.d.ts +0 -91
  308. package/Engines/Extensions/engine.webVR.js +0 -195
  309. package/Engines/Extensions/engine.webVR.js.map +0 -1
  310. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.d.ts +0 -23
  311. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js +0 -18
  312. package/FlowGraph/Blocks/Execution/flowGraphCustomFunctionBlock.js.map +0 -1
  313. package/Gamepads/Controllers/daydreamController.d.ts +0 -38
  314. package/Gamepads/Controllers/daydreamController.js +0 -70
  315. package/Gamepads/Controllers/daydreamController.js.map +0 -1
  316. package/Gamepads/Controllers/gearVRController.d.ts +0 -39
  317. package/Gamepads/Controllers/gearVRController.js +0 -79
  318. package/Gamepads/Controllers/gearVRController.js.map +0 -1
  319. package/Gamepads/Controllers/genericController.d.ts +0 -34
  320. package/Gamepads/Controllers/genericController.js +0 -48
  321. package/Gamepads/Controllers/genericController.js.map +0 -1
  322. package/Gamepads/Controllers/index.d.ts +0 -8
  323. package/Gamepads/Controllers/index.js +0 -9
  324. package/Gamepads/Controllers/index.js.map +0 -1
  325. package/Gamepads/Controllers/oculusTouchController.d.ts +0 -78
  326. package/Gamepads/Controllers/oculusTouchController.js +0 -196
  327. package/Gamepads/Controllers/oculusTouchController.js.map +0 -1
  328. package/Gamepads/Controllers/poseEnabledController.d.ts +0 -219
  329. package/Gamepads/Controllers/poseEnabledController.js +0 -293
  330. package/Gamepads/Controllers/poseEnabledController.js.map +0 -1
  331. package/Gamepads/Controllers/viveController.d.ts +0 -52
  332. package/Gamepads/Controllers/viveController.js +0 -115
  333. package/Gamepads/Controllers/viveController.js.map +0 -1
  334. package/Gamepads/Controllers/webVRController.d.ts +0 -85
  335. package/Gamepads/Controllers/webVRController.js +0 -122
  336. package/Gamepads/Controllers/webVRController.js.map +0 -1
  337. package/Gamepads/Controllers/windowsMotionController.d.ts +0 -212
  338. package/Gamepads/Controllers/windowsMotionController.js +0 -519
  339. package/Gamepads/Controllers/windowsMotionController.js.map +0 -1
  340. package/Materials/greasedLinePluginMaterial.d.ts +0 -496
  341. package/Materials/greasedLinePluginMaterial.js.map +0 -1
  342. package/Materials/greasedLineSimpleMaterial.js.map +0 -1
  343. package/Meshes/greasedLineMesh.d.ts +0 -204
  344. package/Meshes/greasedLineMesh.js.map +0 -1
@@ -1,64 +1,11 @@
1
- import { Engine } from "../Engines/engine.js";
2
- import { RawTexture } from "./Textures/rawTexture.js";
3
- import { MaterialPluginBase } from "./materialPluginBase.js";
4
- import { Vector2, TmpVectors } from "../Maths/math.vector.js";
5
- import { Color3 } from "../Maths/math.color.js";
6
- import { MaterialDefines } from "./materialDefines.js";
7
- import { RegisterClass } from "../Misc/typeStore.js";
8
- /**
9
- * Material types for GreasedLine
10
- * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}
11
- */
12
- export var GreasedLineMeshMaterialType;
13
- (function (GreasedLineMeshMaterialType) {
14
- /**
15
- * StandardMaterial
16
- */
17
- GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_STANDARD"] = 0] = "MATERIAL_TYPE_STANDARD";
18
- /**
19
- * PBR Material
20
- */
21
- GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_PBR"] = 1] = "MATERIAL_TYPE_PBR";
22
- /**
23
- * Simple and fast shader material not supporting lightning nor textures
24
- */
25
- GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_SIMPLE"] = 2] = "MATERIAL_TYPE_SIMPLE";
26
- })(GreasedLineMeshMaterialType || (GreasedLineMeshMaterialType = {}));
27
- /**
28
- * Color blending mode of the @see GreasedLineMaterial and the base material
29
- * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colormode}
30
- */
31
- export var GreasedLineMeshColorMode;
32
- (function (GreasedLineMeshColorMode) {
33
- /**
34
- * Color blending mode SET
35
- */
36
- GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_SET"] = 0] = "COLOR_MODE_SET";
37
- /**
38
- * Color blending mode ADD
39
- */
40
- GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_ADD"] = 1] = "COLOR_MODE_ADD";
41
- /**
42
- * Color blending mode ADD
43
- */
44
- GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_MULTIPLY"] = 2] = "COLOR_MODE_MULTIPLY";
45
- })(GreasedLineMeshColorMode || (GreasedLineMeshColorMode = {}));
46
- /**
47
- * Color distribution type of the @see colors.
48
- * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colordistributiontype}
49
- *
50
- */
51
- export var GreasedLineMeshColorDistributionType;
52
- (function (GreasedLineMeshColorDistributionType) {
53
- /**
54
- * Colors distributed between segments of the line
55
- */
56
- GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_SEGMENT"] = 0] = "COLOR_DISTRIBUTION_TYPE_SEGMENT";
57
- /**
58
- * Colors distributed along the line ingoring the segments
59
- */
60
- GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_LINE"] = 1] = "COLOR_DISTRIBUTION_TYPE_LINE";
61
- })(GreasedLineMeshColorDistributionType || (GreasedLineMeshColorDistributionType = {}));
1
+ import { RawTexture } from "../Textures/rawTexture.js";
2
+ import { MaterialPluginBase } from "../materialPluginBase.js";
3
+ import { Vector2, TmpVectors } from "../../Maths/math.vector.js";
4
+ import { MaterialDefines } from "../materialDefines.js";
5
+ import { RegisterClass } from "../../Misc/typeStore.js";
6
+ import { GreasedLineMeshColorDistributionType, GreasedLineMeshColorMode } from "./greasedLineMaterialInterfaces.js";
7
+ import { GreasedLineMaterialDefaults } from "./greasedLineMaterialDefaults.js";
8
+ import { GreasedLineTools } from "../../Misc/greasedLineTools.js";
62
9
  /**
63
10
  * @internal
64
11
  */
@@ -84,51 +31,72 @@ export class MaterialGreasedLineDefines extends MaterialDefines {
84
31
  * True if scene is in right handed coordinate system.
85
32
  */
86
33
  // eslint-disable-next-line @typescript-eslint/naming-convention
87
- this.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = false;
34
+ this.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = false;
35
+ /**
36
+ * True if the line is in camera facing mode
37
+ */
38
+ // eslint-disable-next-line @typescript-eslint/naming-convention
39
+ this.GREASED_LINE_CAMERA_FACING = true;
88
40
  }
89
41
  }
90
42
  /**
91
- * GreasedLinePluginMaterial for GreasedLineMesh
43
+ * GreasedLinePluginMaterial for GreasedLineMesh/GreasedLineRibbonMesh.
44
+ * Use the GreasedLineBuilder.CreateGreasedLineMaterial function to create and instance of this class.
92
45
  */
93
46
  export class GreasedLinePluginMaterial extends MaterialPluginBase {
47
+ /**
48
+ * Creates a new instance of the GreasedLinePluginMaterial
49
+ * @param material base material for the plugin
50
+ * @param scene the scene
51
+ * @param options plugin options
52
+ */
94
53
  constructor(material, scene, options) {
95
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
54
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
96
55
  options = options || {
97
- color: GreasedLinePluginMaterial.DEFAULT_COLOR,
56
+ color: GreasedLineMaterialDefaults.DEFAULT_COLOR,
98
57
  };
99
58
  const defines = new MaterialGreasedLineDefines();
100
- defines.GREASED_LINE_HAS_COLOR = !!options.color;
59
+ defines.GREASED_LINE_HAS_COLOR = !!options.color && !options.useColors;
101
60
  defines.GREASED_LINE_SIZE_ATTENUATION = (_a = options.sizeAttenuation) !== null && _a !== void 0 ? _a : false;
102
61
  defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
103
- defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = (scene !== null && scene !== void 0 ? scene : material.getScene()).useRightHandedSystem;
62
+ defines.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = (scene !== null && scene !== void 0 ? scene : material.getScene()).useRightHandedSystem;
63
+ defines.GREASED_LINE_CAMERA_FACING = (_b = options.cameraFacing) !== null && _b !== void 0 ? _b : true;
104
64
  super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);
65
+ /**
66
+ * You can provide a colorsTexture to use instead of one generated from the 'colors' option
67
+ */
68
+ this.colorsTexture = null;
105
69
  this._scene = scene !== null && scene !== void 0 ? scene : material.getScene();
106
70
  this._engine = this._scene.getEngine();
107
- this.visibility = (_b = options.visibility) !== null && _b !== void 0 ? _b : 1;
108
- this.useDash = (_c = options.useDash) !== null && _c !== void 0 ? _c : false;
109
- this.dashRatio = (_d = options.dashRatio) !== null && _d !== void 0 ? _d : 0.5;
110
- this.dashOffset = (_e = options.dashOffset) !== null && _e !== void 0 ? _e : 0;
111
- this.width = options.width ? options.width : options.sizeAttenuation ? GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED : GreasedLinePluginMaterial.DEFAULT_WIDTH;
112
- this._sizeAttenuation = (_f = options.sizeAttenuation) !== null && _f !== void 0 ? _f : false;
113
- this.colorMode = (_g = options.colorMode) !== null && _g !== void 0 ? _g : GreasedLineMeshColorMode.COLOR_MODE_SET;
114
- this._color = (_h = options.color) !== null && _h !== void 0 ? _h : null;
115
- this.useColors = (_j = options.useColors) !== null && _j !== void 0 ? _j : false;
116
- this._colorsDistributionType = (_k = options.colorDistributionType) !== null && _k !== void 0 ? _k : GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;
117
- this.colorsSampling = (_l = options.colorsSampling) !== null && _l !== void 0 ? _l : RawTexture.NEAREST_NEAREST;
118
- this._colors = (_m = options.colors) !== null && _m !== void 0 ? _m : null;
119
- this.dashCount = (_o = options.dashCount) !== null && _o !== void 0 ? _o : 1; // calculate the _dashArray value, call the setter
120
- this.resolution = (_p = options.resolution) !== null && _p !== void 0 ? _p : new Vector2(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // calculate aspect call the setter
121
- if (this._colors) {
122
- this._createColorsTexture(`${material.name}-colors-texture`, this._colors);
71
+ this._cameraFacing = (_c = options.cameraFacing) !== null && _c !== void 0 ? _c : true;
72
+ this.visibility = (_d = options.visibility) !== null && _d !== void 0 ? _d : 1;
73
+ this.useDash = (_e = options.useDash) !== null && _e !== void 0 ? _e : false;
74
+ this.dashRatio = (_f = options.dashRatio) !== null && _f !== void 0 ? _f : 0.5;
75
+ this.dashOffset = (_g = options.dashOffset) !== null && _g !== void 0 ? _g : 0;
76
+ this.width = options.width ? options.width : options.sizeAttenuation ? GreasedLineMaterialDefaults.DEFAULT_WIDTH_ATTENUATED : GreasedLineMaterialDefaults.DEFAULT_WIDTH;
77
+ this._sizeAttenuation = (_h = options.sizeAttenuation) !== null && _h !== void 0 ? _h : false;
78
+ this.colorMode = (_j = options.colorMode) !== null && _j !== void 0 ? _j : GreasedLineMeshColorMode.COLOR_MODE_SET;
79
+ this._color = (_k = options.color) !== null && _k !== void 0 ? _k : null;
80
+ this.useColors = (_l = options.useColors) !== null && _l !== void 0 ? _l : false;
81
+ this._colorsDistributionType = (_m = options.colorDistributionType) !== null && _m !== void 0 ? _m : GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;
82
+ this.colorsSampling = (_o = options.colorsSampling) !== null && _o !== void 0 ? _o : RawTexture.NEAREST_NEAREST;
83
+ this._colors = (_p = options.colors) !== null && _p !== void 0 ? _p : null;
84
+ this.dashCount = (_q = options.dashCount) !== null && _q !== void 0 ? _q : 1; // calculate the _dashArray value, call the setter
85
+ this.resolution = (_r = options.resolution) !== null && _r !== void 0 ? _r : new Vector2(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // calculate aspect call the setter
86
+ if (options.colorsTexture) {
87
+ this.colorsTexture = options.colorsTexture; // colorsTexture from options takes precedence
123
88
  }
124
89
  else {
125
- this._color = (_q = this._color) !== null && _q !== void 0 ? _q : GreasedLinePluginMaterial.DEFAULT_COLOR;
126
- GreasedLinePluginMaterial._PrepareEmptyColorsTexture(this._scene);
90
+ if (this._colors) {
91
+ this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${material.name}-colors-texture`, this._colors, this.colorsSampling, this._scene);
92
+ }
93
+ else {
94
+ this._color = (_s = this._color) !== null && _s !== void 0 ? _s : GreasedLineMaterialDefaults.DEFAULT_COLOR;
95
+ GreasedLineTools.PrepareEmptyColorsTexture(this._scene);
96
+ }
127
97
  }
128
98
  this._engine.onDisposeObservable.add(() => {
129
- var _a;
130
- (_a = GreasedLinePluginMaterial._EmptyColorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
131
- GreasedLinePluginMaterial._EmptyColorsTexture = null;
99
+ GreasedLineTools.DisposeEmptyColorsTexture();
132
100
  });
133
101
  this._enable(true); // always enabled
134
102
  }
@@ -138,10 +106,16 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
138
106
  */
139
107
  getAttributes(attributes) {
140
108
  attributes.push("grl_offsets");
141
- attributes.push("grl_previousAndSide");
142
- attributes.push("grl_nextAndCounters");
143
109
  attributes.push("grl_widths");
144
110
  attributes.push("grl_colorPointers");
111
+ attributes.push("grl_counters");
112
+ if (this._cameraFacing) {
113
+ attributes.push("grl_previousAndSide");
114
+ attributes.push("grl_nextAndCounters");
115
+ }
116
+ else {
117
+ attributes.push("grl_slopes");
118
+ }
145
119
  }
146
120
  /**
147
121
  * Get the shader samplers
@@ -155,8 +129,8 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
155
129
  * @param activeTextures
156
130
  */
157
131
  getActiveTextures(activeTextures) {
158
- if (this._colorsTexture) {
159
- activeTextures.push(this._colorsTexture);
132
+ if (this.colorsTexture) {
133
+ activeTextures.push(this.colorsTexture);
160
134
  }
161
135
  }
162
136
  /**
@@ -165,18 +139,21 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
165
139
  */
166
140
  getUniforms() {
167
141
  const ubo = [
168
- { name: "grl_projection", size: 16, type: "mat4" },
169
142
  { name: "grl_singleColor", size: 3, type: "vec3" },
170
- { name: "grl_aspect_resolution_lineWidth", size: 4, type: "vec4" },
171
143
  { name: "grl_dashOptions", size: 4, type: "vec4" },
172
144
  { name: "grl_colorMode_visibility_colorsWidth_useColors", size: 4, type: "vec4" },
173
145
  ];
146
+ if (this._cameraFacing) {
147
+ ubo.push({ name: "grl_projection", size: 16, type: "mat4" }, { name: "grl_aspect_resolution_lineWidth", size: 4, type: "vec4" });
148
+ }
174
149
  return {
175
150
  ubo,
176
- vertex: `
151
+ vertex: this._cameraFacing
152
+ ? `
177
153
  uniform vec4 grl_aspect_resolution_lineWidth;
178
154
  uniform mat4 grl_projection;
179
- `,
155
+ `
156
+ : "",
180
157
  fragment: `
181
158
  uniform vec4 grl_dashOptions;
182
159
  uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;
@@ -195,22 +172,24 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
195
172
  */
196
173
  bindForSubMesh(uniformBuffer) {
197
174
  var _a;
198
- const activeCamera = this._scene.activeCamera;
199
- if (activeCamera) {
200
- const projection = activeCamera.getProjectionMatrix();
201
- uniformBuffer.updateMatrix("grl_projection", projection);
175
+ if (this._cameraFacing) {
176
+ const activeCamera = this._scene.activeCamera;
177
+ if (activeCamera) {
178
+ const projection = activeCamera.getProjectionMatrix();
179
+ uniformBuffer.updateMatrix("grl_projection", projection);
180
+ }
181
+ else {
182
+ throw Error("GreasedLinePluginMaterial requires an active camera.");
183
+ }
184
+ const resolutionLineWidth = TmpVectors.Vector4[0];
185
+ resolutionLineWidth.x = this._aspect;
186
+ resolutionLineWidth.y = this._resolution.x;
187
+ resolutionLineWidth.z = this._resolution.y;
188
+ resolutionLineWidth.w = this.width;
189
+ uniformBuffer.updateVector4("grl_aspect_resolution_lineWidth", resolutionLineWidth);
202
190
  }
203
- else {
204
- throw Error("GreasedLinePluginMaterial requires an active camera.");
205
- }
206
- const resolutionLineWidth = TmpVectors.Vector4[0];
207
- resolutionLineWidth.x = this._aspect;
208
- resolutionLineWidth.y = this._resolution.x;
209
- resolutionLineWidth.z = this._resolution.y;
210
- resolutionLineWidth.w = this.width;
211
- uniformBuffer.updateVector4("grl_aspect_resolution_lineWidth", resolutionLineWidth);
212
191
  const dashOptions = TmpVectors.Vector4[0];
213
- dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this.useDash);
192
+ dashOptions.x = GreasedLineTools.BooleanToNumber(this.useDash);
214
193
  dashOptions.y = this._dashArray;
215
194
  dashOptions.z = this.dashOffset;
216
195
  dashOptions.w = this.dashRatio;
@@ -218,13 +197,13 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
218
197
  const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];
219
198
  colorModeVisibilityColorsWidthUseColors.x = this.colorMode;
220
199
  colorModeVisibilityColorsWidthUseColors.y = this.visibility;
221
- colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;
222
- colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this.useColors);
200
+ colorModeVisibilityColorsWidthUseColors.z = this.colorsTexture ? this.colorsTexture.getSize().width : 0;
201
+ colorModeVisibilityColorsWidthUseColors.w = GreasedLineTools.BooleanToNumber(this.useColors);
223
202
  uniformBuffer.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", colorModeVisibilityColorsWidthUseColors);
224
203
  if (this._color) {
225
204
  uniformBuffer.updateColor3("grl_singleColor", this._color);
226
205
  }
227
- uniformBuffer.setTexture("grl_colors", (_a = this._colorsTexture) !== null && _a !== void 0 ? _a : GreasedLinePluginMaterial._EmptyColorsTexture);
206
+ uniformBuffer.setTexture("grl_colors", (_a = this.colorsTexture) !== null && _a !== void 0 ? _a : GreasedLineMaterialDefaults.EmptyColorsTexture);
228
207
  }
229
208
  /**
230
209
  * Prepare the defines
@@ -233,11 +212,11 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
233
212
  * @param _mesh
234
213
  */
235
214
  prepareDefines(defines, _scene, _mesh) {
236
- var _a;
237
- defines.GREASED_LINE_HAS_COLOR = !!this._color;
238
- defines.GREASED_LINE_SIZE_ATTENUATION = (_a = this._sizeAttenuation) !== null && _a !== void 0 ? _a : false;
215
+ defines.GREASED_LINE_HAS_COLOR = !!this.color && !this.useColors;
216
+ defines.GREASED_LINE_SIZE_ATTENUATION = this._sizeAttenuation;
239
217
  defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
240
- defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;
218
+ defines.GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;
219
+ defines.GREASED_LINE_CAMERA_FACING = this._cameraFacing;
241
220
  }
242
221
  /**
243
222
  * Get the class name
@@ -253,36 +232,48 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
253
232
  */
254
233
  getCustomCode(shaderType) {
255
234
  if (shaderType === "vertex") {
256
- return {
235
+ const obj = {
257
236
  // eslint-disable-next-line @typescript-eslint/naming-convention
258
237
  CUSTOM_VERTEX_DEFINITIONS: `
238
+ attribute float grl_widths;
239
+ attribute vec3 grl_offsets;
240
+ attribute float grl_colorPointers;
241
+
242
+ varying float grlCounters;
243
+ varying float grlColorPointer;
244
+
245
+ #ifdef GREASED_LINE_CAMERA_FACING
259
246
  attribute vec4 grl_previousAndSide;
260
247
  attribute vec4 grl_nextAndCounters;
261
- attribute float grl_widths;
262
- attribute vec3 grl_offsets;
263
- attribute float grl_colorPointers;
264
-
265
- varying float grlCounters;
266
- varying float grlColorPointer;
267
248
 
268
249
  vec2 grlFix( vec4 i, float aspect ) {
269
250
  vec2 res = i.xy / i.w;
270
251
  res.x *= aspect;
271
252
  return res;
272
253
  }
254
+ #else
255
+ attribute vec3 grl_slopes;
256
+ attribute float grl_counters;
257
+ #endif
273
258
  `,
274
259
  // eslint-disable-next-line @typescript-eslint/naming-convention
275
260
  CUSTOM_VERTEX_UPDATE_POSITION: `
261
+ #ifdef GREASED_LINE_CAMERA_FACING
276
262
  vec3 grlPositionOffset = grl_offsets;
277
263
  positionUpdated += grlPositionOffset;
264
+ #else
265
+ positionUpdated = (positionUpdated + grl_offsets) + (grl_slopes * grl_widths);
266
+ #endif
278
267
  `,
279
268
  // eslint-disable-next-line @typescript-eslint/naming-convention
280
269
  CUSTOM_VERTEX_MAIN_END: `
270
+ grlColorPointer = grl_colorPointers;
271
+
272
+ #ifdef GREASED_LINE_CAMERA_FACING
281
273
 
282
274
  float grlAspect = grl_aspect_resolution_lineWidth.x;
283
275
  float grlBaseWidth = grl_aspect_resolution_lineWidth.w;
284
276
 
285
- grlColorPointer = grl_colorPointers;
286
277
 
287
278
  vec3 grlPrevious = grl_previousAndSide.xyz;
288
279
  float grlSide = grl_previousAndSide.w;
@@ -311,25 +302,30 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
311
302
  grlDir = normalize( grlDir1 + grlDir2 );
312
303
  }
313
304
  vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );
314
- #ifdef GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM
305
+ #ifdef GREASED_LINE_RIGHT_HANDED_COORDINATE_SYSTEM
315
306
  grlNormal.xy *= -.5 * grlWidth;
316
307
  #else
317
308
  grlNormal.xy *= .5 * grlWidth;
318
309
  #endif
310
+
319
311
  grlNormal *= grl_projection;
312
+
320
313
  #ifdef GREASED_LINE_SIZE_ATTENUATION
321
314
  grlNormal.xy *= grlFinalPosition.w;
322
315
  grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;
323
316
  #endif
317
+
324
318
  grlFinalPosition.xy += grlNormal.xy * grlSide;
325
319
  gl_Position = grlFinalPosition;
326
320
 
327
321
  vPositionW = vec3(grlFinalPosition);
328
-
322
+ #else
323
+ grlCounters = grl_counters;
324
+ #endif
329
325
  `,
330
- // eslint-disable-next-line @typescript-eslint/naming-convention
331
- "!gl_Position\\=viewProjection\\*worldPos;": "//", // remove
332
326
  };
327
+ this._cameraFacing && (obj["!gl_Position\\=viewProjection\\*worldPos;"] = "//"); // not needed for camera facing GRL
328
+ return obj;
333
329
  }
334
330
  if (shaderType === "fragment") {
335
331
  return {
@@ -383,50 +379,18 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
383
379
  }
384
380
  }
385
381
  #endif
382
+
386
383
  `,
387
384
  };
388
385
  }
389
386
  return null;
390
387
  }
391
- /**
392
- * Converts boolean to number.
393
- * @param bool
394
- * @returns 1 if true, 0 if false.
395
- */
396
- static _BooleanToNumber(bool) {
397
- return bool ? 1 : 0;
398
- }
399
- /**
400
- * Converts an array of Color3 to Uint8Array
401
- * @param colors Arrray of Color3
402
- * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]
403
- */
404
- static _Color3toRGBAUint8(colors) {
405
- const colorTable = new Uint8Array(colors.length * 4);
406
- for (let i = 0, j = 0; i < colors.length; i++) {
407
- colorTable[j++] = colors[i].r * 255;
408
- colorTable[j++] = colors[i].g * 255;
409
- colorTable[j++] = colors[i].b * 255;
410
- colorTable[j++] = 255;
411
- }
412
- return colorTable;
413
- }
414
- /**
415
- * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
416
- * @param name name of the texture
417
- * @param colors Uint8Array of colors
418
- */
419
- _createColorsTexture(name, colors) {
420
- const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
421
- this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, this.colorsSampling);
422
- this._colorsTexture.name = name;
423
- }
424
388
  /**
425
389
  * Disposes the plugin material.
426
390
  */
427
391
  dispose() {
428
392
  var _a;
429
- (_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
393
+ (_a = this.colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
430
394
  super.dispose();
431
395
  }
432
396
  /**
@@ -453,19 +417,19 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
453
417
  const origColorsCount = (_b = (_a = this._colors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
454
418
  this._colors = colors;
455
419
  if (colors === null || colors.length === 0) {
456
- (_c = this._colorsTexture) === null || _c === void 0 ? void 0 : _c.dispose();
420
+ (_c = this.colorsTexture) === null || _c === void 0 ? void 0 : _c.dispose();
457
421
  return;
458
422
  }
459
423
  if (lazy && !forceNewTexture) {
460
424
  return;
461
425
  }
462
- if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {
463
- const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
464
- this._colorsTexture.update(colorArray);
426
+ if (this.colorsTexture && origColorsCount === colors.length && !forceNewTexture) {
427
+ const colorArray = GreasedLineTools.Color3toRGBAUint8(colors);
428
+ this.colorsTexture.update(colorArray);
465
429
  }
466
430
  else {
467
- (_d = this._colorsTexture) === null || _d === void 0 ? void 0 : _d.dispose();
468
- this._createColorsTexture(`${this._material.name}-colors-texture`, colors);
431
+ (_d = this.colorsTexture) === null || _d === void 0 ? void 0 : _d.dispose();
432
+ this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this._material.name}-colors-texture`, colors, this.colorsSampling, this._scene);
469
433
  }
470
434
  }
471
435
  /**
@@ -491,14 +455,16 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
491
455
  this._dashArray = 1 / value;
492
456
  }
493
457
  /**
494
- * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines
458
+ * If set to true the line will be rendered always with the same width regardless how far it is located from the camera.
459
+ * Not supported for non camera facing lines.
495
460
  */
496
461
  get sizeAttenuation() {
497
462
  return this._sizeAttenuation;
498
463
  }
499
464
  /**
500
- * Turn on/off attenuation of the width option and widths array.
501
- * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines
465
+ * Turn on/off size attenuation of the width option and widths array.
466
+ * Not supported for non camera facing lines.
467
+ * @param value If set to true the line will be rendered always with the same width regardless how far it is located from the camera.
502
468
  */
503
469
  set sizeAttenuation(value) {
504
470
  this._sizeAttenuation = value;
@@ -594,15 +560,10 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
594
560
  var _a;
595
561
  super.parse(source, scene, rootUrl);
596
562
  const greasedLineMaterialOptions = source.greasedLineMaterialOptions;
597
- (_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
598
- if (greasedLineMaterialOptions.colors) {
599
- this._createColorsTexture(`${this._material.name}-colors-texture`, greasedLineMaterialOptions.colors);
600
- }
601
- else {
602
- GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);
603
- }
563
+ (_a = this.colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
604
564
  greasedLineMaterialOptions.color && this.setColor(greasedLineMaterialOptions.color, true);
605
565
  greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);
566
+ greasedLineMaterialOptions.colors && (this.colors = greasedLineMaterialOptions.colors);
606
567
  greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);
607
568
  greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);
608
569
  greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);
@@ -614,6 +575,12 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
614
575
  greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);
615
576
  greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);
616
577
  greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);
578
+ if (this.colors) {
579
+ this.colorsTexture = GreasedLineTools.CreateColorsTexture(`${this._material.name}-colors-texture`, this.colors, this.colorsSampling, scene);
580
+ }
581
+ else {
582
+ GreasedLineTools.PrepareEmptyColorsTexture(scene);
583
+ }
617
584
  this.markAllDefinesAsDirty();
618
585
  }
619
586
  /**
@@ -623,9 +590,9 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
623
590
  copyTo(plugin) {
624
591
  var _a;
625
592
  const dest = plugin;
626
- (_a = dest._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
593
+ (_a = dest.colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
627
594
  if (this._colors) {
628
- dest._createColorsTexture(`${dest._material.name}-colors-texture`, this._colors);
595
+ dest.colorsTexture = GreasedLineTools.CreateColorsTexture(`${dest._material.name}-colors-texture`, this._colors, dest.colorsSampling, this._scene);
629
596
  }
630
597
  dest.setColor(this.color, true);
631
598
  dest.colorsDistributionType = this.colorsDistributionType;
@@ -642,34 +609,10 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
642
609
  dest.resolution = this.resolution;
643
610
  dest.markAllDefinesAsDirty();
644
611
  }
645
- /**
646
- * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.
647
- * For fast switching using the useColors property without the need to use defines.
648
- * @param scene Scene
649
- */
650
- static _PrepareEmptyColorsTexture(scene) {
651
- if (!this._EmptyColorsTexture) {
652
- const colorsArray = new Uint8Array(4);
653
- GreasedLinePluginMaterial._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);
654
- GreasedLinePluginMaterial._EmptyColorsTexture.name = "grlEmptyColorsTexture";
655
- }
656
- }
657
612
  }
658
613
  /**
659
614
  * Plugin name
660
615
  */
661
616
  GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial";
662
- /**
663
- * Default line color for newly created lines
664
- */
665
- GreasedLinePluginMaterial.DEFAULT_COLOR = Color3.White();
666
- /**
667
- * Default line width when sizeAttenuation is true
668
- */
669
- GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED = 1;
670
- /**
671
- * Defaule line width
672
- */
673
- GreasedLinePluginMaterial.DEFAULT_WIDTH = 0.1;
674
617
  RegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);
675
618
  //# sourceMappingURL=greasedLinePluginMaterial.js.map