@zephyr3d/scene 0.9.1 → 0.9.3
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 +2 -0
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_system.js +9 -1
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +5 -1
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/geometry_cache_utils.js +20 -4
- package/dist/animation/geometry_cache_utils.js.map +1 -1
- package/dist/animation/ik/ik_angle_constraint.js +2 -6
- package/dist/animation/ik/ik_angle_constraint.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/ik/two_bone_ik_solver.js +2 -6
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +60 -12
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/constraints.js +20 -4
- package/dist/animation/joint_dynamics/constraints.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +94 -46
- 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/joint_dynamics/solver.js +21 -11
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js +15 -3
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +5 -1
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/skeleton.js +2 -2
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +2 -6
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_system.js +13 -40
- 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/app.js.map +1 -1
- package/dist/app/engine.js +1 -1
- package/dist/app/engine.js.map +1 -1
- package/dist/app/screen.js +4 -4
- package/dist/app/screen.js.map +1 -1
- package/dist/app/scriptingsystem.js +24 -1
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +22 -1
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +2 -2
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +60 -60
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/camera.js +1 -1
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +795 -266
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +3 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/shader/helper.js +281 -278
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite.js +6 -6
- package/dist/material/sprite.js.map +1 -1
- package/dist/material/terrain-cm.js +2 -2
- package/dist/material/terrain-cm.js.map +1 -1
- 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/taa.js +31 -39
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/cluster_light.js +3 -4
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +5 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +29 -3
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/executor.js +283 -33
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +338 -108
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +195 -115
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +10 -0
- package/dist/render/rendergraph/history_resources.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +162 -35
- package/dist/render/rendergraph/rendergraph.js.map +1 -1
- package/dist/render/rendergraph/types.js +25 -5
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/rendertarget.js +5 -1
- package/dist/render/rendertarget.js.map +1 -1
- package/dist/render/screenrendertarget.js +5 -1
- package/dist/render/screenrendertarget.js.map +1 -1
- package/dist/render/sky.js +4 -4
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +2 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/graph_node.js +1 -1
- package/dist/scene/graph_node.js.map +1 -1
- package/dist/scene/mesh.js +81 -97
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/particlesys.js +1 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene_node.js +228 -228
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/script_attachment.js +15 -3
- package/dist/scene/script_attachment.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +3 -3
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shapes/box.js +1 -1
- package/dist/shapes/box.js.map +1 -1
- package/dist/shapes/capsule.js +0 -3
- package/dist/shapes/capsule.js.map +1 -1
- package/dist/shapes/cylinder.js +0 -3
- package/dist/shapes/cylinder.js.map +1 -1
- package/dist/shapes/plane.js +0 -3
- package/dist/shapes/plane.js.map +1 -1
- package/dist/shapes/tetrahedron.js +3 -9
- package/dist/shapes/tetrahedron.js.map +1 -1
- package/dist/shapes/torus.js +94 -66
- 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/utility/blueprint/material/common.js +7 -0
- package/dist/utility/blueprint/material/common.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +3 -3
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +4 -4
- package/dist/utility/blueprint/material/ir.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 +299 -268
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +45 -0
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +53 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +10 -0
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +30 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +63 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +11 -0
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/misc.js +2 -0
- package/dist/utility/serialization/scene/misc.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +19 -0
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +22 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +33 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +39 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/script.js +2 -0
- package/dist/utility/serialization/scene/script.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +9 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +21 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js +5 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/values.js +49 -53
- package/dist/values.js.map +1 -1
- package/package.json +2 -2
- 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,127 @@
|
|
|
1
|
+
import { ScriptRegistry } from './scriptregistry.js';
|
|
2
|
+
import { HttpFS } from '@zephyr3d/base';
|
|
3
|
+
import { RuntimeScript } from './runtimescript.js';
|
|
4
|
+
|
|
5
|
+
class ScriptingSystem {
|
|
6
|
+
_registry;
|
|
7
|
+
_hostScripts = new Map();
|
|
8
|
+
_onLoadError;
|
|
9
|
+
_importComment;
|
|
10
|
+
constructor(opts = {}){
|
|
11
|
+
this._registry = new ScriptRegistry(opts.VFS ?? new HttpFS('./'), opts.scriptsRoot ?? '/', opts.editorMode ?? false);
|
|
12
|
+
this._importComment = opts.importComment;
|
|
13
|
+
this._onLoadError = opts.onLoadError;
|
|
14
|
+
}
|
|
15
|
+
get registry() {
|
|
16
|
+
return this._registry;
|
|
17
|
+
}
|
|
18
|
+
// Attachs a script to object and returns the script instance
|
|
19
|
+
async attachScript(host, module) {
|
|
20
|
+
try {
|
|
21
|
+
const url = await this._registry.resolveRuntimeUrl(module);
|
|
22
|
+
if (!url) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const mod = await import(url + (this._importComment ?? ''));
|
|
26
|
+
let instance;
|
|
27
|
+
if (typeof mod?.default === 'function') {
|
|
28
|
+
// default export
|
|
29
|
+
instance = new mod.default();
|
|
30
|
+
if (instance instanceof RuntimeScript) {
|
|
31
|
+
const P = instance.onCreated();
|
|
32
|
+
if (P instanceof Promise) {
|
|
33
|
+
await P;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
console.warn(`Script '${module}' does not have RuntimeScript class exported as default`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const attached = {
|
|
41
|
+
id: module,
|
|
42
|
+
url,
|
|
43
|
+
instance
|
|
44
|
+
};
|
|
45
|
+
let list = this._hostScripts.get(host);
|
|
46
|
+
if (!list) {
|
|
47
|
+
list = [];
|
|
48
|
+
this._hostScripts.set(host, list);
|
|
49
|
+
if (host) {
|
|
50
|
+
host.on('dispose', ()=>{
|
|
51
|
+
this.detachScript(host);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
list.push(attached);
|
|
56
|
+
this.registerHost(host);
|
|
57
|
+
const P = instance.onAttached(host);
|
|
58
|
+
if (P instanceof Promise) {
|
|
59
|
+
await P;
|
|
60
|
+
}
|
|
61
|
+
return attached.instance;
|
|
62
|
+
} catch (e) {
|
|
63
|
+
this._onLoadError?.(e, module);
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Detach script from host object
|
|
68
|
+
detachScript(host, idOrInstance) {
|
|
69
|
+
const list = this._hostScripts.get(host);
|
|
70
|
+
if (!list || list.length === 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
let removed = false;
|
|
74
|
+
for(let i = list.length - 1; i >= 0; i--){
|
|
75
|
+
const it = list[i];
|
|
76
|
+
const hit = !idOrInstance || typeof idOrInstance === 'string' ? it.id === idOrInstance : it.instance === idOrInstance;
|
|
77
|
+
if (hit) {
|
|
78
|
+
try {
|
|
79
|
+
it.instance.onDetached();
|
|
80
|
+
} catch (err) {
|
|
81
|
+
console.error(`Error occured at onDetach() of module '${it.id}': ${err}`);
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
it.instance.onDestroy();
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.error(`Error occured at onDestroy() of module '${it.id}': ${err}`);
|
|
87
|
+
}
|
|
88
|
+
list.splice(i, 1);
|
|
89
|
+
removed = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (list.length === 0) {
|
|
93
|
+
this._hostScripts.delete(host);
|
|
94
|
+
this.unregisterHost(host);
|
|
95
|
+
}
|
|
96
|
+
return removed;
|
|
97
|
+
}
|
|
98
|
+
// Update script instances
|
|
99
|
+
update(deltaTime, elapsedTime) {
|
|
100
|
+
if (this._hostScripts.size === 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
for (const list of this._hostScripts.values()){
|
|
104
|
+
for (const s of list){
|
|
105
|
+
try {
|
|
106
|
+
s.instance.onUpdate(deltaTime, elapsedTime);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(`Error occured at onUpdate() of module '${s.id}': ${err}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Detach all script instances
|
|
114
|
+
detachAllScripts() {
|
|
115
|
+
while(this._hostScripts.size > 0){
|
|
116
|
+
for (const entry of this._hostScripts){
|
|
117
|
+
this.detachScript(entry[0]);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Preserved functions
|
|
122
|
+
registerHost(_host) {}
|
|
123
|
+
unregisterHost(_host) {}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export { ScriptingSystem };
|
|
127
|
+
//# sourceMappingURL=scriptingsystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptingsystem.js","sources":["../../../../../../node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js"],"sourcesContent":["import { ScriptRegistry } from './scriptregistry.js';\nimport { HttpFS } from '@zephyr3d/base';\nimport { RuntimeScript } from './runtimescript.js';\n\nclass ScriptingSystem {\n _registry;\n _hostScripts = new Map();\n _onLoadError;\n _importComment;\n constructor(opts = {}){\n this._registry = new ScriptRegistry(opts.VFS ?? new HttpFS('./'), opts.scriptsRoot ?? '/', opts.editorMode ?? false);\n this._importComment = opts.importComment;\n this._onLoadError = opts.onLoadError;\n }\n get registry() {\n return this._registry;\n }\n // Attachs a script to object and returns the script instance\n async attachScript(host, module) {\n try {\n const url = await this._registry.resolveRuntimeUrl(module);\n if (!url) {\n return null;\n }\n const mod = await import(url + (this._importComment ?? ''));\n let instance;\n if (typeof mod?.default === 'function') {\n // default export\n instance = new mod.default();\n if (instance instanceof RuntimeScript) {\n const P = instance.onCreated();\n if (P instanceof Promise) {\n await P;\n }\n }\n } else {\n console.warn(`Script '${module}' does not have RuntimeScript class exported as default`);\n return null;\n }\n const attached = {\n id: module,\n url,\n instance\n };\n let list = this._hostScripts.get(host);\n if (!list) {\n list = [];\n this._hostScripts.set(host, list);\n if (host) {\n host.on('dispose', ()=>{\n this.detachScript(host);\n });\n }\n }\n list.push(attached);\n this.registerHost(host);\n const P = instance.onAttached(host);\n if (P instanceof Promise) {\n await P;\n }\n return attached.instance;\n } catch (e) {\n this._onLoadError?.(e, module);\n return null;\n }\n }\n // Detach script from host object\n detachScript(host, idOrInstance) {\n const list = this._hostScripts.get(host);\n if (!list || list.length === 0) {\n return false;\n }\n let removed = false;\n for(let i = list.length - 1; i >= 0; i--){\n const it = list[i];\n const hit = !idOrInstance || typeof idOrInstance === 'string' ? it.id === idOrInstance : it.instance === idOrInstance;\n if (hit) {\n try {\n it.instance.onDetached();\n } catch (err) {\n console.error(`Error occured at onDetach() of module '${it.id}': ${err}`);\n }\n try {\n it.instance.onDestroy();\n } catch (err) {\n console.error(`Error occured at onDestroy() of module '${it.id}': ${err}`);\n }\n list.splice(i, 1);\n removed = true;\n }\n }\n if (list.length === 0) {\n this._hostScripts.delete(host);\n this.unregisterHost(host);\n }\n return removed;\n }\n // Update script instances\n update(deltaTime, elapsedTime) {\n if (this._hostScripts.size === 0) {\n return;\n }\n for (const list of this._hostScripts.values()){\n for (const s of list){\n try {\n s.instance.onUpdate(deltaTime, elapsedTime);\n } catch (err) {\n console.error(`Error occured at onUpdate() of module '${s.id}': ${err}`);\n }\n }\n }\n }\n // Detach all script instances\n detachAllScripts() {\n while(this._hostScripts.size > 0){\n for (const entry of this._hostScripts){\n this.detachScript(entry[0]);\n }\n }\n }\n // Preserved functions\n registerHost(_host) {}\n unregisterHost(_host) {}\n}\n\nexport { ScriptingSystem };\n//# sourceMappingURL=scriptingsystem.js.map\n"],"names":[],"mappings":";;;;AAIA,MAAM,eAAe,CAAC;AACtB,IAAI,SAAS;AACb,IAAI,YAAY,GAAG,IAAI,GAAG,EAAE;AAC5B,IAAI,YAAY;AAChB,IAAI,cAAc;AAClB,IAAI,WAAW,CAAC,IAAI,GAAG,EAAE,CAAC;AAC1B,QAAQ,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,WAAW,IAAI,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;AAC5H,QAAQ,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa;AAChD,QAAQ,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW;AAC5C;AACA,IAAI,IAAI,QAAQ,GAAG;AACnB,QAAQ,OAAO,IAAI,CAAC,SAAS;AAC7B;AACA;AACA,IAAI,MAAM,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE;AACrC,QAAQ,IAAI;AACZ,YAAY,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC;AACtE,YAAY,IAAI,CAAC,GAAG,EAAE;AACtB,gBAAgB,OAAO,IAAI;AAC3B;AACA,YAAY,MAAM,GAAG,GAAG,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC;AACvE,YAAY,IAAI,QAAQ;AACxB,YAAY,IAAI,OAAO,GAAG,EAAE,OAAO,KAAK,UAAU,EAAE;AACpD;AACA,gBAAgB,QAAQ,GAAG,IAAI,GAAG,CAA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
5
|
+
return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;
|
|
6
|
+
}
|
|
7
|
+
function isAbsoluteUrl(spec) {
|
|
8
|
+
return /^https?:\/\//i.test(spec);
|
|
9
|
+
}
|
|
10
|
+
function isSpecialUrl(spec) {
|
|
11
|
+
return /^(data|blob):/i.test(spec);
|
|
12
|
+
}
|
|
13
|
+
function isBareModule(spec) {
|
|
14
|
+
return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');
|
|
15
|
+
}
|
|
16
|
+
class ScriptRegistry {
|
|
17
|
+
_vfs;
|
|
18
|
+
_scriptsRoot;
|
|
19
|
+
_built = new Map();
|
|
20
|
+
_editorMode = false;
|
|
21
|
+
constructor(vfs, scriptsRoot, editorMode){
|
|
22
|
+
this._vfs = vfs;
|
|
23
|
+
this._scriptsRoot = scriptsRoot;
|
|
24
|
+
this._editorMode = editorMode;
|
|
25
|
+
}
|
|
26
|
+
get VFS() {
|
|
27
|
+
return this._vfs;
|
|
28
|
+
}
|
|
29
|
+
set VFS(vfs) {
|
|
30
|
+
this._vfs = vfs;
|
|
31
|
+
}
|
|
32
|
+
get editorMode() {
|
|
33
|
+
return this._editorMode;
|
|
34
|
+
}
|
|
35
|
+
set editorMode(val) {
|
|
36
|
+
this._editorMode = val;
|
|
37
|
+
}
|
|
38
|
+
get scriptsRoot() {
|
|
39
|
+
return this._scriptsRoot;
|
|
40
|
+
}
|
|
41
|
+
set scriptsRoot(path) {
|
|
42
|
+
this._scriptsRoot = path;
|
|
43
|
+
}
|
|
44
|
+
async fetchSource(_id) {
|
|
45
|
+
let type = null;
|
|
46
|
+
let pathWithExt = '';
|
|
47
|
+
if (_id.endsWith('.ts')) {
|
|
48
|
+
pathWithExt = _id;
|
|
49
|
+
type = 'ts';
|
|
50
|
+
} else if (_id.endsWith('.js')) {
|
|
51
|
+
pathWithExt = _id;
|
|
52
|
+
type = 'js';
|
|
53
|
+
}
|
|
54
|
+
if (type) {
|
|
55
|
+
const exists = await this._vfs.exists(pathWithExt);
|
|
56
|
+
if (!exists) {
|
|
57
|
+
type = null;
|
|
58
|
+
}
|
|
59
|
+
const stat = await this._vfs.stat(pathWithExt);
|
|
60
|
+
if (stat.isDirectory) {
|
|
61
|
+
type = null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const types = [
|
|
65
|
+
'ts',
|
|
66
|
+
'js'
|
|
67
|
+
];
|
|
68
|
+
if (!type) {
|
|
69
|
+
for (const t of types){
|
|
70
|
+
pathWithExt = `${_id}.${t}`;
|
|
71
|
+
const exists = await this._vfs.exists(pathWithExt);
|
|
72
|
+
if (exists) {
|
|
73
|
+
const stats = await this._vfs.stat(pathWithExt);
|
|
74
|
+
if (stats.isFile) {
|
|
75
|
+
type = t;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (type) {
|
|
82
|
+
const code = await this._vfs.readFile(pathWithExt, {
|
|
83
|
+
encoding: 'utf8'
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
code,
|
|
87
|
+
type,
|
|
88
|
+
path: pathWithExt
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async resolveRuntimeUrl(entryId) {
|
|
93
|
+
const id = this.resolveLogicalId(entryId);
|
|
94
|
+
return this._editorMode ? await this.build(String(id)) : id;
|
|
95
|
+
}
|
|
96
|
+
async getDependencies(entryId, fromId, dependencies) {
|
|
97
|
+
const reStatic = /\b(?:import|export)\s+[^"']*?from\s+(['"])([^'"]+)\1/g;
|
|
98
|
+
const reDynamic = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
|
|
99
|
+
const normalizedId = this.resolveLogicalId(entryId, fromId);
|
|
100
|
+
const srcPath = await this.resolveSourcePath(normalizedId);
|
|
101
|
+
if (!srcPath || dependencies[srcPath.path] !== undefined) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const code = await this._vfs.readFile(srcPath.path, {
|
|
105
|
+
encoding: 'utf8'
|
|
106
|
+
});
|
|
107
|
+
dependencies[srcPath.path] = code;
|
|
108
|
+
const gather = async (input, re)=>{
|
|
109
|
+
for(;;){
|
|
110
|
+
const m = re.exec(input);
|
|
111
|
+
if (!m) {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
const spec = m[2];
|
|
115
|
+
if (spec.startsWith('./') || spec.startsWith('../')) {
|
|
116
|
+
await this.getDependencies(spec, normalizedId, dependencies);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
await gather(code, reStatic);
|
|
121
|
+
await gather(code, reDynamic);
|
|
122
|
+
}
|
|
123
|
+
async build(id) {
|
|
124
|
+
const key = String(id);
|
|
125
|
+
const cached = this._built.get(key);
|
|
126
|
+
if (cached) {
|
|
127
|
+
return cached;
|
|
128
|
+
}
|
|
129
|
+
const srcPath = await this.resolveSourcePath(key);
|
|
130
|
+
if (!srcPath) {
|
|
131
|
+
return '';
|
|
132
|
+
}
|
|
133
|
+
const code = await this._vfs.readFile(srcPath.path, {
|
|
134
|
+
encoding: 'utf8'
|
|
135
|
+
});
|
|
136
|
+
const rewritten = await this.rewriteImports(code, key);
|
|
137
|
+
const js = await this.transpile(rewritten, key, srcPath.type);
|
|
138
|
+
const url = toDataUrl(js, key);
|
|
139
|
+
this._built.set(key, url);
|
|
140
|
+
return url;
|
|
141
|
+
}
|
|
142
|
+
async transpile(code, _id, type) {
|
|
143
|
+
const logicalId = String(_id);
|
|
144
|
+
if (type === 'js') {
|
|
145
|
+
return `${code}\n//# sourceURL=${logicalId}`;
|
|
146
|
+
}
|
|
147
|
+
const ts = window.ts;
|
|
148
|
+
if (!ts) {
|
|
149
|
+
throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');
|
|
150
|
+
}
|
|
151
|
+
const res = ts.transpileModule(code, {
|
|
152
|
+
compilerOptions: {
|
|
153
|
+
target: ts.ScriptTarget.ES2015,
|
|
154
|
+
module: ts.ModuleKind.ESNext,
|
|
155
|
+
sourceMap: true,
|
|
156
|
+
inlineSources: true,
|
|
157
|
+
experimentalDecorators: true,
|
|
158
|
+
useDefineForClassFields: false
|
|
159
|
+
},
|
|
160
|
+
fileName: logicalId
|
|
161
|
+
});
|
|
162
|
+
let out = res.outputText || '';
|
|
163
|
+
if (res.sourceMapText) {
|
|
164
|
+
const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));
|
|
165
|
+
out += `\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;
|
|
166
|
+
}
|
|
167
|
+
out += `\n//# sourceURL=${logicalId}`;
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
async rewriteImports(code, fromId) {
|
|
171
|
+
const reStatic = /\b(?:import|export)\s+[^"']*?from\s+(['"])([^'"]+)\1/g;
|
|
172
|
+
const reDynamic = /\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g;
|
|
173
|
+
const replaceAsync = async (input, re)=>{
|
|
174
|
+
let out = '';
|
|
175
|
+
let last = 0;
|
|
176
|
+
for(;;){
|
|
177
|
+
const m = re.exec(input);
|
|
178
|
+
if (!m) {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
out += input.slice(last, m.index);
|
|
182
|
+
const quote = m[1];
|
|
183
|
+
const spec = m[2];
|
|
184
|
+
let replacement = spec;
|
|
185
|
+
if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {
|
|
186
|
+
replacement = spec;
|
|
187
|
+
} else {
|
|
188
|
+
const depId = this.resolveLogicalId(spec, String(fromId));
|
|
189
|
+
replacement = await this.build(depId); // 递归构建为 data URL
|
|
190
|
+
}
|
|
191
|
+
const replaced = m[0].replace(`${quote}${spec}${quote}`, `${quote}${replacement}${quote}`);
|
|
192
|
+
out += replaced;
|
|
193
|
+
last = m.index + m[0].length;
|
|
194
|
+
}
|
|
195
|
+
out += input.slice(last);
|
|
196
|
+
return out;
|
|
197
|
+
};
|
|
198
|
+
let out = await replaceAsync(code, reStatic);
|
|
199
|
+
out = await replaceAsync(out, reDynamic);
|
|
200
|
+
return out;
|
|
201
|
+
}
|
|
202
|
+
resolveLogicalId(spec, fromId) {
|
|
203
|
+
let path;
|
|
204
|
+
if (spec.startsWith('#/')) {
|
|
205
|
+
path = this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));
|
|
206
|
+
} else if (spec.startsWith('./') || spec.startsWith('../')) {
|
|
207
|
+
if (!fromId) {
|
|
208
|
+
throw new Error(`Relative import "${spec}" requires fromId`);
|
|
209
|
+
}
|
|
210
|
+
path = this._vfs.normalizePath(this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec));
|
|
211
|
+
} else if (spec.startsWith('/')) {
|
|
212
|
+
path = spec.replace(/^\/+/, '/');
|
|
213
|
+
} else {
|
|
214
|
+
return spec;
|
|
215
|
+
}
|
|
216
|
+
return path;
|
|
217
|
+
}
|
|
218
|
+
async resolveSourcePath(logicalId) {
|
|
219
|
+
let type = null;
|
|
220
|
+
let pathWithExt = '';
|
|
221
|
+
if (logicalId.endsWith('.ts')) {
|
|
222
|
+
pathWithExt = logicalId;
|
|
223
|
+
type = 'ts';
|
|
224
|
+
} else if (logicalId.endsWith('.js')) {
|
|
225
|
+
pathWithExt = logicalId;
|
|
226
|
+
type = 'js';
|
|
227
|
+
}
|
|
228
|
+
if (type) {
|
|
229
|
+
const exists = await this._vfs.exists(pathWithExt);
|
|
230
|
+
if (!exists) {
|
|
231
|
+
type = null;
|
|
232
|
+
}
|
|
233
|
+
const stat = await this._vfs.stat(pathWithExt);
|
|
234
|
+
if (stat.isDirectory) {
|
|
235
|
+
type = null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const types = [
|
|
239
|
+
'ts',
|
|
240
|
+
'js'
|
|
241
|
+
];
|
|
242
|
+
if (!type) {
|
|
243
|
+
for (const t of types){
|
|
244
|
+
pathWithExt = `${logicalId}.${t}`;
|
|
245
|
+
const exists = await this._vfs.exists(pathWithExt);
|
|
246
|
+
if (exists) {
|
|
247
|
+
const stats = await this._vfs.stat(pathWithExt);
|
|
248
|
+
if (stats.isFile) {
|
|
249
|
+
type = t;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return type ? {
|
|
256
|
+
type,
|
|
257
|
+
path: pathWithExt
|
|
258
|
+
} : null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export { ScriptRegistry };
|
|
263
|
+
//# sourceMappingURL=scriptregistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scriptregistry.js","sources":["../../../../../../node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js"],"sourcesContent":["import { textToBase64 } from '@zephyr3d/base';\n\nfunction toDataUrl(js, id) {\n const b64 = textToBase64(js);\n return `data:text/javascript;base64,${b64}#${encodeURIComponent(String(id))}`;\n}\nfunction isAbsoluteUrl(spec) {\n return /^https?:\\/\\//i.test(spec);\n}\nfunction isSpecialUrl(spec) {\n return /^(data|blob):/i.test(spec);\n}\nfunction isBareModule(spec) {\n return !spec.startsWith('./') && !spec.startsWith('../') && !spec.startsWith('/') && !spec.startsWith('#/');\n}\nclass ScriptRegistry {\n _vfs;\n _scriptsRoot;\n _built = new Map();\n _editorMode = false;\n constructor(vfs, scriptsRoot, editorMode){\n this._vfs = vfs;\n this._scriptsRoot = scriptsRoot;\n this._editorMode = editorMode;\n }\n get VFS() {\n return this._vfs;\n }\n set VFS(vfs) {\n this._vfs = vfs;\n }\n get editorMode() {\n return this._editorMode;\n }\n set editorMode(val) {\n this._editorMode = val;\n }\n get scriptsRoot() {\n return this._scriptsRoot;\n }\n set scriptsRoot(path) {\n this._scriptsRoot = path;\n }\n async fetchSource(_id) {\n let type = null;\n let pathWithExt = '';\n if (_id.endsWith('.ts')) {\n pathWithExt = _id;\n type = 'ts';\n } else if (_id.endsWith('.js')) {\n pathWithExt = _id;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = [\n 'ts',\n 'js'\n ];\n if (!type) {\n for (const t of types){\n pathWithExt = `${_id}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t;\n break;\n }\n }\n }\n }\n if (type) {\n const code = await this._vfs.readFile(pathWithExt, {\n encoding: 'utf8'\n });\n return {\n code,\n type,\n path: pathWithExt\n };\n }\n }\n async resolveRuntimeUrl(entryId) {\n const id = this.resolveLogicalId(entryId);\n return this._editorMode ? await this.build(String(id)) : id;\n }\n async getDependencies(entryId, fromId, dependencies) {\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\n const normalizedId = this.resolveLogicalId(entryId, fromId);\n const srcPath = await this.resolveSourcePath(normalizedId);\n if (!srcPath || dependencies[srcPath.path] !== undefined) {\n return;\n }\n const code = await this._vfs.readFile(srcPath.path, {\n encoding: 'utf8'\n });\n dependencies[srcPath.path] = code;\n const gather = async (input, re)=>{\n for(;;){\n const m = re.exec(input);\n if (!m) {\n break;\n }\n const spec = m[2];\n if (spec.startsWith('./') || spec.startsWith('../')) {\n await this.getDependencies(spec, normalizedId, dependencies);\n }\n }\n };\n await gather(code, reStatic);\n await gather(code, reDynamic);\n }\n async build(id) {\n const key = String(id);\n const cached = this._built.get(key);\n if (cached) {\n return cached;\n }\n const srcPath = await this.resolveSourcePath(key);\n if (!srcPath) {\n return '';\n }\n const code = await this._vfs.readFile(srcPath.path, {\n encoding: 'utf8'\n });\n const rewritten = await this.rewriteImports(code, key);\n const js = await this.transpile(rewritten, key, srcPath.type);\n const url = toDataUrl(js, key);\n this._built.set(key, url);\n return url;\n }\n async transpile(code, _id, type) {\n const logicalId = String(_id);\n if (type === 'js') {\n return `${code}\\n//# sourceURL=${logicalId}`;\n }\n const ts = window.ts;\n if (!ts) {\n throw new Error('TypeScript runtime (window.ts) not found. Load typescript.js first.');\n }\n const res = ts.transpileModule(code, {\n compilerOptions: {\n target: ts.ScriptTarget.ES2015,\n module: ts.ModuleKind.ESNext,\n sourceMap: true,\n inlineSources: true,\n experimentalDecorators: true,\n useDefineForClassFields: false\n },\n fileName: logicalId\n });\n let out = res.outputText || '';\n if (res.sourceMapText) {\n const mapBase64 = btoa(unescape(encodeURIComponent(res.sourceMapText)));\n out += `\\n//# sourceMappingURL=data:application/json;base64,${mapBase64}`;\n }\n out += `\\n//# sourceURL=${logicalId}`;\n return out;\n }\n async rewriteImports(code, fromId) {\n const reStatic = /\\b(?:import|export)\\s+[^\"']*?from\\s+(['\"])([^'\"]+)\\1/g;\n const reDynamic = /\\bimport\\s*\\(\\s*(['\"])([^'\"]+)\\1\\s*\\)/g;\n const replaceAsync = async (input, re)=>{\n let out = '';\n let last = 0;\n for(;;){\n const m = re.exec(input);\n if (!m) {\n break;\n }\n out += input.slice(last, m.index);\n const quote = m[1];\n const spec = m[2];\n let replacement = spec;\n if (isAbsoluteUrl(spec) || isSpecialUrl(spec) || isBareModule(spec)) {\n replacement = spec;\n } else {\n const depId = this.resolveLogicalId(spec, String(fromId));\n replacement = await this.build(depId); // 递归构建为 data URL\n }\n const replaced = m[0].replace(`${quote}${spec}${quote}`, `${quote}${replacement}${quote}`);\n out += replaced;\n last = m.index + m[0].length;\n }\n out += input.slice(last);\n return out;\n };\n let out = await replaceAsync(code, reStatic);\n out = await replaceAsync(out, reDynamic);\n return out;\n }\n resolveLogicalId(spec, fromId) {\n let path;\n if (spec.startsWith('#/')) {\n path = this._vfs.normalizePath(this._vfs.join(this._scriptsRoot, spec.slice(2)));\n } else if (spec.startsWith('./') || spec.startsWith('../')) {\n if (!fromId) {\n throw new Error(`Relative import \"${spec}\" requires fromId`);\n }\n path = this._vfs.normalizePath(this._vfs.join(this._vfs.dirname(this._vfs.normalizePath(fromId)), spec));\n } else if (spec.startsWith('/')) {\n path = spec.replace(/^\\/+/, '/');\n } else {\n return spec;\n }\n return path;\n }\n async resolveSourcePath(logicalId) {\n let type = null;\n let pathWithExt = '';\n if (logicalId.endsWith('.ts')) {\n pathWithExt = logicalId;\n type = 'ts';\n } else if (logicalId.endsWith('.js')) {\n pathWithExt = logicalId;\n type = 'js';\n }\n if (type) {\n const exists = await this._vfs.exists(pathWithExt);\n if (!exists) {\n type = null;\n }\n const stat = await this._vfs.stat(pathWithExt);\n if (stat.isDirectory) {\n type = null;\n }\n }\n const types = [\n 'ts',\n 'js'\n ];\n if (!type) {\n for (const t of types){\n pathWithExt = `${logicalId}.${t}`;\n const exists = await this._vfs.exists(pathWithExt);\n if (exists) {\n const stats = await this._vfs.stat(pathWithExt);\n if (stats.isFile) {\n type = t;\n break;\n }\n }\n }\n }\n return type ? {\n type,\n path: pathWithExt\n } : null;\n }\n}\n\nexport { ScriptRegistry };\n//# sourceMappingURL=scriptregistry.js.map\n"],"names":[],"mappings":";;AAEA,SAAS,SAAS,CAAC,EAAE,EAAE,EAAE,EAAE;AAC3B,IAAI,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,CAAC;AAChC,IAAI,OAAO,CAAC,4BAA4B,EAAE,GAAG,CAAC,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACjF;AACA,SAAS,aAAa,CAAC,IAAI,EAAE;AAC7B,IAAI,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC;AACrC;AACA,SAAS,YAAY,CAAC,IAAI,EAAE;AAC5B,IAAI,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;AACtC;AACA,SAAS,YAAY,CAAC,IAAI,EAAE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oBAAoB,IAAI,KAAK,CAAC,MAAM,EAAE;AACtC,wBAAwB,IAAI,GAAG,CAAC;AAChC,wBAAwB;AACxB;AACA;AACA;AACA;AACA,QAAQ,OAAO,IAAI,GAAG;AACtB,YAAY,IAAI;AAChB,YAAY,IAAI,EAAE;AAClB,SAAS,GAAG,IAAI;AAChB;AACA;;;;","x_google_ignoreList":[0]}
|
package/dist/posteffect/taa.js
CHANGED
|
@@ -11,11 +11,8 @@ import '../shapes/plane.js';
|
|
|
11
11
|
import '../shapes/sphere.js';
|
|
12
12
|
import '../shapes/tetrahedron.js';
|
|
13
13
|
import { temporalResolve } from '../shaders/temporal.js';
|
|
14
|
+
import { RGHistoryResources } from '../render/rendergraph/history_resources.js';
|
|
14
15
|
|
|
15
|
-
/** Resource names for TAA history buffers */ const TAA_RESOURCES = {
|
|
16
|
-
COLOR: 'taaColor',
|
|
17
|
-
MOTION_VECTOR: 'taaMotionVector'
|
|
18
|
-
};
|
|
19
16
|
/** @internal */ class TAA extends AbstractPostEffect {
|
|
20
17
|
static _resolveProgram = [];
|
|
21
18
|
static _skyMotionVectorProgram = null;
|
|
@@ -51,46 +48,41 @@ import { temporalResolve } from '../shaders/temporal.js';
|
|
|
51
48
|
}
|
|
52
49
|
apply(ctx, inputColorTexture, sceneDepthTexture, srgbOutput) {
|
|
53
50
|
const historyMgr = ctx.camera.getHistoryResourceManager();
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const colorDesc = {
|
|
52
|
+
format: inputColorTexture.format,
|
|
53
|
+
sizeMode: 'absolute',
|
|
54
|
+
width: inputColorTexture.width,
|
|
55
|
+
height: inputColorTexture.height
|
|
56
|
+
};
|
|
57
|
+
const colorSize = {
|
|
58
|
+
width: inputColorTexture.width,
|
|
59
|
+
height: inputColorTexture.height
|
|
60
|
+
};
|
|
61
|
+
const motionVectorDesc = {
|
|
62
|
+
format: ctx.motionVectorTexture.format,
|
|
63
|
+
sizeMode: 'absolute',
|
|
64
|
+
width: ctx.motionVectorTexture.width,
|
|
65
|
+
height: ctx.motionVectorTexture.height
|
|
66
|
+
};
|
|
67
|
+
const motionVectorSize = {
|
|
68
|
+
width: ctx.motionVectorTexture.width,
|
|
69
|
+
height: ctx.motionVectorTexture.height
|
|
70
|
+
};
|
|
71
|
+
const hasHistory = historyMgr.isCompatible(RGHistoryResources.TAA_COLOR, colorDesc, colorSize) && historyMgr.isCompatible(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize);
|
|
72
|
+
if (!hasHistory) {
|
|
57
73
|
// First frame: just pass through
|
|
58
74
|
this.passThrough(ctx, inputColorTexture, srgbOutput);
|
|
59
|
-
//
|
|
75
|
+
// Queue history resources only after retaining references from the pool.
|
|
60
76
|
const currentColorTex = ctx.device.getFramebuffer().getColorAttachments()[0];
|
|
61
77
|
ctx.device.pool.retainTexture(currentColorTex);
|
|
62
|
-
historyMgr.
|
|
63
|
-
format: inputColorTexture.format,
|
|
64
|
-
sizeMode: 'absolute',
|
|
65
|
-
width: inputColorTexture.width,
|
|
66
|
-
height: inputColorTexture.height
|
|
67
|
-
}, {
|
|
68
|
-
width: inputColorTexture.width,
|
|
69
|
-
height: inputColorTexture.height
|
|
70
|
-
}, currentColorTex);
|
|
78
|
+
historyMgr.queueCommit(RGHistoryResources.TAA_COLOR, colorDesc, colorSize, currentColorTex);
|
|
71
79
|
ctx.device.pool.retainTexture(ctx.motionVectorTexture);
|
|
72
|
-
historyMgr.
|
|
73
|
-
format: ctx.motionVectorTexture.format,
|
|
74
|
-
sizeMode: 'absolute',
|
|
75
|
-
width: ctx.motionVectorTexture.width,
|
|
76
|
-
height: ctx.motionVectorTexture.height
|
|
77
|
-
}, {
|
|
78
|
-
width: ctx.motionVectorTexture.width,
|
|
79
|
-
height: ctx.motionVectorTexture.height
|
|
80
|
-
}, ctx.motionVectorTexture);
|
|
80
|
+
historyMgr.queueCommit(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize, ctx.motionVectorTexture);
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
// Get history textures
|
|
84
|
-
const prevColorTex = historyMgr.getPrevious(
|
|
85
|
-
|
|
86
|
-
if (prevColorTex.width !== inputColorTexture.width || prevColorTex.height !== inputColorTexture.height) {
|
|
87
|
-
// Resolution changed, unregister old resources and restart
|
|
88
|
-
historyMgr.unregister(TAA_RESOURCES.COLOR);
|
|
89
|
-
historyMgr.unregister(TAA_RESOURCES.MOTION_VECTOR);
|
|
90
|
-
this.passThrough(ctx, inputColorTexture, srgbOutput);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const prevMotionVectorTex = historyMgr.getPrevious(TAA_RESOURCES.MOTION_VECTOR);
|
|
84
|
+
const prevColorTex = historyMgr.getPrevious(RGHistoryResources.TAA_COLOR);
|
|
85
|
+
const prevMotionVectorTex = historyMgr.getPrevious(RGHistoryResources.TAA_MOTION_VECTOR);
|
|
94
86
|
// Render TAA
|
|
95
87
|
let program = TAA._resolveProgram[ctx.camera.TAADebug];
|
|
96
88
|
if (!program) {
|
|
@@ -115,10 +107,10 @@ import { temporalResolve } from '../shaders/temporal.js';
|
|
|
115
107
|
// Update history with current framebuffer output (zero-copy)
|
|
116
108
|
const currentColorTex = ctx.device.getFramebuffer().getColorAttachments()[0];
|
|
117
109
|
ctx.device.pool.retainTexture(currentColorTex);
|
|
118
|
-
historyMgr.
|
|
110
|
+
historyMgr.queueCommit(RGHistoryResources.TAA_COLOR, colorDesc, colorSize, currentColorTex);
|
|
119
111
|
ctx.device.pool.retainTexture(ctx.motionVectorTexture);
|
|
120
|
-
historyMgr.
|
|
121
|
-
//
|
|
112
|
+
historyMgr.queueCommit(RGHistoryResources.TAA_MOTION_VECTOR, motionVectorDesc, motionVectorSize, ctx.motionVectorTexture);
|
|
113
|
+
// History commits happen after the render graph completes successfully.
|
|
122
114
|
}
|
|
123
115
|
requireLinearDepthTexture(_ctx) {
|
|
124
116
|
return true;
|