@zephyr3d/scene 0.9.4 → 0.9.6
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/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +171 -107
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +344 -365
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1000 -131
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1126 -199
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/material/msdf_text_sprite.js +4 -4
- package/dist/material/msdf_text_sprite.js.map +1 -1
- package/dist/material/pbrblueprint.js +102 -102
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/batchgroup.js +11 -13
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +15 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +79 -16
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +203 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/dist/text/msdf/generator.js.map +1 -1
- package/dist/text/msdf/shape.js +4 -1
- package/dist/text/msdf/shape.js.map +1 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js +4 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +1157 -1154
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +22 -9
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +700 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +64 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +187 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1273
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { DWeakRef, ASSERT, base64ToUint8Array, Vector3,
|
|
2
|
-
import { GLTFLoader } from './loaders/gltf/gltf_loader.js';
|
|
1
|
+
import { DWeakRef, DRef, ASSERT, base64ToUint8Array, Vector3, Vector4, guessMimeType, isPowerOf2, nextPowerOf2 } from '@zephyr3d/base';
|
|
3
2
|
import { WebImageLoader } from './loaders/image/webimage_loader.js';
|
|
4
3
|
import { DDSLoader } from './loaders/dds/dds_loader.js';
|
|
5
4
|
import { HDRLoader } from './loaders/hdr/hdr.js';
|
|
@@ -35,20 +34,20 @@ import '../render/clipmap.js';
|
|
|
35
34
|
import '../shaders/atmosphere.js';
|
|
36
35
|
import { FontAsset } from '../text/font/font_asset.js';
|
|
37
36
|
|
|
38
|
-
/**
|
|
39
|
-
* Centralized asset manager for loading and caching resources.
|
|
40
|
-
*
|
|
41
|
-
* Responsibilities:
|
|
42
|
-
* - Abstracts resource loading via VFS (text/json/binary).
|
|
43
|
-
* - Dispatches texture/model loading to registered loaders by MIME type.
|
|
44
|
-
* - Caches results and uses weak references to allow GPU resources to be GC'd when unused.
|
|
45
|
-
* - Harmonizes cross-backend constraints (e.g., WebGL non-power-of-two rules and sRGB handling).
|
|
46
|
-
* - Provides access to built-in textures with device-restore handlers.
|
|
47
|
-
*
|
|
48
|
-
* Threading/async model:
|
|
49
|
-
* - All I/O is async; repeated calls are coalesced via internal promise caches keyed by URL or hash.
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
37
|
+
/**
|
|
38
|
+
* Centralized asset manager for loading and caching resources.
|
|
39
|
+
*
|
|
40
|
+
* Responsibilities:
|
|
41
|
+
* - Abstracts resource loading via VFS (text/json/binary).
|
|
42
|
+
* - Dispatches texture/model loading to registered loaders by MIME type.
|
|
43
|
+
* - Caches results and uses weak references to allow GPU resources to be GC'd when unused.
|
|
44
|
+
* - Harmonizes cross-backend constraints (e.g., WebGL non-power-of-two rules and sRGB handling).
|
|
45
|
+
* - Provides access to built-in textures with device-restore handlers.
|
|
46
|
+
*
|
|
47
|
+
* Threading/async model:
|
|
48
|
+
* - All I/O is async; repeated calls are coalesced via internal promise caches keyed by URL or hash.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
52
51
|
*/ class AssetManager {
|
|
53
52
|
/** @internal */ static _builtinTextures = {};
|
|
54
53
|
/** @internal */ static _builtinTextureLoaders = {
|
|
@@ -60,9 +59,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
60
59
|
new HDRLoader(),
|
|
61
60
|
new TGALoader()
|
|
62
61
|
];
|
|
63
|
-
/** @internal */
|
|
64
|
-
new GLTFLoader()
|
|
65
|
-
];
|
|
62
|
+
/** @internal */ _modelLoaders = {};
|
|
66
63
|
/** @internal */ _textures;
|
|
67
64
|
/** @internal */ _models;
|
|
68
65
|
/** @internal */ _binaryDatas;
|
|
@@ -74,8 +71,8 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
74
71
|
/** @internal */ _skeletons;
|
|
75
72
|
/** @internal */ _jsonDatas;
|
|
76
73
|
/** @internal */ _resourceManager;
|
|
77
|
-
/**
|
|
78
|
-
* Creates an instance of AssetManager
|
|
74
|
+
/**
|
|
75
|
+
* Creates an instance of AssetManager
|
|
79
76
|
*/ constructor(resourceManager){
|
|
80
77
|
this._resourceManager = resourceManager ?? getEngine().resourceManager;
|
|
81
78
|
this._textures = {};
|
|
@@ -89,18 +86,18 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
89
86
|
this._textDatas = {};
|
|
90
87
|
this._jsonDatas = {};
|
|
91
88
|
}
|
|
92
|
-
/**
|
|
93
|
-
* VFS used to read resources (files, URLs, virtual mounts).
|
|
89
|
+
/**
|
|
90
|
+
* VFS used to read resources (files, URLs, virtual mounts).
|
|
94
91
|
*/ get vfs() {
|
|
95
92
|
return this._resourceManager.VFS;
|
|
96
93
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Clear cached references and promises.
|
|
99
|
-
*
|
|
100
|
-
* - Disposes any DWeakRef holders maintained by this manager.
|
|
101
|
-
* - Empties internal maps for textures, models, and raw data (text/json/binary).
|
|
102
|
-
* - Does not forcibly dispose GPU resources; it only clears references so they can be GC'd
|
|
103
|
-
* if no other owners are holding them.
|
|
94
|
+
/**
|
|
95
|
+
* Clear cached references and promises.
|
|
96
|
+
*
|
|
97
|
+
* - Disposes any DWeakRef holders maintained by this manager.
|
|
98
|
+
* - Empties internal maps for textures, models, and raw data (text/json/binary).
|
|
99
|
+
* - Does not forcibly dispose GPU resources; it only clears references so they can be GC'd
|
|
100
|
+
* if no other owners are holding them.
|
|
104
101
|
*/ clearCache() {
|
|
105
102
|
for(const k in Object.keys(this._textures)){
|
|
106
103
|
const v = this._textures[k];
|
|
@@ -142,13 +139,13 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
142
139
|
this._textDatas = {};
|
|
143
140
|
this._jsonDatas = {};
|
|
144
141
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Removes a cached font asset entry by URL.
|
|
147
|
-
*
|
|
148
|
-
* This only evicts the cache entry. It does not dispose any external references to the FontAsset.
|
|
149
|
-
*
|
|
150
|
-
* @param url - Resource URL or VFS path.
|
|
151
|
-
* @returns `true` if a cache entry existed and was removed.
|
|
142
|
+
/**
|
|
143
|
+
* Removes a cached font asset entry by URL.
|
|
144
|
+
*
|
|
145
|
+
* This only evicts the cache entry. It does not dispose any external references to the FontAsset.
|
|
146
|
+
*
|
|
147
|
+
* @param url - Resource URL or VFS path.
|
|
148
|
+
* @returns `true` if a cache entry existed and was removed.
|
|
152
149
|
*/ releaseFontAsset(url) {
|
|
153
150
|
if (url in this._fontAssets) {
|
|
154
151
|
delete this._fontAssets[url];
|
|
@@ -156,101 +153,97 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
156
153
|
}
|
|
157
154
|
return false;
|
|
158
155
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Register a texture loader (highest priority first).
|
|
161
|
-
*
|
|
162
|
-
* Note: This is a static registry shared by all AssetManager instances.
|
|
163
|
-
*
|
|
164
|
-
* @param loader - A concrete texture loader implementation.
|
|
156
|
+
/**
|
|
157
|
+
* Register a texture loader (highest priority first).
|
|
158
|
+
*
|
|
159
|
+
* Note: This is a static registry shared by all AssetManager instances.
|
|
160
|
+
*
|
|
161
|
+
* @param loader - A concrete texture loader implementation.
|
|
165
162
|
*/ static addTextureLoader(loader) {
|
|
166
163
|
if (loader) {
|
|
167
164
|
this._textureLoaders.unshift(loader);
|
|
168
165
|
}
|
|
169
166
|
}
|
|
170
|
-
/**
|
|
171
|
-
* Register a model loader (highest priority first).
|
|
172
|
-
|
|
173
|
-
* Note: This is a static registry shared by all AssetManager instances.
|
|
174
|
-
*
|
|
175
|
-
* @param loader - A concrete model loader implementation.
|
|
176
|
-
*/ static addModelLoader(loader) {
|
|
167
|
+
/**
|
|
168
|
+
* Register a model loader (highest priority first).
|
|
169
|
+
*/ setModelLoader(mimeType, loader) {
|
|
177
170
|
if (loader) {
|
|
178
|
-
this._modelLoaders
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Fetch a UTF-8 text resource via VFS.
|
|
183
|
-
*
|
|
184
|
-
* - Results are cached per resolved URL (via HttpRequest.urlResolver if provided; otherwise the raw URL).
|
|
185
|
-
* - If cached, any provided postProcess is ignored for subsequent calls; create a separate AssetManager
|
|
186
|
-
* if you need different post-processing of the same URL.
|
|
187
|
-
*
|
|
188
|
-
* @param url - Resource URL or VFS path.
|
|
189
|
-
* @param postProcess - Optional transformation applied to the loaded text.
|
|
190
|
-
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
191
|
-
* @returns A promise that resolves to the loaded (and optionally processed) text.
|
|
192
|
-
*/ async fetchTextData(url, postProcess, httpRequest,
|
|
171
|
+
this._modelLoaders[mimeType] = loader;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Fetch a UTF-8 text resource via VFS.
|
|
176
|
+
*
|
|
177
|
+
* - Results are cached per resolved URL (via HttpRequest.urlResolver if provided; otherwise the raw URL).
|
|
178
|
+
* - If cached, any provided postProcess is ignored for subsequent calls; create a separate AssetManager
|
|
179
|
+
* if you need different post-processing of the same URL.
|
|
180
|
+
*
|
|
181
|
+
* @param url - Resource URL or VFS path.
|
|
182
|
+
* @param postProcess - Optional transformation applied to the loaded text.
|
|
183
|
+
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
184
|
+
* @returns A promise that resolves to the loaded (and optionally processed) text.
|
|
185
|
+
*/ async fetchTextData(url, postProcess, httpRequest, options) {
|
|
193
186
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
194
187
|
let P = this._textDatas[hash];
|
|
195
188
|
if (!P) {
|
|
196
|
-
P = this.loadTextData(url, postProcess,
|
|
189
|
+
P = this.loadTextData(url, postProcess, options?.overrideVFS);
|
|
197
190
|
this._textDatas[hash] = P;
|
|
198
191
|
}
|
|
199
192
|
return P;
|
|
200
193
|
}
|
|
201
|
-
/**
|
|
202
|
-
* Fetch a JSON resource via VFS.
|
|
203
|
-
*
|
|
204
|
-
* - Parses as JSON after text load.
|
|
205
|
-
* - Cached per resolved URL. Post-process is applied only on the first load for a given cache key.
|
|
206
|
-
*
|
|
207
|
-
* @param url - Resource URL or VFS path.
|
|
208
|
-
* @param postProcess - Optional transformation applied to the parsed JSON object.
|
|
209
|
-
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
210
|
-
* @returns A promise that resolves to the loaded (and optionally processed) JSON value.
|
|
211
|
-
*/ async fetchJsonData(url, postProcess, httpRequest,
|
|
194
|
+
/**
|
|
195
|
+
* Fetch a JSON resource via VFS.
|
|
196
|
+
*
|
|
197
|
+
* - Parses as JSON after text load.
|
|
198
|
+
* - Cached per resolved URL. Post-process is applied only on the first load for a given cache key.
|
|
199
|
+
*
|
|
200
|
+
* @param url - Resource URL or VFS path.
|
|
201
|
+
* @param postProcess - Optional transformation applied to the parsed JSON object.
|
|
202
|
+
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
203
|
+
* @returns A promise that resolves to the loaded (and optionally processed) JSON value.
|
|
204
|
+
*/ async fetchJsonData(url, postProcess, httpRequest, options) {
|
|
212
205
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
213
206
|
let P = this._jsonDatas[hash];
|
|
214
207
|
if (!P) {
|
|
215
|
-
P = this.loadJsonData(url, postProcess,
|
|
208
|
+
P = this.loadJsonData(url, postProcess, options?.overrideVFS);
|
|
216
209
|
this._jsonDatas[hash] = P;
|
|
217
210
|
}
|
|
218
211
|
return P;
|
|
219
212
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Fetch a binary resource via VFS.
|
|
222
|
-
*
|
|
223
|
-
* - Cached per resolved URL. Post-process is applied only on first load for a given key.
|
|
224
|
-
*
|
|
225
|
-
* @param url - Resource URL or VFS path.
|
|
226
|
-
* @param postProcess - Optional transformation applied to the loaded ArrayBuffer.
|
|
227
|
-
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
228
|
-
* @returns A promise that resolves to the loaded (and optionally processed) ArrayBuffer.
|
|
229
|
-
*/ async fetchBinaryData(url, postProcess, httpRequest,
|
|
213
|
+
/**
|
|
214
|
+
* Fetch a binary resource via VFS.
|
|
215
|
+
*
|
|
216
|
+
* - Cached per resolved URL. Post-process is applied only on first load for a given key.
|
|
217
|
+
*
|
|
218
|
+
* @param url - Resource URL or VFS path.
|
|
219
|
+
* @param postProcess - Optional transformation applied to the loaded ArrayBuffer.
|
|
220
|
+
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
221
|
+
* @returns A promise that resolves to the loaded (and optionally processed) ArrayBuffer.
|
|
222
|
+
*/ async fetchBinaryData(url, postProcess, httpRequest, options) {
|
|
230
223
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
231
224
|
let P = this._binaryDatas[hash];
|
|
232
225
|
if (!P) {
|
|
233
|
-
P = this.loadBinaryData(url, postProcess,
|
|
226
|
+
P = this.loadBinaryData(url, postProcess, options?.overrideVFS);
|
|
234
227
|
this._binaryDatas[hash] = P;
|
|
235
228
|
}
|
|
236
229
|
return P;
|
|
237
230
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Fetch a font asset via VFS.
|
|
240
|
-
*
|
|
241
|
-
* - Cached per URL only.
|
|
242
|
-
* - `options` are applied only when the font is first loaded for that URL.
|
|
243
|
-
* - If the URL is already cached, later calls ignore `options` and reuse the cached FontAsset.
|
|
244
|
-
*
|
|
245
|
-
* @param url - Resource URL or VFS path.
|
|
246
|
-
* @param options - Optional MSDF atlas settings bound to the loaded FontAsset.
|
|
247
|
-
* @returns A promise that resolves to the loaded (and optionally processed) font asset.
|
|
248
|
-
*/ async fetchFontAsset(url, options
|
|
231
|
+
/**
|
|
232
|
+
* Fetch a font asset via VFS.
|
|
233
|
+
*
|
|
234
|
+
* - Cached per URL only.
|
|
235
|
+
* - `options` are applied only when the font is first loaded for that URL.
|
|
236
|
+
* - If the URL is already cached, later calls ignore `options` and reuse the cached FontAsset.
|
|
237
|
+
*
|
|
238
|
+
* @param url - Resource URL or VFS path.
|
|
239
|
+
* @param options - Optional MSDF atlas settings bound to the loaded FontAsset.
|
|
240
|
+
* @returns A promise that resolves to the loaded (and optionally processed) font asset.
|
|
241
|
+
*/ async fetchFontAsset(url, options) {
|
|
249
242
|
const hash = url;
|
|
250
243
|
let P = this._fontAssets[hash];
|
|
251
244
|
if (!P) {
|
|
252
245
|
P = new Promise((resolve, reject)=>{
|
|
253
|
-
this.loadBinaryData(url, null,
|
|
246
|
+
this.loadBinaryData(url, null, options?.overrideVFS).then((data)=>{
|
|
254
247
|
resolve(data ? FontAsset.fromBuffer(data, options) : null);
|
|
255
248
|
}).catch((err)=>{
|
|
256
249
|
reject(new Error(`Failed to load font asset from ${url}: ${err instanceof Error ? err.message : err}`));
|
|
@@ -260,36 +253,36 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
260
253
|
}
|
|
261
254
|
return P;
|
|
262
255
|
}
|
|
263
|
-
/**
|
|
264
|
-
* Fetch a font asset via VFS if already cached.
|
|
265
|
-
* @param url - Resource URL or VFS path.
|
|
266
|
-
* @returns The cached FontAsset if it exists and is loaded, or null if not cached or still loading.
|
|
256
|
+
/**
|
|
257
|
+
* Fetch a font asset via VFS if already cached.
|
|
258
|
+
* @param url - Resource URL or VFS path.
|
|
259
|
+
* @returns The cached FontAsset if it exists and is loaded, or null if not cached or still loading.
|
|
267
260
|
*/ getFontAsset(url) {
|
|
268
261
|
const hash = url;
|
|
269
262
|
return this._fontAssets[hash] instanceof Promise ? null : this._fontAssets[hash] ?? null;
|
|
270
263
|
}
|
|
271
|
-
async fetchBluePrint(url,
|
|
264
|
+
async fetchBluePrint(url, options) {
|
|
272
265
|
const hash = url;
|
|
273
266
|
let P = this._bluePrints[hash];
|
|
274
267
|
if (!P) {
|
|
275
|
-
P = this.loadBluePrint(url,
|
|
268
|
+
P = this.loadBluePrint(url, options?.overrideVFS);
|
|
276
269
|
this._bluePrints[hash] = P;
|
|
277
270
|
}
|
|
278
271
|
return P;
|
|
279
272
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Fetch a material resource.
|
|
282
|
-
*
|
|
283
|
-
* @typeParam T - Expected concrete material type.
|
|
284
|
-
* @param url - Resource URL or VFS path.
|
|
285
|
-
* @returns A promise that resolves to the loaded material.
|
|
286
|
-
*/ async fetchMaterial(url,
|
|
273
|
+
/**
|
|
274
|
+
* Fetch a material resource.
|
|
275
|
+
*
|
|
276
|
+
* @typeParam T - Expected concrete material type.
|
|
277
|
+
* @param url - Resource URL or VFS path.
|
|
278
|
+
* @returns A promise that resolves to the loaded material.
|
|
279
|
+
*/ async fetchMaterial(url, options) {
|
|
287
280
|
const hash = url;
|
|
288
281
|
let P = this._materials[hash];
|
|
289
282
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
290
283
|
return P.get();
|
|
291
284
|
} else if (!P || P instanceof DWeakRef) {
|
|
292
|
-
P = this.loadMaterial(url, false,
|
|
285
|
+
P = this.loadMaterial(url, false, options?.overrideVFS);
|
|
293
286
|
this._materials[hash] = P;
|
|
294
287
|
}
|
|
295
288
|
const material = await P;
|
|
@@ -298,19 +291,19 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
298
291
|
}
|
|
299
292
|
return material;
|
|
300
293
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Fetch a primitive resource.
|
|
303
|
-
*
|
|
304
|
-
* @typeParam T - Expected concrete primitive type.
|
|
305
|
-
* @param url - Resource URL or VFS path.
|
|
306
|
-
* @returns A promise that resolves to the loaded primitive.
|
|
307
|
-
*/ async fetchPrimitive(url,
|
|
294
|
+
/**
|
|
295
|
+
* Fetch a primitive resource.
|
|
296
|
+
*
|
|
297
|
+
* @typeParam T - Expected concrete primitive type.
|
|
298
|
+
* @param url - Resource URL or VFS path.
|
|
299
|
+
* @returns A promise that resolves to the loaded primitive.
|
|
300
|
+
*/ async fetchPrimitive(url, options) {
|
|
308
301
|
const hash = url;
|
|
309
302
|
let P = this._primitives[hash];
|
|
310
303
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
311
304
|
return P.get();
|
|
312
305
|
} else if (!P || P instanceof DWeakRef) {
|
|
313
|
-
P = this.loadPrimitive(url,
|
|
306
|
+
P = this.loadPrimitive(url, options?.overrideVFS);
|
|
314
307
|
this._primitives[hash] = P;
|
|
315
308
|
}
|
|
316
309
|
const primitive = await P;
|
|
@@ -319,29 +312,29 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
319
312
|
}
|
|
320
313
|
return primitive;
|
|
321
314
|
}
|
|
322
|
-
/**
|
|
323
|
-
* Fetch a texture resource via registered loaders.
|
|
324
|
-
*
|
|
325
|
-
* - Chooses loader by explicit MIME type or by VFS file extension inference.
|
|
326
|
-
* - Deduplicates in-flight requests and caches ready textures.
|
|
327
|
-
* - If `options.texture` is provided, the asset will be uploaded/blitted into that texture.
|
|
328
|
-
* - On WebGL backends, enforces constraints by repacking non-power-of-two or sRGB textures.
|
|
329
|
-
*
|
|
330
|
-
* @typeParam T - Expected concrete texture type.
|
|
331
|
-
* @param url - Resource URL or VFS path.
|
|
332
|
-
* @param options - Texture fetching options (color space, sampler, target texture).
|
|
333
|
-
* @param httpRequest - Optional HttpRequest (not used for binary read but may supply URL resolver for hashing).
|
|
334
|
-
* @returns A promise that resolves to the loaded texture.
|
|
335
|
-
*/ async fetchTexture(url, options
|
|
315
|
+
/**
|
|
316
|
+
* Fetch a texture resource via registered loaders.
|
|
317
|
+
*
|
|
318
|
+
* - Chooses loader by explicit MIME type or by VFS file extension inference.
|
|
319
|
+
* - Deduplicates in-flight requests and caches ready textures.
|
|
320
|
+
* - If `options.texture` is provided, the asset will be uploaded/blitted into that texture.
|
|
321
|
+
* - On WebGL backends, enforces constraints by repacking non-power-of-two or sRGB textures.
|
|
322
|
+
*
|
|
323
|
+
* @typeParam T - Expected concrete texture type.
|
|
324
|
+
* @param url - Resource URL or VFS path.
|
|
325
|
+
* @param options - Texture fetching options (color space, sampler, target texture).
|
|
326
|
+
* @param httpRequest - Optional HttpRequest (not used for binary read but may supply URL resolver for hashing).
|
|
327
|
+
* @returns A promise that resolves to the loaded texture.
|
|
328
|
+
*/ async fetchTexture(url, options) {
|
|
336
329
|
if (options?.texture) {
|
|
337
|
-
return this.loadTexture(url, options.mimeType ?? null, !options.linearColorSpace, options.samplerOptions, options.texture,
|
|
330
|
+
return this.loadTexture(url, options.mimeType ?? null, !options.linearColorSpace, options.samplerOptions, options.texture, options.overrideVFS);
|
|
338
331
|
} else {
|
|
339
332
|
const hash = this.getHash('2d', url, options);
|
|
340
333
|
let P = this._textures[hash];
|
|
341
334
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
342
335
|
return P.get();
|
|
343
336
|
} else if (!P || P instanceof DWeakRef) {
|
|
344
|
-
P = this.loadTexture(url, options?.mimeType ?? null, !options?.linearColorSpace, options?.samplerOptions, null,
|
|
337
|
+
P = this.loadTexture(url, options?.mimeType ?? null, !options?.linearColorSpace, options?.samplerOptions, null, options?.overrideVFS);
|
|
345
338
|
this._textures[hash] = P;
|
|
346
339
|
}
|
|
347
340
|
const tex = await P;
|
|
@@ -351,23 +344,23 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
351
344
|
return tex;
|
|
352
345
|
}
|
|
353
346
|
}
|
|
354
|
-
/**
|
|
355
|
-
* Fetch a model resource via registered model loaders (data only).
|
|
356
|
-
*
|
|
357
|
-
* - Returns a SharedModel which can create scene nodes in any Scene.
|
|
358
|
-
* - Uses DWeakRef to cache and allow model data to be reclaimed if unused.
|
|
359
|
-
*
|
|
360
|
-
* @param url - Model URL or VFS path.
|
|
361
|
-
* @param options - Model loader options (MIME override, Draco, instancing hint, post-process).
|
|
362
|
-
* @returns A promise that resolves to the SharedModel.
|
|
363
|
-
* @internal
|
|
364
|
-
*/ async fetchModelData(url, options
|
|
347
|
+
/**
|
|
348
|
+
* Fetch a model resource via registered model loaders (data only).
|
|
349
|
+
*
|
|
350
|
+
* - Returns a SharedModel which can create scene nodes in any Scene.
|
|
351
|
+
* - Uses DWeakRef to cache and allow model data to be reclaimed if unused.
|
|
352
|
+
*
|
|
353
|
+
* @param url - Model URL or VFS path.
|
|
354
|
+
* @param options - Model loader options (MIME override, Draco, instancing hint, post-process).
|
|
355
|
+
* @returns A promise that resolves to the SharedModel.
|
|
356
|
+
* @internal
|
|
357
|
+
*/ async fetchModelData(url, options) {
|
|
365
358
|
const hash = url;
|
|
366
359
|
let P = this._models[hash];
|
|
367
360
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
368
361
|
return P.get();
|
|
369
362
|
} else if (!P || P instanceof DWeakRef) {
|
|
370
|
-
P = this.loadModel(url, options,
|
|
363
|
+
P = this.loadModel(url, options, options?.overrideVFS);
|
|
371
364
|
this._models[hash] = P;
|
|
372
365
|
}
|
|
373
366
|
const sharedModel = await P;
|
|
@@ -376,38 +369,46 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
376
369
|
}
|
|
377
370
|
return sharedModel;
|
|
378
371
|
}
|
|
379
|
-
/**
|
|
380
|
-
* Fetch a model resource and instantiate it under a scene.
|
|
381
|
-
*
|
|
382
|
-
* - Loads or retrieves a cached SharedModel, then creates a SceneNode hierarchy.
|
|
383
|
-
* - Returns both the created group node and any associated AnimationSet.
|
|
384
|
-
*
|
|
385
|
-
* @param scene - Scene into which the model node will be created.
|
|
386
|
-
* @param url - Model URL or VFS path.
|
|
387
|
-
* @param options - Model loader options and instancing hint.
|
|
388
|
-
* @param httpRequest - Optional HttpRequest (unused for binary read; present for API symmetry).
|
|
389
|
-
* @returns A promise with the created node group and animation set info.
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
372
|
+
/**
|
|
373
|
+
* Fetch a model resource and instantiate it under a scene.
|
|
374
|
+
*
|
|
375
|
+
* - Loads or retrieves a cached SharedModel, then creates a SceneNode hierarchy.
|
|
376
|
+
* - Returns both the created group node and any associated AnimationSet.
|
|
377
|
+
*
|
|
378
|
+
* @param scene - Scene into which the model node will be created.
|
|
379
|
+
* @param url - Model URL or VFS path.
|
|
380
|
+
* @param options - Model loader options and instancing hint.
|
|
381
|
+
* @param httpRequest - Optional HttpRequest (unused for binary read; present for API symmetry).
|
|
382
|
+
* @returns A promise with the created node group and animation set info.
|
|
383
|
+
*
|
|
384
|
+
* @internal
|
|
385
|
+
*/ async fetchModel(scene, url, options) {
|
|
386
|
+
const sharedModel = new DRef();
|
|
387
|
+
try {
|
|
388
|
+
sharedModel.set(await this.fetchModelData(url, options));
|
|
389
|
+
const node = await sharedModel.get().createSceneNode(getEngine().resourceManager, scene, options?.enableInstancing ?? false, options?.loadMeshes ?? true, options?.loadSkeletons ?? true, options?.loadAnimations ?? true, options?.loadJointDynamics ?? true, options?.overrideVFS ?? getEngine().resourceManager.VFS);
|
|
390
|
+
node.sharedModel = sharedModel.get();
|
|
391
|
+
node.animationSet.resetSkeletonModifiers();
|
|
392
|
+
return node;
|
|
393
|
+
} catch (err) {
|
|
394
|
+
console.error(`Load model failed: ${url}: ${err}`);
|
|
395
|
+
} finally{
|
|
396
|
+
sharedModel.dispose();
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Load a text resource via VFS and optionally post-process it.
|
|
401
|
+
*
|
|
402
|
+
* - Does not use or modify the internal cache; use fetchTextData for cached loads.
|
|
403
|
+
*
|
|
404
|
+
* @param url - Resource URL or VFS path.
|
|
405
|
+
* @param postProcess - Optional transformation applied to the text.
|
|
406
|
+
* @returns A promise that resolves to the loaded (and optionally processed) text.
|
|
407
|
+
* @internal
|
|
408
|
+
*/ async loadTextData(url, postProcess, vfs) {
|
|
409
|
+
let text = await this.readFileFromVFS(url, {
|
|
409
410
|
encoding: 'utf8'
|
|
410
|
-
},
|
|
411
|
+
}, vfs);
|
|
411
412
|
if (postProcess) {
|
|
412
413
|
try {
|
|
413
414
|
text = postProcess(text);
|
|
@@ -417,19 +418,19 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
417
418
|
}
|
|
418
419
|
return text;
|
|
419
420
|
}
|
|
420
|
-
/**
|
|
421
|
-
* Load a JSON resource via VFS and optionally post-process it.
|
|
422
|
-
*
|
|
423
|
-
* - Does not use or modify the internal cache; use fetchJsonData for cached loads.
|
|
424
|
-
*
|
|
425
|
-
* @param url - Resource URL or VFS path.
|
|
426
|
-
* @param postProcess - Optional transformation applied to the parsed JSON.
|
|
427
|
-
* @returns A promise that resolves to the loaded (and optionally processed) JSON.
|
|
428
|
-
* @internal
|
|
429
|
-
*/ async loadJsonData(url, postProcess,
|
|
430
|
-
let json = JSON.parse(await this.
|
|
421
|
+
/**
|
|
422
|
+
* Load a JSON resource via VFS and optionally post-process it.
|
|
423
|
+
*
|
|
424
|
+
* - Does not use or modify the internal cache; use fetchJsonData for cached loads.
|
|
425
|
+
*
|
|
426
|
+
* @param url - Resource URL or VFS path.
|
|
427
|
+
* @param postProcess - Optional transformation applied to the parsed JSON.
|
|
428
|
+
* @returns A promise that resolves to the loaded (and optionally processed) JSON.
|
|
429
|
+
* @internal
|
|
430
|
+
*/ async loadJsonData(url, postProcess, vfs) {
|
|
431
|
+
let json = JSON.parse(await this.readFileFromVFS(url, {
|
|
431
432
|
encoding: 'utf8'
|
|
432
|
-
},
|
|
433
|
+
}, vfs));
|
|
433
434
|
if (postProcess) {
|
|
434
435
|
try {
|
|
435
436
|
json = postProcess(json);
|
|
@@ -439,20 +440,20 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
439
440
|
}
|
|
440
441
|
return json;
|
|
441
442
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Load a binary resource via VFS and optionally post-process it.
|
|
444
|
-
*
|
|
445
|
-
* - Does not use or modify the internal cache; use fetchBinaryData for cached loads.
|
|
446
|
-
*
|
|
447
|
-
* @param url - Resource URL or VFS path.
|
|
448
|
-
* @param postProcess - Optional transformation applied to the ArrayBuffer.
|
|
449
|
-
* @returns A promise that resolves to the loaded (and optionally processed) ArrayBuffer.
|
|
450
|
-
* @internal
|
|
451
|
-
*/ async loadBinaryData(url, postProcess,
|
|
443
|
+
/**
|
|
444
|
+
* Load a binary resource via VFS and optionally post-process it.
|
|
445
|
+
*
|
|
446
|
+
* - Does not use or modify the internal cache; use fetchBinaryData for cached loads.
|
|
447
|
+
*
|
|
448
|
+
* @param url - Resource URL or VFS path.
|
|
449
|
+
* @param postProcess - Optional transformation applied to the ArrayBuffer.
|
|
450
|
+
* @returns A promise that resolves to the loaded (and optionally processed) ArrayBuffer.
|
|
451
|
+
* @internal
|
|
452
|
+
*/ async loadBinaryData(url, postProcess, vfs) {
|
|
452
453
|
try {
|
|
453
|
-
let data = await this.
|
|
454
|
+
let data = await this.readFileFromVFS(url, {
|
|
454
455
|
encoding: 'binary'
|
|
455
|
-
},
|
|
456
|
+
}, vfs);
|
|
456
457
|
if (postProcess) {
|
|
457
458
|
data = postProcess(data);
|
|
458
459
|
}
|
|
@@ -462,11 +463,11 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
462
463
|
return null;
|
|
463
464
|
}
|
|
464
465
|
}
|
|
465
|
-
async loadPrimitive(url,
|
|
466
|
+
async loadPrimitive(url, vfs) {
|
|
466
467
|
try {
|
|
467
|
-
const data = await this.
|
|
468
|
+
const data = await this.readFileFromVFS(url, {
|
|
468
469
|
encoding: 'utf8'
|
|
469
|
-
},
|
|
470
|
+
}, vfs);
|
|
470
471
|
const content = JSON.parse(data);
|
|
471
472
|
ASSERT(content.type === 'Primitive' || content.type === 'Default', `Unsupported primitive type: ${content.type}`);
|
|
472
473
|
if (content.type === 'Primitive') {
|
|
@@ -532,20 +533,22 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
532
533
|
}
|
|
533
534
|
}
|
|
534
535
|
}
|
|
535
|
-
async loadBluePrintMaterialData(url, reload,
|
|
536
|
+
async loadBluePrintMaterialData(url, reload, vfs) {
|
|
536
537
|
try {
|
|
537
538
|
let irData;
|
|
538
539
|
if (typeof url === 'string') {
|
|
539
|
-
const data = await this.
|
|
540
|
+
const data = await this.readFileFromVFS(url, {
|
|
540
541
|
encoding: 'utf8'
|
|
541
|
-
},
|
|
542
|
+
}, vfs);
|
|
542
543
|
const content = JSON.parse(data);
|
|
543
544
|
ASSERT(content.type === 'PBRBluePrintMaterial' || content.type === 'SpriteBluePrintMaterial', `Unsupported material type: ${content.type}`);
|
|
544
545
|
irData = content.data;
|
|
545
546
|
} else {
|
|
546
547
|
irData = url;
|
|
547
548
|
}
|
|
548
|
-
const ir = reload ? await this.loadBluePrint(irData.IR,
|
|
549
|
+
const ir = reload ? await this.loadBluePrint(irData.IR, vfs) : await this.fetchBluePrint(irData.IR, vfs ? {
|
|
550
|
+
overrideVFS: vfs
|
|
551
|
+
} : undefined);
|
|
549
552
|
const uniformValues = irData.uniformValues.map((v)=>({
|
|
550
553
|
...v,
|
|
551
554
|
finalValue: v.value.length === 1 ? v.value[0] : new Float32Array(v.value)
|
|
@@ -554,8 +557,9 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
554
557
|
const textures = irData.uniformTextures;
|
|
555
558
|
for (const v of textures){
|
|
556
559
|
const tex = await this.fetchTexture(v.texture, {
|
|
557
|
-
linearColorSpace: !v.sRGB
|
|
558
|
-
|
|
560
|
+
linearColorSpace: !v.sRGB,
|
|
561
|
+
overrideVFS: vfs
|
|
562
|
+
});
|
|
559
563
|
uniformTextures.push({
|
|
560
564
|
...v,
|
|
561
565
|
finalTexture: new DRef(tex),
|
|
@@ -580,27 +584,27 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
580
584
|
return null;
|
|
581
585
|
}
|
|
582
586
|
}
|
|
583
|
-
/**
|
|
584
|
-
* Load a material.
|
|
585
|
-
*
|
|
586
|
-
* - Does not use or modify the internal cache; use fetchMaterial for cached loads.
|
|
587
|
-
*
|
|
588
|
-
* @param url - Resource URL or VFS path.
|
|
589
|
-
* @returns A promise that resolves to the loaded material.
|
|
590
|
-
* @internal
|
|
591
|
-
*/ async loadMaterial(url, reload,
|
|
587
|
+
/**
|
|
588
|
+
* Load a material.
|
|
589
|
+
*
|
|
590
|
+
* - Does not use or modify the internal cache; use fetchMaterial for cached loads.
|
|
591
|
+
*
|
|
592
|
+
* @param url - Resource URL or VFS path.
|
|
593
|
+
* @returns A promise that resolves to the loaded material.
|
|
594
|
+
* @internal
|
|
595
|
+
*/ async loadMaterial(url, reload, vfs) {
|
|
592
596
|
try {
|
|
593
|
-
const data = await this.
|
|
597
|
+
const data = await this.readFileFromVFS(url, {
|
|
594
598
|
encoding: 'utf8'
|
|
595
|
-
},
|
|
599
|
+
}, vfs);
|
|
596
600
|
const content = JSON.parse(data);
|
|
597
601
|
ASSERT(content.type === 'PBRBluePrintMaterial' || content.type === 'SpriteBluePrintMaterial' || content.type === 'Default', `Unsupported material type: ${content.type}`);
|
|
598
602
|
let mat;
|
|
599
603
|
if (content.type === 'PBRBluePrintMaterial') {
|
|
600
|
-
const data = await this.loadBluePrintMaterialData(content.data, reload,
|
|
604
|
+
const data = await this.loadBluePrintMaterialData(content.data, reload, vfs);
|
|
601
605
|
mat = new PBRBluePrintMaterial(data.irFragment, data.irVertex, data.uniformValues, data.uniformTextures);
|
|
602
606
|
} else if (content.type === 'SpriteBluePrintMaterial') {
|
|
603
|
-
const data = await this.loadBluePrintMaterialData(content.data, reload,
|
|
607
|
+
const data = await this.loadBluePrintMaterialData(content.data, reload, vfs);
|
|
604
608
|
mat = new SpriteBlueprintMaterial(data.irFragment, data.uniformValues, data.uniformTextures);
|
|
605
609
|
} else {
|
|
606
610
|
const obj = await this._resourceManager.deserializeObject(null, content.data);
|
|
@@ -743,11 +747,11 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
743
747
|
invalidateBluePrint(path) {
|
|
744
748
|
delete this._bluePrints[path];
|
|
745
749
|
}
|
|
746
|
-
async loadBluePrint(path,
|
|
750
|
+
async loadBluePrint(path, vfs) {
|
|
747
751
|
try {
|
|
748
|
-
const content = await this.
|
|
752
|
+
const content = await this.readFileFromVFS(path, {
|
|
749
753
|
encoding: 'utf8'
|
|
750
|
-
},
|
|
754
|
+
}, vfs);
|
|
751
755
|
const bp = JSON.parse(content);
|
|
752
756
|
ASSERT(bp.type === 'PBRMaterial' || bp.type === 'SpriteMaterial' || bp.type === 'MaterialFunction', `Unsupported blueprint type: ${bp.type}`);
|
|
753
757
|
const states = bp.state;
|
|
@@ -773,19 +777,19 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
773
777
|
return null;
|
|
774
778
|
}
|
|
775
779
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Load a texture directly from an ArrayBuffer or typed array.
|
|
778
|
-
*
|
|
779
|
-
* - Chooses an appropriate loader based on the provided MIME type.
|
|
780
|
-
* - Can upload into an existing texture if `texture` is specified.
|
|
781
|
-
*
|
|
782
|
-
* @typeParam T - Expected concrete texture type.
|
|
783
|
-
* @param arrayBuffer - Raw texture data buffer.
|
|
784
|
-
* @param mimeType - MIME type of the texture (must be supported by a registered loader).
|
|
785
|
-
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
786
|
-
* @param samplerOptions - Optional sampler options passed to the loader path.
|
|
787
|
-
* @param texture - Optional destination texture to populate.
|
|
788
|
-
* @returns A promise that resolves to the created or populated texture.
|
|
780
|
+
/**
|
|
781
|
+
* Load a texture directly from an ArrayBuffer or typed array.
|
|
782
|
+
*
|
|
783
|
+
* - Chooses an appropriate loader based on the provided MIME type.
|
|
784
|
+
* - Can upload into an existing texture if `texture` is specified.
|
|
785
|
+
*
|
|
786
|
+
* @typeParam T - Expected concrete texture type.
|
|
787
|
+
* @param arrayBuffer - Raw texture data buffer.
|
|
788
|
+
* @param mimeType - MIME type of the texture (must be supported by a registered loader).
|
|
789
|
+
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
790
|
+
* @param samplerOptions - Optional sampler options passed to the loader path.
|
|
791
|
+
* @param texture - Optional destination texture to populate.
|
|
792
|
+
* @returns A promise that resolves to the created or populated texture.
|
|
789
793
|
*/ async loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture) {
|
|
790
794
|
for (const loader of AssetManager._textureLoaders){
|
|
791
795
|
if (!loader.supportMIMEType(mimeType)) {
|
|
@@ -796,24 +800,24 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
796
800
|
}
|
|
797
801
|
throw new Error(`Can not find loader for MIME type '${mimeType}'`);
|
|
798
802
|
}
|
|
799
|
-
/**
|
|
800
|
-
* Load a texture via VFS by URL and MIME type.
|
|
801
|
-
*
|
|
802
|
-
* - Uses the first loader that supports the inferred or provided MIME type.
|
|
803
|
-
* - On WebGL, may repack textures (resample to power-of-two, convert formats) to meet backend constraints.
|
|
804
|
-
* - If `texture` is provided, the source is blitted into it, possibly resizing or changing sampling accordingly.
|
|
805
|
-
*
|
|
806
|
-
* @param url - Texture URL or VFS path.
|
|
807
|
-
* @param mimeType - Optional explicit MIME type; otherwise inferred by VFS.
|
|
808
|
-
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
809
|
-
* @param samplerOptions - Optional sampler options for loader or blit path.
|
|
810
|
-
* @param texture - Optional destination texture to populate.
|
|
811
|
-
* @returns A promise that resolves to the created or populated texture.
|
|
812
|
-
* @internal
|
|
813
|
-
*/ async loadTexture(url, mimeType, srgb, samplerOptions, texture,
|
|
814
|
-
const data = await this.
|
|
803
|
+
/**
|
|
804
|
+
* Load a texture via VFS by URL and MIME type.
|
|
805
|
+
*
|
|
806
|
+
* - Uses the first loader that supports the inferred or provided MIME type.
|
|
807
|
+
* - On WebGL, may repack textures (resample to power-of-two, convert formats) to meet backend constraints.
|
|
808
|
+
* - If `texture` is provided, the source is blitted into it, possibly resizing or changing sampling accordingly.
|
|
809
|
+
*
|
|
810
|
+
* @param url - Texture URL or VFS path.
|
|
811
|
+
* @param mimeType - Optional explicit MIME type; otherwise inferred by VFS.
|
|
812
|
+
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
813
|
+
* @param samplerOptions - Optional sampler options for loader or blit path.
|
|
814
|
+
* @param texture - Optional destination texture to populate.
|
|
815
|
+
* @returns A promise that resolves to the created or populated texture.
|
|
816
|
+
* @internal
|
|
817
|
+
*/ async loadTexture(url, mimeType, srgb, samplerOptions, texture, vfs) {
|
|
818
|
+
const data = await this.readFileFromVFS(url, {
|
|
815
819
|
encoding: 'binary'
|
|
816
|
-
},
|
|
820
|
+
}, vfs);
|
|
817
821
|
mimeType = mimeType ?? this.vfs.guessMIMEType(url);
|
|
818
822
|
for (const loader of AssetManager._textureLoaders){
|
|
819
823
|
if (!loader.supportMIMEType(mimeType)) {
|
|
@@ -827,18 +831,18 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
827
831
|
}
|
|
828
832
|
throw new Error(`Can not find loader for asset ${url}`);
|
|
829
833
|
}
|
|
830
|
-
/**
|
|
831
|
-
* Internal routine that executes the texture load using a specific loader and applies
|
|
832
|
-
* backend-specific compatibility steps (e.g., WebGL NPOT/sRGB rules).
|
|
833
|
-
*
|
|
834
|
-
* @param loader - Concrete loader to use for decoding/creation.
|
|
835
|
-
* @param mimeType - Texture MIME type.
|
|
836
|
-
* @param data - Raw binary data.
|
|
837
|
-
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
838
|
-
* @param samplerOptions - Optional sampler options.
|
|
839
|
-
* @param texture - Optional destination texture to populate.
|
|
840
|
-
* @returns A promise that resolves to the created or populated texture.
|
|
841
|
-
* @internal
|
|
834
|
+
/**
|
|
835
|
+
* Internal routine that executes the texture load using a specific loader and applies
|
|
836
|
+
* backend-specific compatibility steps (e.g., WebGL NPOT/sRGB rules).
|
|
837
|
+
*
|
|
838
|
+
* @param loader - Concrete loader to use for decoding/creation.
|
|
839
|
+
* @param mimeType - Texture MIME type.
|
|
840
|
+
* @param data - Raw binary data.
|
|
841
|
+
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
842
|
+
* @param samplerOptions - Optional sampler options.
|
|
843
|
+
* @param texture - Optional destination texture to populate.
|
|
844
|
+
* @returns A promise that resolves to the created or populated texture.
|
|
845
|
+
* @internal
|
|
842
846
|
*/ async doLoadTexture(loader, mimeType, data, srgb, samplerOptions, texture) {
|
|
843
847
|
const device = getDevice();
|
|
844
848
|
if (device.type !== 'webgl') {
|
|
@@ -889,33 +893,22 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
889
893
|
return tex;
|
|
890
894
|
}
|
|
891
895
|
}
|
|
892
|
-
/**
|
|
893
|
-
* Load a model via registered model loaders.
|
|
894
|
-
*
|
|
895
|
-
* - Selects loader by MIME type (explicit or inferred).
|
|
896
|
-
* - Optionally applies a post-process transform to the SharedModel.
|
|
897
|
-
* - Sets the model's name from the source filename for convenience.
|
|
898
|
-
*
|
|
899
|
-
* @param url - Model URL or VFS path.
|
|
900
|
-
* @param options - Model load options (MIME override, Draco module, post-process hook).
|
|
901
|
-
* @returns A promise that resolves to the loaded SharedModel.
|
|
902
|
-
* @internal
|
|
903
|
-
*/ async loadModel(url, options,
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const data = new Blob([
|
|
909
|
-
arrayBuffer
|
|
910
|
-
], {
|
|
911
|
-
type: mimeType
|
|
912
|
-
});
|
|
913
|
-
const filename = this.vfs.basename(url);
|
|
914
|
-
for (const loader of AssetManager._modelLoaders){
|
|
915
|
-
if (!loader.supportMIMEType(mimeType)) {
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
let model = await loader.load(this, url, options?.mimeType || data.type, data, options?.dracoDecoderModule, VFSs);
|
|
896
|
+
/**
|
|
897
|
+
* Load a model via registered model loaders.
|
|
898
|
+
*
|
|
899
|
+
* - Selects loader by MIME type (explicit or inferred).
|
|
900
|
+
* - Optionally applies a post-process transform to the SharedModel.
|
|
901
|
+
* - Sets the model's name from the source filename for convenience.
|
|
902
|
+
*
|
|
903
|
+
* @param url - Model URL or VFS path.
|
|
904
|
+
* @param options - Model load options (MIME override, Draco module, post-process hook).
|
|
905
|
+
* @returns A promise that resolves to the loaded SharedModel.
|
|
906
|
+
* @internal
|
|
907
|
+
*/ async loadModel(url, options, vfs) {
|
|
908
|
+
const mimeType = options?.mimeType || guessMimeType(url);
|
|
909
|
+
const importer = this._modelLoaders[mimeType];
|
|
910
|
+
if (importer) {
|
|
911
|
+
let model = await importer.loadModel(url, vfs);
|
|
919
912
|
if (!model) {
|
|
920
913
|
throw new Error(`Load asset failed: ${url}`);
|
|
921
914
|
}
|
|
@@ -926,22 +919,21 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
926
919
|
throw new Error(`Model loader post process failed: ${err}`);
|
|
927
920
|
}
|
|
928
921
|
}
|
|
929
|
-
model.name = filename;
|
|
930
922
|
return model;
|
|
931
923
|
}
|
|
932
924
|
throw new Error(`Can not find loader for asset ${url}`);
|
|
933
925
|
}
|
|
934
|
-
/**
|
|
935
|
-
* Fetch a built-in texture synchronously by name.
|
|
936
|
-
*
|
|
937
|
-
* - If this built-in was not created yet, the registered loader is invoked.
|
|
938
|
-
* - Registers a device restore handler so the texture can be re-initialized after device loss.
|
|
939
|
-
* - If an existing texture is provided, the loader uploads into it.
|
|
940
|
-
*
|
|
941
|
-
* @typeParam T - Expected concrete texture type.
|
|
942
|
-
* @param name - Built-in texture identifier.
|
|
943
|
-
* @param texture - Optional destination texture to populate.
|
|
944
|
-
* @returns The built-in texture (created or populated).
|
|
926
|
+
/**
|
|
927
|
+
* Fetch a built-in texture synchronously by name.
|
|
928
|
+
*
|
|
929
|
+
* - If this built-in was not created yet, the registered loader is invoked.
|
|
930
|
+
* - Registers a device restore handler so the texture can be re-initialized after device loss.
|
|
931
|
+
* - If an existing texture is provided, the loader uploads into it.
|
|
932
|
+
*
|
|
933
|
+
* @typeParam T - Expected concrete texture type.
|
|
934
|
+
* @param name - Built-in texture identifier.
|
|
935
|
+
* @param texture - Optional destination texture to populate.
|
|
936
|
+
* @returns The built-in texture (created or populated).
|
|
945
937
|
*/ fetchBuiltinTexture(name, texture) {
|
|
946
938
|
const loader = AssetManager._builtinTextureLoaders[name];
|
|
947
939
|
if (!loader) {
|
|
@@ -961,14 +953,14 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
961
953
|
return texture;
|
|
962
954
|
}
|
|
963
955
|
}
|
|
964
|
-
/**
|
|
965
|
-
* Override or unregister the loader for a named built-in texture.
|
|
966
|
-
*
|
|
967
|
-
* - Passing a valid loader function sets/overrides the creation path.
|
|
968
|
-
* - Passing `undefined` removes the loader mapping for the given name.
|
|
969
|
-
*
|
|
970
|
-
* @param name - Built-in texture identifier.
|
|
971
|
-
* @param loader - Factory that creates the built-in texture using the provided AssetManager.
|
|
956
|
+
/**
|
|
957
|
+
* Override or unregister the loader for a named built-in texture.
|
|
958
|
+
*
|
|
959
|
+
* - Passing a valid loader function sets/overrides the creation path.
|
|
960
|
+
* - Passing `undefined` removes the loader mapping for the given name.
|
|
961
|
+
*
|
|
962
|
+
* @param name - Built-in texture identifier.
|
|
963
|
+
* @param loader - Factory that creates the built-in texture using the provided AssetManager.
|
|
972
964
|
*/ static setBuiltinTextureLoader(name, loader) {
|
|
973
965
|
if (loader) {
|
|
974
966
|
this._builtinTextureLoaders[name] = loader;
|
|
@@ -976,54 +968,41 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
976
968
|
delete this._builtinTextureLoaders[name];
|
|
977
969
|
}
|
|
978
970
|
}
|
|
979
|
-
/**
|
|
980
|
-
* Compute a cache key for texture requests.
|
|
981
|
-
*
|
|
982
|
-
* Includes texture type tag, URL, and color space choice to avoid cross-color-space cache collisions.
|
|
983
|
-
*
|
|
984
|
-
* @typeParam T - Texture type parameter (not used for runtime behavior; helps preserve generic intent).
|
|
985
|
-
* @param type - Logical texture type tag (e.g., '2d', 'cube').
|
|
986
|
-
* @param url - Resource URL or VFS path.
|
|
987
|
-
* @param options - Texture fetch options to incorporate into the key.
|
|
988
|
-
* @returns A string cache key combining type, URL, and color space choice.
|
|
989
|
-
* @internal
|
|
971
|
+
/**
|
|
972
|
+
* Compute a cache key for texture requests.
|
|
973
|
+
*
|
|
974
|
+
* Includes texture type tag, URL, and color space choice to avoid cross-color-space cache collisions.
|
|
975
|
+
*
|
|
976
|
+
* @typeParam T - Texture type parameter (not used for runtime behavior; helps preserve generic intent).
|
|
977
|
+
* @param type - Logical texture type tag (e.g., '2d', 'cube').
|
|
978
|
+
* @param url - Resource URL or VFS path.
|
|
979
|
+
* @param options - Texture fetch options to incorporate into the key.
|
|
980
|
+
* @returns A string cache key combining type, URL, and color space choice.
|
|
981
|
+
* @internal
|
|
990
982
|
*/ getHash(type, url, options) {
|
|
991
983
|
return `${type}:${url}:${!options?.linearColorSpace}`;
|
|
992
984
|
}
|
|
993
|
-
/**
|
|
994
|
-
* Try reading from file from a
|
|
995
|
-
*
|
|
996
|
-
* @param path - File path
|
|
997
|
-
* @param options - Read options
|
|
998
|
-
* @param
|
|
999
|
-
* @returns File content
|
|
1000
|
-
*
|
|
1001
|
-
* @internal
|
|
1002
|
-
*/ async
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
* Write file to a list of VFSs
|
|
1015
|
-
*
|
|
1016
|
-
* @param path - File path
|
|
1017
|
-
* @param data - Data to write
|
|
1018
|
-
* @param options - Write options
|
|
1019
|
-
* @param vfsList - Which VFSs will be written to
|
|
1020
|
-
*/ async writeFileToVFSs(path, data, options, vfsList) {
|
|
1021
|
-
vfsList = vfsList ?? [
|
|
1022
|
-
this.vfs
|
|
1023
|
-
];
|
|
1024
|
-
for (const vfs of vfsList){
|
|
1025
|
-
await vfs.writeFile(path, data, options);
|
|
1026
|
-
}
|
|
985
|
+
/**
|
|
986
|
+
* Try reading from file from a VFS
|
|
987
|
+
*
|
|
988
|
+
* @param path - File path
|
|
989
|
+
* @param options - Read options
|
|
990
|
+
* @param vfs - VFS to read from
|
|
991
|
+
* @returns File content
|
|
992
|
+
*
|
|
993
|
+
* @internal
|
|
994
|
+
*/ async readFileFromVFS(path, options, vfs) {
|
|
995
|
+
return await (vfs ?? this.vfs).readFile(path, options);
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Write file to a VFS
|
|
999
|
+
*
|
|
1000
|
+
* @param path - File path
|
|
1001
|
+
* @param data - Data to write
|
|
1002
|
+
* @param options - Write options
|
|
1003
|
+
* @param vfs - VFS to write to
|
|
1004
|
+
*/ async writeFileToVFSs(path, data, options, vfs) {
|
|
1005
|
+
await (vfs ?? this.vfs).writeFile(path, data, options);
|
|
1027
1006
|
}
|
|
1028
1007
|
}
|
|
1029
1008
|
|