@nova-lab/core 1.0.0-dev.19 → 1.1.0-dev.229

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 (501) hide show
  1. package/README.md +1035 -10
  2. package/THIRD_PARTY_NOTICES.md +26 -0
  3. package/dist/2d/accessibility.d.ts +2 -0
  4. package/dist/2d/accessibility.js +171 -0
  5. package/dist/2d/commands.d.ts +2 -0
  6. package/dist/2d/commands.js +80 -0
  7. package/dist/2d/effects.d.ts +10 -0
  8. package/dist/2d/effects.js +566 -0
  9. package/dist/2d/ktx2.d.ts +5 -0
  10. package/dist/2d/ktx2.js +542 -0
  11. package/dist/2d/lighting.d.ts +3 -0
  12. package/dist/2d/lighting.js +495 -0
  13. package/dist/2d/lottie.d.ts +3 -0
  14. package/dist/2d/lottie.js +254 -0
  15. package/dist/2d/meshes.d.ts +4 -0
  16. package/dist/2d/meshes.js +451 -0
  17. package/dist/2d/primitives.d.ts +3 -0
  18. package/dist/2d/primitives.js +85 -0
  19. package/dist/2d/render-textures.d.ts +3 -0
  20. package/dist/2d/render-textures.js +539 -0
  21. package/dist/2d/svg/documents.d.ts +5 -0
  22. package/dist/2d/svg/documents.js +7 -0
  23. package/dist/2d/svg/renderer.d.ts +3 -0
  24. package/dist/2d/svg/renderer.js +222 -0
  25. package/dist/2d/svg.d.ts +3 -0
  26. package/dist/2d/svg.js +4 -0
  27. package/dist/2d/tools.d.ts +2 -0
  28. package/dist/2d/tools.js +100 -0
  29. package/dist/2d/video.d.ts +5 -0
  30. package/dist/2d/video.js +90 -0
  31. package/dist/2d.d.ts +2 -0
  32. package/dist/2d.js +220 -0
  33. package/dist/3d/animation.d.ts +8 -0
  34. package/dist/3d/animation.js +1396 -0
  35. package/dist/3d/area-lights.d.ts +2 -0
  36. package/dist/3d/area-lights.js +19 -0
  37. package/dist/3d/audio.d.ts +4 -0
  38. package/dist/3d/audio.js +500 -0
  39. package/dist/3d/character.d.ts +2 -0
  40. package/dist/3d/character.js +136 -0
  41. package/dist/3d/collision.d.ts +3 -0
  42. package/dist/3d/collision.js +387 -0
  43. package/dist/3d/commands.d.ts +2 -0
  44. package/dist/3d/commands.js +108 -0
  45. package/dist/3d/controls.d.ts +8 -0
  46. package/dist/3d/controls.js +1041 -0
  47. package/dist/3d/documents.d.ts +5 -0
  48. package/dist/3d/documents.js +227 -0
  49. package/dist/3d/effects.d.ts +5 -0
  50. package/dist/3d/effects.js +1986 -0
  51. package/dist/3d/export.d.ts +4 -0
  52. package/dist/3d/export.js +347 -0
  53. package/dist/3d/fbx.d.ts +2 -0
  54. package/dist/3d/fbx.js +784 -0
  55. package/dist/3d/gltf.d.ts +2 -0
  56. package/dist/3d/gltf.js +5 -0
  57. package/dist/3d/helpers.d.ts +5 -0
  58. package/dist/3d/helpers.js +191 -0
  59. package/dist/3d/ik.d.ts +9 -0
  60. package/dist/3d/ik.js +777 -0
  61. package/dist/3d/loaders.d.ts +17 -0
  62. package/dist/3d/loaders.js +1406 -0
  63. package/dist/3d/nodes.d.ts +8 -0
  64. package/dist/3d/nodes.js +49 -0
  65. package/dist/3d/particles.d.ts +5 -0
  66. package/dist/3d/particles.js +1574 -0
  67. package/dist/3d/physics/backend.d.ts +7 -0
  68. package/dist/3d/physics/backend.js +1 -0
  69. package/dist/3d/physics/rapier.d.ts +3 -0
  70. package/dist/3d/physics/rapier.js +765 -0
  71. package/dist/3d/physics.d.ts +5 -0
  72. package/dist/3d/physics.js +3346 -0
  73. package/dist/3d/splats.d.ts +7 -0
  74. package/dist/3d/splats.js +862 -0
  75. package/dist/3d/text.d.ts +5 -0
  76. package/dist/3d/text.js +1043 -0
  77. package/dist/3d/tiles.d.ts +24 -0
  78. package/dist/3d/tiles.js +1705 -0
  79. package/dist/3d/tools.d.ts +12 -0
  80. package/dist/3d/tools.js +338 -0
  81. package/dist/3d/usdz.d.ts +2 -0
  82. package/dist/3d/usdz.js +634 -0
  83. package/dist/3d/xr.d.ts +2 -0
  84. package/dist/3d/xr.js +202 -0
  85. package/dist/3d-B4jWF8Qb.js +5591 -0
  86. package/dist/3d.d.ts +40 -0
  87. package/dist/3d.js +44 -0
  88. package/dist/Capsule-BFVpZfvc.js +44 -0
  89. package/dist/Clip-CAN7t03k.js +204 -0
  90. package/dist/Color-vuv9UnoY.js +34 -0
  91. package/dist/DeformedMesh-CPi0P_vc.js +280 -0
  92. package/dist/Document-DCVEZSvM.js +415 -0
  93. package/dist/Errors-B2ekO9bZ.js +30 -0
  94. package/dist/Features-BsjmePtc.js +557 -0
  95. package/dist/GLTFResourceIO-CYJyCUTt.js +124 -0
  96. package/dist/GPUParticleState-CQlNpoDa.js +545 -0
  97. package/dist/Geometry-DytO490z.js +227 -0
  98. package/dist/Inflate-DWw0V-Up.js +42 -0
  99. package/dist/InstancedMesh-DPrgrw5z.js +527 -0
  100. package/dist/Limits-Bw5XQdFr.js +20 -0
  101. package/dist/LineHelper-Ad0z9uDi.js +131 -0
  102. package/dist/LoaderIO-BwrM84OM.js +114 -0
  103. package/dist/Material-BpfLPmK9.js +777 -0
  104. package/dist/Mesh-BaRxAAJq.js +209 -0
  105. package/dist/Node-QfgAE2_v.js +877 -0
  106. package/dist/NovaAssetRegistry-p2QlCwvT.js +1168 -0
  107. package/dist/NovaNode-CBZ-Ol-W.js +2016 -0
  108. package/dist/NovaRenderCommandWriter-CWQRa42y.js +1949 -0
  109. package/dist/NovaTextSelectionService-CipuujCT.js +18526 -0
  110. package/dist/NovaWebGLProgram-BO250QNF.js +97 -0
  111. package/dist/Options-CajE7LLJ.js +15 -0
  112. package/dist/PolygonMesh-D4PnnfIo.js +657 -0
  113. package/dist/Ready-BzyhRtjD.js +21 -0
  114. package/dist/Scene-CDfNgf9I.js +911 -0
  115. package/dist/Shader-b6_HDndT.js +48 -0
  116. package/dist/SplatShader-wJ6GJ3vo.js +130 -0
  117. package/dist/Texture-dTKMlTpK.js +267 -0
  118. package/dist/TextureLoader-CfDzdy2m.js +411 -0
  119. package/dist/Textures-CGL4Kf-8.js +651 -0
  120. package/dist/ToneMapping-D9IWvN0u.js +46 -0
  121. package/dist/WebGPURenderer-DjD0IxVC.js +4921 -0
  122. package/dist/ZipReader-C-MSEsSr.js +84 -0
  123. package/dist/core.js +218 -24024
  124. package/dist/domain/types/base.types.d.ts +18 -9
  125. package/dist/domain/types/component.types.d.ts +5 -5
  126. package/dist/domain/types/cursor.types.d.ts +1 -1
  127. package/dist/domain/types/diagnostics.types.d.ts +2 -0
  128. package/dist/domain/types/export.types.d.ts +2 -2
  129. package/dist/domain/types/hit-test.types.d.ts +1 -1
  130. package/dist/domain/types/motion.types.d.ts +2 -2
  131. package/dist/domain/types/renderer.types.d.ts +88 -4
  132. package/dist/domain/types/rendering/index.d.ts +29 -4
  133. package/dist/domain/types/sound.types.d.ts +1 -1
  134. package/dist/domain/types/theme.types.d.ts +1 -1
  135. package/dist/domain/utils/bounds.d.ts +1 -1
  136. package/dist/domain/utils/nova-text.d.ts +9 -0
  137. package/dist/domain/utils/schemaBounds.d.ts +2 -2
  138. package/dist/export-svg-document-ChaNXMaG.js +668 -0
  139. package/dist/features/3d/Errors.d.ts +57 -0
  140. package/dist/features/3d/Nova3DApp.d.ts +429 -0
  141. package/dist/features/3d/animation/Animator.d.ts +260 -0
  142. package/dist/features/3d/animation/Clip.d.ts +74 -0
  143. package/dist/features/3d/animation/Graph.d.ts +158 -0
  144. package/dist/features/3d/animation/Mask.d.ts +40 -0
  145. package/dist/features/3d/audio/Audio.d.ts +114 -0
  146. package/dist/features/3d/audio/Sound.d.ts +133 -0
  147. package/dist/features/3d/character/CharacterController.d.ts +61 -0
  148. package/dist/features/3d/collision/Capsule.d.ts +25 -0
  149. package/dist/features/3d/collision/Octree.d.ts +94 -0
  150. package/dist/features/3d/controls/CameraMotionControls.d.ts +154 -0
  151. package/dist/features/3d/controls/CameraOrientation.d.ts +47 -0
  152. package/dist/features/3d/controls/OrbitControls.d.ts +73 -0
  153. package/dist/features/3d/controls/PointerGesture.d.ts +25 -0
  154. package/dist/features/3d/controls/PointerLock.d.ts +36 -0
  155. package/dist/features/3d/controls/Snapping.d.ts +32 -0
  156. package/dist/features/3d/controls/TransformGizmo.d.ts +79 -0
  157. package/dist/features/3d/deformation/DeformationGPU.d.ts +52 -0
  158. package/dist/features/3d/deformation/DeformationShader.d.ts +2 -0
  159. package/dist/features/3d/deformation/DeformedMesh.d.ts +36 -0
  160. package/dist/features/3d/deformation/GeometryDeformation.d.ts +25 -0
  161. package/dist/features/3d/documents/Document.d.ts +59 -0
  162. package/dist/features/3d/documents/DocumentCommands.d.ts +45 -0
  163. package/dist/features/3d/documents/DocumentSchema.d.ts +18 -0
  164. package/dist/features/3d/documents/DocumentTransform.d.ts +4 -0
  165. package/dist/features/3d/documents/DocumentTypes.d.ts +182 -0
  166. package/dist/features/3d/documents/DocumentValidation.d.ts +18 -0
  167. package/dist/features/3d/documents/Projection.d.ts +65 -0
  168. package/dist/features/3d/effects/CubeLUT.d.ts +24 -0
  169. package/dist/features/3d/effects/Effects.d.ts +32 -0
  170. package/dist/features/3d/effects/EffectsGPU.d.ts +80 -0
  171. package/dist/features/3d/effects/EffectsPlan.d.ts +268 -0
  172. package/dist/features/3d/effects/EffectsShaders.d.ts +35 -0
  173. package/dist/features/3d/export/GLTFExporter.d.ts +49 -0
  174. package/dist/features/3d/export/ThreeMFExporter.d.ts +19 -0
  175. package/dist/features/3d/export/ZipWriter.d.ts +9 -0
  176. package/dist/features/3d/fbx/FBXLoader.d.ts +26 -0
  177. package/dist/features/3d/fbx/FBXParser.d.ts +35 -0
  178. package/dist/features/3d/fbx/FBXScene.d.ts +20 -0
  179. package/dist/features/3d/gltf/GLTFLoader.d.ts +16 -0
  180. package/dist/features/3d/gltf/GLTFTypes.d.ts +64 -0
  181. package/dist/features/3d/gltf/services/GLTFBinary.d.ts +21 -0
  182. package/dist/features/3d/gltf/services/GLTFGeometry.d.ts +14 -0
  183. package/dist/features/3d/gltf/services/GLTFResourceIO.d.ts +64 -0
  184. package/dist/features/3d/helpers/LineHelper.d.ts +51 -0
  185. package/dist/features/3d/helpers/StaticHelpers.d.ts +47 -0
  186. package/dist/features/3d/helpers/TrackedHelpers.d.ts +84 -0
  187. package/dist/features/3d/ik/ChainIK.d.ts +44 -0
  188. package/dist/features/3d/ik/IKChain.d.ts +92 -0
  189. package/dist/features/3d/ik/IKMath.d.ts +49 -0
  190. package/dist/features/3d/ik/IKSolver.d.ts +97 -0
  191. package/dist/features/3d/ik/LookAtIK.d.ts +58 -0
  192. package/dist/features/3d/ik/TwoBoneIK.d.ts +57 -0
  193. package/dist/features/3d/import/ImportAnimation.d.ts +20 -0
  194. package/dist/features/3d/import/ImportMath.d.ts +42 -0
  195. package/dist/features/3d/import/ImportedModel.d.ts +135 -0
  196. package/dist/features/3d/import/Inflate.d.ts +5 -0
  197. package/dist/features/3d/import/ModelAsset.d.ts +149 -0
  198. package/dist/features/3d/import/PolygonMesh.d.ts +54 -0
  199. package/dist/features/3d/lights/AreaLightTables.d.ts +8 -0
  200. package/dist/features/3d/lights/AreaLights.d.ts +11 -0
  201. package/dist/features/3d/loaders/EXRCompression.d.ts +13 -0
  202. package/dist/features/3d/loaders/EXRLoader.d.ts +39 -0
  203. package/dist/features/3d/loaders/HDRLoader.d.ts +26 -0
  204. package/dist/features/3d/loaders/Limits.d.ts +70 -0
  205. package/dist/features/3d/loaders/LoaderBuffers.d.ts +42 -0
  206. package/dist/features/3d/loaders/LoaderIO.d.ts +81 -0
  207. package/dist/features/3d/loaders/LoaderModel.d.ts +80 -0
  208. package/dist/features/3d/loaders/LoaderText.d.ts +27 -0
  209. package/dist/features/3d/loaders/MTLLoader.d.ts +105 -0
  210. package/dist/features/3d/loaders/OBJLoader.d.ts +70 -0
  211. package/dist/features/3d/loaders/PLYLoader.d.ts +47 -0
  212. package/dist/features/3d/loaders/STLLoader.d.ts +27 -0
  213. package/dist/features/3d/model/Camera.d.ts +33 -0
  214. package/dist/features/3d/model/Environment.d.ts +31 -0
  215. package/dist/features/3d/model/Geometry.d.ts +59 -0
  216. package/dist/features/3d/model/InstancedMesh.d.ts +134 -0
  217. package/dist/features/3d/model/LOD.d.ts +31 -0
  218. package/dist/features/3d/model/Light.d.ts +200 -0
  219. package/dist/features/3d/model/Material.d.ts +308 -0
  220. package/dist/features/3d/model/MaterialExtensions.d.ts +200 -0
  221. package/dist/features/3d/model/Mesh.d.ts +92 -0
  222. package/dist/features/3d/model/Node.d.ts +87 -0
  223. package/dist/features/3d/model/ReflectionProbe.d.ts +45 -0
  224. package/dist/features/3d/model/RenderTarget.d.ts +41 -0
  225. package/dist/features/3d/model/Scene.d.ts +173 -0
  226. package/dist/features/3d/model/Texture.d.ts +143 -0
  227. package/dist/features/3d/nodes/Nodes.d.ts +8 -0
  228. package/dist/features/3d/nodes/ShaderNode.d.ts +240 -0
  229. package/dist/features/3d/particles/GPUParticleSchedule.d.ts +67 -0
  230. package/dist/features/3d/particles/GPUParticleShaders.d.ts +19 -0
  231. package/dist/features/3d/particles/GPUParticleState.d.ts +106 -0
  232. package/dist/features/3d/particles/GPUParticleSystem.d.ts +192 -0
  233. package/dist/features/3d/particles/ParticleCurves.d.ts +34 -0
  234. package/dist/features/3d/particles/ParticleOptions.d.ts +78 -0
  235. package/dist/features/3d/particles/ParticleSystem.d.ts +368 -0
  236. package/dist/features/3d/physics/PhysicsBackend.d.ts +352 -0
  237. package/dist/features/3d/physics/PhysicsDebug.d.ts +24 -0
  238. package/dist/features/3d/physics/PhysicsWorld.d.ts +352 -0
  239. package/dist/features/3d/physics/basic/BasicCollision.d.ts +75 -0
  240. package/dist/features/3d/physics/basic/BasicPhysics.d.ts +24 -0
  241. package/dist/features/3d/physics/basic/BasicShapes.d.ts +103 -0
  242. package/dist/features/3d/physics/rapier/ContactBuffer.d.ts +32 -0
  243. package/dist/features/3d/physics/rapier/RapierBackend.d.ts +17 -0
  244. package/dist/features/3d/physics/rapier/RapierShapes.d.ts +4 -0
  245. package/dist/features/3d/physics/rapier/RapierWorld.d.ts +198 -0
  246. package/dist/features/3d/physics/rapier/Validation.d.ts +8 -0
  247. package/dist/features/3d/services/Background.d.ts +22 -0
  248. package/dist/features/3d/services/BasicShader.d.ts +55 -0
  249. package/dist/features/3d/services/ClusteredLights.d.ts +69 -0
  250. package/dist/features/3d/services/DrawOrder.d.ts +37 -0
  251. package/dist/features/3d/services/EffectsProcessor.d.ts +38 -0
  252. package/dist/features/3d/services/EnvironmentBRDF.d.ts +35 -0
  253. package/dist/features/3d/services/EnvironmentMaps.d.ts +55 -0
  254. package/dist/features/3d/services/FogShader.d.ts +6 -0
  255. package/dist/features/3d/services/Frustum.d.ts +7 -0
  256. package/dist/features/3d/services/GLState.d.ts +86 -0
  257. package/dist/features/3d/services/GPUPicker.d.ts +31 -0
  258. package/dist/features/3d/services/InstanceShader.d.ts +3 -0
  259. package/dist/features/3d/services/LineProgram.d.ts +32 -0
  260. package/dist/features/3d/services/PBRProgram.d.ts +115 -0
  261. package/dist/features/3d/services/Renderer.d.ts +50 -0
  262. package/dist/features/3d/services/Shader.d.ts +22 -0
  263. package/dist/features/3d/services/ShaderProgram.d.ts +38 -0
  264. package/dist/features/3d/services/ShadowMaps.d.ts +97 -0
  265. package/dist/features/3d/services/SpatialIndex.d.ts +16 -0
  266. package/dist/features/3d/services/TextureLoader.d.ts +40 -0
  267. package/dist/features/3d/services/TextureMipmaps.d.ts +42 -0
  268. package/dist/features/3d/services/ToneMapping.d.ts +12 -0
  269. package/dist/features/3d/services/WebGLRenderer.d.ts +261 -0
  270. package/dist/features/3d/splats/SplatData.d.ts +136 -0
  271. package/dist/features/3d/splats/SplatLoaders.d.ts +64 -0
  272. package/dist/features/3d/splats/SplatShader.d.ts +14 -0
  273. package/dist/features/3d/splats/SplatSort.d.ts +69 -0
  274. package/dist/features/3d/splats/Splats.d.ts +116 -0
  275. package/dist/features/3d/text/FontAtlas.d.ts +246 -0
  276. package/dist/features/3d/text/SDF.d.ts +28 -0
  277. package/dist/features/3d/text/Text.d.ts +179 -0
  278. package/dist/features/3d/text/TextLayout.d.ts +73 -0
  279. package/dist/features/3d/text/TextShader.d.ts +12 -0
  280. package/dist/features/3d/tiles/BoundingVolume.d.ts +43 -0
  281. package/dist/features/3d/tiles/Geodesy.d.ts +106 -0
  282. package/dist/features/3d/tiles/GlobeControls.d.ts +147 -0
  283. package/dist/features/3d/tiles/TileContent.d.ts +35 -0
  284. package/dist/features/3d/tiles/TileFormats.d.ts +77 -0
  285. package/dist/features/3d/tiles/Tiles3D.d.ts +236 -0
  286. package/dist/features/3d/tiles/Tileset.d.ts +81 -0
  287. package/dist/features/3d/tools/BatchedMesh.d.ts +74 -0
  288. package/dist/features/3d/tools/CanvasSurface.d.ts +81 -0
  289. package/dist/features/3d/tools/Color.d.ts +11 -0
  290. package/dist/features/3d/tools/MergeGeometries.d.ts +22 -0
  291. package/dist/features/3d/tools/Options.d.ts +15 -0
  292. package/dist/features/3d/tools/Polyhedra.d.ts +30 -0
  293. package/dist/features/3d/tools/PrimitiveBuffers.d.ts +42 -0
  294. package/dist/features/3d/tools/Primitives.d.ts +164 -0
  295. package/dist/features/3d/tools/Ready.d.ts +12 -0
  296. package/dist/features/3d/tools/SpatialMath.d.ts +57 -0
  297. package/dist/features/3d/tools/SphericalHarmonics.d.ts +9 -0
  298. package/dist/features/3d/tools/math/mat3.d.ts +7 -0
  299. package/dist/features/3d/tools/math/mat4.d.ts +19 -0
  300. package/dist/features/3d/tools/math/quat.d.ts +6 -0
  301. package/dist/features/3d/tools/math/vec3.d.ts +16 -0
  302. package/dist/features/3d/tools/math/vec4.d.ts +5 -0
  303. package/dist/features/3d/types.d.ts +359 -0
  304. package/dist/features/3d/usdz/USDAParser.d.ts +50 -0
  305. package/dist/features/3d/usdz/USDScene.d.ts +20 -0
  306. package/dist/features/3d/usdz/USDZLoader.d.ts +27 -0
  307. package/dist/features/3d/usdz/ZipReader.d.ts +16 -0
  308. package/dist/features/3d/webgpu/Backend.d.ts +40 -0
  309. package/dist/features/3d/webgpu/BasicShader.d.ts +10 -0
  310. package/dist/features/3d/webgpu/Constants.d.ts +32 -0
  311. package/dist/features/3d/webgpu/Deformation.d.ts +71 -0
  312. package/dist/features/3d/webgpu/Environment.d.ts +66 -0
  313. package/dist/features/3d/webgpu/Features.d.ts +68 -0
  314. package/dist/features/3d/webgpu/Layouts.d.ts +27 -0
  315. package/dist/features/3d/webgpu/Lines.d.ts +40 -0
  316. package/dist/features/3d/webgpu/LitExtras.d.ts +46 -0
  317. package/dist/features/3d/webgpu/LitFeatures.d.ts +41 -0
  318. package/dist/features/3d/webgpu/LitScene.d.ts +60 -0
  319. package/dist/features/3d/webgpu/LitShader.d.ts +68 -0
  320. package/dist/features/3d/webgpu/Particles.d.ts +114 -0
  321. package/dist/features/3d/webgpu/Picking.d.ts +59 -0
  322. package/dist/features/3d/webgpu/PipelineKey.d.ts +33 -0
  323. package/dist/features/3d/webgpu/Points.d.ts +41 -0
  324. package/dist/features/3d/webgpu/Probes.d.ts +45 -0
  325. package/dist/features/3d/webgpu/ShaderChunks.d.ts +18 -0
  326. package/dist/features/3d/webgpu/ShaderMaterial.d.ts +57 -0
  327. package/dist/features/3d/webgpu/ShaderMaterialSource.d.ts +5 -0
  328. package/dist/features/3d/webgpu/Shadows.d.ts +49 -0
  329. package/dist/features/3d/webgpu/Splats.d.ts +47 -0
  330. package/dist/features/3d/webgpu/Textures.d.ts +52 -0
  331. package/dist/features/3d/webgpu/Transmission.d.ts +30 -0
  332. package/dist/features/3d/webgpu/UniformLayout.d.ts +30 -0
  333. package/dist/features/3d/webgpu/UtilityShaders.d.ts +38 -0
  334. package/dist/features/3d/webgpu/WebGPURenderer.d.ts +327 -0
  335. package/dist/features/3d/webgpu/effects/EffectsShaders.d.ts +74 -0
  336. package/dist/features/3d/webgpu/effects/WebGPUEffects.d.ts +140 -0
  337. package/dist/features/3d/xr/XR.d.ts +100 -0
  338. package/dist/gltf-By-n0qEg.js +960 -0
  339. package/dist/index.d.ts +86 -81
  340. package/dist/model/document-actions/document-commands.d.ts +18 -0
  341. package/dist/model/documents/svg/create-svg-document-renderer.d.ts +32 -0
  342. package/dist/model/documents/svg/export-svg-document.d.ts +5 -0
  343. package/dist/model/documents/svg/import-svg-document.d.ts +6 -0
  344. package/dist/model/documents/svg/svg-document.types.d.ts +111 -0
  345. package/dist/model/documents/svg/svg-values.d.ts +16 -0
  346. package/dist/model/documents/svg/svg-xml.d.ts +18 -0
  347. package/dist/model/input/NovaInputProxy_Adapter.d.ts +2 -1
  348. package/dist/model/input/NovaInputValidationController.d.ts +1 -1
  349. package/dist/model/input/NovaTextInputController.d.ts +1 -1
  350. package/dist/model/input/NovaTextLayoutEngine.d.ts +2 -6
  351. package/dist/model/input/index.d.ts +7 -7
  352. package/dist/model/input/nova-input.types.d.ts +1 -1
  353. package/dist/model/lighting/LightingRenderer2D.d.ts +58 -0
  354. package/dist/model/lighting/NovaLighting2D.d.ts +56 -0
  355. package/dist/model/lighting/lighting-shaders.d.ts +3 -0
  356. package/dist/model/lighting/lighting-state.d.ts +27 -0
  357. package/dist/model/lighting/lighting.types.d.ts +107 -0
  358. package/dist/model/lottie/LottieNode.d.ts +4 -0
  359. package/dist/model/lottie/lottie.types.d.ts +83 -0
  360. package/dist/model/lottie/prepare-lottie.d.ts +3 -0
  361. package/dist/model/lottie/sample-position.d.ts +9 -0
  362. package/dist/model/motion/NovaMotionEngine.d.ts +3 -3
  363. package/dist/model/motion/nova-motion-easing.d.ts +1 -1
  364. package/dist/model/motion/nova-motion-interpolation.d.ts +1 -1
  365. package/dist/model/motion/nova-motion-presets.d.ts +2 -2
  366. package/dist/model/motion/nova-motion-timeline.d.ts +1 -1
  367. package/dist/model/platform/NovaCanvas.d.ts +7 -6
  368. package/dist/model/primitives/NovaPrimitiveUnsupportedError.d.ts +13 -0
  369. package/dist/model/primitives/definePrimitive.d.ts +5 -0
  370. package/dist/model/primitives/primitive.types.d.ts +28 -0
  371. package/dist/model/render/backends/canvas2d/NovaCanvas2DTargetManager.d.ts +3 -3
  372. package/dist/model/render/backends/canvas2d/NovaRenderer2D.d.ts +61 -15
  373. package/dist/model/render/backends/canvas2d/nova-canvas-blend.d.ts +5 -0
  374. package/dist/model/render/backends/nova-render-backend-factory.d.ts +6 -6
  375. package/dist/model/render/backends/nova-render-backend.d.ts +8 -2
  376. package/dist/model/render/backends/webgl/NovaRendererWebGL.d.ts +32 -11
  377. package/dist/model/render/backends/webgl/NovaStreamCacheIdleLedger.d.ts +12 -1
  378. package/dist/model/render/backends/webgl/NovaWebGLBatcher.d.ts +1 -1
  379. package/dist/model/render/backends/webgl/NovaWebGLCircleImagePass.d.ts +23 -0
  380. package/dist/model/render/backends/webgl/NovaWebGLCompositionPass.d.ts +9 -0
  381. package/dist/model/render/backends/webgl/NovaWebGLDevice.d.ts +3 -1
  382. package/dist/model/render/backends/webgl/NovaWebGLDiagnostics.d.ts +1 -1
  383. package/dist/model/render/backends/webgl/NovaWebGLFrameRenderer.d.ts +162 -53
  384. package/dist/model/render/backends/webgl/NovaWebGLPathClipPass.d.ts +13 -0
  385. package/dist/model/render/backends/webgl/NovaWebGLPathUnion.d.ts +23 -0
  386. package/dist/model/render/compiler/NovaRenderBuilder.d.ts +24 -10
  387. package/dist/model/render/compiler/NovaRenderCommandWriter.d.ts +10 -5
  388. package/dist/model/render/compiler/NovaRenderCompiler.d.ts +7 -6
  389. package/dist/model/render/compiler/NovaRenderFrameBuilder.d.ts +4 -3
  390. package/dist/model/render/effects/blur.d.ts +8 -0
  391. package/dist/model/render/effects/color-matrix.d.ts +8 -0
  392. package/dist/model/render/effects/drop-shadow.d.ts +18 -0
  393. package/dist/model/render/effects/nova-effect-registry.d.ts +66 -0
  394. package/dist/model/render/effects/nova-gaussian-kernel.d.ts +7 -0
  395. package/dist/model/render/effects/nova-gaussian-textures.d.ts +11 -0
  396. package/dist/model/render/effects/shader-effect.d.ts +64 -0
  397. package/dist/model/render/geometry/nova-alpha-mask.d.ts +5 -0
  398. package/dist/model/render/geometry/nova-composition.d.ts +9 -0
  399. package/dist/model/render/geometry/nova-node-clip.d.ts +17 -0
  400. package/dist/model/render/geometry/nova-path-geometry.d.ts +24 -0
  401. package/dist/model/render/geometry/nova-path-tessellation.d.ts +7 -0
  402. package/dist/model/render/geometry/nova-polygon-triangulation.d.ts +1 -1
  403. package/dist/model/render/graph/NovaRectBatchBuffer.d.ts +58 -0
  404. package/dist/model/render/graph/NovaRenderGraph.d.ts +40 -6
  405. package/dist/model/render/graph/NovaRenderHitIndex.d.ts +1 -1
  406. package/dist/model/render/graph/nova-auto-rect.d.ts +1 -1
  407. package/dist/model/render/graph/nova-linear-rect-repack.d.ts +4 -4
  408. package/dist/model/render/graph/nova-linear-rect-transition.d.ts +2 -2
  409. package/dist/model/render/graph/nova-render-culling.d.ts +2 -2
  410. package/dist/model/render/graph/nova-render-dirty-items.d.ts +1 -1
  411. package/dist/model/render/graph/nova-render-group.d.ts +1 -1
  412. package/dist/model/render/graph/nova-render-item.d.ts +2 -2
  413. package/dist/model/render/graph/nova-render-layer.d.ts +1 -1
  414. package/dist/model/render/graph/nova-render-payload-snapshot.d.ts +3 -1
  415. package/dist/model/render/graph/nova-render-program.d.ts +5 -3
  416. package/dist/model/render/graph/nova-render-sequence.d.ts +1 -1
  417. package/dist/model/render/graph/nova-render-stream.d.ts +2 -2
  418. package/dist/model/render/ktx2/BasisSession.d.ts +45 -0
  419. package/dist/model/render/ktx2/KTX2Container.d.ts +26 -0
  420. package/dist/model/render/ktx2/KTX2Loader.d.ts +55 -0
  421. package/dist/model/render/meshes/MeshNode.d.ts +13 -0
  422. package/dist/model/render/meshes/NovaMeshWebGLDevice.d.ts +27 -0
  423. package/dist/model/render/meshes/geometry.d.ts +7 -0
  424. package/dist/model/render/meshes/mesh.d.ts +3 -0
  425. package/dist/model/render/meshes/mesh.types.d.ts +116 -0
  426. package/dist/model/render/meshes/nova-mesh-registry.d.ts +55 -0
  427. package/dist/model/render/orchestration/NovaRenderOrchestrator.d.ts +25 -3
  428. package/dist/model/render/policy/nova-render-policy.d.ts +1 -1
  429. package/dist/model/render/resources/NovaGlyphAtlasManager.d.ts +2 -2
  430. package/dist/model/render/resources/NovaTextAtlasManager.d.ts +3 -3
  431. package/dist/model/render/resources/NovaTextLayoutEngine.d.ts +1 -1
  432. package/dist/model/render/resources/nova-bitmap-upload.d.ts +10 -0
  433. package/dist/model/render/schema/NovaRenderContext.d.ts +6 -4
  434. package/dist/model/render/schema/nova-style-compiler.d.ts +5 -2
  435. package/dist/model/render/targets/NovaNodeRenderTextureSource.d.ts +29 -0
  436. package/dist/model/render/targets/NovaRenderTargetManager.d.ts +1 -1
  437. package/dist/model/render/targets/NovaRenderTexture.d.ts +57 -0
  438. package/dist/model/render/targets/nova-render-target-refs.d.ts +5 -0
  439. package/dist/model/render/targets/nova-render-target-resource.d.ts +1 -1
  440. package/dist/model/render/targets/nova-render-texture-runtime.d.ts +71 -0
  441. package/dist/model/render/textures/nova-compressed-image.d.ts +20 -0
  442. package/dist/model/render/utils/nova-icon-rendering.d.ts +3 -1
  443. package/dist/model/render/utils/nova-image-geometry.d.ts +11 -0
  444. package/dist/model/render/utils/nova-markdown-layout.d.ts +19 -0
  445. package/dist/model/render/utils/nova-text-paint.d.ts +26 -0
  446. package/dist/model/render/utils/nova-wrapped-text-layout.d.ts +19 -0
  447. package/dist/model/runtime/app/Nova.d.ts +35 -35
  448. package/dist/model/runtime/app/NovaApp.d.ts +58 -30
  449. package/dist/model/runtime/app/NovaRaphRuntime.d.ts +2 -2
  450. package/dist/model/runtime/app/createNovaRaphRuntime.d.ts +3 -3
  451. package/dist/model/runtime/assets/NovaAssetRegistry.d.ts +89 -2
  452. package/dist/model/runtime/assets/NovaVideoTexture.d.ts +38 -0
  453. package/dist/model/runtime/assets/nova-render-texture-image-identity.d.ts +4 -0
  454. package/dist/model/runtime/commands/NovaCommandBus.d.ts +1 -1
  455. package/dist/model/runtime/components/NovaComponentNode.d.ts +6 -6
  456. package/dist/model/runtime/components/NovaComponentRegistry.d.ts +1 -1
  457. package/dist/model/runtime/components/NovaSchemaRegistry.d.ts +7 -6
  458. package/dist/model/runtime/components/nova-component-metadata.d.ts +1 -1
  459. package/dist/model/runtime/components/nova-component.decorator.d.ts +2 -2
  460. package/dist/model/runtime/components/nova-defined-component.d.ts +3 -3
  461. package/dist/model/runtime/context/nova-context.d.ts +1 -1
  462. package/dist/model/runtime/cursor/NovaCursorManager.d.ts +3 -3
  463. package/dist/model/runtime/diagnostics/NovaDiagnostics_Module.d.ts +3 -3
  464. package/dist/model/runtime/interaction/NovaEvents.d.ts +16 -6
  465. package/dist/model/runtime/interaction/NovaHitIndex.d.ts +1 -1
  466. package/dist/model/runtime/interaction/NovaSpatialIndex.d.ts +2 -2
  467. package/dist/model/runtime/scene/NovaScene.d.ts +3 -3
  468. package/dist/model/runtime/scene/nova-scene-components.d.ts +6 -6
  469. package/dist/model/runtime/state/nova-store-decorators.d.ts +1 -1
  470. package/dist/model/runtime/state/nova-store-runtime.d.ts +1 -1
  471. package/dist/model/runtime/state/nova-store-tracking.d.ts +7 -3
  472. package/dist/model/runtime/sync/NovaSyncScope.d.ts +11 -2
  473. package/dist/model/runtime/sync/nova-sync-context.d.ts +2 -2
  474. package/dist/model/runtime/sync/nova-sync-ports.d.ts +2 -2
  475. package/dist/model/runtime/sync/nova-sync.types.d.ts +15 -3
  476. package/dist/model/runtime/template/NovaTemplateRuntime.d.ts +6 -6
  477. package/dist/model/runtime/tree/NovaContainer.d.ts +4 -4
  478. package/dist/model/runtime/tree/NovaNode.d.ts +58 -18
  479. package/dist/model/runtime/tree/NovaRaphNode.d.ts +8 -2
  480. package/dist/model/runtime/tree/NovaSurface.d.ts +32 -10
  481. package/dist/model/runtime/tree/nova-node-capture-invalidation.d.ts +11 -0
  482. package/dist/model/semantic/NovaSemanticService.d.ts +1 -1
  483. package/dist/model/semantic/browser/createAccessibilityBridge.d.ts +29 -0
  484. package/dist/model/sound/NovaSoundEngine.d.ts +3 -2
  485. package/dist/model/text-selection/NovaTextSelectionService.d.ts +2 -2
  486. package/dist/model/text-selection/index.d.ts +2 -2
  487. package/dist/model/text-selection/nova-text-selection.types.d.ts +1 -1
  488. package/dist/model/theme/NovaGlobalThemeRegistry.d.ts +2 -2
  489. package/dist/model/theme/NovaThemeService.d.ts +5 -3
  490. package/dist/model/theme/createTokenTheme.d.ts +15 -0
  491. package/dist/model/tools/transform-tools.d.ts +43 -0
  492. package/dist/nodes--Ds4IS2h.js +621 -0
  493. package/dist/nova-color-parser-BCN_rFRN.js +250 -0
  494. package/dist/nova-compressed-image-CE2Ya9Xa.js +46 -0
  495. package/dist/nova-mesh-registry-B7Xz5mhU.js +24 -0
  496. package/dist/nova-render-texture-image-identity-DQ09XFKs.js +15 -0
  497. package/dist/nova-text-paint-CcntsRjI.js +48 -0
  498. package/dist/tokens.d.ts +2 -0
  499. package/dist/tokens.js +50 -0
  500. package/dist/vec4-BTNv1fUp.js +20 -0
  501. package/package.json +223 -4
