@nova-lab/core 1.0.0-dev.19 → 1.1.0-dev.229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1035 -10
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/dist/2d/accessibility.d.ts +2 -0
- package/dist/2d/accessibility.js +171 -0
- package/dist/2d/commands.d.ts +2 -0
- package/dist/2d/commands.js +80 -0
- package/dist/2d/effects.d.ts +10 -0
- package/dist/2d/effects.js +566 -0
- package/dist/2d/ktx2.d.ts +5 -0
- package/dist/2d/ktx2.js +542 -0
- package/dist/2d/lighting.d.ts +3 -0
- package/dist/2d/lighting.js +495 -0
- package/dist/2d/lottie.d.ts +3 -0
- package/dist/2d/lottie.js +254 -0
- package/dist/2d/meshes.d.ts +4 -0
- package/dist/2d/meshes.js +451 -0
- package/dist/2d/primitives.d.ts +3 -0
- package/dist/2d/primitives.js +85 -0
- package/dist/2d/render-textures.d.ts +3 -0
- package/dist/2d/render-textures.js +539 -0
- package/dist/2d/svg/documents.d.ts +5 -0
- package/dist/2d/svg/documents.js +7 -0
- package/dist/2d/svg/renderer.d.ts +3 -0
- package/dist/2d/svg/renderer.js +222 -0
- package/dist/2d/svg.d.ts +3 -0
- package/dist/2d/svg.js +4 -0
- package/dist/2d/tools.d.ts +2 -0
- package/dist/2d/tools.js +100 -0
- package/dist/2d/video.d.ts +5 -0
- package/dist/2d/video.js +90 -0
- package/dist/2d.d.ts +2 -0
- package/dist/2d.js +220 -0
- package/dist/3d/animation.d.ts +8 -0
- package/dist/3d/animation.js +1396 -0
- package/dist/3d/area-lights.d.ts +2 -0
- package/dist/3d/area-lights.js +19 -0
- package/dist/3d/audio.d.ts +4 -0
- package/dist/3d/audio.js +500 -0
- package/dist/3d/character.d.ts +2 -0
- package/dist/3d/character.js +136 -0
- package/dist/3d/collision.d.ts +3 -0
- package/dist/3d/collision.js +387 -0
- package/dist/3d/commands.d.ts +2 -0
- package/dist/3d/commands.js +108 -0
- package/dist/3d/controls.d.ts +8 -0
- package/dist/3d/controls.js +1041 -0
- package/dist/3d/documents.d.ts +5 -0
- package/dist/3d/documents.js +227 -0
- package/dist/3d/effects.d.ts +5 -0
- package/dist/3d/effects.js +1986 -0
- package/dist/3d/export.d.ts +4 -0
- package/dist/3d/export.js +347 -0
- package/dist/3d/fbx.d.ts +2 -0
- package/dist/3d/fbx.js +784 -0
- package/dist/3d/gltf.d.ts +2 -0
- package/dist/3d/gltf.js +5 -0
- package/dist/3d/helpers.d.ts +5 -0
- package/dist/3d/helpers.js +191 -0
- package/dist/3d/ik.d.ts +9 -0
- package/dist/3d/ik.js +777 -0
- package/dist/3d/loaders.d.ts +17 -0
- package/dist/3d/loaders.js +1406 -0
- package/dist/3d/nodes.d.ts +8 -0
- package/dist/3d/nodes.js +49 -0
- package/dist/3d/particles.d.ts +5 -0
- package/dist/3d/particles.js +1574 -0
- package/dist/3d/physics/backend.d.ts +7 -0
- package/dist/3d/physics/backend.js +1 -0
- package/dist/3d/physics/rapier.d.ts +3 -0
- package/dist/3d/physics/rapier.js +765 -0
- package/dist/3d/physics.d.ts +5 -0
- package/dist/3d/physics.js +3346 -0
- package/dist/3d/splats.d.ts +7 -0
- package/dist/3d/splats.js +862 -0
- package/dist/3d/text.d.ts +5 -0
- package/dist/3d/text.js +1043 -0
- package/dist/3d/tiles.d.ts +24 -0
- package/dist/3d/tiles.js +1705 -0
- package/dist/3d/tools.d.ts +12 -0
- package/dist/3d/tools.js +338 -0
- package/dist/3d/usdz.d.ts +2 -0
- package/dist/3d/usdz.js +634 -0
- package/dist/3d/xr.d.ts +2 -0
- package/dist/3d/xr.js +202 -0
- package/dist/3d-B4jWF8Qb.js +5591 -0
- package/dist/3d.d.ts +40 -0
- package/dist/3d.js +44 -0
- package/dist/Capsule-BFVpZfvc.js +44 -0
- package/dist/Clip-CAN7t03k.js +204 -0
- package/dist/Color-vuv9UnoY.js +34 -0
- package/dist/DeformedMesh-CPi0P_vc.js +280 -0
- package/dist/Document-DCVEZSvM.js +415 -0
- package/dist/Errors-B2ekO9bZ.js +30 -0
- package/dist/Features-BsjmePtc.js +557 -0
- package/dist/GLTFResourceIO-CYJyCUTt.js +124 -0
- package/dist/GPUParticleState-CQlNpoDa.js +545 -0
- package/dist/Geometry-DytO490z.js +227 -0
- package/dist/Inflate-DWw0V-Up.js +42 -0
- package/dist/InstancedMesh-DPrgrw5z.js +527 -0
- package/dist/Limits-Bw5XQdFr.js +20 -0
- package/dist/LineHelper-Ad0z9uDi.js +131 -0
- package/dist/LoaderIO-BwrM84OM.js +114 -0
- package/dist/Material-BpfLPmK9.js +777 -0
- package/dist/Mesh-BaRxAAJq.js +209 -0
- package/dist/Node-QfgAE2_v.js +877 -0
- package/dist/NovaAssetRegistry-p2QlCwvT.js +1168 -0
- package/dist/NovaNode-CBZ-Ol-W.js +2016 -0
- package/dist/NovaRenderCommandWriter-CWQRa42y.js +1949 -0
- package/dist/NovaTextSelectionService-CipuujCT.js +18526 -0
- package/dist/NovaWebGLProgram-BO250QNF.js +97 -0
- package/dist/Options-CajE7LLJ.js +15 -0
- package/dist/PolygonMesh-D4PnnfIo.js +657 -0
- package/dist/Ready-BzyhRtjD.js +21 -0
- package/dist/Scene-CDfNgf9I.js +911 -0
- package/dist/Shader-b6_HDndT.js +48 -0
- package/dist/SplatShader-wJ6GJ3vo.js +130 -0
- package/dist/Texture-dTKMlTpK.js +267 -0
- package/dist/TextureLoader-CfDzdy2m.js +411 -0
- package/dist/Textures-CGL4Kf-8.js +651 -0
- package/dist/ToneMapping-D9IWvN0u.js +46 -0
- package/dist/WebGPURenderer-DjD0IxVC.js +4921 -0
- package/dist/ZipReader-C-MSEsSr.js +84 -0
- package/dist/core.js +218 -24024
- package/dist/domain/types/base.types.d.ts +18 -9
- package/dist/domain/types/component.types.d.ts +5 -5
- package/dist/domain/types/cursor.types.d.ts +1 -1
- package/dist/domain/types/diagnostics.types.d.ts +2 -0
- package/dist/domain/types/export.types.d.ts +2 -2
- package/dist/domain/types/hit-test.types.d.ts +1 -1
- package/dist/domain/types/motion.types.d.ts +2 -2
- package/dist/domain/types/renderer.types.d.ts +88 -4
- package/dist/domain/types/rendering/index.d.ts +29 -4
- package/dist/domain/types/sound.types.d.ts +1 -1
- package/dist/domain/types/theme.types.d.ts +1 -1
- package/dist/domain/utils/bounds.d.ts +1 -1
- package/dist/domain/utils/nova-text.d.ts +9 -0
- package/dist/domain/utils/schemaBounds.d.ts +2 -2
- package/dist/export-svg-document-ChaNXMaG.js +668 -0
- package/dist/features/3d/Errors.d.ts +57 -0
- package/dist/features/3d/Nova3DApp.d.ts +429 -0
- package/dist/features/3d/animation/Animator.d.ts +260 -0
- package/dist/features/3d/animation/Clip.d.ts +74 -0
- package/dist/features/3d/animation/Graph.d.ts +158 -0
- package/dist/features/3d/animation/Mask.d.ts +40 -0
- package/dist/features/3d/audio/Audio.d.ts +114 -0
- package/dist/features/3d/audio/Sound.d.ts +133 -0
- package/dist/features/3d/character/CharacterController.d.ts +61 -0
- package/dist/features/3d/collision/Capsule.d.ts +25 -0
- package/dist/features/3d/collision/Octree.d.ts +94 -0
- package/dist/features/3d/controls/CameraMotionControls.d.ts +154 -0
- package/dist/features/3d/controls/CameraOrientation.d.ts +47 -0
- package/dist/features/3d/controls/OrbitControls.d.ts +73 -0
- package/dist/features/3d/controls/PointerGesture.d.ts +25 -0
- package/dist/features/3d/controls/PointerLock.d.ts +36 -0
- package/dist/features/3d/controls/Snapping.d.ts +32 -0
- package/dist/features/3d/controls/TransformGizmo.d.ts +79 -0
- package/dist/features/3d/deformation/DeformationGPU.d.ts +52 -0
- package/dist/features/3d/deformation/DeformationShader.d.ts +2 -0
- package/dist/features/3d/deformation/DeformedMesh.d.ts +36 -0
- package/dist/features/3d/deformation/GeometryDeformation.d.ts +25 -0
- package/dist/features/3d/documents/Document.d.ts +59 -0
- package/dist/features/3d/documents/DocumentCommands.d.ts +45 -0
- package/dist/features/3d/documents/DocumentSchema.d.ts +18 -0
- package/dist/features/3d/documents/DocumentTransform.d.ts +4 -0
- package/dist/features/3d/documents/DocumentTypes.d.ts +182 -0
- package/dist/features/3d/documents/DocumentValidation.d.ts +18 -0
- package/dist/features/3d/documents/Projection.d.ts +65 -0
- package/dist/features/3d/effects/CubeLUT.d.ts +24 -0
- package/dist/features/3d/effects/Effects.d.ts +32 -0
- package/dist/features/3d/effects/EffectsGPU.d.ts +80 -0
- package/dist/features/3d/effects/EffectsPlan.d.ts +268 -0
- package/dist/features/3d/effects/EffectsShaders.d.ts +35 -0
- package/dist/features/3d/export/GLTFExporter.d.ts +49 -0
- package/dist/features/3d/export/ThreeMFExporter.d.ts +19 -0
- package/dist/features/3d/export/ZipWriter.d.ts +9 -0
- package/dist/features/3d/fbx/FBXLoader.d.ts +26 -0
- package/dist/features/3d/fbx/FBXParser.d.ts +35 -0
- package/dist/features/3d/fbx/FBXScene.d.ts +20 -0
- package/dist/features/3d/gltf/GLTFLoader.d.ts +16 -0
- package/dist/features/3d/gltf/GLTFTypes.d.ts +64 -0
- package/dist/features/3d/gltf/services/GLTFBinary.d.ts +21 -0
- package/dist/features/3d/gltf/services/GLTFGeometry.d.ts +14 -0
- package/dist/features/3d/gltf/services/GLTFResourceIO.d.ts +64 -0
- package/dist/features/3d/helpers/LineHelper.d.ts +51 -0
- package/dist/features/3d/helpers/StaticHelpers.d.ts +47 -0
- package/dist/features/3d/helpers/TrackedHelpers.d.ts +84 -0
- package/dist/features/3d/ik/ChainIK.d.ts +44 -0
- package/dist/features/3d/ik/IKChain.d.ts +92 -0
- package/dist/features/3d/ik/IKMath.d.ts +49 -0
- package/dist/features/3d/ik/IKSolver.d.ts +97 -0
- package/dist/features/3d/ik/LookAtIK.d.ts +58 -0
- package/dist/features/3d/ik/TwoBoneIK.d.ts +57 -0
- package/dist/features/3d/import/ImportAnimation.d.ts +20 -0
- package/dist/features/3d/import/ImportMath.d.ts +42 -0
- package/dist/features/3d/import/ImportedModel.d.ts +135 -0
- package/dist/features/3d/import/Inflate.d.ts +5 -0
- package/dist/features/3d/import/ModelAsset.d.ts +149 -0
- package/dist/features/3d/import/PolygonMesh.d.ts +54 -0
- package/dist/features/3d/lights/AreaLightTables.d.ts +8 -0
- package/dist/features/3d/lights/AreaLights.d.ts +11 -0
- package/dist/features/3d/loaders/EXRCompression.d.ts +13 -0
- package/dist/features/3d/loaders/EXRLoader.d.ts +39 -0
- package/dist/features/3d/loaders/HDRLoader.d.ts +26 -0
- package/dist/features/3d/loaders/Limits.d.ts +70 -0
- package/dist/features/3d/loaders/LoaderBuffers.d.ts +42 -0
- package/dist/features/3d/loaders/LoaderIO.d.ts +81 -0
- package/dist/features/3d/loaders/LoaderModel.d.ts +80 -0
- package/dist/features/3d/loaders/LoaderText.d.ts +27 -0
- package/dist/features/3d/loaders/MTLLoader.d.ts +105 -0
- package/dist/features/3d/loaders/OBJLoader.d.ts +70 -0
- package/dist/features/3d/loaders/PLYLoader.d.ts +47 -0
- package/dist/features/3d/loaders/STLLoader.d.ts +27 -0
- package/dist/features/3d/model/Camera.d.ts +33 -0
- package/dist/features/3d/model/Environment.d.ts +31 -0
- package/dist/features/3d/model/Geometry.d.ts +59 -0
- package/dist/features/3d/model/InstancedMesh.d.ts +134 -0
- package/dist/features/3d/model/LOD.d.ts +31 -0
- package/dist/features/3d/model/Light.d.ts +200 -0
- package/dist/features/3d/model/Material.d.ts +308 -0
- package/dist/features/3d/model/MaterialExtensions.d.ts +200 -0
- package/dist/features/3d/model/Mesh.d.ts +92 -0
- package/dist/features/3d/model/Node.d.ts +87 -0
- package/dist/features/3d/model/ReflectionProbe.d.ts +45 -0
- package/dist/features/3d/model/RenderTarget.d.ts +41 -0
- package/dist/features/3d/model/Scene.d.ts +173 -0
- package/dist/features/3d/model/Texture.d.ts +143 -0
- package/dist/features/3d/nodes/Nodes.d.ts +8 -0
- package/dist/features/3d/nodes/ShaderNode.d.ts +240 -0
- package/dist/features/3d/particles/GPUParticleSchedule.d.ts +67 -0
- package/dist/features/3d/particles/GPUParticleShaders.d.ts +19 -0
- package/dist/features/3d/particles/GPUParticleState.d.ts +106 -0
- package/dist/features/3d/particles/GPUParticleSystem.d.ts +192 -0
- package/dist/features/3d/particles/ParticleCurves.d.ts +34 -0
- package/dist/features/3d/particles/ParticleOptions.d.ts +78 -0
- package/dist/features/3d/particles/ParticleSystem.d.ts +368 -0
- package/dist/features/3d/physics/PhysicsBackend.d.ts +352 -0
- package/dist/features/3d/physics/PhysicsDebug.d.ts +24 -0
- package/dist/features/3d/physics/PhysicsWorld.d.ts +352 -0
- package/dist/features/3d/physics/basic/BasicCollision.d.ts +75 -0
- package/dist/features/3d/physics/basic/BasicPhysics.d.ts +24 -0
- package/dist/features/3d/physics/basic/BasicShapes.d.ts +103 -0
- package/dist/features/3d/physics/rapier/ContactBuffer.d.ts +32 -0
- package/dist/features/3d/physics/rapier/RapierBackend.d.ts +17 -0
- package/dist/features/3d/physics/rapier/RapierShapes.d.ts +4 -0
- package/dist/features/3d/physics/rapier/RapierWorld.d.ts +198 -0
- package/dist/features/3d/physics/rapier/Validation.d.ts +8 -0
- package/dist/features/3d/services/Background.d.ts +22 -0
- package/dist/features/3d/services/BasicShader.d.ts +55 -0
- package/dist/features/3d/services/ClusteredLights.d.ts +69 -0
- package/dist/features/3d/services/DrawOrder.d.ts +37 -0
- package/dist/features/3d/services/EffectsProcessor.d.ts +38 -0
- package/dist/features/3d/services/EnvironmentBRDF.d.ts +35 -0
- package/dist/features/3d/services/EnvironmentMaps.d.ts +55 -0
- package/dist/features/3d/services/FogShader.d.ts +6 -0
- package/dist/features/3d/services/Frustum.d.ts +7 -0
- package/dist/features/3d/services/GLState.d.ts +86 -0
- package/dist/features/3d/services/GPUPicker.d.ts +31 -0
- package/dist/features/3d/services/InstanceShader.d.ts +3 -0
- package/dist/features/3d/services/LineProgram.d.ts +32 -0
- package/dist/features/3d/services/PBRProgram.d.ts +115 -0
- package/dist/features/3d/services/Renderer.d.ts +50 -0
- package/dist/features/3d/services/Shader.d.ts +22 -0
- package/dist/features/3d/services/ShaderProgram.d.ts +38 -0
- package/dist/features/3d/services/ShadowMaps.d.ts +97 -0
- package/dist/features/3d/services/SpatialIndex.d.ts +16 -0
- package/dist/features/3d/services/TextureLoader.d.ts +40 -0
- package/dist/features/3d/services/TextureMipmaps.d.ts +42 -0
- package/dist/features/3d/services/ToneMapping.d.ts +12 -0
- package/dist/features/3d/services/WebGLRenderer.d.ts +261 -0
- package/dist/features/3d/splats/SplatData.d.ts +136 -0
- package/dist/features/3d/splats/SplatLoaders.d.ts +64 -0
- package/dist/features/3d/splats/SplatShader.d.ts +14 -0
- package/dist/features/3d/splats/SplatSort.d.ts +69 -0
- package/dist/features/3d/splats/Splats.d.ts +116 -0
- package/dist/features/3d/text/FontAtlas.d.ts +246 -0
- package/dist/features/3d/text/SDF.d.ts +28 -0
- package/dist/features/3d/text/Text.d.ts +179 -0
- package/dist/features/3d/text/TextLayout.d.ts +73 -0
- package/dist/features/3d/text/TextShader.d.ts +12 -0
- package/dist/features/3d/tiles/BoundingVolume.d.ts +43 -0
- package/dist/features/3d/tiles/Geodesy.d.ts +106 -0
- package/dist/features/3d/tiles/GlobeControls.d.ts +147 -0
- package/dist/features/3d/tiles/TileContent.d.ts +35 -0
- package/dist/features/3d/tiles/TileFormats.d.ts +77 -0
- package/dist/features/3d/tiles/Tiles3D.d.ts +236 -0
- package/dist/features/3d/tiles/Tileset.d.ts +81 -0
- package/dist/features/3d/tools/BatchedMesh.d.ts +74 -0
- package/dist/features/3d/tools/CanvasSurface.d.ts +81 -0
- package/dist/features/3d/tools/Color.d.ts +11 -0
- package/dist/features/3d/tools/MergeGeometries.d.ts +22 -0
- package/dist/features/3d/tools/Options.d.ts +15 -0
- package/dist/features/3d/tools/Polyhedra.d.ts +30 -0
- package/dist/features/3d/tools/PrimitiveBuffers.d.ts +42 -0
- package/dist/features/3d/tools/Primitives.d.ts +164 -0
- package/dist/features/3d/tools/Ready.d.ts +12 -0
- package/dist/features/3d/tools/SpatialMath.d.ts +57 -0
- package/dist/features/3d/tools/SphericalHarmonics.d.ts +9 -0
- package/dist/features/3d/tools/math/mat3.d.ts +7 -0
- package/dist/features/3d/tools/math/mat4.d.ts +19 -0
- package/dist/features/3d/tools/math/quat.d.ts +6 -0
- package/dist/features/3d/tools/math/vec3.d.ts +16 -0
- package/dist/features/3d/tools/math/vec4.d.ts +5 -0
- package/dist/features/3d/types.d.ts +359 -0
- package/dist/features/3d/usdz/USDAParser.d.ts +50 -0
- package/dist/features/3d/usdz/USDScene.d.ts +20 -0
- package/dist/features/3d/usdz/USDZLoader.d.ts +27 -0
- package/dist/features/3d/usdz/ZipReader.d.ts +16 -0
- package/dist/features/3d/webgpu/Backend.d.ts +40 -0
- package/dist/features/3d/webgpu/BasicShader.d.ts +10 -0
- package/dist/features/3d/webgpu/Constants.d.ts +32 -0
- package/dist/features/3d/webgpu/Deformation.d.ts +71 -0
- package/dist/features/3d/webgpu/Environment.d.ts +66 -0
- package/dist/features/3d/webgpu/Features.d.ts +68 -0
- package/dist/features/3d/webgpu/Layouts.d.ts +27 -0
- package/dist/features/3d/webgpu/Lines.d.ts +40 -0
- package/dist/features/3d/webgpu/LitExtras.d.ts +46 -0
- package/dist/features/3d/webgpu/LitFeatures.d.ts +41 -0
- package/dist/features/3d/webgpu/LitScene.d.ts +60 -0
- package/dist/features/3d/webgpu/LitShader.d.ts +68 -0
- package/dist/features/3d/webgpu/Particles.d.ts +114 -0
- package/dist/features/3d/webgpu/Picking.d.ts +59 -0
- package/dist/features/3d/webgpu/PipelineKey.d.ts +33 -0
- package/dist/features/3d/webgpu/Points.d.ts +41 -0
- package/dist/features/3d/webgpu/Probes.d.ts +45 -0
- package/dist/features/3d/webgpu/ShaderChunks.d.ts +18 -0
- package/dist/features/3d/webgpu/ShaderMaterial.d.ts +57 -0
- package/dist/features/3d/webgpu/ShaderMaterialSource.d.ts +5 -0
- package/dist/features/3d/webgpu/Shadows.d.ts +49 -0
- package/dist/features/3d/webgpu/Splats.d.ts +47 -0
- package/dist/features/3d/webgpu/Textures.d.ts +52 -0
- package/dist/features/3d/webgpu/Transmission.d.ts +30 -0
- package/dist/features/3d/webgpu/UniformLayout.d.ts +30 -0
- package/dist/features/3d/webgpu/UtilityShaders.d.ts +38 -0
- package/dist/features/3d/webgpu/WebGPURenderer.d.ts +327 -0
- package/dist/features/3d/webgpu/effects/EffectsShaders.d.ts +74 -0
- package/dist/features/3d/webgpu/effects/WebGPUEffects.d.ts +140 -0
- package/dist/features/3d/xr/XR.d.ts +100 -0
- package/dist/gltf-By-n0qEg.js +960 -0
- package/dist/index.d.ts +86 -81
- package/dist/model/document-actions/document-commands.d.ts +18 -0
- package/dist/model/documents/svg/create-svg-document-renderer.d.ts +32 -0
- package/dist/model/documents/svg/export-svg-document.d.ts +5 -0
- package/dist/model/documents/svg/import-svg-document.d.ts +6 -0
- package/dist/model/documents/svg/svg-document.types.d.ts +111 -0
- package/dist/model/documents/svg/svg-values.d.ts +16 -0
- package/dist/model/documents/svg/svg-xml.d.ts +18 -0
- package/dist/model/input/NovaInputProxy_Adapter.d.ts +2 -1
- package/dist/model/input/NovaInputValidationController.d.ts +1 -1
- package/dist/model/input/NovaTextInputController.d.ts +1 -1
- package/dist/model/input/NovaTextLayoutEngine.d.ts +2 -6
- package/dist/model/input/index.d.ts +7 -7
- package/dist/model/input/nova-input.types.d.ts +1 -1
- package/dist/model/lighting/LightingRenderer2D.d.ts +58 -0
- package/dist/model/lighting/NovaLighting2D.d.ts +56 -0
- package/dist/model/lighting/lighting-shaders.d.ts +3 -0
- package/dist/model/lighting/lighting-state.d.ts +27 -0
- package/dist/model/lighting/lighting.types.d.ts +107 -0
- package/dist/model/lottie/LottieNode.d.ts +4 -0
- package/dist/model/lottie/lottie.types.d.ts +83 -0
- package/dist/model/lottie/prepare-lottie.d.ts +3 -0
- package/dist/model/lottie/sample-position.d.ts +9 -0
- package/dist/model/motion/NovaMotionEngine.d.ts +3 -3
- package/dist/model/motion/nova-motion-easing.d.ts +1 -1
- package/dist/model/motion/nova-motion-interpolation.d.ts +1 -1
- package/dist/model/motion/nova-motion-presets.d.ts +2 -2
- package/dist/model/motion/nova-motion-timeline.d.ts +1 -1
- package/dist/model/platform/NovaCanvas.d.ts +7 -6
- package/dist/model/primitives/NovaPrimitiveUnsupportedError.d.ts +13 -0
- package/dist/model/primitives/definePrimitive.d.ts +5 -0
- package/dist/model/primitives/primitive.types.d.ts +28 -0
- package/dist/model/render/backends/canvas2d/NovaCanvas2DTargetManager.d.ts +3 -3
- package/dist/model/render/backends/canvas2d/NovaRenderer2D.d.ts +61 -15
- package/dist/model/render/backends/canvas2d/nova-canvas-blend.d.ts +5 -0
- package/dist/model/render/backends/nova-render-backend-factory.d.ts +6 -6
- package/dist/model/render/backends/nova-render-backend.d.ts +8 -2
- package/dist/model/render/backends/webgl/NovaRendererWebGL.d.ts +32 -11
- package/dist/model/render/backends/webgl/NovaStreamCacheIdleLedger.d.ts +12 -1
- package/dist/model/render/backends/webgl/NovaWebGLBatcher.d.ts +1 -1
- package/dist/model/render/backends/webgl/NovaWebGLCircleImagePass.d.ts +23 -0
- package/dist/model/render/backends/webgl/NovaWebGLCompositionPass.d.ts +9 -0
- package/dist/model/render/backends/webgl/NovaWebGLDevice.d.ts +3 -1
- package/dist/model/render/backends/webgl/NovaWebGLDiagnostics.d.ts +1 -1
- package/dist/model/render/backends/webgl/NovaWebGLFrameRenderer.d.ts +162 -53
- package/dist/model/render/backends/webgl/NovaWebGLPathClipPass.d.ts +13 -0
- package/dist/model/render/backends/webgl/NovaWebGLPathUnion.d.ts +23 -0
- package/dist/model/render/compiler/NovaRenderBuilder.d.ts +24 -10
- package/dist/model/render/compiler/NovaRenderCommandWriter.d.ts +10 -5
- package/dist/model/render/compiler/NovaRenderCompiler.d.ts +7 -6
- package/dist/model/render/compiler/NovaRenderFrameBuilder.d.ts +4 -3
- package/dist/model/render/effects/blur.d.ts +8 -0
- package/dist/model/render/effects/color-matrix.d.ts +8 -0
- package/dist/model/render/effects/drop-shadow.d.ts +18 -0
- package/dist/model/render/effects/nova-effect-registry.d.ts +66 -0
- package/dist/model/render/effects/nova-gaussian-kernel.d.ts +7 -0
- package/dist/model/render/effects/nova-gaussian-textures.d.ts +11 -0
- package/dist/model/render/effects/shader-effect.d.ts +64 -0
- package/dist/model/render/geometry/nova-alpha-mask.d.ts +5 -0
- package/dist/model/render/geometry/nova-composition.d.ts +9 -0
- package/dist/model/render/geometry/nova-node-clip.d.ts +17 -0
- package/dist/model/render/geometry/nova-path-geometry.d.ts +24 -0
- package/dist/model/render/geometry/nova-path-tessellation.d.ts +7 -0
- package/dist/model/render/geometry/nova-polygon-triangulation.d.ts +1 -1
- package/dist/model/render/graph/NovaRectBatchBuffer.d.ts +58 -0
- package/dist/model/render/graph/NovaRenderGraph.d.ts +40 -6
- package/dist/model/render/graph/NovaRenderHitIndex.d.ts +1 -1
- package/dist/model/render/graph/nova-auto-rect.d.ts +1 -1
- package/dist/model/render/graph/nova-linear-rect-repack.d.ts +4 -4
- package/dist/model/render/graph/nova-linear-rect-transition.d.ts +2 -2
- package/dist/model/render/graph/nova-render-culling.d.ts +2 -2
- package/dist/model/render/graph/nova-render-dirty-items.d.ts +1 -1
- package/dist/model/render/graph/nova-render-group.d.ts +1 -1
- package/dist/model/render/graph/nova-render-item.d.ts +2 -2
- package/dist/model/render/graph/nova-render-layer.d.ts +1 -1
- package/dist/model/render/graph/nova-render-payload-snapshot.d.ts +3 -1
- package/dist/model/render/graph/nova-render-program.d.ts +5 -3
- package/dist/model/render/graph/nova-render-sequence.d.ts +1 -1
- package/dist/model/render/graph/nova-render-stream.d.ts +2 -2
- package/dist/model/render/ktx2/BasisSession.d.ts +45 -0
- package/dist/model/render/ktx2/KTX2Container.d.ts +26 -0
- package/dist/model/render/ktx2/KTX2Loader.d.ts +55 -0
- package/dist/model/render/meshes/MeshNode.d.ts +13 -0
- package/dist/model/render/meshes/NovaMeshWebGLDevice.d.ts +27 -0
- package/dist/model/render/meshes/geometry.d.ts +7 -0
- package/dist/model/render/meshes/mesh.d.ts +3 -0
- package/dist/model/render/meshes/mesh.types.d.ts +116 -0
- package/dist/model/render/meshes/nova-mesh-registry.d.ts +55 -0
- package/dist/model/render/orchestration/NovaRenderOrchestrator.d.ts +25 -3
- package/dist/model/render/policy/nova-render-policy.d.ts +1 -1
- package/dist/model/render/resources/NovaGlyphAtlasManager.d.ts +2 -2
- package/dist/model/render/resources/NovaTextAtlasManager.d.ts +3 -3
- package/dist/model/render/resources/NovaTextLayoutEngine.d.ts +1 -1
- package/dist/model/render/resources/nova-bitmap-upload.d.ts +10 -0
- package/dist/model/render/schema/NovaRenderContext.d.ts +6 -4
- package/dist/model/render/schema/nova-style-compiler.d.ts +5 -2
- package/dist/model/render/targets/NovaNodeRenderTextureSource.d.ts +29 -0
- package/dist/model/render/targets/NovaRenderTargetManager.d.ts +1 -1
- package/dist/model/render/targets/NovaRenderTexture.d.ts +57 -0
- package/dist/model/render/targets/nova-render-target-refs.d.ts +5 -0
- package/dist/model/render/targets/nova-render-target-resource.d.ts +1 -1
- package/dist/model/render/targets/nova-render-texture-runtime.d.ts +71 -0
- package/dist/model/render/textures/nova-compressed-image.d.ts +20 -0
- package/dist/model/render/utils/nova-icon-rendering.d.ts +3 -1
- package/dist/model/render/utils/nova-image-geometry.d.ts +11 -0
- package/dist/model/render/utils/nova-markdown-layout.d.ts +19 -0
- package/dist/model/render/utils/nova-text-paint.d.ts +26 -0
- package/dist/model/render/utils/nova-wrapped-text-layout.d.ts +19 -0
- package/dist/model/runtime/app/Nova.d.ts +35 -35
- package/dist/model/runtime/app/NovaApp.d.ts +58 -30
- package/dist/model/runtime/app/NovaRaphRuntime.d.ts +2 -2
- package/dist/model/runtime/app/createNovaRaphRuntime.d.ts +3 -3
- package/dist/model/runtime/assets/NovaAssetRegistry.d.ts +89 -2
- package/dist/model/runtime/assets/NovaVideoTexture.d.ts +38 -0
- package/dist/model/runtime/assets/nova-render-texture-image-identity.d.ts +4 -0
- package/dist/model/runtime/commands/NovaCommandBus.d.ts +1 -1
- package/dist/model/runtime/components/NovaComponentNode.d.ts +6 -6
- package/dist/model/runtime/components/NovaComponentRegistry.d.ts +1 -1
- package/dist/model/runtime/components/NovaSchemaRegistry.d.ts +7 -6
- package/dist/model/runtime/components/nova-component-metadata.d.ts +1 -1
- package/dist/model/runtime/components/nova-component.decorator.d.ts +2 -2
- package/dist/model/runtime/components/nova-defined-component.d.ts +3 -3
- package/dist/model/runtime/context/nova-context.d.ts +1 -1
- package/dist/model/runtime/cursor/NovaCursorManager.d.ts +3 -3
- package/dist/model/runtime/diagnostics/NovaDiagnostics_Module.d.ts +3 -3
- package/dist/model/runtime/interaction/NovaEvents.d.ts +16 -6
- package/dist/model/runtime/interaction/NovaHitIndex.d.ts +1 -1
- package/dist/model/runtime/interaction/NovaSpatialIndex.d.ts +2 -2
- package/dist/model/runtime/scene/NovaScene.d.ts +3 -3
- package/dist/model/runtime/scene/nova-scene-components.d.ts +6 -6
- package/dist/model/runtime/state/nova-store-decorators.d.ts +1 -1
- package/dist/model/runtime/state/nova-store-runtime.d.ts +1 -1
- package/dist/model/runtime/state/nova-store-tracking.d.ts +7 -3
- package/dist/model/runtime/sync/NovaSyncScope.d.ts +11 -2
- package/dist/model/runtime/sync/nova-sync-context.d.ts +2 -2
- package/dist/model/runtime/sync/nova-sync-ports.d.ts +2 -2
- package/dist/model/runtime/sync/nova-sync.types.d.ts +15 -3
- package/dist/model/runtime/template/NovaTemplateRuntime.d.ts +6 -6
- package/dist/model/runtime/tree/NovaContainer.d.ts +4 -4
- package/dist/model/runtime/tree/NovaNode.d.ts +58 -18
- package/dist/model/runtime/tree/NovaRaphNode.d.ts +8 -2
- package/dist/model/runtime/tree/NovaSurface.d.ts +32 -10
- package/dist/model/runtime/tree/nova-node-capture-invalidation.d.ts +11 -0
- package/dist/model/semantic/NovaSemanticService.d.ts +1 -1
- package/dist/model/semantic/browser/createAccessibilityBridge.d.ts +29 -0
- package/dist/model/sound/NovaSoundEngine.d.ts +3 -2
- package/dist/model/text-selection/NovaTextSelectionService.d.ts +2 -2
- package/dist/model/text-selection/index.d.ts +2 -2
- package/dist/model/text-selection/nova-text-selection.types.d.ts +1 -1
- package/dist/model/theme/NovaGlobalThemeRegistry.d.ts +2 -2
- package/dist/model/theme/NovaThemeService.d.ts +5 -3
- package/dist/model/theme/createTokenTheme.d.ts +15 -0
- package/dist/model/tools/transform-tools.d.ts +43 -0
- package/dist/nodes--Ds4IS2h.js +621 -0
- package/dist/nova-color-parser-BCN_rFRN.js +250 -0
- package/dist/nova-compressed-image-CE2Ya9Xa.js +46 -0
- package/dist/nova-mesh-registry-B7Xz5mhU.js +24 -0
- package/dist/nova-render-texture-image-identity-DQ09XFKs.js +15 -0
- package/dist/nova-text-paint-CcntsRjI.js +48 -0
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.js +50 -0
- package/dist/vec4-BTNv1fUp.js +20 -0
- package/package.json +223 -4
package/dist/3d/tiles.js
ADDED
|
@@ -0,0 +1,1705 @@
|
|
|
1
|
+
import { N as m, w as Rt, f as Pt } from "../Errors-B2ekO9bZ.js";
|
|
2
|
+
import { c as $, o as et } from "../Options-CajE7LLJ.js";
|
|
3
|
+
import { d as X, b as V, N as _t, Y as At } from "../Node-QfgAE2_v.js";
|
|
4
|
+
import { p as jt, g as Ct, a as Gt } from "../gltf-By-n0qEg.js";
|
|
5
|
+
import { s as qt } from "../Scene-CDfNgf9I.js";
|
|
6
|
+
import { w as kt, r as Bt } from "../Ready-BzyhRtjD.js";
|
|
7
|
+
import { N as Yt } from "../InstancedMesh-DPrgrw5z.js";
|
|
8
|
+
import { N as $t } from "../Mesh-BaRxAAJq.js";
|
|
9
|
+
const Xt = et({ upAxis: !0, ellipsoid: !0 }), nt = Object.freeze({
|
|
10
|
+
semiMajorAxis: 6378137,
|
|
11
|
+
flattening: 1 / 298.257223563,
|
|
12
|
+
semiMinorAxis: 6378137 * (1 - 1 / 298.257223563)
|
|
13
|
+
}), G = Object.freeze({ radii: Object.freeze([nt.semiMajorAxis, nt.semiMajorAxis, nt.semiMinorAxis]) });
|
|
14
|
+
function W(i) {
|
|
15
|
+
const t = i?.radii;
|
|
16
|
+
if (!t || t.length !== 3 || !t.every((s) => Number.isFinite(s) && s > 0))
|
|
17
|
+
throw new m("invalid-option", "[Nova3D] An ellipsoid needs three positive finite radii.");
|
|
18
|
+
return t;
|
|
19
|
+
}
|
|
20
|
+
function Ft(i, t, s) {
|
|
21
|
+
if (!Number.isFinite(i) || !Number.isFinite(t) || !Number.isFinite(s) || Math.abs(i) > Math.PI / 2 + 1e-12)
|
|
22
|
+
throw new m("invalid-option", "[Nova3D] Geodetic coordinates need finite radians with |latitude| ≤ π/2 and a finite height.");
|
|
23
|
+
}
|
|
24
|
+
function Q(i, t, s, e, n, r) {
|
|
25
|
+
const o = Math.cos(s), a = o * Math.cos(e), c = o * Math.sin(e), h = Math.sin(s), l = r[0] * r[0] * a, _ = r[1] * r[1] * c, u = r[2] * r[2] * h, d = Math.sqrt(a * l + c * _ + h * u);
|
|
26
|
+
i[t] = l / d + a * n, i[t + 1] = _ / d + c * n, i[t + 2] = u / d + h * n;
|
|
27
|
+
}
|
|
28
|
+
function ct(i, t, s, e, n) {
|
|
29
|
+
const r = 1 / n[0], o = 1 / n[1], a = 1 / n[2], c = r * r, h = o * o, l = a * a, _ = t * t * c, u = s * s * h, d = e * e * l, f = _ + u + d;
|
|
30
|
+
if (!(f > 1e-20))
|
|
31
|
+
return !1;
|
|
32
|
+
const y = Math.sqrt(1 / f), p = t * y, w = s * y, v = e * y, b = p * c * 2, T = w * h * 2, M = v * l * 2;
|
|
33
|
+
let x = (1 - y) * Math.hypot(t, s, e) / (0.5 * Math.hypot(b, T, M)), N = 0, D = 1, g = 1, F = 1;
|
|
34
|
+
for (let A = 0; A < 64; A++) {
|
|
35
|
+
x -= N, D = 1 / (1 + x * c), g = 1 / (1 + x * h), F = 1 / (1 + x * l);
|
|
36
|
+
const E = D * D, z = g * g, L = F * F, U = _ * E + u * z + d * L - 1;
|
|
37
|
+
if (Math.abs(U) <= 1e-13)
|
|
38
|
+
break;
|
|
39
|
+
const R = _ * E * D * c + u * z * g * h + d * L * F * l;
|
|
40
|
+
N = U / (-2 * R);
|
|
41
|
+
}
|
|
42
|
+
return i[0] = t * D, i[1] = s * g, i[2] = e * F, Number.isFinite(i[0]) && Number.isFinite(i[1]) && Number.isFinite(i[2]);
|
|
43
|
+
}
|
|
44
|
+
const P = new Float64Array(3);
|
|
45
|
+
function H(i, t, s, e, n) {
|
|
46
|
+
if (!ct(P, t, s, e, n))
|
|
47
|
+
return !1;
|
|
48
|
+
let r = P[0] / (n[0] * n[0]), o = P[1] / (n[1] * n[1]), a = P[2] / (n[2] * n[2]);
|
|
49
|
+
const c = Math.hypot(r, o, a);
|
|
50
|
+
r /= c, o /= c, a /= c;
|
|
51
|
+
const h = t - P[0], l = s - P[1], _ = e - P[2], u = Math.hypot(h, l, _);
|
|
52
|
+
return i[0] = Math.asin(Math.max(-1, Math.min(1, a))), i[1] = Math.atan2(o, r), i[2] = h * t + l * s + _ * e < 0 ? -u : u, !0;
|
|
53
|
+
}
|
|
54
|
+
function Fe(i, t, s = 0, e = G) {
|
|
55
|
+
Ft(i, t, s);
|
|
56
|
+
const n = [0, 0, 0];
|
|
57
|
+
return Q(n, 0, i, t, s, W(e)), n;
|
|
58
|
+
}
|
|
59
|
+
function Ee(i, t = G) {
|
|
60
|
+
const [s, e, n] = Array.isArray(i) && i.length === 3 ? i : [Number.NaN, Number.NaN, Number.NaN];
|
|
61
|
+
if (!Number.isFinite(s) || !Number.isFinite(e) || !Number.isFinite(n))
|
|
62
|
+
throw new m("invalid-option", "[Nova3D] ECEF coordinates must be finite.");
|
|
63
|
+
const r = [0, 0, 0];
|
|
64
|
+
if (!H(r, s, e, n, W(t)))
|
|
65
|
+
throw new m("invalid-option", "[Nova3D] The point is too close to the ellipsoid centre for geodetic coordinates.");
|
|
66
|
+
return { latitude: r[0], longitude: r[1], height: r[2] };
|
|
67
|
+
}
|
|
68
|
+
function ht(i, t, s, e, n) {
|
|
69
|
+
const r = Math.cos(t), o = r * Math.cos(s), a = r * Math.sin(s), c = Math.sin(t), h = -Math.sin(s), l = Math.cos(s), _ = a * 0 - c * l, u = c * h - o * 0, d = o * l - a * h;
|
|
70
|
+
i[0] = h, i[1] = l, i[2] = 0, i[3] = 0, i[4] = _, i[5] = u, i[6] = d, i[7] = 0, i[8] = o, i[9] = a, i[10] = c, i[11] = 0, Q(i, 12, t, s, e, n), i[15] = 1;
|
|
71
|
+
}
|
|
72
|
+
function Ie(i, t, s = 0, e = G) {
|
|
73
|
+
return Et(i, t, s, e);
|
|
74
|
+
}
|
|
75
|
+
function Et(i, t, s, e) {
|
|
76
|
+
Ft(i, t, s);
|
|
77
|
+
const n = new Float64Array(16);
|
|
78
|
+
return ht(n, i, t, s, W(e ?? G)), n;
|
|
79
|
+
}
|
|
80
|
+
function Se(i, t, s = 0, e = {}) {
|
|
81
|
+
return It(i, t, s, e);
|
|
82
|
+
}
|
|
83
|
+
function It(i, t, s, e) {
|
|
84
|
+
$(e, Xt, "local frame");
|
|
85
|
+
const n = Et(i, t, s, e.ellipsoid), r = new Float64Array(16);
|
|
86
|
+
if (Vt(r, n), (e.upAxis ?? "y") === "y")
|
|
87
|
+
for (let o = 0; o < 4; o++) {
|
|
88
|
+
const a = r[o * 4 + 1], c = r[o * 4 + 2];
|
|
89
|
+
r[o * 4 + 1] = c, r[o * 4 + 2] = -a;
|
|
90
|
+
}
|
|
91
|
+
else if (e.upAxis !== "z")
|
|
92
|
+
throw new m("invalid-option", '[Nova3D] upAxis must be "y" or "z".');
|
|
93
|
+
return r;
|
|
94
|
+
}
|
|
95
|
+
function Vt(i, t) {
|
|
96
|
+
const s = t[0], e = t[1], n = t[2], r = t[4], o = t[5], a = t[6], c = t[8], h = t[9], l = t[10], _ = t[12], u = t[13], d = t[14];
|
|
97
|
+
i[0] = s, i[1] = r, i[2] = c, i[3] = 0, i[4] = e, i[5] = o, i[6] = h, i[7] = 0, i[8] = n, i[9] = a, i[10] = l, i[11] = 0, i[12] = -(s * _ + e * u + n * d), i[13] = -(r * _ + o * u + a * d), i[14] = -(c * _ + h * u + l * d), i[15] = 1;
|
|
98
|
+
}
|
|
99
|
+
function Ht(i, t, s, e, n, r, o) {
|
|
100
|
+
const a = 1 / o[0], c = 1 / o[1], h = 1 / o[2], l = i * a, _ = t * c, u = s * h, d = e * a, f = n * c, y = r * h, p = d * d + f * f + y * y, w = 2 * (l * d + _ * f + u * y), v = l * l + _ * _ + u * u - 1, b = w * w - 4 * p * v;
|
|
101
|
+
if (b < 0 || p === 0)
|
|
102
|
+
return -1;
|
|
103
|
+
const T = Math.sqrt(b), M = w < 0 ? -0.5 * (w - T) : -0.5 * (w + T);
|
|
104
|
+
let x = M / p, N = M === 0 ? x : v / M;
|
|
105
|
+
if (x > N) {
|
|
106
|
+
const D = x;
|
|
107
|
+
x = N, N = D;
|
|
108
|
+
}
|
|
109
|
+
return x >= 0 ? x : N >= 0 ? N : -1;
|
|
110
|
+
}
|
|
111
|
+
const Wt = new Float64Array(3);
|
|
112
|
+
class Kt {
|
|
113
|
+
center = new Float64Array(3);
|
|
114
|
+
/** Half-axis vectors as three columns: x (0..2), y (3..5), z (6..8). */
|
|
115
|
+
axes = new Float64Array(9);
|
|
116
|
+
/** Squared half-axis lengths (0 for degenerate axes). */
|
|
117
|
+
lengths = new Float64Array(3);
|
|
118
|
+
radius = 0;
|
|
119
|
+
sphere = !1;
|
|
120
|
+
/** WGS84 region [west, south, east, north, minHeight, maxHeight] for containment, when given as a region. */
|
|
121
|
+
region = null;
|
|
122
|
+
/** Distance from a point to the volume (0 inside). */
|
|
123
|
+
distanceTo(t, s, e) {
|
|
124
|
+
const n = t - this.center[0], r = s - this.center[1], o = e - this.center[2];
|
|
125
|
+
if (this.sphere)
|
|
126
|
+
return Math.max(0, Math.sqrt(n * n + r * r + o * o) - this.radius);
|
|
127
|
+
let a = n, c = r, h = o, l = 0;
|
|
128
|
+
const _ = this.axes;
|
|
129
|
+
for (let u = 0; u < 3; u++) {
|
|
130
|
+
const d = this.lengths[u];
|
|
131
|
+
if (d === 0)
|
|
132
|
+
continue;
|
|
133
|
+
const f = _[u * 3], y = _[u * 3 + 1], p = _[u * 3 + 2], w = (n * f + r * y + o * p) / d;
|
|
134
|
+
a -= w * f, c -= w * y, h -= w * p;
|
|
135
|
+
const v = (Math.abs(w) - 1) * Math.sqrt(d);
|
|
136
|
+
v > 0 && (l += v * v);
|
|
137
|
+
}
|
|
138
|
+
return Math.sqrt(a * a + c * c + h * h + l);
|
|
139
|
+
}
|
|
140
|
+
/** True unless the volume lies entirely behind one of the planes (n·p + d ≥ 0 inside). */
|
|
141
|
+
intersectsFrustum(t) {
|
|
142
|
+
const s = this.center[0], e = this.center[1], n = this.center[2], r = this.axes;
|
|
143
|
+
for (let o = 0; o < t.length; o += 4) {
|
|
144
|
+
const a = t[o], c = t[o + 1], h = t[o + 2], l = a * s + c * e + h * n + t[o + 3], _ = this.sphere ? this.radius : Math.abs(a * r[0] + c * r[1] + h * r[2]) + Math.abs(a * r[3] + c * r[4] + h * r[5]) + Math.abs(a * r[6] + c * r[7] + h * r[8]);
|
|
145
|
+
if (l < -_)
|
|
146
|
+
return !1;
|
|
147
|
+
}
|
|
148
|
+
return !0;
|
|
149
|
+
}
|
|
150
|
+
/** Point containment, used by viewer request volumes. */
|
|
151
|
+
contains(t, s, e, n) {
|
|
152
|
+
if (this.region) {
|
|
153
|
+
const c = Wt;
|
|
154
|
+
if (!H(c, t, s, e, n))
|
|
155
|
+
return !1;
|
|
156
|
+
const [h, l, _, u, d, f] = this.region;
|
|
157
|
+
let y = c[1];
|
|
158
|
+
_ < h && y < h && (y += Math.PI * 2);
|
|
159
|
+
const p = 1e-10, w = 1e-3;
|
|
160
|
+
return c[0] >= l - p && c[0] <= u + p && y >= h - p && y <= (_ < h ? _ + Math.PI * 2 : _) + p && c[2] >= d - w && c[2] <= f + w;
|
|
161
|
+
}
|
|
162
|
+
const r = t - this.center[0], o = s - this.center[1], a = e - this.center[2];
|
|
163
|
+
if (this.sphere)
|
|
164
|
+
return r * r + o * o + a * a <= this.radius * this.radius;
|
|
165
|
+
for (let c = 0; c < 3; c++) {
|
|
166
|
+
const h = this.lengths[c], l = r * this.axes[c * 3] + o * this.axes[c * 3 + 1] + a * this.axes[c * 3 + 2];
|
|
167
|
+
if (h === 0 ? Math.abs(l) > 1e-9 : Math.abs(l) > h * (1 + 1e-12))
|
|
168
|
+
return !1;
|
|
169
|
+
}
|
|
170
|
+
return !0;
|
|
171
|
+
}
|
|
172
|
+
/** @internal */
|
|
173
|
+
_finish() {
|
|
174
|
+
const t = this.axes;
|
|
175
|
+
let s = 0;
|
|
176
|
+
for (let e = 0; e < 3; e++) {
|
|
177
|
+
const n = t[e * 3] ** 2 + t[e * 3 + 1] ** 2 + t[e * 3 + 2] ** 2;
|
|
178
|
+
this.lengths[e] = n, s += n;
|
|
179
|
+
}
|
|
180
|
+
return this.sphere || (this.radius = Math.sqrt(s)), this;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function rt(i, t, s) {
|
|
184
|
+
if (!Array.isArray(i) || i.length !== t || !i.every((e) => typeof e == "number" && Number.isFinite(e)))
|
|
185
|
+
throw new m("format", `[Nova3D] Tile bounding volume ${s} needs ${t} finite numbers.`);
|
|
186
|
+
return i;
|
|
187
|
+
}
|
|
188
|
+
function Jt(i) {
|
|
189
|
+
return Math.sqrt(Math.max(i[0] * i[0] + i[1] * i[1] + i[2] * i[2], i[4] * i[4] + i[5] * i[5] + i[6] * i[6], i[8] * i[8] + i[9] * i[9] + i[10] * i[10]));
|
|
190
|
+
}
|
|
191
|
+
function Zt(i, t, s) {
|
|
192
|
+
const e = t[0], n = t[1];
|
|
193
|
+
let r = t[2];
|
|
194
|
+
const o = t[3], a = t[4], c = t[5];
|
|
195
|
+
if (n > o || a > c || n < -Math.PI / 2 - 1e-9 || o > Math.PI / 2 + 1e-9 || Math.abs(e) > Math.PI * 2 || Math.abs(r) > Math.PI * 2)
|
|
196
|
+
throw new m("format", "[Nova3D] Tile region must satisfy south ≤ north, minHeight ≤ maxHeight and |latitude| ≤ π/2.");
|
|
197
|
+
r < e && (r += Math.PI * 2);
|
|
198
|
+
const h = (e + r) / 2, l = (n + o) / 2, _ = new Float64Array(16);
|
|
199
|
+
ht(_, l, h, 0, s);
|
|
200
|
+
const u = Math.PI / 8, d = Math.max(2, Math.ceil((r - e) / u)), f = Math.max(2, Math.ceil((o - n) / u)), y = [1 / 0, 1 / 0, 1 / 0], p = [-1 / 0, -1 / 0, -1 / 0], w = new Float64Array(3);
|
|
201
|
+
for (let g = 0; g <= d; g++) {
|
|
202
|
+
const F = e + (r - e) * g / d;
|
|
203
|
+
for (let A = 0; A <= f; A++) {
|
|
204
|
+
const E = n + (o - n) * A / f;
|
|
205
|
+
for (const z of [a, c]) {
|
|
206
|
+
Q(w, 0, E, F, z, s);
|
|
207
|
+
const L = w[0] - _[12], U = w[1] - _[13], R = w[2] - _[14];
|
|
208
|
+
for (let I = 0; I < 3; I++) {
|
|
209
|
+
const q = L * _[I * 4] + U * _[I * 4 + 1] + R * _[I * 4 + 2];
|
|
210
|
+
y[I] = Math.min(y[I], q), p[I] = Math.max(p[I], q);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
Q(w, 0, l, h, c, s);
|
|
216
|
+
const v = (w[0] - _[12]) * _[8] + (w[1] - _[13]) * _[9] + (w[2] - _[14]) * _[10];
|
|
217
|
+
p[2] = Math.max(p[2], v);
|
|
218
|
+
const b = Math.max(s[0], s[1], s[2]) + Math.max(0, c), T = Math.max((r - e) / d, (o - n) / f), M = b * (1 - Math.cos(T / 2)) + 1e-6 * b;
|
|
219
|
+
i.sphere = !1, i.region = new Float64Array([t[0], n, t[2], o, a, c]);
|
|
220
|
+
let x = _[12], N = _[13], D = _[14];
|
|
221
|
+
for (let g = 0; g < 3; g++) {
|
|
222
|
+
const F = (y[g] + p[g]) / 2, A = (p[g] - y[g]) / 2 + M;
|
|
223
|
+
x += _[g * 4] * F, N += _[g * 4 + 1] * F, D += _[g * 4 + 2] * F, i.axes[g * 3] = _[g * 4] * A, i.axes[g * 3 + 1] = _[g * 4 + 1] * A, i.axes[g * 3 + 2] = _[g * 4 + 2] * A;
|
|
224
|
+
}
|
|
225
|
+
return i.center[0] = x, i.center[1] = N, i.center[2] = D, i._finish();
|
|
226
|
+
}
|
|
227
|
+
function ft(i, t, s) {
|
|
228
|
+
if (i === null || typeof i != "object" || Array.isArray(i))
|
|
229
|
+
throw new m("format", "[Nova3D] A tile needs a boundingVolume object.");
|
|
230
|
+
const e = i, n = new Kt(), r = t;
|
|
231
|
+
if (e.box !== void 0) {
|
|
232
|
+
const o = rt(e.box, 12, "box");
|
|
233
|
+
n.center[0] = r[0] * o[0] + r[4] * o[1] + r[8] * o[2] + r[12], n.center[1] = r[1] * o[0] + r[5] * o[1] + r[9] * o[2] + r[13], n.center[2] = r[2] * o[0] + r[6] * o[1] + r[10] * o[2] + r[14];
|
|
234
|
+
for (let a = 0; a < 3; a++) {
|
|
235
|
+
const c = o[3 + a * 3], h = o[4 + a * 3], l = o[5 + a * 3];
|
|
236
|
+
n.axes[a * 3] = r[0] * c + r[4] * h + r[8] * l, n.axes[a * 3 + 1] = r[1] * c + r[5] * h + r[9] * l, n.axes[a * 3 + 2] = r[2] * c + r[6] * h + r[10] * l;
|
|
237
|
+
}
|
|
238
|
+
return n._finish();
|
|
239
|
+
}
|
|
240
|
+
if (e.sphere !== void 0) {
|
|
241
|
+
const o = rt(e.sphere, 4, "sphere");
|
|
242
|
+
if (o[3] < 0)
|
|
243
|
+
throw new m("format", "[Nova3D] Tile bounding sphere radius must be non-negative.");
|
|
244
|
+
n.sphere = !0, n.center[0] = r[0] * o[0] + r[4] * o[1] + r[8] * o[2] + r[12], n.center[1] = r[1] * o[0] + r[5] * o[1] + r[9] * o[2] + r[13], n.center[2] = r[2] * o[0] + r[6] * o[1] + r[10] * o[2] + r[14], n.radius = o[3] * Jt(r);
|
|
245
|
+
const a = n.radius;
|
|
246
|
+
return n.axes.set([a, 0, 0, 0, a, 0, 0, 0, a]), n._finish();
|
|
247
|
+
}
|
|
248
|
+
if (e.region !== void 0)
|
|
249
|
+
return Zt(n, rt(e.region, 6, "region"), s);
|
|
250
|
+
throw new m("format", "[Nova3D] Tile bounding volume needs a box, sphere or region.");
|
|
251
|
+
}
|
|
252
|
+
function Qt(i, t) {
|
|
253
|
+
for (let s = 0; s < 6; s++) {
|
|
254
|
+
const e = s >> 1, n = s & 1 ? -1 : 1, r = t[3] + n * t[e], o = t[7] + n * t[4 + e], a = t[11] + n * t[8 + e], c = t[15] + n * t[12 + e], h = Math.hypot(r, o, a) || 1;
|
|
255
|
+
i[s * 4] = r / h, i[s * 4 + 1] = o / h, i[s * 4 + 2] = a / h, i[s * 4 + 3] = c / h;
|
|
256
|
+
}
|
|
257
|
+
return i;
|
|
258
|
+
}
|
|
259
|
+
const j = 0, ut = 1, K = 2, it = 3, pt = Object.freeze({
|
|
260
|
+
// y-up → z-up: (x, y, z) → (x, −z, y), the rotation 3D Tiles prescribes for glTF content.
|
|
261
|
+
Y: new Float64Array([1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1]),
|
|
262
|
+
// x-up → z-up: (x, y, z) → (−z, y, x).
|
|
263
|
+
X: new Float64Array([0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1]),
|
|
264
|
+
Z: new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
|
|
265
|
+
});
|
|
266
|
+
class te {
|
|
267
|
+
constructor(t, s, e, n, r, o, a, c, h) {
|
|
268
|
+
this.parent = t, this.depth = s, this.geometricError = e, this.refine = n, this.transform = r, this.volume = o, this.viewerRequestVolume = a, this.contents = c, this.upAxis = h, this.external = c.length === 1 && /\.json$/i.test(c[0].split(/[?#]/)[0]);
|
|
269
|
+
}
|
|
270
|
+
children = [];
|
|
271
|
+
/** Content is (or is hinted to be) an external tileset: never drawn, always refined. */
|
|
272
|
+
external;
|
|
273
|
+
/** External tileset children are attached. */
|
|
274
|
+
expanded = !1;
|
|
275
|
+
state = j;
|
|
276
|
+
usedFrame = -1;
|
|
277
|
+
leafFrame = -1;
|
|
278
|
+
wantedFrame = -1;
|
|
279
|
+
displayFrame = -1;
|
|
280
|
+
/** Last update in which this tile or a descendant was drawn. */
|
|
281
|
+
shownFrame = -1;
|
|
282
|
+
lastUsed = -1;
|
|
283
|
+
sse = 0;
|
|
284
|
+
distance = 0;
|
|
285
|
+
childrenReady = !1;
|
|
286
|
+
displayed = !1;
|
|
287
|
+
bytes = 0;
|
|
288
|
+
controller = null;
|
|
289
|
+
content = null;
|
|
290
|
+
get hasRenderable() {
|
|
291
|
+
return this.contents.length > 0 && !this.external;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const ee = /* @__PURE__ */ new Set(["3DTILES_content_gltf", "3DTILES_multiple_contents", "3DTILES_metadata", "EXT_structural_metadata", "EXT_mesh_features", "EXT_instance_features", "3DTILES_batch_table_hierarchy"]);
|
|
295
|
+
function J(i, t) {
|
|
296
|
+
if (i === null || typeof i != "object" || Array.isArray(i))
|
|
297
|
+
throw new m("format", `[Nova3D] Tileset ${t} must be an object.`);
|
|
298
|
+
return i;
|
|
299
|
+
}
|
|
300
|
+
function yt(i, t, s) {
|
|
301
|
+
for (let e = 0; e < 4; e++) {
|
|
302
|
+
const n = s[e * 4], r = s[e * 4 + 1], o = s[e * 4 + 2], a = s[e * 4 + 3];
|
|
303
|
+
for (let c = 0; c < 4; c++)
|
|
304
|
+
i[e * 4 + c] = t[c] * n + t[4 + c] * r + t[8 + c] * o + t[12 + c] * a;
|
|
305
|
+
}
|
|
306
|
+
return i;
|
|
307
|
+
}
|
|
308
|
+
function S(i, t, s) {
|
|
309
|
+
if (i === t || i === s) {
|
|
310
|
+
const e = yt(new Float64Array(16), t, s);
|
|
311
|
+
return i.set(e), i;
|
|
312
|
+
}
|
|
313
|
+
return yt(i, t, s);
|
|
314
|
+
}
|
|
315
|
+
function se(i, t) {
|
|
316
|
+
if (typeof i != "string" || i.length === 0)
|
|
317
|
+
throw new m("format", "[Nova3D] Tile content uri must be a nonempty string.");
|
|
318
|
+
let s;
|
|
319
|
+
try {
|
|
320
|
+
s = t === void 0 ? new URL(i) : new URL(i, t);
|
|
321
|
+
} catch {
|
|
322
|
+
throw new m("invalid-option", `[Nova3D] Cannot resolve tile content uri "${i}" without a base URL.`);
|
|
323
|
+
}
|
|
324
|
+
if (t !== void 0 && !i.startsWith("data:")) {
|
|
325
|
+
const e = new URL(t);
|
|
326
|
+
for (const [n, r] of e.searchParams)
|
|
327
|
+
s.searchParams.has(n) || s.searchParams.append(n, r);
|
|
328
|
+
}
|
|
329
|
+
return s.href;
|
|
330
|
+
}
|
|
331
|
+
function mt(i, t) {
|
|
332
|
+
const s = J(typeof i == "string" ? JSON.parse(i) : i, "document"), e = J(s.asset, "asset");
|
|
333
|
+
if (e.version !== "1.0" && e.version !== "1.1" && e.version !== "0.0")
|
|
334
|
+
throw new m("unsupported", `[Nova3D] Unsupported 3D Tiles version ${JSON.stringify(e.version)}.`);
|
|
335
|
+
if (typeof s.geometricError != "number" || !Number.isFinite(s.geometricError) || s.geometricError < 0)
|
|
336
|
+
throw new m("format", "[Nova3D] Tileset geometricError must be a non-negative number.");
|
|
337
|
+
const n = s.extensionsRequired;
|
|
338
|
+
if (n !== void 0) {
|
|
339
|
+
if (!Array.isArray(n))
|
|
340
|
+
throw new m("format", "[Nova3D] Tileset extensionsRequired must be an array.");
|
|
341
|
+
for (const d of n)
|
|
342
|
+
if (typeof d != "string" || !ee.has(d))
|
|
343
|
+
throw new m("unsupported", `[Nova3D] Unsupported required 3D Tiles extension ${JSON.stringify(d)}.`);
|
|
344
|
+
}
|
|
345
|
+
const r = e.gltfUpAxis ?? "Y";
|
|
346
|
+
if (r !== "X" && r !== "Y" && r !== "Z")
|
|
347
|
+
throw new m("format", '[Nova3D] Tileset asset.gltfUpAxis must be "X", "Y" or "Z".');
|
|
348
|
+
const o = pt[r], a = [], c = t.parent ?? null, h = pt.Z, l = [{ json: s.root, parent: c }];
|
|
349
|
+
let _ = null, u = 0;
|
|
350
|
+
for (; l.length > 0; ) {
|
|
351
|
+
const d = l.pop(), f = J(d.json, "tile");
|
|
352
|
+
if (++u > t.maxTiles)
|
|
353
|
+
throw new m("budget", `[Nova3D] Tileset exceeds maxTiles (${t.maxTiles}).`);
|
|
354
|
+
const y = f.geometricError;
|
|
355
|
+
if (typeof y != "number" || !Number.isFinite(y) || y < 0)
|
|
356
|
+
throw new m("format", "[Nova3D] Tile geometricError must be a non-negative number.");
|
|
357
|
+
const p = f.refine === void 0 ? d.parent?.refine ?? "REPLACE" : f.refine, w = typeof p == "string" ? p.toUpperCase() : p;
|
|
358
|
+
if (w !== "ADD" && w !== "REPLACE")
|
|
359
|
+
throw new m("format", '[Nova3D] Tile refine must be "ADD" or "REPLACE".');
|
|
360
|
+
const v = new Float64Array(d.parent ? d.parent.transform : h);
|
|
361
|
+
if (f.transform !== void 0) {
|
|
362
|
+
const g = f.transform;
|
|
363
|
+
if (!Array.isArray(g) || g.length !== 16 || !g.every((F) => typeof F == "number" && Number.isFinite(F)))
|
|
364
|
+
throw new m("format", "[Nova3D] Tile transform needs 16 finite numbers.");
|
|
365
|
+
S(v, v, g);
|
|
366
|
+
}
|
|
367
|
+
const b = ft(f.boundingVolume, v, t.radii), T = f.viewerRequestVolume === void 0 ? null : ft(f.viewerRequestVolume, v, t.radii), M = [], x = f.contents !== void 0 ? f.contents : f.content !== void 0 ? [f.content] : [];
|
|
368
|
+
if (!Array.isArray(x))
|
|
369
|
+
throw new m("format", "[Nova3D] Tile contents must be an array.");
|
|
370
|
+
for (const g of x) {
|
|
371
|
+
const F = J(g, "content"), A = F.uri ?? F.url;
|
|
372
|
+
if (typeof A != "string")
|
|
373
|
+
throw new m("format", "[Nova3D] Tile content needs a uri.");
|
|
374
|
+
M.push(se(A, t.baseUrl));
|
|
375
|
+
}
|
|
376
|
+
const N = new te(d.parent, d.parent ? d.parent.depth + 1 : 0, y, w, v, b, T, M, o);
|
|
377
|
+
if (_ ??= N, d.parent?.children.push(N), f.implicitTiling !== void 0) {
|
|
378
|
+
a.push(Rt("unsupported", "Implicit tiling is not supported; the tile is drawn without subtrees."));
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
const D = f.children;
|
|
382
|
+
if (D !== void 0) {
|
|
383
|
+
if (!Array.isArray(D))
|
|
384
|
+
throw new m("format", "[Nova3D] Tile children must be an array.");
|
|
385
|
+
for (let g = D.length - 1; g >= 0; g--)
|
|
386
|
+
l.push({ json: D[g], parent: N });
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return { root: _, warnings: a, count: u };
|
|
390
|
+
}
|
|
391
|
+
const ne = et({ camera: !0, ellipsoid: !0, frame: !0, minDistance: !0, maxDistance: !0, maxTilt: !0, damping: !0, rotateSpeed: !0, zoomSpeed: !0, adjustNearFar: !0 }), re = et({ latitude: !0, longitude: !0, height: !0, heading: !0, tilt: !0 }), gt = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), Z = 0, wt = 1, bt = 2, ot = 3;
|
|
392
|
+
function Y(i, t, s, e, n = 1 / 0) {
|
|
393
|
+
const r = i ?? t;
|
|
394
|
+
if (typeof r != "number" || Number.isNaN(r) || r < e || r > n)
|
|
395
|
+
throw new m("invalid-option", `[Nova3D] Globe controls ${s} must be in [${e}, ${n}].`);
|
|
396
|
+
return r;
|
|
397
|
+
}
|
|
398
|
+
function O(i, t, s, e, n, r, o, a) {
|
|
399
|
+
const c = Math.hypot(t, s, e);
|
|
400
|
+
if (c < 1e-15 || n === 0)
|
|
401
|
+
return;
|
|
402
|
+
const h = t / c, l = s / c, _ = e / c, u = Math.cos(n), d = Math.sin(n), f = 1 - u, y = f * h * h + u, p = f * h * l - d * _, w = f * h * _ + d * l, v = f * h * l + d * _, b = f * l * l + u, T = f * l * _ - d * h, M = f * h * _ - d * l, x = f * l * _ + d * h, N = f * _ * _ + u;
|
|
403
|
+
for (let D = 0; D < 4; D++) {
|
|
404
|
+
const g = D * 4;
|
|
405
|
+
let F = i[g], A = i[g + 1], E = i[g + 2];
|
|
406
|
+
D === 3 && (F -= r, A -= o, E -= a);
|
|
407
|
+
let z = y * F + p * A + w * E, L = v * F + b * A + T * E, U = M * F + x * A + N * E;
|
|
408
|
+
D === 3 && (z += r, L += o, U += a), i[g] = z, i[g + 1] = L, i[g + 2] = U;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
class ie {
|
|
412
|
+
/** @internal */
|
|
413
|
+
constructor(t, s, e = {}) {
|
|
414
|
+
if (this._app = t, this._camera = s, t.destroyed || !s || s.destroyed || s.kind !== "perspective")
|
|
415
|
+
throw new m("destroyed", "[Nova3D] Globe controls need a live perspective camera.");
|
|
416
|
+
this._radii = W(e.ellipsoid ?? G);
|
|
417
|
+
const n = Math.max(...this._radii);
|
|
418
|
+
if (this._min = Y(e.minDistance, 10, "minDistance", 0), this._max = Y(e.maxDistance, n * 4, "maxDistance", this._min), this._maxTilt = Y(e.maxTilt, 1.4, "maxTilt", 0, Math.PI / 2 - 1e-6), this._damping = Y(e.damping, 0, "damping", 0, 1), this._rotateSpeed = Y(e.rotateSpeed, 5e-3, "rotateSpeed", 0), this._zoomSpeed = Y(e.zoomSpeed, 2e-3, "zoomSpeed", 0), this._adjustNearFar = e.adjustNearFar ?? !0, typeof this._adjustNearFar != "boolean")
|
|
419
|
+
throw new m("invalid-option", "[Nova3D] adjustNearFar must be boolean.");
|
|
420
|
+
e.frame !== void 0 && this._setFrame(e.frame), this._initial = s.getTransform(), this._initialProjection = s.getOptions(), this._readPose(), this._goal.set(this._pose), this._listen(), this._cleanup.push(t.onUpdate((r) => this._tick(r.deltaTime))), this._cleanup.push(t._controlStyle(this)), this._cleanup.push(t._own(() => this.destroy()));
|
|
421
|
+
}
|
|
422
|
+
_radii;
|
|
423
|
+
_min;
|
|
424
|
+
_max;
|
|
425
|
+
_maxTilt;
|
|
426
|
+
_damping;
|
|
427
|
+
_rotateSpeed;
|
|
428
|
+
_zoomSpeed;
|
|
429
|
+
_adjustNearFar;
|
|
430
|
+
_cleanup = [];
|
|
431
|
+
_initial;
|
|
432
|
+
_initialProjection;
|
|
433
|
+
_frame = new Float64Array(gt);
|
|
434
|
+
_inverse = new Float64Array(gt);
|
|
435
|
+
/** Displayed camera pose in the ellipsoid frame (columns right, up, back, position). */
|
|
436
|
+
_pose = new Float64Array(16);
|
|
437
|
+
/** Pose the camera converges to (equal to `_pose` without damping). */
|
|
438
|
+
_goal = new Float64Array(16);
|
|
439
|
+
_scratch = new Float64Array(16);
|
|
440
|
+
_projection32 = X();
|
|
441
|
+
_parent32 = X();
|
|
442
|
+
_ray = new Float64Array(6);
|
|
443
|
+
_point = new Float64Array(3);
|
|
444
|
+
_grab = new Float64Array(3);
|
|
445
|
+
_pivot = new Float64Array(3);
|
|
446
|
+
_pointers = /* @__PURE__ */ new Map();
|
|
447
|
+
_written = null;
|
|
448
|
+
_mode = Z;
|
|
449
|
+
_hasGrab = !1;
|
|
450
|
+
_lastX = 0;
|
|
451
|
+
_lastY = 0;
|
|
452
|
+
_touchDistance = 0;
|
|
453
|
+
_touchAngle = 0;
|
|
454
|
+
_lease;
|
|
455
|
+
_enabled = !0;
|
|
456
|
+
_destroyed = !1;
|
|
457
|
+
get enabled() {
|
|
458
|
+
return this._enabled;
|
|
459
|
+
}
|
|
460
|
+
get destroyed() {
|
|
461
|
+
return this._destroyed;
|
|
462
|
+
}
|
|
463
|
+
/** Camera height above the ellipsoid in ellipsoid metres. */
|
|
464
|
+
get altitude() {
|
|
465
|
+
return this._height(this._pose[12], this._pose[13], this._pose[14]);
|
|
466
|
+
}
|
|
467
|
+
setEnabled(t) {
|
|
468
|
+
if (this._assertAlive(), typeof t != "boolean")
|
|
469
|
+
throw new m("invalid-option", "[Nova3D] enabled must be boolean.");
|
|
470
|
+
t || (this._cancel(), this._stop()), this._enabled = t;
|
|
471
|
+
}
|
|
472
|
+
/** Replaces the ellipsoid frame → world matrix (the camera keeps its world pose). */
|
|
473
|
+
setFrame(t) {
|
|
474
|
+
this._assertAlive(), this._cancel(), this._stop(), this._setFrame(t), this._readPose(), this._goal.set(this._pose);
|
|
475
|
+
}
|
|
476
|
+
/** Places the camera above geodetic coordinates. */
|
|
477
|
+
setView(t) {
|
|
478
|
+
$(t, re, "globe view"), this._assertAlive();
|
|
479
|
+
const { latitude: s, longitude: e, height: n } = t, r = t.heading ?? 0, o = t.tilt ?? 0;
|
|
480
|
+
if (![s, e, n, r, o].every(Number.isFinite) || Math.abs(s) > Math.PI / 2 || o < 0 || o > Math.PI / 2)
|
|
481
|
+
throw new m("invalid-option", "[Nova3D] Globe view needs finite radians, |latitude| ≤ π/2 and tilt in [0, π/2].");
|
|
482
|
+
this._cancel(), this._stop();
|
|
483
|
+
const a = this._goal;
|
|
484
|
+
ht(a, s, e, Math.max(this._min, Math.min(this._max, n)), this._radii);
|
|
485
|
+
const c = a[8], h = a[9], l = a[10];
|
|
486
|
+
O(a, c, h, l, -r, a[12], a[13], a[14]), O(a, a[0], a[1], a[2], o, a[12], a[13], a[14]), this._pose.set(a), this._write();
|
|
487
|
+
}
|
|
488
|
+
/** Geodetic position of the camera. */
|
|
489
|
+
getGeodetic() {
|
|
490
|
+
this._assertAlive();
|
|
491
|
+
const t = [0, 0, 0];
|
|
492
|
+
if (!H(t, this._pose[12], this._pose[13], this._pose[14], this._radii))
|
|
493
|
+
throw new m("invalid-option", "[Nova3D] The camera is at the ellipsoid centre.");
|
|
494
|
+
return { latitude: t[0], longitude: t[1], height: t[2] };
|
|
495
|
+
}
|
|
496
|
+
/** Re-reads the camera pose after external changes. */
|
|
497
|
+
sync() {
|
|
498
|
+
this._assertAlive(), this._stop(), this._readPose(), this._goal.set(this._pose);
|
|
499
|
+
}
|
|
500
|
+
reset() {
|
|
501
|
+
this._assertAlive(), this._cancel(), this._stop(), this._camera._setTransform(this._initial), this._camera._setProjection(this._initialProjection), this._readPose(), this._goal.set(this._pose);
|
|
502
|
+
}
|
|
503
|
+
destroy() {
|
|
504
|
+
if (!this._destroyed) {
|
|
505
|
+
this._destroyed = !0, this._cancel(), this._stop();
|
|
506
|
+
for (const t of this._cleanup.splice(0).reverse())
|
|
507
|
+
t();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
// ── Pose bookkeeping ─────────────────────────────────────────────────────────
|
|
511
|
+
_setFrame(t) {
|
|
512
|
+
if (!t || t.length !== 16 || !Array.from(t).every(Number.isFinite))
|
|
513
|
+
throw new m("invalid-option", "[Nova3D] Globe transform needs 16 finite numbers.");
|
|
514
|
+
const s = new Float64Array(t);
|
|
515
|
+
if (!V(this._inverse, s))
|
|
516
|
+
throw new m("invalid-option", "[Nova3D] Globe transform is singular.");
|
|
517
|
+
this._frame.set(s);
|
|
518
|
+
}
|
|
519
|
+
/** World scale of ellipsoid metres. */
|
|
520
|
+
_scale() {
|
|
521
|
+
const t = this._frame;
|
|
522
|
+
return Math.cbrt(Math.abs(t[0] * (t[5] * t[10] - t[6] * t[9]) - t[4] * (t[1] * t[10] - t[2] * t[9]) + t[8] * (t[1] * t[6] - t[2] * t[5])));
|
|
523
|
+
}
|
|
524
|
+
/** Camera world in double precision (parent world × local TRS), into the ellipsoid frame. */
|
|
525
|
+
_readPose() {
|
|
526
|
+
const t = this._camera.getTransform(), s = this._scratch, [e, n, r, o] = t.quaternion, [a, c, h] = t.scale, l = e * e, _ = n * n, u = r * r;
|
|
527
|
+
s.set([
|
|
528
|
+
(1 - 2 * (_ + u)) * a,
|
|
529
|
+
2 * (e * n + o * r) * a,
|
|
530
|
+
2 * (e * r - o * n) * a,
|
|
531
|
+
0,
|
|
532
|
+
2 * (e * n - o * r) * c,
|
|
533
|
+
(1 - 2 * (l + u)) * c,
|
|
534
|
+
2 * (n * r + o * e) * c,
|
|
535
|
+
0,
|
|
536
|
+
2 * (e * r + o * n) * h,
|
|
537
|
+
2 * (n * r - o * e) * h,
|
|
538
|
+
(1 - 2 * (l + _)) * h,
|
|
539
|
+
0,
|
|
540
|
+
t.position[0],
|
|
541
|
+
t.position[1],
|
|
542
|
+
t.position[2],
|
|
543
|
+
1
|
|
544
|
+
]);
|
|
545
|
+
const d = this._camera.parent;
|
|
546
|
+
d instanceof _t && (d.getWorldMatrix(this._parent32), S(s, this._parent32, s)), S(this._pose, this._inverse, s);
|
|
547
|
+
for (let f = 0; f < 3; f++) {
|
|
548
|
+
const y = f * 4, p = Math.hypot(this._pose[y], this._pose[y + 1], this._pose[y + 2]) || 1;
|
|
549
|
+
this._pose[y] /= p, this._pose[y + 1] /= p, this._pose[y + 2] /= p;
|
|
550
|
+
}
|
|
551
|
+
this._written = t;
|
|
552
|
+
}
|
|
553
|
+
/** Re-reads the camera when something else moved it since the last write. */
|
|
554
|
+
_syncIfMoved() {
|
|
555
|
+
const t = this._camera.getTransform(), s = this._written;
|
|
556
|
+
(!s || t.position.some((e, n) => e !== s.position[n]) || t.quaternion.some((e, n) => e !== s.quaternion[n])) && (this._stop(), this._readPose(), this._goal.set(this._pose));
|
|
557
|
+
}
|
|
558
|
+
_write() {
|
|
559
|
+
const t = this._camera, s = this._scratch;
|
|
560
|
+
S(s, this._frame, this._pose);
|
|
561
|
+
const e = t.parent;
|
|
562
|
+
if (e instanceof _t) {
|
|
563
|
+
e.getWorldMatrix(this._parent32);
|
|
564
|
+
const r = V(X(), this._parent32);
|
|
565
|
+
if (!r)
|
|
566
|
+
throw new m("invalid-option", "[Nova3D] Globe camera parent is singular.");
|
|
567
|
+
S(s, r, s);
|
|
568
|
+
}
|
|
569
|
+
const n = At(s);
|
|
570
|
+
if (t._setTransform(n), this._written = t.getTransform(), this._adjustNearFar) {
|
|
571
|
+
const r = Math.max(0, this._height(this._pose[12], this._pose[13], this._pose[14])), o = Math.max(...this._radii), a = 1e4, c = this._scale(), h = Math.max(0.1, r * 0.05), l = Math.sqrt(r * (2 * o + r)) + Math.sqrt(a * (2 * o + a)) + h * 2;
|
|
572
|
+
t._setProjection({ near: h * c, far: l * c });
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
_height(t, s, e) {
|
|
576
|
+
const n = this._point;
|
|
577
|
+
return H(n, t, s, e, this._radii) ? n[2] : -Math.max(...this._radii);
|
|
578
|
+
}
|
|
579
|
+
/** Keeps the right axis horizontal (up toward the local normal) after a move. */
|
|
580
|
+
_alignUp(t) {
|
|
581
|
+
const s = this._radii, e = this._point;
|
|
582
|
+
if (!ct(e, t[12], t[13], t[14], s))
|
|
583
|
+
return;
|
|
584
|
+
let n = e[0] / (s[0] * s[0]), r = e[1] / (s[1] * s[1]), o = e[2] / (s[2] * s[2]);
|
|
585
|
+
const a = Math.hypot(n, r, o);
|
|
586
|
+
n /= a, r /= a, o /= a;
|
|
587
|
+
const c = -t[8], h = -t[9], l = -t[10];
|
|
588
|
+
let _ = h * o - l * r, u = l * n - c * o, d = c * r - h * n;
|
|
589
|
+
if (Math.hypot(_, u, d) < 0.1) {
|
|
590
|
+
const p = t[0] * n + t[1] * r + t[2] * o;
|
|
591
|
+
_ = t[0] - p * n, u = t[1] - p * r, d = t[2] - p * o;
|
|
592
|
+
}
|
|
593
|
+
const f = _ * c + u * h + d * l;
|
|
594
|
+
_ -= f * c, u -= f * h, d -= f * l;
|
|
595
|
+
const y = Math.hypot(_, u, d);
|
|
596
|
+
y < 1e-12 || (_ /= y, u /= y, d /= y, t[0] = _, t[1] = u, t[2] = d, t[4] = u * l - d * h, t[5] = d * c - _ * l, t[6] = _ * h - u * c);
|
|
597
|
+
}
|
|
598
|
+
// ── Rays ────────────────────────────────────────────────────────────────────
|
|
599
|
+
/** Writes the pointer ray of `pose` (origin, unit direction) in the ellipsoid frame. */
|
|
600
|
+
_pointerRay(t, s, e) {
|
|
601
|
+
const r = this._app.target.getBoundingClientRect();
|
|
602
|
+
let o = 0, a = 0, c = r.width, h = r.height;
|
|
603
|
+
for (const v of this._app._viewList())
|
|
604
|
+
if (v.camera === this._camera && !v.target) {
|
|
605
|
+
const b = v.viewport;
|
|
606
|
+
b && (o = b.x * r.width, a = b.y * r.height, c = b.width * r.width, h = b.height * r.height);
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
if (!(c > 0) || !(h > 0))
|
|
610
|
+
return !1;
|
|
611
|
+
const l = (t - r.left - o) / c * 2 - 1, _ = 1 - (s - r.top - a) / h * 2, u = this._camera.getProjectionMatrix(c / h, this._projection32), d = this._scratch;
|
|
612
|
+
if (!V(d, u))
|
|
613
|
+
return !1;
|
|
614
|
+
const f = d[3] * l + d[7] * _ + d[11] + d[15], y = (d[0] * l + d[4] * _ + d[8] + d[12]) / f, p = (d[1] * l + d[5] * _ + d[9] + d[13]) / f, w = (d[2] * l + d[6] * _ + d[10] + d[14]) / f;
|
|
615
|
+
return this._cameraRay(y, p, w, e), !0;
|
|
616
|
+
}
|
|
617
|
+
_cameraRay(t, s, e, n) {
|
|
618
|
+
const r = this._ray;
|
|
619
|
+
r[0] = n[12], r[1] = n[13], r[2] = n[14];
|
|
620
|
+
const o = n[0] * t + n[4] * s + n[8] * e, a = n[1] * t + n[5] * s + n[9] * e, c = n[2] * t + n[6] * s + n[10] * e, h = Math.hypot(o, a, c) || 1;
|
|
621
|
+
r[3] = o / h, r[4] = a / h, r[5] = c / h;
|
|
622
|
+
}
|
|
623
|
+
/** Ray parameter of the ellipsoid hit of `_ray`, or −1. */
|
|
624
|
+
_hit() {
|
|
625
|
+
const t = this._ray;
|
|
626
|
+
return Ht(t[0], t[1], t[2], t[3], t[4], t[5], this._radii);
|
|
627
|
+
}
|
|
628
|
+
// ── Operations (all on the goal pose) ──────────────────────────────────────
|
|
629
|
+
/** Rotates the globe so the grabbed point follows the pointer. @internal */
|
|
630
|
+
_rotateTo(t, s) {
|
|
631
|
+
const e = this._goal;
|
|
632
|
+
if (this._hasGrab) {
|
|
633
|
+
if (this._pointerRay(t, s, e)) {
|
|
634
|
+
const n = this._ray, r = this._grab, o = Math.hypot(r[0], r[1], r[2]), a = n[0] * n[3] + n[1] * n[4] + n[2] * n[5], c = n[0] * n[0] + n[1] * n[1] + n[2] * n[2] - o * o, h = a * a - c, l = h >= 0 ? -a - Math.sqrt(h) : -a;
|
|
635
|
+
let _ = n[0] + n[3] * Math.max(0, l), u = n[1] + n[4] * Math.max(0, l), d = n[2] + n[5] * Math.max(0, l);
|
|
636
|
+
const f = Math.hypot(_, u, d) || 1;
|
|
637
|
+
_ *= o / f, u *= o / f, d *= o / f;
|
|
638
|
+
const y = u * r[2] - d * r[1], p = d * r[0] - _ * r[2], w = _ * r[1] - u * r[0], v = Math.atan2(Math.hypot(y, p, w), _ * r[0] + u * r[1] + d * r[2]);
|
|
639
|
+
O(e, y, p, w, v, 0, 0, 0);
|
|
640
|
+
}
|
|
641
|
+
} else {
|
|
642
|
+
const n = t - this._lastX, r = s - this._lastY, o = Math.max(1e-6, Math.min(1, this._altitudeOf(e) / Math.max(...this._radii)));
|
|
643
|
+
O(e, e[4], e[5], e[6], -n * this._rotateSpeed * o, 0, 0, 0), O(e, e[0], e[1], e[2], -r * this._rotateSpeed * o, 0, 0, 0);
|
|
644
|
+
}
|
|
645
|
+
this._lastX = t, this._lastY = s, this._alignUp(e), this._schedule();
|
|
646
|
+
}
|
|
647
|
+
/** Height of a pose above the ellipsoid. */
|
|
648
|
+
_altitudeOf(t) {
|
|
649
|
+
return this._height(t[12], t[13], t[14]);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Moves along the pointer ray so the surface point under it stays put while the
|
|
653
|
+
* distance scales by `factor` (< 1 zooms in), clamped to the height limits. @internal
|
|
654
|
+
*/
|
|
655
|
+
_zoom(t, s, e) {
|
|
656
|
+
const n = this._goal;
|
|
657
|
+
if (!(e > 0) || e === 1)
|
|
658
|
+
return;
|
|
659
|
+
let r;
|
|
660
|
+
if (this._pointerRay(t, s, n)) {
|
|
661
|
+
const f = this._hit();
|
|
662
|
+
r = f > 0 ? f : Math.max(this._altitudeOf(n), this._min);
|
|
663
|
+
} else
|
|
664
|
+
this._cameraRay(0, 0, -1, n), r = Math.max(this._altitudeOf(n), this._min);
|
|
665
|
+
const o = this._ray, a = r * (1 - e), c = n[12], h = n[13], l = n[14], _ = (f) => this._height(c + o[3] * a * f, h + o[4] * a * f, l + o[5] * a * f);
|
|
666
|
+
let u = 1;
|
|
667
|
+
const d = _(1);
|
|
668
|
+
if (d < this._min || d > this._max) {
|
|
669
|
+
let f = 0, y = 1;
|
|
670
|
+
for (let p = 0; p < 40; p++) {
|
|
671
|
+
const w = (f + y) / 2, v = _(w);
|
|
672
|
+
v >= this._min && v <= this._max ? f = w : y = w;
|
|
673
|
+
}
|
|
674
|
+
u = f;
|
|
675
|
+
}
|
|
676
|
+
n[12] = c + o[3] * a * u, n[13] = h + o[4] * a * u, n[14] = l + o[5] * a * u, this._alignUp(n), this._schedule();
|
|
677
|
+
}
|
|
678
|
+
/** Turns the heading (about the pivot normal) and tilt (about the camera right axis). @internal */
|
|
679
|
+
_orbit(t, s) {
|
|
680
|
+
const e = this._goal, n = this._pivot, r = this._radii;
|
|
681
|
+
let o = n[0] / (r[0] * r[0]), a = n[1] / (r[1] * r[1]), c = n[2] / (r[2] * r[2]);
|
|
682
|
+
const h = Math.hypot(o, a, c) || 1;
|
|
683
|
+
if (o /= h, a /= h, c /= h, s !== 0) {
|
|
684
|
+
let l = e[0], _ = e[1], u = e[2];
|
|
685
|
+
const d = l * o + _ * a + u * c;
|
|
686
|
+
l -= d * o, _ -= d * a, u -= d * c;
|
|
687
|
+
const f = a * u - c * _, y = c * l - o * u, p = o * _ - a * l, w = e[12] - n[0], v = e[13] - n[1], b = e[14] - n[2], T = Math.atan2(-(w * f + v * y + b * p), w * o + v * a + b * c), M = Math.max(0, Math.min(this._maxTilt, T + s)), x = this._scratch;
|
|
688
|
+
x.set(e), O(e, l, _, u, M - T, n[0], n[1], n[2]), this._altitudeOf(e) < this._min && e.set(x);
|
|
689
|
+
}
|
|
690
|
+
O(e, o, a, c, t, n[0], n[1], n[2]), this._alignUp(e), this._schedule();
|
|
691
|
+
}
|
|
692
|
+
/** Sets the heading/tilt pivot: the surface under the view centre, else under the pointer, else below the camera. */
|
|
693
|
+
_choosePivot(t, s) {
|
|
694
|
+
const e = this._goal, n = this._pivot;
|
|
695
|
+
this._cameraRay(0, 0, -1, e);
|
|
696
|
+
let r = this._hit();
|
|
697
|
+
r < 0 && this._pointerRay(t, s, e) && (r = this._hit());
|
|
698
|
+
const o = this._ray;
|
|
699
|
+
r >= 0 ? (n[0] = o[0] + o[3] * r, n[1] = o[1] + o[4] * r, n[2] = o[2] + o[5] * r) : ct(n, e[12], e[13], e[14], this._radii) || n.fill(0);
|
|
700
|
+
}
|
|
701
|
+
/** Starts a grab rotation: the ellipsoid point under the pointer, if any. */
|
|
702
|
+
_beginRotate(t, s) {
|
|
703
|
+
if (this._mode = wt, this._lastX = t, this._lastY = s, this._hasGrab = !1, this._pointerRay(t, s, this._goal)) {
|
|
704
|
+
const e = this._hit();
|
|
705
|
+
if (e >= 0) {
|
|
706
|
+
const n = this._ray;
|
|
707
|
+
this._grab[0] = n[0] + n[3] * e, this._grab[1] = n[1] + n[4] * e, this._grab[2] = n[2] + n[5] * e, this._hasGrab = !0;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
// ── Input ───────────────────────────────────────────────────────────────────
|
|
712
|
+
_active() {
|
|
713
|
+
return !this._destroyed && this._enabled && !this._camera.destroyed && !this._app.destroyed;
|
|
714
|
+
}
|
|
715
|
+
_listen() {
|
|
716
|
+
const t = this._app.target, s = t.ownerDocument.defaultView, e = (n, r, o, a = !1) => {
|
|
717
|
+
if (!n)
|
|
718
|
+
return;
|
|
719
|
+
const c = (h) => this._app._deliverInput(() => o(h));
|
|
720
|
+
n.addEventListener(r, c, { passive: a }), this._cleanup.push(() => n.removeEventListener(r, c));
|
|
721
|
+
};
|
|
722
|
+
e(t, "pointerdown", (n) => this._down(n)), e(t, "pointermove", (n) => this._moveEvent(n)), e(t, "pointerup", (n) => this._up(n)), e(t, "pointercancel", (n) => this._up(n)), e(t, "lostpointercapture", (n) => this._up(n)), e(t, "wheel", (n) => this._wheel(n)), e(t, "contextmenu", (n) => {
|
|
723
|
+
this._active() && n.preventDefault();
|
|
724
|
+
}), e(s, "blur", () => this._cancel()), e(s, "keydown", (n) => {
|
|
725
|
+
n.key === "Escape" && this._mode !== Z && this._cancel();
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
_down(t) {
|
|
729
|
+
if (!(!this._active() || t.defaultPrevented || this._pointers.size >= 2)) {
|
|
730
|
+
if (this._pointers.size === 0) {
|
|
731
|
+
if (!this._app._claimInput(this))
|
|
732
|
+
return;
|
|
733
|
+
this._syncIfMoved();
|
|
734
|
+
}
|
|
735
|
+
this._pointers.set(t.pointerId, { x: t.clientX, y: t.clientY });
|
|
736
|
+
try {
|
|
737
|
+
this._app.target.setPointerCapture?.(t.pointerId);
|
|
738
|
+
} catch {
|
|
739
|
+
}
|
|
740
|
+
t.preventDefault(), this._pointers.size === 2 ? this._beginTouch() : t.button === 2 || t.ctrlKey || t.shiftKey ? (this._mode = bt, this._lastX = t.clientX, this._lastY = t.clientY, this._choosePivot(t.clientX, t.clientY)) : this._beginRotate(t.clientX, t.clientY);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
_beginTouch() {
|
|
744
|
+
const [t, s] = [...this._pointers.values()];
|
|
745
|
+
this._mode = ot, this._touchDistance = Math.hypot(s.x - t.x, s.y - t.y), this._touchAngle = Math.atan2(s.y - t.y, s.x - t.x), this._lastX = (t.x + s.x) / 2, this._lastY = (t.y + s.y) / 2, this._choosePivot(this._lastX, this._lastY);
|
|
746
|
+
}
|
|
747
|
+
_moveEvent(t) {
|
|
748
|
+
const s = this._pointers.get(t.pointerId);
|
|
749
|
+
if (s) {
|
|
750
|
+
if (!this._active()) {
|
|
751
|
+
this._cancel();
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (t.preventDefault(), s.x = t.clientX, s.y = t.clientY, this._mode === wt)
|
|
755
|
+
this._rotateTo(t.clientX, t.clientY);
|
|
756
|
+
else if (this._mode === bt) {
|
|
757
|
+
const e = t.clientX - this._lastX, n = t.clientY - this._lastY;
|
|
758
|
+
this._lastX = t.clientX, this._lastY = t.clientY, this._orbit(-e * this._rotateSpeed, -n * this._rotateSpeed);
|
|
759
|
+
} else if (this._mode === ot) {
|
|
760
|
+
const [e, n] = [...this._pointers.values()], r = Math.hypot(n.x - e.x, n.y - e.y), o = Math.atan2(n.y - e.y, n.x - e.x), a = (e.x + n.x) / 2, c = (e.y + n.y) / 2;
|
|
761
|
+
let h = o - this._touchAngle;
|
|
762
|
+
h = Math.atan2(Math.sin(h), Math.cos(h));
|
|
763
|
+
const l = c - this._lastY;
|
|
764
|
+
r > 1 && this._touchDistance > 1 && this._zoom(a, c, this._touchDistance / r), this._orbit(h, -l * this._rotateSpeed), this._touchDistance = r, this._touchAngle = o, this._lastX = a, this._lastY = c;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
_up(t) {
|
|
769
|
+
if (this._pointers.delete(t.pointerId)) {
|
|
770
|
+
if (this._app.target.hasPointerCapture?.(t.pointerId) && this._app.target.releasePointerCapture(t.pointerId), this._pointers.size === 1 && this._mode === ot) {
|
|
771
|
+
const [s] = [...this._pointers.values()];
|
|
772
|
+
this._beginRotate(s.x, s.y);
|
|
773
|
+
return;
|
|
774
|
+
}
|
|
775
|
+
this._pointers.size === 0 && (this._mode = Z, this._app._releaseInput(this));
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
_wheel(t) {
|
|
779
|
+
if (!(!this._active() || this._pointers.size > 0 || !this._app._claimInput(this)))
|
|
780
|
+
try {
|
|
781
|
+
t.preventDefault(), this._syncIfMoved();
|
|
782
|
+
const s = t.deltaY * (t.deltaMode === 1 ? 16 : t.deltaMode === 2 ? this._app._cssExtent("height") : 1);
|
|
783
|
+
this._zoom(t.clientX, t.clientY, Math.exp(Math.max(-10, Math.min(10, s * this._zoomSpeed))));
|
|
784
|
+
} finally {
|
|
785
|
+
this._app._releaseInput(this);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
/** Ends a gesture where it is (the camera keeps the pose reached so far). */
|
|
789
|
+
_cancel() {
|
|
790
|
+
for (const s of this._pointers.keys())
|
|
791
|
+
this._app.target.hasPointerCapture?.(s) && this._app.target.releasePointerCapture(s);
|
|
792
|
+
const t = this._pointers.size > 0;
|
|
793
|
+
this._pointers.clear(), this._mode = Z, t && this._app._releaseInput(this);
|
|
794
|
+
}
|
|
795
|
+
// ── Frames ──────────────────────────────────────────────────────────────────
|
|
796
|
+
_schedule() {
|
|
797
|
+
if (this._damping === 0 || this._damping === 1) {
|
|
798
|
+
this._pose.set(this._goal), this._write();
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
this._lease ??= this._app._acquireLoop("nova3d.globe");
|
|
802
|
+
}
|
|
803
|
+
_tick(t) {
|
|
804
|
+
if (!this._lease)
|
|
805
|
+
return;
|
|
806
|
+
if (!this._active()) {
|
|
807
|
+
this._stop();
|
|
808
|
+
return;
|
|
809
|
+
}
|
|
810
|
+
const s = 1 - (1 - this._damping) ** (Math.max(1e-3, Math.min(0.1, t)) * 60), e = this._pose, n = this._goal, r = Math.hypot(e[12], e[13], e[14]), o = Math.hypot(n[12], n[13], n[14]);
|
|
811
|
+
let a = Math.abs(o - r);
|
|
812
|
+
if (r > 0 && o > 0) {
|
|
813
|
+
const w = e[13] * n[14] - e[14] * n[13], v = e[14] * n[12] - e[12] * n[14], b = e[12] * n[13] - e[13] * n[12], T = Math.atan2(Math.hypot(w, v, b), e[12] * n[12] + e[13] * n[13] + e[14] * n[14]);
|
|
814
|
+
a += T * o, O(e, w, v, b, T * s, 0, 0, 0);
|
|
815
|
+
const M = r + (o - r) * s, x = Math.hypot(e[12], e[13], e[14]);
|
|
816
|
+
e[12] *= M / x, e[13] *= M / x, e[14] *= M / x;
|
|
817
|
+
}
|
|
818
|
+
let c = -e[8] + (e[8] - n[8]) * s, h = -e[9] + (e[9] - n[9]) * s, l = -e[10] + (e[10] - n[10]) * s, _ = e[0] + (n[0] - e[0]) * s, u = e[1] + (n[1] - e[1]) * s, d = e[2] + (n[2] - e[2]) * s;
|
|
819
|
+
a += Math.hypot(n[8] - e[8], n[9] - e[9], n[10] - e[10]) * Math.max(1, o - Math.max(...this._radii));
|
|
820
|
+
const f = Math.hypot(c, h, l) || 1;
|
|
821
|
+
c /= f, h /= f, l /= f;
|
|
822
|
+
const y = _ * c + u * h + d * l;
|
|
823
|
+
_ -= y * c, u -= y * h, d -= y * l;
|
|
824
|
+
const p = Math.hypot(_, u, d) || 1;
|
|
825
|
+
e[0] = _ / p, e[1] = u / p, e[2] = d / p, e[8] = -c, e[9] = -h, e[10] = -l, e[4] = e[1] * l - e[2] * h, e[5] = e[2] * c - e[0] * l, e[6] = e[0] * h - e[1] * c, a < 1e-4 && (e.set(n), this._stop()), this._write();
|
|
826
|
+
}
|
|
827
|
+
_stop() {
|
|
828
|
+
this._lease?.release(), this._lease = void 0;
|
|
829
|
+
}
|
|
830
|
+
_assertAlive() {
|
|
831
|
+
if (this._destroyed || this._app.destroyed)
|
|
832
|
+
throw new m("destroyed", "[Nova3D] Globe controls are destroyed.");
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
function Ue(i, t) {
|
|
836
|
+
return $(t, ne, "globe controls"), new ie(i, t?.camera, t);
|
|
837
|
+
}
|
|
838
|
+
const vt = 1179937895, St = new TextDecoder("utf-8");
|
|
839
|
+
function Ut(i) {
|
|
840
|
+
return i.byteLength < 4 ? "" : String.fromCharCode(i[0], i[1], i[2], i[3]);
|
|
841
|
+
}
|
|
842
|
+
function C(i) {
|
|
843
|
+
return new DataView(i.buffer, i.byteOffset, i.byteLength);
|
|
844
|
+
}
|
|
845
|
+
function lt(i, t) {
|
|
846
|
+
if (i.byteLength === 0)
|
|
847
|
+
return {};
|
|
848
|
+
let s;
|
|
849
|
+
try {
|
|
850
|
+
s = JSON.parse(St.decode(i).replace(/\0+$/, ""));
|
|
851
|
+
} catch {
|
|
852
|
+
throw new m("format", `[Nova3D] Invalid ${t} JSON.`);
|
|
853
|
+
}
|
|
854
|
+
if (s === null || typeof s != "object" || Array.isArray(s))
|
|
855
|
+
throw new m("format", `[Nova3D] ${t} JSON must be an object.`);
|
|
856
|
+
return s;
|
|
857
|
+
}
|
|
858
|
+
const oe = {
|
|
859
|
+
BYTE: { size: 1, read: (i, t) => i.getInt8(t) },
|
|
860
|
+
UNSIGNED_BYTE: { size: 1, read: (i, t) => i.getUint8(t) },
|
|
861
|
+
SHORT: { size: 2, read: (i, t) => i.getInt16(t, !0) },
|
|
862
|
+
UNSIGNED_SHORT: { size: 2, read: (i, t) => i.getUint16(t, !0) },
|
|
863
|
+
INT: { size: 4, read: (i, t) => i.getInt32(t, !0) },
|
|
864
|
+
UNSIGNED_INT: { size: 4, read: (i, t) => i.getUint32(t, !0) },
|
|
865
|
+
FLOAT: { size: 4, read: (i, t) => i.getFloat32(t, !0) },
|
|
866
|
+
DOUBLE: { size: 8, read: (i, t) => i.getFloat64(t, !0) }
|
|
867
|
+
};
|
|
868
|
+
class ae {
|
|
869
|
+
constructor(t, s) {
|
|
870
|
+
this.json = t, this._binary = s;
|
|
871
|
+
}
|
|
872
|
+
has(t) {
|
|
873
|
+
return this.json[t] !== void 0;
|
|
874
|
+
}
|
|
875
|
+
/** A global property: an inline number/array, or a binary reference. */
|
|
876
|
+
global(t, s, e = "FLOAT") {
|
|
877
|
+
const n = this.json[t];
|
|
878
|
+
if (n === void 0)
|
|
879
|
+
return null;
|
|
880
|
+
if (typeof n == "number" || typeof n == "boolean")
|
|
881
|
+
return [Number(n)];
|
|
882
|
+
if (Array.isArray(n)) {
|
|
883
|
+
if (n.length !== s || !n.every((r) => typeof r == "number" && Number.isFinite(r)))
|
|
884
|
+
throw new m("format", `[Nova3D] Feature table ${t} needs ${s} numbers.`);
|
|
885
|
+
return n;
|
|
886
|
+
}
|
|
887
|
+
return Array.from(this.array(t, 1, s, e));
|
|
888
|
+
}
|
|
889
|
+
/** A per-feature property in the binary body as doubles, or null when absent. */
|
|
890
|
+
array(t, s, e, n) {
|
|
891
|
+
const r = this.json[t];
|
|
892
|
+
if (r === void 0)
|
|
893
|
+
return null;
|
|
894
|
+
if (r === null || typeof r != "object" || Array.isArray(r))
|
|
895
|
+
throw new m("format", `[Nova3D] Feature table ${t} must reference the binary body.`);
|
|
896
|
+
const o = r, a = typeof o.componentType == "string" ? o.componentType : n, c = oe[a], h = o.byteOffset;
|
|
897
|
+
if (!c || typeof h != "number" || !Number.isSafeInteger(h) || h < 0)
|
|
898
|
+
throw new m("format", `[Nova3D] Feature table ${t} has an invalid binary reference.`);
|
|
899
|
+
const l = s * e;
|
|
900
|
+
if (h + l * c.size > this._binary.byteLength)
|
|
901
|
+
throw new m("format", `[Nova3D] Feature table ${t} exceeds the binary body.`);
|
|
902
|
+
const _ = C(this._binary), u = new Float64Array(l);
|
|
903
|
+
for (let d = 0; d < l; d++)
|
|
904
|
+
u[d] = c.read(_, h + d * c.size);
|
|
905
|
+
return u;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function dt(i, t) {
|
|
909
|
+
const s = t === "i3dm" ? 32 : 28;
|
|
910
|
+
if (i.byteLength < s || Ut(i) !== t)
|
|
911
|
+
throw new m("format", `[Nova3D] Invalid ${t} header.`);
|
|
912
|
+
const e = C(i), n = e.getUint32(4, !0), r = e.getUint32(8, !0);
|
|
913
|
+
if (n !== 1 || r > i.byteLength || r < s)
|
|
914
|
+
throw new m("unsupported", `[Nova3D] Unsupported ${t} version or length.`);
|
|
915
|
+
let o = e.getUint32(12, !0), a = e.getUint32(16, !0), c = e.getUint32(20, !0), h = e.getUint32(24, !0), l = s;
|
|
916
|
+
t === "b3dm" && (c >= 570425344 ? (l -= 8, c = a, h = 0, o = 0, a = 0) : h >= 570425344 && (l -= 4, c = o, h = a, o = 0, a = 0));
|
|
917
|
+
const _ = t === "i3dm" ? e.getUint32(28, !0) : 1, u = l + o + a + c + h;
|
|
918
|
+
if (u > r)
|
|
919
|
+
throw new m("format", `[Nova3D] ${t} tables exceed the tile length.`);
|
|
920
|
+
const d = lt(i.subarray(l, l + o), `${t} feature table`), f = i.subarray(l + o, l + o + a);
|
|
921
|
+
return { featureTable: new ae(d, f), body: i.subarray(u, r), gltfFormat: _ };
|
|
922
|
+
}
|
|
923
|
+
const ce = new TextEncoder().encode("CESIUM_RTC");
|
|
924
|
+
function he(i, t) {
|
|
925
|
+
const s = t[0];
|
|
926
|
+
for (let e = i.indexOf(s); e >= 0 && e + t.length <= i.length; e = i.indexOf(s, e + 1)) {
|
|
927
|
+
let n = 1;
|
|
928
|
+
for (; n < t.length && i[e + n] === t[n]; )
|
|
929
|
+
n++;
|
|
930
|
+
if (n === t.length)
|
|
931
|
+
return !0;
|
|
932
|
+
}
|
|
933
|
+
return !1;
|
|
934
|
+
}
|
|
935
|
+
function tt(i) {
|
|
936
|
+
const t = i.byteLength >= 20 && C(i).getUint32(0, !0) === vt;
|
|
937
|
+
let s = 0, e = i.byteLength;
|
|
938
|
+
if (t && (e = C(i).getUint32(12, !0), s = 20, s + e > i.byteLength))
|
|
939
|
+
throw new m("format", "[Nova3D] Invalid GLB JSON chunk.");
|
|
940
|
+
const n = i.subarray(s, s + e);
|
|
941
|
+
if (!he(n, ce))
|
|
942
|
+
return { data: i, rtc: null };
|
|
943
|
+
const r = lt(n, "glTF"), o = r.extensions, a = o?.CESIUM_RTC?.center, c = Array.isArray(a) && a.length === 3 && a.every((f) => typeof f == "number" && Number.isFinite(f)) ? a : null;
|
|
944
|
+
for (const f of ["extensionsUsed", "extensionsRequired"])
|
|
945
|
+
Array.isArray(r[f]) && (r[f] = r[f].filter((y) => y !== "CESIUM_RTC"));
|
|
946
|
+
o && delete o.CESIUM_RTC;
|
|
947
|
+
const h = new TextEncoder().encode(JSON.stringify(r));
|
|
948
|
+
if (!t)
|
|
949
|
+
return { data: h, rtc: c };
|
|
950
|
+
const l = Math.ceil(h.length / 4) * 4, _ = i.subarray(s + e, C(i).getUint32(8, !0)), u = new Uint8Array(20 + l + _.byteLength), d = C(u);
|
|
951
|
+
return d.setUint32(0, vt, !0), d.setUint32(4, 2, !0), d.setUint32(8, u.byteLength, !0), d.setUint32(12, l, !0), d.setUint32(16, 1313821514, !0), u.fill(32, 20, 20 + l), u.set(h, 20), u.set(_, 20 + l), { data: u, rtc: c };
|
|
952
|
+
}
|
|
953
|
+
function xt(i, t, s, e) {
|
|
954
|
+
let n = i / 65535 * 2 - 1, r = t / 65535 * 2 - 1;
|
|
955
|
+
const o = 1 - (Math.abs(n) + Math.abs(r));
|
|
956
|
+
if (o < 0) {
|
|
957
|
+
const c = n;
|
|
958
|
+
n = (1 - Math.abs(r)) * (c >= 0 ? 1 : -1), r = (1 - Math.abs(c)) * (r >= 0 ? 1 : -1);
|
|
959
|
+
}
|
|
960
|
+
const a = Math.hypot(n, r, o) || 1;
|
|
961
|
+
s[e] = n / a, s[e + 1] = r / a, s[e + 2] = o / a;
|
|
962
|
+
}
|
|
963
|
+
function zt(i, t, s) {
|
|
964
|
+
const e = i.array("POSITION", t, 3, "FLOAT");
|
|
965
|
+
if (e)
|
|
966
|
+
return e;
|
|
967
|
+
const n = i.array("POSITION_QUANTIZED", t, 3, "UNSIGNED_SHORT"), r = i.global("QUANTIZED_VOLUME_OFFSET", 3), o = i.global("QUANTIZED_VOLUME_SCALE", 3);
|
|
968
|
+
if (!n || !r || !o)
|
|
969
|
+
throw new m("format", `[Nova3D] ${s} needs POSITION or POSITION_QUANTIZED with its volume.`);
|
|
970
|
+
for (let a = 0; a < n.length; a++) {
|
|
971
|
+
const c = a % 3;
|
|
972
|
+
n[a] = r[c] + n[a] / 65535 * o[c];
|
|
973
|
+
}
|
|
974
|
+
return n;
|
|
975
|
+
}
|
|
976
|
+
function Lt(i, t, s) {
|
|
977
|
+
const e = i.json[t];
|
|
978
|
+
if (typeof e != "number" || !Number.isSafeInteger(e) || e < 0 || e > s)
|
|
979
|
+
throw new m("format", `[Nova3D] Feature table ${t} must be an integer in [0, ${s}].`);
|
|
980
|
+
return e;
|
|
981
|
+
}
|
|
982
|
+
function le(i) {
|
|
983
|
+
const { featureTable: t, body: s, gltfFormat: e } = dt(i, "i3dm"), n = Lt(t, "INSTANCES_LENGTH", 1 << 22), r = zt(t, n, "i3dm"), o = t.global("RTC_CENTER", 3) ?? [0, 0, 0], a = t.array("NORMAL_UP", n, 3, "FLOAT"), c = t.array("NORMAL_RIGHT", n, 3, "FLOAT"), h = a ? null : t.array("NORMAL_UP_OCT32P", n, 2, "UNSIGNED_SHORT"), l = c ? null : t.array("NORMAL_RIGHT_OCT32P", n, 2, "UNSIGNED_SHORT"), _ = t.json.EAST_NORTH_UP === !0, u = t.array("SCALE", n, 1, "FLOAT"), d = t.array("SCALE_NON_UNIFORM", n, 3, "FLOAT"), f = [0, 0, 0];
|
|
984
|
+
for (let b = 0; b < n; b++)
|
|
985
|
+
f[0] += r[b * 3] / n, f[1] += r[b * 3 + 1] / n, f[2] += r[b * 3 + 2] / n;
|
|
986
|
+
const y = new Float64Array(n * 16), p = [0, 0, 0, 0, 0, 0, 0, 0, 0], w = G.radii;
|
|
987
|
+
for (let b = 0; b < n; b++) {
|
|
988
|
+
const T = r[b * 3], M = r[b * 3 + 1], x = r[b * 3 + 2];
|
|
989
|
+
if (a && c)
|
|
990
|
+
p[0] = c[b * 3], p[1] = c[b * 3 + 1], p[2] = c[b * 3 + 2], p[3] = a[b * 3], p[4] = a[b * 3 + 1], p[5] = a[b * 3 + 2];
|
|
991
|
+
else if (h && l)
|
|
992
|
+
xt(l[b * 2], l[b * 2 + 1], p, 0), xt(h[b * 2], h[b * 2 + 1], p, 3);
|
|
993
|
+
else if (_) {
|
|
994
|
+
const E = T + o[0], z = M + o[1], L = x + o[2];
|
|
995
|
+
let U = E / (w[0] * w[0]), R = z / (w[1] * w[1]), I = L / (w[2] * w[2]);
|
|
996
|
+
const q = Math.hypot(U, R, I) || 1;
|
|
997
|
+
U /= q, R /= q, I /= q;
|
|
998
|
+
let k = -z, B = E;
|
|
999
|
+
const st = Math.hypot(k, B);
|
|
1000
|
+
st < 1e-9 ? (k = 0, B = 1) : (k /= st, B /= st), p[0] = k, p[1] = B, p[2] = 0, p[3] = -I * B, p[4] = I * k, p[5] = U * B - R * k;
|
|
1001
|
+
} else
|
|
1002
|
+
p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 1, p[5] = 0;
|
|
1003
|
+
p[6] = p[1] * p[5] - p[2] * p[4], p[7] = p[2] * p[3] - p[0] * p[5], p[8] = p[0] * p[4] - p[1] * p[3];
|
|
1004
|
+
const N = u ? u[b] : 1, D = N * (d ? d[b * 3] : 1), g = N * (d ? d[b * 3 + 1] : 1), F = N * (d ? d[b * 3 + 2] : 1), A = b * 16;
|
|
1005
|
+
for (let E = 0; E < 3; E++)
|
|
1006
|
+
y[A + E] = p[E] * D, y[A + 4 + E] = p[3 + E] * g, y[A + 8 + E] = p[6 + E] * F;
|
|
1007
|
+
y[A + 12] = T - f[0], y[A + 13] = M - f[1], y[A + 14] = x - f[2], y[A + 15] = 1;
|
|
1008
|
+
}
|
|
1009
|
+
const v = [o[0] + f[0], o[1] + f[1], o[2] + f[2]];
|
|
1010
|
+
if (e === 0) {
|
|
1011
|
+
const b = St.decode(s).replace(/[\0\s]+$/, "");
|
|
1012
|
+
if (!b)
|
|
1013
|
+
throw new m("format", "[Nova3D] i3dm glTF URI is empty.");
|
|
1014
|
+
return { kind: "instances", gltf: null, uri: b, origin: v, matrices: y, count: n };
|
|
1015
|
+
}
|
|
1016
|
+
if (e !== 1)
|
|
1017
|
+
throw new m("unsupported", "[Nova3D] Unsupported i3dm gltfFormat.");
|
|
1018
|
+
return { kind: "instances", gltf: s, uri: null, origin: v, matrices: y, count: n };
|
|
1019
|
+
}
|
|
1020
|
+
function de(i) {
|
|
1021
|
+
const { featureTable: t } = dt(i, "pnts");
|
|
1022
|
+
if (t.json.extensions?.["3DTILES_draco_point_compression"])
|
|
1023
|
+
throw new m("unsupported", "[Nova3D] Draco-compressed point clouds are not supported.");
|
|
1024
|
+
const e = Lt(t, "POINTS_LENGTH", 1 << 24), n = zt(t, e, "pnts"), r = t.global("RTC_CENTER", 3), o = new Float32Array(e * 3);
|
|
1025
|
+
o.set(n);
|
|
1026
|
+
let a = null;
|
|
1027
|
+
const c = t.array("RGBA", e, 4, "UNSIGNED_BYTE"), h = c ? null : t.array("RGB", e, 3, "UNSIGNED_BYTE"), l = c || h ? null : t.array("RGB565", e, 1, "UNSIGNED_SHORT");
|
|
1028
|
+
if (c || h || l) {
|
|
1029
|
+
a = new Float32Array(e * 4);
|
|
1030
|
+
for (let d = 0; d < e; d++)
|
|
1031
|
+
if (c)
|
|
1032
|
+
for (let f = 0; f < 4; f++)
|
|
1033
|
+
a[d * 4 + f] = c[d * 4 + f] / 255;
|
|
1034
|
+
else if (h) {
|
|
1035
|
+
for (let f = 0; f < 3; f++)
|
|
1036
|
+
a[d * 4 + f] = h[d * 3 + f] / 255;
|
|
1037
|
+
a[d * 4 + 3] = 1;
|
|
1038
|
+
} else {
|
|
1039
|
+
const f = l[d];
|
|
1040
|
+
a[d * 4] = (f >> 11) / 31, a[d * 4 + 1] = (f >> 5 & 63) / 63, a[d * 4 + 2] = (f & 31) / 31, a[d * 4 + 3] = 1;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
const _ = t.global("CONSTANT_RGBA", 4, "UNSIGNED_BYTE"), u = a === null && _ ? _.map((d) => d / 255) : null;
|
|
1044
|
+
return { kind: "points", positions: o, colors: a, constant: u, rtc: r };
|
|
1045
|
+
}
|
|
1046
|
+
function _e(i) {
|
|
1047
|
+
const { featureTable: t, body: s } = dt(i, "b3dm"), e = t.global("RTC_CENTER", 3), n = tt(s);
|
|
1048
|
+
return { kind: "gltf", data: n.data, rtc: e ?? n.rtc };
|
|
1049
|
+
}
|
|
1050
|
+
function Ot(i, t = [], s = 0) {
|
|
1051
|
+
const e = Ut(i);
|
|
1052
|
+
if (e === "glTF") {
|
|
1053
|
+
const r = tt(i);
|
|
1054
|
+
return t.push({ kind: "gltf", data: r.data, rtc: r.rtc }), t;
|
|
1055
|
+
}
|
|
1056
|
+
if (e === "b3dm")
|
|
1057
|
+
return t.push(_e(i)), t;
|
|
1058
|
+
if (e === "i3dm")
|
|
1059
|
+
return t.push(le(i)), t;
|
|
1060
|
+
if (e === "pnts")
|
|
1061
|
+
return t.push(de(i)), t;
|
|
1062
|
+
if (e === "cmpt") {
|
|
1063
|
+
if (s > 8 || i.byteLength < 16)
|
|
1064
|
+
throw new m("format", "[Nova3D] Invalid or too deeply nested cmpt tile.");
|
|
1065
|
+
const r = C(i), o = r.getUint32(8, !0), a = r.getUint32(12, !0);
|
|
1066
|
+
if (r.getUint32(4, !0) !== 1 || o > i.byteLength)
|
|
1067
|
+
throw new m("unsupported", "[Nova3D] Unsupported cmpt version or length.");
|
|
1068
|
+
let c = 16;
|
|
1069
|
+
for (let h = 0; h < a; h++) {
|
|
1070
|
+
if (c + 12 > o)
|
|
1071
|
+
throw new m("format", "[Nova3D] cmpt inner tile exceeds the container.");
|
|
1072
|
+
const l = r.getUint32(c + 8, !0);
|
|
1073
|
+
if (l < 12 || c + l > o)
|
|
1074
|
+
throw new m("format", "[Nova3D] cmpt inner tile exceeds the container.");
|
|
1075
|
+
Ot(i.subarray(c, c + l), t, s + 1), c += l;
|
|
1076
|
+
}
|
|
1077
|
+
return t;
|
|
1078
|
+
}
|
|
1079
|
+
let n = 0;
|
|
1080
|
+
for (; n < i.length && (i[n] === 32 || i[n] === 10 || i[n] === 13 || i[n] === 9 || i[n] === 239 || i[n] === 187 || i[n] === 191); )
|
|
1081
|
+
n++;
|
|
1082
|
+
if (i[n] === 123) {
|
|
1083
|
+
const r = lt(i, "tile content");
|
|
1084
|
+
if (r.root !== void 0 && r.asset !== void 0 && r.geometricError !== void 0)
|
|
1085
|
+
return t.push({ kind: "tileset", json: r }), t;
|
|
1086
|
+
const o = tt(i);
|
|
1087
|
+
return t.push({ kind: "gltf", data: o.data, rtc: o.rtc }), t;
|
|
1088
|
+
}
|
|
1089
|
+
throw new m("unsupported", `[Nova3D] Unsupported tile content "${e.replace(/[^\x20-\x7E]/g, "?")}".`);
|
|
1090
|
+
}
|
|
1091
|
+
function at(i, t, s) {
|
|
1092
|
+
return new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, i, t, s, 1]);
|
|
1093
|
+
}
|
|
1094
|
+
function fe(i, t, s) {
|
|
1095
|
+
let e = Math.hypot(s[0], s[1], s[2]);
|
|
1096
|
+
const n = Math.hypot(s[4], s[5], s[6]), r = Math.hypot(s[8], s[9], s[10]);
|
|
1097
|
+
s[0] * (s[5] * s[10] - s[6] * s[9]) - s[4] * (s[1] * s[10] - s[2] * s[9]) + s[8] * (s[1] * s[6] - s[2] * s[5]) < 0 && (e = -e);
|
|
1098
|
+
const a = e === 0 ? 0 : 1 / e, c = n === 0 ? 0 : 1 / n, h = r === 0 ? 0 : 1 / r, l = s[0] * a, _ = s[1] * a, u = s[2] * a, d = s[4] * c, f = s[5] * c, y = s[6] * c, p = s[8] * h, w = s[9] * h, v = s[10] * h, b = l + f + v;
|
|
1099
|
+
let T, M, x, N;
|
|
1100
|
+
if (b > 0) {
|
|
1101
|
+
const g = Math.sqrt(b + 1) * 2;
|
|
1102
|
+
N = 0.25 * g, T = (y - w) / g, M = (p - u) / g, x = (_ - d) / g;
|
|
1103
|
+
} else if (l > f && l > v) {
|
|
1104
|
+
const g = Math.sqrt(1 + l - f - v) * 2;
|
|
1105
|
+
N = (y - w) / g, T = 0.25 * g, M = (d + _) / g, x = (p + u) / g;
|
|
1106
|
+
} else if (f > v) {
|
|
1107
|
+
const g = Math.sqrt(1 + f - l - v) * 2;
|
|
1108
|
+
N = (p - u) / g, T = (d + _) / g, M = 0.25 * g, x = (w + y) / g;
|
|
1109
|
+
} else {
|
|
1110
|
+
const g = Math.sqrt(1 + v - l - f) * 2;
|
|
1111
|
+
N = (_ - d) / g, T = (p + u) / g, M = (w + y) / g, x = 0.25 * g;
|
|
1112
|
+
}
|
|
1113
|
+
const D = Math.hypot(T, M, x, N) || 1;
|
|
1114
|
+
i[t] = s[12], i[t + 1] = s[13], i[t + 2] = s[14], i[t + 3] = T / D, i[t + 4] = M / D, i[t + 5] = x / D, i[t + 6] = N / D, i[t + 7] = e, i[t + 8] = n, i[t + 9] = r;
|
|
1115
|
+
}
|
|
1116
|
+
function ue(i) {
|
|
1117
|
+
const t = /^data:[^,]*?(;base64)?,(.*)$/s.exec(i);
|
|
1118
|
+
if (!t)
|
|
1119
|
+
throw new m("invalid-option", "[Nova3D] Invalid data URI.");
|
|
1120
|
+
if (!t[1])
|
|
1121
|
+
return new TextEncoder().encode(decodeURIComponent(t[2]));
|
|
1122
|
+
const s = atob(t[2]), e = new Uint8Array(s.length);
|
|
1123
|
+
for (let n = 0; n < s.length; n++)
|
|
1124
|
+
e[n] = s.charCodeAt(n);
|
|
1125
|
+
return e;
|
|
1126
|
+
}
|
|
1127
|
+
function pe(i, t, s) {
|
|
1128
|
+
const e = async (n, r) => {
|
|
1129
|
+
const o = s.bytes ? (a, c) => a.startsWith("data:") ? Promise.resolve(ue(a)) : s.bytes(new URL(a, c.baseUrl ?? r.url).href, c.signal) : s.gltf?.resolveResource;
|
|
1130
|
+
return jt(n, { ...s.gltf, signal: r.signal, baseUrl: r.url, resolveResource: o });
|
|
1131
|
+
};
|
|
1132
|
+
return async (n, r) => {
|
|
1133
|
+
const o = [], a = [], c = () => {
|
|
1134
|
+
let h;
|
|
1135
|
+
for (const l of a.splice(0).reverse())
|
|
1136
|
+
try {
|
|
1137
|
+
l();
|
|
1138
|
+
} catch (_) {
|
|
1139
|
+
h ??= _;
|
|
1140
|
+
}
|
|
1141
|
+
if (h !== void 0)
|
|
1142
|
+
throw h;
|
|
1143
|
+
};
|
|
1144
|
+
try {
|
|
1145
|
+
for (const h of n)
|
|
1146
|
+
if (h.kind === "gltf") {
|
|
1147
|
+
const l = await e(h.data, r);
|
|
1148
|
+
a.push(() => l.destroy());
|
|
1149
|
+
const _ = l.instantiate(t);
|
|
1150
|
+
a.push(() => _.destroy());
|
|
1151
|
+
const u = h.rtc, d = u ? S(new Float64Array(16), at(u[0], u[1], u[2]), r.upAxis) : r.upAxis;
|
|
1152
|
+
o.push({ node: _.root, local: d });
|
|
1153
|
+
} else if (h.kind === "instances") {
|
|
1154
|
+
let l = h.gltf;
|
|
1155
|
+
if (!l) {
|
|
1156
|
+
const p = new URL(h.uri, r.url).href;
|
|
1157
|
+
l = s.bytes ? await s.bytes(p, r.signal) : new Uint8Array(await (await Pt(p, { signal: r.signal })).arrayBuffer());
|
|
1158
|
+
}
|
|
1159
|
+
const _ = await e(tt(l).data, r);
|
|
1160
|
+
a.push(() => _.destroy());
|
|
1161
|
+
const u = _.instantiate(t), d = t.createGroup(), f = [];
|
|
1162
|
+
a.push(() => {
|
|
1163
|
+
for (const p of f)
|
|
1164
|
+
p.destroy();
|
|
1165
|
+
d.destroy();
|
|
1166
|
+
});
|
|
1167
|
+
try {
|
|
1168
|
+
const p = [u.root], w = new Float32Array(h.count * 10), v = new Float64Array(16), b = new Float64Array(16);
|
|
1169
|
+
for (; p.length > 0; ) {
|
|
1170
|
+
const T = p.pop();
|
|
1171
|
+
if (p.push(...T.children), !(T instanceof $t) || T instanceof Yt)
|
|
1172
|
+
continue;
|
|
1173
|
+
const M = T.getWorldMatrix();
|
|
1174
|
+
S(b, r.upAxis, M);
|
|
1175
|
+
for (let N = 0; N < h.count; N++)
|
|
1176
|
+
S(v, h.matrices.subarray(N * 16, N * 16 + 16), b), fe(w, N * 10, v);
|
|
1177
|
+
const x = t.createInstancedMesh({ geometry: T.geometry, material: T.material, capacity: Math.max(1, h.count), count: h.count });
|
|
1178
|
+
f.push(x), h.count > 0 && x.updatePoses(0, w, h.count), x.reparent(d, { preserve: "local" });
|
|
1179
|
+
}
|
|
1180
|
+
} finally {
|
|
1181
|
+
u.destroy();
|
|
1182
|
+
}
|
|
1183
|
+
const y = h.origin;
|
|
1184
|
+
o.push({ node: d, local: at(y[0], y[1], y[2]) });
|
|
1185
|
+
} else if (h.kind === "points") {
|
|
1186
|
+
const l = i.createGeometry({ positions: h.positions, colors: h.colors ?? void 0, topology: "points" });
|
|
1187
|
+
a.push(() => l.destroy());
|
|
1188
|
+
const _ = h.constant ?? [1, 1, 1, 1], u = h.colors ? h.colors.some((p, w) => w % 4 === 3 && p < 1) : _[3] < 1, d = i.createMaterial({ type: "basic", color: _, pointSize: s.pointSize, alphaMode: u ? "blend" : "opaque" });
|
|
1189
|
+
a.push(() => d.destroy());
|
|
1190
|
+
const f = t.createMesh({ geometry: l, material: d });
|
|
1191
|
+
a.push(() => f.destroy());
|
|
1192
|
+
const y = h.rtc;
|
|
1193
|
+
o.push({ node: f, local: y ? at(y[0], y[1], y[2]) : null });
|
|
1194
|
+
} else
|
|
1195
|
+
throw new m("format", "[Nova3D] An external tileset cannot share a tile with other contents.");
|
|
1196
|
+
} catch (h) {
|
|
1197
|
+
try {
|
|
1198
|
+
c();
|
|
1199
|
+
} catch {
|
|
1200
|
+
}
|
|
1201
|
+
throw h;
|
|
1202
|
+
}
|
|
1203
|
+
return { parts: o, destroy: c };
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
function Nt(i) {
|
|
1207
|
+
try {
|
|
1208
|
+
i();
|
|
1209
|
+
} catch (t) {
|
|
1210
|
+
globalThis.reportError(t);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
const Tt = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
1214
|
+
function Mt(i, t, s) {
|
|
1215
|
+
const e = i ?? t;
|
|
1216
|
+
if (!Number.isSafeInteger(e) || e <= 0)
|
|
1217
|
+
throw new m("invalid-option", `[Nova3D] ${s} must be a positive integer.`);
|
|
1218
|
+
return e;
|
|
1219
|
+
}
|
|
1220
|
+
const ye = et({ url: !0, json: !0, baseUrl: !0, fetch: !0, errorTarget: !0, maxBytes: !0, maxConcurrent: !0, maxTiles: !0, signal: !0, clock: !0, frame: !0, recenter: !0, pointSize: !0, gltf: !0, ellipsoid: !0 }), me = new Set([...Gt].filter((i) => i !== "signal"));
|
|
1221
|
+
function Dt(i) {
|
|
1222
|
+
if (!i || i.length !== 16 || !Array.from(i).every(Number.isFinite))
|
|
1223
|
+
throw new m("invalid-option", "[Nova3D] A tileset frame needs 16 finite numbers.");
|
|
1224
|
+
return new Float64Array(i);
|
|
1225
|
+
}
|
|
1226
|
+
function ge(i) {
|
|
1227
|
+
return i.reason ?? new DOMException("Tile load aborted", "AbortError");
|
|
1228
|
+
}
|
|
1229
|
+
class we {
|
|
1230
|
+
/** @internal */
|
|
1231
|
+
constructor(t, s, e, n) {
|
|
1232
|
+
if (this._app = t, !e || !t._ownsScene(s))
|
|
1233
|
+
throw new m("owner", "[Nova3D] Tiles need a live scene of this app.");
|
|
1234
|
+
if ($(e, ye, "tiles"), e.gltf !== void 0 && ($(e.gltf, me, "tiles glTF"), e.gltf.decoders !== void 0 && $(e.gltf.decoders, Ct, "glTF decoders")), e.url === void 0 == (e.json === void 0))
|
|
1235
|
+
throw new m("invalid-option", "[Nova3D] Tiles need exactly one of url or json.");
|
|
1236
|
+
if (this._errorTarget = e.errorTarget ?? 16, !Number.isFinite(this._errorTarget) || this._errorTarget <= 0)
|
|
1237
|
+
throw new m("invalid-option", "[Nova3D] errorTarget must be a positive number of pixels.");
|
|
1238
|
+
if (this._maxBytes = e.maxBytes ?? 256 * 1024 * 1024, !Number.isFinite(this._maxBytes) || this._maxBytes < 0)
|
|
1239
|
+
throw new m("invalid-option", "[Nova3D] maxBytes must be a non-negative number.");
|
|
1240
|
+
this._maxConcurrent = Mt(e.maxConcurrent, 6, "maxConcurrent"), this._maxTiles = Mt(e.maxTiles, 1e6, "maxTiles");
|
|
1241
|
+
const r = e.pointSize ?? 2;
|
|
1242
|
+
if (!Number.isFinite(r) || r <= 0)
|
|
1243
|
+
throw new m("invalid-option", "[Nova3D] pointSize must be positive.");
|
|
1244
|
+
if (e.fetch !== void 0 && typeof e.fetch != "function")
|
|
1245
|
+
throw new m("invalid-option", "[Nova3D] fetch must be a function.");
|
|
1246
|
+
this._radii = W(e.ellipsoid ?? G), e.frame !== void 0 && (this._frame = Dt(e.frame)), this._recenter = e.recenter ?? !1, this._fetch = e.fetch ?? ((_, u) => globalThis.fetch(_, u)), this._scene = s;
|
|
1247
|
+
const o = (_, u) => this._bytes(_, u);
|
|
1248
|
+
this._factory = n ?? pe(t, s, { gltf: e.gltf, bytes: e.fetch ? o : void 0, pointSize: r }), this.root = s.createGroup();
|
|
1249
|
+
const a = e.signal;
|
|
1250
|
+
if (a) {
|
|
1251
|
+
const _ = () => this._controller.abort(a.reason);
|
|
1252
|
+
a.addEventListener("abort", _, { once: !0 }), this._cleanup.push(() => a.removeEventListener("abort", _)), a.aborted && _();
|
|
1253
|
+
}
|
|
1254
|
+
this._cleanup.push(t._own(() => this._abandon()));
|
|
1255
|
+
const c = e.clock ?? "app";
|
|
1256
|
+
if (c !== "app" && c !== "manual")
|
|
1257
|
+
throw new m("invalid-option", "[Nova3D] Tiles clock must be app or manual.");
|
|
1258
|
+
c === "app" && this._cleanup.push(t._beforeRender(() => this._autoUpdate()));
|
|
1259
|
+
const h = e.baseUrl !== void 0 ? String(e.baseUrl) : this._documentBase(), l = e.url === void 0 ? void 0 : new URL(String(e.url), h).href;
|
|
1260
|
+
this._ready = Promise.resolve().then(() => this._start(l, e.json, l ?? h)), this._ready.catch(() => {
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
/** Group of every tile node; transform it freely (it composes after `frame`). */
|
|
1264
|
+
root;
|
|
1265
|
+
_ready;
|
|
1266
|
+
_scene;
|
|
1267
|
+
_fetch;
|
|
1268
|
+
_factory;
|
|
1269
|
+
_radii;
|
|
1270
|
+
_errorTarget;
|
|
1271
|
+
_maxBytes;
|
|
1272
|
+
_maxConcurrent;
|
|
1273
|
+
_maxTiles;
|
|
1274
|
+
_controller = new AbortController();
|
|
1275
|
+
_cleanup = [];
|
|
1276
|
+
_loadListeners = /* @__PURE__ */ new Set();
|
|
1277
|
+
_errorListeners = /* @__PURE__ */ new Set();
|
|
1278
|
+
_warningListeners = /* @__PURE__ */ new Set();
|
|
1279
|
+
_stats = { visible: 0, loaded: 0, downloading: 0, queued: 0, bytes: 0, tiles: 0, failed: 0 };
|
|
1280
|
+
_loading = /* @__PURE__ */ new Set();
|
|
1281
|
+
_loaded = /* @__PURE__ */ new Set();
|
|
1282
|
+
_wanted = [];
|
|
1283
|
+
_evictable = [];
|
|
1284
|
+
_shown = [];
|
|
1285
|
+
_previous = [];
|
|
1286
|
+
_tileset = null;
|
|
1287
|
+
_frame = new Float64Array(Tt);
|
|
1288
|
+
_recenter;
|
|
1289
|
+
_destroyed = !1;
|
|
1290
|
+
_frameIndex = 0;
|
|
1291
|
+
// Per-update scratch (double precision unless noted).
|
|
1292
|
+
_camera32 = X();
|
|
1293
|
+
_projection32 = X();
|
|
1294
|
+
_root32 = X();
|
|
1295
|
+
_tilesetWorld = new Float64Array(16);
|
|
1296
|
+
_inverse = new Float64Array(16);
|
|
1297
|
+
_placement = new Float64Array(16);
|
|
1298
|
+
_clip = new Float64Array(16);
|
|
1299
|
+
_planes = new Float64Array(24);
|
|
1300
|
+
_eye = new Float64Array(3);
|
|
1301
|
+
_sseScale = 0;
|
|
1302
|
+
_perspective = !0;
|
|
1303
|
+
/** Live counters, updated in place. */
|
|
1304
|
+
get stats() {
|
|
1305
|
+
return this._stats;
|
|
1306
|
+
}
|
|
1307
|
+
get destroyed() {
|
|
1308
|
+
return this._destroyed;
|
|
1309
|
+
}
|
|
1310
|
+
get errorTarget() {
|
|
1311
|
+
return this._errorTarget;
|
|
1312
|
+
}
|
|
1313
|
+
/** Tileset space → root space, written into `out` when given. */
|
|
1314
|
+
getFrame(t = new Float64Array(16)) {
|
|
1315
|
+
for (let s = 0; s < 16; s++)
|
|
1316
|
+
t[s] = this._frame[s];
|
|
1317
|
+
return t;
|
|
1318
|
+
}
|
|
1319
|
+
/** Replaces the double-precision tileset frame; null restores identity. Loaded tiles are re-placed. */
|
|
1320
|
+
setFrame(t) {
|
|
1321
|
+
this._assertAlive(), this._frame = t === null ? new Float64Array(Tt) : Dt(t), this._recenter = !1;
|
|
1322
|
+
for (const s of this._loaded)
|
|
1323
|
+
this._place(s, s.content);
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Tileset space (ECEF for geodata) → world: `root` world × `frame`. Pass it to
|
|
1327
|
+
* globe controls so their ellipsoid follows the tileset.
|
|
1328
|
+
*/
|
|
1329
|
+
getEllipsoidTransform(t = new Float64Array(16)) {
|
|
1330
|
+
return this._assertAlive(), this.root.getWorldMatrix(this._root32), S(t, this._root32, this._frame);
|
|
1331
|
+
}
|
|
1332
|
+
/** World-space bounding sphere of the root tile, or null before `whenReady` resolves. */
|
|
1333
|
+
getBoundingSphere() {
|
|
1334
|
+
this._assertAlive();
|
|
1335
|
+
const t = this._tileset;
|
|
1336
|
+
if (!t)
|
|
1337
|
+
return null;
|
|
1338
|
+
const s = this.getEllipsoidTransform(), [e, n, r] = t.volume.center, o = Math.sqrt(Math.max(s[0] ** 2 + s[1] ** 2 + s[2] ** 2, s[4] ** 2 + s[5] ** 2 + s[6] ** 2, s[8] ** 2 + s[9] ** 2 + s[10] ** 2));
|
|
1339
|
+
return {
|
|
1340
|
+
center: [s[0] * e + s[4] * n + s[8] * r + s[12], s[1] * e + s[5] * n + s[9] * r + s[13], s[2] * e + s[6] * n + s[10] * r + s[14]],
|
|
1341
|
+
radius: t.volume.radius * o
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
onTileLoad(t) {
|
|
1345
|
+
return this._assertAlive(), this._loadListeners.add(t), () => this._loadListeners.delete(t);
|
|
1346
|
+
}
|
|
1347
|
+
/** Resolves once the root tileset document is parsed; rejects with its failure (also sent to `onError`). */
|
|
1348
|
+
whenReady(t) {
|
|
1349
|
+
return kt(this._ready, Bt(t, "tiles").signal);
|
|
1350
|
+
}
|
|
1351
|
+
/** Tileset and content failures; the only place tiles report errors (never `app.onError`). */
|
|
1352
|
+
onError(t) {
|
|
1353
|
+
return this._assertAlive(), this._errorListeners.add(t), () => this._errorListeners.delete(t);
|
|
1354
|
+
}
|
|
1355
|
+
/** Parts of the tileset skipped without failing it, such as implicit tiling. */
|
|
1356
|
+
onWarning(t) {
|
|
1357
|
+
return this._assertAlive(), this._warningListeners.add(t), () => this._warningListeners.delete(t);
|
|
1358
|
+
}
|
|
1359
|
+
/**
|
|
1360
|
+
* Selects, shows and requests tiles for `camera`. `viewport` is the view size in CSS
|
|
1361
|
+
* pixels (default: the app view of this camera, else the canvas). Called before every
|
|
1362
|
+
* frame with the 'app' clock; allocation-free apart from request start-up. Selection
|
|
1363
|
+
* follows the camera, so it takes no time step.
|
|
1364
|
+
*/
|
|
1365
|
+
update(t, s) {
|
|
1366
|
+
this._assertAlive();
|
|
1367
|
+
const e = this._tileset;
|
|
1368
|
+
if (!e || this._controller.signal.aborted)
|
|
1369
|
+
return;
|
|
1370
|
+
let n, r;
|
|
1371
|
+
if (s) {
|
|
1372
|
+
if (n = s.width, r = s.height, !(n > 0) || !(r > 0))
|
|
1373
|
+
throw new m("invalid-option", "[Nova3D] Tiles viewport must be positive.");
|
|
1374
|
+
} else {
|
|
1375
|
+
n = this._app._cssExtent("width"), r = this._app._cssExtent("height");
|
|
1376
|
+
for (const a of this._app._viewList())
|
|
1377
|
+
if (a.camera === t) {
|
|
1378
|
+
n = a.target ? a.target.width : n * (a.viewport?.width ?? 1), r = a.target ? a.target.height : r * (a.viewport?.height ?? 1);
|
|
1379
|
+
break;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
this._prepare(t, n, r);
|
|
1383
|
+
const o = ++this._frameIndex;
|
|
1384
|
+
this._wanted.length = 0, this._traverse(e, o), this._select(e, o), this._applyVisibility(o), this._schedule(o), this._evict(o), this._stats.loaded = this._loaded.size, this._stats.downloading = this._loading.size;
|
|
1385
|
+
}
|
|
1386
|
+
destroy() {
|
|
1387
|
+
if (this._destroyed)
|
|
1388
|
+
return;
|
|
1389
|
+
this._destroyed = !0, this._controller.abort();
|
|
1390
|
+
for (const s of this._loading)
|
|
1391
|
+
s.controller?.abort(), s.controller = null, s.state = j;
|
|
1392
|
+
this._loading.clear();
|
|
1393
|
+
let t;
|
|
1394
|
+
for (const s of this._loaded) {
|
|
1395
|
+
try {
|
|
1396
|
+
s.content?.destroy();
|
|
1397
|
+
} catch (e) {
|
|
1398
|
+
t ??= e;
|
|
1399
|
+
}
|
|
1400
|
+
s.content = null, s.state = j;
|
|
1401
|
+
}
|
|
1402
|
+
this._loaded.clear(), !this.root.destroyed && !this._app.destroyed && this.root.destroy();
|
|
1403
|
+
for (const s of this._cleanup.splice(0).reverse())
|
|
1404
|
+
s();
|
|
1405
|
+
if (this._loadListeners.clear(), this._errorListeners.clear(), t !== void 0)
|
|
1406
|
+
throw t;
|
|
1407
|
+
}
|
|
1408
|
+
/** The app is going away: its scenes and resources are released by it. */
|
|
1409
|
+
_abandon() {
|
|
1410
|
+
this._destroyed = !0, this._controller.abort();
|
|
1411
|
+
for (const t of this._loading)
|
|
1412
|
+
t.controller?.abort(), t.controller = null;
|
|
1413
|
+
this._loading.clear(), this._loaded.clear(), this._cleanup.length = 0;
|
|
1414
|
+
}
|
|
1415
|
+
_documentBase() {
|
|
1416
|
+
return this._app.target?.ownerDocument?.baseURI ?? globalThis.location?.href;
|
|
1417
|
+
}
|
|
1418
|
+
async _start(t, s, e) {
|
|
1419
|
+
try {
|
|
1420
|
+
let n = s;
|
|
1421
|
+
if (t !== void 0) {
|
|
1422
|
+
const o = await this._bytes(t, this._controller.signal);
|
|
1423
|
+
n = JSON.parse(new TextDecoder().decode(o));
|
|
1424
|
+
}
|
|
1425
|
+
if (this._destroyed)
|
|
1426
|
+
return;
|
|
1427
|
+
const r = mt(n, { baseUrl: e, radii: this._radii, maxTiles: this._maxTiles });
|
|
1428
|
+
this._stats.tiles = r.count, this._tileset = r.root;
|
|
1429
|
+
for (const o of r.warnings)
|
|
1430
|
+
this._emitWarning(t ?? null, o);
|
|
1431
|
+
this._recenter && this._recentre(r.root), this._scene._invalidate();
|
|
1432
|
+
} catch (n) {
|
|
1433
|
+
throw this._controller.signal.aborted || this._emitError(t ?? null, n), n;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
_recentre(t) {
|
|
1437
|
+
const [s, e, n] = t.volume.center;
|
|
1438
|
+
if (Math.hypot(s, e, n) < 1e5)
|
|
1439
|
+
return;
|
|
1440
|
+
const r = [0, 0, 0];
|
|
1441
|
+
H(r, s, e, n, this._radii) && (this._frame = It(r[0], r[1], r[2], { ellipsoid: { radii: this._radii } }));
|
|
1442
|
+
}
|
|
1443
|
+
async _bytes(t, s) {
|
|
1444
|
+
const e = await this._fetch(t, { signal: s });
|
|
1445
|
+
if (s.aborted)
|
|
1446
|
+
throw ge(s);
|
|
1447
|
+
if (ArrayBuffer.isView(e))
|
|
1448
|
+
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
1449
|
+
if (Object.prototype.toString.call(e) === "[object ArrayBuffer]")
|
|
1450
|
+
return new Uint8Array(e);
|
|
1451
|
+
const n = e;
|
|
1452
|
+
if (!n || typeof n.arrayBuffer != "function")
|
|
1453
|
+
throw new m("invalid-option", "[Nova3D] Tiles fetch must return a Response or bytes.");
|
|
1454
|
+
if (!n.ok)
|
|
1455
|
+
throw new m("network", `[Nova3D] Tile request failed with HTTP ${n.status}: ${t}`);
|
|
1456
|
+
return new Uint8Array(await n.arrayBuffer());
|
|
1457
|
+
}
|
|
1458
|
+
_autoUpdate() {
|
|
1459
|
+
if (!(this._destroyed || !this._tileset)) {
|
|
1460
|
+
for (const t of this._app._viewList())
|
|
1461
|
+
if (t.scene === this._scene && !t.camera.destroyed) {
|
|
1462
|
+
this.update(t.camera);
|
|
1463
|
+
return;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
/** Camera position, frustum planes and SSE scale in tileset space. */
|
|
1468
|
+
_prepare(t, s, e) {
|
|
1469
|
+
const n = this._tilesetWorld;
|
|
1470
|
+
this.root.getWorldMatrix(this._root32), S(n, this._root32, this._frame), t.getWorldMatrix(this._camera32), t.getProjectionMatrix(s / e, this._projection32);
|
|
1471
|
+
const r = this._inverse;
|
|
1472
|
+
if (!V(r, n))
|
|
1473
|
+
throw new m("invalid-option", "[Nova3D] Tileset world transform is singular.");
|
|
1474
|
+
const o = this._camera32, a = this._eye, c = o[12], h = o[13], l = o[14];
|
|
1475
|
+
a[0] = r[0] * c + r[4] * h + r[8] * l + r[12], a[1] = r[1] * c + r[5] * h + r[9] * l + r[13], a[2] = r[2] * c + r[6] * h + r[10] * l + r[14];
|
|
1476
|
+
const _ = this._clip;
|
|
1477
|
+
if (!V(_, o))
|
|
1478
|
+
throw new m("invalid-option", "[Nova3D] Camera transform is singular.");
|
|
1479
|
+
S(_, _, n), S(_, this._projection32, _), Qt(this._planes, _);
|
|
1480
|
+
const u = this._projection32;
|
|
1481
|
+
if (this._perspective = u[11] !== 0, this._perspective)
|
|
1482
|
+
this._sseScale = e * u[5] / 2;
|
|
1483
|
+
else {
|
|
1484
|
+
const d = n[0] * (n[5] * n[10] - n[6] * n[9]) - n[4] * (n[1] * n[10] - n[2] * n[9]) + n[8] * (n[1] * n[6] - n[2] * n[5]);
|
|
1485
|
+
this._sseScale = e * u[5] / 2 * Math.cbrt(Math.abs(d));
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
_visible(t) {
|
|
1489
|
+
const s = this._eye;
|
|
1490
|
+
return t.viewerRequestVolume && !t.viewerRequestVolume.contains(s[0], s[1], s[2], this._radii) ? !1 : t.volume.intersectsFrustum(this._planes);
|
|
1491
|
+
}
|
|
1492
|
+
_computeError(t) {
|
|
1493
|
+
if (!this._perspective)
|
|
1494
|
+
return t.geometricError * this._sseScale;
|
|
1495
|
+
const s = this._eye, e = t.volume.distanceTo(s[0], s[1], s[2]);
|
|
1496
|
+
return t.distance = e, e <= 1e-9 ? 1 / 0 : t.geometricError * this._sseScale / e;
|
|
1497
|
+
}
|
|
1498
|
+
/** True when the content of a tile can cover its volume (drawn, failed or empty leaf). */
|
|
1499
|
+
_covers(t) {
|
|
1500
|
+
return t.hasRenderable ? t.state === K || t.state === it : !t.external && t.children.length === 0;
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Marks used tiles (in view) and leaves (error met or no children), and returns
|
|
1504
|
+
* whether the subtree can draw without holes this frame.
|
|
1505
|
+
*/
|
|
1506
|
+
_traverse(t, s) {
|
|
1507
|
+
if (!this._visible(t))
|
|
1508
|
+
return !0;
|
|
1509
|
+
t.usedFrame = s, t.lastUsed = s;
|
|
1510
|
+
const e = this._computeError(t);
|
|
1511
|
+
if (t.sse = e, !(t.external || t.children.length > 0 && e > this._errorTarget))
|
|
1512
|
+
return t.leafFrame = s, this._covers(t);
|
|
1513
|
+
let r = !t.external || t.expanded;
|
|
1514
|
+
const o = t.children;
|
|
1515
|
+
for (let a = 0; a < o.length; a++)
|
|
1516
|
+
this._traverse(o[a], s) || (r = !1);
|
|
1517
|
+
return t.childrenReady = r, t.refine === "ADD" ? t.hasRenderable ? this._covers(t) : r : r || t.hasRenderable && this._covers(t);
|
|
1518
|
+
}
|
|
1519
|
+
_select(t, s) {
|
|
1520
|
+
if (t.usedFrame !== s)
|
|
1521
|
+
return;
|
|
1522
|
+
if (t.leafFrame === s) {
|
|
1523
|
+
this._want(t, s), this._showOrKeep(t, s);
|
|
1524
|
+
return;
|
|
1525
|
+
}
|
|
1526
|
+
const e = t.children;
|
|
1527
|
+
if (t.refine === "ADD" || t.childrenReady) {
|
|
1528
|
+
(t.refine === "ADD" || t.external) && (this._want(t, s), this._show(t, s));
|
|
1529
|
+
for (let n = 0; n < e.length; n++)
|
|
1530
|
+
this._select(e[n], s);
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
this._want(t, s), this._showOrKeep(t, s);
|
|
1534
|
+
for (let n = 0; n < e.length; n++)
|
|
1535
|
+
this._prefetch(e[n], s);
|
|
1536
|
+
}
|
|
1537
|
+
_prefetch(t, s) {
|
|
1538
|
+
if (t.usedFrame !== s || (this._want(t, s), t.leafFrame === s))
|
|
1539
|
+
return;
|
|
1540
|
+
const e = t.children;
|
|
1541
|
+
for (let n = 0; n < e.length; n++)
|
|
1542
|
+
this._prefetch(e[n], s);
|
|
1543
|
+
}
|
|
1544
|
+
_want(t, s) {
|
|
1545
|
+
t.contents.length !== 0 && (t.wantedFrame = s, t.state === j && this._wanted.push(t));
|
|
1546
|
+
}
|
|
1547
|
+
_show(t, s) {
|
|
1548
|
+
return t.state !== K || !t.content ? !1 : (t.displayFrame !== s && (t.displayFrame = s, this._shown.push(t)), !0);
|
|
1549
|
+
}
|
|
1550
|
+
/**
|
|
1551
|
+
* Shows a REPLACE tile, or while it is still loading keeps the descendants drawn by
|
|
1552
|
+
* the previous update (zooming out never opens holes).
|
|
1553
|
+
*/
|
|
1554
|
+
_showOrKeep(t, s) {
|
|
1555
|
+
!this._show(t, s) && t.refine === "REPLACE" && t.hasRenderable && t.state !== it && this._keep(t, s);
|
|
1556
|
+
}
|
|
1557
|
+
_keep(t, s) {
|
|
1558
|
+
const e = t.children;
|
|
1559
|
+
for (let n = 0; n < e.length; n++) {
|
|
1560
|
+
const r = e[n];
|
|
1561
|
+
r.shownFrame === s - 1 && (r.displayed && (r.lastUsed = s, this._show(r, s)), this._keep(r, s));
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
_applyVisibility(t) {
|
|
1565
|
+
const s = this._shown;
|
|
1566
|
+
for (let n = 0; n < s.length; n++) {
|
|
1567
|
+
const r = s[n];
|
|
1568
|
+
r.displayed || this._setVisible(r, !0);
|
|
1569
|
+
let o = r;
|
|
1570
|
+
for (; o && o.shownFrame !== t; )
|
|
1571
|
+
o.shownFrame = t, o = o.parent;
|
|
1572
|
+
}
|
|
1573
|
+
const e = this._previous;
|
|
1574
|
+
for (let n = 0; n < e.length; n++) {
|
|
1575
|
+
const r = e[n];
|
|
1576
|
+
r.displayFrame !== t && r.displayed && this._setVisible(r, !1);
|
|
1577
|
+
}
|
|
1578
|
+
this._stats.visible = s.length, e.length = 0, this._previous = s, this._shown = e;
|
|
1579
|
+
}
|
|
1580
|
+
_setVisible(t, s) {
|
|
1581
|
+
t.displayed = s;
|
|
1582
|
+
const e = t.content?.parts;
|
|
1583
|
+
if (e)
|
|
1584
|
+
for (let n = 0; n < e.length; n++) {
|
|
1585
|
+
const r = e[n].node;
|
|
1586
|
+
r.destroyed || r.setVisible(s);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
/** Shallower first (fallbacks for REPLACE), then the larger screen-space error. */
|
|
1590
|
+
_priority = (t, s) => t.depth - s.depth || s.sse - t.sse;
|
|
1591
|
+
_recency = (t, s) => t.lastUsed - s.lastUsed;
|
|
1592
|
+
_schedule(t) {
|
|
1593
|
+
for (const n of this._loading)
|
|
1594
|
+
n.wantedFrame !== t && (n.controller?.abort(), n.controller = null, n.state = j, this._loading.delete(n));
|
|
1595
|
+
const s = this._wanted;
|
|
1596
|
+
s.length > 1 && s.sort(this._priority);
|
|
1597
|
+
let e = 0;
|
|
1598
|
+
for (let n = 0; n < s.length && this._loading.size < this._maxConcurrent; n++)
|
|
1599
|
+
this._load(s[n]), e++;
|
|
1600
|
+
this._stats.queued = s.length - e;
|
|
1601
|
+
}
|
|
1602
|
+
_evict(t) {
|
|
1603
|
+
if (this._stats.bytes <= this._maxBytes)
|
|
1604
|
+
return;
|
|
1605
|
+
const s = this._evictable;
|
|
1606
|
+
s.length = 0;
|
|
1607
|
+
for (const e of this._loaded)
|
|
1608
|
+
e.lastUsed !== t && s.push(e);
|
|
1609
|
+
s.sort(this._recency);
|
|
1610
|
+
for (let e = 0; e < s.length && this._stats.bytes > this._maxBytes; e++)
|
|
1611
|
+
this._unload(s[e]);
|
|
1612
|
+
s.length = 0;
|
|
1613
|
+
}
|
|
1614
|
+
_unload(t) {
|
|
1615
|
+
const s = t.content;
|
|
1616
|
+
t.content = null, t.state = j, t.displayed = !1, this._loaded.delete(t), this._stats.bytes -= t.bytes, t.bytes = 0;
|
|
1617
|
+
try {
|
|
1618
|
+
s?.destroy();
|
|
1619
|
+
} catch (e) {
|
|
1620
|
+
this._emitError(t.contents[0] ?? null, e);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
_place(t, s) {
|
|
1624
|
+
const e = this._placement;
|
|
1625
|
+
for (const n of s.parts)
|
|
1626
|
+
S(e, this._frame, t.transform), n.local && S(e, e, n.local), n.node.parent !== this.root && n.node.reparent(this.root, { preserve: "local" }), n.node._setTransform(At(e));
|
|
1627
|
+
}
|
|
1628
|
+
async _load(t) {
|
|
1629
|
+
const s = new AbortController(), e = s.signal, n = () => s.abort(this._controller.signal.reason);
|
|
1630
|
+
this._controller.signal.addEventListener("abort", n, { once: !0 }), t.controller = s, t.state = ut, this._loading.add(t);
|
|
1631
|
+
let r = null;
|
|
1632
|
+
try {
|
|
1633
|
+
const o = await Promise.all(t.contents.map((h) => this._bytes(h, e)));
|
|
1634
|
+
let a = 0;
|
|
1635
|
+
const c = [];
|
|
1636
|
+
for (const h of o)
|
|
1637
|
+
a += h.byteLength, Ot(h, c);
|
|
1638
|
+
if (t.controller !== s)
|
|
1639
|
+
return;
|
|
1640
|
+
if (c.length === 1 && c[0].kind === "tileset" && t.contents.length === 1) {
|
|
1641
|
+
if (!t.expanded) {
|
|
1642
|
+
const h = mt(c[0].json, { baseUrl: t.contents[0], parent: t, radii: this._radii, maxTiles: this._maxTiles - this._stats.tiles });
|
|
1643
|
+
this._stats.tiles += h.count, t.expanded = !0;
|
|
1644
|
+
for (const l of h.warnings)
|
|
1645
|
+
this._emitWarning(t.contents[0], l);
|
|
1646
|
+
}
|
|
1647
|
+
t.external = !0, t.state = K;
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
if (t.external = !1, r = await this._factory(c, { url: t.contents[0], signal: e, upAxis: t.upAxis }), t.controller !== s || this._destroyed) {
|
|
1651
|
+
const h = r;
|
|
1652
|
+
r = null, this._app.destroyed || h.destroy();
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
this._place(t, r);
|
|
1656
|
+
for (const h of r.parts)
|
|
1657
|
+
h.node.setVisible(!1);
|
|
1658
|
+
if (t.content = r, r = null, t.displayed = !1, t.bytes = a, t.state = K, this._loaded.add(t), this._stats.bytes += a, this._stats.loaded = this._loaded.size, this._loadListeners.size > 0) {
|
|
1659
|
+
const h = Object.freeze({ url: t.contents[0], nodes: Object.freeze(t.content.parts.map((l) => l.node)), depth: t.depth, geometricError: t.geometricError, bytes: a });
|
|
1660
|
+
for (const l of [...this._loadListeners])
|
|
1661
|
+
l(h);
|
|
1662
|
+
}
|
|
1663
|
+
} catch (o) {
|
|
1664
|
+
if (r && !this._app.destroyed)
|
|
1665
|
+
try {
|
|
1666
|
+
r.destroy();
|
|
1667
|
+
} catch {
|
|
1668
|
+
}
|
|
1669
|
+
if (t.controller !== s || e.aborted || this._destroyed)
|
|
1670
|
+
return;
|
|
1671
|
+
t.state = it, this._stats.failed++, this._emitError(t.contents[0] ?? null, o);
|
|
1672
|
+
} finally {
|
|
1673
|
+
this._controller.signal.removeEventListener("abort", n), t.controller === s && (t.controller = null, this._loading.delete(t), t.state === ut && (t.state = j)), this._destroyed || (this._stats.downloading = this._loading.size, this._scene._invalidate());
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
_emitError(t, s) {
|
|
1677
|
+
const e = Object.freeze({ url: t, error: s });
|
|
1678
|
+
for (const n of [...this._errorListeners])
|
|
1679
|
+
Nt(() => n(e));
|
|
1680
|
+
}
|
|
1681
|
+
_emitWarning(t, s) {
|
|
1682
|
+
const e = Object.freeze({ url: t, warning: s });
|
|
1683
|
+
for (const n of [...this._warningListeners])
|
|
1684
|
+
Nt(() => n(e));
|
|
1685
|
+
}
|
|
1686
|
+
_assertAlive() {
|
|
1687
|
+
if (this._destroyed || this._app.destroyed)
|
|
1688
|
+
throw new m("destroyed", "[Nova3D] Tiles are destroyed.");
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
function ze(i, t) {
|
|
1692
|
+
return new we(qt(i), i, t);
|
|
1693
|
+
}
|
|
1694
|
+
export {
|
|
1695
|
+
ie as Nova3DGlobeControls,
|
|
1696
|
+
we as Nova3DTiles,
|
|
1697
|
+
nt as WGS84,
|
|
1698
|
+
G as WGS84_ELLIPSOID,
|
|
1699
|
+
Ue as createGlobeControls,
|
|
1700
|
+
ze as createTiles,
|
|
1701
|
+
Ee as ecefToGeodetic,
|
|
1702
|
+
Se as ecefToLocalFrame,
|
|
1703
|
+
Ie as enuFrame,
|
|
1704
|
+
Fe as geodeticToECEF
|
|
1705
|
+
};
|