@nova-lab/core 1.0.0-dev.19 → 1.1.1-dev.229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +229 -4
package/dist/3d/audio.js
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { N as r, f as I } from "../Errors-B2ekO9bZ.js";
|
|
2
|
+
import { c as _, o as p } from "../Options-CajE7LLJ.js";
|
|
3
|
+
const v = { buffer: !0, volume: !0, muted: !0, loop: !0, loopStart: !0, loopEnd: !0, playbackRate: !0 }, O = { distanceModel: !0, refDistance: !0, maxDistance: !0, rolloffFactor: !0, coneInnerAngle: !0, coneOuterAngle: !0, coneOuterGain: !0, panningModel: !0 }, R = p(v), N = p({ ...v, ...O }), L = p({ ...v, ...O, node: !0 }), P = ["linear", "inverse", "exponential"], G = ["HRTF", "equalpower"], y = Math.PI * 2, D = 180 / Math.PI;
|
|
4
|
+
function c(n, t, e, o = !1, i = 1 / 0) {
|
|
5
|
+
if (typeof n != "number" || !Number.isFinite(n))
|
|
6
|
+
throw new r("invalid-option", `[Nova3D] ${t} must be a finite number.`);
|
|
7
|
+
if (o ? n <= e : n < e)
|
|
8
|
+
throw new r("invalid-option", `[Nova3D] ${t} must be ${o ? "greater than" : "at least"} ${e}.`);
|
|
9
|
+
if (n > i)
|
|
10
|
+
throw new r("invalid-option", `[Nova3D] ${t} must be at most ${i}.`);
|
|
11
|
+
return n;
|
|
12
|
+
}
|
|
13
|
+
function S(n, t) {
|
|
14
|
+
if (typeof n != "boolean")
|
|
15
|
+
throw new r("invalid-option", `[Nova3D] ${t} must be boolean.`);
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
18
|
+
function C(n) {
|
|
19
|
+
return typeof n == "object" && n !== null && typeof n.duration == "number" && typeof n.getChannelData == "function";
|
|
20
|
+
}
|
|
21
|
+
function x(n, t) {
|
|
22
|
+
if (typeof t != "object" || t === null)
|
|
23
|
+
throw new r("invalid-option", "[Nova3D] Sound options must be an object.");
|
|
24
|
+
const e = { ...n };
|
|
25
|
+
if (t.buffer !== void 0) {
|
|
26
|
+
if (t.buffer !== null && !C(t.buffer))
|
|
27
|
+
throw new r("invalid-option", "[Nova3D] Sound buffer must be a decoded AudioBuffer or null.");
|
|
28
|
+
e.buffer = t.buffer;
|
|
29
|
+
}
|
|
30
|
+
if (t.volume !== void 0 && (e.volume = c(t.volume, "Sound volume", 0)), t.muted !== void 0 && (e.muted = S(t.muted, "Sound muted")), t.loop !== void 0 && (e.loop = S(t.loop, "Sound loop")), t.loopStart !== void 0 && (e.loopStart = c(t.loopStart, "Sound loopStart", 0)), t.loopEnd !== void 0 && (e.loopEnd = c(t.loopEnd, "Sound loopEnd", 0)), e.loopEnd > 0 && e.loopEnd <= e.loopStart)
|
|
31
|
+
throw new r("invalid-option", "[Nova3D] Sound loopEnd must be 0 or greater than loopStart.");
|
|
32
|
+
return t.playbackRate !== void 0 && (e.playbackRate = c(t.playbackRate, "Sound playbackRate", 0, !0)), e;
|
|
33
|
+
}
|
|
34
|
+
function M(n, t) {
|
|
35
|
+
const e = { ...n };
|
|
36
|
+
if (t.distanceModel !== void 0) {
|
|
37
|
+
if (!P.includes(t.distanceModel))
|
|
38
|
+
throw new r("invalid-option", "[Nova3D] distanceModel must be linear, inverse or exponential.");
|
|
39
|
+
e.distanceModel = t.distanceModel;
|
|
40
|
+
}
|
|
41
|
+
if (t.refDistance !== void 0 && (e.refDistance = c(t.refDistance, "refDistance", 0)), t.maxDistance !== void 0 && (e.maxDistance = c(t.maxDistance, "maxDistance", 0, !0)), t.rolloffFactor !== void 0 && (e.rolloffFactor = c(t.rolloffFactor, "rolloffFactor", 0)), t.coneInnerAngle !== void 0 && (e.coneInnerAngle = c(t.coneInnerAngle, "coneInnerAngle", 0, !1, y)), t.coneOuterAngle !== void 0 && (e.coneOuterAngle = c(t.coneOuterAngle, "coneOuterAngle", 0, !1, y)), t.coneOuterGain !== void 0 && (e.coneOuterGain = c(t.coneOuterGain, "coneOuterGain", 0, !1, 1)), t.panningModel !== void 0) {
|
|
42
|
+
if (!G.includes(t.panningModel))
|
|
43
|
+
throw new r("invalid-option", "[Nova3D] panningModel must be HRTF or equalpower.");
|
|
44
|
+
e.panningModel = t.panningModel;
|
|
45
|
+
}
|
|
46
|
+
return e;
|
|
47
|
+
}
|
|
48
|
+
class T {
|
|
49
|
+
/** Created by `Nova3DAudio`. @internal */
|
|
50
|
+
constructor(t, e) {
|
|
51
|
+
this._host = t, this._context = t.context, this._options = x({ buffer: null, volume: 1, muted: !1, loop: !1, loopStart: 0, loopEnd: 0, playbackRate: 1 }, e), this._gain = this._context.createGain(), this._gain.gain.value = this._options.muted ? 0 : this._options.volume, this._gain.connect(t._output());
|
|
52
|
+
}
|
|
53
|
+
/** @internal */
|
|
54
|
+
_context;
|
|
55
|
+
/** @internal */
|
|
56
|
+
_gain;
|
|
57
|
+
/** @internal */
|
|
58
|
+
_destroyed = !1;
|
|
59
|
+
_options;
|
|
60
|
+
_source = null;
|
|
61
|
+
_state = "stopped";
|
|
62
|
+
/** Buffer position (seconds) at `_startedAt`. */
|
|
63
|
+
_offset = 0;
|
|
64
|
+
_startedAt = 0;
|
|
65
|
+
_endedListeners = /* @__PURE__ */ new Set();
|
|
66
|
+
_ended = (t) => {
|
|
67
|
+
const e = this._source;
|
|
68
|
+
if (!(!e || t.target !== e)) {
|
|
69
|
+
this._source = null, e.onended = null, e.disconnect(), this._state = "stopped", this._offset = 0;
|
|
70
|
+
for (const o of [...this._endedListeners])
|
|
71
|
+
o();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
get destroyed() {
|
|
75
|
+
return this._destroyed;
|
|
76
|
+
}
|
|
77
|
+
/** A non-looping sound reached its end on its own (not by `stop`); returns unsubscribe. */
|
|
78
|
+
onEnded(t) {
|
|
79
|
+
return this._assertAlive(), this._endedListeners.add(t), () => this._endedListeners.delete(t);
|
|
80
|
+
}
|
|
81
|
+
get state() {
|
|
82
|
+
return this._state;
|
|
83
|
+
}
|
|
84
|
+
get buffer() {
|
|
85
|
+
return this._options.buffer;
|
|
86
|
+
}
|
|
87
|
+
/** Buffer duration in seconds, 0 without a buffer. */
|
|
88
|
+
get duration() {
|
|
89
|
+
return this._options.buffer?.duration ?? 0;
|
|
90
|
+
}
|
|
91
|
+
/** Current position in buffer seconds, folded into the loop region while looping. */
|
|
92
|
+
get currentTime() {
|
|
93
|
+
if (this._state !== "playing")
|
|
94
|
+
return this._offset;
|
|
95
|
+
const t = this._options, e = this.duration, o = this._offset + (this._context.currentTime - this._startedAt) * t.playbackRate;
|
|
96
|
+
if (!t.loop)
|
|
97
|
+
return Math.min(o, e);
|
|
98
|
+
const i = t.loopEnd > 0 && t.loopStart < t.loopEnd, s = i ? Math.min(t.loopStart, e) : 0, a = i ? Math.min(t.loopEnd, e) : e;
|
|
99
|
+
return o < a || a <= s ? o : s + (o - s) % (a - s);
|
|
100
|
+
}
|
|
101
|
+
/** The playback options with every default filled in. */
|
|
102
|
+
getOptions() {
|
|
103
|
+
return { ...this._options };
|
|
104
|
+
}
|
|
105
|
+
/** Applies a validated patch; a new buffer stops current playback. */
|
|
106
|
+
set(t) {
|
|
107
|
+
this._assertAlive(), _(t, this._patchKeys(), "sound");
|
|
108
|
+
const e = x(this._options, t);
|
|
109
|
+
this._apply(e);
|
|
110
|
+
}
|
|
111
|
+
/** Starts or resumes from the current position. A no-op while playing. */
|
|
112
|
+
play() {
|
|
113
|
+
if (this._assertAlive(), !this._options.buffer)
|
|
114
|
+
throw new r("state", "[Nova3D] Sound has no buffer to play.");
|
|
115
|
+
this._state !== "playing" && (this._beforePlay(), this._start(this._offset >= this.duration && !this._options.loop ? 0 : this._offset));
|
|
116
|
+
}
|
|
117
|
+
/** Keeps the position; `play()` continues from it. */
|
|
118
|
+
pause() {
|
|
119
|
+
this._assertAlive(), this._state === "playing" && (this._offset = this.currentTime, this._halt(), this._state = "paused");
|
|
120
|
+
}
|
|
121
|
+
/** Stops and rewinds to 0. */
|
|
122
|
+
stop() {
|
|
123
|
+
this._assertAlive(), this._halt(), this._offset = 0, this._state = "stopped";
|
|
124
|
+
}
|
|
125
|
+
/** Moves to `time` seconds; playing sounds continue from there without a gap in state. */
|
|
126
|
+
seek(t) {
|
|
127
|
+
if (this._assertAlive(), c(t, "Sound seek time", 0, !1, this._options.buffer ? this.duration : 0), this._state === "playing") {
|
|
128
|
+
this._halt(), this._start(t);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this._offset = t;
|
|
132
|
+
}
|
|
133
|
+
/** Stops playback and disconnects every node this sound owns. */
|
|
134
|
+
destroy() {
|
|
135
|
+
this._destroyed || (this._halt(), this._state = "stopped", this._destroyed = !0, this._endedListeners.clear(), this._disconnect(), this._host._release(this));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Entry node of the per-sound chain; sources connect here.
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
_input() {
|
|
142
|
+
return this._gain;
|
|
143
|
+
}
|
|
144
|
+
/** @internal */
|
|
145
|
+
_beforePlay() {
|
|
146
|
+
}
|
|
147
|
+
/** @internal */
|
|
148
|
+
_disconnect() {
|
|
149
|
+
this._gain.disconnect();
|
|
150
|
+
}
|
|
151
|
+
/** @internal */
|
|
152
|
+
/** Keys `set` accepts. @internal */
|
|
153
|
+
_patchKeys() {
|
|
154
|
+
return R;
|
|
155
|
+
}
|
|
156
|
+
_assertAlive() {
|
|
157
|
+
if (this._destroyed)
|
|
158
|
+
throw new r("destroyed", "[Nova3D] Sound is destroyed.");
|
|
159
|
+
}
|
|
160
|
+
_apply(t) {
|
|
161
|
+
const e = this._options;
|
|
162
|
+
t.buffer !== e.buffer && this._state !== "stopped" && (this._halt(), this._offset = 0, this._state = "stopped"), (t.volume !== e.volume || t.muted !== e.muted) && (this._gain.gain.value = t.muted ? 0 : t.volume);
|
|
163
|
+
const o = this._source;
|
|
164
|
+
o && (t.playbackRate !== e.playbackRate || t.loop !== e.loop || t.loopStart !== e.loopStart || t.loopEnd !== e.loopEnd) && (this._offset = this.currentTime, this._startedAt = this._context.currentTime, o.loop = t.loop, o.loopStart = t.loopStart, o.loopEnd = t.loopEnd, o.playbackRate.value = t.playbackRate), this._options = t;
|
|
165
|
+
}
|
|
166
|
+
_start(t) {
|
|
167
|
+
const e = this._options, o = this._context.createBufferSource();
|
|
168
|
+
o.buffer = e.buffer, o.loop = e.loop, o.loopStart = e.loopStart, o.loopEnd = e.loopEnd, o.playbackRate.value = e.playbackRate, o.onended = this._ended, o.connect(this._input()), o.start(0, t), this._source = o, this._startedAt = this._context.currentTime, this._offset = t, this._state = "playing";
|
|
169
|
+
}
|
|
170
|
+
_halt() {
|
|
171
|
+
const t = this._source;
|
|
172
|
+
if (t) {
|
|
173
|
+
this._source = null, t.onended = null;
|
|
174
|
+
try {
|
|
175
|
+
t.stop();
|
|
176
|
+
} catch {
|
|
177
|
+
}
|
|
178
|
+
t.disconnect();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
class k extends T {
|
|
183
|
+
_panner;
|
|
184
|
+
_node;
|
|
185
|
+
_spatial;
|
|
186
|
+
/** Last written world matrix; NaN forces the next sync. */
|
|
187
|
+
_written = new Float32Array(16).fill(Number.NaN);
|
|
188
|
+
/** Created by `Nova3DAudio`. @internal */
|
|
189
|
+
constructor(t, e) {
|
|
190
|
+
if (typeof e != "object" || e === null || !t._attachable(e.node))
|
|
191
|
+
throw new r("owner", "[Nova3D] Positional sound requires a live node of the audio app.");
|
|
192
|
+
const o = M({ distanceModel: "inverse", refDistance: 1, maxDistance: 1e4, rolloffFactor: 1, coneInnerAngle: y, coneOuterAngle: y, coneOuterGain: 0, panningModel: "HRTF" }, e);
|
|
193
|
+
super(t, e), this._node = e.node, this._spatial = o, this._panner = this._context.createPanner(), this._writeSpatial(o), this._panner.connect(this._gain);
|
|
194
|
+
}
|
|
195
|
+
get node() {
|
|
196
|
+
return this._node;
|
|
197
|
+
}
|
|
198
|
+
/** The panner, for advanced routing; Nova owns its position and orientation. */
|
|
199
|
+
get panner() {
|
|
200
|
+
return this._panner;
|
|
201
|
+
}
|
|
202
|
+
/** Moves the emitter to another live node of the same app (Babylon `attachToMesh`). */
|
|
203
|
+
attach(t) {
|
|
204
|
+
if (this._assertAlive(), !this._host._attachable(t))
|
|
205
|
+
throw new r("owner", "[Nova3D] Positional sound requires a live node of the audio app.");
|
|
206
|
+
this._node = t, this._written[15] = Number.NaN;
|
|
207
|
+
}
|
|
208
|
+
/** @internal */
|
|
209
|
+
_patchKeys() {
|
|
210
|
+
return N;
|
|
211
|
+
}
|
|
212
|
+
/** The playback and spatial options with every default filled in. */
|
|
213
|
+
getOptions() {
|
|
214
|
+
return { ...super.getOptions(), ...this._spatial };
|
|
215
|
+
}
|
|
216
|
+
/** Applies a validated playback and spatial patch; a new buffer stops current playback. */
|
|
217
|
+
set(t) {
|
|
218
|
+
this._assertAlive(), _(t, N, "positional sound");
|
|
219
|
+
const e = M(this._spatial, t);
|
|
220
|
+
super.set(t), this._writeSpatial(e), this._spatial = e;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Writes position and −Z orientation when `matrix` differs from the last written one.
|
|
224
|
+
* Returns false when nothing changed. Allocation-free.
|
|
225
|
+
* @internal
|
|
226
|
+
*/
|
|
227
|
+
_sync(t, e, o) {
|
|
228
|
+
const i = this._written, s = Number.isNaN(i[15]);
|
|
229
|
+
if (!s && !F(t, i))
|
|
230
|
+
return !1;
|
|
231
|
+
i.set(t);
|
|
232
|
+
const a = this._panner;
|
|
233
|
+
l(a.positionX, t[12], e, o, s), l(a.positionY, t[13], e, o, s), l(a.positionZ, t[14], e, o, s);
|
|
234
|
+
const u = Math.hypot(t[8], t[9], t[10]);
|
|
235
|
+
return u > 1e-12 && (l(a.orientationX, -t[8] / u, e, o, s), l(a.orientationY, -t[9] / u, e, o, s), l(a.orientationZ, -t[10] / u, e, o, s)), !0;
|
|
236
|
+
}
|
|
237
|
+
/** @internal */
|
|
238
|
+
_input() {
|
|
239
|
+
return this._panner;
|
|
240
|
+
}
|
|
241
|
+
/** @internal */
|
|
242
|
+
_beforePlay() {
|
|
243
|
+
this._written[15] = Number.NaN, this._host._syncSound(this);
|
|
244
|
+
}
|
|
245
|
+
/** @internal */
|
|
246
|
+
_disconnect() {
|
|
247
|
+
this._panner.disconnect(), super._disconnect();
|
|
248
|
+
}
|
|
249
|
+
_writeSpatial(t) {
|
|
250
|
+
const e = this._panner;
|
|
251
|
+
e.panningModel = t.panningModel, e.distanceModel = t.distanceModel, e.refDistance = t.refDistance, e.maxDistance = t.maxDistance, e.rolloffFactor = t.rolloffFactor, e.coneInnerAngle = t.coneInnerAngle * D, e.coneOuterAngle = t.coneOuterAngle * D, e.coneOuterGain = t.coneOuterGain;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function F(n, t) {
|
|
255
|
+
for (let e = 0; e < 16; e++)
|
|
256
|
+
if (n[e] !== t[e])
|
|
257
|
+
return !0;
|
|
258
|
+
return !1;
|
|
259
|
+
}
|
|
260
|
+
function l(n, t, e, o, i) {
|
|
261
|
+
i || o === 0 ? n.setValueAtTime(t, e) : n.setTargetAtTime(t, e, o);
|
|
262
|
+
}
|
|
263
|
+
const K = p({ context: !0, listener: !0, volume: !0, muted: !0, clock: !0, smoothing: !0 }), B = p({ signal: !0 });
|
|
264
|
+
function $() {
|
|
265
|
+
const n = globalThis, t = n.AudioContext ?? n.webkitAudioContext;
|
|
266
|
+
if (typeof t != "function")
|
|
267
|
+
throw new r("unsupported", "[Nova3D] Web Audio is not available; pass options.context.");
|
|
268
|
+
return new t();
|
|
269
|
+
}
|
|
270
|
+
function W(n) {
|
|
271
|
+
return typeof n == "object" && n !== null && typeof n.createGain == "function" && typeof n.createPanner == "function";
|
|
272
|
+
}
|
|
273
|
+
class j {
|
|
274
|
+
/** @internal */
|
|
275
|
+
constructor(t, e = {}) {
|
|
276
|
+
if (this._app = t, !t || t.destroyed)
|
|
277
|
+
throw new r("destroyed", "[Nova3D] Audio requires a live app.");
|
|
278
|
+
_(e, K, "audio");
|
|
279
|
+
const o = e.clock ?? "app";
|
|
280
|
+
if (o !== "app" && o !== "manual")
|
|
281
|
+
throw new r("invalid-option", "[Nova3D] Audio clock must be app or manual.");
|
|
282
|
+
const i = e.smoothing ?? 0;
|
|
283
|
+
if (typeof i != "number" || !Number.isFinite(i) || i < 0)
|
|
284
|
+
throw new r("invalid-option", "[Nova3D] Audio smoothing must be a finite number >= 0.");
|
|
285
|
+
if (e.context !== void 0 && !W(e.context))
|
|
286
|
+
throw new r("invalid-option", "[Nova3D] Audio context must be a BaseAudioContext.");
|
|
287
|
+
const s = e.volume ?? 1, a = e.muted ?? !1;
|
|
288
|
+
this._checkVolume(s), this._checkMuted(a);
|
|
289
|
+
const u = e.listener ?? null;
|
|
290
|
+
if (u !== null && !this._attachable(u))
|
|
291
|
+
throw new r("owner", "[Nova3D] Audio listener must be a live node of the audio app.");
|
|
292
|
+
this._clock = o, this._smoothing = i, this._ownsContext = e.context === void 0, this.context = e.context ?? $(), this._master = this.context.createGain(), this._volume = s, this._muted = a, this._master.gain.value = a ? 0 : s, this._master.connect(this.context.destination), this._listener = u, this._cleanup.push(t._own(() => this.destroy())), o === "app" && this._cleanup.push(t.onBeforeRender(this._frame));
|
|
293
|
+
}
|
|
294
|
+
context;
|
|
295
|
+
_master;
|
|
296
|
+
_ownsContext;
|
|
297
|
+
_clock;
|
|
298
|
+
_smoothing;
|
|
299
|
+
_sounds = [];
|
|
300
|
+
_positional = [];
|
|
301
|
+
_loads = /* @__PURE__ */ new Set();
|
|
302
|
+
_cleanup = [];
|
|
303
|
+
_matrix = new Float32Array(16);
|
|
304
|
+
/** Last written listener matrix; NaN forces the next write. */
|
|
305
|
+
_listenerWritten = new Float32Array(16).fill(Number.NaN);
|
|
306
|
+
_listener = null;
|
|
307
|
+
_volume = 1;
|
|
308
|
+
_muted = !1;
|
|
309
|
+
_destroyed = !1;
|
|
310
|
+
_frame = () => {
|
|
311
|
+
this._destroyed || this.update();
|
|
312
|
+
};
|
|
313
|
+
get destroyed() {
|
|
314
|
+
return this._destroyed;
|
|
315
|
+
}
|
|
316
|
+
get clock() {
|
|
317
|
+
return this._clock;
|
|
318
|
+
}
|
|
319
|
+
get listener() {
|
|
320
|
+
return this._listener;
|
|
321
|
+
}
|
|
322
|
+
get volume() {
|
|
323
|
+
return this._volume;
|
|
324
|
+
}
|
|
325
|
+
get muted() {
|
|
326
|
+
return this._muted;
|
|
327
|
+
}
|
|
328
|
+
/** Every live sound (order not guaranteed). */
|
|
329
|
+
get sounds() {
|
|
330
|
+
return [...this._sounds];
|
|
331
|
+
}
|
|
332
|
+
/** Follows `node` from the next update; `null` keeps the last listener pose. */
|
|
333
|
+
setListener(t) {
|
|
334
|
+
if (this._assertAlive(), t !== null && !this._attachable(t))
|
|
335
|
+
throw new r("owner", "[Nova3D] Audio listener must be a live node of the audio app.");
|
|
336
|
+
this._listener = t, this._listenerWritten[15] = Number.NaN;
|
|
337
|
+
}
|
|
338
|
+
setVolume(t) {
|
|
339
|
+
this._assertAlive(), this._checkVolume(t), this._volume = t, this._master.gain.value = this._muted ? 0 : t;
|
|
340
|
+
}
|
|
341
|
+
setMuted(t) {
|
|
342
|
+
this._assertAlive(), this._checkMuted(t), this._muted = t, this._master.gain.value = t ? 0 : this._volume;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Resumes a suspended realtime context; call it from a user gesture to unlock autoplay.
|
|
346
|
+
* Offline contexts are left to `startRendering()`.
|
|
347
|
+
*/
|
|
348
|
+
async resume() {
|
|
349
|
+
this._assertAlive();
|
|
350
|
+
const t = this.context;
|
|
351
|
+
t.state !== "suspended" || "startRendering" in t || typeof t.resume != "function" || await t.resume();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Creates a non-positional sound (three.js `Audio`).
|
|
355
|
+
* Owned by the audio system: destroyed with it (and with the app).
|
|
356
|
+
*/
|
|
357
|
+
createSound(t = {}) {
|
|
358
|
+
this._assertAlive(), _(t, R, "sound");
|
|
359
|
+
const e = new T(this, t);
|
|
360
|
+
return this._sounds.push(e), e;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* Creates a sound emitted from `options.node` (three.js `PositionalAudio`).
|
|
364
|
+
* Owned by the audio system: destroyed with it (and with the app).
|
|
365
|
+
*/
|
|
366
|
+
createPositionalSound(t) {
|
|
367
|
+
this._assertAlive(), _(t, L, "positional sound");
|
|
368
|
+
const e = new k(this, t);
|
|
369
|
+
return this._sounds.push(e), this._positional.push(e), e;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Fetches (string or URL) or copies (ArrayBuffer) encoded audio and decodes it with
|
|
373
|
+
* this context. Aborts with `options.signal` and when the audio system is destroyed.
|
|
374
|
+
*/
|
|
375
|
+
async loadBuffer(t, e = {}) {
|
|
376
|
+
if (this._assertAlive(), _(e, B, "audio load"), typeof t != "string" && !(t instanceof URL) && !(t instanceof ArrayBuffer))
|
|
377
|
+
throw new r("invalid-option", "[Nova3D] Audio source must be a URL or an ArrayBuffer.");
|
|
378
|
+
const o = new AbortController(), i = () => o.abort(e.signal?.reason);
|
|
379
|
+
e.signal?.aborted && i(), e.signal?.addEventListener("abort", i, { once: !0 }), this._loads.add(o);
|
|
380
|
+
try {
|
|
381
|
+
const s = o.signal;
|
|
382
|
+
s.throwIfAborted();
|
|
383
|
+
let a;
|
|
384
|
+
if (t instanceof ArrayBuffer)
|
|
385
|
+
a = t.slice(0);
|
|
386
|
+
else {
|
|
387
|
+
const h = await I(t, { signal: s });
|
|
388
|
+
if (!h.ok)
|
|
389
|
+
throw new r("network", `[Nova3D] Audio request failed with HTTP ${h.status}.`);
|
|
390
|
+
a = await h.arrayBuffer(), s.throwIfAborted();
|
|
391
|
+
}
|
|
392
|
+
const u = await this.context.decodeAudioData(a);
|
|
393
|
+
return s.throwIfAborted(), u;
|
|
394
|
+
} finally {
|
|
395
|
+
e.signal?.removeEventListener("abort", i), this._loads.delete(o);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Writes the listener and playing positional sounds whose world matrix changed since
|
|
400
|
+
* the last write. Runs automatically before each rendered frame with the `'app'` clock;
|
|
401
|
+
* takes no time step, since Web Audio schedules at its own context time.
|
|
402
|
+
* Allocation-free; O(playing positional sounds).
|
|
403
|
+
*/
|
|
404
|
+
update() {
|
|
405
|
+
this._assertAlive();
|
|
406
|
+
const t = this.context.currentTime;
|
|
407
|
+
this._syncListener(t);
|
|
408
|
+
const e = this._positional;
|
|
409
|
+
for (let o = e.length - 1; o >= 0; o--) {
|
|
410
|
+
const i = e[o];
|
|
411
|
+
if (i.state === "playing") {
|
|
412
|
+
if (i.node.destroyed) {
|
|
413
|
+
i.destroy();
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
i._sync(i.node.getWorldMatrix(this._matrix), t, this._smoothing);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
/** Stops every sound, aborts loads, disconnects owned nodes and closes an owned context. */
|
|
421
|
+
destroy() {
|
|
422
|
+
if (!this._destroyed) {
|
|
423
|
+
for (const t of this._loads)
|
|
424
|
+
t.abort(new DOMException("Audio system destroyed.", "AbortError"));
|
|
425
|
+
for (this._loads.clear(); this._sounds.length > 0; )
|
|
426
|
+
this._sounds[this._sounds.length - 1].destroy();
|
|
427
|
+
this._destroyed = !0;
|
|
428
|
+
for (const t of this._cleanup.splice(0))
|
|
429
|
+
t();
|
|
430
|
+
this._master.disconnect(), this._listener = null, this._ownsContext && typeof this.context.close == "function" && this.context.state !== "closed" && this.context.close().catch(() => {
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/** @internal */
|
|
435
|
+
_output() {
|
|
436
|
+
return this._master;
|
|
437
|
+
}
|
|
438
|
+
/** @internal */
|
|
439
|
+
_release(t) {
|
|
440
|
+
E(this._sounds, t), t instanceof k && E(this._positional, t);
|
|
441
|
+
}
|
|
442
|
+
/** @internal */
|
|
443
|
+
_attachable(t) {
|
|
444
|
+
return typeof t == "object" && t !== null && !t.destroyed && this._app._ownsScene(t.scene);
|
|
445
|
+
}
|
|
446
|
+
/** Writes a sound that is about to start, so it never plays one frame at a stale pose. @internal */
|
|
447
|
+
_syncSound(t) {
|
|
448
|
+
if (t.node.destroyed)
|
|
449
|
+
throw new r("destroyed", "[Nova3D] Positional sound node is destroyed.");
|
|
450
|
+
const e = this.context.currentTime;
|
|
451
|
+
this._syncListener(e), t._sync(t.node.getWorldMatrix(this._matrix), e, this._smoothing);
|
|
452
|
+
}
|
|
453
|
+
_syncListener(t) {
|
|
454
|
+
const e = this._listener;
|
|
455
|
+
if (!e)
|
|
456
|
+
return;
|
|
457
|
+
if (e.destroyed) {
|
|
458
|
+
this._listener = null;
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
const o = e.getWorldMatrix(this._matrix), i = this._listenerWritten, s = Number.isNaN(i[15]);
|
|
462
|
+
if (!s && !F(o, i))
|
|
463
|
+
return;
|
|
464
|
+
i.set(o);
|
|
465
|
+
const a = Math.hypot(o[8], o[9], o[10]), u = Math.hypot(o[4], o[5], o[6]);
|
|
466
|
+
if (a <= 1e-12 || u <= 1e-12)
|
|
467
|
+
return;
|
|
468
|
+
const h = -o[8] / a, b = -o[9] / a, w = -o[10] / a, m = o[4] / u, g = o[5] / u, A = o[6] / u, d = this.context.listener;
|
|
469
|
+
if (d.positionX) {
|
|
470
|
+
const f = this._smoothing;
|
|
471
|
+
l(d.positionX, o[12], t, f, s), l(d.positionY, o[13], t, f, s), l(d.positionZ, o[14], t, f, s), l(d.forwardX, h, t, f, s), l(d.forwardY, b, t, f, s), l(d.forwardZ, w, t, f, s), l(d.upX, m, t, f, s), l(d.upY, g, t, f, s), l(d.upZ, A, t, f, s);
|
|
472
|
+
} else
|
|
473
|
+
d.setPosition(o[12], o[13], o[14]), d.setOrientation(h, b, w, m, g, A);
|
|
474
|
+
}
|
|
475
|
+
_checkVolume(t) {
|
|
476
|
+
if (typeof t != "number" || !Number.isFinite(t) || t < 0)
|
|
477
|
+
throw new r("invalid-option", "[Nova3D] Audio volume must be a finite number >= 0.");
|
|
478
|
+
}
|
|
479
|
+
_checkMuted(t) {
|
|
480
|
+
if (typeof t != "boolean")
|
|
481
|
+
throw new r("invalid-option", "[Nova3D] Audio muted must be boolean.");
|
|
482
|
+
}
|
|
483
|
+
_assertAlive() {
|
|
484
|
+
if (this._destroyed)
|
|
485
|
+
throw new r("destroyed", "[Nova3D] Audio system is destroyed.");
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function E(n, t) {
|
|
489
|
+
const e = n.lastIndexOf(t);
|
|
490
|
+
e >= 0 && (n[e] = n[n.length - 1], n.pop());
|
|
491
|
+
}
|
|
492
|
+
function V(n, t = {}) {
|
|
493
|
+
return new j(n, t);
|
|
494
|
+
}
|
|
495
|
+
export {
|
|
496
|
+
j as Nova3DAudio,
|
|
497
|
+
k as Nova3DPositionalSound,
|
|
498
|
+
T as Nova3DSound,
|
|
499
|
+
V as createAudio
|
|
500
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { N as u } from "../Capsule-BFVpZfvc.js";
|
|
2
|
+
import { N as h } from "../Errors-B2ekO9bZ.js";
|
|
3
|
+
const b = /* @__PURE__ */ new Set(["position", "radius", "height", "speed", "gravity", "jumpSpeed", "stepHeight", "maxSlopeAngle", "skin", "maxSubSteps"]);
|
|
4
|
+
class w {
|
|
5
|
+
/** @internal */
|
|
6
|
+
constructor(t, e = {}) {
|
|
7
|
+
this._octree = t;
|
|
8
|
+
for (const l of Object.keys(e))
|
|
9
|
+
if (!b.has(l))
|
|
10
|
+
throw new h("invalid-option", `[Nova3D] Неизвестная настройка персонажа: ${l}.`);
|
|
11
|
+
this._radius = _(e.radius ?? 0.35, 0, !1), this._height = _(e.height ?? 1.8, 2 * this._radius, !0), this._speed = _(e.speed ?? 6), this._gravity = _(e.gravity ?? 20), this._jumpSpeed = _(e.jumpSpeed ?? 8), this._stepHeight = _(e.stepHeight ?? 0.3), this._skin = _(e.skin ?? 0.01, 0, !1);
|
|
12
|
+
const a = _(e.maxSlopeAngle ?? Math.PI / 4);
|
|
13
|
+
if (a >= Math.PI / 2 || this._skin >= this._radius)
|
|
14
|
+
throw new h("invalid-option", "[Nova3D] Недопустимые slope или skin.");
|
|
15
|
+
if (this._slope = Math.cos(a), this._maxSubSteps = _(e.maxSubSteps ?? 64, 1), !Number.isInteger(this._maxSubSteps) || this._maxSubSteps > 1024)
|
|
16
|
+
throw new h("invalid-option", "[Nova3D] maxSubSteps: целое от 1 до 1024.");
|
|
17
|
+
this.teleport(e.position ?? [0, 0, 0]);
|
|
18
|
+
}
|
|
19
|
+
_capsule = new u();
|
|
20
|
+
_before = new u();
|
|
21
|
+
_probe = new u();
|
|
22
|
+
_offset = new Float64Array(3);
|
|
23
|
+
_velocity = new Float64Array(3);
|
|
24
|
+
_hit = { normal: new Float64Array(3), depth: 0 };
|
|
25
|
+
_stepHit = { normal: new Float64Array(3), depth: 0 };
|
|
26
|
+
_radius;
|
|
27
|
+
_height;
|
|
28
|
+
_speed;
|
|
29
|
+
_gravity;
|
|
30
|
+
_jumpSpeed;
|
|
31
|
+
_stepHeight;
|
|
32
|
+
_slope;
|
|
33
|
+
_skin;
|
|
34
|
+
_maxSubSteps;
|
|
35
|
+
_grounded = !1;
|
|
36
|
+
_jumpHeld = !1;
|
|
37
|
+
_destroyed = !1;
|
|
38
|
+
get grounded() {
|
|
39
|
+
return this._grounded;
|
|
40
|
+
}
|
|
41
|
+
get destroyed() {
|
|
42
|
+
return this._destroyed;
|
|
43
|
+
}
|
|
44
|
+
get velocity() {
|
|
45
|
+
return this._velocity;
|
|
46
|
+
}
|
|
47
|
+
/** Положение ног в массив вызывающего. */
|
|
48
|
+
getPosition(t) {
|
|
49
|
+
if (this._alive(), t.length < 3)
|
|
50
|
+
throw new h("invalid-option", "[Nova3D] Для position нужны три элемента.");
|
|
51
|
+
return t[0] = this._capsule.start[0], t[1] = this._capsule.start[1] - this._radius, t[2] = this._capsule.start[2], t;
|
|
52
|
+
}
|
|
53
|
+
/** Перенос без сохранения скорости и состояния опоры. */
|
|
54
|
+
teleport(t) {
|
|
55
|
+
this._alive();
|
|
56
|
+
for (let e = 0; e < 3; e++)
|
|
57
|
+
if (!Number.isFinite(t[e]))
|
|
58
|
+
throw new h("invalid-option", "[Nova3D] Position должна быть конечной.");
|
|
59
|
+
this._capsule.start.set(t), this._capsule.end.set(t), this._capsule.start[1] += this._radius, this._capsule.end[1] += this._height - this._radius, this._capsule.radius = this._radius, this._velocity.fill(0), this._grounded = !1, this._jumpHeld = !1;
|
|
60
|
+
}
|
|
61
|
+
/** Один фиксированный тик с ограниченными substeps, без временных объектов. */
|
|
62
|
+
update(t, e) {
|
|
63
|
+
if (this._alive(), !Number.isFinite(t) || t <= 0 || t > 0.1 || !Number.isFinite(e.moveX) || !Number.isFinite(e.moveZ) || e.jump !== void 0 && typeof e.jump != "boolean")
|
|
64
|
+
throw new h("invalid-option", "[Nova3D] Недопустимый тик или ввод персонажа.");
|
|
65
|
+
for (const i in e)
|
|
66
|
+
if (i !== "moveX" && i !== "moveZ" && i !== "jump")
|
|
67
|
+
throw new h("invalid-option", `[Nova3D] Неизвестный ввод: ${i}.`);
|
|
68
|
+
const a = Math.max(1, Math.hypot(e.moveX, e.moveZ)), l = e.moveX / a * this._speed, f = e.moveZ / a * this._speed, v = !!e.jump && !this._jumpHeld && this._grounded, y = (v ? this._jumpSpeed : this._velocity[1]) - this._gravity * t, c = Math.max(1, Math.ceil(Math.hypot(l, y, f) * t / (this._radius * 0.5)));
|
|
69
|
+
if (c > this._maxSubSteps)
|
|
70
|
+
throw new h("invalid-option", "[Nova3D] Превышено безопасное число substeps.");
|
|
71
|
+
this._velocity[0] = l, this._velocity[1] = y, this._velocity[2] = f, this._jumpHeld = !!e.jump;
|
|
72
|
+
let m = this._grounded && !v;
|
|
73
|
+
this._grounded = !1;
|
|
74
|
+
for (let i = 0; i < c; i++) {
|
|
75
|
+
this._grounded = !1, this._before.copy(this._capsule), this._offset[0] = this._velocity[0] * t / c, this._offset[1] = this._velocity[1] * t / c, this._offset[2] = this._velocity[2] * t / c, this._capsule.translate(this._offset);
|
|
76
|
+
for (let g = 0; g < 8; g++) {
|
|
77
|
+
const o = this._octree.capsuleIntersect(this._capsule, this._hit);
|
|
78
|
+
if (!o || o.depth < 1e-9)
|
|
79
|
+
break;
|
|
80
|
+
const s = o.normal, r = s[1];
|
|
81
|
+
if (m && r < this._slope && r > -0.1 && this._tryStep()) {
|
|
82
|
+
this._grounded = !0, this._velocity[1] = 0;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if (r > 0 && r < this._slope) {
|
|
86
|
+
const n = s[0] * s[0] + s[2] * s[2];
|
|
87
|
+
this._capsule.start[0] += s[0] * o.depth / n, this._capsule.end[0] += s[0] * o.depth / n, this._capsule.start[2] += s[2] * o.depth / n, this._capsule.end[2] += s[2] * o.depth / n;
|
|
88
|
+
} else r >= this._slope ? this._shift(this._capsule, 0, o.depth / r, 0) : this._capsule.translate(s, o.depth);
|
|
89
|
+
if (r >= this._slope && this._velocity[1] <= 0 ? (this._grounded = !0, this._velocity[1] = 0) : r < -0.1 && this._velocity[1] > 0 && (this._velocity[1] = 0), r < this._slope) {
|
|
90
|
+
const n = this._velocity[0] * s[0] + this._velocity[2] * s[2], d = s[0] * s[0] + s[2] * s[2];
|
|
91
|
+
n < 0 && d > 1e-12 && (this._velocity[0] -= s[0] * n / d, this._velocity[2] -= s[2] * n / d);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
m ||= this._grounded;
|
|
95
|
+
}
|
|
96
|
+
if (this._velocity[1] <= 0) {
|
|
97
|
+
this._probe.copy(this._capsule), this._shift(this._probe, 0, -2 * this._skin, 0);
|
|
98
|
+
const i = this._octree.capsuleIntersect(this._probe, this._hit);
|
|
99
|
+
i && i.normal[1] >= this._slope && (this._shift(this._probe, 0, i.depth / i.normal[1], 0), this._capsule.copy(this._probe), this._velocity[1] = 0, this._grounded = !0);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** Не освобождает заимствованное дерево уровня. */
|
|
103
|
+
destroy() {
|
|
104
|
+
this._destroyed = !0;
|
|
105
|
+
}
|
|
106
|
+
_tryStep() {
|
|
107
|
+
if (this._stepHeight === 0 || (this._probe.copy(this._before), this._shift(this._probe, 0, this._stepHeight + this._skin, 0), this._octree.capsuleIntersect(this._probe, this._stepHit)) || (this._shift(this._probe, this._offset[0], 0, this._offset[2]), this._octree.capsuleIntersect(this._probe, this._stepHit)))
|
|
108
|
+
return !1;
|
|
109
|
+
this._shift(this._probe, 0, -this._stepHeight - 3 * this._skin, 0);
|
|
110
|
+
const t = this._octree.capsuleIntersect(this._probe, this._stepHit);
|
|
111
|
+
if (!t || t.normal[1] < this._slope)
|
|
112
|
+
return !1;
|
|
113
|
+
this._probe.translate(t.normal, t.depth);
|
|
114
|
+
const e = this._probe.start[1] - this._before.start[1];
|
|
115
|
+
return e < -this._skin || e > this._stepHeight + this._skin ? !1 : (this._capsule.copy(this._probe), !0);
|
|
116
|
+
}
|
|
117
|
+
_shift(t, e, a, l) {
|
|
118
|
+
t.start[0] += e, t.start[1] += a, t.start[2] += l, t.end[0] += e, t.end[1] += a, t.end[2] += l;
|
|
119
|
+
}
|
|
120
|
+
_alive() {
|
|
121
|
+
if (this._destroyed)
|
|
122
|
+
throw new h("destroyed", "[Nova3D] Контроллер уничтожен.");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function _(p, t = 0, e = !0) {
|
|
126
|
+
if (!Number.isFinite(p) || (e ? p < t : p <= t))
|
|
127
|
+
throw new h("invalid-option", "[Nova3D] Недопустимая настройка персонажа.");
|
|
128
|
+
return p;
|
|
129
|
+
}
|
|
130
|
+
function k(p, t = {}) {
|
|
131
|
+
return new w(p, t);
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
w as Nova3DCharacterController,
|
|
135
|
+
k as createCharacterController
|
|
136
|
+
};
|