@@ -0,0 +1,1574 @@
1
+ import { N as g } from "../Errors-B2ekO9bZ.js";
2
+ import { v as It } from "../Mesh-BaRxAAJq.js";
3
+ import { N as Gt, s as Rt } from "../Scene-CDfNgf9I.js";
4
+ import { N as $t, j as Tt, F as Ot, d as bt, e as kt } from "../Node-QfgAE2_v.js";
5
+ import { p as Vt } from "../Color-vuv9UnoY.js";
6
+ import { W as Xt, G as qt, p as Yt, a as Zt } from "../GPUParticleState-CQlNpoDa.js";
7
+ import { c as Kt, o as jt } from "../Options-CajE7LLJ.js";
8
+ import { l as Q } from "../InstancedMesh-DPrgrw5z.js";
9
+ const nt = 256, ct = nt - 1;
10
+ function Y(o, t, e, i) {
11
+ if (typeof o != "number" || !Number.isFinite(o))
12
+ throw new g("invalid-option", `[Nova3D] Particle ${t} must be a finite number.`);
13
+ if (o < e || o > i)
14
+ throw new g("invalid-option", `[Nova3D] Particle ${t} must be in [${e}, ${i}].`);
15
+ return o;
16
+ }
17
+ function dt(o, t, e, i, s, r) {
18
+ if (typeof o == "number") {
19
+ s[r] = s[r + 1] = Y(o, t, e, i);
20
+ return;
21
+ }
22
+ if (!Array.isArray(o) || o.length !== 2)
23
+ throw new g("invalid-option", `[Nova3D] Particle ${t} must be a number or a [min, max] pair.`);
24
+ const n = Y(o[0], t, e, i), c = Y(o[1], t, e, i);
25
+ if (n > c)
26
+ throw new g("invalid-option", `[Nova3D] Particle ${t} minimum exceeds its maximum.`);
27
+ s[r] = n, s[r + 1] = c;
28
+ }
29
+ function Et(o, t) {
30
+ if (!Array.isArray(o) || o.length === 0 || o.length > 1024)
31
+ throw new g("invalid-option", `[Nova3D] Particle ${t} needs 1..1024 [t, value] keys.`);
32
+ const e = [];
33
+ for (let i = 0; i < o.length; i++) {
34
+ const s = o[i];
35
+ if (!Array.isArray(s) || s.length !== 2)
36
+ throw new g("invalid-option", `[Nova3D] Particle ${t} keys must be [t, value] pairs.`);
37
+ const r = Y(s[0], `${t} key time`, 0, 1);
38
+ if (i > 0 && r <= e[i - 1])
39
+ throw new g("invalid-option", `[Nova3D] Particle ${t} key times must increase.`);
40
+ e.push(r);
41
+ }
42
+ return e;
43
+ }
44
+ function Ut(o, t, e) {
45
+ if (t <= o[0]) {
46
+ e.index = 0, e.blend = 0;
47
+ return;
48
+ }
49
+ let i = 0;
50
+ for (; i < o.length - 1 && o[i + 1] < t; )
51
+ i++;
52
+ if (i === o.length - 1) {
53
+ e.index = i, e.blend = 0;
54
+ return;
55
+ }
56
+ e.index = i, e.blend = (t - o[i]) / (o[i + 1] - o[i]);
57
+ }
58
+ function ut(o, t, e, i) {
59
+ if (typeof o == "number")
60
+ return Y(o, t, e, i);
61
+ const s = Et(o, t), r = o.map((a) => Y(a[1], t, e, i));
62
+ if (r.length === 1)
63
+ return r[0];
64
+ const n = new Float32Array(nt + 1), c = { index: 0, blend: 0 };
65
+ for (let a = 0; a <= ct; a++) {
66
+ Ut(s, a / ct, c);
67
+ const h = r[c.index];
68
+ n[a] = c.blend === 0 ? h : h + (r[c.index + 1] - h) * c.blend;
69
+ }
70
+ return n[nt] = n[ct], n;
71
+ }
72
+ function Qt(o, t) {
73
+ if (typeof o == "string" || Array.isArray(o) && typeof o[0] == "number")
74
+ return vt(o, t);
75
+ const e = o, i = Et(e, t), s = e.map((c) => vt(c[1], t));
76
+ if (s.length === 1)
77
+ return s[0];
78
+ const r = new Float32Array((nt + 1) * 4), n = { index: 0, blend: 0 };
79
+ for (let c = 0; c <= ct; c++) {
80
+ Ut(i, c / ct, n);
81
+ const a = s[n.index], h = n.blend === 0 ? a : s[n.index + 1];
82
+ for (let l = 0; l < 4; l++)
83
+ r[c * 4 + l] = a[l] + (h[l] - a[l]) * n.blend;
84
+ }
85
+ return r.copyWithin(nt * 4, ct * 4, nt * 4), r;
86
+ }
87
+ function vt(o, t) {
88
+ try {
89
+ return Vt(o);
90
+ } catch {
91
+ throw new g("invalid-option", `[Nova3D] Particle ${t} must be normalized sRGB components or a hex colour.`);
92
+ }
93
+ }
94
+ function wt(o, t) {
95
+ const e = (t < 0 ? 0 : t > 1 ? 1 : t) * ct, i = e | 0, s = o[i];
96
+ return s + (o[i + 1] - s) * (e - i);
97
+ }
98
+ const gt = 5;
99
+ class Ht {
100
+ constructor(t, e, i, s, r, n) {
101
+ this.capacity = t, this._duration = e, this._loop = i, this._rate = s, this._bursts = r, this._seed = n, this._random = n, this._burstFired = new Int32Array(r.length / 6);
102
+ }
103
+ /**
104
+ * Segment columns: first slot, generation (uint32), births that can land
105
+ * (at most the capacity), age at the step end of the first birth, and the age
106
+ * spacing of later births (younger by `spacing` each).
107
+ */
108
+ segments = new Float64Array(16 * gt);
109
+ segmentCount = 0;
110
+ /** Seconds into the current emission cycle. */
111
+ time = 0;
112
+ emitting = !1;
113
+ /** Index of the next birth. */
114
+ emitted = 0;
115
+ /** One past the highest slot that received a birth since the last clear. */
116
+ highWater = 0;
117
+ _accumulator = 0;
118
+ _random;
119
+ _burstFired;
120
+ /** Starts a cycle at time 0 with every burst pending. */
121
+ start() {
122
+ this.time = 0, this._accumulator = 0, this._burstFired.fill(0), this.emitting = !0;
123
+ }
124
+ /** Ends emission; planned births stop. */
125
+ halt() {
126
+ this.emitting = !1;
127
+ }
128
+ /**
129
+ * Marks every slot free: the next birth starts the next generation at slot 0, so
130
+ * fresh particles never repeat the random attributes of cleared ones.
131
+ */
132
+ clear() {
133
+ this.emitted = Math.ceil(this.emitted / this.capacity) * this.capacity, this.highWater = 0;
134
+ }
135
+ /** Clears and rewinds births and the random stream to the seed, as `restart`. */
136
+ rewind() {
137
+ this.emitted = 0, this.highWater = 0, this._random = this._seed;
138
+ }
139
+ /**
140
+ * Positions the cycle `span` seconds before its end, with bursts before that
141
+ * point already fired, so simulating `span` seconds reaches steady state.
142
+ */
143
+ prewarm(t) {
144
+ const e = this._duration, i = ((e - t) % e + e) % e;
145
+ this.time = i;
146
+ const s = this._bursts;
147
+ for (let r = 0, n = 0; n < s.length; r++, n += 6) {
148
+ let c = 0;
149
+ for (; c < s[n + 3] && s[n] + c * s[n + 4] < i; )
150
+ c++;
151
+ this._burstFired[r] = c;
152
+ }
153
+ }
154
+ /** Plans one burst of `count` births of age 0, whatever the emission state. */
155
+ burst(t) {
156
+ return this.segmentCount = 0, this._push(t, 0, 0), this.segmentCount;
157
+ }
158
+ /**
159
+ * Plans the births of the cycle window [time, time + step), wrapping loops, with
160
+ * ages measured to the end of the step; returns the number of segments.
161
+ */
162
+ plan(t) {
163
+ this.segmentCount = 0;
164
+ let e = this.time, i = t;
165
+ const s = this._duration;
166
+ for (; i > 0 && this.emitting; ) {
167
+ const r = Math.min(i, s - e), n = e + r, c = i - r, a = typeof this._rate == "number" ? this._rate : wt(this._rate, e / s);
168
+ if (a > 0) {
169
+ const l = this._accumulator + a * r, _ = Math.floor(l + 1e-9);
170
+ _ > 0 && this._push(_, (l - 1) / a + c, 1 / a), this._accumulator = Math.max(0, l - _);
171
+ }
172
+ const h = this._bursts;
173
+ for (let l = 0, _ = 0; _ < h.length; l++, _ += 6) {
174
+ const d = h[_ + 3];
175
+ for (; this._burstFired[l] < d; ) {
176
+ const f = h[_] + this._burstFired[l] * h[_ + 4];
177
+ if (f >= n && !(n >= s && f <= s))
178
+ break;
179
+ if (this._burstFired[l]++, h[_ + 5] < 1 && this._next() >= h[_ + 5])
180
+ continue;
181
+ const v = h[_ + 1], u = v === h[_ + 2] ? v : Math.floor(v + this._next() * (h[_ + 2] - v + 1));
182
+ this._push(u, Math.max(0, n - f) + c, 0);
183
+ }
184
+ }
185
+ i = c, e = n, e >= s && (this._loop ? (e = 0, this._burstFired.fill(0)) : (e = s, this.emitting = !1));
186
+ }
187
+ return this.time = e, this.segmentCount;
188
+ }
189
+ /** Appends births [emitted, emitted + count) as one segment. */
190
+ _push(t, e, i) {
191
+ if (t <= 0)
192
+ return;
193
+ const s = this.capacity, r = this.emitted % s, n = Math.min(t, s);
194
+ if (this.segments.length < (this.segmentCount + 1) * gt) {
195
+ const h = new Float64Array(this.segments.length * 2);
196
+ h.set(this.segments), this.segments = h;
197
+ }
198
+ const c = this.segmentCount++ * gt, a = this.segments;
199
+ a[c] = r, a[c + 1] = Math.floor(this.emitted / s) % 4294967296, a[c + 2] = n, a[c + 3] = e, a[c + 4] = i, this.emitted += t, this.highWater = r + n >= s ? s : Math.max(this.highWater, r + n);
200
+ }
201
+ /** Mulberry32, as the CPU system: deterministic uniform number in [0, 1). */
202
+ _next() {
203
+ let t = this._random = this._random + 1831565813 >>> 0;
204
+ return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
205
+ }
206
+ }
207
+ const Ct = ["point", "sphere", "hemisphere", "cone", "box", "circle", "edge"], Jt = {
208
+ point: ["type"],
209
+ sphere: ["type", "radius", "radiusThickness"],
210
+ hemisphere: ["type", "radius", "radiusThickness"],
211
+ cone: ["type", "angle", "radius", "radiusThickness"],
212
+ box: ["type", "size"],
213
+ circle: ["type", "radius", "radiusThickness", "arc"],
214
+ edge: ["type", "length"]
215
+ }, te = ["id", "visible", "position", "rotation", "quaternion", "scale"], Bt = ["id", "visible", "pickable", "position", "rotation", "quaternion", "scale", "capacity", "parent", "clock", "seed", "autoPlay", "duration", "loop", "prewarm", "space", "shape", "randomizeDirection", "rate", "bursts", "lifetime", "startSpeed", "startSize", "startRotation", "angularVelocity", "startColor", "gravity", "drag", "speedOverLife", "velocityOverLife", "sizeOverLife", "colorOverLife", "alphaOverLife", "sortCamera", "blending", "billboard", "texture", "spriteSheet", "depthTest", "fog", "renderOrder", "layers", "timeScale"];
216
+ function Wt(o, t, e, i) {
217
+ if (!t || typeof t != "object")
218
+ throw new g("invalid-option", "[Nova3D] Particle system options are required.");
219
+ for (const y of Object.keys(t))
220
+ if (!i.has(y))
221
+ throw new g("invalid-option", `[Nova3D] Unknown particle system option ${y}.`);
222
+ const s = t.capacity;
223
+ if (!Number.isSafeInteger(s) || s < 1 || s > e)
224
+ throw new g("invalid-option", `[Nova3D] Particle capacity must be an integer in [1, ${e}].`);
225
+ const r = t.clock ?? "app", n = t.space ?? "world";
226
+ if (r !== "app" && r !== "manual")
227
+ throw new g("invalid-option", "[Nova3D] Particle clock must be app or manual.");
228
+ if (n !== "local" && n !== "world")
229
+ throw new g("invalid-option", "[Nova3D] Particle space must be local or world.");
230
+ const c = t.seed ?? Math.floor(Math.random() * 4294967296);
231
+ if (!Number.isSafeInteger(c) || c < 0 || c > 4294967295)
232
+ throw new g("invalid-option", "[Nova3D] Particle seed must be an unsigned 32-bit integer.");
233
+ for (const y of ["autoPlay", "loop", "prewarm", "depthTest", "fog"])
234
+ if (t[y] !== void 0 && typeof t[y] != "boolean")
235
+ throw new g("invalid-option", `[Nova3D] Particle ${y} must be boolean.`);
236
+ const a = Y(t.duration ?? 5, "duration", 1e-3, 1e6), h = t.loop ?? !0, l = t.prewarm ?? !1;
237
+ if (l && !h)
238
+ throw new g("invalid-option", "[Nova3D] Particle prewarm requires loop.");
239
+ const _ = Y(t.timeScale ?? 1, "timeScale", 0, 1e6), d = new Float64Array(6), f = ee(t.shape ?? { type: "point" }, d), v = Y(t.randomizeDirection ?? 0, "randomizeDirection", 0, 1), u = ut(t.rate ?? 10, "rate", 0, 1e7), L = new Float64Array(10);
240
+ dt(t.lifetime ?? 2, "lifetime", 1e-4, 1e6, L, 0), dt(t.startSpeed ?? 1, "startSpeed", -1e6, 1e6, L, 2), dt(t.startSize ?? 1, "startSize", 0, 1e6, L, 4), dt(t.startRotation ?? 0, "startRotation", -1e6, 1e6, L, 6), dt(t.angularVelocity ?? 0, "angularVelocity", -1e6, 1e6, L, 8);
241
+ const M = t.startColor ?? "#ffffff", w = Array.isArray(M) && M.length === 2, N = Float64Array.from(vt(w ? M[0] : M, "startColor")), p = w ? Float64Array.from(vt(M[1], "startColor")) : N, E = t.gravity ?? [0, 0, 0];
242
+ if (!Array.isArray(E) || E.length !== 3)
243
+ throw new g("invalid-option", "[Nova3D] Particle gravity must be a 3-vector.");
244
+ const C = new Float64Array(3);
245
+ for (let y = 0; y < 3; y++)
246
+ C[y] = Y(E[y], "gravity", -1e6, 1e6);
247
+ const U = Y(t.drag ?? 0, "drag", 0, 1e6), Z = ut(t.speedOverLife ?? 1, "speedOverLife", -1e6, 1e6);
248
+ if (t.velocityOverLife !== void 0 && (!Array.isArray(t.velocityOverLife) || t.velocityOverLife.length !== 3))
249
+ throw new g("invalid-option", "[Nova3D] Particle velocityOverLife needs three curves.");
250
+ const q = t.velocityOverLife ? t.velocityOverLife.map((y, A) => ut(y, `velocityOverLife[${A}]`, -1e6, 1e6)) : null, G = ut(t.sizeOverLife ?? 1, "sizeOverLife", 0, 1e6), P = Qt(t.colorOverLife ?? "#ffffff", "colorOverLife"), $ = ut(t.alphaOverLife ?? 1, "alphaOverLife", 0, 1), I = L[6] !== 0 || L[7] !== 0 || L[8] !== 0 || L[9] !== 0, B = ie(t.bursts ?? [], a, e), m = t.blending ?? "normal", S = t.billboard ?? "spherical";
251
+ if (!["normal", "additive", "multiply"].includes(m))
252
+ throw new g("invalid-option", "[Nova3D] Particle blending must be normal, additive or multiply.");
253
+ if (S !== "spherical" && S !== "vertical")
254
+ throw new g("invalid-option", "[Nova3D] Particle billboard must be spherical or vertical.");
255
+ const F = t.texture ?? null, R = new Float64Array(5), z = re(t.spriteSheet, F, R), b = t.parent;
256
+ if (b !== void 0 && (!(b instanceof $t) || b.destroyed || b.scene !== o))
257
+ throw new g("owner", "[Nova3D] Particle parent must be a live node of the scene.");
258
+ t.sortCamera && Ft(t.sortCamera, o);
259
+ const D = {};
260
+ for (const y of te)
261
+ t[y] !== void 0 && (D[y] = t[y]);
262
+ return {
263
+ capacity: s,
264
+ clock: r,
265
+ space: n,
266
+ seed: c,
267
+ autoPlay: t.autoPlay ?? !0,
268
+ duration: a,
269
+ loop: h,
270
+ prewarm: l,
271
+ timeScale: _,
272
+ shape: f,
273
+ shapeValues: d,
274
+ randomize: v,
275
+ rate: u,
276
+ ranges: L,
277
+ colorA: N,
278
+ colorB: p,
279
+ gravity: C,
280
+ drag: U,
281
+ speedCurve: Z,
282
+ velocityCurves: q,
283
+ sizeCurve: G,
284
+ colorCurve: P,
285
+ alphaCurve: $,
286
+ rotates: I,
287
+ bursts: B,
288
+ blending: m,
289
+ billboard: S,
290
+ texture: F,
291
+ spriteSheet: z,
292
+ animated: z !== null && R[1] > 1,
293
+ sheet: R,
294
+ parent: b,
295
+ sortCamera: t.sortCamera ?? null,
296
+ depthTest: t.depthTest ?? !0,
297
+ fog: t.fog ?? !0,
298
+ nodeOptions: D
299
+ };
300
+ }
301
+ function ee(o, t) {
302
+ if (!o || typeof o != "object" || !Ct.includes(o.type))
303
+ throw new g("invalid-option", `[Nova3D] Particle shape type must be one of ${Ct.join(", ")}.`);
304
+ for (const s of Object.keys(o))
305
+ if (!Jt[o.type].includes(s))
306
+ throw new g("invalid-option", `[Nova3D] Unknown ${o.type} shape option ${s}.`);
307
+ const e = o;
308
+ t[0] = Y(e.radius ?? e.length ?? 1, o.type === "edge" ? "edge length" : "shape radius", 0, 1e6), t[1] = Y(e.radiusThickness ?? 1, "radiusThickness", 0, 1), t[2] = o.type === "cone" ? Y(e.angle ?? Math.PI / 6, "cone angle", 0, Math.PI / 2) : Y(e.arc ?? Math.PI * 2, "circle arc", 0, Math.PI * 2), o.type === "cone" && e.radius === void 0 && (t[0] = 0);
309
+ const i = e.size ?? [1, 1, 1];
310
+ if (!Array.isArray(i) || i.length !== 3)
311
+ throw new g("invalid-option", "[Nova3D] Box shape size must be a 3-vector.");
312
+ for (let s = 0; s < 3; s++)
313
+ t[3 + s] = Y(i[s], "box size", 0, 1e6);
314
+ return Ct.indexOf(o.type);
315
+ }
316
+ const se = jt({ time: !0, count: !0, cycles: !0, interval: !0, probability: !0 });
317
+ function ie(o, t, e) {
318
+ if (!Array.isArray(o) || o.length > 256)
319
+ throw new g("invalid-option", "[Nova3D] Particle bursts must be an array of at most 256 bursts.");
320
+ const i = new Float64Array(o.length * 6);
321
+ for (let s = 0; s < o.length; s++) {
322
+ const r = o[s];
323
+ Kt(r, se, "particle burst");
324
+ const n = s * 6;
325
+ if (i[n] = Y(r.time, "burst time", 0, t), dt(r.count, "burst count", 0, e, i, n + 1), !Number.isInteger(i[n + 1]) || !Number.isInteger(i[n + 2]))
326
+ throw new g("invalid-option", "[Nova3D] Particle burst count must be integral.");
327
+ const c = r.cycles ?? 1;
328
+ if (!Number.isSafeInteger(c) || c < 1 || c > 1e6)
329
+ throw new g("invalid-option", "[Nova3D] Particle burst cycles must be an integer in [1, 1e6].");
330
+ i[n + 3] = c, i[n + 4] = Y(r.interval ?? 0, "burst interval", 0, 1e6), i[n + 5] = Y(r.probability ?? 1, "burst probability", 0, 1);
331
+ }
332
+ return i;
333
+ }
334
+ function re(o, t, e) {
335
+ if (o === void 0)
336
+ return null;
337
+ if (!t || typeof o != "object" || !o)
338
+ throw new g("invalid-option", "[Nova3D] Particle spriteSheet needs a texture.");
339
+ for (const h of Object.keys(o))
340
+ if (!["columns", "rows", "frame", "frameCount", "cycles", "frameRate", "randomStartFrame"].includes(h))
341
+ throw new g("invalid-option", `[Nova3D] Unknown particle spriteSheet option ${h}.`);
342
+ const i = o.columns, s = o.rows, r = o.frame ?? 0, n = o.frameCount ?? 1;
343
+ if (!Number.isSafeInteger(i) || !Number.isSafeInteger(s) || i < 1 || s < 1 || i > 4096 || s > 4096 || !Number.isSafeInteger(r) || r < 0 || !Number.isSafeInteger(n) || n < 1 || r + n > i * s)
344
+ throw new g("invalid-option", "[Nova3D] Particle spriteSheet needs 1..4096 columns and rows and frames inside them.");
345
+ if (o.cycles !== void 0 && o.frameRate !== void 0)
346
+ throw new g("invalid-option", "[Nova3D] Particle spriteSheet takes cycles or frameRate, not both.");
347
+ const c = o.cycles ?? 1, a = o.frameRate;
348
+ if (!(Number.isFinite(c) && c > 0) || a !== void 0 && !(Number.isFinite(a) && a > 0) || o.randomStartFrame !== void 0 && typeof o.randomStartFrame != "boolean")
349
+ throw new g("invalid-option", "[Nova3D] Particle spriteSheet cycles and frameRate must be positive; randomStartFrame boolean.");
350
+ return e[0] = r, e[1] = n, e[2] = a ?? c * n, e[3] = a === void 0 ? 0 : 1, e[4] = o.randomStartFrame ? 1 : 0, { columns: i, rows: s, frame: r };
351
+ }
352
+ function Ft(o, t) {
353
+ if (!(o instanceof Gt) || o.destroyed || o.scene !== t)
354
+ throw new g("invalid-option", "[Nova3D] sortCamera must be a live camera of the particle scene.");
355
+ }
356
+ const ne = 1 << 20, zt = 1024, At = 1 / 30, oe = 0.25, lt = qt, ft = nt, ht = 1e9, ae = /* @__PURE__ */ new Set([...Bt, "bounds", "sortStagesPerFrame"]), at = 0, st = 1, mt = 2, Lt = bt(), he = bt(), pt = kt();
357
+ function ce(o) {
358
+ const t = new Float32Array(ft * 3 * 4), e = (r, n) => typeof r == "number" ? r : r[n], i = o.colorCurve, s = o.velocityCurves;
359
+ for (let r = 0; r < ft; r++) {
360
+ const n = r * 4;
361
+ for (let h = 0; h < 4; h++)
362
+ t[n + h] = i instanceof Float32Array ? i[n + h] : i[h];
363
+ const c = (ft + r) * 4;
364
+ t[c] = e(o.sizeCurve, r), t[c + 1] = e(o.alphaCurve, r), t[c + 2] = e(o.speedCurve, r);
365
+ const a = (ft * 2 + r) * 4;
366
+ for (let h = 0; h < 3; h++)
367
+ t[a + h] = s ? e(s[h], r) : 0;
368
+ }
369
+ return t;
370
+ }
371
+ class le {
372
+ /** @internal */
373
+ constructor(t, e, i) {
374
+ if (this._app = t, !t || t.destroyed || typeof t.createGeometry != "function" || !t._ownsScene(e))
375
+ throw new g("owner", "[Nova3D] Particle systems need a live app and one of its scenes.");
376
+ const s = Wt(e, i, ne, ae), r = _e(i.bounds ?? null);
377
+ if (i.pickable)
378
+ throw new g("invalid-option", "[Nova3D] GPU particles are not pickable; their positions live on the GPU.");
379
+ const n = i.sortStagesPerFrame ?? 32;
380
+ if (!Number.isSafeInteger(n) || n < 1 || n > 1024)
381
+ throw new g("invalid-option", "[Nova3D] sortStagesPerFrame must be an integer in [1, 1024].");
382
+ const c = t.backend === "webgpu";
383
+ let a;
384
+ if (!c) {
385
+ if (typeof t._gpu != "function")
386
+ throw new g("invalid-option", "[Nova3D] GPU particles need a WebGL2 or WebGPU app.");
387
+ a = t._gpu();
388
+ const p = a.gl;
389
+ if (p.isContextLost())
390
+ throw new g("state", "[Nova3D] Create GPU particles after the WebGL context is restored.");
391
+ if (!p.getExtension("EXT_color_buffer_float"))
392
+ throw new g("unsupported", "[Nova3D] GPU particles need EXT_color_buffer_float (float render targets); use createParticleSystem on this device.");
393
+ if (p.getParameter(p.MAX_VERTEX_TEXTURE_IMAGE_UNITS) < 4 || p.getParameter(p.MAX_DRAW_BUFFERS) < 2)
394
+ throw new g("unsupported", "[Nova3D] GPU particles need four vertex texture units and two draw buffers.");
395
+ }
396
+ const h = s.capacity;
397
+ this._settings = s, this.capacity = h, this.space = s.space, this.clock = s.clock, this._timeScale = s.timeScale, this._sortCamera = s.sortCamera, this._sortStages = n, this._width = Math.min(h, zt), this._height = Math.ceil(h / this._width), this._orderSize = St(h), this._orderWidth = Math.min(this._orderSize, zt), this._schedule = new Ht(h, s.duration, s.loop, s.rate, s.bursts, s.seed), this._curveTable = ce(s);
398
+ const l = s.shapeValues, _ = {
399
+ capacity: h,
400
+ width: this._width,
401
+ height: this._height,
402
+ orderSize: this._orderSize,
403
+ orderWidth: this._orderWidth,
404
+ seed: s.seed >>> 0,
405
+ shape: s.shape,
406
+ world: s.space === "world",
407
+ drag: s.drag,
408
+ speedCurve: typeof s.speedCurve != "number",
409
+ velocityCurve: s.velocityCurves !== null,
410
+ ranges: [s.ranges[0], s.ranges[1], s.ranges[2], s.ranges[3]],
411
+ shapeValues: [l[0], l[1], l[2], s.randomize],
412
+ boxSize: [l[3], l[4], l[5]],
413
+ speedConstant: typeof s.speedCurve == "number" ? s.speedCurve : 1,
414
+ curves: this._curveTable
415
+ };
416
+ this._gpuState = c ? t._webgpu("GPU particles").createParticleState(_) : new Xt(a.gl, a.invalidate, _);
417
+ const f = s.texture?.flipY ? 1 : 0, v = 1 - f, u = r ? r.min : [-ht, -ht, -ht], L = r ? r.max : [ht, ht, ht], M = t.createGeometry({
418
+ positions: new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0, u[0], u[1], u[2], L[0], L[1], L[2]]),
419
+ uvs: new Float32Array([0, v, 1, v, 1, f, 0, f, 0, 0, 0, 0]),
420
+ indices: new Uint16Array([0, 1, 2, 0, 2, 3])
421
+ });
422
+ let w, N;
423
+ try {
424
+ this._gpuState.create(), this._resident = !0, w = this._createMaterial(), N = e.createGroup(s.nodeOptions), s.parent && N.reparent(s.parent);
425
+ const p = e.createMesh({ geometry: M, material: w, pickable: !1, renderOrder: i.renderOrder, layers: i.layers });
426
+ this.space === "local" && p.reparent(N), p._drawInstances = 0, p._pullQuads = !0, this._gpuState.attach(p), this._mesh = p;
427
+ } catch (p) {
428
+ N?.destroy(), w?.destroy();
429
+ for (const E of this._textures)
430
+ E.destroy();
431
+ throw M.destroy(), this._deleteResources(), p;
432
+ }
433
+ this.node = N, this._geometry = M, this._material = w, this._cleanup.push(t._own(() => this.destroy())), this._cleanup.push(t.onUpdate(this._onFrame)), this._cleanup.push(t._beforeRender(this._onRender)), this._cleanup.push(t.onContextStateChange((p) => {
434
+ p.state === "lost" ? this._lost = !0 : p.state === "restored" && this._restore();
435
+ })), s.autoPlay && this.play();
436
+ }
437
+ /** Emitter node: move it to move the emitter. */
438
+ node;
439
+ /**
440
+ * The mesh drawing the particles with one instanced draw.
441
+ * @internal
442
+ */
443
+ _mesh;
444
+ /** Fixed particle capacity. */
445
+ capacity;
446
+ space;
447
+ clock;
448
+ _settings;
449
+ _schedule;
450
+ _gpuState;
451
+ _geometry;
452
+ _material;
453
+ _textures = [];
454
+ _cleanup = [];
455
+ _width;
456
+ _height;
457
+ _orderWidth;
458
+ _orderSize;
459
+ _curveTable;
460
+ _sortStages;
461
+ /** GPU objects exist for the current device or context generation. */
462
+ _resident = !1;
463
+ _lease;
464
+ _destroyed = !1;
465
+ _lost = !1;
466
+ _state = at;
467
+ _timeScale;
468
+ /** Seconds until every particle is surely dead once emission ended. */
469
+ _drain = 0;
470
+ _sortCamera;
471
+ /** Bitonic network cursor: block size, compare distance, and the size it sorts. */
472
+ _sortBlock = 2;
473
+ _sortDistance = 1;
474
+ _sortSize = 0;
475
+ _sorted = !1;
476
+ _fog = void 0;
477
+ /** Draw count written to the mesh, to skip unchanged writes. */
478
+ _instances = 0;
479
+ // Per-update frame: local gravity, emitter translation now and at the previous update.
480
+ _frame = new Float64Array(9);
481
+ _hasPrevious = !1;
482
+ _updateLength = 0;
483
+ _untilEnd = 0;
484
+ // Upload staging, reused by every pass.
485
+ _input = { pass: new Float32Array(4), inverseUpdate: 0, gravity: new Float32Array(3), emitterShift: new Float32Array(3), emitter: new Float32Array(16), segmentSlots: new Uint32Array(lt * 4), segmentAges: new Float32Array(lt * 2), segmentCount: 0 };
486
+ _onFrame = (t) => {
487
+ if (!this._destroyed) {
488
+ if (this.node.destroyed || this.node.scene.destroyed) {
489
+ this.destroy();
490
+ return;
491
+ }
492
+ this.clock === "app" && this._state === st && this._advance(Math.min(t.deltaTime, oe) * this._timeScale);
493
+ }
494
+ };
495
+ _onRender = () => {
496
+ this._destroyed || this._lost || this.node.scene.destroyed || (this._settings.fog && this._syncFog(), this._sortPasses());
497
+ };
498
+ /**
499
+ * Slots that may hold a live particle: the instance count of the draw (Babylon.js
500
+ * active count), an upper bound of the live particles; `readCount()` reads the
501
+ * exact number back from the GPU.
502
+ */
503
+ get count() {
504
+ return this._schedule.highWater;
505
+ }
506
+ /** Seconds into the current emission cycle. */
507
+ get time() {
508
+ return this._schedule.time;
509
+ }
510
+ get playing() {
511
+ return this._state === st;
512
+ }
513
+ get paused() {
514
+ return this._state === mt;
515
+ }
516
+ /** Whether the emitter still emits; false after `stop` or the end of a non-looping cycle. */
517
+ get emitting() {
518
+ return this._schedule.emitting;
519
+ }
520
+ /** Draw order within the blended group; see `Nova3DMesh.renderOrder`. */
521
+ get renderOrder() {
522
+ return this._mesh.renderOrder;
523
+ }
524
+ setRenderOrder(t) {
525
+ this._assertAlive(), this._mesh.setRenderOrder(t);
526
+ }
527
+ /** Layer bit mask; see `Nova3DMesh.layers`. */
528
+ get layers() {
529
+ return this._mesh.layers;
530
+ }
531
+ setLayers(t) {
532
+ this._assertAlive(), this._mesh.setLayers(It(t));
533
+ }
534
+ get timeScale() {
535
+ return this._timeScale;
536
+ }
537
+ get destroyed() {
538
+ return this._destroyed;
539
+ }
540
+ /** GPU bytes of the state, curve and sort textures. */
541
+ get gpuBytes() {
542
+ const t = this._width * this._height * 16 * 4, e = this._resident && this._gpuState.ordered ? this._orderSize * 4 * 2 : 0;
543
+ return t + ft * 3 * 16 + e;
544
+ }
545
+ /** Sets the multiplier of every clock advance, in [0, 1e6]. */
546
+ setTimeScale(t) {
547
+ this._assertAlive(), this._timeScale = Y(t, "timeScale", 0, 1e6);
548
+ }
549
+ /**
550
+ * Sorts back to front along this camera's view direction, approximately: the
551
+ * bitonic network advances `sortStagesPerFrame` stages per rendered frame against
552
+ * the live positions. null turns sorting off.
553
+ */
554
+ setSortCamera(t) {
555
+ this._assertAlive(), t !== null && Ft(t, this.node.scene), this._sortCamera = t, this._syncInstances();
556
+ }
557
+ /**
558
+ * Starts a stopped system from cycle time 0 (prewarmed when configured), resumes a
559
+ * paused one, and restarts emission after `stop` without clearing.
560
+ */
561
+ play() {
562
+ this._assertAlive();
563
+ const t = this._schedule;
564
+ if (this._state === mt && (this._state = st, this._hasPrevious = !1, t.emitting || this._drain > 0)) {
565
+ this._syncLease();
566
+ return;
567
+ }
568
+ if (t.emitting && this._state === st)
569
+ return;
570
+ const e = this._state === at;
571
+ this._hasPrevious = !1, t.start(), this._state = st, e && this._settings.prewarm && this._prewarmCycle(), this._syncLease();
572
+ }
573
+ /** Freezes simulation and emission until `play`. */
574
+ pause() {
575
+ this._assertAlive(), this._state === st && (this._state = mt, this._syncLease());
576
+ }
577
+ /** Stops emitting; live particles finish their lives unless `clear` removes them now. */
578
+ stop(t = !1) {
579
+ if (this._assertAlive(), typeof t != "boolean")
580
+ throw new g("invalid-option", "[Nova3D] stop(clear) takes a boolean.");
581
+ this._schedule.emitting && (this._schedule.halt(), this._drain = this._drainTime()), t ? (this._clear(), this._schedule.clear(), this._drain = 0, this._state = at, this._hasPrevious = !1, this._syncInstances()) : this._drain <= 0 && (this._state = at), this._syncLease();
582
+ }
583
+ /** Clears, rewinds births and the random stream to the seed and plays again. */
584
+ restart() {
585
+ this._assertAlive(), this.stop(!0), this._schedule.rewind(), this.play();
586
+ }
587
+ /** Emits `count` particles of age 0 now, whatever the emission state; a stopped system starts simulating. */
588
+ emitBurst(t) {
589
+ if (this._assertAlive(), !Number.isSafeInteger(t) || t < 0)
590
+ throw new g("invalid-option", "[Nova3D] Burst count must be a non-negative integer.");
591
+ t !== 0 && (this._state === at && (this._state = st), this._schedule.emitting || (this._drain = Math.max(this._drain, this._drainTime())), this._readFrame(), this._updateLength = 0, this._untilEnd = 0, this._schedule.burst(t), this._passes(0, 0), this._finish());
592
+ }
593
+ /** Advances a manual-clock system by `deltaTime` seconds (scaled by timeScale). */
594
+ update(t) {
595
+ if (this._assertAlive(), this.clock !== "manual")
596
+ throw new g("state", "[Nova3D] update is only available with manual clock.");
597
+ Y(t, "deltaTime", 0, 1e6), this._state === st && this._advance(t * this._timeScale);
598
+ }
599
+ /**
600
+ * Reads the number of live particles back from the GPU without stalling the frame
601
+ * (pixel pack buffer and fence); resolves to 0 when the context is lost meanwhile.
602
+ */
603
+ async readCount() {
604
+ this._assertAlive();
605
+ const t = Math.ceil(this._schedule.highWater / this._width);
606
+ return t === 0 || this._lost || !this._resident ? 0 : this._gpuState.readCount(t, Math.min(this.capacity, this._width * t), () => !this._lost && !this._destroyed);
607
+ }
608
+ /** Releases the GPU state, node, mesh, geometry and material; a user texture is kept. */
609
+ destroy() {
610
+ if (this._destroyed)
611
+ return;
612
+ this._destroyed = !0, this._lease?.release(), this._lease = void 0;
613
+ for (const e of this._cleanup.splice(0))
614
+ e();
615
+ const t = !this.node.scene.destroyed;
616
+ t && !this._mesh.destroyed && this._mesh.destroy(), t && !this.node.destroyed && this.node.destroy(), this._material.destroyed || this._material.destroy();
617
+ for (const e of this._textures)
618
+ e.destroyed || e.destroy();
619
+ this._geometry.destroyed || this._geometry.destroy(), this._deleteResources();
620
+ }
621
+ /** Simulates `delta` seconds in equal steps of at most MAX_STEP. */
622
+ _advance(t) {
623
+ if (t <= 0)
624
+ return;
625
+ this._readFrame();
626
+ const e = Math.ceil(t / At), i = t / e;
627
+ this._updateLength = t;
628
+ for (let s = 0; s < e; s++) {
629
+ this._untilEnd = (e - 1 - s) * i;
630
+ const r = this._schedule;
631
+ r.emitting ? (r.plan(i), r.emitting || (this._drain = this._drainTime())) : (r.segmentCount = 0, this._drain -= i), (r.emitting || this._drain > -i) && this._passes(i, i);
632
+ }
633
+ !this._schedule.emitting && this._drain <= 0 && (this._state = at), this._finish();
634
+ }
635
+ /** One ageing pass of `dt` seconds with the planned segments, then spawn-only passes for the rest. */
636
+ _passes(t, e) {
637
+ const s = this._schedule.segmentCount;
638
+ this._pass(t, e, 0, Math.min(s, lt));
639
+ for (let r = lt; r < s; r += lt)
640
+ this._pass(0, e, r, Math.min(s - r, lt));
641
+ }
642
+ /** Runs the simulation pass over the used rows. */
643
+ _pass(t, e, i, s) {
644
+ const r = Math.ceil(this._schedule.highWater / this._width);
645
+ if (this._lost || !this._resident || r === 0)
646
+ return;
647
+ const n = this._input, c = this._settings;
648
+ n.pass[0] = t, n.pass[1] = c.drag > 0 ? Math.exp(-c.drag * t) : 1, n.pass[2] = e, n.pass[3] = this._untilEnd, n.inverseUpdate = this._updateLength > 0 ? 1 / this._updateLength : 0;
649
+ const a = this._frame;
650
+ n.gravity[0] = a[0], n.gravity[1] = a[1], n.gravity[2] = a[2], n.emitterShift[0] = a[3] - a[6], n.emitterShift[1] = a[4] - a[7], n.emitterShift[2] = a[5] - a[8];
651
+ const h = this._schedule.segments, l = n.segmentSlots, _ = n.segmentAges;
652
+ for (let d = 0; d < s; d++) {
653
+ const f = (i + d) * gt;
654
+ l[d * 4] = h[f], l[d * 4 + 1] = h[f + 2], l[d * 4 + 2] = h[f + 1], _[d * 2] = h[f + 3], _[d * 2 + 1] = h[f + 4];
655
+ }
656
+ n.segmentCount = s, this._gpuState.simulate(r, n);
657
+ }
658
+ /** Ends a batch of passes: draw count, renderer state, frame request and the loop lease. */
659
+ _finish() {
660
+ this._resident && !this._lost && this._gpuState.flush(), this._syncInstances(), this.node.scene._invalidate(), this._syncLease();
661
+ }
662
+ /** Writes the instance count of the particle draw. */
663
+ _syncInstances() {
664
+ const t = this._sortCamera !== null && !this._sortCamera.destroyed && this._schedule.highWater > 1, e = t ? St(this._schedule.highWater) : this._schedule.highWater;
665
+ t !== this._sorted && (this._sorted = t, this._material.setUniform("particleSorted", t ? 1 : 0)), e !== this._instances && (this._instances = e, this._mesh._drawInstances = e, this.node.scene._invalidate());
666
+ }
667
+ /** Runs this frame's share of the bitonic network against the sort camera. */
668
+ _sortPasses() {
669
+ const t = this._sortCamera;
670
+ if (t === null)
671
+ return;
672
+ if (t.destroyed) {
673
+ this._sortCamera = null, this._syncInstances();
674
+ return;
675
+ }
676
+ const e = this._schedule.highWater;
677
+ if (e < 2 || !this._resident || this._lost)
678
+ return;
679
+ this._gpuState.ensureOrder() && (this._sortBlock = 2, this._sortDistance = 1);
680
+ const i = St(e);
681
+ i !== this._sortSize && (this._sortSize = i, this._sortBlock = 2, this._sortDistance = 1);
682
+ const s = t.getWorldMatrix(he);
683
+ let r = -s[8], n = -s[9], c = -s[10];
684
+ if (this.space === "local") {
685
+ const h = this.node.getWorldMatrix(Lt), l = h[0] * r + h[1] * n + h[2] * c, _ = h[4] * r + h[5] * n + h[6] * c, d = h[8] * r + h[9] * n + h[10] * c;
686
+ r = l, n = _, c = d;
687
+ }
688
+ const a = this._gpuState;
689
+ a.beginSort(i, r, n, c);
690
+ for (let h = 0; h < this._sortStages; h++)
691
+ a.sortStage(this._sortBlock, this._sortDistance), this._sortDistance >>= 1, this._sortDistance === 0 && (this._sortBlock <<= 1, this._sortBlock > i && (this._sortBlock = 2), this._sortDistance = this._sortBlock >> 1);
692
+ a.endSort();
693
+ }
694
+ /** Mirrors the scene fog into the material uniforms when it changes. */
695
+ _syncFog() {
696
+ const t = this.node.scene._readFog();
697
+ if (t === this._fog)
698
+ return;
699
+ this._fog = t;
700
+ const e = this._material;
701
+ e.setUniform("particleFogMode", t ? t.mode + 1 : 0), t && (e.setUniform("particleFogColor", t.color), e.setUniform("particleFogParameters", [t.a, t.b]));
702
+ }
703
+ /** Reads the emitter world frame: matrix, local gravity and translation history. */
704
+ _readFrame() {
705
+ const t = this._frame, e = this.node.getWorldMatrix(Lt);
706
+ this._hasPrevious ? (t[3] = t[6], t[4] = t[7], t[5] = t[8]) : (t[3] = e[12], t[4] = e[13], t[5] = e[14]), t[6] = e[12], t[7] = e[13], t[8] = e[14], this._hasPrevious = !0, this._input.emitter.set(e);
707
+ const i = this._settings.gravity;
708
+ if (this.space === "world") {
709
+ t[0] = i[0], t[1] = i[1], t[2] = i[2];
710
+ return;
711
+ }
712
+ if (Tt(pt, e), !Ot(pt, pt)) {
713
+ t[0] = t[1] = t[2] = 0;
714
+ return;
715
+ }
716
+ const s = pt;
717
+ t[0] = s[0] * i[0] + s[3] * i[1] + s[6] * i[2], t[1] = s[1] * i[0] + s[4] * i[1] + s[7] * i[2], t[2] = s[2] * i[0] + s[5] * i[1] + s[8] * i[2];
718
+ }
719
+ /** Simulates the tail of one previous cycle so the system starts in steady state. */
720
+ _prewarmCycle() {
721
+ const t = this._settings.ranges[1];
722
+ this._schedule.prewarm(t), this._readFrame();
723
+ const e = Math.ceil(t / At), i = t / e;
724
+ this._updateLength = 0, this._untilEnd = 0;
725
+ for (let s = 0; s < e; s++)
726
+ this._schedule.plan(i), this._passes(i, i);
727
+ this._finish();
728
+ }
729
+ /** Longest remaining life once births stop, with one step of margin for summed step rounding. */
730
+ _drainTime() {
731
+ return this._settings.ranges[1] + At;
732
+ }
733
+ /** Holds the app loop lease exactly while an app-clock system is playing. */
734
+ _syncLease() {
735
+ !this._destroyed && this.clock === "app" && this._state === st ? this._lease ??= this._app._acquireLoop("nova3d.gpu-particles") : (this._lease?.release(), this._lease = void 0);
736
+ }
737
+ /** Frees every slot; the draw order restarts from the identity. */
738
+ _clear() {
739
+ this._lost || !this._resident || (this._gpuState.clear(), this._sortBlock = 2, this._sortDistance = 1, this._sortSize = 0);
740
+ }
741
+ /** After a context restore: new GPU objects, and the system restarts when it was emitting. */
742
+ _restore() {
743
+ if (this._destroyed)
744
+ return;
745
+ this._lost = !1, this._gpuState.destroy(!0), this._resident = !1;
746
+ try {
747
+ this._gpuState.create(), this._resident = !0;
748
+ } catch (i) {
749
+ throw this.destroy(), i;
750
+ }
751
+ this._sortBlock = 2, this._sortDistance = 1, this._sortSize = 0;
752
+ const t = this._schedule.emitting, e = this._state === mt;
753
+ this._schedule.halt(), this._schedule.rewind(), this._drain = 0, this._state = at, this._hasPrevious = !1, t && (this.play(), e && this.pause()), this._finish();
754
+ }
755
+ _deleteResources() {
756
+ const t = this._resident;
757
+ this._resident = !1, t && this._gpuState.destroy(this._lost);
758
+ }
759
+ /** The shader material drawing the particles; GPU state is exposed as external textures. */
760
+ _createMaterial() {
761
+ const t = this._settings, e = (r) => {
762
+ const n = this._app.createTexture({ width: 1, height: 1, data: new Float32Array(4), format: "rgba16f", colorSpace: "linear", mipmaps: !1, filter: "nearest", wrap: "clamp" });
763
+ return n._external = r, this._textures.push(n), n;
764
+ }, i = this._gpuState, s = {
765
+ particleStateA: e(() => i.texture("stateA")),
766
+ particleStateB: e(() => i.texture("stateB")),
767
+ particleCurves: e(() => i.texture("curves")),
768
+ particleOrder: e(() => i.texture("order")),
769
+ particleOrderWidth: this._orderWidth,
770
+ particleSorted: 0,
771
+ particleWidth: this._width,
772
+ particleCapacity: this.capacity,
773
+ particleRanges: [t.ranges[0], t.ranges[1], t.ranges[4], t.ranges[5]],
774
+ particleSpin: [t.ranges[6], t.ranges[7], t.ranges[8], t.ranges[9]],
775
+ particleColorA: Array.from(t.colorA),
776
+ particleColorB: Array.from(t.colorB),
777
+ particleColorConstant: t.colorCurve instanceof Float32Array ? [1, 1, 1, 1] : t.colorCurve,
778
+ particleSizeAlpha: [typeof t.sizeCurve == "number" ? t.sizeCurve : 1, typeof t.alphaCurve == "number" ? t.alphaCurve : 1],
779
+ particleSheet: Array.from(t.sheet.subarray(0, 4)),
780
+ particleAtlas: [t.spriteSheet?.columns ?? 1, t.spriteSheet?.rows ?? 1, t.sheet[4], t.texture?.flipY ? 1 : 0]
781
+ };
782
+ return t.texture && (s.particleMap = t.texture), t.fog && (s.particleFogMode = 0, s.particleFogColor = [0, 0, 0], s.particleFogParameters = [0, 1]), this._app.createMaterial({
783
+ type: "shader",
784
+ vertex: Zt,
785
+ fragment: Yt,
786
+ uniforms: s,
787
+ defines: {
788
+ PARTICLE_SIZE_CURVE: typeof t.sizeCurve != "number",
789
+ PARTICLE_ALPHA_CURVE: typeof t.alphaCurve != "number",
790
+ PARTICLE_COLOR_CURVE: t.colorCurve instanceof Float32Array,
791
+ PARTICLE_TWO_COLORS: t.colorA !== t.colorB,
792
+ PARTICLE_MAP: t.texture !== null,
793
+ PARTICLE_SHEET: t.spriteSheet !== null,
794
+ PARTICLE_ANIMATED: t.animated,
795
+ PARTICLE_ROTATES: t.rotates,
796
+ PARTICLE_VERTICAL: t.billboard === "vertical",
797
+ PARTICLE_FOG: t.fog
798
+ },
799
+ alphaMode: "blend",
800
+ blending: t.blending,
801
+ depthWrite: !1,
802
+ depthTest: t.depthTest,
803
+ side: "double"
804
+ });
805
+ }
806
+ _assertAlive() {
807
+ if (this._destroyed)
808
+ throw new g("destroyed", "[Nova3D] Particle system is destroyed.");
809
+ }
810
+ }
811
+ function St(o) {
812
+ let t = 1;
813
+ for (; t < o; )
814
+ t *= 2;
815
+ return t;
816
+ }
817
+ function _e(o) {
818
+ if (o === null)
819
+ return null;
820
+ const t = (e) => Array.isArray(e) && e.length === 3 && e.every((i) => Number.isFinite(i) && Math.abs(i) <= ht);
821
+ if (!o || typeof o != "object" || !t(o.min) || !t(o.max) || o.min.some((e, i) => e > o.max[i]))
822
+ throw new g("invalid-option", "[Nova3D] Particle bounds need finite min and max 3-vectors with min ≤ max.");
823
+ return o;
824
+ }
825
+ function Me(o, t) {
826
+ return new le(Rt(o), o, t);
827
+ }
828
+ const de = 262144, Dt = 1 / 30, ue = 0.25, H = 0.7072, xt = nt - 1, fe = new Set(Bt), _t = 0, it = 1, Mt = 2, Pt = bt(), me = bt(), yt = kt();
829
+ class pe {
830
+ /** @internal */
831
+ constructor(t, e, i) {
832
+ if (this._app = t, !t || t.destroyed || typeof t.createGeometry != "function" || !t._ownsScene(e))
833
+ throw new g("owner", "[Nova3D] Particle systems need a live app and one of its scenes.");
834
+ const s = Wt(e, i, de, fe), r = s.capacity, n = s.space, c = s.clock, a = s.seed;
835
+ this._duration = s.duration, this._loop = s.loop, this._prewarm = s.prewarm, this._timeScale = s.timeScale, this._shape = s.shape, this._shapeValues = s.shapeValues, this._randomize = s.randomize, this._rate = s.rate, this._ranges = s.ranges, this._colorA = s.colorA, this._colorB = s.colorB, this._gravity = s.gravity, this._drag = s.drag, this._speedCurve = s.speedCurve, this._velocityCurves = s.velocityCurves, this._sizeCurve = s.sizeCurve, this._colorCurve = s.colorCurve, this._alphaCurve = s.alphaCurve, this._rotates = s.rotates, this._colorVaries = this._colorCurve instanceof Float32Array || typeof this._alphaCurve != "number", this._spins = this._ranges[8] !== 0 || this._ranges[9] !== 0, this._bursts = s.bursts, this._burstFired = new Int32Array(this._bursts.length / 6), this._sheet = s.sheet;
836
+ const { blending: h, billboard: l, texture: _, spriteSheet: d, animated: f, parent: v } = s;
837
+ this.capacity = r, this.space = n, this.clock = c, this._seed = a, this._random = a, this._position = new Float32Array(r * 3), this._velocity = new Float32Array(r * 3), this._age = new Float32Array(r), this._inverseLife = new Float32Array(r), this._size = new Float32Array(r), this._angle = new Float32Array(r), this._spin = new Float32Array(r), this._color = new Float32Array(r * 4), this._poses = new Float32Array(r * 10), this._colors = new Float32Array(t.backend === "webgl2" ? 0 : r * 4), this._frameOffset = f ? new Float32Array(r) : null, this._frames = f ? new Float32Array(r) : null;
838
+ const u = t.backend === "webgl2";
839
+ this._matrices = new Float32Array(u ? 0 : r * 16), this._recordRoll = this._rotates || f, this._recordColor = u && this._colorA === this._colorB && !this._colorVaries ? this._sharedColor() : null, this._recordFloats = 4 + (this._recordRoll ? 4 : 0) + (this._recordColor === null ? 4 : 0), this._records = u ? new Float32Array(r * this._recordFloats) : null, this._fusable = u && typeof this._sizeCurve == "number" && this._ranges[4] === this._ranges[5] && !this._spins && !f && !(this._recordColor === null && this._colorVaries) && typeof this._speedCurve == "number" && this._velocityCurves === null;
840
+ const M = _?.flipY ?? !1 ? 1 : 0, w = 1 - M, N = t.createGeometry({
841
+ // Quad plus two unreferenced guard vertices so bounds cover any view-plane rotation.
842
+ positions: new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0, -H, -H, -H, H, H, H]),
843
+ normals: new Float32Array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]),
844
+ uvs: new Float32Array([0, w, 1, w, 1, M, 0, M, 0, 0, 0, 0]),
845
+ indices: new Uint16Array([0, 1, 2, 0, 2, 3])
846
+ });
847
+ let p, E;
848
+ try {
849
+ p = t.createMaterial({ type: "basic", map: _, spriteSheet: d, alphaMode: "blend", blending: h, depthWrite: !1, depthTest: s.depthTest, fog: s.fog, billboard: l }), E = e.createGroup(s.nodeOptions), v && E.reparent(v);
850
+ const C = e.createInstancedMesh({ geometry: N, material: p, capacity: r, count: 0, colors: !0, frames: f, pickable: i.pickable ?? !1, renderOrder: i.renderOrder, layers: i.layers });
851
+ n === "local" && C.reparent(E), this._mesh = C, C._pullQuads = !0, C._quadRecords = this._records, C._quadRecordTexels = this._recordFloats >> 2, C._quadRecordRoll = this._recordRoll, C._quadRecordColor = this._recordColor, C._setInstanceBounds(this._bounds);
852
+ } catch (C) {
853
+ throw E?.destroy(), p?.destroy(), N.destroy(), C;
854
+ }
855
+ this.node = E, this._geometry = N, this._material = p, this._sortCamera = s.sortCamera, this._cleanup.push(t._own(() => this.destroy())), this._cleanup.push(t.onUpdate(this._onFrame)), s.autoPlay && this.play();
856
+ }
857
+ /** Emitter node: move it to move the emitter. */
858
+ node;
859
+ /**
860
+ * The instanced mesh drawing the particles.
861
+ * @internal
862
+ */
863
+ _mesh;
864
+ /** Fixed particle capacity. */
865
+ capacity;
866
+ space;
867
+ clock;
868
+ _geometry;
869
+ _material;
870
+ _cleanup = [];
871
+ _lease;
872
+ _destroyed = !1;
873
+ _state = _t;
874
+ _emitting = !1;
875
+ _count = 0;
876
+ _written = -1;
877
+ _time = 0;
878
+ _accumulator = 0;
879
+ _timeScale = 1;
880
+ _seed;
881
+ _random = 0;
882
+ _sortCamera = null;
883
+ // Settings.
884
+ _duration;
885
+ _loop;
886
+ _prewarm;
887
+ _shape;
888
+ /** radius, thickness, angle or arc, box size xyz, edge length. */
889
+ _shapeValues;
890
+ _randomize;
891
+ _rate;
892
+ /** Ranges as [min, max] pairs: lifetime, speed, size, rotation, angular velocity. */
893
+ _ranges;
894
+ _colorA;
895
+ _colorB;
896
+ _gravity;
897
+ _drag;
898
+ _speedCurve;
899
+ _velocityCurves;
900
+ _sizeCurve;
901
+ _colorCurve;
902
+ _alphaCurve;
903
+ _rotates;
904
+ /** A colour or alpha curve: the colour of a particle changes over its life. */
905
+ _colorVaries;
906
+ /** An angular velocity: the roll of a particle changes over its life. */
907
+ _spins;
908
+ /** Burst columns: time, count min, count max, cycles, interval, probability. */
909
+ _bursts;
910
+ _burstFired;
911
+ // Particle storage, structure of arrays.
912
+ _position;
913
+ _velocity;
914
+ _age;
915
+ _inverseLife;
916
+ _size;
917
+ _angle;
918
+ _spin;
919
+ _color;
920
+ /** Animated atlas: first frame offset per particle; null when static. */
921
+ _frameOffset;
922
+ _frames;
923
+ /** Mesh-space union of the written particle boxes (min xyz, max xyz). */
924
+ _bounds = new Float64Array(6);
925
+ /** Instance matrices written beside the poses. */
926
+ _matrices;
927
+ /** WebGL only: compact quad records the renderer uploads instead of matrices (see InstancedMesh._quadRecords). */
928
+ _records;
929
+ /** Floats per record: centre and scale, the roll texel (`_recordRoll`), the colour texel (no `_recordColor`). */
930
+ _recordFloats;
931
+ /** Records carry a roll and frame texel: rotating or animated systems. */
932
+ _recordRoll;
933
+ /** Linear colour shared by every particle (one start colour, no colour or alpha curve); records then omit colour. */
934
+ _recordColor;
935
+ /**
936
+ * The life-independent record fields (scale, roll and colour that never change over a
937
+ * particle's life) sit at the particle's own slot: spawns write them and swap-removals move
938
+ * them, so an unsorted write refreshes only what changes. A sorted write breaks this.
939
+ */
940
+ _aligned = !0;
941
+ /** Test hook: false forces the generic integration step and the full record write. @internal */
942
+ _specialised = !0;
943
+ /** Sort order of the last write (null: unsorted); lazy poses follow it. */
944
+ _writtenOrder = null;
945
+ /**
946
+ * Only centres change and one size gives one box reach: the last integration step of an
947
+ * unsorted update can copy centres and their bounds itself (`_fusing`), leaving `_write`
948
+ * nothing per particle (`_fused`).
949
+ */
950
+ _fusable;
951
+ _fusing = !1;
952
+ _fused = !1;
953
+ /** Start frame, frame count, frames per unit life (cycles mode) or per second, rate mode flag, random start. */
954
+ _sheet;
955
+ // Upload staging and sorting.
956
+ _poses;
957
+ _colors;
958
+ _depth;
959
+ _depthBits;
960
+ _keys;
961
+ _order;
962
+ _histogram;
963
+ // Per-update frame state.
964
+ /** Local gravity, emitter translation now and at the previous update. */
965
+ _frame = new Float64Array(9);
966
+ _hasPrevious = !1;
967
+ _updateLength = 0;
968
+ _untilEnd = 0;
969
+ _sample = new Float64Array(6);
970
+ _onFrame = (t) => {
971
+ if (!this._destroyed) {
972
+ if (this.node.destroyed || this.node.scene.destroyed) {
973
+ this.destroy();
974
+ return;
975
+ }
976
+ this.clock === "app" && this._state === it && this._advance(Math.min(t.deltaTime, ue) * this._timeScale);
977
+ }
978
+ };
979
+ /** Live particles. */
980
+ get count() {
981
+ return this._count;
982
+ }
983
+ /** Resolves to `count`; the GPU system reads its count back from the GPU, this one has it at once. */
984
+ readCount() {
985
+ return this._assertAlive(), Promise.resolve(this._count);
986
+ }
987
+ /** Seconds into the current emission cycle. */
988
+ get time() {
989
+ return this._time;
990
+ }
991
+ get playing() {
992
+ return this._state === it;
993
+ }
994
+ get paused() {
995
+ return this._state === Mt;
996
+ }
997
+ /** Whether the emitter still emits; false after `stop` or the end of a non-looping cycle. */
998
+ get emitting() {
999
+ return this._emitting;
1000
+ }
1001
+ /** GPU bytes of the per-particle instance data uploaded for drawing. */
1002
+ get gpuBytes() {
1003
+ const t = this._records ? this._recordFloats : 20 + (this._frames ? 1 : 0);
1004
+ return this.capacity * t * 4;
1005
+ }
1006
+ /** Draw order within the blended group; see `Nova3DMesh.renderOrder`. */
1007
+ get renderOrder() {
1008
+ return this._mesh.renderOrder;
1009
+ }
1010
+ setRenderOrder(t) {
1011
+ this._assertAlive(), this._mesh.setRenderOrder(t);
1012
+ }
1013
+ /** Layer bit mask; see `Nova3DMesh.layers`. */
1014
+ get layers() {
1015
+ return this._mesh.layers;
1016
+ }
1017
+ setLayers(t) {
1018
+ this._assertAlive(), this._mesh.setLayers(It(t));
1019
+ }
1020
+ get timeScale() {
1021
+ return this._timeScale;
1022
+ }
1023
+ get destroyed() {
1024
+ return this._destroyed;
1025
+ }
1026
+ /** Sets the multiplier of every clock advance, in [0, 1e6]. */
1027
+ setTimeScale(t) {
1028
+ this._assertAlive(), this._timeScale = Y(t, "timeScale", 0, 1e6);
1029
+ }
1030
+ /** Sorts back to front along this camera's view direction, or turns sorting off. */
1031
+ setSortCamera(t) {
1032
+ this._assertAlive(), t !== null && Ft(t, this.node.scene), this._sortCamera = t, this._write();
1033
+ }
1034
+ /**
1035
+ * Starts a stopped system from cycle time 0 (prewarmed when configured), resumes a
1036
+ * paused one, and restarts emission after `stop` without clearing.
1037
+ */
1038
+ play() {
1039
+ if (this._assertAlive(), this._state === Mt && (this._state = it, this._hasPrevious = !1, this._emitting || this._count > 0)) {
1040
+ this._syncLease();
1041
+ return;
1042
+ }
1043
+ if (this._emitting && this._state === it)
1044
+ return;
1045
+ const t = this._state === _t;
1046
+ this._hasPrevious = !1, this._time = 0, this._accumulator = 0, this._burstFired.fill(0), this._emitting = !0, this._state = it, t && this._prewarm && this._prewarmCycle(), this._write(), this._syncLease();
1047
+ }
1048
+ /** Freezes simulation and emission until `play`. */
1049
+ pause() {
1050
+ this._assertAlive(), this._state === it && (this._state = Mt, this._syncLease());
1051
+ }
1052
+ /** Stops emitting; live particles finish their lives unless `clear` removes them now. */
1053
+ stop(t = !1) {
1054
+ if (this._assertAlive(), typeof t != "boolean")
1055
+ throw new g("invalid-option", "[Nova3D] stop(clear) takes a boolean.");
1056
+ this._emitting = !1, t ? (this._count = 0, this._state = _t, this._hasPrevious = !1, this._write()) : this._count === 0 && (this._state = _t), this._syncLease();
1057
+ }
1058
+ /** Clears, rewinds the random stream to the seed and plays again. */
1059
+ restart() {
1060
+ this._assertAlive(), this.stop(!0), this._random = this._seed, this.play();
1061
+ }
1062
+ /** Emits `count` particles now, whatever the emission state; a stopped system starts simulating. */
1063
+ emitBurst(t) {
1064
+ if (this._assertAlive(), !Number.isSafeInteger(t) || t < 0)
1065
+ throw new g("invalid-option", "[Nova3D] Burst count must be a non-negative integer.");
1066
+ this._state === _t && (this._state = it), this._readFrame(), this._updateLength = 0, this._untilEnd = 0;
1067
+ for (let e = 0; e < t && this._count < this.capacity; e++)
1068
+ this._spawn(0);
1069
+ this._write(), this._syncLease();
1070
+ }
1071
+ /** Advances a manual-clock system by `deltaTime` seconds (scaled by timeScale). */
1072
+ update(t) {
1073
+ if (this._assertAlive(), this.clock !== "manual")
1074
+ throw new g("state", "[Nova3D] update is only available with manual clock.");
1075
+ Y(t, "deltaTime", 0, 1e6), this._state === it && this._advance(t * this._timeScale);
1076
+ }
1077
+ /** Releases the node, mesh, geometry and material; a user texture is kept. */
1078
+ destroy() {
1079
+ if (this._destroyed)
1080
+ return;
1081
+ this._destroyed = !0, this._lease?.release(), this._lease = void 0;
1082
+ for (const e of this._cleanup.splice(0))
1083
+ e();
1084
+ const t = !this.node.scene.destroyed;
1085
+ t && !this._mesh.destroyed && this._mesh.destroy(), t && !this.node.destroyed && this.node.destroy(), this._material.destroyed || this._material.destroy(), this._geometry.destroyed || this._geometry.destroy();
1086
+ }
1087
+ /** Simulates `delta` seconds in equal steps of at most MAX_STEP and uploads once. */
1088
+ _advance(t) {
1089
+ if (t <= 0)
1090
+ return;
1091
+ this._readFrame();
1092
+ const e = Math.ceil(t / Dt), i = t / e;
1093
+ this._updateLength = t;
1094
+ const s = this._fusable && this._specialised && this._aligned && this._sortCamera === null;
1095
+ for (let r = 0; r < e; r++)
1096
+ this._untilEnd = (e - 1 - r) * i, this._fusing = s && r === e - 1, this._step(i);
1097
+ this._fusing = !1, this._fused = s, !this._emitting && this._count === 0 && (this._state = _t), this._write(), this._syncLease();
1098
+ }
1099
+ /** One integration step: age and move live particles, then emit for the step. */
1100
+ _step(t) {
1101
+ const e = this._position, i = this._velocity, s = this._age, r = this._inverseLife, n = this._angle, c = this._spin, a = this._frame, h = a[0] * t, l = a[1] * t, _ = a[2] * t, d = this._drag > 0 ? Math.exp(-this._drag * t) : 1, f = t * 0.5, v = this._speedCurve, u = this._velocityCurves, L = this._rotates;
1102
+ let M = this._count, w = 0;
1103
+ if (typeof v == "number" && u === null && this._specialised) {
1104
+ const N = v !== 1 ? f * v : f, p = this._fusing ? this._records : null, E = this._recordFloats;
1105
+ let C = 1 / 0, U = 1 / 0, Z = 1 / 0, q = -1 / 0, G = -1 / 0, P = -1 / 0;
1106
+ for (; w < M; ) {
1107
+ if ((s[w] += t) * r[w] >= 1) {
1108
+ M--, w !== M && this._move(M, w);
1109
+ continue;
1110
+ }
1111
+ const I = w * 3, B = i[I], m = i[I + 1], S = i[I + 2], F = (B + h) * d, R = (m + l) * d, z = (S + _) * d;
1112
+ if (i[I] = F, i[I + 1] = R, i[I + 2] = z, e[I] += (B + F) * N, e[I + 1] += (m + R) * N, e[I + 2] += (S + z) * N, L && (n[w] += c[w] * t), p !== null) {
1113
+ const b = e[I], D = e[I + 1], y = e[I + 2], A = w * E;
1114
+ p[A] = b, p[A + 1] = D, p[A + 2] = y, b < C && (C = b), b > q && (q = b), D < U && (U = D), D > G && (G = D), y < Z && (Z = y), y > P && (P = y);
1115
+ }
1116
+ w++;
1117
+ }
1118
+ p !== null && rt(this._bounds, C, U, Z, q, G, P), this._count = M, this._emitting && this._emit(t);
1119
+ return;
1120
+ }
1121
+ for (; w < M; ) {
1122
+ const N = (s[w] += t) * r[w];
1123
+ if (N >= 1) {
1124
+ M--, w !== M && this._move(M, w);
1125
+ continue;
1126
+ }
1127
+ const p = w * 3, E = i[p], C = i[p + 1], U = i[p + 2], Z = (E + h) * d, q = (C + l) * d, G = (U + _) * d;
1128
+ i[p] = Z, i[p + 1] = q, i[p + 2] = G;
1129
+ let P = f;
1130
+ typeof v != "number" ? P *= wt(v, N) : v !== 1 && (P *= v), e[p] += (E + Z) * P, e[p + 1] += (C + q) * P, e[p + 2] += (U + G) * P, u !== null && (e[p] += J(u[0], N) * t, e[p + 1] += J(u[1], N) * t, e[p + 2] += J(u[2], N) * t), L && (n[w] += c[w] * t), w++;
1131
+ }
1132
+ this._count = M, this._emitting && this._emit(t);
1133
+ }
1134
+ /** Emits rate and bursts for the cycle window [time, time + step), wrapping loops. */
1135
+ _emit(t) {
1136
+ let e = this._time, i = t;
1137
+ for (; i > 0 && this._emitting; ) {
1138
+ const s = Math.min(i, this._duration - e), r = e + s, n = i - s, c = typeof this._rate == "number" ? this._rate : wt(this._rate, e / this._duration);
1139
+ if (c > 0) {
1140
+ const l = this._accumulator + c * s, _ = Math.floor(l + 1e-9);
1141
+ for (let d = 1; d <= _; d++)
1142
+ this._spawnAt((l - d) / c + n, t);
1143
+ this._accumulator = Math.max(0, l - _);
1144
+ }
1145
+ const a = this._bursts;
1146
+ for (let h = 0, l = 0; l < a.length; h++, l += 6) {
1147
+ const _ = a[l + 3];
1148
+ for (; this._burstFired[h] < _; ) {
1149
+ const d = a[l] + this._burstFired[h] * a[l + 4];
1150
+ if (d >= r && !(r >= this._duration && d <= this._duration))
1151
+ break;
1152
+ if (this._burstFired[h]++, a[l + 5] < 1 && this._next() >= a[l + 5])
1153
+ continue;
1154
+ const f = a[l + 1], v = f === a[l + 2] ? f : Math.floor(f + this._next() * (a[l + 2] - f + 1)), u = Math.max(0, r - d) + n;
1155
+ for (let L = 0; L < v; L++)
1156
+ this._spawnAt(u, t);
1157
+ }
1158
+ }
1159
+ i = n, e = r, e >= this._duration && (this._loop ? (e = 0, this._burstFired.fill(0)) : (e = this._duration, this._emitting = !1));
1160
+ }
1161
+ this._time = e;
1162
+ }
1163
+ /** Spawns one particle born `age` seconds before the end of a step of length `step`. */
1164
+ _spawnAt(t, e) {
1165
+ this._count < this.capacity && this._spawn(t < 0 ? 0 : t > e ? e : t);
1166
+ }
1167
+ /** Initializes the next free slot and integrates it over its `age`. */
1168
+ _spawn(t) {
1169
+ const e = this._count, i = this._range(0);
1170
+ if (t >= i)
1171
+ return;
1172
+ this._count++, this._shapeSample();
1173
+ const s = this._sample, r = this._range(2), n = e * 3;
1174
+ let c = s[0], a = s[1], h = s[2], l = s[3], _ = s[4], d = s[5];
1175
+ if (this.space === "world") {
1176
+ const m = Pt, S = m[0] * c + m[4] * a + m[8] * h + m[12], F = m[1] * c + m[5] * a + m[9] * h + m[13], R = m[2] * c + m[6] * a + m[10] * h + m[14], z = m[0] * l + m[4] * _ + m[8] * d, b = m[1] * l + m[5] * _ + m[9] * d, D = m[2] * l + m[6] * _ + m[10] * d, y = Math.hypot(z, b, D);
1177
+ y > 1e-12 && (l = z / y, _ = b / y, d = D / y);
1178
+ const A = this._updateLength > 0 ? (t + this._untilEnd) / this._updateLength : 0, T = this._frame;
1179
+ c = S + (T[3] - T[6]) * A, a = F + (T[4] - T[7]) * A, h = R + (T[5] - T[8]) * A;
1180
+ }
1181
+ const f = l * r, v = _ * r, u = d * r, L = this._frame, M = this._drag > 0 ? Math.exp(-this._drag * t) : 1, w = (f + L[0] * t) * M, N = (v + L[1] * t) * M, p = (u + L[2] * t) * M, E = t / i, C = t * 0.5 * J(this._speedCurve, E), U = this._position;
1182
+ U[n] = c + (f + w) * C, U[n + 1] = a + (v + N) * C, U[n + 2] = h + (u + p) * C, this._velocityCurves !== null && (U[n] += J(this._velocityCurves[0], E) * t, U[n + 1] += J(this._velocityCurves[1], E) * t, U[n + 2] += J(this._velocityCurves[2], E) * t);
1183
+ const Z = this._velocity;
1184
+ Z[n] = w, Z[n + 1] = N, Z[n + 2] = p, this._age[e] = t, this._inverseLife[e] = 1 / i, this._size[e] = this._range(4);
1185
+ const q = this._range(8);
1186
+ this._angle[e] = this._range(6) + q * t, this._spin[e] = q;
1187
+ const G = this._colorA === this._colorB ? 0 : this._next(), P = this._colorA, $ = this._colorB, I = this._color, B = e * 4;
1188
+ if (I[B] = P[0] + ($[0] - P[0]) * G, I[B + 1] = P[1] + ($[1] - P[1]) * G, I[B + 2] = P[2] + ($[2] - P[2]) * G, I[B + 3] = P[3] + ($[3] - P[3]) * G, this._frameOffset !== null && (this._frameOffset[e] = this._sheet[4] === 1 ? Math.floor(this._next() * this._sheet[1]) : 0), this._records !== null && (this._seedRecord(e), this._fusing)) {
1189
+ const m = this._records, S = e * this._recordFloats, F = this._bounds, R = U[n], z = U[n + 1], b = U[n + 2];
1190
+ m[S] = R, m[S + 1] = z, m[S + 2] = b, rt(F, Math.min(F[0], R), Math.min(F[1], z), Math.min(F[2], b), Math.max(F[3], R), Math.max(F[4], z), Math.max(F[5], b));
1191
+ }
1192
+ }
1193
+ /** Writes the life-independent record fields of particle `index` into its own slot. */
1194
+ _seedRecord(t) {
1195
+ const e = this._records, i = t * this._recordFloats, s = this._sizeCurve;
1196
+ if (typeof s == "number") {
1197
+ const r = this._size[t] * s;
1198
+ if (e[i + 3] = r, this._recordRoll && !this._spins) {
1199
+ let n = 0, c = 1;
1200
+ if (this._rotates) {
1201
+ const a = this._angle[t] * 0.5;
1202
+ n = Math.fround(Math.sin(a)), c = Math.fround(Math.cos(a));
1203
+ }
1204
+ e[i + 4] = (1 - n * (n + n)) * r, e[i + 5] = c * (n + n) * r;
1205
+ }
1206
+ }
1207
+ if (this._recordColor === null && !this._colorVaries) {
1208
+ const r = this._colorCurve, n = this._color, c = t * 4, a = i + this._recordFloats - 4;
1209
+ e[a] = Q(Math.fround(n[c] * r[0])), e[a + 1] = Q(Math.fround(n[c + 1] * r[1])), e[a + 2] = Q(Math.fround(n[c + 2] * r[2])), e[a + 3] = n[c + 3] * r[3] * this._alphaCurve;
1210
+ }
1211
+ }
1212
+ /** Linear record colour of the single start colour without curves, as the per-particle path rounds it. */
1213
+ _sharedColor() {
1214
+ const t = this._colorA, e = this._colorCurve, i = new Float32Array(4);
1215
+ return i[0] = Q(Math.fround(Math.fround(t[0]) * e[0])), i[1] = Q(Math.fround(Math.fround(t[1]) * e[1])), i[2] = Q(Math.fround(Math.fround(t[2]) * e[2])), i[3] = Math.fround(t[3]) * e[3] * this._alphaCurve, i;
1216
+ }
1217
+ /** Writes a shape position and unit direction into `_sample`. */
1218
+ _shapeSample() {
1219
+ const t = this._sample, e = this._shapeValues;
1220
+ let i = 0, s = 0, r = 0, n = 0, c = 1, a = 0;
1221
+ switch (this._shape) {
1222
+ case 0:
1223
+ this._unit(), n = t[3], c = t[4], a = t[5];
1224
+ break;
1225
+ case 1:
1226
+ case 2: {
1227
+ this._unit(), n = t[3], c = this._shape === 2 ? Math.abs(t[4]) : t[4], a = t[5];
1228
+ const l = (1 - e[1]) ** 3, _ = e[0] * Math.cbrt(l + (1 - l) * this._next());
1229
+ i = n * _, s = c * _, r = a * _;
1230
+ break;
1231
+ }
1232
+ case 3: {
1233
+ const l = e[2], _ = this._next() * Math.PI * 2, d = Math.cos(_), f = Math.sin(_);
1234
+ let v;
1235
+ if (e[0] > 0) {
1236
+ const L = (1 - e[1]) ** 2, M = Math.sqrt(L + (1 - L) * this._next());
1237
+ i = d * e[0] * M, r = f * e[0] * M, v = l * M;
1238
+ } else
1239
+ v = Math.acos(1 - this._next() * (1 - Math.cos(l)));
1240
+ const u = Math.sin(v);
1241
+ n = d * u, c = Math.cos(v), a = f * u;
1242
+ break;
1243
+ }
1244
+ case 4:
1245
+ i = (this._next() - 0.5) * e[3], s = (this._next() - 0.5) * e[4], r = (this._next() - 0.5) * e[5];
1246
+ break;
1247
+ case 5: {
1248
+ const l = (1 - e[1]) ** 2, _ = e[0] * Math.sqrt(l + (1 - l) * this._next()), d = this._next() * e[2];
1249
+ n = Math.cos(d), c = 0, a = Math.sin(d), i = n * _, r = a * _;
1250
+ break;
1251
+ }
1252
+ default:
1253
+ i = (this._next() - 0.5) * e[0];
1254
+ }
1255
+ const h = this._randomize;
1256
+ if (h > 0) {
1257
+ this._unit();
1258
+ const l = n + (t[3] - n) * h, _ = c + (t[4] - c) * h, d = a + (t[5] - a) * h, f = Math.hypot(l, _, d);
1259
+ f > 1e-9 && (n = l / f, c = _ / f, a = d / f);
1260
+ }
1261
+ t[0] = i, t[1] = s, t[2] = r, t[3] = n, t[4] = c, t[5] = a;
1262
+ }
1263
+ /** Uniform random unit vector into `_sample[3..5]`. */
1264
+ _unit() {
1265
+ const t = this._sample, e = this._next() * 2 - 1, i = this._next() * Math.PI * 2, s = Math.sqrt(1 - e * e);
1266
+ t[3] = s * Math.cos(i), t[4] = e, t[5] = s * Math.sin(i);
1267
+ }
1268
+ /** Uniform sample of range `slot` (pair offset). */
1269
+ _range(t) {
1270
+ const e = this._ranges[t], i = this._ranges[t + 1];
1271
+ return e === i ? e : e + (i - e) * this._next();
1272
+ }
1273
+ /** Mulberry32: deterministic uniform number in [0, 1). */
1274
+ _next() {
1275
+ let t = this._random = this._random + 1831565813 >>> 0;
1276
+ return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
1277
+ }
1278
+ /** Swap-removes: moves particle `from` into slot `to`. */
1279
+ _move(t, e) {
1280
+ const i = t * 3, s = e * 3, r = this._position, n = this._velocity;
1281
+ r[s] = r[i], r[s + 1] = r[i + 1], r[s + 2] = r[i + 2], n[s] = n[i], n[s + 1] = n[i + 1], n[s + 2] = n[i + 2], this._age[e] = this._age[t], this._inverseLife[e] = this._inverseLife[t], this._size[e] = this._size[t], this._angle[e] = this._angle[t], this._spin[e] = this._spin[t];
1282
+ const c = this._color, a = t * 4, h = e * 4;
1283
+ c[h] = c[a], c[h + 1] = c[a + 1], c[h + 2] = c[a + 2], c[h + 3] = c[a + 3], this._frameOffset !== null && (this._frameOffset[e] = this._frameOffset[t]);
1284
+ const l = this._records;
1285
+ if (l !== null) {
1286
+ const _ = this._recordFloats;
1287
+ for (let d = t * _, f = e * _, v = f + _; f < v; d++, f++)
1288
+ l[f] = l[d];
1289
+ }
1290
+ }
1291
+ /** Reads the emitter world frame: local gravity and translation history. */
1292
+ _readFrame() {
1293
+ const t = this._frame, e = this.node.getWorldMatrix(Pt);
1294
+ this._hasPrevious ? (t[3] = t[6], t[4] = t[7], t[5] = t[8]) : (t[3] = e[12], t[4] = e[13], t[5] = e[14]), t[6] = e[12], t[7] = e[13], t[8] = e[14], this._hasPrevious = !0;
1295
+ const i = this._gravity;
1296
+ if (this.space === "world") {
1297
+ t[0] = i[0], t[1] = i[1], t[2] = i[2];
1298
+ return;
1299
+ }
1300
+ if (Tt(yt, e), !Ot(yt, yt)) {
1301
+ t[0] = t[1] = t[2] = 0;
1302
+ return;
1303
+ }
1304
+ const s = yt;
1305
+ t[0] = s[0] * i[0] + s[3] * i[1] + s[6] * i[2], t[1] = s[1] * i[0] + s[4] * i[1] + s[7] * i[2], t[2] = s[2] * i[0] + s[5] * i[1] + s[8] * i[2];
1306
+ }
1307
+ /** Uploads the live prefix, sorted when a camera is set: WebGL records or WebGPU poses and colours. */
1308
+ _write() {
1309
+ const t = this._count, e = this._fused;
1310
+ if (this._fused = !1, t === 0 && this._written === 0)
1311
+ return;
1312
+ const i = this._sortOrder(t);
1313
+ if (this._records === null)
1314
+ this._writeOwned(t, i);
1315
+ else {
1316
+ if (e && i === null) {
1317
+ const s = Math.abs(Math.fround(this._ranges[4]) * this._sizeCurve) * H, r = s * Math.SQRT2, n = this._bounds;
1318
+ rt(n, n[0] - r, n[1] - r, n[2] - s, n[3] + r, n[4] + r, n[5] + s);
1319
+ } else i === null && this._aligned && this._specialised ? this._writeChanging(t) : this._writeRecords(t, i);
1320
+ this._writtenOrder = i, this._mesh.setCount(t), this._mesh._writeRecords(t, this._poseSource);
1321
+ }
1322
+ this._written = t;
1323
+ }
1324
+ /**
1325
+ * Full record write of every live particle in draw order: the reference of the
1326
+ * specialised unsorted write, and the sorted path.
1327
+ */
1328
+ _writeRecords(t, e) {
1329
+ const i = this._records, s = this._recordFloats, r = this._recordRoll, n = this._recordColor === null ? s - 4 : -1, c = this.capacity, a = this._position, h = this._size, l = this._angle, _ = this._color, d = this._age, f = this._inverseLife, v = this._sizeCurve, u = this._colorCurve, L = this._alphaCurve, M = this._rotates, w = this._frameOffset, N = this._sheet;
1330
+ let p = 1 / 0, E = 1 / 0, C = 1 / 0, U = -1 / 0, Z = -1 / 0, q = -1 / 0;
1331
+ for (let G = 0; G < t; G++) {
1332
+ const P = e === null ? G : e[c + G], $ = d[P] * f[P], I = P * 3, B = G * s, m = a[I], S = a[I + 1], F = a[I + 2];
1333
+ i[B] = m, i[B + 1] = S, i[B + 2] = F;
1334
+ const R = h[P] * J(v, $);
1335
+ if (i[B + 3] = R, r) {
1336
+ let D = 0, y = 1;
1337
+ if (M) {
1338
+ const k = l[P] * 0.5;
1339
+ D = Math.fround(Math.sin(k)), y = Math.fround(Math.cos(k));
1340
+ }
1341
+ const A = D * (D + D), T = y * (D + D);
1342
+ i[B + 4] = (1 - A) * R, i[B + 5] = T * R, w !== null && (i[B + 6] = Nt(N, d[P], $, w[P]));
1343
+ }
1344
+ const z = Math.abs(R) * H, b = z * Math.SQRT2;
1345
+ if (m - b < p && (p = m - b), m + b > U && (U = m + b), S - b < E && (E = S - b), S + b > Z && (Z = S + b), F - z < C && (C = F - z), F + z > q && (q = F + z), n >= 0) {
1346
+ const D = P * 4;
1347
+ let y = _[D], A = _[D + 1], T = _[D + 2], k = _[D + 3];
1348
+ if (u instanceof Float32Array) {
1349
+ const V = ($ < 0 ? 0 : $ > 1 ? 1 : $) * xt, K = V | 0, W = V - K, x = K * 4;
1350
+ y *= u[x] + (u[x + 4] - u[x]) * W, A *= u[x + 1] + (u[x + 5] - u[x + 1]) * W, T *= u[x + 2] + (u[x + 6] - u[x + 2]) * W, k *= u[x + 3] + (u[x + 7] - u[x + 3]) * W;
1351
+ } else
1352
+ y *= u[0], A *= u[1], T *= u[2], k *= u[3];
1353
+ i[B + n] = Q(Math.fround(y)), i[B + n + 1] = Q(Math.fround(A)), i[B + n + 2] = Q(Math.fround(T)), i[B + n + 3] = k * J(L, $);
1354
+ }
1355
+ }
1356
+ rt(this._bounds, p, E, C, U, Z, q), this._aligned = e === null;
1357
+ }
1358
+ /**
1359
+ * Unsorted write of what changes over life: centres always, then scale, roll, frame and
1360
+ * colour only when a curve, a rotation or an animated atlas drives them. The rest was
1361
+ * written at spawn and follows swap-removals (`_seedRecord`, `_move`). Same floats as
1362
+ * `_writeRecords`.
1363
+ */
1364
+ _writeChanging(t) {
1365
+ const e = this._records, i = this._recordFloats, s = this._position, r = this._size, n = this._sizeCurve, c = this._rotates, a = this._spins, h = this._frameOffset, l = this._recordColor === null && this._colorVaries, _ = this._bounds;
1366
+ if (typeof n == "number" && !a && h === null && !l) {
1367
+ let S = 1 / 0, F = 1 / 0, R = 1 / 0, z = -1 / 0, b = -1 / 0, D = -1 / 0;
1368
+ const y = this._ranges[4];
1369
+ if (y === this._ranges[5]) {
1370
+ for (let k = 0, V = 0, K = t * 3; k < K; k += 3, V += i) {
1371
+ const W = s[k], x = s[k + 1], X = s[k + 2];
1372
+ e[V] = W, e[V + 1] = x, e[V + 2] = X, W < S && (S = W), W > z && (z = W), x < F && (F = x), x > b && (b = x), X < R && (R = X), X > D && (D = X);
1373
+ }
1374
+ const A = t > 0 ? Math.abs(Math.fround(y) * n) * H : 0, T = A * Math.SQRT2;
1375
+ rt(_, S - T, F - T, R - A, z + T, b + T, D + A);
1376
+ return;
1377
+ }
1378
+ for (let A = 0, T = 0, k = 0; A < t; A++, T += 3, k += i) {
1379
+ const V = s[T], K = s[T + 1], W = s[T + 2];
1380
+ e[k] = V, e[k + 1] = K, e[k + 2] = W;
1381
+ const x = Math.abs(r[A] * n) * H, X = x * Math.SQRT2;
1382
+ V - X < S && (S = V - X), V + X > z && (z = V + X), K - X < F && (F = K - X), K + X > b && (b = K + X), W - x < R && (R = W - x), W + x > D && (D = W + x);
1383
+ }
1384
+ rt(_, S, F, R, z, b, D);
1385
+ return;
1386
+ }
1387
+ const d = this._angle, f = this._color, v = this._age, u = this._inverseLife, L = this._colorCurve, M = this._alphaCurve, w = this._sheet, N = typeof n == "number" ? null : n, p = typeof n == "number" ? n : 1, E = this._recordRoll && (a || N !== null), C = L instanceof Float32Array ? L : null, U = typeof M == "number" ? null : M, Z = typeof M == "number" ? M : 1, q = i - 4;
1388
+ let G = 1 / 0, P = 1 / 0, $ = 1 / 0, I = -1 / 0, B = -1 / 0, m = -1 / 0;
1389
+ for (let S = 0; S < t; S++) {
1390
+ const F = v[S] * u[S], R = (F < 0 ? 0 : F > 1 ? 1 : F) * xt, z = R | 0, b = R - z, D = S * 3, y = S * i, A = s[D], T = s[D + 1], k = s[D + 2];
1391
+ e[y] = A, e[y + 1] = T, e[y + 2] = k;
1392
+ let V;
1393
+ if (N !== null) {
1394
+ const x = N[z];
1395
+ V = r[S] * (x + (N[z + 1] - x) * b), e[y + 3] = V;
1396
+ } else
1397
+ V = r[S] * p;
1398
+ if (E) {
1399
+ let x = 0, X = 1;
1400
+ if (c) {
1401
+ const et = d[S] * 0.5;
1402
+ x = Math.fround(Math.sin(et)), X = Math.fround(Math.cos(et));
1403
+ }
1404
+ const tt = x * (x + x), j = X * (x + x);
1405
+ e[y + 4] = (1 - tt) * V, e[y + 5] = j * V;
1406
+ }
1407
+ if (h !== null) {
1408
+ const x = w[3] === 1 ? v[S] * w[2] : (F < 0 ? 0 : F >= 1 ? 0.999999 : F) * w[2];
1409
+ e[y + 6] = w[0] + (Math.floor(x) + h[S]) % w[1];
1410
+ }
1411
+ const K = Math.abs(V) * H, W = K * Math.SQRT2;
1412
+ if (A - W < G && (G = A - W), A + W > I && (I = A + W), T - W < P && (P = T - W), T + W > B && (B = T + W), k - K < $ && ($ = k - K), k + K > m && (m = k + K), l) {
1413
+ const x = S * 4;
1414
+ let X = f[x], tt = f[x + 1], j = f[x + 2], et = f[x + 3];
1415
+ if (C !== null) {
1416
+ const O = z * 4;
1417
+ X *= C[O] + (C[O + 4] - C[O]) * b, tt *= C[O + 1] + (C[O + 5] - C[O + 1]) * b, j *= C[O + 2] + (C[O + 6] - C[O + 2]) * b, et *= C[O + 3] + (C[O + 7] - C[O + 3]) * b;
1418
+ } else {
1419
+ const O = L;
1420
+ X *= O[0], tt *= O[1], j *= O[2], et *= O[3];
1421
+ }
1422
+ let ot = Z;
1423
+ if (U !== null) {
1424
+ const O = U[z];
1425
+ ot = O + (U[z + 1] - O) * b;
1426
+ }
1427
+ e[y + q] = Q(Math.fround(X)), e[y + q + 1] = Q(Math.fround(tt)), e[y + q + 2] = Q(Math.fround(j)), e[y + q + 3] = et * ot;
1428
+ }
1429
+ }
1430
+ rt(_, G, P, $, I, B, m);
1431
+ }
1432
+ /** Lazily derived mesh poses of the last records write. */
1433
+ _poseSource = () => {
1434
+ const t = this._poses;
1435
+ return this._writePoses(this._written, this._writtenOrder, t), t;
1436
+ };
1437
+ /** Packed poses (position, view-plane roll quaternion, uniform scale) in draw order. */
1438
+ _writePoses(t, e, i) {
1439
+ const s = this.capacity, r = this._position, n = this._size, c = this._angle, a = this._age, h = this._inverseLife, l = this._sizeCurve, _ = this._rotates;
1440
+ for (let d = 0; d < t; d++) {
1441
+ const f = e === null ? d : e[s + d], v = f * 3, u = d * 10;
1442
+ if (i[u] = r[v], i[u + 1] = r[v + 1], i[u + 2] = r[v + 2], i[u + 3] = 0, i[u + 4] = 0, _) {
1443
+ const M = c[f] * 0.5;
1444
+ i[u + 5] = Math.sin(M), i[u + 6] = Math.cos(M);
1445
+ } else
1446
+ i[u + 5] = 0, i[u + 6] = 1;
1447
+ const L = n[f] * J(l, a[f] * h[f]);
1448
+ i[u + 7] = L, i[u + 8] = L, i[u + 9] = L;
1449
+ }
1450
+ }
1451
+ /** WebGPU: poses, matrices, sRGB colours and frames through the mesh's owner path. */
1452
+ _writeOwned(t, e) {
1453
+ const i = this.capacity, s = this._poses, r = this._matrices, n = this._colors, c = this._position, a = this._size, h = this._angle, l = this._color, _ = this._age, d = this._inverseLife, f = this._sizeCurve, v = this._colorCurve, u = v instanceof Float32Array ? v : null, L = this._alphaCurve, M = this._rotates, w = this._frames, N = this._frameOffset, p = this._sheet;
1454
+ let E = 1 / 0, C = 1 / 0, U = 1 / 0, Z = -1 / 0, q = -1 / 0, G = -1 / 0;
1455
+ for (let P = 0; P < t; P++) {
1456
+ const $ = e === null ? P : e[i + P], I = _[$] * d[$], B = $ * 3, m = P * 10, S = c[B], F = c[B + 1], R = c[B + 2];
1457
+ if (s[m] = S, s[m + 1] = F, s[m + 2] = R, s[m + 3] = 0, s[m + 4] = 0, M) {
1458
+ const j = h[$] * 0.5;
1459
+ s[m + 5] = Math.sin(j), s[m + 6] = Math.cos(j);
1460
+ } else
1461
+ s[m + 5] = 0, s[m + 6] = 1;
1462
+ const z = a[$] * J(f, I);
1463
+ s[m + 7] = z, s[m + 8] = z, s[m + 9] = z;
1464
+ const b = s[m + 5], D = b * (b + b), y = s[m + 6] * (b + b), A = P * 16;
1465
+ r[A] = (1 - D) * z, r[A + 1] = y * z, r[A + 2] = 0, r[A + 3] = 0, r[A + 4] = -y * z, r[A + 5] = (1 - D) * z, r[A + 6] = 0, r[A + 7] = 0, r[A + 8] = 0, r[A + 9] = 0, r[A + 10] = z, r[A + 11] = 0, r[A + 12] = S, r[A + 13] = F, r[A + 14] = R, r[A + 15] = 1;
1466
+ const T = Math.abs(z) * H, k = T * Math.SQRT2;
1467
+ S - k < E && (E = S - k), S + k > Z && (Z = S + k), F - k < C && (C = F - k), F + k > q && (q = F + k), R - T < U && (U = R - T), R + T > G && (G = R + T);
1468
+ const V = $ * 4, K = P * 4;
1469
+ let W = l[V], x = l[V + 1], X = l[V + 2], tt = l[V + 3];
1470
+ if (u !== null) {
1471
+ const j = (I < 0 ? 0 : I > 1 ? 1 : I) * xt, et = j | 0, ot = j - et, O = et * 4;
1472
+ W *= u[O] + (u[O + 4] - u[O]) * ot, x *= u[O + 1] + (u[O + 5] - u[O + 1]) * ot, X *= u[O + 2] + (u[O + 6] - u[O + 2]) * ot, tt *= u[O + 3] + (u[O + 7] - u[O + 3]) * ot;
1473
+ } else {
1474
+ const j = v;
1475
+ W *= j[0], x *= j[1], X *= j[2], tt *= j[3];
1476
+ }
1477
+ n[K] = W, n[K + 1] = x, n[K + 2] = X, n[K + 3] = tt * J(L, I), w !== null && (w[P] = Nt(p, _[$], I, N[$]));
1478
+ }
1479
+ rt(this._bounds, E, C, U, Z, q, G), this._mesh.setCount(t), t > 0 && (this._mesh._writeOwned(t, s, r, n), w !== null && this._mesh.updateFrames(0, w, t));
1480
+ }
1481
+ /** Back-to-front order by view depth, or null when sorting is off. */
1482
+ _sortOrder(t) {
1483
+ const e = this._sortCamera;
1484
+ if (e === null || t < 2)
1485
+ return null;
1486
+ if (e.destroyed)
1487
+ return this._sortCamera = null, null;
1488
+ const i = e.getWorldMatrix(me);
1489
+ let s = -i[8], r = -i[9], n = -i[10];
1490
+ if (this.space === "local") {
1491
+ const h = this.node.getWorldMatrix(Pt), l = h[0] * s + h[1] * r + h[2] * n, _ = h[4] * s + h[5] * r + h[6] * n, d = h[8] * s + h[9] * r + h[10] * n;
1492
+ s = l, r = _, n = d;
1493
+ }
1494
+ if (!this._depth) {
1495
+ const h = new ArrayBuffer(this.capacity * 4);
1496
+ this._depth = new Float32Array(h), this._depthBits = new Uint32Array(h), this._keys = new Uint32Array(this.capacity * 2), this._order = new Uint32Array(this.capacity * 2), this._histogram = new Uint32Array(3 * 2048);
1497
+ }
1498
+ const c = this._depth, a = this._position;
1499
+ for (let h = 0; h < t; h++) {
1500
+ const l = h * 3;
1501
+ c[h] = a[l] * s + a[l + 1] * r + a[l + 2] * n;
1502
+ }
1503
+ return ye(t, this._depthBits, this._keys, this._order, this._histogram), this._order;
1504
+ }
1505
+ /** Holds the app loop lease exactly while an app-clock system is playing. */
1506
+ _syncLease() {
1507
+ !this._destroyed && this.clock === "app" && this._state === it ? this._lease ??= this._app._acquireLoop("nova3d.particles") : (this._lease?.release(), this._lease = void 0);
1508
+ }
1509
+ /** Simulates the tail of one previous cycle so the system starts in steady state. */
1510
+ _prewarmCycle() {
1511
+ const t = this._ranges[1], e = ((this._duration - t) % this._duration + this._duration) % this._duration;
1512
+ this._time = e, this._burstFired.fill(0);
1513
+ for (let r = 0, n = 0; n < this._bursts.length; r++, n += 6) {
1514
+ let c = 0;
1515
+ for (; c < this._bursts[n + 3] && this._bursts[n] + c * this._bursts[n + 4] < e; )
1516
+ c++;
1517
+ this._burstFired[r] = c;
1518
+ }
1519
+ this._readFrame();
1520
+ const i = Math.ceil(t / Dt), s = t / i;
1521
+ this._updateLength = 0, this._untilEnd = 0;
1522
+ for (let r = 0; r < i; r++)
1523
+ this._step(s);
1524
+ }
1525
+ _assertAlive() {
1526
+ if (this._destroyed)
1527
+ throw new g("destroyed", "[Nova3D] Particle system is destroyed.");
1528
+ }
1529
+ }
1530
+ function J(o, t) {
1531
+ return typeof o == "number" ? o : wt(o, t);
1532
+ }
1533
+ function Nt(o, t, e, i) {
1534
+ const s = o[3] === 1 ? t * o[2] : (e < 0 ? 0 : e >= 1 ? 0.999999 : e) * o[2];
1535
+ return o[0] + (Math.floor(s) + i) % o[1];
1536
+ }
1537
+ function rt(o, t, e, i, s, r, n) {
1538
+ o[0] = t, o[1] = e, o[2] = i, o[3] = s, o[4] = r, o[5] = n;
1539
+ }
1540
+ function ye(o, t, e, i, s) {
1541
+ const r = e.length >> 1;
1542
+ s.fill(0);
1543
+ for (let a = 0; a < o; a++) {
1544
+ const h = t[a], l = ~(h & 2147483648 ? ~h : h | 2147483648) >>> 0;
1545
+ e[a] = l, i[a] = a, s[l & 2047]++, s[2048 + (l >>> 11 & 2047)]++, s[4096 + (l >>> 22)]++;
1546
+ }
1547
+ for (let a = 0; a < 3; a++) {
1548
+ let h = 0;
1549
+ for (let l = a * 2048, _ = l + 2048; l < _; l++) {
1550
+ const d = s[l];
1551
+ s[l] = h, h += d;
1552
+ }
1553
+ }
1554
+ let n = 0, c = r;
1555
+ for (let a = 0, h = 0; a < 3; a++, h += 11) {
1556
+ const l = a * 2048;
1557
+ for (let d = 0; d < o; d++) {
1558
+ const f = e[n + d], v = s[l + (f >>> h & 2047)]++;
1559
+ e[c + v] = f, i[c + v] = i[n + d];
1560
+ }
1561
+ const _ = n;
1562
+ n = c, c = _;
1563
+ }
1564
+ }
1565
+ function Pe(o, t) {
1566
+ return new pe(Rt(o), o, t);
1567
+ }
1568
+ export {
1569
+ ne as MAX_GPU_PARTICLES,
1570
+ le as Nova3DGPUParticleSystem,
1571
+ pe as Nova3DParticleSystem,
1572
+ Me as createGPUParticleSystem,
1573
+ Pe as createParticleSystem
1574
+ };