@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,1041 @@
1
+ import { N as d } from "../Errors-B2ekO9bZ.js";
2
+ import { c as M, o as P } from "../Options-CajE7LLJ.js";
3
+ import { W as N, o as k, g as p, P as q, x as B, X as ct, d as w, Y as E, Z as lt, N as z, b as j, r as T, Q as O, _ as _t, s as L, $ as dt, l as x, L as ut, C as pt, a0 as ft, a1 as mt, G as Y, a2 as gt, a3 as yt, f as vt, k as wt } from "../Node-QfgAE2_v.js";
4
+ const C = Math.PI * 2;
5
+ function bt(r) {
6
+ return r - C * Math.floor((r + Math.PI) / C);
7
+ }
8
+ function H(r, t, e, s) {
9
+ const i = r[0], o = r[1], n = r[2], a = r[3];
10
+ t[0] = 1 - 2 * (o * o + n * n), t[1] = 2 * (i * o + a * n), t[2] = 2 * (i * n - a * o), e[0] = 2 * (i * o - a * n), e[1] = 1 - 2 * (i * i + n * n), e[2] = 2 * (o * n + a * i), s[0] = -2 * (i * n + a * o), s[1] = -2 * (o * n - a * i), s[2] = -(1 - 2 * (i * i + o * o));
11
+ }
12
+ class Q {
13
+ constructor(t, e, s) {
14
+ this._minPitch = t, this._maxPitch = e, this._flat = s;
15
+ }
16
+ rolls = !1;
17
+ yaw = 0;
18
+ pitch = 0;
19
+ read(t) {
20
+ const e = t[0], s = t[1], i = t[2], o = t[3], n = -2 * (e * i + o * s), a = -2 * (s * i - o * e), h = -(1 - 2 * (e * e + s * s)), l = Math.abs(a) > 0.999999;
21
+ this.yaw = l ? Math.atan2(Math.sign(a) * 2 * (e * s - o * i), Math.sign(a) * 2 * (s * i + o * e)) : Math.atan2(-n, -h), this.pitch = Math.max(this._minPitch, Math.min(this._maxPitch, Math.asin(Math.max(-1, Math.min(1, a)))));
22
+ }
23
+ rotate(t, e, s, i) {
24
+ this.yaw = bt(this.yaw + t), this.pitch = Math.max(this._minPitch, Math.min(this._maxPitch, this.pitch + e)), this.write(i);
25
+ }
26
+ /** q = Ry(yaw) · Rx(pitch). */
27
+ write(t) {
28
+ const e = Math.sin(this.yaw / 2), s = Math.cos(this.yaw / 2), i = Math.sin(this.pitch / 2), o = Math.cos(this.pitch / 2);
29
+ t[0] = s * i, t[1] = e * o, t[2] = -e * i, t[3] = s * o;
30
+ }
31
+ basis(t, e, s, i) {
32
+ if (!this._flat) {
33
+ H(t, e, s, i);
34
+ return;
35
+ }
36
+ const o = Math.sin(this.yaw), n = Math.cos(this.yaw);
37
+ e[0] = n, e[1] = 0, e[2] = -o, s[0] = 0, s[1] = 1, s[2] = 0, i[0] = -o, i[1] = 0, i[2] = -n;
38
+ }
39
+ }
40
+ class Mt {
41
+ rolls = !0;
42
+ read() {
43
+ }
44
+ /** q = q · Ry(yaw) · Rx(pitch) · Rz(roll), then normalized against accumulated error. */
45
+ rotate(t, e, s, i) {
46
+ t !== 0 && I(i, 0, Math.sin(t / 2), 0, Math.cos(t / 2)), e !== 0 && I(i, Math.sin(e / 2), 0, 0, Math.cos(e / 2)), s !== 0 && I(i, 0, 0, Math.sin(s / 2), Math.cos(s / 2));
47
+ const o = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
48
+ i[0] /= o, i[1] /= o, i[2] /= o, i[3] /= o;
49
+ }
50
+ basis(t, e, s, i) {
51
+ H(t, e, s, i);
52
+ }
53
+ }
54
+ function I(r, t, e, s, i) {
55
+ const o = r[0], n = r[1], a = r[2], h = r[3];
56
+ r[0] = h * t + o * i + n * s - a * e, r[1] = h * e - o * s + n * i + a * t, r[2] = h * s + o * e - n * t + a * i, r[3] = h * i - o * t - n * e - a * s;
57
+ }
58
+ class F {
59
+ constructor(t, e, s = !1) {
60
+ this._app = t, this._callbacks = e;
61
+ const i = t.target, o = i.ownerDocument.defaultView, n = (a, h, l, c = !1) => {
62
+ const _ = (u) => {
63
+ try {
64
+ l(u);
65
+ } catch (f) {
66
+ t._deliverInput(() => {
67
+ throw f;
68
+ });
69
+ }
70
+ };
71
+ a.addEventListener(h, _, { capture: c, passive: !1 }), this._cleanup.push(() => a.removeEventListener(h, _, c));
72
+ };
73
+ n(i, "pointerdown", (a) => this._begin(a), s), n(i, "pointermove", (a) => this._move(a)), n(i, "pointerup", (a) => this._end(a)), n(i, "pointercancel", (a) => {
74
+ a.pointerId === this._pointer && this.cancel();
75
+ }), n(i, "lostpointercapture", (a) => {
76
+ a.pointerId === this._pointer && this.cancel();
77
+ }), n(o, "blur", () => this.cancel()), n(o, "keydown", (a) => {
78
+ a.key === "Escape" && this._pointer !== null && (a.preventDefault(), this.cancel());
79
+ }), this._cleanup.push(t._controlStyle(this)), this._cleanup.push(t._own(() => this.destroy()));
80
+ }
81
+ _pointer = null;
82
+ _destroyed = !1;
83
+ _cleanup = [];
84
+ cancel() {
85
+ this._pointer !== null && (this._release(), this._callbacks.cancel());
86
+ }
87
+ destroy() {
88
+ if (!this._destroyed) {
89
+ this._destroyed = !0;
90
+ try {
91
+ this.cancel();
92
+ } finally {
93
+ for (const t of this._cleanup.splice(0).reverse())
94
+ t();
95
+ }
96
+ }
97
+ }
98
+ _begin(t) {
99
+ if (!(this._destroyed || this._pointer !== null || t.defaultPrevented || !this._app._claimInput(this)))
100
+ try {
101
+ if (!this._callbacks.begin(t)) {
102
+ this._app._releaseInput(this);
103
+ return;
104
+ }
105
+ if (this._destroyed || this._app.destroyed) {
106
+ this._release(), this._callbacks.cancel();
107
+ return;
108
+ }
109
+ this._pointer = t.pointerId, this._app.target.setPointerCapture(t.pointerId), t.preventDefault();
110
+ } catch (e) {
111
+ throw this._release(), this._callbacks.cancel(), e;
112
+ }
113
+ }
114
+ _move(t) {
115
+ if (t.pointerId === this._pointer) {
116
+ t.preventDefault();
117
+ try {
118
+ this._callbacks.move(t);
119
+ } catch (e) {
120
+ throw this.cancel(), e;
121
+ }
122
+ }
123
+ }
124
+ _end(t) {
125
+ if (t.pointerId === this._pointer) {
126
+ t.preventDefault(), this._release();
127
+ try {
128
+ this._callbacks.end(t);
129
+ } catch (e) {
130
+ throw this._callbacks.cancel(), e;
131
+ }
132
+ }
133
+ }
134
+ _release() {
135
+ const t = this._pointer;
136
+ this._pointer = null, this._app._releaseInput(this), t !== null && this._app.target.hasPointerCapture(t) && this._app.target.releasePointerCapture(t);
137
+ }
138
+ }
139
+ class kt {
140
+ constructor(t, e) {
141
+ this._app = t, this._callbacks = e;
142
+ const s = t.target;
143
+ this._document = s.ownerDocument;
144
+ const i = (o, n, a) => {
145
+ const h = (l) => {
146
+ try {
147
+ a(l);
148
+ } catch (c) {
149
+ t._deliverInput(() => {
150
+ throw c;
151
+ });
152
+ }
153
+ };
154
+ o.addEventListener(n, h), this._cleanup.push(() => o.removeEventListener(n, h));
155
+ };
156
+ i(this._document, "pointerlockchange", () => this._changed()), i(this._document, "pointerlockerror", () => this._failed(new d("state", "[Nova3D] Pointer lock request was rejected."))), i(s, "mousemove", (o) => this._move(o));
157
+ }
158
+ _state = "unlocked";
159
+ _request = 0;
160
+ _abandoned = !1;
161
+ _destroyed = !1;
162
+ _document;
163
+ _cleanup = [];
164
+ get state() {
165
+ return this._state;
166
+ }
167
+ /**
168
+ * Requests the lock; the result arrives through pointerlockchange or pointerlockerror.
169
+ * Returns false when another owner already holds the canvas.
170
+ */
171
+ request() {
172
+ if (this._destroyed)
173
+ return !1;
174
+ if (this._state !== "unlocked")
175
+ return !0;
176
+ const t = this._app.target;
177
+ if (typeof t.requestPointerLock != "function")
178
+ throw new d("unsupported", "[Nova3D] Pointer lock is unavailable in this environment.");
179
+ if (this._document.pointerLockElement === t || !this._app._claimInput(this))
180
+ return !1;
181
+ this._state = "pending", this._abandoned = !1;
182
+ const e = ++this._request;
183
+ let s;
184
+ try {
185
+ s = t.requestPointerLock();
186
+ } catch (i) {
187
+ throw this._state = "unlocked", this._app._releaseInput(this), i;
188
+ }
189
+ return s !== null && typeof s == "object" && typeof s.then == "function" && s.then(void 0, (i) => {
190
+ !this._destroyed && e === this._request && !this._app.destroyed && this._app._deliverInput(() => this._failed(new d("state", "[Nova3D] Pointer lock request was rejected.", { cause: i })));
191
+ }), !0;
192
+ }
193
+ /** Releases the lock or cancels a request not yet granted. */
194
+ exit() {
195
+ const t = this._state;
196
+ t !== "unlocked" && (this._request++, this._state = "unlocked", this._app._releaseInput(this), t === "pending" ? this._abandoned = !0 : this._document.pointerLockElement === this._app.target && this._document.exitPointerLock(), t === "locked" && this._callbacks.change(!1));
197
+ }
198
+ destroy() {
199
+ if (this._destroyed)
200
+ return;
201
+ const t = this._state === "pending";
202
+ try {
203
+ this.exit();
204
+ } finally {
205
+ this._destroyed = !0;
206
+ for (const e of this._cleanup.splice(0).reverse())
207
+ e();
208
+ t && this._releaseLateGrant();
209
+ }
210
+ }
211
+ _changed() {
212
+ if (this._document.pointerLockElement === this._app.target) {
213
+ this._state === "pending" ? (this._state = "locked", this._callbacks.change(!0)) : this._abandoned && (this._abandoned = !1, this._document.exitPointerLock());
214
+ return;
215
+ }
216
+ this._abandoned = !1, this._state === "locked" && (this._state = "unlocked", this._app._releaseInput(this), this._callbacks.change(!1));
217
+ }
218
+ _failed(t) {
219
+ if (this._abandoned = !1, this._state === "pending")
220
+ throw this._state = "unlocked", this._app._releaseInput(this), t;
221
+ }
222
+ _move(t) {
223
+ if (this._state !== "locked" || this._document.pointerLockElement !== this._app.target)
224
+ return;
225
+ const e = t.movementX, s = t.movementY;
226
+ (e || s) && Number.isFinite(e) && Number.isFinite(s) && this._callbacks.move(e, s);
227
+ }
228
+ /** A lock granted after destroy goes back to the browser at once. */
229
+ _releaseLateGrant() {
230
+ const t = this._document, e = this._app.target, s = () => {
231
+ t.removeEventListener("pointerlockchange", s), t.removeEventListener("pointerlockerror", s), t.pointerLockElement === e && t.exitPointerLock();
232
+ };
233
+ t.addEventListener("pointerlockchange", s), t.addEventListener("pointerlockerror", s);
234
+ }
235
+ }
236
+ const Z = { camera: !0, speed: !0, boostMultiplier: !0, lookSpeed: !0, damping: !0, pointerLock: !0, minPitch: !0, maxPitch: !0, keys: !0 }, xt = P(Z), Pt = P({ ...Z, freeLook: !0, rollSpeed: !0 }), A = ["forward", "backward", "left", "right", "up", "down", "rollLeft", "rollRight", "boost"], Dt = 0, Lt = 1, Nt = 2, St = 3, At = 4, Ot = 5, J = 6, tt = 7, It = 8, Et = 6, $ = 8, zt = 0.1, jt = 1 / 60, Tt = 1e-4, W = 1e-7, et = Object.freeze({
237
+ forward: Object.freeze(["KeyW", "ArrowUp"]),
238
+ backward: Object.freeze(["KeyS", "ArrowDown"]),
239
+ left: Object.freeze(["KeyA", "ArrowLeft"]),
240
+ right: Object.freeze(["KeyD", "ArrowRight"]),
241
+ up: Object.freeze(["KeyE"]),
242
+ down: Object.freeze(["KeyQ"]),
243
+ rollLeft: Object.freeze(["KeyZ"]),
244
+ rollRight: Object.freeze(["KeyC"]),
245
+ boost: Object.freeze(["ShiftLeft", "ShiftRight"])
246
+ }), Ft = Object.freeze({ ...et, up: Object.freeze([]), down: Object.freeze([]), rollLeft: Object.freeze([]), rollRight: Object.freeze([]) }), D = /* @__PURE__ */ new WeakMap();
247
+ function Kt(r) {
248
+ const t = D.get(r);
249
+ return t === void 0 && r.hasAttribute("tabindex") ? () => {
250
+ } : (t === void 0 && r.setAttribute("tabindex", "-1"), D.set(r, (t ?? 0) + 1), () => {
251
+ const e = (D.get(r) ?? 1) - 1;
252
+ if (e > 0) {
253
+ D.set(r, e);
254
+ return;
255
+ }
256
+ D.delete(r), r.removeAttribute("tabindex");
257
+ });
258
+ }
259
+ function S(r, t, e, s = !1) {
260
+ const i = r ?? t;
261
+ if (typeof i != "number" || !Number.isFinite(i) || i < 0 || !s && i === 0)
262
+ throw new d("invalid-option", `[Nova3D] ${e} must be a finite ${s ? "non-negative" : "positive"} number.`);
263
+ return i;
264
+ }
265
+ function st(r, t, e) {
266
+ const s = r ?? t;
267
+ if (typeof s != "boolean")
268
+ throw new d("invalid-option", `[Nova3D] ${e} must be boolean.`);
269
+ return s;
270
+ }
271
+ function Rt(r, t, e) {
272
+ if (r !== void 0 && (r === null || typeof r != "object" || Array.isArray(r)))
273
+ throw new d("invalid-option", "[Nova3D] keys must be an object.");
274
+ for (const i of Object.keys(r ?? {}))
275
+ if (!A.includes(i))
276
+ throw new d("invalid-option", `[Nova3D] Unknown camera key action "${i}".`);
277
+ const s = /* @__PURE__ */ new Map();
278
+ return A.forEach((i, o) => {
279
+ const n = r?.[i] ?? t[i];
280
+ if (!Array.isArray(n) || n.some((a) => typeof a != "string" || a.length === 0))
281
+ throw new d("invalid-option", `[Nova3D] keys.${i} must be an array of KeyboardEvent.code strings.`);
282
+ if (!(!e && (o === J || o === tt)))
283
+ for (const a of n) {
284
+ const h = s.get(a);
285
+ if (h !== void 0 && h !== o)
286
+ throw new d("invalid-option", `[Nova3D] Key "${a}" is bound to both ${A[h]} and ${i}.`);
287
+ s.set(a, o);
288
+ }
289
+ }), s;
290
+ }
291
+ class it {
292
+ /** @internal */
293
+ constructor(t, e, s, i, o, n, a) {
294
+ if (this._app = t, this._camera = e, this._orientation = s, this._label = i, this._loop = `nova3d.${i.toLowerCase()}`, this._speed = S(o.speed, 5, `${i} speed`), this._boost = S(o.boostMultiplier, 3, `${i} boostMultiplier`), this._look = S(o.lookSpeed, 2e-3, `${i} lookSpeed`, !0), this._rollSpeed = S(o.rollSpeed, 1, `${i} rollSpeed`, !0), this._damping = o.damping ?? 0, typeof this._damping != "number" || !Number.isFinite(this._damping) || this._damping < 0 || this._damping > 1)
295
+ throw new d("invalid-option", `[Nova3D] ${i} damping must be within [0, 1].`);
296
+ this._smooth = this._damping > 0 && this._damping < 1, this._pointerLock = st(o.pointerLock, a, `${i} pointerLock`), this._codes = Rt(o.keys, n, s.rolls), this._patch = { position: this._position, quaternion: this._quaternion }, this._initial = e.getTransform(), this._read();
297
+ const h = t.target, l = h.ownerDocument.defaultView;
298
+ this._gesture = new F(t, {
299
+ begin: (_) => this._begin(_),
300
+ move: (_) => this._drag(_),
301
+ end: () => {
302
+ },
303
+ cancel: () => {
304
+ }
305
+ }), this._cleanup.push(() => this._gesture.destroy()), this._lockSession = new kt(t, {
306
+ change: (_) => this._lockChanged(_),
307
+ move: (_, u) => this._lockMove(_, u)
308
+ }), this._cleanup.push(() => this._lockSession.destroy());
309
+ const c = (_, u, f) => {
310
+ const m = (y) => {
311
+ try {
312
+ f(y);
313
+ } catch (g) {
314
+ t._deliverInput(() => {
315
+ throw g;
316
+ });
317
+ }
318
+ };
319
+ _.addEventListener(u, m), this._cleanup.push(() => _.removeEventListener(u, m));
320
+ };
321
+ c(h, "keydown", (_) => this._keyDown(_)), c(h, "keyup", (_) => this._keyUp(_)), c(h, "blur", () => this._releaseKeys()), c(l, "blur", () => this._releaseKeys()), c(h, "pointerdown", (_) => this._lockClick(_)), this._cleanup.push(Kt(h)), this._cleanup.push(t.onUpdate((_) => this._tick(_.deltaTime))), this._cleanup.push(t._own(() => this.destroy()));
322
+ }
323
+ _gesture;
324
+ _lockSession;
325
+ _cleanup = [];
326
+ _lockListeners = /* @__PURE__ */ new Set();
327
+ _codes;
328
+ _pressed = /* @__PURE__ */ new Set();
329
+ _counts = new Uint16Array(A.length);
330
+ _position = [0, 0, 0];
331
+ _quaternion = [0, 0, 0, 1];
332
+ _right = [1, 0, 0];
333
+ _up = [0, 1, 0];
334
+ _forward = [0, 0, -1];
335
+ /** Velocity along right/up/forward in m/s. */
336
+ _velocity = [0, 0, 0];
337
+ _patch;
338
+ _initial;
339
+ _speed;
340
+ _boost;
341
+ _look;
342
+ _damping;
343
+ _smooth;
344
+ _rollSpeed;
345
+ _pointerLock;
346
+ _loop;
347
+ _pendingYaw = 0;
348
+ _pendingPitch = 0;
349
+ _lease;
350
+ _fresh = !1;
351
+ _lastX = 0;
352
+ _lastY = 0;
353
+ _enabled = !0;
354
+ _destroyed = !1;
355
+ get enabled() {
356
+ return this._enabled;
357
+ }
358
+ /** Whether pointer lock is active. */
359
+ get locked() {
360
+ return this._lockSession.state === "locked";
361
+ }
362
+ get destroyed() {
363
+ return this._destroyed;
364
+ }
365
+ setEnabled(t) {
366
+ if (this._assertAlive(), typeof t != "boolean")
367
+ throw new d("invalid-option", "[Nova3D] enabled must be boolean.");
368
+ if (t !== this._enabled) {
369
+ if (!t) {
370
+ this._halt(), this._enabled = !1;
371
+ return;
372
+ }
373
+ this._enabled = !0, this._read();
374
+ }
375
+ }
376
+ /** Requests pointer lock on the canvas; call it from a user gesture handler. */
377
+ lock() {
378
+ return this._assertAlive(), this._active(!0) ? this._lockSession.request() : !1;
379
+ }
380
+ unlock() {
381
+ this._assertAlive(), this._lockSession.exit();
382
+ }
383
+ onLockChange(t) {
384
+ if (this._assertAlive(), typeof t != "function")
385
+ throw new d("invalid-option", "[Nova3D] Lock listener must be a function.");
386
+ return this._lockListeners.add(t), () => this._lockListeners.delete(t);
387
+ }
388
+ /** Re-reads the camera pose after an external change during motion. */
389
+ sync() {
390
+ this._assertAlive(), this._read();
391
+ }
392
+ reset() {
393
+ this._assertAlive(), this._halt(), this._camera._setTransform(this._initial), this._read();
394
+ }
395
+ destroy() {
396
+ if (!this._destroyed) {
397
+ this._destroyed = !0;
398
+ try {
399
+ this._stop(), this._clearMotion();
400
+ } finally {
401
+ for (const t of this._cleanup.splice(0).reverse())
402
+ t();
403
+ this._lockListeners.clear();
404
+ }
405
+ }
406
+ }
407
+ /**
408
+ * `full` also checks the active view; app.view copies the object, so hot
409
+ * paths (tick, move) use the light check.
410
+ */
411
+ _active(t) {
412
+ return !this._destroyed && this._enabled && !this._app.destroyed && !this._camera.destroyed && (!t || this._app.view?.camera === this._camera);
413
+ }
414
+ _read() {
415
+ const t = this._camera.getTransform();
416
+ this._position[0] = t.position[0], this._position[1] = t.position[1], this._position[2] = t.position[2];
417
+ const e = t.quaternion, s = Math.hypot(e[0], e[1], e[2], e[3]);
418
+ this._quaternion[0] = e[0] / s, this._quaternion[1] = e[1] / s, this._quaternion[2] = e[2] / s, this._quaternion[3] = e[3] / s, this._orientation.read(this._quaternion);
419
+ }
420
+ _write() {
421
+ try {
422
+ this._camera._setTransform(this._patch);
423
+ } catch (t) {
424
+ throw this._halt(), t;
425
+ }
426
+ }
427
+ _keyDown(t) {
428
+ if (t.key === "Escape" && this._lockSession.state !== "unlocked") {
429
+ t.preventDefault(), this._lockSession.exit();
430
+ return;
431
+ }
432
+ if (t.defaultPrevented || t.ctrlKey || t.metaKey || t.altKey)
433
+ return;
434
+ const e = this._codes.get(t.code);
435
+ if (e !== void 0) {
436
+ if (this._pressed.has(t.code)) {
437
+ t.preventDefault();
438
+ return;
439
+ }
440
+ this._active(!0) && (t.preventDefault(), this._lease === void 0 && this._read(), this._pressed.add(t.code), this._counts[e]++, e < $ && this._schedule());
441
+ }
442
+ }
443
+ _keyUp(t) {
444
+ const e = this._codes.get(t.code);
445
+ e === void 0 || !this._pressed.delete(t.code) || (this._active(!1) && t.preventDefault(), this._counts[e]--, this._settle());
446
+ }
447
+ _releaseKeys() {
448
+ this._pressed.size !== 0 && (this._pressed.clear(), this._counts.fill(0), this._settle());
449
+ }
450
+ /** Without damping, released keys stop the motion at once and release the frame lease. */
451
+ _settle() {
452
+ !this._smooth && !this._held(0, Et) && (this._velocity[0] = 0, this._velocity[1] = 0, this._velocity[2] = 0), this._wantsFrames() || this._stop();
453
+ }
454
+ _held(t, e) {
455
+ for (let s = t; s < e; s++)
456
+ if (this._counts[s] > 0)
457
+ return !0;
458
+ return !1;
459
+ }
460
+ _wantsFrames() {
461
+ return this._held(0, $) || this._velocity[0] !== 0 || this._velocity[1] !== 0 || this._velocity[2] !== 0 || this._pendingYaw !== 0 || this._pendingPitch !== 0;
462
+ }
463
+ _begin(t) {
464
+ return this._pointerLock || t.button !== 0 || this._lockSession.state !== "unlocked" || !this._active(!0) ? !1 : (this._focus(), this._lease === void 0 && this._read(), this._lastX = t.clientX, this._lastY = t.clientY, !0);
465
+ }
466
+ _drag(t) {
467
+ if (!this._active(!1)) {
468
+ this._gesture.cancel();
469
+ return;
470
+ }
471
+ const e = t.clientX - this._lastX, s = t.clientY - this._lastY;
472
+ this._lastX = t.clientX, this._lastY = t.clientY, this._turn(e, s);
473
+ }
474
+ _lockClick(t) {
475
+ !this._pointerLock || t.defaultPrevented || t.button !== 0 || this._lockSession.state !== "unlocked" || !this._active(!0) || (this._focus(), this._lockSession.request());
476
+ }
477
+ _lockMove(t, e) {
478
+ if (!this._active(!1)) {
479
+ this._lockSession.exit();
480
+ return;
481
+ }
482
+ this._turn(t, e);
483
+ }
484
+ _lockChanged(t) {
485
+ t ? this._lease === void 0 && this._read() : this._releaseKeys();
486
+ for (const e of this._lockListeners)
487
+ this._app._deliverInput(() => e(t));
488
+ }
489
+ _turn(t, e) {
490
+ const s = -t * this._look, i = -e * this._look;
491
+ if (!(s === 0 && i === 0)) {
492
+ if (this._smooth) {
493
+ this._pendingYaw += s, this._pendingPitch += i, this._schedule();
494
+ return;
495
+ }
496
+ this._orientation.rotate(s, i, 0, this._quaternion), this._write();
497
+ }
498
+ }
499
+ _focus() {
500
+ const t = this._app.target;
501
+ t.ownerDocument.activeElement !== t && t.focus({ preventScroll: !0 });
502
+ }
503
+ _schedule() {
504
+ this._lease === void 0 && (this._lease = this._app._acquireLoop(this._loop), this._fresh = !0);
505
+ }
506
+ _tick(t) {
507
+ if (this._lease === void 0)
508
+ return;
509
+ if (!this._active(this._fresh)) {
510
+ this._halt();
511
+ return;
512
+ }
513
+ const e = Math.max(0, Math.min(t, this._fresh ? jt : zt));
514
+ this._fresh = !1;
515
+ const s = this._counts, i = this._smooth ? 1 - (1 - this._damping) ** (e * 60) : 1, o = (s[St] > 0 ? 1 : 0) - (s[Nt] > 0 ? 1 : 0), n = (s[At] > 0 ? 1 : 0) - (s[Ot] > 0 ? 1 : 0), a = (s[Dt] > 0 ? 1 : 0) - (s[Lt] > 0 ? 1 : 0), h = Math.sqrt(o * o + n * n + a * a), l = h > 0 ? this._speed * (s[It] > 0 ? this._boost : 1) / h : 0, c = this._velocity;
516
+ c[0] += (o * l - c[0]) * i, c[1] += (n * l - c[1]) * i, c[2] += (a * l - c[2]) * i;
517
+ let _ = 0, u = 0;
518
+ if (this._pendingYaw !== 0 || this._pendingPitch !== 0) {
519
+ const y = Math.abs(this._pendingYaw) * (1 - i) < W && Math.abs(this._pendingPitch) * (1 - i) < W;
520
+ _ = y ? this._pendingYaw : this._pendingYaw * i, u = y ? this._pendingPitch : this._pendingPitch * i, this._pendingYaw -= _, this._pendingPitch -= u;
521
+ }
522
+ const f = ((s[J] > 0 ? 1 : 0) - (s[tt] > 0 ? 1 : 0)) * this._rollSpeed * e;
523
+ let m = !1;
524
+ if ((_ !== 0 || u !== 0 || f !== 0) && (this._orientation.rotate(_, u, f, this._quaternion), m = !0), (c[0] !== 0 || c[1] !== 0 || c[2] !== 0) && e > 0) {
525
+ this._orientation.basis(this._quaternion, this._right, this._up, this._forward);
526
+ const y = this._position;
527
+ for (let g = 0; g < 3; g++)
528
+ y[g] += (this._right[g] * c[0] + this._up[g] * c[1] + this._forward[g] * c[2]) * e;
529
+ m = !0;
530
+ }
531
+ m && this._write(), h === 0 && Math.abs(c[0]) + Math.abs(c[1]) + Math.abs(c[2]) < Tt && (c[0] = 0, c[1] = 0, c[2] = 0), this._wantsFrames() || this._stop();
532
+ }
533
+ /** Stops all motion, the gesture and the lock; the camera keeps its current pose. */
534
+ _halt() {
535
+ this._gesture.cancel(), this._lockSession.exit(), this._clearMotion(), this._stop();
536
+ }
537
+ _clearMotion() {
538
+ this._pressed.clear(), this._counts.fill(0), this._velocity[0] = 0, this._velocity[1] = 0, this._velocity[2] = 0, this._pendingYaw = 0, this._pendingPitch = 0;
539
+ }
540
+ _stop() {
541
+ this._lease?.release(), this._lease = void 0, this._fresh = !1;
542
+ }
543
+ _assertAlive() {
544
+ if (this._destroyed || this._app.destroyed)
545
+ throw new d("destroyed", `[Nova3D] ${this._label} controls are destroyed.`);
546
+ }
547
+ }
548
+ class Yt extends it {
549
+ }
550
+ class Ct extends it {
551
+ }
552
+ function ot(r, t) {
553
+ const e = Math.PI / 2 - 1e-3, s = r.minPitch ?? -e, i = r.maxPitch ?? e;
554
+ if (typeof s != "number" || typeof i != "number" || !Number.isFinite(s) || !Number.isFinite(i) || s < -Math.PI / 2 || i > Math.PI / 2 || s > i)
555
+ throw new d("invalid-option", `[Nova3D] ${t} pitch limits must satisfy -π/2 ≤ minPitch ≤ maxPitch ≤ π/2.`);
556
+ return [s, i];
557
+ }
558
+ function nt(r, t, e) {
559
+ if (t === null || typeof t != "object")
560
+ throw new d("invalid-option", `[Nova3D] ${e} controls require options.`);
561
+ if (r.destroyed || t.camera?.destroyed !== !1 || r.view?.camera !== t.camera)
562
+ throw new d("owner", `[Nova3D] ${e} controls require the active camera of this app.`);
563
+ }
564
+ function Zt(r, t) {
565
+ M(t, Pt, "fly controls"), nt(r, t, "Fly");
566
+ const e = st(t.freeLook, !1, "Fly freeLook"), [s, i] = ot(t, "Fly"), o = e ? new Mt() : new Q(s, i, !1);
567
+ return new Yt(r, t.camera, o, "Fly", t, et, !1);
568
+ }
569
+ function Jt(r, t) {
570
+ M(t, xt, "first-person controls"), nt(r, t, "First-person");
571
+ const [e, s] = ot(t, "First-person");
572
+ return new Ct(r, t.camera, new Q(e, s, !0), "First-person", t, Ft, !0);
573
+ }
574
+ const $t = P({ camera: !0, target: !0, minDistance: !0, maxDistance: !0, minPolarAngle: !0, maxPolarAngle: !0, damping: !0 });
575
+ class Wt {
576
+ /** @internal */
577
+ constructor(t, e, s) {
578
+ if (this._app = t, this._camera = e, t.destroyed || t.view?.camera !== e || e.destroyed)
579
+ throw new d("owner", "[Nova3D] Orbit controls require the active camera of this app.");
580
+ if (this._target = N(s.target, 3, "orbit target"), this._initialTarget = [...this._target], this._initialProjection = e.getOptions(), this._initial = e.getTransform(), this._min = s.minDistance ?? 0.01, this._max = s.maxDistance ?? 1 / 0, this._minPolar = s.minPolarAngle ?? 1e-4, this._maxPolar = s.maxPolarAngle ?? Math.PI - 1e-4, this._damping = s.damping ?? 0, !Number.isFinite(this._min) || this._min <= 0 || this._max < this._min || Number.isNaN(this._max) || !Number.isFinite(this._minPolar) || !Number.isFinite(this._maxPolar) || this._minPolar <= 0 || this._maxPolar >= Math.PI || this._minPolar > this._maxPolar || !Number.isFinite(this._damping) || this._damping < 0 || this._damping > 1)
581
+ throw new d("invalid-option", "[Nova3D] Invalid orbit limits or damping.");
582
+ this._goal = this._readSpherical(), this._apply(this._goal), this._initial = e.getTransform(), this._gesture = new F(t, {
583
+ begin: (n) => this._begin(n),
584
+ move: (n) => this._move(n),
585
+ end: () => {
586
+ this._saved = void 0;
587
+ },
588
+ cancel: () => this._cancel()
589
+ });
590
+ const i = (n) => t._deliverInput(() => {
591
+ if (!(!this._active() || this._saved || !t._claimInput(this)))
592
+ try {
593
+ n.preventDefault(), this._goal = this._readSpherical();
594
+ const a = n.deltaY * (n.deltaMode === 1 ? 16 : n.deltaMode === 2 ? t.size.height : 1), h = e.getOptions();
595
+ if ("verticalSize" in h) {
596
+ e._setProjection({ verticalSize: Math.max(1e-4, Math.min(1e6, h.verticalSize * Math.exp(Math.max(-10, Math.min(10, a * 1e-3))))) });
597
+ return;
598
+ }
599
+ this._goal.radius = this._clampRadius(this._goal.radius * Math.exp(Math.max(-10, Math.min(10, a * 1e-3)))), this._schedule();
600
+ } finally {
601
+ t._releaseInput(this);
602
+ }
603
+ }), o = (n) => {
604
+ this._active() && n.preventDefault();
605
+ };
606
+ t.target.addEventListener("wheel", i, { passive: !1 }), t.target.addEventListener("contextmenu", o), this._cleanup.push(() => t.target.removeEventListener("wheel", i), () => t.target.removeEventListener("contextmenu", o)), this._cleanup.push(t.onUpdate((n) => this._tick(n.deltaTime))), this._cleanup.push(t._own(() => this.destroy()));
607
+ }
608
+ _gesture;
609
+ _cleanup = [];
610
+ _initial;
611
+ _initialProjection;
612
+ _initialTarget;
613
+ _min;
614
+ _max;
615
+ _minPolar;
616
+ _maxPolar;
617
+ _damping;
618
+ _target;
619
+ _goal;
620
+ _lease;
621
+ _saved;
622
+ _point = [0, 0];
623
+ _button = 0;
624
+ _enabled = !0;
625
+ _destroyed = !1;
626
+ get enabled() {
627
+ return this._enabled;
628
+ }
629
+ get destroyed() {
630
+ return this._destroyed;
631
+ }
632
+ /** Disabling stops a drag and any damped motion. */
633
+ setEnabled(t) {
634
+ if (this._assertAlive(), typeof t != "boolean")
635
+ throw new d("invalid-option", "[Nova3D] enabled must be boolean.");
636
+ t || (this._gesture.cancel(), this._stop()), this._enabled = t;
637
+ }
638
+ /** Moves the orbit centre; the camera keeps its position and turns to the target. */
639
+ setTarget(t) {
640
+ this._assertAlive();
641
+ const e = N(t, 3, "orbit target");
642
+ this._gesture.cancel(), this._stop();
643
+ const s = this._target;
644
+ this._target = e;
645
+ try {
646
+ this._goal = this._readSpherical(), this._apply(this._goal);
647
+ } catch (i) {
648
+ throw this._target = s, i;
649
+ }
650
+ }
651
+ /** Restores the camera pose, projection and target from creation. */
652
+ reset() {
653
+ this._assertAlive(), this._gesture.cancel(), this._stop(), this._camera._setTransform(this._initial), this._camera._setProjection(this._initialProjection), this._target = [...this._initialTarget], this._goal = this._readSpherical();
654
+ }
655
+ destroy() {
656
+ if (!this._destroyed) {
657
+ this._destroyed = !0;
658
+ try {
659
+ this._gesture.destroy();
660
+ } finally {
661
+ this._stop();
662
+ for (const t of this._cleanup.splice(0).reverse())
663
+ t();
664
+ }
665
+ }
666
+ }
667
+ _active() {
668
+ return !this._destroyed && this._enabled && !this._camera.destroyed && this._app.view?.camera === this._camera;
669
+ }
670
+ _begin(t) {
671
+ return !this._active() || t.button !== 0 && t.button !== 2 ? !1 : (this._stop(), this._goal = this._readSpherical(), this._saved = { transform: this._camera.getTransform(), target: [...this._target] }, this._point = [t.clientX, t.clientY], this._button = t.button, !0);
672
+ }
673
+ _move(t) {
674
+ if (!this._active()) {
675
+ this._gesture.cancel();
676
+ return;
677
+ }
678
+ const e = t.clientX - this._point[0], s = t.clientY - this._point[1];
679
+ this._point = [t.clientX, t.clientY];
680
+ const i = this._app.target.getBoundingClientRect();
681
+ if (!(i.width <= 0 || i.height <= 0)) {
682
+ if (this._button === 0)
683
+ this._goal.theta -= e * Math.PI * 2 / i.width, this._goal.phi = Math.max(this._minPolar, Math.min(this._maxPolar, this._goal.phi + s * Math.PI / i.height));
684
+ else {
685
+ const o = this._camera.getWorldMatrix(), n = this._camera.getOptions(), a = "fov" in n ? 2 * this._goal.radius * Math.tan(n.fov / 2) : n.verticalSize, h = k(p(), [o[0], o[1], o[2]]), l = k(p(), [o[4], o[5], o[6]]), c = q(p(), B(p(), h, -e * a / i.height), l, s * a / i.height);
686
+ this._target = this._target.map((_, u) => _ + c[u]);
687
+ }
688
+ this._schedule();
689
+ }
690
+ }
691
+ _readSpherical() {
692
+ const t = this._camera.getWorldMatrix(), e = [t[12] - this._target[0], t[13] - this._target[1], t[14] - this._target[2]], s = Math.hypot(...e);
693
+ if (s < 1e-10)
694
+ throw new d("invalid-option", "[Nova3D] Orbit camera and target must differ.");
695
+ return { radius: this._clampRadius(s), theta: Math.atan2(e[0], e[2]), phi: Math.max(this._minPolar, Math.min(this._maxPolar, Math.acos(Math.max(-1, Math.min(1, e[1] / s))))) };
696
+ }
697
+ _apply(t) {
698
+ const { radius: e, theta: s, phi: i } = t, o = [this._target[0] + e * Math.sin(i) * Math.sin(s), this._target[1] + e * Math.cos(i), this._target[2] + e * Math.sin(i) * Math.cos(s)], n = ct(w(), o, this._target, [0, 1, 0]), a = E(this._camera.getWorldMatrix()).scale;
699
+ lt(n, n, a);
700
+ const h = this._camera.parent;
701
+ if (h instanceof z) {
702
+ const l = j(w(), h.getWorldMatrix());
703
+ if (!l)
704
+ throw new d("invalid-option", "[Nova3D] Orbit camera parent is singular.");
705
+ T(n, l, n);
706
+ }
707
+ this._camera._setTransform(E(n));
708
+ }
709
+ _schedule() {
710
+ if (this._damping === 0 || this._damping === 1) {
711
+ this._apply(this._goal), this._stop();
712
+ return;
713
+ }
714
+ this._lease ??= this._app._acquireLoop("nova3d.orbit");
715
+ }
716
+ _tick(t) {
717
+ if (!this._lease)
718
+ return;
719
+ if (!this._active()) {
720
+ this._gesture.cancel(), this._stop();
721
+ return;
722
+ }
723
+ const e = this._readSpherical(), s = 1 - (1 - this._damping) ** (Math.max(1e-3, Math.min(0.1, t)) * 60);
724
+ let i = this._goal.theta - e.theta;
725
+ i = Math.atan2(Math.sin(i), Math.cos(i));
726
+ const o = this._goal.radius - e.radius, n = this._goal.phi - e.phi;
727
+ if (Math.max(Math.abs(o), Math.abs(i), Math.abs(n)) < 1e-5) {
728
+ this._apply(this._goal), this._stop();
729
+ return;
730
+ }
731
+ try {
732
+ this._apply({ radius: e.radius + o * s, theta: e.theta + i * s, phi: e.phi + n * s });
733
+ } catch (a) {
734
+ throw this._stop(), a;
735
+ }
736
+ }
737
+ _cancel() {
738
+ this._stop();
739
+ const t = this._saved;
740
+ this._saved = void 0, t && !this._camera.destroyed && (this._target = t.target, this._camera._setTransform(t.transform), this._goal = this._readSpherical());
741
+ }
742
+ _stop() {
743
+ this._lease?.release(), this._lease = void 0;
744
+ }
745
+ _clampRadius(t) {
746
+ return Math.max(this._min, Math.min(this._max, t));
747
+ }
748
+ _assertAlive() {
749
+ if (this._destroyed || this._app.destroyed)
750
+ throw new d("destroyed", "[Nova3D] Orbit controls are destroyed.");
751
+ }
752
+ }
753
+ function te(r, t) {
754
+ return M(t, $t, "orbit controls"), new Wt(r, t.camera, t);
755
+ }
756
+ const rt = P({ step: !0 }), Gt = P({ step: !0, origin: !0 });
757
+ function K(r, t, e = 0) {
758
+ if (O(r, "snap value"), O(t, "snap step"), O(e, "snap origin"), t <= 0)
759
+ throw new d("invalid-option", "[Nova3D] Snap step must be positive.");
760
+ const s = e + Math.round((r - e) / t) * t;
761
+ if (!Number.isFinite(s))
762
+ throw new d("invalid-option", "[Nova3D] Snapped value overflowed.");
763
+ return Object.is(s, -0) ? 0 : s;
764
+ }
765
+ function ee(r, t) {
766
+ M(t, Gt, "snap");
767
+ const e = N(r, 3, "position"), s = N(t.origin ?? [0, 0, 0], 3, "origin");
768
+ return e.map((i, o) => K(i, t.step, s[o]));
769
+ }
770
+ function se(r, t) {
771
+ return M(t, rt, "snap"), K(r, t.step);
772
+ }
773
+ function ie(r, t) {
774
+ return M(t, rt, "snap"), N(r, 3, "scale").map((e) => K(e, t.step));
775
+ }
776
+ const Vt = P({ camera: !0, mode: !0, space: !0, onGesture: !0 }), G = [[1, 0, 0], [0, 1, 0], [0, 0, 1]], Xt = ["x", "y", "z"], V = ["#ff4545", "#53cf78", "#599bff"];
777
+ function X(r) {
778
+ return Object.freeze({ position: Object.freeze([...r.position]), quaternion: Object.freeze([...r.quaternion]), scale: Object.freeze([...r.scale]) });
779
+ }
780
+ function U(r, t, e) {
781
+ const s = x(r.direction, e);
782
+ if (Math.abs(s) < 1e-8)
783
+ return null;
784
+ const i = x(L(p(), t, r.origin), e) / s;
785
+ return i < 0 ? null : r.origin.map((o, n) => o + r.direction[n] * i);
786
+ }
787
+ function Ut(r, t, e) {
788
+ const s = e.x - t.x, i = e.y - t.y, o = s * s + i * i;
789
+ if (o < 16)
790
+ return 1 / 0;
791
+ const n = Math.max(0, Math.min(1, ((r.x - t.x) * s + (r.y - t.y) * i) / o));
792
+ return Math.hypot(r.x - t.x - n * s, r.y - t.y - n * i);
793
+ }
794
+ class qt {
795
+ /** @internal */
796
+ constructor(t, e) {
797
+ if (this._app = t, this._options = e, t.destroyed || t.view?.camera !== e.camera || e.camera.destroyed || typeof e.onGesture != "function")
798
+ throw new d("invalid-option", "[Nova3D] Gizmo requires the active camera and a gesture callback.");
799
+ this._validateMode(e.mode), this._validateSpace(e.space), this._mode = e.mode, this._space = e.space, this._gesture = new F(t, {
800
+ begin: (s) => this._begin(s),
801
+ move: (s) => this._move(s),
802
+ end: () => this._finish("end"),
803
+ cancel: () => this._finish("cancel")
804
+ }, !0), this._cleanup.push(t._beforeRender(() => this._updateVisuals())), this._cleanup.push(t._own(() => this.destroy()));
805
+ }
806
+ _gesture;
807
+ _cleanup = [];
808
+ _mode;
809
+ _space;
810
+ _node;
811
+ _root;
812
+ _geometry = [];
813
+ _materials = [];
814
+ _positions = [];
815
+ _drag;
816
+ _enabled = !0;
817
+ _destroyed = !1;
818
+ get enabled() {
819
+ return this._enabled;
820
+ }
821
+ get destroyed() {
822
+ return this._destroyed;
823
+ }
824
+ /** Disabled gizmos stay visible but ignore pointer input; disabling cancels a drag. */
825
+ setEnabled(t) {
826
+ if (this._assertAlive(), typeof t != "boolean")
827
+ throw new d("invalid-option", "[Nova3D] enabled must be boolean.");
828
+ t || this.cancel(), this._enabled = t;
829
+ }
830
+ /** Shows the gizmo on `node`, a live object of the active scene. */
831
+ attach(t) {
832
+ if (this._assertAlive(), t.destroyed || t.scene !== this._app.view?.scene || t === this._options.camera)
833
+ throw new d("owner", "[Nova3D] Gizmo target must be a live object in the active scene.");
834
+ this.cancel(), this._assertAlive(), this._disposeVisuals(), this._node = t;
835
+ try {
836
+ this._createVisuals(), this._updateVisuals();
837
+ } catch (e) {
838
+ throw this._disposeVisuals(), this._node = void 0, e;
839
+ }
840
+ }
841
+ detach() {
842
+ this.cancel(), this._node = void 0, this._disposeVisuals();
843
+ }
844
+ setMode(t) {
845
+ if (this._assertAlive(), this._validateMode(t), t === this._mode)
846
+ return;
847
+ const e = this._node;
848
+ this.cancel(), this._mode = t, e && !e.destroyed && this.attach(e);
849
+ }
850
+ setSpace(t) {
851
+ this._assertAlive(), this._validateSpace(t), this.cancel(), this._space = t, this._updateVisuals();
852
+ }
853
+ cancel() {
854
+ this._gesture.cancel();
855
+ }
856
+ destroy() {
857
+ if (!this._destroyed) {
858
+ this._destroyed = !0;
859
+ try {
860
+ this._gesture.destroy();
861
+ } finally {
862
+ this._node = void 0, this._disposeVisuals();
863
+ for (const t of this._cleanup.splice(0).reverse())
864
+ t();
865
+ }
866
+ }
867
+ }
868
+ _basis() {
869
+ const t = this._node;
870
+ if (!t || t.destroyed || this._options.camera.destroyed || this._app.view?.camera !== this._options.camera || this._app.view?.scene !== t.scene)
871
+ return null;
872
+ const e = t.getWorldMatrix(), s = [e[12], e[13], e[14]], i = this._app.project(s);
873
+ if (!i.inFrustum)
874
+ return null;
875
+ const o = this._app.unproject({ x: i.x, y: i.y + 64, depth: i.depth }), n = _t(s, o);
876
+ if (!Number.isFinite(n) || n < 1e-10)
877
+ return null;
878
+ const a = G.map((h, l) => this._space === "world" ? h : Array.from(k(p(), [e[l * 4], e[l * 4 + 1], e[l * 4 + 2]])));
879
+ return a.some((h) => Math.hypot(...h) < 0.5) ? null : { origin: s, directions: a, length: n };
880
+ }
881
+ _createVisuals() {
882
+ const t = this._node.scene;
883
+ this._root = t.createGroup({ pickable: !1 });
884
+ for (let e = 0; e < 3; e++) {
885
+ const s = new Float32Array(this._mode === "rotate" ? 384 : 6), i = this._app.createGeometry({ positions: s, topology: "lines", usage: "dynamic" });
886
+ this._geometry.push(i), this._positions.push(s);
887
+ const o = this._app.createMaterial({ type: "basic", color: V[e] });
888
+ this._materials.push(o), t.createMesh({ geometry: i, material: o, pickable: !1 }).reparent(this._root);
889
+ }
890
+ }
891
+ _points(t, e) {
892
+ const s = [];
893
+ if (this._mode === "rotate") {
894
+ const i = e.directions[(t + 1) % 3], o = e.directions[(t + 2) % 3];
895
+ for (let n = 0; n < 64; n++)
896
+ for (const a of [n * Math.PI / 32, (n + 1) * Math.PI / 32])
897
+ s.push(...e.origin.map((h, l) => h + e.length * (i[l] * Math.cos(a) + o[l] * Math.sin(a))));
898
+ } else
899
+ s.push(...e.origin, ...e.origin.map((i, o) => i + e.directions[t][o] * e.length));
900
+ return new Float32Array(s);
901
+ }
902
+ _updateVisuals() {
903
+ const t = this._basis();
904
+ if (!t) {
905
+ this._gesture.cancel(), this._root && !this._root.destroyed && this._root.setVisible(!1), this._node?.destroyed && (this._disposeVisuals(), this._node = void 0);
906
+ return;
907
+ }
908
+ if (!(!this._root || this._root.destroyed)) {
909
+ this._root.setVisible(!0);
910
+ for (let e = 0; e < 3; e++) {
911
+ const s = this._points(e, t);
912
+ s.some((i, o) => i !== this._positions[e][o]) && (this._geometry[e].updateRange(0, { positions: s }), this._positions[e] = s);
913
+ }
914
+ }
915
+ }
916
+ _point(t) {
917
+ const e = this._app.target.getBoundingClientRect();
918
+ return { x: (t.clientX - e.left) * this._app.size.width / e.width, y: (t.clientY - e.top) * this._app.size.height / e.height };
919
+ }
920
+ _begin(t) {
921
+ if (t.button !== 0 || this._destroyed || !this._enabled)
922
+ return !1;
923
+ const e = this._basis();
924
+ if (!e)
925
+ return !1;
926
+ const s = this._point(t);
927
+ let i = -1, o = 8;
928
+ for (let g = 0; g < 3; g++) {
929
+ const b = this._points(g, e);
930
+ for (let v = 0; v < b.length; v += 6) {
931
+ const at = this._app.project([b[v], b[v + 1], b[v + 2]]), ht = this._app.project([b[v + 3], b[v + 4], b[v + 5]]), R = Ut(s, at, ht);
932
+ R < o && (o = R, i = g);
933
+ }
934
+ }
935
+ if (i < 0)
936
+ return !1;
937
+ const n = this._options.camera.getWorldMatrix(), a = e.directions[i], h = L(p(), [n[12], n[13], n[14]], e.origin), l = this._mode === "rotate" ? dt(a) : q(p(), h, a, -x(h, a));
938
+ if (ut(l) < 1e-8)
939
+ return !1;
940
+ k(l, l);
941
+ const c = Array.from(l), _ = U(this._app.screenRay(s), e.origin, c);
942
+ if (!_)
943
+ return !1;
944
+ const u = this._node, f = X(u.getTransform()), m = u.parent, y = m instanceof z ? m.getWorldMatrix() : w();
945
+ if (!j(w(), y))
946
+ throw new d("invalid-option", "[Nova3D] Gizmo parent is singular.");
947
+ return this._drag = { node: u, axis: i, direction: a, origin: e.origin, normal: c, anchor: _, from: f, last: f, world: u.getWorldMatrix(), parent: m, parentWorld: y, length: e.length }, this._materials[i].set({ color: "#ffffff" }), this._emit("begin", this._drag, f), !0;
948
+ }
949
+ _move(t) {
950
+ const e = this._drag;
951
+ if (!e)
952
+ return;
953
+ const s = e.parent instanceof z ? e.parent.getWorldMatrix() : w();
954
+ if (e.node.destroyed || e.node.parent !== e.parent || Array.from(s).some((h, l) => h !== e.parentWorld[l]) || this._app.view?.camera !== this._options.camera) {
955
+ this.cancel();
956
+ return;
957
+ }
958
+ const i = U(this._app.screenRay(this._point(t)), e.origin, e.normal);
959
+ if (!i)
960
+ return;
961
+ const o = L(p(), i, e.anchor), n = x(o, e.direction);
962
+ let a;
963
+ if (this._mode === "rotate" && this._space === "local") {
964
+ const h = this._angle(e, i) * Math.sign(pt(e.world)), l = ft(Y(), e.from.quaternion, mt(Y(), G[e.axis], h));
965
+ a = { ...e.from, quaternion: Array.from(l) };
966
+ } else if (this._mode === "scale" && this._space === "local") {
967
+ const h = [...e.from.scale];
968
+ h[e.axis] *= Math.max(1e-4, 1 + n / e.length), a = { ...e.from, scale: h };
969
+ } else {
970
+ const h = w();
971
+ if (this._mode === "translate")
972
+ gt(h, B(p(), e.direction, n));
973
+ else {
974
+ if (this._mode === "rotate")
975
+ yt(h, this._angle(e, i), e.direction);
976
+ else {
977
+ const u = Math.max(1e-4, 1 + n / e.length) - 1;
978
+ for (let f = 0; f < 3; f++)
979
+ for (let m = 0; m < 3; m++)
980
+ h[f * 4 + m] += u * e.direction[f] * e.direction[m];
981
+ }
982
+ const _ = vt(p(), e.origin, h);
983
+ h[12] = e.origin[0] - _[0], h[13] = e.origin[1] - _[1], h[14] = e.origin[2] - _[2];
984
+ }
985
+ const l = T(w(), h, e.world), c = j(w(), e.parentWorld);
986
+ a = E(T(l, c, l));
987
+ }
988
+ e.last = X(a), this._emit("change", e, e.last);
989
+ }
990
+ _angle(t, e) {
991
+ const s = k(p(), L(p(), t.anchor, t.origin)), i = k(p(), L(p(), e, t.origin));
992
+ return Math.atan2(x(t.direction, wt(p(), s, i)), x(s, i));
993
+ }
994
+ _finish(t) {
995
+ const e = this._drag;
996
+ if (this._drag = void 0, !e)
997
+ return;
998
+ const s = this._materials[e.axis];
999
+ s && !s.destroyed && s.set({ color: V[e.axis] }), this._emit(t, e, t === "cancel" ? e.from : e.last);
1000
+ }
1001
+ _emit(t, e, s) {
1002
+ this._options.onGesture(Object.freeze({ type: t, node: e.node, axis: Xt[e.axis], mode: this._mode, space: this._space, from: e.from, transform: s }));
1003
+ }
1004
+ _disposeVisuals() {
1005
+ this._root?.destroy(), this._root = void 0;
1006
+ for (const t of this._geometry.splice(0))
1007
+ t.destroy();
1008
+ for (const t of this._materials.splice(0))
1009
+ t.destroy();
1010
+ this._positions.length = 0;
1011
+ }
1012
+ _validateMode(t) {
1013
+ if (!["translate", "rotate", "scale"].includes(t))
1014
+ throw new d("invalid-option", "[Nova3D] Invalid gizmo mode.");
1015
+ }
1016
+ _validateSpace(t) {
1017
+ if (!["local", "world"].includes(t))
1018
+ throw new d("invalid-option", "[Nova3D] Invalid gizmo space.");
1019
+ }
1020
+ _assertAlive() {
1021
+ if (this._destroyed || this._app.destroyed)
1022
+ throw new d("destroyed", "[Nova3D] Gizmo is destroyed.");
1023
+ }
1024
+ }
1025
+ function oe(r, t) {
1026
+ return M(t, Vt, "transform gizmo"), new qt(r, t);
1027
+ }
1028
+ export {
1029
+ it as Nova3DCameraMotionControls,
1030
+ Ct as Nova3DFirstPersonControls,
1031
+ Yt as Nova3DFlyControls,
1032
+ Wt as Nova3DOrbitControls,
1033
+ qt as Nova3DTransformGizmo,
1034
+ Jt as createFirstPersonControls,
1035
+ Zt as createFlyControls,
1036
+ te as createOrbitControls,
1037
+ oe as createTransformGizmo,
1038
+ se as snapRotation,
1039
+ ie as snapScale,
1040
+ ee as snapTranslation
1041
+ };