@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,1043 @@
1
+ import { N as m } from "../Errors-B2ekO9bZ.js";
2
+ import { c as wt, o as bt } from "../Options-CajE7LLJ.js";
3
+ import { w as vt } from "../Ready-BzyhRtjD.js";
4
+ import { N as At } from "../Mesh-BaRxAAJq.js";
5
+ import { N as St } from "../Node-QfgAE2_v.js";
6
+ import { s as Ft } from "../Scene-CDfNgf9I.js";
7
+ import { p as Q, l as J } from "../Color-vuv9UnoY.js";
8
+ const E = 1e20;
9
+ function nt(i, t, e, s, n, o, r) {
10
+ o[0] = 0, r[0] = -E, r[1] = E, n[0] = i[t];
11
+ for (let l = 1, h = 0; l < s; l++) {
12
+ const a = i[t + l * e];
13
+ n[l] = a;
14
+ const d = l * l;
15
+ let f;
16
+ do {
17
+ const c = o[h];
18
+ f = (a - n[c] + d - c * c) / (l - c) / 2;
19
+ } while (f <= r[h] && --h > -1);
20
+ h++, o[h] = l, r[h] = f, r[h + 1] = E;
21
+ }
22
+ for (let l = 0, h = 0; l < s; l++) {
23
+ for (; r[h + 1] < l; )
24
+ h++;
25
+ const a = o[h], d = l - a;
26
+ i[t + l * e] = n[a] + d * d;
27
+ }
28
+ }
29
+ function ot(i, t, e, s, n, o, r, l, h) {
30
+ for (let a = t; a < t + s; a++)
31
+ nt(i, e * o + a, o, n, r, l, h);
32
+ for (let a = e; a < e + n; a++)
33
+ nt(i, a * o + t, 1, s, r, l, h);
34
+ }
35
+ class zt {
36
+ _outer;
37
+ _inner;
38
+ _f;
39
+ _v;
40
+ _z;
41
+ constructor(t) {
42
+ this._outer = new Float64Array(t * t), this._inner = new Float64Array(t * t), this._f = new Float64Array(t), this._v = new Int32Array(t), this._z = new Float64Array(t + 1);
43
+ }
44
+ /**
45
+ * Converts RGBA coverage `pixels` (alpha used, `inkWidth`×`inkHeight` rows from
46
+ * the top) into a field of (ink + 2·buffer) cells written to channel `channel`
47
+ * of the RGBA8 `target` at texel (`x`, `y`) of a `targetWidth`-wide image.
48
+ */
49
+ build(t, e, s, n, o, r, l, h, a, d, f) {
50
+ const c = e + 2 * n, x = s + 2 * n, _ = c * x, g = Math.max(c, x);
51
+ (_ > this._outer.length || g > this._f.length) && (this._outer = new Float64Array(_), this._inner = new Float64Array(_), this._f = new Float64Array(g), this._v = new Int32Array(g), this._z = new Float64Array(g + 1));
52
+ const z = this._outer, b = this._inner;
53
+ z.fill(E, 0, _), b.fill(0, 0, _);
54
+ for (let v = 0; v < s; v++)
55
+ for (let k = 0; k < e; k++) {
56
+ const C = t[(v * e + k) * 4 + 3] / 255;
57
+ if (C === 0)
58
+ continue;
59
+ const D = (v + n) * c + k + n;
60
+ if (C === 1)
61
+ z[D] = 0, b[D] = E;
62
+ else {
63
+ const u = 0.5 - C;
64
+ z[D] = u > 0 ? u * u : 0, b[D] = u < 0 ? u * u : 0;
65
+ }
66
+ }
67
+ ot(z, 0, 0, c, x, c, this._f, this._v, this._z), ot(b, 0, 0, c, x, c, this._f, this._v, this._z);
68
+ const N = 255 / o, T = 255 - 255 * r;
69
+ for (let v = 0; v < x; v++) {
70
+ let k = v * c, C = ((d + v) * h + a) * 4 + f;
71
+ for (let D = 0; D < c; D++, k++, C += 4) {
72
+ const u = Math.round(T - (Math.sqrt(z[k]) - Math.sqrt(b[k])) * N);
73
+ l[C] = u < 0 ? 0 : u > 255 ? 255 : u;
74
+ }
75
+ }
76
+ }
77
+ }
78
+ const kt = bt({ signal: !0, text: !0 }), R = 15, Mt = /* @__PURE__ */ new Set(["family", "weight", "style", "sdfSize", "radius", "cutoff", "buffer", "atlasWidth", "maxAtlasHeight", "kerning", "rasterizer"]), V = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap();
79
+ let Dt = 0;
80
+ const Z = 1;
81
+ class Nt {
82
+ _canvas;
83
+ _context;
84
+ _font = "";
85
+ constructor() {
86
+ this._canvas = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(64, 64) : document.createElement("canvas");
87
+ const t = this._canvas.getContext("2d", { willReadFrequently: !0 });
88
+ if (!t)
89
+ throw new m("unsupported", "[Nova3D] Text needs a Canvas 2D context; pass a font rasterizer.");
90
+ this._context = t;
91
+ }
92
+ measureFont(t) {
93
+ const e = this._use(t).measureText("M"), s = Number.parseFloat(/(\d+(?:\.\d+)?)px/.exec(t)?.[1] ?? "16"), n = e.fontBoundingBoxAscent, o = e.fontBoundingBoxDescent;
94
+ return Number.isFinite(n) && Number.isFinite(o) && n + o > 0 ? { ascent: n, descent: o } : { ascent: s * 0.8, descent: s * 0.2 };
95
+ }
96
+ measureGlyph(t, e) {
97
+ const s = this._use(e).measureText(t);
98
+ return { advance: s.width, left: s.actualBoundingBoxLeft || 0, right: s.actualBoundingBoxRight || 0, ascent: s.actualBoundingBoxAscent || 0, descent: s.actualBoundingBoxDescent || 0 };
99
+ }
100
+ measureWidth(t, e) {
101
+ return this._use(e).measureText(t).width;
102
+ }
103
+ rasterize(t, e, s, n, o, r) {
104
+ const l = this._canvas;
105
+ (l.width < o || l.height < r) && (l.width = Math.max(l.width, o), l.height = Math.max(l.height, r), this._font = "");
106
+ const h = this._use(e);
107
+ return h.clearRect(0, 0, o, r), h.fillText(t, s, n), h.getImageData(0, 0, o, r).data;
108
+ }
109
+ _use(t) {
110
+ const e = this._context;
111
+ return this._font !== t && (e.font = t, e.textBaseline = "alphabetic", e.textAlign = "left", e.fillStyle = "#000", "fontKerning" in e && (e.fontKerning = "normal"), this._font = t), e;
112
+ }
113
+ }
114
+ let Tt;
115
+ function K(i, t, e, s) {
116
+ if (!Number.isSafeInteger(i) || i < e || i > s)
117
+ throw new m("invalid-option", `[Nova3D] Font ${t} must be an integer in [${e}, ${s}].`);
118
+ return i;
119
+ }
120
+ function Ct(i) {
121
+ if (!i || typeof i != "object")
122
+ throw new m("invalid-option", "[Nova3D] Font options must be an object.");
123
+ for (const _ of Object.keys(i))
124
+ if (!Mt.has(_))
125
+ throw new m("invalid-option", `[Nova3D] Unknown font option ${_}.`);
126
+ const t = i.family ?? "sans-serif", e = String(i.weight ?? "normal"), s = i.style ?? "normal";
127
+ if (typeof t != "string" || t.trim() === "" || /[;{}]/.test(t) || !/^(?:normal|bold|bolder|lighter|[1-9]\d{0,2})$/.test(e) || !["normal", "italic", "oblique"].includes(s))
128
+ throw new m("invalid-option", "[Nova3D] Font family must be a CSS family list, weight a CSS weight and style normal, italic or oblique.");
129
+ const n = K(i.sdfSize ?? 48, "sdfSize", 8, 256), o = i.radius ?? n / 4, r = i.cutoff ?? 0.25;
130
+ if (!Number.isFinite(o) || o <= 0 || o > n || !Number.isFinite(r) || r < 0 || r >= 1)
131
+ throw new m("invalid-option", "[Nova3D] Font radius must be in (0, sdfSize] and cutoff in [0, 1).");
132
+ const l = K(i.buffer ?? Math.ceil(o * (1 - r)) + 1, "buffer", 0, n), h = K(i.atlasWidth ?? 1024, "atlasWidth", 64, 8192), a = K(i.maxAtlasHeight ?? 4096, "maxAtlasHeight", 64, 16384), d = i.kerning ?? !0;
133
+ if (typeof d != "boolean")
134
+ throw new m("invalid-option", "[Nova3D] Font kerning must be boolean.");
135
+ const f = i.rasterizer;
136
+ if (f !== void 0 && (!f || typeof f.rasterize != "function" || typeof f.measureGlyph != "function" || typeof f.measureFont != "function" || typeof f.measureWidth != "function"))
137
+ throw new m("invalid-option", "[Nova3D] Font rasterizer must implement measureFont, measureGlyph, measureWidth and rasterize.");
138
+ if (2 * n + 2 * l + Z > h)
139
+ throw new m("invalid-option", "[Nova3D] Font atlasWidth must hold a glyph cell of 2·sdfSize + 2·buffer texels.");
140
+ let c = 0;
141
+ f && (c = rt.get(f) ?? ++Dt, rt.set(f, c));
142
+ const x = [t, e, s, n, o, r, l, h, a, d, c].join("|");
143
+ return { family: t, weight: e, style: s, sdfSize: n, radius: o, cutoff: r, buffer: l, atlasWidth: h, maxAtlasHeight: a, kerning: d, rasterizer: f, key: x };
144
+ }
145
+ class Wt {
146
+ family;
147
+ weight;
148
+ style;
149
+ sdfSize;
150
+ radius;
151
+ cutoff;
152
+ buffer;
153
+ kerning;
154
+ /** CSS font shorthand at the SDF size. */
155
+ font;
156
+ /** Atlas texels: SDF bytes in R, G, B and A, one glyph layer per channel. */
157
+ texture;
158
+ _app;
159
+ _key;
160
+ _rasterizer;
161
+ _builder;
162
+ _maxHeight;
163
+ _width;
164
+ _height;
165
+ _pixels;
166
+ _ids = /* @__PURE__ */ new Map();
167
+ _info = new Float32Array(R * 64);
168
+ _count = 0;
169
+ _kerning = /* @__PURE__ */ new Map();
170
+ /** Per channel: shelf y, height and fill x as triples, then the channel bottom. */
171
+ _shelves = [[], [], [], []];
172
+ _bottoms = [0, 0, 0, 0];
173
+ _dirtyTop = 1 / 0;
174
+ _dirtyBottom = -1 / 0;
175
+ _ascent = 0.8;
176
+ _descent = 0.2;
177
+ _refs = 0;
178
+ _destroyed = !1;
179
+ _users = /* @__PURE__ */ new Set();
180
+ _detach;
181
+ constructor(t, e) {
182
+ this._app = t, this._key = e.key, this.family = e.family, this.weight = e.weight, this.style = e.style, this.sdfSize = e.sdfSize, this.radius = e.radius, this.cutoff = e.cutoff, this.buffer = e.buffer, this.kerning = e.kerning, this.font = `${e.style} ${e.weight} ${e.sdfSize}px ${e.family}`, this._rasterizer = e.rasterizer ?? (Tt ??= new Nt()), this._builder = new zt(2 * e.sdfSize + 2 * e.buffer), this._width = e.atlasWidth, this._maxHeight = e.maxAtlasHeight, this._height = Math.min(256, this._maxHeight), this._pixels = new Uint8Array(this._width * this._height * 4), this.texture = t.createTexture(this._textureOptions()), this._measureFont(), this._detach = t._own(() => this._teardown());
183
+ }
184
+ /** Atlas width in texels. */
185
+ get width() {
186
+ return this._width;
187
+ }
188
+ /** Current atlas height in texels; doubles when glyphs no longer fit. */
189
+ get height() {
190
+ return this._height;
191
+ }
192
+ /** Rasterized glyphs, white space included. */
193
+ get glyphCount() {
194
+ return this._count;
195
+ }
196
+ /** Handles keeping the atlas alive. */
197
+ get refCount() {
198
+ return this._refs;
199
+ }
200
+ get destroyed() {
201
+ return this._destroyed;
202
+ }
203
+ /** Font ascent in em. */
204
+ get ascent() {
205
+ return this._ascent;
206
+ }
207
+ /** Font descent in em. */
208
+ get descent() {
209
+ return this._descent;
210
+ }
211
+ /** Rasterizes the glyphs of `text` now, so later layouts upload nothing. */
212
+ prepare(t) {
213
+ if (this._assertAlive(), typeof t != "string")
214
+ throw new m("invalid-option", "[Nova3D] prepare takes a string.");
215
+ for (let e = 0; e < t.length; ) {
216
+ const s = t.codePointAt(e);
217
+ s !== 10 && s !== 13 && this._glyph(s), e += s > 65535 ? 2 : 1;
218
+ }
219
+ this._flush();
220
+ }
221
+ /**
222
+ * Drops every glyph and re-rasterizes on demand, then lays out every text
223
+ * again: call it after a web font finished loading.
224
+ */
225
+ refresh() {
226
+ this._assertAlive(), this._ids.clear(), this._kerning.clear(), this._count = 0;
227
+ for (let t = 0; t < 4; t++)
228
+ this._shelves[t].length = 0, this._bottoms[t] = 0;
229
+ this._pixels.fill(0), this.texture.updateRegion(0, 0, this._width, this._height, this._pixels), this._dirtyTop = 1 / 0, this._dirtyBottom = -1 / 0, this._measureFont();
230
+ for (const t of [...this._users])
231
+ t._atlasChanged("refresh");
232
+ }
233
+ /**
234
+ * Waits for `document.fonts` to load the face (for `text` when given), then
235
+ * refreshes. Resolves without a refresh where the Font Loading API is missing.
236
+ */
237
+ async whenReady(t = {}) {
238
+ wt(t, kt, "font ready"), this._assertAlive();
239
+ const e = typeof document < "u" ? document.fonts : void 0;
240
+ !e || typeof e.load != "function" || (await vt(e.load(this.font, t.text), t.signal), this._destroyed || this.refresh());
241
+ }
242
+ /** Drops one handle's reference; the last one frees the texture. */
243
+ _release() {
244
+ this._destroyed || (this._refs--, this._refs <= 0 && this._destroy());
245
+ }
246
+ _retain() {
247
+ this._assertAlive(), this._refs++;
248
+ }
249
+ /** @internal */
250
+ _addUser(t) {
251
+ this._users.add(t);
252
+ }
253
+ /** @internal */
254
+ _removeUser(t) {
255
+ this._users.delete(t);
256
+ }
257
+ /** @internal */
258
+ _owner() {
259
+ return this._app;
260
+ }
261
+ /** Glyph records, `GLYPH_STRIDE` floats per id; reallocated as glyphs are added. @internal */
262
+ _records() {
263
+ return this._info;
264
+ }
265
+ /** Advance of a code point in em, rasterizing it on first use. @internal */
266
+ _advance(t) {
267
+ const e = this._glyph(t);
268
+ return this._info[e * R];
269
+ }
270
+ /** Pair kerning in em from measured widths, cached per pair. @internal */
271
+ _pairKerning(t, e) {
272
+ if (!this.kerning || t === 10 || e === 10 || t === 9 || e === 9)
273
+ return 0;
274
+ const s = t * 1114112 + e;
275
+ let n = this._kerning.get(s);
276
+ if (n === void 0) {
277
+ const o = this.font;
278
+ n = (this._rasterizer.measureWidth(String.fromCodePoint(t, e), o) - this._advance(t) * this.sdfSize - this._advance(e) * this.sdfSize) / this.sdfSize, (!Number.isFinite(n) || Math.abs(n) < 1e-3) && (n = 0), this._kerning.set(s, n);
279
+ }
280
+ return n;
281
+ }
282
+ /** Glyph id of a code point, rasterizing and packing it on first use. @internal */
283
+ _glyph(t) {
284
+ const e = this._ids.get(t);
285
+ if (e !== void 0)
286
+ return e;
287
+ this._assertAlive();
288
+ const s = String.fromCodePoint(t), n = this.font, o = this.sdfSize, r = this._rasterizer.measureGlyph(s, n), l = this._count;
289
+ if ((l + 1) * R > this._info.length) {
290
+ const b = new Float32Array(this._info.length * 2);
291
+ b.set(this._info), this._info = b;
292
+ }
293
+ const h = this._info, a = l * R;
294
+ h.fill(0, a, a + R), h[a] = Number.isFinite(r.advance) ? r.advance / o : 0;
295
+ const d = 2 * o, f = Math.min(d, Math.max(-d, Math.ceil(r.left) || 0)), c = Math.min(d - f, Math.max(-f, Math.ceil(r.right) || 0)), x = Math.min(d, Math.max(-d, Math.ceil(r.ascent) || 0)), _ = Math.min(d - x, Math.max(-x, Math.ceil(r.descent) || 0)), g = f + c, z = x + _;
296
+ if (g > 0 && z > 0 && Number.isFinite(g + z)) {
297
+ const b = this.buffer, N = g + 2 * b, T = z + 2 * b, v = this._place(N, T), k = this._rasterizer.rasterize(s, n, f, x, g, z);
298
+ if (k.length < g * z * 4)
299
+ throw new m("invalid-option", "[Nova3D] Font rasterizer returned too few pixels.");
300
+ this._builder.build(k, g, z, b, this.radius, this.cutoff, this._pixels, this._width, v[0], v[1], v[2]), this._dirtyTop = Math.min(this._dirtyTop, v[1]), this._dirtyBottom = Math.max(this._dirtyBottom, v[1] + T), h[a + 1] = (-f - b) / o, h[a + 2] = (-_ - b) / o, h[a + 3] = (c + b) / o, h[a + 4] = (x + b) / o, h[a + 5] = v[0], h[a + 6] = v[1], h[a + 7] = N, h[a + 8] = T, h[a + 9] = v[2], h[a + 10] = -f / o, h[a + 11] = -_ / o, h[a + 12] = c / o, h[a + 13] = x / o;
301
+ }
302
+ return this._ids.set(t, l), this._count++, l;
303
+ }
304
+ /** Uploads the rows touched by new glyphs as one region. @internal */
305
+ _flush() {
306
+ if (this._dirtyBottom <= this._dirtyTop || this._destroyed)
307
+ return;
308
+ const t = this._dirtyTop, e = this._dirtyBottom - t, s = this._width * 4;
309
+ this.texture.updateRegion(0, t, this._width, e, this._pixels.subarray(t * s, (t + e) * s)), this._dirtyTop = 1 / 0, this._dirtyBottom = -1 / 0;
310
+ }
311
+ /** Shelf-packs a cell into the first channel with room, growing the atlas when none has. */
312
+ _placement = [0, 0, 0];
313
+ _place(t, e) {
314
+ const s = t + Z, n = e + Z;
315
+ for (; ; ) {
316
+ for (let o = 0; o < 4; o++) {
317
+ const r = this._shelves[o];
318
+ let l = -1;
319
+ for (let h = 0; h < r.length; h += 3) {
320
+ const a = r[h + 1];
321
+ a >= n && a <= n * 1.3 + 2 && r[h + 2] + s <= this._width && (l < 0 || a < r[l + 1]) && (l = h);
322
+ }
323
+ if (l < 0 && this._bottoms[o] + n <= this._height && (l = r.length, r.push(this._bottoms[o], n, 0), this._bottoms[o] += n), l >= 0) {
324
+ const h = this._placement;
325
+ return h[0] = r[l + 2], h[1] = r[l], h[2] = o, r[l + 2] += s, h;
326
+ }
327
+ }
328
+ this._grow();
329
+ }
330
+ }
331
+ /** Doubles the atlas height; the texture is reallocated once and every text gets the new size. */
332
+ _grow() {
333
+ if (this._height >= this._maxHeight)
334
+ throw new m("budget", `[Nova3D] Font atlas ${this.font} is full at ${this._width}×${this._height}; raise maxAtlasHeight or use fewer glyphs.`);
335
+ this._flush();
336
+ const t = Math.min(this._maxHeight, this._height * 2), e = new Uint8Array(this._width * t * 4);
337
+ e.set(this._pixels), this._pixels = e, this._height = t, this.texture.setSource(this._textureOptions());
338
+ for (const s of [...this._users])
339
+ s._atlasChanged("resize");
340
+ }
341
+ _textureOptions() {
342
+ return { width: this._width, height: this._height, data: this._pixels, colorSpace: "linear", filter: "linear", mipmaps: !1 };
343
+ }
344
+ _measureFont() {
345
+ const t = this._rasterizer.measureFont(this.font), e = t.ascent / this.sdfSize, s = t.descent / this.sdfSize;
346
+ Number.isFinite(e) && Number.isFinite(s) && e + s > 0 && (this._ascent = e, this._descent = s);
347
+ }
348
+ /** App teardown: texts go first so the texture has no material users left. */
349
+ _teardown() {
350
+ for (const t of [...this._users])
351
+ t.destroy();
352
+ this._destroy();
353
+ }
354
+ _destroy() {
355
+ if (this._destroyed)
356
+ return;
357
+ this._destroyed = !0, this._refs = 0, this._detach();
358
+ const t = V.get(this._app);
359
+ t?.get(this._key) === this && t.delete(this._key), this.texture.destroyed || this.texture.destroy(), this._ids.clear(), this._kerning.clear();
360
+ }
361
+ _assertAlive() {
362
+ if (this._destroyed)
363
+ throw new m("destroyed", "[Nova3D] Font atlas is destroyed.");
364
+ }
365
+ }
366
+ class X {
367
+ /** @internal */
368
+ _atlas;
369
+ _textOwned;
370
+ _destroyed = !1;
371
+ /** @internal */
372
+ constructor(t, e = !1) {
373
+ t._retain(), this._atlas = t, this._textOwned = e;
374
+ }
375
+ get family() {
376
+ return this._atlas.family;
377
+ }
378
+ get weight() {
379
+ return this._atlas.weight;
380
+ }
381
+ get style() {
382
+ return this._atlas.style;
383
+ }
384
+ get sdfSize() {
385
+ return this._atlas.sdfSize;
386
+ }
387
+ get radius() {
388
+ return this._atlas.radius;
389
+ }
390
+ get cutoff() {
391
+ return this._atlas.cutoff;
392
+ }
393
+ get buffer() {
394
+ return this._atlas.buffer;
395
+ }
396
+ get kerning() {
397
+ return this._atlas.kerning;
398
+ }
399
+ /** CSS font shorthand at the SDF size. */
400
+ get font() {
401
+ return this._atlas.font;
402
+ }
403
+ /** Atlas texels: SDF bytes in R, G, B and A, one glyph layer per channel. */
404
+ get texture() {
405
+ return this._atlas.texture;
406
+ }
407
+ /** Atlas width in texels. */
408
+ get width() {
409
+ return this._atlas.width;
410
+ }
411
+ /** Current atlas height in texels; doubles when glyphs no longer fit. */
412
+ get height() {
413
+ return this._atlas.height;
414
+ }
415
+ /** Rasterized glyphs, white space included. */
416
+ get glyphCount() {
417
+ return this._atlas.glyphCount;
418
+ }
419
+ /** Live handles of the shared atlas, the ones texts hold included. */
420
+ get refCount() {
421
+ return this._atlas.refCount;
422
+ }
423
+ /** Font ascent in em. */
424
+ get ascent() {
425
+ return this._atlas.ascent;
426
+ }
427
+ /** Font descent in em. */
428
+ get descent() {
429
+ return this._atlas.descent;
430
+ }
431
+ /** True after `destroy()`, or once the app destroyed the shared atlas. */
432
+ get destroyed() {
433
+ return this._destroyed || this._atlas.destroyed;
434
+ }
435
+ /** Rasterizes the glyphs of `text` now, so later layouts upload nothing. */
436
+ prepare(t) {
437
+ this._assertAlive(), this._atlas.prepare(t);
438
+ }
439
+ /**
440
+ * Drops every glyph and re-rasterizes on demand, then lays out every text of
441
+ * the atlas again: call it after a web font finished loading.
442
+ */
443
+ refresh() {
444
+ this._assertAlive(), this._atlas.refresh();
445
+ }
446
+ /**
447
+ * Waits for `document.fonts` to load the face (for `text` when given), then
448
+ * refreshes. Resolves without a refresh where the Font Loading API is missing.
449
+ */
450
+ whenReady(t) {
451
+ return this._assertAlive(), this._atlas.whenReady(t);
452
+ }
453
+ /**
454
+ * Releases this handle; the shared atlas is freed when no handle is left. The
455
+ * handle of a text belongs to the text: destroy the text instead.
456
+ */
457
+ destroy() {
458
+ if (!this._destroyed) {
459
+ if (this._textOwned)
460
+ throw new m("owner", "[Nova3D] The font atlas of a text is released by destroying the text.");
461
+ this._drop();
462
+ }
463
+ }
464
+ /**
465
+ * Releases the handle of a destroyed text.
466
+ * @internal
467
+ */
468
+ _drop() {
469
+ this._destroyed || (this._destroyed = !0, this._atlas._release());
470
+ }
471
+ _assertAlive() {
472
+ if (this.destroyed)
473
+ throw new m("destroyed", "[Nova3D] Font atlas is destroyed.");
474
+ }
475
+ }
476
+ function se(i, t = {}) {
477
+ return new X(dt(i, t));
478
+ }
479
+ function dt(i, t) {
480
+ if (!i || i.destroyed || typeof i.createTexture != "function")
481
+ throw new m("destroyed", "[Nova3D] Font atlases need a live app.");
482
+ const e = Ct(t);
483
+ let s = V.get(i);
484
+ s || (s = /* @__PURE__ */ new Map(), V.set(i, s));
485
+ let n = s.get(e.key);
486
+ return (!n || n.destroyed) && (n = new Wt(i, e), s.set(e.key, n)), n;
487
+ }
488
+ const P = 10, ft = 9, ut = 32;
489
+ function q(i) {
490
+ return i === ut || i === ft || i === 12288 || i === 5760 || i === 8287 || i >= 8192 && i <= 8202 && i !== 8199;
491
+ }
492
+ function at(i) {
493
+ return i >= 11904 && i <= 40959 || i >= 44032 && i <= 55215 || i >= 63744 && i <= 64255 || i >= 65280 && i <= 65519 || i >= 131072 && i <= 262143;
494
+ }
495
+ const Bt = new Set(Array.from("!%),.:;?]}¢°·’”†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?]}~ーぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ」』】〉》", (i) => i.codePointAt(0))), It = new Set(Array.from("([{£¥‘“‵〈《「『【〔〖〝﹙﹛$([{£¥", (i) => i.codePointAt(0)));
496
+ function Ot(i, t) {
497
+ return q(t) || Bt.has(t) || It.has(i) ? !1 : q(i) || i === 8203 || i === 45 || i === 8208 || i === 8211 ? !0 : at(i) || at(t);
498
+ }
499
+ class Ut {
500
+ count = 0;
501
+ lineCount = 0;
502
+ codePoints = new Uint32Array(16);
503
+ charIndices = new Uint32Array(16);
504
+ lines = new Uint32Array(16);
505
+ x = new Float32Array(16);
506
+ y = new Float32Array(16);
507
+ advances = new Float32Array(16);
508
+ lineStart = new Uint32Array(4);
509
+ lineEnd = new Uint32Array(4);
510
+ lineWidth = new Float64Array(4);
511
+ lineHard = new Uint8Array(4);
512
+ /** minX, minY, maxX, maxY of the line boxes. */
513
+ blockBounds = new Float64Array(4);
514
+ /** Grows glyph storage to at least `size` entries, keeping contents. */
515
+ reserve(t) {
516
+ if (t <= this.codePoints.length)
517
+ return;
518
+ const e = Math.max(t, this.codePoints.length * 2), s = (n, o) => {
519
+ const r = o(e);
520
+ return r.set(n), r;
521
+ };
522
+ this.codePoints = s(this.codePoints, (n) => new Uint32Array(n)), this.charIndices = s(this.charIndices, (n) => new Uint32Array(n)), this.lines = s(this.lines, (n) => new Uint32Array(n)), this.x = s(this.x, (n) => new Float32Array(n)), this.y = s(this.y, (n) => new Float32Array(n)), this.advances = s(this.advances, (n) => new Float32Array(n));
523
+ }
524
+ /** Appends a line record. @internal */
525
+ _line(t, e, s, n) {
526
+ const o = this.lineCount;
527
+ if (o >= this.lineStart.length) {
528
+ const r = this.lineStart.length * 2, l = new Uint32Array(r);
529
+ l.set(this.lineStart), this.lineStart = l;
530
+ const h = new Uint32Array(r);
531
+ h.set(this.lineEnd), this.lineEnd = h;
532
+ const a = new Float64Array(r);
533
+ a.set(this.lineWidth), this.lineWidth = a;
534
+ const d = new Uint8Array(r);
535
+ d.set(this.lineHard), this.lineHard = d;
536
+ }
537
+ this.lineStart[o] = t, this.lineEnd[o] = e, this.lineWidth[o] = s, this.lineHard[o] = n ? 1 : 0, this.lineCount++;
538
+ }
539
+ }
540
+ function Ht(i, t, e, s) {
541
+ s.reserve(i.length);
542
+ let n = 0;
543
+ for (let u = 0; u < i.length; ) {
544
+ const A = i.codePointAt(u);
545
+ A !== 13 && (s.codePoints[n] = A, s.charIndices[n] = u, n++), u += A > 65535 ? 2 : 1;
546
+ }
547
+ s.count = n, s.lineCount = 0;
548
+ const o = t.fontSize, r = t.letterSpacing * o, l = s.codePoints, h = s.advances, a = s.x;
549
+ for (let u = 0; u < n; u++) {
550
+ const A = l[u];
551
+ h[u] = A === P ? 0 : (A === ft ? e.advance(ut) * 4 : e.advance(A)) * o + r;
552
+ }
553
+ const d = t.maxWidth !== 1 / 0, f = t.maxWidth;
554
+ let c = 0;
555
+ for (; ; ) {
556
+ let u = 0, A = -1, p = n, S = !1;
557
+ for (let y = c; y < n; y++) {
558
+ const w = l[y];
559
+ if (w === P) {
560
+ a[y] = u, p = y + 1, S = !0;
561
+ break;
562
+ }
563
+ if (y > c) {
564
+ const B = l[y - 1];
565
+ Ot(B, w) && (A = y), u += e.kerning(B, w) * o;
566
+ }
567
+ if (d && y > c && !q(w) && u + h[y] > f) {
568
+ if (A > c) {
569
+ p = A;
570
+ break;
571
+ }
572
+ if (t.breakWord) {
573
+ p = y;
574
+ break;
575
+ }
576
+ }
577
+ a[y] = u, u += h[y];
578
+ }
579
+ let F = 0;
580
+ for (let y = c; y < p; y++) {
581
+ const w = l[y];
582
+ w !== P && !q(w) && (F = Math.max(F, a[y] + h[y]));
583
+ }
584
+ for (let y = c; y < p; y++)
585
+ s.lines[y] = s.lineCount;
586
+ if (s._line(c, p, F, S), c = p, c >= n) {
587
+ S && s._line(n, n, 0, !1);
588
+ break;
589
+ }
590
+ }
591
+ let x = 0;
592
+ for (let u = 0; u < s.lineCount; u++)
593
+ x = Math.max(x, s.lineWidth[u]);
594
+ const _ = t.lineHeight * o, g = (_ - (t.ascent + t.descent) * o) / 2 + t.ascent * o, z = s.lineCount * _, b = t.anchorX, N = t.anchorY, T = b === "left" ? 0 : b === "center" ? -x / 2 : b === "right" ? -x : -b, v = N === "top" ? 0 : N === "baseline" ? g : N === "middle" ? z / 2 : N === "bottom" ? z : N, k = t.textAlign, C = s.y;
595
+ for (let u = 0; u < s.lineCount; u++) {
596
+ const A = s.lineStart[u], p = s.lineEnd[u], S = x - s.lineWidth[u], F = (k === "center" ? S / 2 : k === "right" ? S : 0) + T, y = v - u * _ - g;
597
+ let w = -1, B = 0;
598
+ if (k === "justify" && S > 0 && s.lineHard[u] === 0 && u < s.lineCount - 1) {
599
+ for (let M = A; M < p; M++)
600
+ !q(l[M]) && l[M] !== P && (w = M);
601
+ for (let M = A; M < w; M++)
602
+ q(l[M]) && B++;
603
+ }
604
+ const j = B > 0 ? B : w - A, U = j > 0 ? S / j : 0;
605
+ let H = 0;
606
+ for (let M = A; M < p; M++)
607
+ a[M] += F + H, C[M] = y, U > 0 && M < w && (B === 0 || q(l[M])) ? H += U : U > 0 && M >= w && (H = S);
608
+ }
609
+ const D = s.blockBounds;
610
+ D[0] = T, D[1] = v - z, D[2] = T + x, D[3] = v;
611
+ }
612
+ const tt = 65536, $t = `uniform float textBillboard;
613
+ out vec2 vTexel;
614
+ flat out vec4 vChannel;
615
+ void main(){
616
+ float channel=floor(uv.x/${tt.toFixed(1)});
617
+ vTexel=vec2(uv.x-channel*${tt.toFixed(1)},uv.y);
618
+ vChannel=vec4(equal(vec4(channel),vec4(0.0,1.0,2.0,3.0)));
619
+ if(textBillboard>0.5){
620
+ vec4 center=viewMatrix*(modelMatrix*vec4(0.0,0.0,0.0,1.0));
621
+ vec2 scale=vec2(length(modelMatrix[0].xyz),length(modelMatrix[1].xyz));
622
+ gl_Position=projectionMatrix*(center+vec4(position.xy*scale,0.0,0.0));
623
+ }else{
624
+ gl_Position=viewProjectionMatrix*(modelMatrix*vec4(position,1.0));
625
+ }
626
+ }`, qt = `uniform sampler2D textAtlas;
627
+ uniform vec2 textAtlasSize;
628
+
629
+ uniform vec4 textSdf;
630
+ uniform vec4 textFill;
631
+ uniform vec4 textOutline;
632
+ in vec2 vTexel;
633
+ flat in vec4 vChannel;
634
+ void main(){
635
+ float value=dot(texture(textAtlas,vTexel/textAtlasSize),vChannel);
636
+ float dist=(1.0-textSdf.y-value)*textSdf.x;
637
+ float reach=textSdf.x*(1.0-textSdf.y);
638
+
639
+ float width=clamp(0.5*length(fwidth(vTexel)),1e-4,reach);
640
+ float fill=(1.0-smoothstep(-width,width,dist))*textFill.a;
641
+ float outline=0.0;
642
+ float extent=textSdf.z+textSdf.w;
643
+ if(extent>0.0){
644
+ float soft=clamp(reach-extent,1e-4,width);
645
+ outline=(1.0-smoothstep(textSdf.z-soft,extent+soft,dist))*textOutline.a;
646
+ }
647
+ float alpha=fill+outline*(1.0-fill);
648
+ if(alpha<0.002)discard;
649
+ novaOutput(vec4((textFill.rgb*fill+textOutline.rgb*outline*(1.0-fill))/alpha,alpha));
650
+ }`, _t = { fontSize: 1, maxWidth: 1 / 0, lineHeight: 1.2, letterSpacing: 0, textAlign: "left", anchorX: "left", anchorY: "top", whiteSpace: "normal", overflowWrap: "normal", color: "#ffffff", opacity: 1, outlineWidth: 0, outlineColor: "#000000", outlineOpacity: 1, outlineBlur: 0, billboard: !1, depthTest: !0, depthWrite: void 0, alphaMode: "blend", alphaToCoverage: !1, side: "double" }, et = Object.keys(_t), jt = /* @__PURE__ */ new Set(["text", "fontSize", "maxWidth", "lineHeight", "letterSpacing", "textAlign", "anchorX", "anchorY", "whiteSpace", "overflowWrap", "billboard"]), Rt = /* @__PURE__ */ new Set(["fontSize", "color", "opacity", "outlineWidth", "outlineColor", "outlineOpacity", "outlineBlur"]), Et = /* @__PURE__ */ new Set(["billboard", "depthTest", "depthWrite", "alphaMode", "alphaToCoverage", "side"]), yt = ["id", "visible", "pickable", "position", "rotation", "quaternion", "scale", "parent"], Gt = /* @__PURE__ */ new Set([...et, ...yt, "text", "font", "renderOrder", "layers"]), Kt = 8, G = 1 << 22;
651
+ function O(i, t, e, s, n = !1) {
652
+ if (typeof i != "number" || Number.isNaN(i) || i < e || i > s || n && i === e)
653
+ throw new m("invalid-option", `[Nova3D] Text ${t} must be a number in ${n ? "(" : "["}${e}, ${s}].`);
654
+ return i;
655
+ }
656
+ function ht(i, t) {
657
+ if (typeof i == "string" && /^\d+(?:\.\d+)?%$/.test(i) || typeof i == "number" && Number.isFinite(i) && i >= 0)
658
+ return i;
659
+ throw new m("invalid-option", `[Nova3D] Text ${t} must be a nonnegative number or a percentage of fontSize.`);
660
+ }
661
+ function $(i, t, e) {
662
+ if (!e.includes(i))
663
+ throw new m("invalid-option", `[Nova3D] Text ${t} must be ${e.join(", ")}.`);
664
+ return i;
665
+ }
666
+ function Y(i, t) {
667
+ if (typeof i != "boolean")
668
+ throw new m("invalid-option", `[Nova3D] Text ${t} must be boolean.`);
669
+ return i;
670
+ }
671
+ function gt(i, t) {
672
+ const e = { ...i };
673
+ for (const s of et) {
674
+ const n = t[s];
675
+ (n !== void 0 || s === "depthWrite" && s in t) && (e[s] = n);
676
+ }
677
+ return O(e.fontSize, "fontSize", 0, 1e9, !0), e.maxWidth !== 1 / 0 && O(e.maxWidth, "maxWidth", 0, 1e12), O(e.lineHeight, "lineHeight", 0, 1e3), O(e.letterSpacing, "letterSpacing", -10, 10), $(e.textAlign, "textAlign", ["left", "center", "right", "justify"]), typeof e.anchorX == "number" ? O(e.anchorX, "anchorX", -1e12, 1e12) : $(e.anchorX, "anchorX", ["left", "center", "right"]), typeof e.anchorY == "number" ? O(e.anchorY, "anchorY", -1e12, 1e12) : $(e.anchorY, "anchorY", ["top", "middle", "baseline", "bottom"]), $(e.whiteSpace, "whiteSpace", ["normal", "nowrap"]), $(e.overflowWrap, "overflowWrap", ["normal", "break-word"]), Q(e.color), Q(e.outlineColor), O(e.opacity, "opacity", 0, 1), O(e.outlineOpacity, "outlineOpacity", 0, 1), ht(e.outlineWidth, "outlineWidth"), ht(e.outlineBlur, "outlineBlur"), Y(e.billboard, "billboard"), Y(e.depthTest, "depthTest"), e.depthWrite !== void 0 && Y(e.depthWrite, "depthWrite"), $(e.alphaMode, "alphaMode", ["blend", "mask"]), Y(e.alphaToCoverage, "alphaToCoverage"), $(e.side, "side", ["front", "back", "double"]), e;
678
+ }
679
+ function lt(i, t) {
680
+ return typeof i == "number" ? i : Number.parseFloat(i) / 100 * t;
681
+ }
682
+ function ct(i, t) {
683
+ const e = Q(i);
684
+ return [J(e[0]), J(e[1]), J(e[2]), e[3] * t];
685
+ }
686
+ function pt(i, t) {
687
+ const e = t.sdfSize / i.fontSize, s = t.radius * (1 - t.cutoff);
688
+ let n = lt(i.outlineWidth, i.fontSize) * e, o = lt(i.outlineBlur, i.fontSize) * e;
689
+ const r = Math.max(0, s - 1);
690
+ if (n + o > r) {
691
+ const l = r / (n + o);
692
+ n *= l, o *= l;
693
+ }
694
+ return {
695
+ textSdf: [t.radius, t.cutoff, n, o],
696
+ textFill: ct(i.color, i.opacity),
697
+ textOutline: ct(i.outlineColor, i.outlineOpacity * i.opacity),
698
+ textBillboard: i.billboard ? 1 : 0
699
+ };
700
+ }
701
+ function mt(i) {
702
+ return { side: i.side, alphaMode: i.alphaMode, alphaCutoff: 0.5, alphaToCoverage: i.alphaToCoverage, depthTest: i.depthTest, depthWrite: i.depthWrite ?? "auto", billboard: i.billboard ? "spherical" : "none" };
703
+ }
704
+ function xt(i) {
705
+ const t = 2 + 4 * i > 65536 ? new Uint32Array(i * 6) : new Uint16Array(i * 6);
706
+ for (let e = 0, s = 0; e < i; e++, s += 6) {
707
+ const n = 2 + e * 4;
708
+ t[s] = n, t[s + 1] = n + 1, t[s + 2] = n + 2, t[s + 3] = n, t[s + 4] = n + 2, t[s + 5] = n + 3;
709
+ }
710
+ return t;
711
+ }
712
+ function Pt(i) {
713
+ let t = 0;
714
+ for (let e = 0; e < i.length; e++) {
715
+ const s = i.charCodeAt(e);
716
+ (s < 56320 || s > 57343) && t++;
717
+ }
718
+ return t;
719
+ }
720
+ function Yt(i, t, e) {
721
+ if (!i || i.destroyed || typeof i.createGeometry != "function" || !i._ownsScene(t))
722
+ throw new m("owner", "[Nova3D] Text needs a live app and one of its scenes.");
723
+ if (!e || typeof e != "object")
724
+ throw new m("invalid-option", "[Nova3D] Text options are required.");
725
+ for (const g of Object.keys(e))
726
+ if (!Gt.has(g))
727
+ throw new m("invalid-option", `[Nova3D] Unknown text option ${g}.`);
728
+ if (typeof e.text != "string")
729
+ throw new m("invalid-option", "[Nova3D] Text text must be a string.");
730
+ const s = gt(_t, e), n = e.parent;
731
+ if (n !== void 0 && (!(n instanceof St) || n.destroyed || n.scene !== t))
732
+ throw new m("owner", "[Nova3D] Text parent must be a live node of the scene.");
733
+ const o = e.font;
734
+ if (o instanceof X && (o.destroyed || o._atlas._owner() !== i))
735
+ throw new m("owner", "[Nova3D] Text atlas must be live and belong to the same app.");
736
+ const r = new X(o instanceof X ? o._atlas : dt(i, o ?? {}), !0), l = r._atlas, h = Math.max(Kt, Pt(e.text));
737
+ if (h > G)
738
+ throw r._drop(), new m("invalid-option", `[Nova3D] Text holds at most ${G} code points.`);
739
+ const a = new Float32Array((2 + 4 * h) * 3), d = new Float32Array((2 + 4 * h) * 2);
740
+ let f, c;
741
+ try {
742
+ f = i.createGeometry({ positions: a, uvs: d, indices: xt(h), usage: "dynamic" }), c = i.createMaterial({
743
+ type: "shader",
744
+ vertex: $t,
745
+ fragment: qt,
746
+ uniforms: { textAtlas: l.texture, textAtlasSize: [l.width, l.height], ...pt(s, l) },
747
+ ...mt(s)
748
+ });
749
+ } catch (g) {
750
+ throw f?.destroy(), r._drop(), g;
751
+ }
752
+ const x = { geometry: f, material: c, renderOrder: e.renderOrder, layers: e.layers };
753
+ for (const g of yt)
754
+ e[g] !== void 0 && (x[g] = e[g]);
755
+ return { style: s, handle: r, capacity: h, positions: a, uvs: d, meshOptions: x, dispose: () => {
756
+ c.destroy(), f.destroy(), r._drop();
757
+ } };
758
+ }
759
+ class Xt extends At {
760
+ /** @internal */
761
+ _text = null;
762
+ setGeometry() {
763
+ throw new m("owner", "[Nova3D] The geometry of a text is internal.");
764
+ }
765
+ setMaterial() {
766
+ throw new m("owner", "[Nova3D] The material of a text is internal.");
767
+ }
768
+ /**
769
+ * Swaps in a larger glyph geometry.
770
+ * @internal
771
+ */
772
+ _replaceGeometry(t) {
773
+ super.setGeometry(t);
774
+ }
775
+ /** @internal */
776
+ _intersect(t, e) {
777
+ return this._text?._billboard() ? this._text._pickBillboard(t, e) : super._intersect(t, e);
778
+ }
779
+ /** @internal */
780
+ _onDestroy() {
781
+ super._onDestroy(), this._text?._teardown();
782
+ }
783
+ }
784
+ class Lt {
785
+ /**
786
+ * The scene node drawing the text: transform, reparent, hide or parent other
787
+ * nodes to it. Text hits report it as `hit.node`.
788
+ */
789
+ node;
790
+ /** The text's handle to its shared glyph atlas, released with the text. */
791
+ atlas;
792
+ _mesh;
793
+ _font;
794
+ _text;
795
+ _style;
796
+ _capacity;
797
+ _positions;
798
+ _uvs;
799
+ /** Quads whose vertices may hold old glyphs, collapsed on the next write. */
800
+ _written;
801
+ _quads = 0;
802
+ _fresh = !1;
803
+ _buffers = new Ut();
804
+ _input = { fontSize: 1, maxWidth: 1 / 0, lineHeight: 1.2, letterSpacing: 0, textAlign: "left", anchorX: "left", anchorY: "top", breakWord: !1, ascent: 0.8, descent: 0.2 };
805
+ _source;
806
+ _glyphBounds = new Float32Array(64);
807
+ _glyphPositions = new Float32Array(32);
808
+ _glyphIds = new Int32Array(16);
809
+ /** Local box of block and quads: minX, minY, maxX, maxY. */
810
+ _box = new Float64Array(4);
811
+ _ink = new Float64Array(4);
812
+ _version = 0;
813
+ _view = null;
814
+ _detachApp;
815
+ _app;
816
+ /** @internal */
817
+ constructor(t, e, s) {
818
+ const n = Yt(t, e, s);
819
+ let o;
820
+ try {
821
+ o = new Xt(e, n.meshOptions);
822
+ } catch (l) {
823
+ throw n.dispose(), l;
824
+ }
825
+ this._mesh = o, this.node = o, this.atlas = n.handle;
826
+ const r = n.handle._atlas;
827
+ this._font = r, this._app = t, this._text = s.text, this._style = n.style, this._capacity = n.capacity, this._positions = n.positions, this._uvs = n.uvs, this._written = n.capacity, this._source = { advance: (l) => r._advance(l), kerning: (l, h) => r._pairKerning(l, h) }, o._text = this, r._addUser(this), this._detachApp = t._own(() => this.destroy());
828
+ try {
829
+ this._rebuild();
830
+ } catch (l) {
831
+ throw this.destroy(), l;
832
+ }
833
+ }
834
+ get destroyed() {
835
+ return this._mesh.destroyed;
836
+ }
837
+ /** Draw order within the opaque or blended group; see `Nova3DMesh.renderOrder`. */
838
+ get renderOrder() {
839
+ return this._mesh.renderOrder;
840
+ }
841
+ setRenderOrder(t) {
842
+ this._mesh.setRenderOrder(t);
843
+ }
844
+ /** Layer bit mask; see `Nova3DMesh.layers`. */
845
+ get layers() {
846
+ return this._mesh.layers;
847
+ }
848
+ setLayers(t) {
849
+ this._mesh.setLayers(t);
850
+ }
851
+ /** Shadow casting and receiving of the glyph quads; see `Nova3DMesh.setShadows`. */
852
+ setShadows(t) {
853
+ this._mesh.setShadows(t);
854
+ }
855
+ /** Removes the node and releases the geometry, the material and the atlas handle. */
856
+ destroy() {
857
+ this._mesh.destroyed || this._mesh.destroy();
858
+ }
859
+ /** The laid-out string. */
860
+ get text() {
861
+ return this._text;
862
+ }
863
+ /** Glyph quads the geometry holds without reallocation. */
864
+ get capacity() {
865
+ return this._capacity;
866
+ }
867
+ /** Layout of the current text and style; rebuilt only after changes. */
868
+ get layout() {
869
+ if (this._assertAlive(), this._view?.version !== this._version) {
870
+ const t = this._buffers, e = t.count, s = this._glyphPositions;
871
+ for (let r = 0; r < e; r++)
872
+ s[r * 2] = t.x[r], s[r * 2 + 1] = t.y[r];
873
+ const n = t.blockBounds, o = this._ink;
874
+ this._view = {
875
+ version: this._version,
876
+ value: Object.freeze({
877
+ glyphCount: e,
878
+ quadCount: this._quads,
879
+ lineCount: t.lineCount,
880
+ blockBounds: Object.freeze([n[0], n[1], n[2], n[3]]),
881
+ visibleBounds: this._quads > 0 ? Object.freeze([o[0], o[1], o[2], o[3]]) : null,
882
+ glyphPositions: s.subarray(0, e * 2),
883
+ glyphBounds: this._glyphBounds.subarray(0, e * 4),
884
+ glyphCharIndices: t.charIndices.subarray(0, e),
885
+ glyphLines: t.lines.subarray(0, e)
886
+ })
887
+ };
888
+ }
889
+ return this._view.value;
890
+ }
891
+ /** Current style with defaults filled in. */
892
+ /** The style with every default filled in and the string; `depthWrite` only when set. */
893
+ getOptions() {
894
+ this._assertAlive();
895
+ const t = { ...this._style, text: this._text };
896
+ return t.depthWrite === void 0 && delete t.depthWrite, t;
897
+ }
898
+ /** Replaces the string; buffers are rewritten in place while capacity allows. */
899
+ setText(t) {
900
+ if (this._mesh._assertLogicalWrite(), typeof t != "string")
901
+ throw new m("invalid-option", "[Nova3D] Text text must be a string.");
902
+ t !== this._text && (this._text = t, this._rebuild());
903
+ }
904
+ /** Applies a text and style patch atomically: one layout at most, validated first. */
905
+ set(t) {
906
+ if (this._mesh._assertLogicalWrite(), !t || typeof t != "object")
907
+ throw new m("invalid-option", "[Nova3D] Text patch must be an object.");
908
+ for (const a of Object.keys(t))
909
+ if (a !== "text" && !et.includes(a))
910
+ throw new m("invalid-option", `[Nova3D] Unknown text option ${a}.`);
911
+ if (t.text !== void 0 && typeof t.text != "string")
912
+ throw new m("invalid-option", "[Nova3D] Text text must be a string.");
913
+ const e = this._style, s = gt(e, t), n = (a) => {
914
+ for (const d of a)
915
+ if (d === "text" ? t.text !== void 0 && t.text !== this._text : s[d] !== e[d])
916
+ return !0;
917
+ return !1;
918
+ }, o = n(jt), r = n(Rt), l = n(Et);
919
+ this._style = s, t.text !== void 0 && (this._text = t.text);
920
+ const h = this._mesh.material;
921
+ if (l && h.set(mt(s)), r || l) {
922
+ const a = pt(s, this._font);
923
+ h.setUniform("textSdf", a.textSdf), h.setUniform("textFill", a.textFill), h.setUniform("textOutline", a.textOutline), h.setUniform("textBillboard", a.textBillboard);
924
+ }
925
+ o && this._rebuild();
926
+ }
927
+ /** @internal */
928
+ _atlasChanged(t) {
929
+ this.destroyed || (t === "resize" ? this._mesh.material.setUniform("textAtlasSize", [this._font.width, this._font.height]) : this._rebuild());
930
+ }
931
+ /** @internal */
932
+ _billboard() {
933
+ return this._style.billboard;
934
+ }
935
+ /**
936
+ * Billboards hit against the plane facing the ray (camera roll ignored): their
937
+ * glyph quads or, with 'bounds', the block and quad box.
938
+ * @internal
939
+ */
940
+ _pickBillboard(t, e) {
941
+ const s = this._mesh, n = s._worldState().matrix, o = t.direction, r = t.origin, l = n[12] - r[0], h = n[13] - r[1], a = n[14] - r[2], d = l * o[0] + h * o[1] + a * o[2];
942
+ if (d < 0)
943
+ return null;
944
+ let f = -o[2], c = o[0], x = Math.hypot(f, c);
945
+ x < 1e-9 && (f = 1, c = 0, x = 1), f /= x, c /= x;
946
+ const _ = -c * o[1], g = c * o[0] - f * o[2], z = f * o[1], b = o[0] * d - l, N = o[1] * d - h, T = o[2] * d - a, v = Math.hypot(n[0], n[1], n[2]), k = Math.hypot(n[4], n[5], n[6]);
947
+ if (v === 0 || k === 0)
948
+ return null;
949
+ const C = (b * f + T * c) / v, D = (b * _ + N * g + T * z) / k;
950
+ let u = !1, A = -1;
951
+ if (e === "bounds") {
952
+ const F = this._box;
953
+ u = C >= F[0] && C <= F[2] && D >= F[1] && D <= F[3];
954
+ } else {
955
+ const F = this._positions;
956
+ for (let y = 0; y < this._quads && !u; y++) {
957
+ const w = (2 + y * 4) * 3;
958
+ C >= F[w] && C <= F[w + 6] && D >= F[w + 1] && D <= F[w + 7] && (u = !0, A = y);
959
+ }
960
+ }
961
+ if (!u)
962
+ return null;
963
+ const p = [r[0] + o[0] * d, r[1] + o[1] * d, r[2] + o[2] * d], S = [-o[0], -o[1], -o[2]];
964
+ return A < 0 ? { node: s, point: p, normal: null, distance: d } : { node: s, point: p, normal: S, distance: d, triangleIndex: A * 2 };
965
+ }
966
+ /**
967
+ * Releases everything the text owns once its node is destroyed.
968
+ * @internal
969
+ */
970
+ _teardown() {
971
+ this._detachApp(), this._font._removeUser(this), this._mesh.material.destroy(), this._mesh.geometry.destroy(), this.atlas._drop();
972
+ }
973
+ /** Lays out the text and rewrites the glyph quads, reusing buffers when they fit. */
974
+ _rebuild() {
975
+ const t = this._font, e = this._style, s = this._input;
976
+ s.fontSize = e.fontSize, s.maxWidth = e.whiteSpace === "nowrap" ? 1 / 0 : e.maxWidth, s.lineHeight = e.lineHeight, s.letterSpacing = e.letterSpacing, s.textAlign = e.textAlign, s.anchorX = e.anchorX, s.anchorY = e.anchorY, s.breakWord = e.overflowWrap === "break-word", s.ascent = t.ascent, s.descent = t.descent;
977
+ const n = this._buffers;
978
+ Ht(this._text, s, this._source, n);
979
+ const o = n.count, r = t._records();
980
+ o > this._glyphIds.length && (this._glyphIds = new Int32Array(Math.max(o, this._glyphIds.length * 2)));
981
+ const l = this._glyphIds;
982
+ let h = 0;
983
+ for (let p = 0; p < o; p++) {
984
+ const S = n.codePoints[p], F = S === 10 || S === 9 ? -1 : t._glyph(S) * R;
985
+ l[p] = F >= 0 && r[F + 7] > 0 ? F : -1, l[p] >= 0 && h++;
986
+ }
987
+ this._reserve(h, o);
988
+ const a = this._positions, d = this._uvs, f = this._glyphBounds, c = e.fontSize, x = n.blockBounds, _ = this._box, g = this._ink;
989
+ _[0] = x[0], _[1] = x[1], _[2] = x[2], _[3] = x[3], g[0] = g[1] = 1 / 0, g[2] = g[3] = -1 / 0;
990
+ let z = 0;
991
+ for (let p = 0; p < o; p++) {
992
+ const S = n.x[p], F = n.y[p], y = p * 4, w = l[p];
993
+ if (w < 0) {
994
+ f[y] = f[y + 2] = S, f[y + 1] = f[y + 3] = F;
995
+ continue;
996
+ }
997
+ f[y] = S + r[w + 10] * c, f[y + 1] = F + r[w + 11] * c, f[y + 2] = S + r[w + 12] * c, f[y + 3] = F + r[w + 13] * c, g[0] = Math.min(g[0], f[y]), g[1] = Math.min(g[1], f[y + 1]), g[2] = Math.max(g[2], f[y + 2]), g[3] = Math.max(g[3], f[y + 3]);
998
+ const B = S + r[w + 1] * c, j = F + r[w + 2] * c, U = S + r[w + 3] * c, H = F + r[w + 4] * c;
999
+ _[0] = Math.min(_[0], B), _[1] = Math.min(_[1], j), _[2] = Math.max(_[2], U), _[3] = Math.max(_[3], H);
1000
+ const M = r[w + 5] + r[w + 9] * tt, L = r[w + 6], it = M + r[w + 7], st = L + r[w + 8], W = (2 + z * 4) * 3, I = (2 + z * 4) * 2;
1001
+ a[W] = B, a[W + 1] = j, a[W + 2] = 0, a[W + 3] = U, a[W + 4] = j, a[W + 5] = 0, a[W + 6] = U, a[W + 7] = H, a[W + 8] = 0, a[W + 9] = B, a[W + 10] = H, a[W + 11] = 0, d[I] = M, d[I + 1] = st, d[I + 2] = it, d[I + 3] = st, d[I + 4] = it, d[I + 5] = L, d[I + 6] = M, d[I + 7] = L, z++;
1002
+ }
1003
+ t._flush();
1004
+ let b = _[0], N = _[1], T = 0, v = _[2], k = _[3], C = 0;
1005
+ if (e.billboard) {
1006
+ const p = Math.max(Math.hypot(_[0], _[1]), Math.hypot(_[2], _[1]), Math.hypot(_[0], _[3]), Math.hypot(_[2], _[3]));
1007
+ b = N = T = -p, v = k = C = p;
1008
+ }
1009
+ a[0] = b, a[1] = N, a[2] = T, a[3] = v, a[4] = k, a[5] = C;
1010
+ const D = Math.max(h, this._written);
1011
+ for (let p = (2 + h * 4) * 3, S = (2 + D * 4) * 3; p < S; p += 3)
1012
+ a[p] = b, a[p + 1] = N, a[p + 2] = T;
1013
+ const u = 2 + D * 4, A = this._mesh;
1014
+ if (this._fresh) {
1015
+ const p = A.geometry, S = this._app.createGeometry({ positions: a, uvs: d, indices: xt(this._capacity), usage: "dynamic" });
1016
+ A._replaceGeometry(S), p.destroy(), this._fresh = !1;
1017
+ } else
1018
+ A.geometry.updateRange(0, { positions: a.subarray(0, u * 3), uvs: d.subarray(0, u * 2) });
1019
+ A.geometry.setDrawRange(0, h * 6), this._written = h, this._quads = h, this._version++;
1020
+ }
1021
+ _assertAlive() {
1022
+ if (this._mesh.destroyed || this._mesh.scene.destroyed)
1023
+ throw new m("destroyed", "[Nova3D] Text is destroyed.");
1024
+ }
1025
+ /** Grows quad and per-glyph storage; a new geometry is created on the next write. */
1026
+ _reserve(t, e) {
1027
+ if (e * 4 > this._glyphBounds.length && (this._glyphBounds = new Float32Array(Math.max(e * 4, this._glyphBounds.length * 2)), this._glyphPositions = new Float32Array(this._glyphBounds.length / 2)), t <= this._capacity)
1028
+ return;
1029
+ if (t > G)
1030
+ throw new m("invalid-option", `[Nova3D] Text holds at most ${G} glyph quads.`);
1031
+ const s = Math.min(G, Math.max(t, this._capacity * 2));
1032
+ this._positions = new Float32Array((2 + 4 * s) * 3), this._uvs = new Float32Array((2 + 4 * s) * 2), this._capacity = s, this._written = s, this._fresh = !0;
1033
+ }
1034
+ }
1035
+ function ne(i, t) {
1036
+ return new Lt(Ft(i), i, t);
1037
+ }
1038
+ export {
1039
+ X as Nova3DFontAtlas,
1040
+ Lt as Nova3DText,
1041
+ se as createFontAtlas,
1042
+ ne as createText
1043
+ };