@nova-lab/core 1.0.0-dev.19 → 1.1.1-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 +229 -4
@@ -0,0 +1,1406 @@
1
+ import { N, p as lt, w as at } from "../Errors-B2ekO9bZ.js";
2
+ import { a as K, c as it, e as W, l as nt, d as pt, f as Nt, g as ct, p as St, h as Pt } from "../LoaderIO-BwrM84OM.js";
3
+ import { M as Bt, N as Et, t as Vt, l as Ht } from "../TextureLoader-CfDzdy2m.js";
4
+ import { t as Zt } from "../Texture-dTKMlTpK.js";
5
+ import { c as ht, o as j } from "../Options-CajE7LLJ.js";
6
+ import { i as $t } from "../Node-QfgAE2_v.js";
7
+ import { l as wt } from "../Color-vuv9UnoY.js";
8
+ function L(s) {
9
+ throw new N(lt(s), `[Nova3D] EXR ${s}.`);
10
+ }
11
+ function Rt(s) {
12
+ const t = s.length;
13
+ for (let i = 1; i < t; i++)
14
+ s[i] = s[i - 1] + s[i] - 128;
15
+ const n = new Uint8Array(t);
16
+ let e = 0, o = t + 1 >> 1;
17
+ for (let i = 0; i < t; )
18
+ n[i++] = s[e++], i < t && (n[i++] = s[o++]);
19
+ return n;
20
+ }
21
+ async function Tt(s, t) {
22
+ if (typeof DecompressionStream > "u")
23
+ throw new N("unsupported", "[Nova3D] EXR ZIP/PXR24 decoding requires DecompressionStream.");
24
+ const e = new ReadableStream({
25
+ start(r) {
26
+ r.enqueue(s), r.close();
27
+ }
28
+ }).pipeThrough(new DecompressionStream("deflate")).getReader(), o = new Uint8Array(t);
29
+ let i = 0;
30
+ try {
31
+ for (; ; ) {
32
+ const r = await e.read();
33
+ if (r.done)
34
+ break;
35
+ r.value.byteLength > t - i && L("block inflates past its size"), o.set(r.value, i), i += r.value.byteLength;
36
+ }
37
+ } catch (r) {
38
+ if (await e.cancel().catch(() => {
39
+ }), r instanceof N)
40
+ throw r;
41
+ L("block has corrupt zlib data");
42
+ }
43
+ return i !== t && L("block inflates short of its size"), o;
44
+ }
45
+ async function Yt(s, t) {
46
+ return Rt(await Tt(s, t));
47
+ }
48
+ function Xt(s, t) {
49
+ const n = new Uint8Array(t);
50
+ let e = 0, o = 0;
51
+ for (; e < s.length; ) {
52
+ const i = s[e++] << 24 >> 24;
53
+ i < 0 ? ((e - i > s.length || o - i > t) && L("RLE literal overflows"), n.set(s.subarray(e, e - i), o), e -= i, o -= i) : ((e >= s.length || o + i + 1 > t) && L("RLE run overflows"), n.fill(s[e++], o, o + i + 1), o += i + 1);
54
+ }
55
+ return o !== t && L("RLE block is short"), Rt(n);
56
+ }
57
+ async function Jt(s, t, n, e, o) {
58
+ let i = 0;
59
+ for (const u of e)
60
+ i += t * (u === 1 ? 2 : u === 2 ? 3 : 4);
61
+ const r = await Tt(s, i * n), a = new Uint8Array(o), m = new DataView(a.buffer);
62
+ let c = 0, h = 0;
63
+ for (let u = 0; u < n; u++)
64
+ for (const l of e)
65
+ if (l === 1) {
66
+ const f = c, p = f + t;
67
+ c = p + t;
68
+ let d = 0;
69
+ for (let g = 0; g < t; g++)
70
+ d = d + (r[f + g] << 8 | r[p + g]) & 65535, m.setUint16(h, d, !0), h += 2;
71
+ } else {
72
+ const f = c, p = f + t, d = p + t, g = d + t;
73
+ c = l === 2 ? g : g + t;
74
+ let y = 0;
75
+ for (let v = 0; v < t; v++) {
76
+ const b = l === 2 ? r[f + v] << 24 | r[p + v] << 16 | r[d + v] << 8 : r[f + v] << 24 | r[p + v] << 16 | r[d + v] << 8 | r[g + v];
77
+ y = y + b >>> 0, m.setUint32(h, y, !0), h += 4;
78
+ }
79
+ }
80
+ return a;
81
+ }
82
+ const rt = 65537, tt = 14, vt = 1 << tt, At = vt - 1, bt = 59, xt = 63, Kt = 2 + xt - bt, It = 8192, Wt = 24;
83
+ function Gt(s, t, n, e, o, i) {
84
+ let r = t, a = 0, m = 0;
85
+ const c = (l) => {
86
+ for (; m < l; )
87
+ r >= n && L("PIZ Huffman table is truncated"), a = (a << 8 | s[r++]) & 16777215, m += 8;
88
+ return m -= l, a >> m & (1 << l) - 1;
89
+ };
90
+ for (let l = e; l <= o; l++) {
91
+ const f = c(6);
92
+ if (f === xt || f >= bt) {
93
+ const p = f === xt ? c(8) + Kt : f - bt + 2;
94
+ l + p > o + 1 && L("PIZ Huffman table run overflows"), i.fill(0, l, l + p), l += p - 1;
95
+ } else
96
+ f > Wt && L("PIZ Huffman code is longer than 24 bits"), i[l] = f;
97
+ }
98
+ const h = new Float64Array(59);
99
+ for (let l = 0; l < rt; l++)
100
+ h[i[l]]++;
101
+ let u = 0;
102
+ for (let l = 58; l > 0; l--) {
103
+ const f = Math.floor((u + h[l]) / 2);
104
+ h[l] = u, u = f;
105
+ }
106
+ for (let l = 0; l < rt; l++) {
107
+ const f = i[l];
108
+ f > 0 && (i[l] = f | h[f]++ << 6);
109
+ }
110
+ return r;
111
+ }
112
+ function qt(s, t, n, e, o) {
113
+ (n < 20 || t + n > s.length) && L("PIZ Huffman block is truncated");
114
+ const i = new DataView(s.buffer, s.byteOffset, s.byteLength), r = i.getUint32(t, !0), a = i.getUint32(t + 4, !0), m = i.getUint32(t + 12, !0), c = t + n;
115
+ (r >= rt || a >= rt || r > a) && L("PIZ Huffman table range is invalid");
116
+ const h = new Int32Array(rt);
117
+ let u = Gt(s, t + 20, c, r, a, h);
118
+ m > 8 * (c - u) && L("PIZ Huffman bit count exceeds its data");
119
+ const l = new Uint8Array(vt), f = new Int32Array(vt), p = [];
120
+ for (let A = r; A <= a; A++) {
121
+ const k = h[A] & 63, P = h[A] >>> 6;
122
+ if (k !== 0)
123
+ if (P >>> k && L("PIZ Huffman table entry is invalid"), k > tt) {
124
+ const _ = P >>> k - tt;
125
+ l[_] && L("PIZ Huffman table entry is invalid"), (p[_] ??= []).push(A);
126
+ } else {
127
+ const _ = P << tt - k;
128
+ for (let M = 0; M < 1 << tt - k; M++)
129
+ (l[_ + M] || p[_ + M]) && L("PIZ Huffman table entry is invalid"), l[_ + M] = k, f[_ + M] = A;
130
+ }
131
+ }
132
+ const d = a;
133
+ let g = 0, y = 0, v = 0;
134
+ const b = u + Math.ceil(m / 8), w = (A) => {
135
+ if (A === d) {
136
+ y < 8 && (u >= b && L("PIZ Huffman run is truncated"), g = g << 8 | s[u++], y += 8), y -= 8;
137
+ const k = g >> y & 255;
138
+ (v === 0 || v + k > o) && L("PIZ Huffman run overflows"), e.fill(e[v - 1], v, v + k), v += k;
139
+ } else
140
+ v >= o && L("PIZ Huffman data overflows"), e[v++] = A;
141
+ };
142
+ for (; u < b; )
143
+ for (g = g << 8 | s[u++], y += 8; y >= tt; ) {
144
+ const A = g >> y - tt & At, k = l[A];
145
+ if (k) {
146
+ y -= k, w(f[A]);
147
+ continue;
148
+ }
149
+ const P = p[A];
150
+ P || L("PIZ Huffman code is invalid");
151
+ let _ = !1;
152
+ for (const M of P) {
153
+ const T = h[M] & 63;
154
+ for (; y < T && u < b; )
155
+ g = g << 8 | s[u++], y += 8;
156
+ if (y >= T && h[M] >>> 6 === (g >> y - T & (1 << T) - 1)) {
157
+ y -= T, w(M), _ = !0;
158
+ break;
159
+ }
160
+ }
161
+ _ || L("PIZ Huffman code is invalid");
162
+ }
163
+ const I = 8 - m & 7;
164
+ for (g >>= I, y -= I; y > 0; ) {
165
+ const A = g << tt - y & At, k = l[A];
166
+ (!k || k > y) && L("PIZ Huffman tail is invalid"), y -= k, w(f[A]);
167
+ }
168
+ v !== o && L("PIZ Huffman data is short");
169
+ }
170
+ let et = 0, st = 0;
171
+ function jt(s, t) {
172
+ const n = s << 16 >> 16, e = t << 16 >> 16, o = n + (e & 1) + (e >> 1);
173
+ et = o, st = o - e;
174
+ }
175
+ function Qt(s, t) {
176
+ const n = s & 65535, e = t & 65535, o = n - (e >> 1) & 65535;
177
+ et = e + o - 32768 & 65535, st = o;
178
+ }
179
+ function te(s, t, n, e, o, i, r) {
180
+ const a = r < 16384 ? jt : Qt, m = n > o ? o : n;
181
+ let c = 1;
182
+ for (; c <= m; )
183
+ c <<= 1;
184
+ c >>= 1;
185
+ let h = c;
186
+ for (c >>= 1; c >= 1; ) {
187
+ let u = 0;
188
+ const l = i * (o - h), f = i * c, p = i * h, d = e * c, g = e * h;
189
+ for (; u <= l; u += p) {
190
+ let y = u;
191
+ const v = u + e * (n - h);
192
+ for (; y <= v; y += g) {
193
+ const b = y + d, w = y + f, I = w + d;
194
+ a(s[y + t], s[w + t]);
195
+ const A = et, k = st;
196
+ a(s[b + t], s[I + t]);
197
+ const P = et, _ = st;
198
+ a(A, P), s[y + t] = et, s[b + t] = st, a(k, _), s[w + t] = et, s[I + t] = st;
199
+ }
200
+ if (n & c) {
201
+ const b = y + f;
202
+ a(s[y + t], s[b + t]), s[y + t] = et, s[b + t] = st;
203
+ }
204
+ }
205
+ if (o & c) {
206
+ let y = u;
207
+ const v = u + e * (n - h);
208
+ for (; y <= v; y += g) {
209
+ const b = y + d;
210
+ a(s[y + t], s[b + t]), s[y + t] = et, s[b + t] = st;
211
+ }
212
+ }
213
+ h = c, c >>= 1;
214
+ }
215
+ }
216
+ function ee(s, t, n, e, o) {
217
+ let i = 0;
218
+ for (const w of e)
219
+ i += t * n * w;
220
+ i * 2 !== o && L("PIZ block size is inconsistent"), s.length < 4 && L("PIZ block is truncated");
221
+ const r = new DataView(s.buffer, s.byteOffset, s.byteLength), a = r.getUint16(0, !0), m = r.getUint16(2, !0);
222
+ m >= It && L("PIZ bitmap range is invalid");
223
+ const c = new Uint8Array(It);
224
+ let h = 4;
225
+ if (a <= m) {
226
+ const w = m - a + 1;
227
+ h + w > s.length && L("PIZ bitmap is truncated"), c.set(s.subarray(h, h + w), a), h += w;
228
+ }
229
+ const u = new Uint16Array(65536);
230
+ let l = 0;
231
+ for (let w = 0; w < 65536; w++)
232
+ (w === 0 || c[w >> 3] & 1 << (w & 7)) && (u[l++] = w);
233
+ const f = l - 1;
234
+ h + 4 > s.length && L("PIZ block is truncated");
235
+ const p = r.getUint32(h, !0);
236
+ h += 4;
237
+ const d = new Uint16Array(i);
238
+ qt(s, h, p, d, i);
239
+ let g = 0;
240
+ const y = [];
241
+ for (const w of e) {
242
+ y.push(g);
243
+ for (let I = 0; I < w; I++)
244
+ te(d, g + I, t, w, n, t * w, f);
245
+ g += t * n * w;
246
+ }
247
+ for (let w = 0; w < i; w++)
248
+ d[w] = u[d[w]];
249
+ const v = new Uint8Array(o);
250
+ let b = 0;
251
+ for (let w = 0; w < n; w++)
252
+ for (let I = 0; I < e.length; I++) {
253
+ const A = t * e[I];
254
+ let k = y[I] + w * A;
255
+ for (let P = 0; P < A; P++, k++) {
256
+ const _ = d[k];
257
+ v[b++] = _ & 255, v[b++] = _ >> 8;
258
+ }
259
+ }
260
+ return v;
261
+ }
262
+ const se = ["none", "rle", "zips", "zip", "piz", "pxr24", null, null, null, null], ne = ["NONE", "RLE", "ZIPS", "ZIP", "PIZ", "PXR24", "B44", "B44A", "DWAA", "DWAB"], ie = [1, 1, 1, 16, 32, 16], oe = 64, kt = 8;
263
+ let ut = null;
264
+ function re() {
265
+ if (!ut) {
266
+ ut = new Float32Array(65536);
267
+ for (let s = 0; s < 65536; s++) {
268
+ const t = s & 32768 ? -1 : 1, n = s >> 10 & 31, e = s & 1023;
269
+ ut[s] = n === 0 ? t * 2 ** -14 * (e / 1024) : n === 31 ? e ? Number.NaN : t * (1 / 0) : t * 2 ** (n - 15) * (1 + e / 1024);
270
+ }
271
+ }
272
+ return ut;
273
+ }
274
+ function S(s) {
275
+ throw new N(lt(s), `[Nova3D] EXR ${s}.`);
276
+ }
277
+ async function ae(s, t) {
278
+ const { limits: n, signal: e } = K(t, ct, "EXR parse"), o = W(n);
279
+ if (e?.throwIfAborted(), typeof s == "string")
280
+ throw new N("invalid-option", "[Nova3D] EXR input must be bytes.");
281
+ const i = pt(s, o.maxInputBytes, "EXR"), r = i.byteLength, a = new DataView(i.buffer, i.byteOffset, r);
282
+ (r < 8 || a.getUint32(0, !0) !== 20000630) && S("magic number is missing");
283
+ const m = i[4], c = i[5];
284
+ m !== 2 && S("version must be 2"), c & 2 && S("tiled images are not supported"), c & 8 && S("deep images are not supported"), c & 16 && S("multi-part files are not supported");
285
+ let h = 8;
286
+ const u = () => {
287
+ const x = h;
288
+ for (; h < r && i[h] !== 0; )
289
+ h - x >= 255 && S("header name is too long"), h++;
290
+ return h >= r && S("header is truncated"), String.fromCharCode(...i.subarray(x, h++));
291
+ };
292
+ let l, f = -1, p;
293
+ for (let x = 0; ; x++) {
294
+ x > 4096 && S("header has too many attributes");
295
+ const R = u();
296
+ if (R === "")
297
+ break;
298
+ const U = u();
299
+ h + 4 > r && S("header is truncated");
300
+ const $ = a.getInt32(h, !0);
301
+ h += 4, ($ < 0 || h + $ > r) && S("attribute size is invalid");
302
+ const D = h + $;
303
+ if (R === "channels" && U === "chlist") {
304
+ l = [];
305
+ let C = h;
306
+ for (; ; ) {
307
+ C >= D && S("channel list is truncated");
308
+ const Y = C;
309
+ for (; C < D && i[C] !== 0; )
310
+ C++;
311
+ C >= D && S("channel list is truncated");
312
+ const V = String.fromCharCode(...i.subarray(Y, C++));
313
+ if (V === "")
314
+ break;
315
+ (C + 16 > D || l.length >= oe) && S("channel list is invalid or too long");
316
+ const F = a.getInt32(C, !0), O = a.getInt32(C + 8, !0), X = a.getInt32(C + 12, !0);
317
+ C += 16, (F < 0 || F > 2) && S("channel has an unknown pixel type"), (O !== 1 || X !== 1) && S("subsampled channels are not supported"), l.push({ name: V, type: F, size: F === 1 ? 2 : 4, slot: -1 });
318
+ }
319
+ } else R === "compression" && U === "compression" ? ($ < 1 && S("compression attribute is empty"), f = i[h]) : R === "dataWindow" && U === "box2i" && ($ < 16 && S("dataWindow attribute is truncated"), p = [a.getInt32(h, !0), a.getInt32(h + 4, !0), a.getInt32(h + 8, !0), a.getInt32(h + 12, !0)]);
320
+ h = D;
321
+ }
322
+ (!l?.length || !p || f < 0) && S("header lacks channels, compression or dataWindow");
323
+ const d = se[f];
324
+ d || S(`compression ${ne[f] ?? f} is not supported`);
325
+ const [g, y, v, b] = p, w = v - g + 1, I = b - y + 1;
326
+ Nt(w, I, o, "EXR");
327
+ const A = new Map(l.map((x) => [x.name, x]));
328
+ if (A.has("R") || A.has("G") || A.has("B"))
329
+ ["R", "G", "B", "A"].forEach((x, R) => {
330
+ const U = A.get(x);
331
+ U && (U.slot = R);
332
+ });
333
+ else if (A.has("Y")) {
334
+ A.get("Y").slot = 4;
335
+ const x = A.get("A");
336
+ x && (x.slot = 3);
337
+ } else
338
+ S("image needs R, G, B or Y channels");
339
+ const k = l.reduce((x, R) => x + R.size * w, 0), P = ie[f], _ = Math.ceil(I / P), M = h;
340
+ M + _ * 16 > r && S("offset table is truncated");
341
+ const T = new Float32Array(w * I * 4);
342
+ if (!A.get("A") || A.get("A").slot !== 3)
343
+ for (let x = 3; x < T.length; x += 4)
344
+ T[x] = 1;
345
+ const Z = re(), G = l.map((x) => x.type), Q = l.map((x) => x.size / 2), q = (x, R, U) => {
346
+ const $ = new DataView(x.buffer, x.byteOffset, x.byteLength);
347
+ let D = 0;
348
+ for (let C = 0; C < U; C++) {
349
+ const Y = (R + C) * w * 4;
350
+ for (const V of l) {
351
+ const F = V.slot;
352
+ if (F < 0) {
353
+ D += V.size * w;
354
+ continue;
355
+ }
356
+ let O = Y + (F === 4 ? 0 : F);
357
+ const X = D + V.size * w;
358
+ if (V.type === 1)
359
+ for (; D < X; D += 2, O += 4)
360
+ T[O] = Z[$.getUint16(D, !0)];
361
+ else if (V.type === 2)
362
+ for (; D < X; D += 4, O += 4)
363
+ T[O] = $.getFloat32(D, !0);
364
+ else
365
+ for (; D < X; D += 4, O += 4)
366
+ T[O] = $.getUint32(D, !0);
367
+ if (F === 4)
368
+ for (let ot = Y; ot < Y + w * 4; ot += 4)
369
+ T[ot + 1] = T[ot], T[ot + 2] = T[ot];
370
+ }
371
+ }
372
+ }, E = async (x) => {
373
+ const R = M + x * 8, U = a.getUint32(R, !0), $ = a.getUint32(R + 4, !0), D = $ * 2 ** 32 + U;
374
+ ($ > 2097151 || D < M + _ * 8 || D + 8 > r) && S("chunk offset is invalid");
375
+ const C = a.getInt32(D, !0), Y = a.getInt32(D + 4, !0);
376
+ (C !== y + x * P || Y < 0 || D + 8 + Y > r) && S("chunk header is invalid");
377
+ const V = Math.min(P, b - C + 1), F = V * k, O = i.subarray(D + 8, D + 8 + Y);
378
+ let X;
379
+ d === "none" || Y >= F ? ((d === "none" ? Y !== F : Y < F) && S("uncompressed chunk has the wrong size"), X = O.subarray(0, F)) : d === "rle" ? X = Xt(O, F) : d === "zips" || d === "zip" ? X = await Yt(O, F) : d === "piz" ? X = ee(O, w, V, Q, F) : X = await Jt(O, w, V, G, F), q(X, C - y, V);
380
+ };
381
+ for (let x = 0; x < _; x += kt) {
382
+ e?.throwIfAborted();
383
+ const R = [];
384
+ for (let U = x; U < Math.min(_, x + kt); U++)
385
+ R.push(E(U));
386
+ await Promise.all(R);
387
+ }
388
+ e?.throwIfAborted();
389
+ const ft = l.filter((x) => x.slot < 0).map((x) => at("ignored", `EXR channel ${JSON.stringify(x.name)} is not used and was ignored.`));
390
+ return { width: w, height: I, data: T, channels: l.map((x) => x.name), compression: d, warnings: ft };
391
+ }
392
+ async function qe(s, t) {
393
+ const { limits: n, signal: e } = K(t, ct, "EXR load");
394
+ return ae(await it(nt(s), W(n).maxInputBytes, e, "EXR"), { limits: n, signal: e });
395
+ }
396
+ let mt = null;
397
+ function le() {
398
+ if (!mt) {
399
+ mt = new Float32Array(256);
400
+ for (let s = 1; s < 256; s++)
401
+ mt[s] = 2 ** (s - 128) / 255;
402
+ }
403
+ return mt;
404
+ }
405
+ function H(s) {
406
+ throw new N(lt(s), `[Nova3D] HDR ${s}.`);
407
+ }
408
+ async function ce(s, t) {
409
+ const n = W(K(t, St, "HDR parse").limits), e = pt(s, n.maxInputBytes, "HDR"), o = e.byteLength;
410
+ let i = 0;
411
+ const r = () => {
412
+ const v = i;
413
+ for (; i < o && e[i] !== 10; )
414
+ i - v > 4096 && H("header line is too long"), i++;
415
+ return i >= o && H("header is truncated"), String.fromCharCode(...e.subarray(v, i++)).replace(/\r$/, "");
416
+ };
417
+ r().startsWith("#?") || H("must start with #?RADIANCE or #?RGBE");
418
+ let a = 1, m = 1, c = !1;
419
+ for (let v = 0; ; v++) {
420
+ v > 1024 && H("header has too many lines");
421
+ const b = r().trim();
422
+ if (b === "")
423
+ break;
424
+ if (b.startsWith("FORMAT="))
425
+ b !== "FORMAT=32-bit_rle_rgbe" && H("format must be 32-bit_rle_rgbe"), c = !0;
426
+ else if (b.startsWith("EXPOSURE=")) {
427
+ const w = Number(b.slice(9));
428
+ Number.isFinite(w) && w > 0 && (a *= w);
429
+ } else if (b.startsWith("GAMMA=")) {
430
+ const w = Number(b.slice(6));
431
+ Number.isFinite(w) && w > 0 && (m = w);
432
+ }
433
+ }
434
+ c || H("header has no FORMAT");
435
+ const h = /^([+-])Y (\d+) \+X (\d+)$/.exec(r().trim());
436
+ h || H("resolution must be -Y h +X w or +Y h +X w");
437
+ const u = Number(h[2]), l = Number(h[3]);
438
+ Nt(l, u, n, "HDR");
439
+ const f = h[1] === "+";
440
+ o - i < u * Math.min(l * 4, 4 + 8 * Math.ceil(l / 127)) && H("data is truncated");
441
+ const p = le(), d = new Float32Array(l * u * 4), g = new Uint8Array(l * 4), y = l >= 8 && l < 32768 && i + 4 <= o && e[i] === 2 && e[i + 1] === 2 && !(e[i + 2] & 128);
442
+ for (let v = 0; v < u; v++) {
443
+ if (y) {
444
+ (i + 4 > o || e[i] !== 2 || e[i + 1] !== 2 || (e[i + 2] << 8 | e[i + 3]) !== l) && H("scanline has a bad RLE header"), i += 4;
445
+ for (let w = 0; w < 4; w++) {
446
+ let I = 0;
447
+ for (; I < l; ) {
448
+ i >= o && H("data is truncated");
449
+ let A = e[i++];
450
+ if (A > 128) {
451
+ A -= 128, (I + A > l || i >= o) && H("run overflows its scanline");
452
+ const k = e[i++];
453
+ for (let P = I + A; I < P; I++)
454
+ g[I * 4 + w] = k;
455
+ } else {
456
+ (A === 0 || I + A > l || i + A > o) && H("literal overflows its scanline");
457
+ for (let k = I + A; I < k; I++)
458
+ g[I * 4 + w] = e[i++];
459
+ }
460
+ }
461
+ }
462
+ } else
463
+ i + l * 4 > o && H("data is truncated"), g.set(e.subarray(i, i + l * 4)), i += l * 4;
464
+ let b = (f ? u - 1 - v : v) * l * 4;
465
+ for (let w = 0; w < l * 4; w += 4, b += 4) {
466
+ const I = p[g[w + 3]];
467
+ d[b] = g[w] * I, d[b + 1] = g[w + 1] * I, d[b + 2] = g[w + 2] * I, d[b + 3] = 1;
468
+ }
469
+ }
470
+ return { width: l, height: u, data: d, exposure: a, gamma: m, warnings: [] };
471
+ }
472
+ async function je(s, t) {
473
+ const { limits: n, signal: e } = K(t, ct, "HDR load");
474
+ return ce(await it(nt(s), W(n).maxInputBytes, e, "HDR"), { limits: n });
475
+ }
476
+ class gt {
477
+ constructor(t, n, e = !0, o = 0) {
478
+ this.text = t, this._format = n, this._comments = e, this._position = o;
479
+ }
480
+ /** 1-based number of the current line. */
481
+ line = 0;
482
+ /** Tokens on the current line. */
483
+ count = 0;
484
+ starts = new Int32Array(32);
485
+ ends = new Int32Array(32);
486
+ _position = 0;
487
+ _lineEnd = 0;
488
+ /** Character offset after the current line. */
489
+ get position() {
490
+ return this._position;
491
+ }
492
+ /** Moves to the next line with tokens; false at the end of the text. */
493
+ next() {
494
+ const t = this.text, n = t.length;
495
+ for (; this._position < n; ) {
496
+ let e = this._position;
497
+ for (; e < n; ) {
498
+ const r = t.charCodeAt(e);
499
+ if (r === 10 || r === 13)
500
+ break;
501
+ e++;
502
+ }
503
+ const o = this._position;
504
+ this._position = e + 1, this._lineEnd = e, this.line++, e < n && t.charCodeAt(e) === 13 && t.charCodeAt(e + 1) === 10 && this._position++, this.count = 0;
505
+ let i = o;
506
+ for (; i < e; ) {
507
+ let r = t.charCodeAt(i);
508
+ if (r === 32 || r === 9 || r === 11 || r === 12) {
509
+ i++;
510
+ continue;
511
+ }
512
+ if (r === 35 && this._comments)
513
+ break;
514
+ const a = i;
515
+ for (; i < e && (r = t.charCodeAt(i), !(r === 32 || r === 9 || r === 11 || r === 12)); )
516
+ i++;
517
+ if (this.count === this.starts.length) {
518
+ const m = new Int32Array(this.count * 2), c = new Int32Array(this.count * 2);
519
+ m.set(this.starts), c.set(this.ends), this.starts = m, this.ends = c;
520
+ }
521
+ this.starts[this.count] = a, this.ends[this.count++] = i;
522
+ }
523
+ if (this.count > 0)
524
+ return !0;
525
+ }
526
+ return this.count = 0, !1;
527
+ }
528
+ token(t) {
529
+ return this.text.slice(this.starts[t], this.ends[t]);
530
+ }
531
+ /** Case-insensitive comparison with a lower-case ASCII word. */
532
+ is(t, n) {
533
+ const e = this.starts[t];
534
+ if (this.ends[t] - e !== n.length)
535
+ return !1;
536
+ for (let o = 0; o < n.length; o++) {
537
+ let i = this.text.charCodeAt(e + o);
538
+ if (i >= 65 && i <= 90 && (i += 32), i !== n.charCodeAt(o))
539
+ return !1;
540
+ }
541
+ return !0;
542
+ }
543
+ /** Remaining text of the line from a token, trimmed. */
544
+ rest(t) {
545
+ return t < this.count ? this.text.slice(this.starts[t], this._lineEnd).trim() : "";
546
+ }
547
+ /** Finite number token. */
548
+ number(t) {
549
+ t >= this.count && this.fail("is missing a number");
550
+ const n = Number(this.text.slice(this.starts[t], this.ends[t]));
551
+ return Number.isFinite(n) || this.fail("has an invalid number"), n;
552
+ }
553
+ fail(t) {
554
+ throw new N(lt(t), `[Nova3D] ${this._format} line ${this.line} ${t}.`);
555
+ }
556
+ }
557
+ const he = j({ limits: !0, baseUrl: !0 }), fe = j({ flipV: !0 }), ue = { map_kd: "diffuse", map_ka: "ambient", map_ks: "specular", map_ke: "emissive", map_ns: "shininess", map_d: "alpha", map_bump: "bump", bump: "bump", norm: "normal", map_norm: "normal", disp: "displacement", map_disp: "displacement", map_pr: "roughness", map_pm: "metalness" }, me = { "-blendu": 1, "-blendv": 1, "-bm": 1, "-boost": 1, "-cc": 1, "-clamp": 1, "-imfchan": 1, "-mm": 2, "-o": 3, "-s": 3, "-t": 3, "-texres": 1, "-type": 1 }, de = 65536;
558
+ function pe(s) {
559
+ const t = [0, 0], n = [1, 1];
560
+ let e = 1, o = !1, i = 1;
561
+ for (; i < s.count; ) {
562
+ const a = s.token(i).toLowerCase(), m = me[a];
563
+ if (m === void 0 || !a.startsWith("-"))
564
+ break;
565
+ if (i++, a === "-o" || a === "-s" || a === "-t") {
566
+ const c = [];
567
+ for (; c.length < m && i < s.count && Number.isFinite(Number(s.token(i))); )
568
+ c.push(s.number(i++));
569
+ c.length === 0 && s.fail("has a texture option without values"), a === "-o" ? (t[0] = c[0], t[1] = c[1] ?? 0) : a === "-s" && (n[0] = c[0], n[1] = c[1] ?? 1);
570
+ } else
571
+ for (let c = 0; c < m && i < s.count - 1; c++)
572
+ a === "-bm" ? e = s.number(i) : a === "-clamp" && (o = s.is(i, "on")), i++;
573
+ }
574
+ const r = s.rest(i).replaceAll("\\", "/");
575
+ return r || s.fail("has a texture statement without a path"), { path: r, offset: t, scale: n, bumpScale: e, clamp: o };
576
+ }
577
+ function dt(s) {
578
+ if (s.count < 2 || s.is(1, "spectral") || s.is(1, "xyz"))
579
+ return;
580
+ const t = s.number(1);
581
+ return s.count >= 4 ? [t, s.number(2), s.number(3)] : [t, t, t];
582
+ }
583
+ async function Ct(s, t) {
584
+ t = K(t, he, "MTL parse");
585
+ const n = W(t.limits), e = new gt(Pt(s, n.maxInputBytes, "MTL"), "MTL"), o = /* @__PURE__ */ new Map();
586
+ let i = null, r = {};
587
+ const a = /* @__PURE__ */ new Set();
588
+ for (; e.next(); ) {
589
+ if (e.is(0, "newmtl")) {
590
+ const u = e.rest(1);
591
+ o.size >= de && e.fail("exceeds the material limit"), r = {}, i = { name: u, maps: r }, o.set(u, i);
592
+ continue;
593
+ }
594
+ if (!i)
595
+ continue;
596
+ const c = e.token(0).toLowerCase(), h = ue[c];
597
+ if (h) {
598
+ r[h] = pe(e);
599
+ continue;
600
+ }
601
+ switch (c) {
602
+ case "ka":
603
+ i.ambient = dt(e);
604
+ break;
605
+ case "kd":
606
+ i.diffuse = dt(e);
607
+ break;
608
+ case "ks":
609
+ i.specular = dt(e);
610
+ break;
611
+ case "ke":
612
+ i.emissive = dt(e);
613
+ break;
614
+ case "ns":
615
+ i.shininess = e.number(1);
616
+ break;
617
+ case "ni":
618
+ i.ior = e.number(1);
619
+ break;
620
+ case "d":
621
+ i.opacity = e.number(e.is(1, "-halo") ? 2 : 1);
622
+ break;
623
+ case "tr":
624
+ i.opacity = 1 - e.number(1);
625
+ break;
626
+ case "illum":
627
+ i.illum = e.number(1);
628
+ break;
629
+ case "pr":
630
+ i.roughness = e.number(1);
631
+ break;
632
+ case "pm":
633
+ i.metalness = e.number(1);
634
+ break;
635
+ default:
636
+ a.size < 64 && a.add(c);
637
+ }
638
+ }
639
+ const m = [...a].map((c) => at("ignored", `MTL statement ${JSON.stringify(c)} is not supported and was ignored.`));
640
+ return t.baseUrl === void 0 ? { materials: o, warnings: m } : { materials: o, baseUrl: t.baseUrl, warnings: m };
641
+ }
642
+ async function Qe(s, t) {
643
+ const { limits: n, signal: e } = K(t, ct, "MTL load"), o = nt(s);
644
+ return Ct(await it(o, W(n).maxInputBytes, e, "MTL"), { limits: n, baseUrl: o.href });
645
+ }
646
+ function ge(s) {
647
+ if (s.length === 1)
648
+ return s[0];
649
+ const t = /* @__PURE__ */ new Map();
650
+ for (const n of s)
651
+ for (const [e, o] of n.materials)
652
+ t.set(e, o);
653
+ return { materials: t, baseUrl: s[0]?.baseUrl, warnings: s.flatMap((n) => n.warnings) };
654
+ }
655
+ function B(s, t) {
656
+ return Number.isFinite(s) ? Math.min(Math.max(s, 0), t) : 0;
657
+ }
658
+ function Lt(s, t) {
659
+ return [B(wt(B(s[0], t)), t), B(wt(B(s[1], t)), t), B(wt(B(s[2], t)), t)];
660
+ }
661
+ function we(s, t) {
662
+ const [n, e] = s.scale, [o, i] = s.offset;
663
+ return n === 1 && e === 1 && o === 0 && i === 0 ? null : { offset: [o, t ? 1 - e - i : i], scale: [n, e] };
664
+ }
665
+ function ye(s, t = /* @__PURE__ */ new Map(), n = {}) {
666
+ ht(n, fe, "MTL material");
667
+ const e = n.flipV ?? !0, o = s.maps, i = (f) => {
668
+ const p = o[f], d = p ? t.get(p.path) : void 0;
669
+ return d && !d.destroyed ? d : null;
670
+ }, r = (f) => {
671
+ const p = o[f];
672
+ return p ? we(p, e) : null;
673
+ }, a = B(s.opacity ?? 1, 1), m = Lt(s.diffuse ?? [1, 1, 1], 1), c = o.normal ? "normal" : "bump", h = {
674
+ baseColorFactor: [m[0], m[1], m[2], a],
675
+ alphaMode: a < 1 || o.alpha ? "blend" : "opaque",
676
+ baseColorMap: i("diffuse"),
677
+ baseColorMapTransform: r("diffuse"),
678
+ normalMap: i(c),
679
+ normalMapTransform: r(c),
680
+ normalScale: B(o[c]?.bumpScale ?? 1, 65504),
681
+ emissiveFactor: s.emissive ? Lt(s.emissive, 65504) : [0, 0, 0],
682
+ emissiveMap: i("emissive"),
683
+ emissiveMapTransform: r("emissive")
684
+ };
685
+ if (s.emissive === void 0 && o.emissive && (h.emissiveFactor = [1, 1, 1]), s.roughness !== void 0 || s.metalness !== void 0 || o.roughness !== void 0 || o.metalness !== void 0) {
686
+ const f = o.roughness && o.metalness && o.roughness.path === o.metalness.path;
687
+ return { type: "pbr", ...h, roughnessFactor: B(s.roughness ?? 1, 1), metallicFactor: B(s.metalness ?? 0, 1), metallicRoughnessMap: f ? i("roughness") : null, metallicRoughnessMapTransform: f ? r("roughness") : null };
688
+ }
689
+ const l = s.illum !== void 0 && s.illum <= 1;
690
+ return {
691
+ type: "phong",
692
+ ...h,
693
+ specularColor: l ? [0, 0, 0] : s.specular ? [B(s.specular[0], 1), B(s.specular[1], 1), B(s.specular[2], 1)] : void 0,
694
+ shininess: B(s.shininess ?? 30, 65504),
695
+ specularMap: l ? null : i("specular"),
696
+ specularMapTransform: r("specular")
697
+ };
698
+ }
699
+ const ve = j({ material: !0, materials: !0, textures: !0 }), be = j({ baseUrl: !0, signal: !0, limits: !0 }), xe = j({ intensity: !0, rotation: !0, sampler: !0 });
700
+ function _e(s, t) {
701
+ const n = s && "baseColorFactor" in s ? s.baseColorFactor : void 0, e = (i) => i <= 31308e-7 ? 12.92 * i : 1.055 * i ** (1 / 2.4) - 0.055, o = n ? [e(n[0]), e(n[1]), e(n[2]), n[3]] : [1, 1, 1, 1];
702
+ return t === "points" ? { type: "basic", color: o, pointSize: 1 } : { type: "basic", color: o };
703
+ }
704
+ function ts(s, t = {}) {
705
+ if (ht(t, ve, "model asset"), !Array.isArray(s?.parts))
706
+ throw new N("invalid-option", "[Nova3D] Model data needs a parts array.");
707
+ const n = s, e = t.materials ?? n.materials, o = t.material ?? { type: "phong" }, i = new Bt();
708
+ try {
709
+ const r = /* @__PURE__ */ new Map();
710
+ for (const [u, l] of t.textures ?? [])
711
+ r.set(u, i.createTexture(l));
712
+ const a = /* @__PURE__ */ new Map(), m = [];
713
+ for (const u of s.parts) {
714
+ const l = u.geometry.topology ?? "triangles", f = u.material === null || !e ? void 0 : e.materials.get(u.material), p = `${l}\0${f ? f.name : ""}`;
715
+ let d = a.get(p);
716
+ if (d === void 0) {
717
+ const g = f ? ye(f, r, { flipV: n.flipV ?? !0 }) : o;
718
+ i.createMaterial(l === "triangles" ? g : _e(g, l)), d = i.materials.length - 1, a.set(p, d);
719
+ }
720
+ i.createGeometry(u.geometry), m.push([{ geometry: i.geometry.length - 1, material: d }]);
721
+ }
722
+ for (const u of [...i.textures])
723
+ u._hasOtherUsers(/* @__PURE__ */ new Set()) || (u.destroy(), i.textures.splice(i.textures.indexOf(u), 1));
724
+ const c = i.geometry, h = i.materials;
725
+ return new Et({
726
+ nodes: s.parts.map((u, l) => ({ transform: $t(), children: [], mesh: l })),
727
+ scenes: [s.parts.map((u, l) => l)],
728
+ defaultScene: 0,
729
+ meshes: m.map((u) => u.map((l) => ({ geometry: c[l.geometry], material: h[l.material] }))),
730
+ meshWeights: s.parts.map(() => Object.freeze([])),
731
+ skins: [],
732
+ geometry: c,
733
+ materials: h,
734
+ textures: i.textures
735
+ }, []);
736
+ } catch (r) {
737
+ throw i.destroy(), r;
738
+ }
739
+ }
740
+ const Ae = /* @__PURE__ */ new Set(["diffuse", "ambient", "emissive"]);
741
+ async function es(s, t = {}) {
742
+ ht(t, be, "MTL texture load");
743
+ const n = /* @__PURE__ */ new Map();
744
+ for (const r of s.materials.values())
745
+ for (const [a, m] of Object.entries(r.maps))
746
+ Ae.has(a) ? n.set(m.path, "srgb") : n.has(m.path) || n.set(m.path, "linear");
747
+ const e = t.baseUrl ?? s.baseUrl, o = t.signal ?? new AbortController().signal, i = /* @__PURE__ */ new Map();
748
+ return await Promise.all([...n].map(async ([r, a]) => {
749
+ const m = Vt(t.limits === void 0 ? { colorSpace: a } : { colorSpace: a, limits: t.limits }, o);
750
+ i.set(r, await Ht(document, nt(r, e), m));
751
+ })), i;
752
+ }
753
+ function Ie(s) {
754
+ let t = !0;
755
+ for (let e = 0; e < s.length; e++) {
756
+ const o = s[e];
757
+ if (!(o >= 0 && o <= 65504)) {
758
+ t = !1;
759
+ break;
760
+ }
761
+ }
762
+ if (t)
763
+ return s;
764
+ const n = new Float32Array(s.length);
765
+ for (let e = 0; e < s.length; e++) {
766
+ const o = s[e];
767
+ n[e] = o >= 0 ? o <= 65504 ? o : 65504 : 0;
768
+ }
769
+ return n;
770
+ }
771
+ function ke(s, t, n = {}) {
772
+ if (ht(n, Zt, "HDR texture sampler"), !(t?.data instanceof Float32Array) || t.data.length !== t.width * t.height * 4)
773
+ throw new N("invalid-option", "[Nova3D] HDR image needs width·height RGBA float32 pixels.");
774
+ return s.createTexture({ filter: "linear", mipmaps: !1, wrapS: "repeat", wrapT: "clamp", ...n, width: t.width, height: t.height, data: Ie(t.data), format: "rgba16f", colorSpace: "linear" });
775
+ }
776
+ function ss(s, t, n = {}) {
777
+ ht(n, xe, "HDR environment");
778
+ const e = ke(s, t, n.sampler);
779
+ try {
780
+ return s.createEnvironment({ source: e, intensity: n.intensity, rotation: n.rotation });
781
+ } catch (o) {
782
+ throw e.destroy(), o;
783
+ }
784
+ }
785
+ class J {
786
+ data;
787
+ length = 0;
788
+ constructor(t = 64) {
789
+ this.data = new Float32Array(Math.max(4, t));
790
+ }
791
+ reserve(t) {
792
+ const n = this.length + t;
793
+ if (n > this.data.length) {
794
+ let e = this.data.length * 2;
795
+ for (; e < n; )
796
+ e *= 2;
797
+ const o = new Float32Array(e);
798
+ o.set(this.data.subarray(0, this.length)), this.data = o;
799
+ }
800
+ }
801
+ push2(t, n) {
802
+ this.reserve(2), this.data[this.length++] = t, this.data[this.length++] = n;
803
+ }
804
+ push3(t, n, e) {
805
+ this.reserve(3), this.data[this.length++] = t, this.data[this.length++] = n, this.data[this.length++] = e;
806
+ }
807
+ push4(t, n, e, o) {
808
+ this.reserve(4), this.data[this.length++] = t, this.data[this.length++] = n, this.data[this.length++] = e, this.data[this.length++] = o;
809
+ }
810
+ /** Appends `count` copies of a value. */
811
+ fill(t, n) {
812
+ this.reserve(n), this.data.fill(t, this.length, this.length + n), this.length += n;
813
+ }
814
+ /** Exact-size copy. */
815
+ take() {
816
+ return this.data.slice(0, this.length);
817
+ }
818
+ }
819
+ class _t {
820
+ data;
821
+ length = 0;
822
+ constructor(t = 64) {
823
+ this.data = new Uint32Array(Math.max(4, t));
824
+ }
825
+ push(t) {
826
+ if (this.length === this.data.length) {
827
+ const n = new Uint32Array(this.data.length * 2);
828
+ n.set(this.data), this.data = n;
829
+ }
830
+ this.data[this.length++] = t;
831
+ }
832
+ }
833
+ class Le {
834
+ _keys;
835
+ _values;
836
+ _mask;
837
+ _size = 0;
838
+ constructor(t = 64) {
839
+ let n = 16;
840
+ for (; n < t * 2; )
841
+ n *= 2;
842
+ this._keys = new Int32Array(n * 3), this._values = new Int32Array(n).fill(-1), this._mask = n - 1;
843
+ }
844
+ /** Index stored for the triple, or the new `value` after inserting it. */
845
+ getOrSet(t, n, e, o) {
846
+ let i = this._hash(t, n, e) & this._mask;
847
+ const r = this._keys, a = this._values;
848
+ for (; a[i] !== -1; ) {
849
+ const m = i * 3;
850
+ if (r[m] === t && r[m + 1] === n && r[m + 2] === e)
851
+ return a[i];
852
+ i = i + 1 & this._mask;
853
+ }
854
+ return r[i * 3] = t, r[i * 3 + 1] = n, r[i * 3 + 2] = e, a[i] = o, ++this._size * 2 > a.length && this._grow(), o;
855
+ }
856
+ _hash(t, n, e) {
857
+ let o = Math.imul(t ^ 2654435769, 2246822507);
858
+ return o = Math.imul(o ^ n + 1663821227 ^ o >>> 13, 3266489909), o = Math.imul(o ^ e + 2135587861 ^ o >>> 16, 668265263), (o ^ o >>> 15) >>> 0;
859
+ }
860
+ _grow() {
861
+ const t = this._keys, n = this._values, e = n.length * 2;
862
+ this._keys = new Int32Array(e * 3), this._values = new Int32Array(e).fill(-1), this._mask = e - 1;
863
+ for (let o = 0; o < n.length; o++) {
864
+ if (n[o] === -1)
865
+ continue;
866
+ const i = t[o * 3], r = t[o * 3 + 1], a = t[o * 3 + 2];
867
+ let m = this._hash(i, r, a) & this._mask;
868
+ for (; this._values[m] !== -1; )
869
+ m = m + 1 & this._mask;
870
+ this._keys.set(t.subarray(o * 3, o * 3 + 3), m * 3), this._values[m] = n[o];
871
+ }
872
+ }
873
+ }
874
+ function zt(s, t, n) {
875
+ return n <= 65536 ? Uint16Array.from(s.subarray(0, t)) : s.slice(0, t);
876
+ }
877
+ function Me(s, t, n) {
878
+ const e = new Float32Array(s.length);
879
+ for (let o = 0; o + 2 < n; o += 3) {
880
+ const i = (t ? t[o] : o) * 3, r = (t ? t[o + 1] : o + 1) * 3, a = (t ? t[o + 2] : o + 2) * 3, m = s[r] - s[i], c = s[r + 1] - s[i + 1], h = s[r + 2] - s[i + 2], u = s[a] - s[i], l = s[a + 1] - s[i + 1], f = s[a + 2] - s[i + 2], p = c * f - h * l, d = h * u - m * f, g = m * l - c * u;
881
+ e[i] += p, e[i + 1] += d, e[i + 2] += g, e[r] += p, e[r + 1] += d, e[r + 2] += g, e[a] += p, e[a + 1] += d, e[a + 2] += g;
882
+ }
883
+ return Ft(e, 0, e.length), e;
884
+ }
885
+ function Ft(s, t, n) {
886
+ for (let e = t; e < n; e += 3) {
887
+ const o = Math.hypot(s[e], s[e + 1], s[e + 2]);
888
+ o > 0 && Number.isFinite(o) ? (s[e] /= o, s[e + 1] /= o, s[e + 2] /= o) : (s[e] = 0, s[e + 1] = 0, s[e + 2] = 1);
889
+ }
890
+ }
891
+ const De = j({ limits: !0, flipV: !0, normals: !0, split: !0 }), Ne = j({ limits: !0, flipV: !0, normals: !0, split: !0, signal: !0, materials: !0 }), Se = ["triangles", "lines", "points"];
892
+ class Pe {
893
+ limits;
894
+ flipV;
895
+ normalMode;
896
+ split;
897
+ positions = new J(1024);
898
+ colors = null;
899
+ uvs = new J(256);
900
+ normals = new J(256);
901
+ libraries = [];
902
+ builders = [];
903
+ _byKey = /* @__PURE__ */ new Map();
904
+ _current = [void 0, void 0, void 0];
905
+ _object = "";
906
+ _group = "";
907
+ _material = null;
908
+ _vertices = 0;
909
+ _primitives = 0;
910
+ _cv = new Int32Array(16);
911
+ _ct = new Int32Array(16);
912
+ _cn = new Int32Array(16);
913
+ _ci = new Int32Array(16);
914
+ _corner = new Int32Array(3);
915
+ /** Keywords of statements the parser does not read (`s` excepted). */
916
+ _ignored = /* @__PURE__ */ new Set();
917
+ constructor(t) {
918
+ if (this.limits = W(t.limits), this.flipV = t.flipV ?? !0, this.normalMode = t.normals ?? "flat", this.split = t.split ?? "group", typeof this.flipV != "boolean" || !["flat", "smooth", "none"].includes(this.normalMode) || !["group", "material"].includes(this.split))
919
+ throw new N("invalid-option", "[Nova3D] Invalid OBJ parse options.");
920
+ }
921
+ parse(t) {
922
+ const n = t.includes("\\") ? t.replace(/\\\r?\n/g, " ") : t, e = new gt(n, "OBJ"), o = this.limits.maxVertices;
923
+ for (; e.next(); ) {
924
+ const r = e.starts[0], a = e.ends[0] - r, m = n.charCodeAt(r), c = a > 1 ? n.charCodeAt(r + 1) : 0;
925
+ if (m === 118 && a === 1)
926
+ this.positions.length >= o * 3 && e.fail("exceeds the vertex limit"), this.positions.push3(e.number(1), e.number(2), e.number(3)), e.count >= 7 ? (this.colors || (this.colors = new J(this.positions.data.length), this.colors.fill(1, this.positions.length - 3)), this.colors.push3(yt(e.number(4)), yt(e.number(5)), yt(e.number(6)))) : this.colors && this.colors.push3(1, 1, 1);
927
+ else if (m === 118 && c === 116 && a === 2) {
928
+ this.uvs.length >= o * 2 && e.fail("exceeds the texture coordinate limit");
929
+ const h = e.count > 2 ? e.number(2) : 0;
930
+ this.uvs.push2(e.number(1), this.flipV ? 1 - h : h);
931
+ } else if (m === 118 && c === 110 && a === 2)
932
+ this.normals.length >= o * 3 && e.fail("exceeds the normal limit"), this.normals.push3(e.number(1), e.number(2), e.number(3));
933
+ else if (m === 102 && a === 1)
934
+ this._face(e);
935
+ else if (m === 108 && a === 1)
936
+ this._line(e);
937
+ else if (m === 112 && a === 1)
938
+ this._points(e);
939
+ else if (e.is(0, "o"))
940
+ this._object = e.rest(1), this._current = [void 0, void 0, void 0];
941
+ else if (e.is(0, "g"))
942
+ this._group = e.rest(1), this._current = [void 0, void 0, void 0];
943
+ else if (e.is(0, "usemtl"))
944
+ this._material = e.rest(1) || null, this._current = [void 0, void 0, void 0];
945
+ else if (e.is(0, "mtllib")) {
946
+ const h = e.rest(1);
947
+ h && this.libraries.length < 256 && this.libraries.push(h);
948
+ } else !e.is(0, "s") && this._ignored.size < 64 && this._ignored.add(n.slice(r, e.ends[0]));
949
+ }
950
+ const i = [...this._ignored].map((r) => at("ignored", `OBJ statement ${JSON.stringify(r)} is not supported and was ignored.`));
951
+ return { parts: this.builders.map((r) => this._finish(r)), materialLibraries: this.libraries, flipV: this.flipV, warnings: i };
952
+ }
953
+ _builder(t) {
954
+ const n = Se.indexOf(t), e = this._current[n];
955
+ if (e)
956
+ return e;
957
+ const o = this.split === "group" ? `${t}\0${this._material ?? ""}\0${this._material === null ? 0 : 1}\0${this._object}\0${this._group}` : `${t}\0${this._material ?? ""}\0${this._material === null ? 0 : 1}`;
958
+ let i = this._byKey.get(o);
959
+ if (!i) {
960
+ if (this.builders.length >= this.limits.maxParts)
961
+ throw new N("budget", "[Nova3D] OBJ exceeds the part limit.");
962
+ i = { object: this._object, group: this._group, material: this._material, topology: t, vertices: 0, primitives: 0, positions: new J(), normals: null, uvs: null, colors: null, indices: new _t(), map: new Le(), computed: null }, this._byKey.set(o, i), this.builders.push(i);
963
+ }
964
+ return this._current[n] = i, i;
965
+ }
966
+ /** Resolves one `v[/vt[/vn]]` token into `_corner`; -1 marks a missing index. */
967
+ _readCorner(t, n, e) {
968
+ const o = t.text, i = t.ends[n];
969
+ let r = t.starts[n];
970
+ const a = this._corner;
971
+ a.fill(-1);
972
+ for (let m = 0; m < 3; m++) {
973
+ if (m > 0) {
974
+ if (r >= i)
975
+ break;
976
+ o.charCodeAt(r) !== 47 && t.fail("has an invalid index"), r++;
977
+ }
978
+ let c = !1;
979
+ r < i && o.charCodeAt(r) === 45 && (c = !0, r++);
980
+ let h = 0, u = 0;
981
+ for (; r < i; ) {
982
+ const p = o.charCodeAt(r);
983
+ if (p < 48 || p > 57)
984
+ break;
985
+ h = h * 10 + p - 48, u++, r++, h > 2147483647 && t.fail("has an index out of range");
986
+ }
987
+ if (u === 0) {
988
+ (c || m !== 1 || r >= i) && t.fail("has an invalid index");
989
+ continue;
990
+ }
991
+ const l = m === 0 ? this.positions.length / 3 : m === 1 ? this.uvs.length / 2 : this.normals.length / 3, f = c ? l - h : h - 1;
992
+ (h === 0 || f < 0 || f >= l) && t.fail("references an undefined vertex"), a[m] = f;
993
+ }
994
+ (r !== i || !e && a[2] !== -1) && t.fail("has an invalid index");
995
+ }
996
+ _ensureCorners(t) {
997
+ if (this._cv.length < t) {
998
+ let n = this._cv.length;
999
+ for (; n < t; )
1000
+ n *= 2;
1001
+ this._cv = new Int32Array(n), this._ct = new Int32Array(n), this._cn = new Int32Array(n), this._ci = new Int32Array(n);
1002
+ }
1003
+ }
1004
+ _vertex(t, n, e, o, i, r, a, m) {
1005
+ const c = i === "flat" ? t.vertices : t.map.getOrSet(n, e, o, t.vertices);
1006
+ if (c !== t.vertices)
1007
+ return c;
1008
+ if (++this._vertices > this.limits.maxVertices)
1009
+ throw new N("budget", "[Nova3D] OBJ exceeds the vertex limit.");
1010
+ t.vertices++;
1011
+ const h = this.positions.data;
1012
+ if (t.positions.push3(h[n * 3], h[n * 3 + 1], h[n * 3 + 2]), e >= 0 ? (t.uvs || (t.uvs = new J(t.positions.data.length), t.uvs.fill(0, c * 2)), t.uvs.push2(this.uvs.data[e * 2], this.uvs.data[e * 2 + 1])) : t.uvs?.push2(0, 0), i !== "none") {
1013
+ if (!t.normals) {
1014
+ t.normals = new J(t.positions.data.length), t.normals.fill(0, c * 3);
1015
+ for (let u = 2; u < c * 3; u += 3)
1016
+ t.normals.data[u] = 1;
1017
+ }
1018
+ i === "file" ? t.normals.push3(this.normals.data[o * 3], this.normals.data[o * 3 + 1], this.normals.data[o * 3 + 2]) : i === "flat" ? t.normals.push3(r, a, m) : (t.normals.push3(0, 0, 0), t.computed ??= new _t(), t.computed.push(c));
1019
+ } else
1020
+ t.normals?.push3(0, 0, 1);
1021
+ if (this.colors) {
1022
+ t.colors || (t.colors = new J(t.positions.data.length * 2), t.colors.fill(1, c * 4));
1023
+ const u = this.colors.data;
1024
+ t.colors.push4(u[n * 3], u[n * 3 + 1], u[n * 3 + 2], 1);
1025
+ } else
1026
+ t.colors?.push4(1, 1, 1, 1);
1027
+ return c;
1028
+ }
1029
+ _count(t, n) {
1030
+ if (this._primitives += n, t.primitives += n, this._primitives > this.limits.maxPrimitives)
1031
+ throw new N("budget", "[Nova3D] OBJ exceeds the primitive limit.");
1032
+ }
1033
+ _face(t) {
1034
+ const n = t.count - 1;
1035
+ n < 3 && t.fail("needs at least three face vertices"), this._ensureCorners(n);
1036
+ const e = this._builder("triangles");
1037
+ this._count(e, n - 2);
1038
+ let o = !1;
1039
+ for (let c = 0; c < n; c++)
1040
+ this._readCorner(t, c + 1, !0), this._cv[c] = this._corner[0], this._ct[c] = this._corner[1], this._cn[c] = this._corner[2], o ||= this._corner[2] === -1;
1041
+ let i = 0, r = 0, a = 0;
1042
+ if (o && this.normalMode !== "none") {
1043
+ const c = this.positions.data;
1044
+ for (let h = 0; h < n; h++) {
1045
+ const u = this._cv[h] * 3, l = this._cv[(h + 1) % n] * 3;
1046
+ i += (c[u + 1] - c[l + 1]) * (c[u + 2] + c[l + 2]), r += (c[u + 2] - c[l + 2]) * (c[u] + c[l]), a += (c[u] - c[l]) * (c[u + 1] + c[l + 1]);
1047
+ }
1048
+ if (this.normalMode === "flat") {
1049
+ const h = Math.hypot(i, r, a);
1050
+ h > 0 && Number.isFinite(h) ? (i /= h, r /= h, a /= h) : (i = 0, r = 0, a = 1);
1051
+ }
1052
+ }
1053
+ const m = this.normalMode === "flat" ? "flat" : this.normalMode === "smooth" ? "computed" : "none";
1054
+ for (let c = 0; c < n; c++) {
1055
+ const h = this._cn[c], u = this._vertex(e, this._cv[c], this._ct[c], h, h >= 0 ? "file" : m, i, r, a);
1056
+ if (this._ci[c] = u, h < 0 && m === "computed") {
1057
+ const l = e.normals.data;
1058
+ l[u * 3] += i, l[u * 3 + 1] += r, l[u * 3 + 2] += a;
1059
+ }
1060
+ }
1061
+ for (let c = 1; c + 1 < n; c++)
1062
+ e.indices.push(this._ci[0]), e.indices.push(this._ci[c]), e.indices.push(this._ci[c + 1]);
1063
+ }
1064
+ _line(t) {
1065
+ const n = t.count - 1;
1066
+ n < 2 && t.fail("needs at least two line vertices");
1067
+ const e = this._builder("lines");
1068
+ this._count(e, n - 1);
1069
+ let o = -1;
1070
+ for (let i = 0; i < n; i++) {
1071
+ this._readCorner(t, i + 1, !1);
1072
+ const r = this._vertex(e, this._corner[0], this._corner[1], -1, "none", 0, 0, 0);
1073
+ o >= 0 && (e.indices.push(o), e.indices.push(r)), o = r;
1074
+ }
1075
+ }
1076
+ _points(t) {
1077
+ const n = t.count - 1;
1078
+ n < 1 && t.fail("needs at least one point");
1079
+ const e = this._builder("points");
1080
+ this._count(e, n);
1081
+ for (let o = 0; o < n; o++)
1082
+ this._readCorner(t, o + 1, !1), e.indices.push(this._vertex(e, this._corner[0], this._corner[1], -1, "none", 0, 0, 0));
1083
+ }
1084
+ _finish(t) {
1085
+ const n = t.normals?.take();
1086
+ if (n && t.computed) {
1087
+ const o = t.computed;
1088
+ for (let i = 0; i < o.length; i++) {
1089
+ const r = o.data[i] * 3;
1090
+ Ft(n, r, r + 3);
1091
+ }
1092
+ }
1093
+ const e = { positions: t.positions.take(), indices: zt(t.indices.data, t.indices.length, t.vertices), topology: t.topology };
1094
+ return n && (e.normals = n), t.uvs && (e.uvs = t.uvs.take()), t.colors && (e.colors = t.colors.take()), { name: t.group || t.object, object: t.object, group: t.group, material: t.material, geometry: e };
1095
+ }
1096
+ }
1097
+ function yt(s) {
1098
+ return s < 0 ? 0 : s > 1 ? 1 : s;
1099
+ }
1100
+ async function Re(s, t) {
1101
+ const n = new Pe(K(t, De, "OBJ parse"));
1102
+ return n.parse(Pt(s, n.limits.maxInputBytes, "OBJ"));
1103
+ }
1104
+ async function ns(s, t) {
1105
+ const { signal: n, materials: e, ...o } = K(t, Ne, "OBJ load"), i = W(o.limits), r = nt(s), a = await Re(await it(r, i.maxInputBytes, n, "OBJ"), o);
1106
+ if (e === !1 || a.materialLibraries.length === 0)
1107
+ return a;
1108
+ const m = [];
1109
+ for (const h of a.materialLibraries) {
1110
+ const u = nt(h.replaceAll("\\", "/"), r.href), l = await it(u, i.maxInputBytes, n, "MTL");
1111
+ m.push(await Ct(l, { limits: o.limits, baseUrl: u.href }));
1112
+ }
1113
+ const c = ge(m);
1114
+ return { ...a, materials: c, warnings: [...a.warnings, ...c.warnings] };
1115
+ }
1116
+ const Te = j({ limits: !0, flipV: !0, normals: !0 }), Ce = j({ limits: !0, flipV: !0, normals: !0, signal: !0 }), Mt = { char: 0, int8: 0, uchar: 1, uint8: 1, short: 2, int16: 2, ushort: 3, uint16: 3, int: 4, int32: 4, uint: 5, uint32: 5, float: 6, float32: 6, double: 7, float64: 7 }, Ut = [1, 1, 2, 2, 4, 4, 4, 8], ze = [127, 255, 32767, 65535, 2147483647, 4294967295, 1, 1], Fe = { x: 0, y: 1, z: 2, nx: 3, ny: 4, nz: 5, s: 6, u: 6, texture_u: 6, texture_s: 6, t: 7, v: 7, texture_v: 7, texture_t: 7, red: 8, diffuse_red: 8, r: 8, green: 9, diffuse_green: 9, g: 9, blue: 10, diffuse_blue: 10, b: 10, alpha: 11, diffuse_alpha: 11, a: 11 }, Dt = 65536;
1117
+ function z(s) {
1118
+ throw new N(lt(s), `[Nova3D] PLY ${s}.`);
1119
+ }
1120
+ function Ue(s, t, n) {
1121
+ const e = new DataView(s.buffer, s.byteOffset, s.byteLength), o = s.byteLength, i = {
1122
+ offset: t,
1123
+ read(r) {
1124
+ const a = i.offset, m = Ut[r];
1125
+ switch (a + m > o && z("data is truncated"), i.offset = a + m, r) {
1126
+ case 0:
1127
+ return e.getInt8(a);
1128
+ case 1:
1129
+ return s[a];
1130
+ case 2:
1131
+ return e.getInt16(a, n);
1132
+ case 3:
1133
+ return e.getUint16(a, n);
1134
+ case 4:
1135
+ return e.getInt32(a, n);
1136
+ case 5:
1137
+ return e.getUint32(a, n);
1138
+ case 6:
1139
+ return e.getFloat32(a, n);
1140
+ default:
1141
+ return e.getFloat64(a, n);
1142
+ }
1143
+ }
1144
+ };
1145
+ return i;
1146
+ }
1147
+ function Oe(s, t) {
1148
+ const n = new gt(s, "PLY", !1, t);
1149
+ let e = 0;
1150
+ return {
1151
+ read(o) {
1152
+ for (; e >= n.count; )
1153
+ n.next() || z("data is truncated"), e = 0;
1154
+ const i = n.number(e++);
1155
+ return o < 6 && !Number.isInteger(i) && n.fail("has a non-integer value for an integer property"), i;
1156
+ }
1157
+ };
1158
+ }
1159
+ function Be(s) {
1160
+ const t = Math.min(s.byteLength, 1048576);
1161
+ let n = "";
1162
+ for (let e = 0; e < t; e += 8192) {
1163
+ const o = Math.max(0, n.length - 16);
1164
+ n += String.fromCharCode(...s.subarray(e, Math.min(t, e + 8192)));
1165
+ const i = /\nend_header[ \t]*\r?\n/g;
1166
+ i.lastIndex = o;
1167
+ const r = i.exec(n);
1168
+ if (r) {
1169
+ const a = r.index + r[0].length;
1170
+ n = n.slice(0, a);
1171
+ const m = n.split(/\r?\n/);
1172
+ m[0].trim() !== "ply" && z('header must start with "ply"');
1173
+ let c;
1174
+ const h = [], u = [];
1175
+ for (const l of m.slice(1)) {
1176
+ const f = l.trim(), p = f.split(/\s+/);
1177
+ if (p[0] === "format")
1178
+ (!["ascii", "binary_little_endian", "binary_big_endian"].includes(p[1]) || p[2] !== "1.0") && z("format is not supported"), c = p[1];
1179
+ else if (p[0] === "comment" || p[0] === "obj_info")
1180
+ u.length < 1024 && u.push(f.slice(p[0].length).trim());
1181
+ else if (p[0] === "element") {
1182
+ const d = Number(p[2]);
1183
+ (p.length !== 3 || !Number.isSafeInteger(d) || d < 0 || h.length >= 64) && z("has an invalid element declaration"), h.push({ name: p[1], count: d, properties: [] });
1184
+ } else if (p[0] === "property") {
1185
+ const d = h.at(-1);
1186
+ (!d || d.properties.length >= 256) && z("has a property outside an element");
1187
+ const g = p[1] === "list", y = Mt[g ? p[3] : p[1]], v = g ? Mt[p[2]] : -1, b = g ? p[4] : p[2];
1188
+ (y === void 0 || v === void 0 || !b || p.length !== (g ? 5 : 3) || g && v >= 6) && z("has an invalid property declaration");
1189
+ const w = d.name === "vertex" && !g ? Fe[b] ?? -1 : d.name === "face" && g && (b === "vertex_indices" || b === "vertex_index") ? 0 : -1;
1190
+ d.properties.push({ name: b, type: y, count: v, role: w });
1191
+ } else f !== "" && p[0] !== "end_header" && z("header has an unknown line");
1192
+ }
1193
+ return c || z("header has no format"), { format: c, elements: h, comments: u, body: a };
1194
+ }
1195
+ }
1196
+ return z("header has no end_header within 1 MiB");
1197
+ }
1198
+ async function Ee(s, t) {
1199
+ t = K(t, Te, "PLY parse");
1200
+ const n = W(t.limits), e = t.flipV ?? !0, o = t.normals ?? "smooth";
1201
+ if (typeof e != "boolean" || o !== "smooth" && o !== "none")
1202
+ throw new N("invalid-option", "[Nova3D] Invalid PLY parse options.");
1203
+ const i = pt(s, n.maxInputBytes, "PLY"), { format: r, elements: a, comments: m, body: c } = Be(i), h = a.find((_) => _.name === "vertex");
1204
+ h || z("has no vertex element");
1205
+ const u = h.count;
1206
+ if (u > n.maxVertices)
1207
+ throw new N("budget", "[Nova3D] PLY exceeds the vertex limit.");
1208
+ const l = new Set(h.properties.map((_) => _.role));
1209
+ (!l.has(0) || !l.has(1) || !l.has(2)) && z("vertices need x, y and z");
1210
+ const f = a.find((_) => _.name === "face");
1211
+ if (f && f.count > 0 && !f.properties.some((_) => _.role === 0) && z("faces need a vertex_indices list"), f && f.count > n.maxPrimitives)
1212
+ throw new N("budget", "[Nova3D] PLY exceeds the primitive limit.");
1213
+ if (r !== "ascii") {
1214
+ let _ = 0;
1215
+ for (const M of a)
1216
+ _ += M.count * M.properties.reduce((T, Z) => T + Ut[Z.count >= 0 ? Z.count : Z.type], 0);
1217
+ _ > i.byteLength - c && z("data is truncated");
1218
+ }
1219
+ const p = new Float32Array(u * 3), d = l.has(3) && l.has(4) && l.has(5) ? new Float32Array(u * 3) : void 0, g = l.has(6) && l.has(7) ? new Float32Array(u * 2) : void 0, y = l.has(8) && l.has(9) && l.has(10) ? new Float32Array(u * 4).fill(1) : void 0, v = new _t(f ? Math.min(f.count * 3, 1 << 20) : 4);
1220
+ let b = 0, w = -1;
1221
+ const I = new Uint32Array(Dt), A = r === "ascii" ? Oe(new TextDecoder().decode(i.subarray(c)), 0) : Ue(i, c, r === "binary_little_endian");
1222
+ for (const _ of a) {
1223
+ const M = _ === h, T = _ === f;
1224
+ if (_.properties.length !== 0)
1225
+ for (let Z = 0; Z < _.count; Z++)
1226
+ for (const G of _.properties) {
1227
+ if (G.count >= 0) {
1228
+ const E = A.read(G.count);
1229
+ (!Number.isInteger(E) || E < 0 || E > Dt) && z("has an invalid list length");
1230
+ const ft = T && G.role === 0;
1231
+ for (let x = 0; x < E; x++) {
1232
+ const R = A.read(G.type);
1233
+ ft && ((!Number.isInteger(R) || R < 0) && z("has an invalid vertex index"), I[x] = R, w = Math.max(w, R));
1234
+ }
1235
+ if (ft) {
1236
+ if (E < 3 && z("face has fewer than three vertices"), b += E - 2, b > n.maxPrimitives)
1237
+ throw new N("budget", "[Nova3D] PLY exceeds the primitive limit.");
1238
+ for (let x = 1; x + 1 < E; x++)
1239
+ v.push(I[0]), v.push(I[x]), v.push(I[x + 1]);
1240
+ }
1241
+ continue;
1242
+ }
1243
+ const Q = A.read(G.type);
1244
+ if (!M || G.role < 0)
1245
+ continue;
1246
+ Number.isFinite(Q) || z("has a non-finite vertex value");
1247
+ const q = G.role;
1248
+ if (q < 3)
1249
+ p[Z * 3 + q] = Q;
1250
+ else if (q < 6)
1251
+ d && (d[Z * 3 + q - 3] = Q);
1252
+ else if (q < 8)
1253
+ g && (g[Z * 2 + q - 6] = q === 7 && e ? 1 - Q : Q);
1254
+ else if (y) {
1255
+ const E = Q / ze[G.type];
1256
+ y[Z * 4 + q - 8] = E < 0 ? 0 : E > 1 ? 1 : E;
1257
+ }
1258
+ }
1259
+ }
1260
+ w >= u && z("face references an undefined vertex");
1261
+ const k = { positions: p };
1262
+ b > 0 ? (k.indices = zt(v.data, v.length, u), d ? k.normals = d : o === "smooth" && (k.normals = Me(p, k.indices, v.length))) : (k.topology = "points", d && (k.normals = d)), g && (k.uvs = g), y && (k.colors = y);
1263
+ const P = [];
1264
+ for (const _ of a)
1265
+ if (_ !== h && _ !== f && _.count > 0)
1266
+ P.push(at("ignored", `PLY element ${JSON.stringify(_.name)} is not used and was ignored.`));
1267
+ else if (_ === h || _ === f)
1268
+ for (const M of _.properties)
1269
+ (_ === h ? M.role < 0 : M.role !== 0) && P.push(at("ignored", `PLY ${_.name} property ${JSON.stringify(M.name)} is not used and was ignored.`));
1270
+ return { format: r, comments: m, elements: a.map(({ name: _, count: M }) => ({ name: _, count: M })), warnings: P, parts: u ? [{ name: "", material: null, geometry: k }] : [] };
1271
+ }
1272
+ async function is(s, t) {
1273
+ const { signal: n, ...e } = K(t, Ce, "PLY load");
1274
+ return Ee(await it(nt(s), W(e.limits).maxInputBytes, n, "PLY"), e);
1275
+ }
1276
+ function Ot(s, t, n, e, o, i) {
1277
+ const r = s[t + 3] - s[t], a = s[t + 4] - s[t + 1], m = s[t + 5] - s[t + 2], c = s[t + 6] - s[t], h = s[t + 7] - s[t + 1], u = s[t + 8] - s[t + 2];
1278
+ let l = a * u - m * h, f = m * c - r * u, p = r * h - a * c, d = Math.hypot(l, f, p);
1279
+ (!(d > 0) || !Number.isFinite(d)) && (l = n, f = e, p = o, d = Math.hypot(l, f, p)), (!(d > 0) || !Number.isFinite(d)) && (l = 0, f = 0, p = 1, d = 1);
1280
+ for (let g = 0; g < 3; g++)
1281
+ i[t + g * 3] = l / d, i[t + g * 3 + 1] = f / d, i[t + g * 3 + 2] = p / d;
1282
+ }
1283
+ function Ve(s, t, n) {
1284
+ if (t > n.maxPrimitives || t * 3 > n.maxVertices)
1285
+ throw new N("budget", "[Nova3D] STL exceeds the vertex or primitive limit.");
1286
+ const e = new DataView(s.buffer, s.byteOffset, s.byteLength);
1287
+ let o;
1288
+ for (let f = 0; f + 10 <= 80; f++)
1289
+ if (s[f] === 67 && s[f + 1] === 79 && s[f + 2] === 76 && s[f + 3] === 79 && s[f + 4] === 82 && s[f + 5] === 61) {
1290
+ o = [s[f + 6] / 255, s[f + 7] / 255, s[f + 8] / 255, s[f + 9] / 255];
1291
+ break;
1292
+ }
1293
+ let i = !1;
1294
+ if (!o) {
1295
+ for (let f = 0; f < t; f++)
1296
+ if (e.getUint16(84 + f * 50 + 48, !0) & 32768) {
1297
+ i = !0;
1298
+ break;
1299
+ }
1300
+ }
1301
+ const r = !!o || i, a = new Float32Array(t * 9), m = new Float32Array(t * 9), c = r ? new Float32Array(t * 12) : void 0, h = o ?? [1, 1, 1, 1];
1302
+ for (let f = 0; f < t; f++) {
1303
+ const p = 84 + f * 50;
1304
+ for (let d = 0; d < 9; d++) {
1305
+ const g = e.getFloat32(p + 12 + d * 4, !0);
1306
+ if (!Number.isFinite(g))
1307
+ throw new N("format", "[Nova3D] STL has a non-finite vertex.");
1308
+ a[f * 9 + d] = g;
1309
+ }
1310
+ if (Ot(a, f * 9, e.getFloat32(p, !0), e.getFloat32(p + 4, !0), e.getFloat32(p + 8, !0), m), c) {
1311
+ const d = e.getUint16(p + 48, !0);
1312
+ let g = h[0], y = h[1], v = h[2];
1313
+ o && !(d & 32768) ? (g = (d & 31) / 31, y = (d >> 5 & 31) / 31, v = (d >> 10 & 31) / 31) : i && d & 32768 && (v = (d & 31) / 31, y = (d >> 5 & 31) / 31, g = (d >> 10 & 31) / 31);
1314
+ for (let b = f * 12; b < f * 12 + 12; b += 4)
1315
+ c[b] = g, c[b + 1] = y, c[b + 2] = v, c[b + 3] = h[3];
1316
+ }
1317
+ }
1318
+ const u = { positions: a, normals: m };
1319
+ c && (u.colors = c);
1320
+ const l = { format: "binary", hasColors: r, warnings: [], parts: t ? [{ name: "", material: null, geometry: u }] : [] };
1321
+ return o ? { ...l, defaultColor: o } : l;
1322
+ }
1323
+ function He(s, t) {
1324
+ const n = new gt(s, "STL", !1), e = [];
1325
+ let o = null, i = new J(), r = "";
1326
+ const a = new J(12);
1327
+ let m = 0, c = 0, h = 1, u = 0;
1328
+ for (; n.next(); )
1329
+ if (n.is(0, "solid"))
1330
+ o && n.fail("opens a solid inside a solid"), r = n.rest(1), o = new J(1024), i = new J(384);
1331
+ else if (n.is(0, "facet")) {
1332
+ o || n.fail("has a facet outside a solid"), a.length = 0;
1333
+ const l = n.count >= 5 && n.is(1, "normal");
1334
+ m = l ? n.number(2) : 0, c = l ? n.number(3) : 0, h = l ? n.number(4) : 1;
1335
+ } else if (n.is(0, "vertex"))
1336
+ o || n.fail("has a vertex outside a solid"), a.length >= 3 * 1024 && n.fail("has a facet with too many vertices"), a.push3(n.number(1), n.number(2), n.number(3));
1337
+ else if (n.is(0, "endfacet")) {
1338
+ o || n.fail("has an endfacet outside a solid");
1339
+ const l = a.length / 3;
1340
+ if (l < 3 && n.fail("has a facet with fewer than three vertices"), u += (l - 2) * 3, u > t.maxVertices || u / 3 > t.maxPrimitives)
1341
+ throw new N("budget", "[Nova3D] STL exceeds the vertex or primitive limit.");
1342
+ const f = a.data;
1343
+ for (let p = 1; p + 1 < l; p++)
1344
+ o.push3(f[0], f[1], f[2]), o.push3(f[p * 3], f[p * 3 + 1], f[p * 3 + 2]), o.push3(f[p * 3 + 3], f[p * 3 + 4], f[p * 3 + 5]), i.push3(m, c, h);
1345
+ a.length = 0;
1346
+ } else if (n.is(0, "endsolid")) {
1347
+ if (o || n.fail("has an endsolid outside a solid"), o.length) {
1348
+ if (e.length >= t.maxParts)
1349
+ throw new N("budget", "[Nova3D] STL exceeds the part limit.");
1350
+ const l = o.take(), f = new Float32Array(l.length), p = i.data;
1351
+ for (let d = 0, g = 0; d < l.length; d += 9, g += 3)
1352
+ Ot(l, d, p[g], p[g + 1], p[g + 2], f);
1353
+ e.push({ name: r, material: null, geometry: { positions: l, normals: f } });
1354
+ }
1355
+ o = null;
1356
+ }
1357
+ if (o)
1358
+ throw new N("format", "[Nova3D] STL solid is not closed.");
1359
+ return { format: "ascii", hasColors: !1, parts: e, warnings: [] };
1360
+ }
1361
+ async function Ze(s, t) {
1362
+ const n = W(K(t, St, "STL parse").limits), e = pt(s, n.maxInputBytes, "STL");
1363
+ if (e.byteLength >= 84) {
1364
+ const i = new DataView(e.buffer, e.byteOffset, e.byteLength).getUint32(80, !0), r = 84 + i * 50 === e.byteLength;
1365
+ let a = !1;
1366
+ if (!r) {
1367
+ let m = 0;
1368
+ for (; m < e.byteLength && e[m] <= 32; )
1369
+ m++;
1370
+ a = String.fromCharCode(...e.subarray(m, m + 5)).toLowerCase() === "solid";
1371
+ for (let c = 84; a && c < Math.min(e.byteLength, 1024); c++)
1372
+ a = e[c] < 128;
1373
+ }
1374
+ if (r || !a && 84 + i * 50 <= e.byteLength)
1375
+ return Ve(e, i, n);
1376
+ if (!a)
1377
+ throw new N("format", "[Nova3D] STL is neither ASCII nor a complete binary file.");
1378
+ }
1379
+ const o = typeof s == "string" ? s : new TextDecoder().decode(e);
1380
+ if (!/^\s*solid/i.test(o.slice(0, 256)))
1381
+ throw new N("format", "[Nova3D] STL is neither ASCII nor a complete binary file.");
1382
+ return He(o, n);
1383
+ }
1384
+ async function os(s, t) {
1385
+ const { limits: n, signal: e } = K(t, ct, "STL load");
1386
+ return Ze(await it(nt(s), W(n).maxInputBytes, e, "STL"), { limits: n });
1387
+ }
1388
+ export {
1389
+ ss as createHDREnvironment,
1390
+ ke as createHDRTexture,
1391
+ ts as createModelAsset,
1392
+ qe as loadEXR,
1393
+ je as loadHDR,
1394
+ Qe as loadMTL,
1395
+ es as loadMTLTextures,
1396
+ ns as loadOBJ,
1397
+ is as loadPLY,
1398
+ os as loadSTL,
1399
+ ye as mtlMaterialOptions,
1400
+ ae as parseEXR,
1401
+ ce as parseHDR,
1402
+ Ct as parseMTL,
1403
+ Re as parseOBJ,
1404
+ Ee as parsePLY,
1405
+ Ze as parseSTL
1406
+ };