@zephyr3d/scene 0.6.0 → 0.7.0
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 +1 -1
- package/dist/animation/animation.js +149 -27
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +173 -73
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js +65 -10
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +41 -20
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/morphtarget.js +14 -38
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +59 -22
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/proptrack.js +190 -0
- package/dist/animation/proptrack.js.map +1 -0
- package/dist/animation/rotationtrack.js +29 -11
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +29 -11
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +241 -78
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/translationtrack.js +30 -11
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/api.js +43 -0
- package/dist/app/api.js.map +1 -0
- package/dist/app/app.js +153 -0
- package/dist/app/app.js.map +1 -0
- package/dist/app/engine.js +312 -0
- package/dist/app/engine.js.map +1 -0
- package/dist/app/inputmgr.js +351 -0
- package/dist/app/inputmgr.js.map +1 -0
- package/dist/app/runtimescript.js +62 -0
- package/dist/app/runtimescript.js.map +1 -0
- package/dist/app/scriptingsystem.js +220 -0
- package/dist/app/scriptingsystem.js.map +1 -0
- package/dist/app/scriptregistry.js +432 -0
- package/dist/app/scriptregistry.js.map +1 -0
- package/dist/asset/assetmanager.js +772 -291
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/builtin.js +7 -43
- package/dist/asset/builtin.js.map +1 -1
- package/dist/asset/loaders/dds/dds.js +17 -93
- package/dist/asset/loaders/dds/dds.js.map +1 -1
- package/dist/asset/loaders/dds/dds_loader.js +8 -18
- package/dist/asset/loaders/dds/dds_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +36 -42
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/gltf/helpers.js +27 -14
- package/dist/asset/loaders/gltf/helpers.js.map +1 -1
- package/dist/asset/loaders/hdr/hdr.js +17 -12
- package/dist/asset/loaders/hdr/hdr.js.map +1 -1
- package/dist/asset/loaders/image/tga_Loader.js +13 -16
- package/dist/asset/loaders/image/tga_Loader.js.map +1 -1
- package/dist/asset/loaders/image/webimage_loader.js +51 -50
- package/dist/asset/loaders/image/webimage_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/model.js +158 -4
- package/dist/asset/model.js.map +1 -1
- package/dist/blitter/bilateralblur.js +0 -1
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/blitter.js +22 -23
- package/dist/blitter/blitter.js.map +1 -1
- package/dist/blitter/box.js.map +1 -1
- package/dist/blitter/copy.js.map +1 -1
- package/dist/blitter/gaussianblur.js +23 -23
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +141 -34
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +653 -149
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/fps.js +2 -10
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +132 -59
- package/dist/camera/orbit.js.map +1 -1
- package/dist/camera/orthocamera.js +37 -12
- package/dist/camera/orthocamera.js.map +1 -1
- package/dist/camera/perspectivecamera.js +37 -20
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +18268 -6982
- package/dist/index.js +49 -16
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +5 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/grassmaterial.js +6 -1
- package/dist/material/grassmaterial.js.map +1 -1
- package/dist/material/lambert.js +6 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +346 -73
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +498 -156
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +5 -1
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/foliage.js +3 -3
- package/dist/material/mixins/foliage.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +18 -5
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +6 -6
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +235 -0
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -0
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +52 -15
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +27 -9
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +16 -4
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/brdf.js +134 -0
- package/dist/material/mixins/pbr/brdf.js.map +1 -0
- package/dist/material/mixins/pbr/common.js +68 -85
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +98 -83
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +6 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/particle.js +272 -0
- package/dist/material/particle.js.map +1 -0
- package/dist/material/pbrblueprint.js +186 -0
- package/dist/material/pbrblueprint.js.map +1 -0
- package/dist/material/pbrmr.js +10 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +10 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +521 -287
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/terrain-cm.js +607 -0
- package/dist/material/terrain-cm.js.map +1 -0
- package/dist/material/terrainmaterial.js +59 -54
- package/dist/material/terrainmaterial.js.map +1 -1
- package/dist/material/unlit.js +5 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +415 -0
- package/dist/material/water.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/node_modules/es-module-lexer/dist/lexer.js +5 -0
- package/dist/node_modules/es-module-lexer/dist/lexer.js.map +1 -0
- package/dist/posteffect/bloom.js +39 -54
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/compositor.js +95 -128
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/fxaa.js +10 -18
- package/dist/posteffect/fxaa.js.map +1 -1
- package/dist/posteffect/grayscale.js +9 -17
- package/dist/posteffect/grayscale.js.map +1 -1
- package/dist/posteffect/motionblur.js +105 -0
- package/dist/posteffect/motionblur.js.map +1 -0
- package/dist/posteffect/posteffect.js +66 -35
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/sao.js +13 -21
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/ssr.js +60 -100
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/taa.js +175 -0
- package/dist/posteffect/taa.js.map +1 -0
- package/dist/posteffect/tonemap.js +12 -20
- package/dist/posteffect/tonemap.js.map +1 -1
- package/dist/render/abuffer_oit.js +30 -19
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +429 -101
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +7 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +43 -3
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/depthpass.js +14 -5
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +113 -40
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +86 -141
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +234 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -0
- package/dist/render/fft_wavegenerator.js +64 -50
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/fullscreenquad.js +2 -2
- package/dist/render/fullscreenquad.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +98 -48
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +4 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/hzb.js +6 -3
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/lightpass.js +19 -18
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/objectcolorpass.js +4 -4
- package/dist/render/objectcolorpass.js.map +1 -1
- package/dist/render/primitive.js +213 -104
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/render_queue.js +40 -20
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderbundle_wrapper.js +65 -15
- package/dist/render/renderbundle_wrapper.js.map +1 -1
- package/dist/render/renderer.js +326 -185
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/renderpass.js +20 -36
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/shadowmap_pass.js +3 -3
- package/dist/render/shadowmap_pass.js.map +1 -1
- package/dist/render/sky.js +864 -541
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +13 -15
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -5
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +78 -48
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/graph_node.js +2 -3
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/light.js +28 -89
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +218 -87
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/octree.js +371 -162
- package/dist/scene/octree.js.map +1 -1
- package/dist/scene/particlesys.js +684 -0
- package/dist/scene/particlesys.js.map +1 -0
- package/dist/scene/raycast_visitor.js +34 -5
- package/dist/scene/raycast_visitor.js.map +1 -1
- package/dist/scene/scene.js +309 -85
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +675 -102
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain/grass.js +48 -49
- package/dist/scene/terrain/grass.js.map +1 -1
- package/dist/scene/terrain/heightfield.js +46 -44
- package/dist/scene/terrain/heightfield.js.map +1 -1
- package/dist/scene/terrain/patch.js +20 -29
- package/dist/scene/terrain/patch.js.map +1 -1
- package/dist/scene/terrain/quadtree.js +58 -27
- package/dist/scene/terrain/quadtree.js.map +1 -1
- package/dist/scene/terrain/terrain.js +31 -45
- package/dist/scene/terrain/terrain.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +603 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +160 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js +533 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -0
- package/dist/scene/water.js +378 -0
- package/dist/scene/water.js.map +1 -0
- package/dist/shaders/atmosphere.js +957 -0
- package/dist/shaders/atmosphere.js.map +1 -0
- package/dist/shaders/fog.js +116 -0
- package/dist/shaders/fog.js.map +1 -0
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +217 -8
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/pbr.js.map +1 -1
- package/dist/shaders/shadow.js +8 -8
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/ssr.js +87 -39
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +216 -0
- package/dist/shaders/temporal.js.map +1 -0
- package/dist/shaders/water.js +42 -20
- package/dist/shaders/water.js.map +1 -1
- package/dist/shadow/esm.js +31 -13
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +12 -13
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +12 -13
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +38 -0
- package/dist/shadow/shader.js.map +1 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadowmapper.js +67 -26
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +15 -16
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +33 -16
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/box.js +181 -83
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/cylinder.js +101 -43
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +70 -29
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/shape.js +120 -17
- package/dist/shapes/shape.js.map +1 -1
- package/dist/shapes/sphere.js +78 -44
- package/dist/shapes/sphere.js.map +1 -1
- package/dist/shapes/tetrahedron.js +256 -0
- package/dist/shapes/tetrahedron.js.map +1 -0
- package/dist/shapes/torus.js +76 -55
- 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/{app.js → src/app/app.js} +18 -40
- package/dist/src/app/app.js.map +1 -0
- package/dist/{input → src/app}/inputmgr.js +41 -16
- 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/{blitter/depthlimitedgaussion.js → src/blitter/bilateralblur.js} +1 -2
- 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/{material/mixins → src/utility/textures}/ggxlut.js +1 -1
- 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/utility/aabbtree.js +15 -5
- package/dist/utility/aabbtree.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +851 -0
- package/dist/utility/blueprint/common/constants.js.map +1 -0
- package/dist/utility/blueprint/common/math.js +2045 -0
- package/dist/utility/blueprint/common/math.js.map +1 -0
- package/dist/utility/blueprint/common.js +7 -0
- package/dist/utility/blueprint/common.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/func.js +521 -0
- package/dist/utility/blueprint/material/func.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +1659 -0
- package/dist/utility/blueprint/material/inputs.js.map +1 -0
- package/dist/utility/blueprint/material/ir.js +1311 -0
- package/dist/utility/blueprint/material/ir.js.map +1 -0
- package/dist/utility/blueprint/material/pbr.js +362 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -0
- package/dist/utility/blueprint/material/texture.js +1099 -0
- package/dist/utility/blueprint/material/texture.js.map +1 -0
- package/dist/utility/blueprint/node.js +187 -0
- package/dist/utility/blueprint/node.js.map +1 -0
- package/dist/utility/bounding_volume.js +0 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/debug.js +26 -0
- package/dist/utility/debug.js.map +1 -0
- package/dist/utility/draco/decoder.js +1 -1
- package/dist/utility/draco/decoder.js.map +1 -1
- package/dist/utility/misc.js +18 -6
- package/dist/utility/misc.js.map +1 -1
- package/dist/utility/panorama.js +8 -6
- package/dist/utility/panorama.js.map +1 -1
- package/dist/utility/pmrem.js +30 -18
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/rendermipmap.js +116 -0
- package/dist/utility/rendermipmap.js.map +1 -0
- 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/json.js +402 -0
- package/dist/utility/serialization/json.js.map +1 -0
- package/dist/utility/serialization/manager.js +1176 -0
- package/dist/utility/serialization/manager.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +699 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -0
- package/dist/utility/serialization/scene/batch.js +53 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -0
- package/dist/utility/serialization/scene/camera.js +808 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +224 -0
- package/dist/utility/serialization/scene/common.js.map +1 -0
- package/dist/utility/serialization/scene/light.js +589 -0
- package/dist/utility/serialization/scene/light.js.map +1 -0
- package/dist/utility/serialization/scene/material.js +942 -0
- package/dist/utility/serialization/scene/material.js.map +1 -0
- package/dist/utility/serialization/scene/mesh.js +374 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -0
- package/dist/utility/serialization/scene/misc.js +39 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -0
- package/dist/utility/serialization/scene/node.js +391 -0
- package/dist/utility/serialization/scene/node.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +425 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +582 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -0
- package/dist/utility/serialization/scene/scene.js +763 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -0
- package/dist/utility/serialization/scene/terrain.js +495 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +465 -0
- package/dist/utility/serialization/scene/water.js.map +1 -0
- package/dist/utility/shprojector.js +313 -0
- package/dist/utility/shprojector.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +4 -5
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/gradientnoise.js +2 -1
- package/dist/utility/textures/gradientnoise.js.map +1 -1
- package/dist/utility/textures/randomnoise.js +1 -0
- package/dist/utility/textures/randomnoise.js.map +1 -1
- package/dist/values.js +91 -4
- package/dist/values.js.map +1 -1
- package/package.json +29 -15
- package/dist/app.js.map +0 -1
- package/dist/blitter/depthlimitedgaussion.js.map +0 -1
- package/dist/input/inputmgr.js.map +0 -1
- package/dist/material/mixins/ggxlut.js.map +0 -1
- package/dist/posteffect/water.js +0 -508
- package/dist/posteffect/water.js.map +0 -1
- package/dist/render/oit.js +0 -16
- package/dist/render/oit.js.map +0 -1
- package/dist/render/scatteringlut.js +0 -634
- package/dist/render/scatteringlut.js.map +0 -1
- package/dist/render/watermesh.js +0 -193
- package/dist/render/watermesh.js.map +0 -1
- package/dist/render/wavegenerator.js +0 -8
- package/dist/render/wavegenerator.js.map +0 -1
- package/dist/scene/xform.js +0 -247
- package/dist/scene/xform.js.map +0 -1
- package/dist/utility/shprojection.js +0 -442
- package/dist/utility/shprojection.js.map +0 -1
package/dist/scene/scene_node.js
CHANGED
|
@@ -1,97 +1,334 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { makeObservable, Disposable, randomUUID, DRef, ObservableVector3, ObservableQuaternion, Matrix4x4, Vector3, Vector4 } from '@zephyr3d/base';
|
|
2
|
+
import { AnimationSet } from '../animation/animationset.js';
|
|
3
|
+
import '../animation/eulerrotationtrack.js';
|
|
4
|
+
import '../values.js';
|
|
5
|
+
import { getEngine } from '../app/api.js';
|
|
6
|
+
import '../animation/skeleton.js';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
|
-
* The base class
|
|
9
|
+
* The base class of all scene graph objects.
|
|
5
10
|
*
|
|
6
11
|
* @remarks
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* Responsibilities:
|
|
13
|
+
* - Defines hierarchical transform (position, rotation, scale) with lazily computed matrices.
|
|
14
|
+
* - Integrates with the scene graph (parent/children, attachment notifications).
|
|
15
|
+
* - Provides traversal utilities (`iterate`, `iterateBottomToTop`, `traverse`).
|
|
16
|
+
* - Manages visibility state and CPU/GPU picking flags.
|
|
17
|
+
* - Computes and caches local/world bounding volumes, notifies scene for spatial updates.
|
|
18
|
+
* - Supports cloning and shared model instancing.
|
|
19
|
+
* - Emits events on visibility, transform, bounding volume, attachment, and disposal.
|
|
20
|
+
*
|
|
21
|
+
* Performance:
|
|
22
|
+
* - `localMatrix`, `worldMatrix`, and `invWorldMatrix` are cached until invalidated.
|
|
23
|
+
* - Transform mutations and `invalidateBoundingVolume` update caches and spatial structures.
|
|
24
|
+
*
|
|
25
|
+
* Events:
|
|
26
|
+
* - `nodeattached`, `noderemoved`, `visiblechanged`, `transformchanged`, `bvchanged`, `dispose`.
|
|
12
27
|
*
|
|
13
28
|
* @public
|
|
14
|
-
*/ class SceneNode extends
|
|
29
|
+
*/ class SceneNode extends makeObservable(Disposable)() {
|
|
30
|
+
static _runTimeId = 1;
|
|
15
31
|
/*
|
|
16
32
|
static readonly PICK_INHERITED = -1;
|
|
17
33
|
static readonly PICK_DISABLED = 0;
|
|
18
34
|
static readonly PICK_ENABLED = 1;
|
|
19
|
-
*/ static BBOXDRAW_INHERITED = -1;
|
|
20
|
-
static BBOXDRAW_DISABLED = 0;
|
|
21
|
-
static BBOXDRAW_LOCAL = 1;
|
|
22
|
-
static BBOXDRAW_WORLD = 2;
|
|
23
|
-
/** @internal */
|
|
24
|
-
/** @internal */
|
|
25
|
-
/** @internal */
|
|
26
|
-
/** @internal */
|
|
27
|
-
/** @internal */
|
|
28
|
-
/** @internal */
|
|
29
|
-
/** @internal */
|
|
30
|
-
/** @internal */
|
|
31
|
-
/** @internal */
|
|
32
|
-
/** @internal */
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
*/ /** Bounding-box draw mode inherited from nearest graph ancestor. */ static BBOXDRAW_INHERITED = -1;
|
|
36
|
+
/** Disable bounding-box visualization. */ static BBOXDRAW_DISABLED = 0;
|
|
37
|
+
/** Draw local-space bounding box. */ static BBOXDRAW_LOCAL = 1;
|
|
38
|
+
/** Draw world-space bounding box. */ static BBOXDRAW_WORLD = 2;
|
|
39
|
+
/** @internal Runtime unique id. */ _runtimeId;
|
|
40
|
+
/** @internal Unique persistent id. */ _id;
|
|
41
|
+
/** @internal Prefab id */ _prefabId;
|
|
42
|
+
/** @internal Animation set reference. */ _animationSet;
|
|
43
|
+
/** @internal Optional shared model reference for instancing. */ _sharedModel;
|
|
44
|
+
/** @internal */ _jointTypeT;
|
|
45
|
+
/** @internal */ _jointTypeS;
|
|
46
|
+
/** @internal */ _jointTypeR;
|
|
47
|
+
/** @internal Clip test flag used by renderer. */ _clipMode;
|
|
48
|
+
/** @internal Bounding-box visualization mode. */ _boxDrawMode;
|
|
49
|
+
/** @internal Visibility state ('visible'|'hidden'|'inherit'). */ _visible;
|
|
50
|
+
/** @internal CPU picking flag. */ _pickable;
|
|
51
|
+
/** @internal GPU picking flag. */ _gpuPickable;
|
|
52
|
+
/** @internal Friendly name for debugging/UI. */ _name;
|
|
53
|
+
/** @internal Owning scene. */ _scene;
|
|
54
|
+
/** @internal Local-space bounding volume cache. */ _bv;
|
|
55
|
+
/** @internal True if local BV needs recomputing. */ _bvDirty;
|
|
56
|
+
/** @internal World-space bounding volume cache. */ _bvWorld;
|
|
57
|
+
/** @internal Whether this node participates in scene spatial structures (octree). */ _placeToOctree;
|
|
58
|
+
/** @internal If true, this node cannot be cloned/attached as a child (engine policy). */ _sealed;
|
|
59
|
+
/** @internal Parent node. */ _parent;
|
|
60
|
+
/** @internal Children list (DRef for memory/resource mgmt). */ _children;
|
|
61
|
+
/** @internal Local position (observable). */ _position;
|
|
62
|
+
/** @internal Local scale (observable). */ _scaling;
|
|
63
|
+
/** @internal Local rotation (observable quaternion). */ _rotation;
|
|
64
|
+
/** @internal Local transform matrix cache. */ _localMatrix;
|
|
65
|
+
/** @internal World transform matrix cache. */ _worldMatrix;
|
|
66
|
+
/** @internal Determinant of world transform (cached). */ _worldMatrixDet;
|
|
67
|
+
/** @internal Inverse world transform matrix cache. */ _invWorldMatrix;
|
|
68
|
+
/** @internal Scratch local matrix to avoid allocations. */ _tmpLocalMatrix;
|
|
69
|
+
/** @internal Scratch world matrix to avoid allocations. */ _tmpWorldMatrix;
|
|
70
|
+
/** @internal Monotonically increasing tag for transform changes. */ _transformTag;
|
|
71
|
+
/** @internal Shared callback used by observables on transform mutation. */ _transformChangeCallback;
|
|
72
|
+
/** @internal Arbitrary metadata payload for this node. */ _metaData;
|
|
73
|
+
/** @internal If true, suppress transform-change callbacks (during bulk updates). */ _disableCallback;
|
|
74
|
+
/** @internal User-attached script entry (engine-defined). */ _script;
|
|
75
|
+
/**
|
|
76
|
+
* Construct a scene node.
|
|
77
|
+
*
|
|
78
|
+
* @remarks
|
|
79
|
+
* If a `scene` is provided and this is not the root node, the node is reparented
|
|
80
|
+
* under the scene's root immediately.
|
|
81
|
+
*
|
|
82
|
+
* @param scene - Scene that will own this node.
|
|
36
83
|
*/ constructor(scene){
|
|
37
84
|
super();
|
|
85
|
+
this._runtimeId = SceneNode._runTimeId++;
|
|
86
|
+
this._id = randomUUID();
|
|
87
|
+
this._prefabId = '';
|
|
38
88
|
this._scene = scene;
|
|
39
89
|
this._name = '';
|
|
90
|
+
this._animationSet = new DRef();
|
|
91
|
+
this._sharedModel = new DRef();
|
|
92
|
+
this._jointTypeT = 'none';
|
|
93
|
+
this._jointTypeS = 'none';
|
|
94
|
+
this._jointTypeR = 'none';
|
|
40
95
|
this._bv = null;
|
|
41
96
|
this._bvWorld = null;
|
|
42
97
|
this._bvDirty = true;
|
|
43
98
|
this._clipMode = true;
|
|
44
99
|
this._boxDrawMode = SceneNode.BBOXDRAW_DISABLED;
|
|
45
100
|
this._visible = 'inherit';
|
|
46
|
-
this.
|
|
101
|
+
this._pickable = false;
|
|
102
|
+
this._gpuPickable = true;
|
|
47
103
|
this._placeToOctree = true;
|
|
104
|
+
this._parent = null;
|
|
105
|
+
this._sealed = false;
|
|
106
|
+
this._children = [];
|
|
107
|
+
this._transformChangeCallback = ()=>this._onTransformChanged(true);
|
|
108
|
+
this._position = new ObservableVector3(0, 0, 0);
|
|
109
|
+
this._position.callback = this._transformChangeCallback;
|
|
110
|
+
this._scaling = new ObservableVector3(1, 1, 1);
|
|
111
|
+
this._scaling.callback = this._transformChangeCallback;
|
|
112
|
+
this._rotation = new ObservableQuaternion();
|
|
113
|
+
this._rotation.callback = this._transformChangeCallback;
|
|
114
|
+
this._worldMatrix = null;
|
|
115
|
+
this._worldMatrixDet = null;
|
|
116
|
+
this._invWorldMatrix = null;
|
|
117
|
+
this._localMatrix = null;
|
|
118
|
+
this._transformTag = 0;
|
|
119
|
+
this._disableCallback = false;
|
|
120
|
+
this._tmpLocalMatrix = Matrix4x4.identity();
|
|
121
|
+
this._tmpWorldMatrix = Matrix4x4.identity();
|
|
122
|
+
this._script = '';
|
|
123
|
+
this._metaData = null;
|
|
48
124
|
if (scene && this !== scene.rootNode) {
|
|
49
125
|
this.reparent(scene.rootNode);
|
|
50
126
|
}
|
|
51
127
|
}
|
|
52
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Whether the node should be inserted into the scene's spatial structure.
|
|
130
|
+
*
|
|
131
|
+
* @remarks
|
|
132
|
+
* Toggling this hints the scene to (re)place the node in octree/acceleration structures.
|
|
133
|
+
*/ get placeToOctree() {
|
|
53
134
|
return this._placeToOctree;
|
|
54
135
|
}
|
|
55
136
|
set placeToOctree(val) {
|
|
56
137
|
if (!!val !== this._placeToOctree) {
|
|
57
138
|
this._placeToOctree = !!val;
|
|
58
139
|
if (this.isGraphNode()) {
|
|
59
|
-
this.scene
|
|
140
|
+
this.scene?.invalidateNodePlacement(this);
|
|
60
141
|
}
|
|
61
142
|
}
|
|
62
143
|
}
|
|
63
144
|
/**
|
|
64
|
-
*
|
|
145
|
+
* Node's runtime unique identifier
|
|
146
|
+
*/ get runtimeId() {
|
|
147
|
+
return this._runtimeId;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Node's persistent identifier.
|
|
151
|
+
*
|
|
152
|
+
* @remarks
|
|
153
|
+
* Changing this affects serialization and registry lookup; ensure uniqueness.
|
|
154
|
+
*/ get persistentId() {
|
|
155
|
+
return this._id;
|
|
156
|
+
}
|
|
157
|
+
set persistentId(id) {
|
|
158
|
+
this._id = id;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* If not empty, this node was loaded from a prefab
|
|
162
|
+
*
|
|
163
|
+
* @remarks
|
|
164
|
+
* Internal used for serialization
|
|
165
|
+
*/ get prefabId() {
|
|
166
|
+
return this._prefabId;
|
|
167
|
+
}
|
|
168
|
+
set prefabId(id) {
|
|
169
|
+
this._prefabId = id;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Get prefab node this node belongs to, or null if this node does not belongs to any prefab
|
|
173
|
+
* @returns prefab node this node belongs to
|
|
174
|
+
*/ getPrefabNode() {
|
|
175
|
+
return this._prefabId ? this : this.parent?.getPrefabNode() ?? null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Translation type if this is a joint node of any skeleton
|
|
179
|
+
*
|
|
180
|
+
* @remarks
|
|
181
|
+
* Internal used for serialization
|
|
182
|
+
*/ get jointTypeT() {
|
|
183
|
+
return this._jointTypeT;
|
|
184
|
+
}
|
|
185
|
+
set jointTypeT(val) {
|
|
186
|
+
this._jointTypeT = val;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Scale type if this is a joint node of any skeleton
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* Internal used for serialization
|
|
193
|
+
*/ get jointTypeS() {
|
|
194
|
+
return this._jointTypeS;
|
|
195
|
+
}
|
|
196
|
+
set jointTypeS(val) {
|
|
197
|
+
this._jointTypeS = val;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Rotation type if this is a joint node of any skeleton
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* Internal used for serialization
|
|
204
|
+
*/ get jointTypeR() {
|
|
205
|
+
return this._jointTypeR;
|
|
206
|
+
}
|
|
207
|
+
set jointTypeR(val) {
|
|
208
|
+
this._jointTypeR = val;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Arbitrary metadata associated with this node.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* Stored and transported with the node; format is application-defined.
|
|
215
|
+
*/ get metaData() {
|
|
216
|
+
return this._metaData;
|
|
217
|
+
}
|
|
218
|
+
set metaData(val) {
|
|
219
|
+
this._metaData = val;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Attached script filename or identifier (engine-specific).
|
|
223
|
+
*
|
|
224
|
+
* @remarks
|
|
225
|
+
* Integrates with the engine’s scripting system if available.
|
|
226
|
+
*/ get script() {
|
|
227
|
+
return this._script;
|
|
228
|
+
}
|
|
229
|
+
set script(fileName) {
|
|
230
|
+
this._script = fileName ?? '';
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Display name of the node (for UI/debugging).
|
|
65
234
|
*/ get name() {
|
|
66
235
|
return this._name;
|
|
67
236
|
}
|
|
68
237
|
set name(val) {
|
|
69
238
|
this._name = val || '';
|
|
70
239
|
}
|
|
71
|
-
/** The scene
|
|
240
|
+
/** The owning scene. */ get scene() {
|
|
72
241
|
return this._scene;
|
|
73
242
|
}
|
|
74
|
-
/**
|
|
75
|
-
|
|
243
|
+
/**
|
|
244
|
+
* Whether this node is currently attached under the scene's root.
|
|
245
|
+
*/ get attached() {
|
|
246
|
+
let node = this;
|
|
247
|
+
while(node && node !== this._scene.rootNode){
|
|
248
|
+
node = node.parent;
|
|
249
|
+
}
|
|
250
|
+
return node === this._scene.rootNode;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* If true, the node is logically sealed; some operations (like cloning as child)
|
|
254
|
+
* may be restricted by engine policies.
|
|
255
|
+
*/ get sealed() {
|
|
256
|
+
return this._sealed;
|
|
257
|
+
}
|
|
258
|
+
set sealed(val) {
|
|
259
|
+
this._sealed = val;
|
|
76
260
|
}
|
|
77
261
|
/**
|
|
78
|
-
*
|
|
262
|
+
* Lazily created animation set for this node.
|
|
263
|
+
*
|
|
264
|
+
* @remarks
|
|
265
|
+
* Accessing this schedules the node for update in the scene.
|
|
266
|
+
*/ get animationSet() {
|
|
267
|
+
if (!this._animationSet.get()) {
|
|
268
|
+
this._animationSet.set(new AnimationSet(this));
|
|
269
|
+
this.scene.queueUpdateNode(this);
|
|
270
|
+
}
|
|
271
|
+
return this._animationSet.get();
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Shared model reference for instancing/streaming systems.
|
|
275
|
+
*/ get sharedModel() {
|
|
276
|
+
return this._sharedModel.get();
|
|
277
|
+
}
|
|
278
|
+
set sharedModel(model) {
|
|
279
|
+
this._sharedModel.set(model);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Clone this node.
|
|
283
|
+
*
|
|
284
|
+
* @remarks
|
|
285
|
+
* If a shared model exists, it may create an instanced node. The clone is
|
|
286
|
+
* attached under the same parent; children are cloned based on `method` and `recursive`.
|
|
287
|
+
*
|
|
288
|
+
* @param method - Clone method ('deep' or 'instance').
|
|
289
|
+
* @param recursive - Whether children are cloned recursively.
|
|
290
|
+
* @returns New node instance
|
|
291
|
+
*/ async clone() {
|
|
292
|
+
this.iterate((node)=>{
|
|
293
|
+
if (node.isTerrain() || node.isClipmapTerrain()) {
|
|
294
|
+
throw new Error('Cloning terrain node is not allowed');
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
const parent = this.parent;
|
|
298
|
+
const tmpParent = new SceneNode(this.scene);
|
|
299
|
+
const data = await getEngine().resourceManager.serializeObject(this);
|
|
300
|
+
const other = await getEngine().resourceManager.deserializeObject(tmpParent, data);
|
|
301
|
+
other.persistentId = randomUUID();
|
|
302
|
+
other.parent = parent;
|
|
303
|
+
tmpParent.dispose();
|
|
304
|
+
const postClonePromises = [];
|
|
305
|
+
other.iterate((node)=>{
|
|
306
|
+
const P = node.onPostClone();
|
|
307
|
+
if (P instanceof Promise) {
|
|
308
|
+
postClonePromises.push(P);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
if (postClonePromises.length > 0) {
|
|
312
|
+
await Promise.all(postClonePromises);
|
|
313
|
+
}
|
|
314
|
+
return other;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Whether the given node is a direct child of this node.
|
|
79
318
|
* @param child - The node to be checked
|
|
80
319
|
* @returns true if the given node is a direct child of this node, false otherwise
|
|
81
320
|
*/ hasChild(child) {
|
|
82
|
-
return
|
|
321
|
+
return child && child.parent === this;
|
|
83
322
|
}
|
|
84
323
|
/**
|
|
85
|
-
*
|
|
324
|
+
* Remove all children from this node.
|
|
86
325
|
*/ removeChildren() {
|
|
87
326
|
while(this._children.length){
|
|
88
|
-
this._children[0].remove();
|
|
327
|
+
this._children[0].get().remove();
|
|
89
328
|
}
|
|
90
329
|
}
|
|
91
330
|
/**
|
|
92
|
-
*
|
|
93
|
-
* @param child - The node to be checked
|
|
94
|
-
* @returns true if this node is the direct parent or indirect parent of the given node, false otherwise
|
|
331
|
+
* Whether this node is an ancestor (direct or indirect) of the given node.
|
|
95
332
|
*/ isParentOf(child) {
|
|
96
333
|
while(child && child !== this){
|
|
97
334
|
child = child.parent;
|
|
@@ -99,55 +336,82 @@ import { XForm } from './xform.js';
|
|
|
99
336
|
return child === this;
|
|
100
337
|
}
|
|
101
338
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
339
|
+
* Detach this node from its parent.
|
|
340
|
+
*
|
|
341
|
+
* @returns this
|
|
104
342
|
*/ remove() {
|
|
105
343
|
this.parent = null;
|
|
106
344
|
return this;
|
|
107
345
|
}
|
|
108
346
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @param
|
|
112
|
-
*/ traverse(v
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
v.visit(this);
|
|
118
|
-
} else {
|
|
119
|
-
v.visit(this);
|
|
120
|
-
for (const child of this._children){
|
|
121
|
-
child.traverse(v);
|
|
122
|
-
}
|
|
347
|
+
* Depth-first traversal of this node's subtree (pre-order).
|
|
348
|
+
*
|
|
349
|
+
* @param v - Visitor invoked on each node.
|
|
350
|
+
*/ traverse(v) {
|
|
351
|
+
v.visit(this);
|
|
352
|
+
for (const child of this._children){
|
|
353
|
+
child.get().traverse(v);
|
|
123
354
|
}
|
|
124
355
|
}
|
|
125
356
|
/**
|
|
126
|
-
* Iterate self and
|
|
357
|
+
* Iterate self and descendants in pre-order.
|
|
127
358
|
*
|
|
128
|
-
*
|
|
129
|
-
* DO NOT remove child duration iteration!
|
|
359
|
+
* Warning: Do not remove children during this iteration. To allow removal, use `iterateBottomToTop`.
|
|
130
360
|
*
|
|
131
|
-
* @param callback -
|
|
361
|
+
* @param callback - Called for each node; if returns true, iteration stops.
|
|
362
|
+
* @returns true if iteration was aborted early.
|
|
132
363
|
*/ iterate(callback) {
|
|
133
|
-
callback(this)
|
|
364
|
+
if (callback(this)) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
134
367
|
for (const child of this._children){
|
|
135
|
-
child.iterate(callback)
|
|
368
|
+
if (child.get().iterate(callback)) {
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Iterate self and descendants in reverse post-order (bottom-to-top).
|
|
376
|
+
*
|
|
377
|
+
* Child nodes can be safely removed during this iteration.
|
|
378
|
+
*
|
|
379
|
+
* @param callback - Called for each node; if returns true, iteration stops.
|
|
380
|
+
* @returns true if iteration was aborted early.
|
|
381
|
+
*/ iterateBottomToTop(callback) {
|
|
382
|
+
for(let i = this._children.length - 1; i >= 0; i--){
|
|
383
|
+
const child = this._children[i];
|
|
384
|
+
if (child.get().iterateBottomToTop(callback)) {
|
|
385
|
+
return true;
|
|
386
|
+
}
|
|
136
387
|
}
|
|
388
|
+
if (callback(this)) {
|
|
389
|
+
return true;
|
|
390
|
+
}
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
/** Type guard: true if this node is a graph node. */ isGraphNode() {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
/** Type guard: true if this node is a light. */ isLight() {
|
|
397
|
+
return false;
|
|
137
398
|
}
|
|
138
|
-
/** true if this is a
|
|
399
|
+
/** Type guard: true if this node is a mesh. */ isMesh() {
|
|
139
400
|
return false;
|
|
140
401
|
}
|
|
141
|
-
/** true if this is a
|
|
402
|
+
/** Type guard: true if this node is a water node. */ isWater() {
|
|
142
403
|
return false;
|
|
143
404
|
}
|
|
144
|
-
/** true if this is a
|
|
405
|
+
/** Type guard: true if this node is a particle system. */ isParticleSystem() {
|
|
145
406
|
return false;
|
|
146
407
|
}
|
|
147
|
-
/** true if this is a batch group
|
|
408
|
+
/** Type guard: true if this node is a batch group. */ isBatchGroup() {
|
|
148
409
|
return false;
|
|
149
410
|
}
|
|
150
|
-
/** true if this is a terrain
|
|
411
|
+
/** Type guard: true if this node is a terrain. */ isTerrain() {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
/** Type guard: true if this node is a clipmap terrain. */ isClipmapTerrain() {
|
|
151
415
|
return false;
|
|
152
416
|
}
|
|
153
417
|
/** true if this is a camera node, false otherwise */ isCamera() {
|
|
@@ -156,10 +420,6 @@ import { XForm } from './xform.js';
|
|
|
156
420
|
/** true if this is a punctual light node, false otherwise */ isPunctualLight() {
|
|
157
421
|
return false;
|
|
158
422
|
}
|
|
159
|
-
/** Disposes the node */ dispose() {
|
|
160
|
-
this.remove();
|
|
161
|
-
this.removeChildren();
|
|
162
|
-
}
|
|
163
423
|
/**
|
|
164
424
|
* Computes the bounding volume of the node
|
|
165
425
|
* @returns The output bounding volume
|
|
@@ -191,11 +451,17 @@ import { XForm } from './xform.js';
|
|
|
191
451
|
* @returns The world space bounding volume of the node
|
|
192
452
|
*/ getWorldBoundingVolume() {
|
|
193
453
|
if (!this._bvWorld) {
|
|
194
|
-
this._bvWorld = this.
|
|
454
|
+
this._bvWorld = this.computeWorldBoundingVolume(this.getBoundingVolume());
|
|
195
455
|
}
|
|
196
456
|
return this._bvWorld;
|
|
197
457
|
}
|
|
198
458
|
/**
|
|
459
|
+
* Computes the world space bounding volume of the node
|
|
460
|
+
* @returns The output bounding volume
|
|
461
|
+
*/ computeWorldBoundingVolume(localBV) {
|
|
462
|
+
return localBV?.transform(this.worldMatrix) ?? null;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
199
465
|
* Force the bounding volume to be recalculated
|
|
200
466
|
*/ invalidateBoundingVolume() {
|
|
201
467
|
this._bvDirty = true;
|
|
@@ -213,7 +479,7 @@ import { XForm } from './xform.js';
|
|
|
213
479
|
} else if (this.isGraphNode()) {
|
|
214
480
|
this._scene.invalidateNodePlacement(this);
|
|
215
481
|
}
|
|
216
|
-
this.dispatchEvent(
|
|
482
|
+
this.dispatchEvent('bvchanged', this);
|
|
217
483
|
}
|
|
218
484
|
}
|
|
219
485
|
/** Clip mode */ get clipTestEnabled() {
|
|
@@ -238,17 +504,79 @@ import { XForm } from './xform.js';
|
|
|
238
504
|
this._visible = val;
|
|
239
505
|
if (prevHidden !== this.hidden) {
|
|
240
506
|
if (this.isGraphNode()) {
|
|
241
|
-
this._scene
|
|
507
|
+
this._scene?.invalidateNodePlacement(this);
|
|
508
|
+
}
|
|
509
|
+
let parent = this;
|
|
510
|
+
while(parent){
|
|
511
|
+
parent.dispatchEvent('visiblechanged', this);
|
|
512
|
+
parent = parent.parent;
|
|
242
513
|
}
|
|
243
514
|
this.notifyHiddenChanged();
|
|
244
515
|
}
|
|
245
516
|
}
|
|
246
517
|
}
|
|
247
|
-
/**
|
|
248
|
-
return this.
|
|
518
|
+
/** Whether this node is enabled for CPU picking */ get pickable() {
|
|
519
|
+
return this._pickable;
|
|
249
520
|
}
|
|
250
521
|
set pickable(val) {
|
|
251
|
-
this.
|
|
522
|
+
this._pickable = !!val;
|
|
523
|
+
}
|
|
524
|
+
/** Whether this node is enabled for GPU picking */ get gpuPickable() {
|
|
525
|
+
return this._gpuPickable;
|
|
526
|
+
}
|
|
527
|
+
set gpuPickable(val) {
|
|
528
|
+
this._gpuPickable = !!val;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Finds a scene node by its persistent ID.
|
|
532
|
+
*
|
|
533
|
+
* @typeParam T - Expected node type.
|
|
534
|
+
* @param id - Persistent identifier to match against `SceneNode.persistentId`.
|
|
535
|
+
* @returns The first matching node, or `null` if not found.
|
|
536
|
+
*/ findNodeById(id) {
|
|
537
|
+
let node = null;
|
|
538
|
+
this.iterate((child)=>{
|
|
539
|
+
if (child.persistentId === id) {
|
|
540
|
+
node = child;
|
|
541
|
+
return true;
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
return node;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Finds a skeleton object by its persistent ID.
|
|
548
|
+
* @param id - Persistent identifier to match against `Skeleton.persistentId`.
|
|
549
|
+
* @returns The first matchign node, or `null` if not found.
|
|
550
|
+
*/ findSkeletonById(id) {
|
|
551
|
+
const prefabNode = this.getPrefabNode() ?? this;
|
|
552
|
+
let sk = null;
|
|
553
|
+
prefabNode.iterate((node)=>{
|
|
554
|
+
sk = node.animationSet.skeletons.find((s)=>s.get().persistentId === id);
|
|
555
|
+
return !!sk;
|
|
556
|
+
});
|
|
557
|
+
return sk?.get() ?? null;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Finds a scene node by name.
|
|
561
|
+
*
|
|
562
|
+
* If multiple nodes share the same name, returns the first match encountered
|
|
563
|
+
* during traversal.
|
|
564
|
+
*
|
|
565
|
+
* @typeParam T - Expected node type.
|
|
566
|
+
* @param name - Node name to match.
|
|
567
|
+
* @returns The first matching node, or `null` if not found.
|
|
568
|
+
*
|
|
569
|
+
* @remarks
|
|
570
|
+
* Names are not guaranteed unique. Prefer IDs for stable references.
|
|
571
|
+
*/ findNodeByName(name) {
|
|
572
|
+
let node = null;
|
|
573
|
+
this.iterate((child)=>{
|
|
574
|
+
if (child.name === name) {
|
|
575
|
+
node = child;
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
return node;
|
|
252
580
|
}
|
|
253
581
|
/** Computed value for bounding box draw mode */ get computedBoundingBoxDrawMode() {
|
|
254
582
|
if (this._boxDrawMode === SceneNode.BBOXDRAW_INHERITED) {
|
|
@@ -266,48 +594,293 @@ import { XForm } from './xform.js';
|
|
|
266
594
|
set boundingBoxDrawMode(mode) {
|
|
267
595
|
this._boxDrawMode = mode;
|
|
268
596
|
}
|
|
597
|
+
/** Get called when the node was just created by cloning from other node */ onPostClone() {}
|
|
598
|
+
/** Disposes the node */ onDispose() {
|
|
599
|
+
super.onDispose();
|
|
600
|
+
this.remove();
|
|
601
|
+
this.removeChildren();
|
|
602
|
+
this._animationSet?.dispose();
|
|
603
|
+
this._animationSet = null;
|
|
604
|
+
this._sharedModel?.dispose();
|
|
605
|
+
this._sharedModel = null;
|
|
606
|
+
}
|
|
269
607
|
/** @internal */ _setParent(p) {
|
|
608
|
+
if (p && p._scene !== this._scene) {
|
|
609
|
+
throw new Error('Parent node and child node must belongs to the same scene');
|
|
610
|
+
}
|
|
270
611
|
let lastParent = this._parent;
|
|
271
612
|
let newParent = p;
|
|
272
613
|
if (newParent !== lastParent) {
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
614
|
+
const willDetach = (!p || !p.attached) && this.attached;
|
|
615
|
+
const willAttach = !this.attached && p && p.attached;
|
|
616
|
+
if (newParent) {
|
|
617
|
+
newParent._children.push(new DRef(this));
|
|
618
|
+
}
|
|
619
|
+
if (this._parent) {
|
|
620
|
+
const index = this._parent._children.findIndex((val)=>val.get() === this);
|
|
621
|
+
this._parent.children[index].dispose();
|
|
622
|
+
this._parent._children.splice(index, 1);
|
|
623
|
+
}
|
|
624
|
+
this._parent = p;
|
|
625
|
+
this._onTransformChanged(false);
|
|
626
|
+
if (willDetach) {
|
|
627
|
+
this._detached();
|
|
628
|
+
}
|
|
629
|
+
if (willAttach) {
|
|
630
|
+
this._attached();
|
|
631
|
+
}
|
|
632
|
+
while(lastParent){
|
|
633
|
+
lastParent.dispatchEvent('noderemoved', this);
|
|
634
|
+
lastParent = lastParent.parent;
|
|
635
|
+
}
|
|
636
|
+
while(newParent){
|
|
637
|
+
newParent.dispatchEvent('nodeattached', this);
|
|
638
|
+
newParent = newParent.parent;
|
|
639
|
+
}
|
|
290
640
|
}
|
|
291
641
|
}
|
|
292
642
|
/** @internal */ _onTransformChanged(invalidateLocal) {
|
|
293
|
-
|
|
643
|
+
if (this._disableCallback) {
|
|
644
|
+
return;
|
|
645
|
+
}
|
|
646
|
+
if (invalidateLocal) {
|
|
647
|
+
this._localMatrix = null;
|
|
648
|
+
}
|
|
649
|
+
this._worldMatrix = null;
|
|
650
|
+
this._invWorldMatrix = null;
|
|
651
|
+
this._worldMatrixDet = null;
|
|
652
|
+
this._transformTag++;
|
|
653
|
+
for (const child of this._children){
|
|
654
|
+
child.get()._onTransformChanged(false);
|
|
655
|
+
}
|
|
294
656
|
this.invalidateWorldBoundingVolume(true);
|
|
295
|
-
this.dispatchEvent(
|
|
657
|
+
this.dispatchEvent('transformchanged', this);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Get called when this node is attached to scene
|
|
661
|
+
*/ _onAttached() {}
|
|
662
|
+
/**
|
|
663
|
+
* Get called when this node is detached from scene
|
|
664
|
+
*/ _onDetached() {}
|
|
665
|
+
/** @internal */ _attached() {
|
|
666
|
+
this.iterate((child)=>{
|
|
667
|
+
this.scene.queueUpdateNode(child);
|
|
668
|
+
child._onAttached();
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
/** @internal */ _detached() {
|
|
672
|
+
this.iterate((child)=>{
|
|
673
|
+
child._onDetached();
|
|
674
|
+
});
|
|
296
675
|
}
|
|
297
|
-
/** @internal */ _willAttach() {}
|
|
298
|
-
/** @internal */ _attached() {}
|
|
299
|
-
/** @internal */ _willDetach() {}
|
|
300
|
-
/** @internal */ _detached() {}
|
|
301
676
|
/** @internal */ notifyHiddenChanged() {
|
|
302
677
|
this._visibleChanged();
|
|
303
|
-
this.dispatchEvent(this, 'visiblechanged');
|
|
304
678
|
for (const child of this._children){
|
|
305
|
-
if (child.showState === 'inherit') {
|
|
306
|
-
child.notifyHiddenChanged();
|
|
679
|
+
if (child.get().showState === 'inherit') {
|
|
680
|
+
child.get().notifyHiddenChanged();
|
|
307
681
|
}
|
|
308
682
|
}
|
|
309
683
|
}
|
|
310
684
|
/** @internal */ _visibleChanged() {}
|
|
685
|
+
/** Parent of the xform */ get parent() {
|
|
686
|
+
return this._parent;
|
|
687
|
+
}
|
|
688
|
+
set parent(p) {
|
|
689
|
+
p = p || null;
|
|
690
|
+
if (p !== this._parent) {
|
|
691
|
+
this._setParent(p);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/** Children of this xform */ get children() {
|
|
695
|
+
return this._children;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Position of the xform relative to it's parent
|
|
699
|
+
*/ get position() {
|
|
700
|
+
return this._position;
|
|
701
|
+
}
|
|
702
|
+
set position(val) {
|
|
703
|
+
this._position.setXYZ(val[0], val[1], val[2]);
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Scaling of the xform
|
|
707
|
+
*/ get scale() {
|
|
708
|
+
return this._scaling;
|
|
709
|
+
}
|
|
710
|
+
set scale(val) {
|
|
711
|
+
this._scaling.setXYZ(val[0], val[1], val[2]);
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Rotation of the xform
|
|
715
|
+
*/ get rotation() {
|
|
716
|
+
return this._rotation;
|
|
717
|
+
}
|
|
718
|
+
set rotation(val) {
|
|
719
|
+
this._rotation.setXYZW(val[0], val[1], val[2], val[3]);
|
|
720
|
+
}
|
|
721
|
+
worldToThis(v, result) {
|
|
722
|
+
if (v instanceof Vector3) {
|
|
723
|
+
result = result || new Vector3();
|
|
724
|
+
this.invWorldMatrix.transformPointAffine(v, result);
|
|
725
|
+
return result;
|
|
726
|
+
} else {
|
|
727
|
+
result = result || new Vector4();
|
|
728
|
+
this.invWorldMatrix.transformAffine(v, result);
|
|
729
|
+
return result;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
otherToThis(other, v, result) {
|
|
733
|
+
return this.worldToThis(other.thisToWorld(v, result), result);
|
|
734
|
+
}
|
|
735
|
+
thisToWorld(v, result) {
|
|
736
|
+
if (v instanceof Vector3) {
|
|
737
|
+
result = result || new Vector3();
|
|
738
|
+
this.worldMatrix.transformPointAffine(v, result);
|
|
739
|
+
return result;
|
|
740
|
+
} else {
|
|
741
|
+
result = result || new Vector4();
|
|
742
|
+
this.worldMatrix.transformAffine(v, result);
|
|
743
|
+
return result;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
thisToOther(other, v, result) {
|
|
747
|
+
return other.worldToThis(this.thisToWorld(v, result), result);
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Gets the position of the xform in world space
|
|
751
|
+
* @returns position of the xform in world space
|
|
752
|
+
*/ getWorldPosition(outPos) {
|
|
753
|
+
return outPos?.setXYZ(this.worldMatrix.m03, this.worldMatrix.m13, this.worldMatrix.m23) ?? new Vector3(this.worldMatrix.m03, this.worldMatrix.m13, this.worldMatrix.m23);
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Moves the xform by an offset vector
|
|
757
|
+
* @param delta - The offset vector
|
|
758
|
+
* @returns self
|
|
759
|
+
*/ moveBy(delta) {
|
|
760
|
+
this._position.addBy(delta);
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Scales the xform by a given scale factor
|
|
765
|
+
* @param factor - The scale factor
|
|
766
|
+
* @returns self
|
|
767
|
+
*/ scaleBy(factor) {
|
|
768
|
+
this._scaling.mulBy(factor);
|
|
769
|
+
return this;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Sets the local transform matrix of the xform
|
|
773
|
+
* @param matrix - The transform matrix to set
|
|
774
|
+
* @returns self
|
|
775
|
+
*/ setLocalTransform(matrix) {
|
|
776
|
+
this._disableCallback = true;
|
|
777
|
+
matrix.decompose(this._scaling, this._rotation, this._position);
|
|
778
|
+
this._disableCallback = false;
|
|
779
|
+
this._onTransformChanged(true);
|
|
780
|
+
/*
|
|
781
|
+
this._localMatrix = matrix;
|
|
782
|
+
this._disableCallback = true;
|
|
783
|
+
this._localMatrix.decompose(this._scaling, this._rotation, this._position);
|
|
784
|
+
this._disableCallback = false;
|
|
785
|
+
this._onTransformChanged(false);
|
|
786
|
+
*/ return this;
|
|
787
|
+
}
|
|
788
|
+
/** Local transformation matrix of the xform */ get localMatrix() {
|
|
789
|
+
if (!this._localMatrix) {
|
|
790
|
+
this.calculateLocalTransform(this._tmpLocalMatrix);
|
|
791
|
+
this._localMatrix = this._tmpLocalMatrix;
|
|
792
|
+
/*
|
|
793
|
+
this._localMatrix
|
|
794
|
+
.scaling(this._scaling)
|
|
795
|
+
.rotateLeft(new Matrix4x4(this._rotation))
|
|
796
|
+
.translateLeft(this._position);
|
|
797
|
+
*/ }
|
|
798
|
+
return this._localMatrix;
|
|
799
|
+
}
|
|
800
|
+
set localMatrix(matrix) {
|
|
801
|
+
this.setLocalTransform(matrix);
|
|
802
|
+
}
|
|
803
|
+
/** World transformation matrix of the xform */ get worldMatrix() {
|
|
804
|
+
if (!this._worldMatrix) {
|
|
805
|
+
this._worldMatrix = this._tmpWorldMatrix;
|
|
806
|
+
this.calculateWorldTransform(this._worldMatrix);
|
|
807
|
+
}
|
|
808
|
+
return this._worldMatrix;
|
|
809
|
+
}
|
|
810
|
+
/** The determinant of world matrix */ get worldMatrixDet() {
|
|
811
|
+
if (this._worldMatrixDet === null) {
|
|
812
|
+
this._worldMatrixDet = this.worldMatrix.det();
|
|
813
|
+
}
|
|
814
|
+
return this._worldMatrixDet;
|
|
815
|
+
}
|
|
816
|
+
/** Inverse of the world transformation matrix of the xform */ get invWorldMatrix() {
|
|
817
|
+
if (!this._invWorldMatrix) {
|
|
818
|
+
this._invWorldMatrix = Matrix4x4.invertAffine(this.worldMatrix);
|
|
819
|
+
}
|
|
820
|
+
return this._invWorldMatrix;
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Calculate local transform matrix
|
|
824
|
+
* @param outMatrix - Matrix object that holds the result of calculation
|
|
825
|
+
*/ calculateLocalTransform(outMatrix) {
|
|
826
|
+
outMatrix.compose(this._scaling, this._rotation, this._position);
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Calculate world transform matrix
|
|
830
|
+
* @param outMatrix - Matrix object that holds the result of calculation
|
|
831
|
+
*/ calculateWorldTransform(outMatrix) {
|
|
832
|
+
if (this._parent) {
|
|
833
|
+
Matrix4x4.multiplyAffine(this._parent.worldMatrix, this.localMatrix, outMatrix);
|
|
834
|
+
} else {
|
|
835
|
+
outMatrix.set(this.localMatrix);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
/**
|
|
839
|
+
* Sets the local tranformation matrix by a look-at matrix
|
|
840
|
+
* @param eye - The eye position used to make the look-at matrix
|
|
841
|
+
* @param target - The target position used to make the look-at matrix
|
|
842
|
+
* @param up - The up vector used to make the look-at matrix
|
|
843
|
+
* @returns self
|
|
844
|
+
*/ lookAt(eye, target, up) {
|
|
845
|
+
this.setLocalTransform(Matrix4x4.lookAt(eye, target, up));
|
|
846
|
+
return this;
|
|
847
|
+
}
|
|
848
|
+
/**
|
|
849
|
+
* Update node state once per-frame
|
|
850
|
+
* @param frameId - Current frame id
|
|
851
|
+
* @param elapsedInSeconds - Elapsed time from game start in seconds
|
|
852
|
+
* @param deltaInSeconds - Elapsed time since previous frame in seconds
|
|
853
|
+
*/ update(frameId, elapsedInSeconds, deltaInSeconds) {
|
|
854
|
+
if (!this.attached) {
|
|
855
|
+
return;
|
|
856
|
+
}
|
|
857
|
+
const animationSet = this._animationSet.get();
|
|
858
|
+
if (animationSet) {
|
|
859
|
+
if (animationSet.numAnimations > 0 || animationSet.skeletons.length > 0) {
|
|
860
|
+
animationSet.update(deltaInSeconds);
|
|
861
|
+
this.scene.queueUpdateNode(this);
|
|
862
|
+
} else {
|
|
863
|
+
this._animationSet.dispose();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Update node state once per-camera
|
|
869
|
+
* @param _camera - Updates according to which camera
|
|
870
|
+
* @param _elapsedInSeconds - Elapsed time from game start in seconds
|
|
871
|
+
* @param _deltaInSeconds - Elapsed time since previous frame in seconds
|
|
872
|
+
*/ updatePerCamera(_camera, _elapsedInSeconds, _deltaInSeconds) {}
|
|
873
|
+
/**
|
|
874
|
+
* Removes this node from it's parent and add this node to another parent node if required
|
|
875
|
+
* @param p - The new parent node that this node should be added to or null
|
|
876
|
+
* @returns self
|
|
877
|
+
*/ reparent(p) {
|
|
878
|
+
this.parent = p;
|
|
879
|
+
return this;
|
|
880
|
+
}
|
|
881
|
+
/** @internal */ get transformTag() {
|
|
882
|
+
return this._transformTag;
|
|
883
|
+
}
|
|
311
884
|
}
|
|
312
885
|
|
|
313
886
|
export { SceneNode };
|