@zephyr3d/scene 0.9.2 → 0.9.4
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/dist/animation/animationset.js +135 -135
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ik_chain_builder.js +68 -0
- package/dist/animation/ik/ik_chain_builder.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +2 -7
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +146 -146
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/math.js +16 -0
- package/dist/animation/joint_dynamics/math.js.map +1 -0
- package/dist/animation/spring/spring_system.js +75 -75
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring2/constraints.js.map +1 -1
- package/dist/animation/spring2/controller.js +64 -64
- package/dist/animation/spring2/controller.js.map +1 -1
- package/dist/animation/spring2/math.js.map +1 -1
- package/dist/animation/spring2/spring_system.js +8 -8
- package/dist/animation/spring2/spring_system.js.map +1 -1
- package/dist/app/engine.js +119 -71
- package/dist/app/engine.js.map +1 -1
- package/dist/asset/assetmanager.js +296 -244
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/camera/camera.js +184 -184
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +685 -38
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +290 -290
- package/dist/material/material.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +123 -108
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +6 -3
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +93 -93
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -3
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js +22 -22
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +29 -17
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +1 -0
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +8 -9
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +6 -0
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shapes/torus.js +90 -59
- package/dist/shapes/torus.js.map +1 -1
- package/dist/src/animation/animation.js +127 -0
- package/dist/src/animation/animation.js.map +1 -0
- package/dist/src/animation/animationset.js +255 -0
- package/dist/src/animation/animationset.js.map +1 -0
- package/dist/src/animation/animationtrack.js +34 -0
- package/dist/src/animation/animationtrack.js.map +1 -0
- package/dist/src/animation/eulerrotationtrack.js +52 -0
- package/dist/src/animation/eulerrotationtrack.js.map +1 -0
- package/dist/src/animation/morphtarget.js +93 -0
- package/dist/src/animation/morphtarget.js.map +1 -0
- package/dist/src/animation/morphtrack.js +70 -0
- package/dist/src/animation/morphtrack.js.map +1 -0
- package/dist/src/animation/proptrack.js +161 -0
- package/dist/src/animation/proptrack.js.map +1 -0
- package/dist/src/animation/rotationtrack.js +51 -0
- package/dist/src/animation/rotationtrack.js.map +1 -0
- package/dist/src/animation/scaletrack.js +50 -0
- package/dist/src/animation/scaletrack.js.map +1 -0
- package/dist/src/animation/skeleton.js +204 -0
- package/dist/src/animation/skeleton.js.map +1 -0
- package/dist/src/animation/translationtrack.js +50 -0
- package/dist/src/animation/translationtrack.js.map +1 -0
- package/dist/src/app/app.js +129 -0
- package/dist/src/app/app.js.map +1 -0
- package/dist/src/app/inputmgr.js +267 -0
- package/dist/src/app/inputmgr.js.map +1 -0
- package/dist/src/asset/assetmanager.js +404 -0
- package/dist/src/asset/assetmanager.js.map +1 -0
- package/dist/src/asset/builtin.js +337 -0
- package/dist/src/asset/builtin.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds.js +470 -0
- package/dist/src/asset/loaders/dds/dds.js.map +1 -0
- package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
- package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
- package/dist/src/asset/loaders/gltf/helpers.js +327 -0
- package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
- package/dist/src/asset/loaders/hdr/hdr.js +180 -0
- package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
- package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
- package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
- package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
- package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
- package/dist/src/asset/loaders/loader.js +45 -0
- package/dist/src/asset/loaders/loader.js.map +1 -0
- package/dist/src/asset/model.js +414 -0
- package/dist/src/asset/model.js.map +1 -0
- package/dist/src/blitter/bilateralblur.js +221 -0
- package/dist/src/blitter/bilateralblur.js.map +1 -0
- package/dist/src/blitter/blitter.js +390 -0
- package/dist/src/blitter/blitter.js.map +1 -0
- package/dist/src/blitter/box.js +118 -0
- package/dist/src/blitter/box.js.map +1 -0
- package/dist/src/blitter/copy.js +22 -0
- package/dist/src/blitter/copy.js.map +1 -0
- package/dist/src/blitter/gaussianblur.js +228 -0
- package/dist/src/blitter/gaussianblur.js.map +1 -0
- package/dist/src/camera/base.js +92 -0
- package/dist/src/camera/base.js.map +1 -0
- package/dist/src/camera/camera.js +1005 -0
- package/dist/src/camera/camera.js.map +1 -0
- package/dist/src/camera/fps.js +238 -0
- package/dist/src/camera/fps.js.map +1 -0
- package/dist/src/camera/orbit.js +245 -0
- package/dist/src/camera/orbit.js.map +1 -0
- package/dist/src/camera/orthocamera.js +167 -0
- package/dist/src/camera/orthocamera.js.map +1 -0
- package/dist/src/camera/perspectivecamera.js +141 -0
- package/dist/src/camera/perspectivecamera.js.map +1 -0
- package/dist/src/index.js +120 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/material/blinn.js +81 -0
- package/dist/src/material/blinn.js.map +1 -0
- package/dist/src/material/grassmaterial.js +113 -0
- package/dist/src/material/grassmaterial.js.map +1 -0
- package/dist/src/material/lambert.js +92 -0
- package/dist/src/material/lambert.js.map +1 -0
- package/dist/src/material/material.js +301 -0
- package/dist/src/material/material.js.map +1 -0
- package/dist/src/material/meshmaterial.js +704 -0
- package/dist/src/material/meshmaterial.js.map +1 -0
- package/dist/src/material/mixins/albedocolor.js +76 -0
- package/dist/src/material/mixins/albedocolor.js.map +1 -0
- package/dist/src/material/mixins/foliage.js +47 -0
- package/dist/src/material/mixins/foliage.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
- package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
- package/dist/src/material/mixins/lit.js +476 -0
- package/dist/src/material/mixins/lit.js.map +1 -0
- package/dist/src/material/mixins/pbr/common.js +918 -0
- package/dist/src/material/mixins/pbr/common.js.map +1 -0
- package/dist/src/material/mixins/texture.js +172 -0
- package/dist/src/material/mixins/texture.js.map +1 -0
- package/dist/src/material/mixins/vertexcolor.js +56 -0
- package/dist/src/material/mixins/vertexcolor.js.map +1 -0
- package/dist/src/material/particle.js +178 -0
- package/dist/src/material/particle.js.map +1 -0
- package/dist/src/material/pbrmr.js +97 -0
- package/dist/src/material/pbrmr.js.map +1 -0
- package/dist/src/material/pbrsg.js +97 -0
- package/dist/src/material/pbrsg.js.map +1 -0
- package/dist/src/material/shader/helper.js +1209 -0
- package/dist/src/material/shader/helper.js.map +1 -0
- package/dist/src/material/terrain-cm.js +606 -0
- package/dist/src/material/terrain-cm.js.map +1 -0
- package/dist/src/material/terrainmaterial.js +375 -0
- package/dist/src/material/terrainmaterial.js.map +1 -0
- package/dist/src/material/unlit.js +41 -0
- package/dist/src/material/unlit.js.map +1 -0
- package/dist/src/material/water.js +417 -0
- package/dist/src/material/water.js.map +1 -0
- package/dist/src/posteffect/bloom.js +361 -0
- package/dist/src/posteffect/bloom.js.map +1 -0
- package/dist/src/posteffect/compositor.js +226 -0
- package/dist/src/posteffect/compositor.js.map +1 -0
- package/dist/src/posteffect/fxaa.js +273 -0
- package/dist/src/posteffect/fxaa.js.map +1 -0
- package/dist/src/posteffect/grayscale.js +69 -0
- package/dist/src/posteffect/grayscale.js.map +1 -0
- package/dist/src/posteffect/motionblur.js +96 -0
- package/dist/src/posteffect/motionblur.js.map +1 -0
- package/dist/src/posteffect/posteffect.js +126 -0
- package/dist/src/posteffect/posteffect.js.map +1 -0
- package/dist/src/posteffect/sao.js +324 -0
- package/dist/src/posteffect/sao.js.map +1 -0
- package/dist/src/posteffect/ssr.js +489 -0
- package/dist/src/posteffect/ssr.js.map +1 -0
- package/dist/src/posteffect/taa.js +172 -0
- package/dist/src/posteffect/taa.js.map +1 -0
- package/dist/src/posteffect/tonemap.js +94 -0
- package/dist/src/posteffect/tonemap.js.map +1 -0
- package/dist/src/render/abuffer_oit.js +361 -0
- package/dist/src/render/abuffer_oit.js.map +1 -0
- package/dist/src/render/clipmap.js +851 -0
- package/dist/src/render/clipmap.js.map +1 -0
- package/dist/src/render/cluster_light.js +333 -0
- package/dist/src/render/cluster_light.js.map +1 -0
- package/dist/src/render/cull_visitor.js +187 -0
- package/dist/src/render/cull_visitor.js.map +1 -0
- package/dist/src/render/depthpass.js +68 -0
- package/dist/src/render/depthpass.js.map +1 -0
- package/dist/src/render/drawable_mixin.js +227 -0
- package/dist/src/render/drawable_mixin.js.map +1 -0
- package/dist/src/render/envlight.js +463 -0
- package/dist/src/render/envlight.js.map +1 -0
- package/dist/src/render/fbm_wavegenerator.js +251 -0
- package/dist/src/render/fbm_wavegenerator.js.map +1 -0
- package/dist/src/render/fft_wavegenerator.js +1006 -0
- package/dist/src/render/fft_wavegenerator.js.map +1 -0
- package/dist/src/render/fullscreenquad.js +38 -0
- package/dist/src/render/fullscreenquad.js.map +1 -0
- package/dist/src/render/gerstner_wavegenerator.js +314 -0
- package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
- package/dist/src/render/globalbindgroup_allocator.js +60 -0
- package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
- package/dist/src/render/hzb.js +273 -0
- package/dist/src/render/hzb.js.map +1 -0
- package/dist/src/render/lightpass.js +172 -0
- package/dist/src/render/lightpass.js.map +1 -0
- package/dist/src/render/objectcolorpass.js +51 -0
- package/dist/src/render/objectcolorpass.js.map +1 -0
- package/dist/src/render/primitive.js +364 -0
- package/dist/src/render/primitive.js.map +1 -0
- package/dist/src/render/render_queue.js +467 -0
- package/dist/src/render/render_queue.js.map +1 -0
- package/dist/src/render/renderbundle_wrapper.js +152 -0
- package/dist/src/render/renderbundle_wrapper.js.map +1 -0
- package/dist/src/render/renderer.js +455 -0
- package/dist/src/render/renderer.js.map +1 -0
- package/dist/src/render/renderpass.js +200 -0
- package/dist/src/render/renderpass.js.map +1 -0
- package/dist/src/render/shadowmap_pass.js +56 -0
- package/dist/src/render/shadowmap_pass.js.map +1 -0
- package/dist/src/render/sky.js +1103 -0
- package/dist/src/render/sky.js.map +1 -0
- package/dist/src/render/weightedblended_oit.js +168 -0
- package/dist/src/render/weightedblended_oit.js.map +1 -0
- package/dist/src/scene/batchgroup.js +162 -0
- package/dist/src/scene/batchgroup.js.map +1 -0
- package/dist/src/scene/environment.js +209 -0
- package/dist/src/scene/environment.js.map +1 -0
- package/dist/src/scene/graph_node.js +72 -0
- package/dist/src/scene/graph_node.js.map +1 -0
- package/dist/src/scene/light.js +416 -0
- package/dist/src/scene/light.js.map +1 -0
- package/dist/src/scene/mesh.js +341 -0
- package/dist/src/scene/mesh.js.map +1 -0
- package/dist/src/scene/octree.js +649 -0
- package/dist/src/scene/octree.js.map +1 -0
- package/dist/src/scene/particlesys.js +738 -0
- package/dist/src/scene/particlesys.js.map +1 -0
- package/dist/src/scene/raycast_visitor.js +103 -0
- package/dist/src/scene/raycast_visitor.js.map +1 -0
- package/dist/src/scene/scene.js +284 -0
- package/dist/src/scene/scene.js.map +1 -0
- package/dist/src/scene/scene_node.js +732 -0
- package/dist/src/scene/scene_node.js.map +1 -0
- package/dist/src/scene/terrain/grass.js +278 -0
- package/dist/src/scene/terrain/grass.js.map +1 -0
- package/dist/src/scene/terrain/heightfield.js +475 -0
- package/dist/src/scene/terrain/heightfield.js.map +1 -0
- package/dist/src/scene/terrain/patch.js +530 -0
- package/dist/src/scene/terrain/patch.js.map +1 -0
- package/dist/src/scene/terrain/quadtree.js +461 -0
- package/dist/src/scene/terrain/quadtree.js.map +1 -0
- package/dist/src/scene/terrain/terrain.js +246 -0
- package/dist/src/scene/terrain/terrain.js.map +1 -0
- package/dist/src/scene/terrain-cm/grass.js +594 -0
- package/dist/src/scene/terrain-cm/grass.js.map +1 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/src/scene/water.js +374 -0
- package/dist/src/scene/water.js.map +1 -0
- package/dist/src/shaders/atmosphere.js +957 -0
- package/dist/src/shaders/atmosphere.js.map +1 -0
- package/dist/src/shaders/fog.js +112 -0
- package/dist/src/shaders/fog.js.map +1 -0
- package/dist/src/shaders/misc.js +266 -0
- package/dist/src/shaders/misc.js.map +1 -0
- package/dist/src/shaders/noise.js +222 -0
- package/dist/src/shaders/noise.js.map +1 -0
- package/dist/src/shaders/pbr.js +51 -0
- package/dist/src/shaders/pbr.js.map +1 -0
- package/dist/src/shaders/shadow.js +636 -0
- package/dist/src/shaders/shadow.js.map +1 -0
- package/dist/src/shaders/ssr.js +490 -0
- package/dist/src/shaders/ssr.js.map +1 -0
- package/dist/src/shaders/temporal.js +215 -0
- package/dist/src/shaders/temporal.js.map +1 -0
- package/dist/src/shaders/water.js +756 -0
- package/dist/src/shaders/water.js.map +1 -0
- package/dist/src/shadow/esm.js +237 -0
- package/dist/src/shadow/esm.js.map +1 -0
- package/dist/src/shadow/pcf_opt.js +181 -0
- package/dist/src/shadow/pcf_opt.js.map +1 -0
- package/dist/src/shadow/pcf_pd.js +189 -0
- package/dist/src/shadow/pcf_pd.js.map +1 -0
- package/dist/src/shadow/shader.js +37 -0
- package/dist/src/shadow/shader.js.map +1 -0
- package/dist/src/shadow/shadow_impl.js +15 -0
- package/dist/src/shadow/shadow_impl.js.map +1 -0
- package/dist/src/shadow/shadowmapper.js +790 -0
- package/dist/src/shadow/shadowmapper.js.map +1 -0
- package/dist/src/shadow/ssm.js +159 -0
- package/dist/src/shadow/ssm.js.map +1 -0
- package/dist/src/shadow/vsm.js +297 -0
- package/dist/src/shadow/vsm.js.map +1 -0
- package/dist/src/shapes/box.js +386 -0
- package/dist/src/shapes/box.js.map +1 -0
- package/dist/src/shapes/cylinder.js +125 -0
- package/dist/src/shapes/cylinder.js.map +1 -0
- package/dist/src/shapes/plane.js +88 -0
- package/dist/src/shapes/plane.js.map +1 -0
- package/dist/src/shapes/shape.js +87 -0
- package/dist/src/shapes/shape.js.map +1 -0
- package/dist/src/shapes/sphere.js +114 -0
- package/dist/src/shapes/sphere.js.map +1 -0
- package/dist/src/shapes/tetrahedron.js +188 -0
- package/dist/src/shapes/tetrahedron.js.map +1 -0
- package/dist/src/shapes/torus.js +111 -0
- package/dist/src/shapes/torus.js.map +1 -0
- package/dist/src/utility/aabbtree.js +400 -0
- package/dist/src/utility/aabbtree.js.map +1 -0
- package/dist/src/utility/bounding_volume.js +29 -0
- package/dist/src/utility/bounding_volume.js.map +1 -0
- package/dist/src/utility/debug.js +28 -0
- package/dist/src/utility/debug.js.map +1 -0
- package/dist/src/utility/draco/decoder.js +116 -0
- package/dist/src/utility/draco/decoder.js.map +1 -0
- package/dist/src/utility/misc.js +105 -0
- package/dist/src/utility/misc.js.map +1 -0
- package/dist/src/utility/panorama.js +163 -0
- package/dist/src/utility/panorama.js.map +1 -0
- package/dist/src/utility/pmrem.js +354 -0
- package/dist/src/utility/pmrem.js.map +1 -0
- package/dist/src/utility/rendermipmap.js +115 -0
- package/dist/src/utility/rendermipmap.js.map +1 -0
- package/dist/src/utility/serialization/json.js +402 -0
- package/dist/src/utility/serialization/json.js.map +1 -0
- package/dist/src/utility/serialization/manager.js +623 -0
- package/dist/src/utility/serialization/manager.js.map +1 -0
- package/dist/src/utility/serialization/scene/animation.js +248 -0
- package/dist/src/utility/serialization/scene/animation.js.map +1 -0
- package/dist/src/utility/serialization/scene/batch.js +59 -0
- package/dist/src/utility/serialization/scene/batch.js.map +1 -0
- package/dist/src/utility/serialization/scene/camera.js +790 -0
- package/dist/src/utility/serialization/scene/camera.js.map +1 -0
- package/dist/src/utility/serialization/scene/common.js +222 -0
- package/dist/src/utility/serialization/scene/common.js.map +1 -0
- package/dist/src/utility/serialization/scene/light.js +575 -0
- package/dist/src/utility/serialization/scene/light.js.map +1 -0
- package/dist/src/utility/serialization/scene/material.js +1111 -0
- package/dist/src/utility/serialization/scene/material.js.map +1 -0
- package/dist/src/utility/serialization/scene/mesh.js +148 -0
- package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/src/utility/serialization/scene/misc.js +39 -0
- package/dist/src/utility/serialization/scene/misc.js.map +1 -0
- package/dist/src/utility/serialization/scene/node.js +451 -0
- package/dist/src/utility/serialization/scene/node.js.map +1 -0
- package/dist/src/utility/serialization/scene/particle.js +425 -0
- package/dist/src/utility/serialization/scene/particle.js.map +1 -0
- package/dist/src/utility/serialization/scene/primitive.js +692 -0
- package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/src/utility/serialization/scene/scene.js +704 -0
- package/dist/src/utility/serialization/scene/scene.js.map +1 -0
- package/dist/src/utility/serialization/scene/terrain.js +488 -0
- package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/src/utility/serialization/scene/water.js +465 -0
- package/dist/src/utility/serialization/scene/water.js.map +1 -0
- package/dist/src/utility/shprojector.js +297 -0
- package/dist/src/utility/shprojector.js.map +1 -0
- package/dist/src/utility/textures/ggxlut.js +213 -0
- package/dist/src/utility/textures/ggxlut.js.map +1 -0
- package/dist/src/utility/textures/gradientnoise.js +62 -0
- package/dist/src/utility/textures/gradientnoise.js.map +1 -0
- package/dist/src/utility/textures/randomnoise.js +41 -0
- package/dist/src/utility/textures/randomnoise.js.map +1 -0
- package/dist/src/values.js +162 -0
- package/dist/src/values.js.map +1 -0
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +143 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +1275 -1091
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +505 -490
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/serialization/blueprint/constants.js +255 -0
- package/dist/utility/serialization/blueprint/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/constants.js +203 -0
- package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
- package/dist/utility/serialization/blueprint/material/texture.js +165 -0
- package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
- package/dist/utility/serialization/manager.js +55 -11
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +2 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +2 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +2 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +4 -4
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +1 -5
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
- package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
- package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone.js +0 -240
- package/dist/animation/spring/spring_bone.js.map +0 -1
- package/dist/animation/spring/spring_bone_collider.js +0 -198
- package/dist/animation/spring/spring_bone_collider.js.map +0 -1
- package/dist/animation/spring/spring_bone_constraint.js +0 -170
- package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
- package/dist/animation/spring/spring_bone_system.js +0 -328
- package/dist/animation/spring/spring_bone_system.js.map +0 -1
- package/dist/render/sky_motion_vector.js +0 -85
- package/dist/render/sky_motion_vector.js.map +0 -1
|
@@ -0,0 +1,732 @@
|
|
|
1
|
+
import { Observable, DRef, ObservableVector3, ObservableQuaternion, Matrix4x4, Vector3, Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { AnimationSet } from '../animation/animationset.js';
|
|
3
|
+
import '../animation/eulerrotationtrack.js';
|
|
4
|
+
import '../animation/skeleton.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The base class for any kind of scene objects
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* We use a data structure called SceneGraph to store scenes,
|
|
11
|
+
* which consists of a couple of scene objects forming a
|
|
12
|
+
* hierarchical structure. This is the base class for any kind
|
|
13
|
+
* of the scene object, which contains the basic properties such
|
|
14
|
+
* as position, rotation, and scale of the object.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/ class SceneNode extends Observable {
|
|
18
|
+
/*
|
|
19
|
+
static readonly PICK_INHERITED = -1;
|
|
20
|
+
static readonly PICK_DISABLED = 0;
|
|
21
|
+
static readonly PICK_ENABLED = 1;
|
|
22
|
+
*/ static BBOXDRAW_INHERITED = -1;
|
|
23
|
+
static BBOXDRAW_DISABLED = 0;
|
|
24
|
+
static BBOXDRAW_LOCAL = 1;
|
|
25
|
+
static BBOXDRAW_WORLD = 2;
|
|
26
|
+
/** @internal */ _id;
|
|
27
|
+
/** @internal */ _disposed;
|
|
28
|
+
/** @internal */ _animationSet;
|
|
29
|
+
/** @internal */ _sharedModel;
|
|
30
|
+
/** @internal */ _clipMode;
|
|
31
|
+
/** @internal */ _boxDrawMode;
|
|
32
|
+
/** @internal */ _visible;
|
|
33
|
+
/** @internal */ _pickable;
|
|
34
|
+
/** @internal */ _gpuPickable;
|
|
35
|
+
/** @internal */ _name;
|
|
36
|
+
/** @internal */ _scene;
|
|
37
|
+
/** @internal */ _bv;
|
|
38
|
+
/** @internal */ _bvDirty;
|
|
39
|
+
/** @internal */ _bvWorld;
|
|
40
|
+
/** @internal */ _placeToOctree;
|
|
41
|
+
/** @internal */ _sealed;
|
|
42
|
+
/** @internal */ _parent;
|
|
43
|
+
/** @internal */ _children;
|
|
44
|
+
/** @internal */ _position;
|
|
45
|
+
/** @internal */ _scaling;
|
|
46
|
+
/** @internal */ _rotation;
|
|
47
|
+
/** @internal */ _localMatrix;
|
|
48
|
+
/** @internal */ _worldMatrix;
|
|
49
|
+
/** @internal */ _worldMatrixDet;
|
|
50
|
+
/** @internal */ _invWorldMatrix;
|
|
51
|
+
/** @internal */ _tmpLocalMatrix;
|
|
52
|
+
/** @internal */ _tmpWorldMatrix;
|
|
53
|
+
/** @internal */ _transformTag;
|
|
54
|
+
/** @internal */ _transformChangeCallback;
|
|
55
|
+
/** @internal */ _metaData;
|
|
56
|
+
/** @internal */ _disableCallback;
|
|
57
|
+
/** @internal */ _script;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new scene node
|
|
60
|
+
* @param scene - Which scene the node belongs to
|
|
61
|
+
*/ constructor(scene){
|
|
62
|
+
super();
|
|
63
|
+
this._id = crypto.randomUUID();
|
|
64
|
+
this._disposed = false;
|
|
65
|
+
this._scene = scene;
|
|
66
|
+
this._name = '';
|
|
67
|
+
this._animationSet = new DRef();
|
|
68
|
+
this._sharedModel = new DRef();
|
|
69
|
+
this._bv = null;
|
|
70
|
+
this._bvWorld = null;
|
|
71
|
+
this._bvDirty = true;
|
|
72
|
+
this._clipMode = true;
|
|
73
|
+
this._boxDrawMode = SceneNode.BBOXDRAW_DISABLED;
|
|
74
|
+
this._visible = 'inherit';
|
|
75
|
+
this._pickable = false;
|
|
76
|
+
this._gpuPickable = true;
|
|
77
|
+
this._placeToOctree = true;
|
|
78
|
+
this._parent = null;
|
|
79
|
+
this._sealed = false;
|
|
80
|
+
this._children = [];
|
|
81
|
+
this._transformChangeCallback = ()=>this._onTransformChanged(true);
|
|
82
|
+
this._position = new ObservableVector3(0, 0, 0);
|
|
83
|
+
this._position.callback = this._transformChangeCallback;
|
|
84
|
+
this._scaling = new ObservableVector3(1, 1, 1);
|
|
85
|
+
this._scaling.callback = this._transformChangeCallback;
|
|
86
|
+
this._rotation = new ObservableQuaternion();
|
|
87
|
+
this._rotation.callback = this._transformChangeCallback;
|
|
88
|
+
this._worldMatrix = null;
|
|
89
|
+
this._worldMatrixDet = null;
|
|
90
|
+
this._invWorldMatrix = null;
|
|
91
|
+
this._localMatrix = null;
|
|
92
|
+
this._transformTag = 0;
|
|
93
|
+
this._disableCallback = false;
|
|
94
|
+
this._tmpLocalMatrix = Matrix4x4.identity();
|
|
95
|
+
this._tmpWorldMatrix = Matrix4x4.identity();
|
|
96
|
+
this._script = '';
|
|
97
|
+
this._metaData = null;
|
|
98
|
+
if (scene && this !== scene.rootNode) {
|
|
99
|
+
this.reparent(scene.rootNode);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/** @internal */ get placeToOctree() {
|
|
103
|
+
return this._placeToOctree;
|
|
104
|
+
}
|
|
105
|
+
set placeToOctree(val) {
|
|
106
|
+
if (!!val !== this._placeToOctree) {
|
|
107
|
+
this._placeToOctree = !!val;
|
|
108
|
+
if (this.isGraphNode()) {
|
|
109
|
+
this.scene?.invalidateNodePlacement(this);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Id of the node
|
|
115
|
+
*/ get persistentId() {
|
|
116
|
+
return this._id;
|
|
117
|
+
}
|
|
118
|
+
set persistentId(id) {
|
|
119
|
+
this._id = id;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Metadata of the scene
|
|
123
|
+
*/ get metaData() {
|
|
124
|
+
return this._metaData;
|
|
125
|
+
}
|
|
126
|
+
set metaData(val) {
|
|
127
|
+
this._metaData = val;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Attached scripts of this node
|
|
131
|
+
*/ get script() {
|
|
132
|
+
return this._script;
|
|
133
|
+
}
|
|
134
|
+
set script(fileName) {
|
|
135
|
+
this._script = fileName ?? '';
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Name of the node
|
|
139
|
+
*/ get name() {
|
|
140
|
+
return this._name;
|
|
141
|
+
}
|
|
142
|
+
set name(val) {
|
|
143
|
+
this._name = val || '';
|
|
144
|
+
}
|
|
145
|
+
/** The scene to which the node belongs */ get scene() {
|
|
146
|
+
return this._scene;
|
|
147
|
+
}
|
|
148
|
+
/** true if the node is attached to a scene, false otherwise */ get attached() {
|
|
149
|
+
let node = this;
|
|
150
|
+
while(node && node !== this._scene.rootNode){
|
|
151
|
+
node = node.parent;
|
|
152
|
+
}
|
|
153
|
+
return node === this._scene.rootNode;
|
|
154
|
+
}
|
|
155
|
+
/** true if the node is sealed */ get sealed() {
|
|
156
|
+
return this._sealed;
|
|
157
|
+
}
|
|
158
|
+
set sealed(val) {
|
|
159
|
+
this._sealed = val;
|
|
160
|
+
}
|
|
161
|
+
get animationSet() {
|
|
162
|
+
if (!this._animationSet.get()) {
|
|
163
|
+
this._animationSet.set(new AnimationSet(this));
|
|
164
|
+
this.scene.queueUpdateNode(this);
|
|
165
|
+
}
|
|
166
|
+
return this._animationSet.get();
|
|
167
|
+
}
|
|
168
|
+
get sharedModel() {
|
|
169
|
+
return this._sharedModel.get();
|
|
170
|
+
}
|
|
171
|
+
set sharedModel(model) {
|
|
172
|
+
this._sharedModel.set(model);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Creates a new node by cloning this node
|
|
176
|
+
* @param method - clone method
|
|
177
|
+
* @param recursive - true if children should also be cloned, otherwise false
|
|
178
|
+
* @returns New cloned node
|
|
179
|
+
*/ clone(method, recursive) {
|
|
180
|
+
const other = this._sharedModel.get() ? this._sharedModel.get().createSceneNode(this.scene, method === 'instance') : new SceneNode(this.scene);
|
|
181
|
+
other.copyFrom(this, method, recursive);
|
|
182
|
+
other.parent = this.parent;
|
|
183
|
+
return other;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Copy properties from other node
|
|
187
|
+
* @param other - Other node to copy properties from
|
|
188
|
+
* @param method - Clone method
|
|
189
|
+
* @param recursive - true if children of the node to copy from should be cloned and copied to this node, otherwise, children of the node to copy from will not be copied.
|
|
190
|
+
*/ copyFrom(other, method, recursive) {
|
|
191
|
+
if (other.disposed || this.disposed) {
|
|
192
|
+
console.error('SceneNode.copyFrom(): Cannot copy from/to disposed node');
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (other.scene !== this.scene) {
|
|
196
|
+
console.error('SceneNode.copyFrom(): Cannot copy from/to node which belongs to another scene');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
this.clipTestEnabled = other.clipTestEnabled;
|
|
200
|
+
this.boundingBoxDrawMode = other.boundingBoxDrawMode;
|
|
201
|
+
this.showState = other.showState;
|
|
202
|
+
this.pickable = other.pickable;
|
|
203
|
+
this.placeToOctree = other.placeToOctree;
|
|
204
|
+
this.position.set(other.position);
|
|
205
|
+
this.scale.set(other.scale);
|
|
206
|
+
this.rotation.set(other.rotation);
|
|
207
|
+
if (recursive) {
|
|
208
|
+
for (const child of other.children){
|
|
209
|
+
if (!child.get().sealed) {
|
|
210
|
+
child.get().clone(method, true).parent = this;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Check if given node is a direct child of the node
|
|
217
|
+
* @param child - The node to be checked
|
|
218
|
+
* @returns true if the given node is a direct child of this node, false otherwise
|
|
219
|
+
*/ hasChild(child) {
|
|
220
|
+
return child && child.parent === this;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Removes all children from this node
|
|
224
|
+
*/ removeChildren() {
|
|
225
|
+
while(this._children.length){
|
|
226
|
+
this._children[0].get().remove();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Checks if this node is the direct parent or indirect parent of a given node
|
|
231
|
+
* @param child - The node to be checked
|
|
232
|
+
* @returns true if this node is the direct parent or indirect parent of the given node, false otherwise
|
|
233
|
+
*/ isParentOf(child) {
|
|
234
|
+
while(child && child !== this){
|
|
235
|
+
child = child.parent;
|
|
236
|
+
}
|
|
237
|
+
return child === this;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Removes this node from it's parent
|
|
241
|
+
* @returns self
|
|
242
|
+
*/ remove() {
|
|
243
|
+
this.parent = null;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Traverse the entire subtree of this node by a visitor
|
|
248
|
+
* @param v - The visitor that will travel the subtree of this node
|
|
249
|
+
* @param inverse - true if traversing from bottom to top, otherwise top to bottom
|
|
250
|
+
*/ traverse(v) {
|
|
251
|
+
v.visit(this);
|
|
252
|
+
for (const child of this._children){
|
|
253
|
+
child.get().traverse(v);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Iterate self and all of the children
|
|
258
|
+
*
|
|
259
|
+
* @remarks
|
|
260
|
+
* DO NOT remove child duration iteration!
|
|
261
|
+
*
|
|
262
|
+
* @param callback - callback function that will be called on each node, if callback returns true, iteration will be stopped immediately
|
|
263
|
+
*/ iterate(callback) {
|
|
264
|
+
if (!!callback(this)) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
for (const child of this._children){
|
|
268
|
+
if (!!child.get().iterate(callback)) {
|
|
269
|
+
return true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Iterate self and all of the children from bottom to top in reversed order
|
|
276
|
+
*
|
|
277
|
+
* @remarks
|
|
278
|
+
* Child can be removed duration iteration!
|
|
279
|
+
*
|
|
280
|
+
* @param callback - callback function that will be called on each node, if callback returns true, iteration will be stopped immediately
|
|
281
|
+
*/ iterateBottomToTop(callback) {
|
|
282
|
+
for(let i = this._children.length - 1; i >= 0; i--){
|
|
283
|
+
const child = this._children[i];
|
|
284
|
+
if (!!child.get().iterateBottomToTop(callback)) {
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
if (!!callback(this)) {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
/** true if this is a graph node, false otherwise */ isGraphNode() {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
/** true if this is a light node, false otherwise */ isLight() {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
/** true if this is a mesh node, false otherwise */ isMesh() {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
/** true if this is a water node, false otherwise */ isWater() {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
/** true if this is a particle system node, false otherwise */ isParticleSystem() {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
/** true if this is a batch group, false otherwise */ isBatchGroup() {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
/** true if this is a terrain node, false otherwise */ isTerrain() {
|
|
312
|
+
return false;
|
|
313
|
+
}
|
|
314
|
+
/** true if this is a clipmap terrain node, false otherwise */ isClipmapTerrain() {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
/** true if this is a camera node, false otherwise */ isCamera() {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
/** true if this is a punctual light node, false otherwise */ isPunctualLight() {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
/** Disposes the node */ dispose() {
|
|
324
|
+
this._disposed = true;
|
|
325
|
+
this.remove();
|
|
326
|
+
this.removeChildren();
|
|
327
|
+
this._animationSet?.dispose();
|
|
328
|
+
this._animationSet = null;
|
|
329
|
+
this._sharedModel?.dispose();
|
|
330
|
+
this._sharedModel = null;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Whether this node was disposed
|
|
334
|
+
*/ get disposed() {
|
|
335
|
+
return this._disposed;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Computes the bounding volume of the node
|
|
339
|
+
* @returns The output bounding volume
|
|
340
|
+
*/ computeBoundingVolume() {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Gets the bounding volume of the node
|
|
345
|
+
* @returns The bounding volume of the node
|
|
346
|
+
*/ getBoundingVolume() {
|
|
347
|
+
if (this._bvDirty) {
|
|
348
|
+
this._bv = this.computeBoundingVolume();
|
|
349
|
+
this._bvDirty = false;
|
|
350
|
+
}
|
|
351
|
+
return this._bv;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Sets the bounding volume of the node
|
|
355
|
+
* @param bv - The bounding volume to set
|
|
356
|
+
*/ setBoundingVolume(bv) {
|
|
357
|
+
if (bv !== this._bv) {
|
|
358
|
+
this._bv = bv;
|
|
359
|
+
this._bvDirty = !this._bv;
|
|
360
|
+
this.invalidateWorldBoundingVolume(false);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Gets the world space bounding volume of the node
|
|
365
|
+
* @returns The world space bounding volume of the node
|
|
366
|
+
*/ getWorldBoundingVolume() {
|
|
367
|
+
if (!this._bvWorld) {
|
|
368
|
+
this._bvWorld = this.computeWorldBoundingVolume(this.getBoundingVolume());
|
|
369
|
+
}
|
|
370
|
+
return this._bvWorld;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Computes the world space bounding volume of the node
|
|
374
|
+
* @returns The output bounding volume
|
|
375
|
+
*/ computeWorldBoundingVolume(localBV) {
|
|
376
|
+
return localBV?.transform(this.worldMatrix) ?? null;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Force the bounding volume to be recalculated
|
|
380
|
+
*/ invalidateBoundingVolume() {
|
|
381
|
+
this._bvDirty = true;
|
|
382
|
+
this.invalidateWorldBoundingVolume(false);
|
|
383
|
+
}
|
|
384
|
+
/** Force the world space bounding volume to be recalculated */ invalidateWorldBoundingVolume(transformChanged) {
|
|
385
|
+
this._bvWorld = null;
|
|
386
|
+
if (this._scene) {
|
|
387
|
+
if (transformChanged) {
|
|
388
|
+
this.iterate((node)=>{
|
|
389
|
+
if (node.isGraphNode()) {
|
|
390
|
+
this._scene.invalidateNodePlacement(node);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
} else if (this.isGraphNode()) {
|
|
394
|
+
this._scene.invalidateNodePlacement(this);
|
|
395
|
+
}
|
|
396
|
+
this.dispatchEvent('bvchanged', this);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Clip mode */ get clipTestEnabled() {
|
|
400
|
+
return this._clipMode;
|
|
401
|
+
}
|
|
402
|
+
set clipTestEnabled(val) {
|
|
403
|
+
this._clipMode = val;
|
|
404
|
+
}
|
|
405
|
+
/** Computed value of show state */ get hidden() {
|
|
406
|
+
let node = this;
|
|
407
|
+
while(node && node._visible === 'inherit'){
|
|
408
|
+
node = node.parent;
|
|
409
|
+
}
|
|
410
|
+
return node ? node._visible === 'hidden' : false;
|
|
411
|
+
}
|
|
412
|
+
/** Show state */ get showState() {
|
|
413
|
+
return this._visible;
|
|
414
|
+
}
|
|
415
|
+
set showState(val) {
|
|
416
|
+
if (val !== this._visible) {
|
|
417
|
+
const prevHidden = this.hidden;
|
|
418
|
+
this._visible = val;
|
|
419
|
+
if (prevHidden !== this.hidden) {
|
|
420
|
+
if (this.isGraphNode()) {
|
|
421
|
+
this._scene?.invalidateNodePlacement(this);
|
|
422
|
+
}
|
|
423
|
+
let parent = this;
|
|
424
|
+
while(parent){
|
|
425
|
+
parent.dispatchEvent('visiblechanged', this);
|
|
426
|
+
parent = parent.parent;
|
|
427
|
+
}
|
|
428
|
+
this.notifyHiddenChanged();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/** Whether this node is enabled for CPU picking */ get pickable() {
|
|
433
|
+
return this._pickable;
|
|
434
|
+
}
|
|
435
|
+
set pickable(val) {
|
|
436
|
+
this._pickable = !!val;
|
|
437
|
+
}
|
|
438
|
+
/** Whether this node is enabled for GPU picking */ get gpuPickable() {
|
|
439
|
+
return this._gpuPickable;
|
|
440
|
+
}
|
|
441
|
+
set gpuPickable(val) {
|
|
442
|
+
this._gpuPickable = !!val;
|
|
443
|
+
}
|
|
444
|
+
/** Computed value for bounding box draw mode */ get computedBoundingBoxDrawMode() {
|
|
445
|
+
if (this._boxDrawMode === SceneNode.BBOXDRAW_INHERITED) {
|
|
446
|
+
let parent = this.parent;
|
|
447
|
+
while(parent && !parent.isGraphNode()){
|
|
448
|
+
parent = parent.parent;
|
|
449
|
+
}
|
|
450
|
+
return parent?.computedBoundingBoxDrawMode ?? SceneNode.BBOXDRAW_DISABLED;
|
|
451
|
+
}
|
|
452
|
+
return this._boxDrawMode;
|
|
453
|
+
}
|
|
454
|
+
/** Bounding box draw mode */ get boundingBoxDrawMode() {
|
|
455
|
+
return this._boxDrawMode;
|
|
456
|
+
}
|
|
457
|
+
set boundingBoxDrawMode(mode) {
|
|
458
|
+
this._boxDrawMode = mode;
|
|
459
|
+
}
|
|
460
|
+
/** @internal */ _setParent(p) {
|
|
461
|
+
if (p && p._scene !== this._scene) {
|
|
462
|
+
throw new Error('Parent node and child node must belongs to the same scene');
|
|
463
|
+
}
|
|
464
|
+
let lastParent = this._parent;
|
|
465
|
+
let newParent = p;
|
|
466
|
+
if (newParent !== lastParent) {
|
|
467
|
+
const willDetach = (!p || !p.attached) && this.attached;
|
|
468
|
+
const willAttach = !this.attached && p && p.attached;
|
|
469
|
+
if (newParent) {
|
|
470
|
+
newParent._children.push(new DRef(this));
|
|
471
|
+
}
|
|
472
|
+
if (this._parent) {
|
|
473
|
+
const index = this._parent._children.findIndex((val)=>val.get() === this);
|
|
474
|
+
this._parent.children[index].dispose();
|
|
475
|
+
this._parent._children.splice(index, 1);
|
|
476
|
+
}
|
|
477
|
+
this._parent = p;
|
|
478
|
+
this._onTransformChanged(false);
|
|
479
|
+
if (willDetach) {
|
|
480
|
+
this._detached();
|
|
481
|
+
}
|
|
482
|
+
if (willAttach) {
|
|
483
|
+
this._attached();
|
|
484
|
+
}
|
|
485
|
+
while(lastParent){
|
|
486
|
+
lastParent.dispatchEvent('noderemoved', this);
|
|
487
|
+
lastParent = lastParent.parent;
|
|
488
|
+
}
|
|
489
|
+
while(newParent){
|
|
490
|
+
newParent.dispatchEvent('nodeattached', this);
|
|
491
|
+
newParent = newParent.parent;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/** @internal */ _onTransformChanged(invalidateLocal) {
|
|
496
|
+
if (this._disableCallback) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
if (invalidateLocal) {
|
|
500
|
+
this._localMatrix = null;
|
|
501
|
+
}
|
|
502
|
+
this._worldMatrix = null;
|
|
503
|
+
this._invWorldMatrix = null;
|
|
504
|
+
this._worldMatrixDet = null;
|
|
505
|
+
this._transformTag++;
|
|
506
|
+
for (const child of this._children){
|
|
507
|
+
child.get()._onTransformChanged(false);
|
|
508
|
+
}
|
|
509
|
+
this.invalidateWorldBoundingVolume(true);
|
|
510
|
+
this.dispatchEvent('transformchanged', this);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Get called when this node is attached to scene
|
|
514
|
+
*/ _onAttached() {}
|
|
515
|
+
/**
|
|
516
|
+
* Get called when this node is detached from scene
|
|
517
|
+
*/ _onDetached() {}
|
|
518
|
+
/** @internal */ _attached() {
|
|
519
|
+
this.iterate((child)=>{
|
|
520
|
+
child._onAttached();
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
/** @internal */ _detached() {
|
|
524
|
+
this.iterate((child)=>{
|
|
525
|
+
child._onDetached();
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
/** @internal */ notifyHiddenChanged() {
|
|
529
|
+
this._visibleChanged();
|
|
530
|
+
for (const child of this._children){
|
|
531
|
+
if (child.get().showState === 'inherit') {
|
|
532
|
+
child.get().notifyHiddenChanged();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/** @internal */ _visibleChanged() {}
|
|
537
|
+
/** Parent of the xform */ get parent() {
|
|
538
|
+
return this._parent;
|
|
539
|
+
}
|
|
540
|
+
set parent(p) {
|
|
541
|
+
p = p || null;
|
|
542
|
+
if (p !== this._parent) {
|
|
543
|
+
this._setParent(p);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
/** Children of this xform */ get children() {
|
|
547
|
+
return this._children;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Position of the xform relative to it's parent
|
|
551
|
+
*/ get position() {
|
|
552
|
+
return this._position;
|
|
553
|
+
}
|
|
554
|
+
set position(val) {
|
|
555
|
+
this._position.setXYZ(val[0], val[1], val[2]);
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Scaling of the xform
|
|
559
|
+
*/ get scale() {
|
|
560
|
+
return this._scaling;
|
|
561
|
+
}
|
|
562
|
+
set scale(val) {
|
|
563
|
+
this._scaling.setXYZ(val[0], val[1], val[2]);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Rotation of the xform
|
|
567
|
+
*/ get rotation() {
|
|
568
|
+
return this._rotation;
|
|
569
|
+
}
|
|
570
|
+
set rotation(val) {
|
|
571
|
+
this._rotation.setXYZW(val[0], val[1], val[2], val[3]);
|
|
572
|
+
}
|
|
573
|
+
worldToThis(v, result) {
|
|
574
|
+
if (v instanceof Vector3) {
|
|
575
|
+
result = result || new Vector3();
|
|
576
|
+
this.invWorldMatrix.transformPointAffine(v, result);
|
|
577
|
+
return result;
|
|
578
|
+
} else {
|
|
579
|
+
result = result || new Vector4();
|
|
580
|
+
this.invWorldMatrix.transformAffine(v, result);
|
|
581
|
+
return result;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
otherToThis(other, v, result) {
|
|
585
|
+
return this.worldToThis(other.thisToWorld(v, result), result);
|
|
586
|
+
}
|
|
587
|
+
thisToWorld(v, result) {
|
|
588
|
+
if (v instanceof Vector3) {
|
|
589
|
+
result = result || new Vector3();
|
|
590
|
+
this.worldMatrix.transformPointAffine(v, result);
|
|
591
|
+
return result;
|
|
592
|
+
} else {
|
|
593
|
+
result = result || new Vector4();
|
|
594
|
+
this.worldMatrix.transformAffine(v, result);
|
|
595
|
+
return result;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
thisToOther(other, v, result) {
|
|
599
|
+
return other.worldToThis(this.thisToWorld(v, result), result);
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Gets the position of the xform in world space
|
|
603
|
+
* @returns position of the xform in world space
|
|
604
|
+
*/ getWorldPosition(outPos) {
|
|
605
|
+
return outPos?.setXYZ(this.worldMatrix.m03, this.worldMatrix.m13, this.worldMatrix.m23) ?? new Vector3(this.worldMatrix.m03, this.worldMatrix.m13, this.worldMatrix.m23);
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Moves the xform by an offset vector
|
|
609
|
+
* @param delta - The offset vector
|
|
610
|
+
* @returns self
|
|
611
|
+
*/ moveBy(delta) {
|
|
612
|
+
this._position.addBy(delta);
|
|
613
|
+
return this;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Scales the xform by a given scale factor
|
|
617
|
+
* @param factor - The scale factor
|
|
618
|
+
* @returns self
|
|
619
|
+
*/ scaleBy(factor) {
|
|
620
|
+
this._scaling.mulBy(factor);
|
|
621
|
+
return this;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Sets the local transform matrix of the xform
|
|
625
|
+
* @param matrix - The transform matrix to set
|
|
626
|
+
* @returns self
|
|
627
|
+
*/ setLocalTransform(matrix) {
|
|
628
|
+
this._disableCallback = true;
|
|
629
|
+
matrix.decompose(this._scaling, this._rotation, this._position);
|
|
630
|
+
this._disableCallback = false;
|
|
631
|
+
this._onTransformChanged(true);
|
|
632
|
+
/*
|
|
633
|
+
this._localMatrix = matrix;
|
|
634
|
+
this._disableCallback = true;
|
|
635
|
+
this._localMatrix.decompose(this._scaling, this._rotation, this._position);
|
|
636
|
+
this._disableCallback = false;
|
|
637
|
+
this._onTransformChanged(false);
|
|
638
|
+
*/ return this;
|
|
639
|
+
}
|
|
640
|
+
/** Local transformation matrix of the xform */ get localMatrix() {
|
|
641
|
+
if (!this._localMatrix) {
|
|
642
|
+
this.calculateLocalTransform(this._tmpLocalMatrix);
|
|
643
|
+
this._localMatrix = this._tmpLocalMatrix;
|
|
644
|
+
/*
|
|
645
|
+
this._localMatrix
|
|
646
|
+
.scaling(this._scaling)
|
|
647
|
+
.rotateLeft(new Matrix4x4(this._rotation))
|
|
648
|
+
.translateLeft(this._position);
|
|
649
|
+
*/ }
|
|
650
|
+
return this._localMatrix;
|
|
651
|
+
}
|
|
652
|
+
set localMatrix(matrix) {
|
|
653
|
+
this.setLocalTransform(matrix);
|
|
654
|
+
}
|
|
655
|
+
/** World transformation matrix of the xform */ get worldMatrix() {
|
|
656
|
+
if (!this._worldMatrix) {
|
|
657
|
+
this._worldMatrix = this._tmpWorldMatrix;
|
|
658
|
+
this.calculateWorldTransform(this._worldMatrix);
|
|
659
|
+
}
|
|
660
|
+
return this._worldMatrix;
|
|
661
|
+
}
|
|
662
|
+
/** The determinant of world matrix */ get worldMatrixDet() {
|
|
663
|
+
if (this._worldMatrixDet === null) {
|
|
664
|
+
this._worldMatrixDet = this.worldMatrix.det();
|
|
665
|
+
}
|
|
666
|
+
return this._worldMatrixDet;
|
|
667
|
+
}
|
|
668
|
+
/** Inverse of the world transformation matrix of the xform */ get invWorldMatrix() {
|
|
669
|
+
if (!this._invWorldMatrix) {
|
|
670
|
+
this._invWorldMatrix = Matrix4x4.invertAffine(this.worldMatrix);
|
|
671
|
+
}
|
|
672
|
+
return this._invWorldMatrix;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Calculate local transform matrix
|
|
676
|
+
* @param outMatrix - Matrix object that holds the result of calculation
|
|
677
|
+
*/ calculateLocalTransform(outMatrix) {
|
|
678
|
+
outMatrix.compose(this._scaling, this._rotation, this._position);
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Calculate world transform matrix
|
|
682
|
+
* @param outMatrix - Matrix object that holds the result of calculation
|
|
683
|
+
*/ calculateWorldTransform(outMatrix) {
|
|
684
|
+
if (this._parent) {
|
|
685
|
+
Matrix4x4.multiplyAffine(this._parent.worldMatrix, this.localMatrix, outMatrix);
|
|
686
|
+
} else {
|
|
687
|
+
outMatrix.set(this.localMatrix);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Sets the local tranformation matrix by a look-at matrix
|
|
692
|
+
* @param eye - The eye position used to make the look-at matrix
|
|
693
|
+
* @param target - The target position used to make the look-at matrix
|
|
694
|
+
* @param up - The up vector used to make the look-at matrix
|
|
695
|
+
* @returns self
|
|
696
|
+
*/ lookAt(eye, target, up) {
|
|
697
|
+
this.setLocalTransform(Matrix4x4.lookAt(eye, target, up));
|
|
698
|
+
return this;
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Update node state once per-frame
|
|
702
|
+
* @param frameId - Current frame id
|
|
703
|
+
* @param elapsedInSeconds - Elapsed time from game start in seconds
|
|
704
|
+
* @param deltaInSeconds - Elapsed time since previous frame in seconds
|
|
705
|
+
*/ update(frameId, elapsedInSeconds, deltaInSeconds) {
|
|
706
|
+
const animationSet = this.animationSet;
|
|
707
|
+
if (animationSet) {
|
|
708
|
+
animationSet.update(deltaInSeconds);
|
|
709
|
+
this.scene.queueUpdateNode(this);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Update node state once per-camera
|
|
714
|
+
* @param _camera - Updates according to which camera
|
|
715
|
+
* @param _elapsedInSeconds - Elapsed time from game start in seconds
|
|
716
|
+
* @param _deltaInSeconds - Elapsed time since previous frame in seconds
|
|
717
|
+
*/ updatePerCamera(_camera, _elapsedInSeconds, _deltaInSeconds) {}
|
|
718
|
+
/**
|
|
719
|
+
* Removes this node from it's parent and add this node to another parent node if required
|
|
720
|
+
* @param p - The new parent node that this node should be added to or null
|
|
721
|
+
* @returns self
|
|
722
|
+
*/ reparent(p) {
|
|
723
|
+
this.parent = p;
|
|
724
|
+
return this;
|
|
725
|
+
}
|
|
726
|
+
/** @internal */ get transformTag() {
|
|
727
|
+
return this._transformTag;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
export { SceneNode };
|
|
732
|
+
//# sourceMappingURL=scene_node.js.map
|