@zephyr3d/scene 0.9.26 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -27
- package/dist/animation/animation_bank.js +634 -0
- package/dist/animation/animation_bank.js.map +1 -0
- package/dist/animation/animation_bank_gpu.js +256 -0
- package/dist/animation/animation_bank_gpu.js.map +1 -0
- package/dist/animation/animationset.js +146 -30
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/cloth/gpu_cloth_component.js +406 -0
- package/dist/animation/cloth/gpu_cloth_component.js.map +1 -0
- package/dist/animation/cloth/gpu_cloth_system.js +332 -202
- package/dist/animation/cloth/gpu_cloth_system.js.map +1 -1
- package/dist/animation/gpu_animation_driver.js +289 -0
- package/dist/animation/gpu_animation_driver.js.map +1 -0
- package/dist/animation/joint_dynamics/collision.js +112 -1
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +6 -0
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +11 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +50 -12
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/skeleton.js +300 -56
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skin_palette_atlas.js +252 -0
- package/dist/animation/skin_palette_atlas.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +298 -38
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -1
- package/dist/animation/spring/spring_chain.js +2 -0
- package/dist/animation/spring/spring_chain.js.map +1 -1
- package/dist/animation/spring/spring_collider.js +159 -21
- package/dist/animation/spring/spring_collider.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +1 -0
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring/spring_solver.js +173 -0
- package/dist/animation/spring/spring_solver.js.map +1 -0
- package/dist/animation/spring/spring_system.js +249 -24
- package/dist/animation/spring/spring_system.js.map +1 -1
- package/dist/animation/spring_modifier.js +32 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/app/app.js +26 -0
- package/dist/app/app.js.map +1 -1
- package/dist/app/engine.js +86 -15
- package/dist/app/engine.js.map +1 -1
- package/dist/app/gamepad.js +191 -0
- package/dist/app/gamepad.js.map +1 -0
- package/dist/app/inputactions.js +271 -0
- package/dist/app/inputactions.js.map +1 -0
- package/dist/app/inputmgr.js +331 -22
- package/dist/app/inputmgr.js.map +1 -1
- package/dist/app/loading.js +138 -0
- package/dist/app/loading.js.map +1 -0
- package/dist/app/pipelinecache.js +209 -0
- package/dist/app/pipelinecache.js.map +1 -0
- package/dist/app/runtimescript.js +25 -0
- package/dist/app/runtimescript.js.map +1 -1
- package/dist/app/scriptingsystem.js +54 -0
- package/dist/app/scriptingsystem.js.map +1 -1
- package/dist/app/scriptregistry.js +7 -2
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/asset_manifest.js +59 -0
- package/dist/asset/asset_manifest.js.map +1 -0
- package/dist/asset/asset_preload.js +258 -0
- package/dist/asset/asset_preload.js.map +1 -0
- package/dist/asset/assetmanager.js +117 -65
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/dist/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/dist/asset/loaders/ktx2/basis_location.js +17 -0
- package/dist/asset/loaders/ktx2/basis_location.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js +88 -0
- package/dist/asset/loaders/ktx2/ktx2_loader.js.map +1 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js +118 -0
- package/dist/asset/loaders/ktx2/ktx2_targets.js.map +1 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js +259 -0
- package/dist/asset/loaders/ktx2/transcoder_pool.js.map +1 -0
- package/dist/asset/mesh_lod_builder.js +104 -0
- package/dist/asset/mesh_lod_builder.js.map +1 -0
- package/dist/asset/mesh_settings.js +111 -0
- package/dist/asset/mesh_settings.js.map +1 -0
- package/dist/asset/meshopt_decoder.js +18 -0
- package/dist/asset/meshopt_decoder.js.map +1 -0
- package/dist/asset/meshopt_simplifier.js +26 -0
- package/dist/asset/meshopt_simplifier.js.map +1 -0
- package/dist/asset/model.js +177 -3
- package/dist/asset/model.js.map +1 -1
- package/dist/asset/texture_settings.js +231 -0
- package/dist/asset/texture_settings.js.map +1 -0
- package/dist/asset/zmsh_binary.js +131 -0
- package/dist/asset/zmsh_binary.js.map +1 -0
- package/dist/asset/zsdf_binary.js +111 -0
- package/dist/asset/zsdf_binary.js.map +1 -0
- package/dist/blitter/bilateralblur.js +1 -2
- package/dist/blitter/bilateralblur.js.map +1 -1
- package/dist/blitter/gaussianblur.js +1 -6
- package/dist/blitter/gaussianblur.js.map +1 -1
- package/dist/camera/base.js +31 -10
- package/dist/camera/base.js.map +1 -1
- package/dist/camera/camera.js +178 -200
- package/dist/camera/camera.js.map +1 -1
- package/dist/camera/follow.js +342 -0
- package/dist/camera/follow.js.map +1 -0
- package/dist/camera/fps.js +9 -7
- package/dist/camera/fps.js.map +1 -1
- package/dist/camera/orbit.js +46 -19
- package/dist/camera/orbit.js.map +1 -1
- package/dist/index.d.ts +30475 -19865
- package/dist/index.js +67 -12
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +3 -0
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/eye.js +1 -1
- package/dist/material/eye.js.map +1 -1
- package/dist/material/hair.js +2 -3
- package/dist/material/hair.js.map +1 -1
- package/dist/material/hairstrand.js +235 -235
- package/dist/material/hairstrand.js.map +1 -1
- package/dist/material/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +362 -300
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +118 -45
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +1 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +34 -61
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +16 -2
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +2 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +223 -83
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +31 -206
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mtoon.js +1 -1
- package/dist/material/mtoon.js.map +1 -1
- package/dist/material/pbrmr.js +3 -0
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +3 -0
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/sdf_debug.js +78 -0
- package/dist/material/sdf_debug.js.map +1 -0
- package/dist/material/shader/helper.js +733 -190
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/shader/terrain_blend.js +204 -43
- package/dist/material/shader/terrain_blend.js.map +1 -1
- package/dist/material/skin.js +331 -297
- package/dist/material/skin.js.map +1 -1
- package/dist/material/skinprofile.js +1058 -0
- package/dist/material/skinprofile.js.map +1 -0
- package/dist/material/sss.js +353 -0
- package/dist/material/sss.js.map +1 -0
- package/dist/material/sss_kernel.js +265 -0
- package/dist/material/sss_kernel.js.map +1 -0
- package/dist/material/sssprofile.js +879 -0
- package/dist/material/sssprofile.js.map +1 -0
- package/dist/material/subsurfaceprofile.js +4 -8
- package/dist/material/subsurfaceprofile.js.map +1 -1
- package/dist/material/terrain-cm.js +464 -188
- package/dist/material/terrain-cm.js.map +1 -1
- package/dist/material/unlit.js +3 -0
- package/dist/material/unlit.js.map +1 -1
- package/dist/material/water.js +2009 -201
- package/dist/material/water.js.map +1 -1
- package/dist/node_modules/meshoptimizer/LICENSE +21 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js +197 -0
- package/dist/node_modules/meshoptimizer/meshopt_decoder.js.map +1 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js +677 -0
- package/dist/node_modules/meshoptimizer/meshopt_simplifier.js.map +1 -0
- package/dist/physics/character.js +226 -0
- package/dist/physics/character.js.map +1 -0
- package/dist/physics/collider.js +209 -0
- package/dist/physics/collider.js.map +1 -0
- package/dist/physics/events.js +79 -0
- package/dist/physics/events.js.map +1 -0
- package/dist/physics/joint.js +272 -0
- package/dist/physics/joint.js.map +1 -0
- package/dist/physics/node_physics.js +234 -0
- package/dist/physics/node_physics.js.map +1 -0
- package/dist/physics/part.js +91 -0
- package/dist/physics/part.js.map +1 -0
- package/dist/physics/rigid_body.js +379 -0
- package/dist/physics/rigid_body.js.map +1 -0
- package/dist/physics/vehicle.js +335 -0
- package/dist/physics/vehicle.js.map +1 -0
- package/dist/physics/world.js +25 -0
- package/dist/physics/world.js.map +1 -0
- package/dist/posteffect/bloom.js +49 -14
- package/dist/posteffect/bloom.js.map +1 -1
- package/dist/posteffect/motionblur.js +668 -63
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/posteffect.js +12 -1
- package/dist/posteffect/posteffect.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +48 -50
- package/dist/posteffect/sao.js.map +1 -1
- package/dist/posteffect/skinsss.js +605 -355
- package/dist/posteffect/skinsss.js.map +1 -1
- package/dist/posteffect/ssgi.js +91 -162
- package/dist/posteffect/ssgi.js.map +1 -1
- package/dist/posteffect/ssr.js +3 -11
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +34 -15
- package/dist/posteffect/sss.js.map +1 -1
- package/dist/posteffect/taa.js +1 -0
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +40 -39
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +328 -62
- package/dist/render/clipmap.js.map +1 -1
- package/dist/render/cluster_light.js +958 -224
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +26 -5
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/debug_views.js +37 -0
- package/dist/render/debug_views.js.map +1 -0
- package/dist/render/depthpass.js +5 -1
- package/dist/render/depthpass.js.map +1 -1
- package/dist/render/drawable_mixin.js +53 -6
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/dualdepthpeeling_oit.js +53 -53
- package/dist/render/dualdepthpeeling_oit.js.map +1 -1
- package/dist/render/envlight.js +196 -113
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +8 -13
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +268 -136
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +113 -28
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/gi/probe_volume.js +1334 -0
- package/dist/render/gi/probe_volume.js.map +1 -0
- package/dist/render/gi/scene_gi.js +282 -0
- package/dist/render/gi/scene_gi.js.map +1 -0
- package/dist/render/gi/voxel_atlas.js +198 -0
- package/dist/render/gi/voxel_atlas.js.map +1 -0
- package/dist/render/gi/voxel_lighting.js +652 -0
- package/dist/render/gi/voxel_lighting.js.map +1 -0
- package/dist/render/gi/voxel_scene.js +642 -0
- package/dist/render/gi/voxel_scene.js.map +1 -0
- package/dist/render/gi/voxelize_pass.js +223 -0
- package/dist/render/gi/voxelize_pass.js.map +1 -0
- package/dist/render/globalbindgroup_allocator.js +3 -2
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/gpu_picking.js +9 -36
- package/dist/render/gpu_picking.js.map +1 -1
- package/dist/render/hzb.js +80 -22
- package/dist/render/hzb.js.map +1 -1
- package/dist/render/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +23 -9
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/lod.js +46 -0
- package/dist/render/lod.js.map +1 -0
- package/dist/render/oit.js +11 -11
- package/dist/render/oit.js.map +1 -1
- package/dist/render/primitive.js +301 -9
- package/dist/render/primitive.js.map +1 -1
- package/dist/render/primitive_readback.js +209 -0
- package/dist/render/primitive_readback.js.map +1 -0
- package/dist/render/render_queue.js +198 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +14 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +15 -1
- package/dist/render/rendergraph/blackboard.js.map +1 -1
- package/dist/render/rendergraph/executor.js +136 -0
- package/dist/render/rendergraph/executor.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +585 -59
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_resource_requirements.js +1 -0
- package/dist/render/rendergraph/frame_resource_requirements.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +8 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/scene_render_context.js +31 -2
- package/dist/render/rendergraph/scene_render_context.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +28 -5
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sdf/box_allocator.js +98 -0
- package/dist/render/sdf/box_allocator.js.map +1 -0
- package/dist/render/sdf/global_sdf.js +865 -0
- package/dist/render/sdf/global_sdf.js.map +1 -0
- package/dist/render/sdf/scene_sdf.js +562 -0
- package/dist/render/sdf/scene_sdf.js.map +1 -0
- package/dist/render/sdf/sdf_atlas.js +227 -0
- package/dist/render/sdf/sdf_atlas.js.map +1 -0
- package/dist/render/sdf/sdf_programs.js +42 -0
- package/dist/render/sdf/sdf_programs.js.map +1 -0
- package/dist/render/sdf/sdf_view.js +199 -0
- package/dist/render/sdf/sdf_view.js.map +1 -0
- package/dist/render/sdf/waterline.js +610 -0
- package/dist/render/sdf/waterline.js.map +1 -0
- package/dist/render/shadow_mask_pass.js +142 -25
- package/dist/render/shadow_mask_pass.js.map +1 -1
- package/dist/render/shore_wave_generator.js +1193 -0
- package/dist/render/shore_wave_generator.js.map +1 -0
- package/dist/render/sky.js +516 -86
- package/dist/render/sky.js.map +1 -1
- package/dist/render/transmission_thickness_pass.js +477 -0
- package/dist/render/transmission_thickness_pass.js.map +1 -0
- package/dist/render/underwater.js +524 -0
- package/dist/render/underwater.js.map +1 -0
- package/dist/render/virtualtexture/virtual_texture.js +1214 -0
- package/dist/render/virtualtexture/virtual_texture.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_common.js +472 -0
- package/dist/render/volumetric_cloud/cloud_common.js.map +1 -0
- package/dist/render/volumetric_cloud/cloud_noise.js +189 -0
- package/dist/render/volumetric_cloud/cloud_noise.js.map +1 -0
- package/dist/render/volumetric_cloud/debug_view.js +131 -0
- package/dist/render/volumetric_cloud/debug_view.js.map +1 -0
- package/dist/render/volumetric_cloud/resources.js +380 -0
- package/dist/render/volumetric_cloud/resources.js.map +1 -0
- package/dist/render/volumetric_cloud/sky_cache.js +380 -0
- package/dist/render/volumetric_cloud/sky_cache.js.map +1 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js +318 -0
- package/dist/render/volumetric_cloud/volumetric_cloud.js.map +1 -0
- package/dist/render/water_caustics.js +1195 -0
- package/dist/render/water_caustics.js.map +1 -0
- package/dist/render/water_foam.js +627 -0
- package/dist/render/water_foam.js.map +1 -0
- package/dist/render/water_interaction.js +1795 -0
- package/dist/render/water_interaction.js.map +1 -0
- package/dist/render/weightedblended_oit.js +36 -36
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +9 -4
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +108 -12
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +28 -7
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/foliage.js +1020 -0
- package/dist/scene/foliage.js.map +1 -0
- package/dist/scene/foliage_buckets.js +147 -0
- package/dist/scene/foliage_buckets.js.map +1 -0
- package/dist/scene/foliage_mask.js +358 -0
- package/dist/scene/foliage_mask.js.map +1 -0
- package/dist/scene/hair.js +15 -4
- package/dist/scene/hair.js.map +1 -1
- package/dist/scene/light.js +179 -13
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +327 -45
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +9 -3
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +9 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +8 -2
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/physics_settings.js +157 -0
- package/dist/scene/physics_settings.js.map +1 -0
- package/dist/scene/scene.js +190 -44
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +147 -6
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/terrain-cm/bladegrassmaterial.js +735 -0
- package/dist/scene/terrain-cm/bladegrassmaterial.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +881 -42
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grass_gpu.js +929 -0
- package/dist/scene/terrain-cm/grass_gpu.js.map +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js +180 -9
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +465 -36
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/terrain-cm/terrain_gi_albedo.js +257 -0
- package/dist/scene/terrain-cm/terrain_gi_albedo.js.map +1 -0
- package/dist/scene/terrain-cm/terrain_rvt.js +395 -0
- package/dist/scene/terrain-cm/terrain_rvt.js.map +1 -0
- package/dist/scene/update_queue.js +54 -0
- package/dist/scene/update_queue.js.map +1 -0
- package/dist/scene/water.js +997 -96
- package/dist/scene/water.js.map +1 -1
- package/dist/scene/water_surface_sampler.js +324 -0
- package/dist/scene/water_surface_sampler.js.map +1 -0
- package/dist/scene/wind.js +317 -0
- package/dist/scene/wind.js.map +1 -0
- package/dist/shaders/atmosphere.js +388 -166
- package/dist/shaders/atmosphere.js.map +1 -1
- package/dist/shaders/fog.js +100 -32
- package/dist/shaders/fog.js.map +1 -1
- package/dist/shaders/gi.js +365 -0
- package/dist/shaders/gi.js.map +1 -0
- package/dist/shaders/ltc_rect.js +202 -0
- package/dist/shaders/ltc_rect.js.map +1 -0
- package/dist/shaders/misc.js +1 -10
- package/dist/shaders/misc.js.map +1 -1
- package/dist/shaders/noise.js +5 -1
- package/dist/shaders/noise.js.map +1 -1
- package/dist/shaders/probes.js +309 -0
- package/dist/shaders/probes.js.map +1 -0
- package/dist/shaders/sdf.js +537 -0
- package/dist/shaders/sdf.js.map +1 -0
- package/dist/shaders/shadow.js +104 -70
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shaders/skin_brdf.js +243 -0
- package/dist/shaders/skin_brdf.js.map +1 -0
- package/dist/shaders/ssr.js +6 -159
- package/dist/shaders/ssr.js.map +1 -1
- package/dist/shaders/temporal.js +38 -27
- package/dist/shaders/temporal.js.map +1 -1
- package/dist/shaders/water.js +40 -87
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +42 -0
- package/dist/shaders/water_medium.js.map +1 -0
- package/dist/shadow/dom.js +110 -19
- package/dist/shadow/dom.js.map +1 -1
- package/dist/shadow/esm.js +3 -3
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +15 -48
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +15 -53
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/pcss.js +34 -9
- package/dist/shadow/pcss.js.map +1 -1
- package/dist/shadow/shadow_impl.js +3 -8
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +87 -49
- package/dist/shadow/shadow_region.js.map +1 -1
- package/dist/shadow/shadowmapper.js +93 -53
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/ssm.js +18 -72
- package/dist/shadow/ssm.js.map +1 -1
- package/dist/shadow/vsm.js +3 -3
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/shapes/shape.js +44 -1
- package/dist/shapes/shape.js.map +1 -1
- package/dist/utility/buoyancy.js +287 -0
- package/dist/utility/buoyancy.js.map +1 -0
- package/dist/utility/physical.js +10 -1
- package/dist/utility/physical.js.map +1 -1
- package/dist/utility/pmrem.js +17 -43
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/sdf/bake.js +435 -0
- package/dist/utility/sdf/bake.js.map +1 -0
- package/dist/utility/sdf/bvh.js +576 -0
- package/dist/utility/sdf/bvh.js.map +1 -0
- package/dist/utility/serialization/manager.js +36 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +77 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +11 -4
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +140 -279
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/cloth.js +25 -0
- package/dist/utility/serialization/scene/cloth.js.map +1 -0
- package/dist/utility/serialization/scene/common.js +14 -6
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/foliage.js +821 -0
- package/dist/utility/serialization/scene/foliage.js.map +1 -0
- package/dist/utility/serialization/scene/hair.js +11 -4
- package/dist/utility/serialization/scene/hair.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +115 -7
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +388 -220
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +69 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +140 -5
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/node_physics.js +1318 -0
- package/dist/utility/serialization/scene/node_physics.js.map +1 -0
- package/dist/utility/serialization/scene/particle.js +11 -4
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/physics.js +120 -0
- package/dist/utility/serialization/scene/physics.js.map +1 -0
- package/dist/utility/serialization/scene/primitive.js +124 -10
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +1687 -51
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +11 -4
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +163 -33
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +11 -4
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +2473 -114
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +97 -109
- package/dist/utility/shprojector.js.map +1 -1
- package/dist/utility/textures/foam.js +170 -0
- package/dist/utility/textures/foam.js.map +1 -0
- package/dist/utility/textures/ggxlut.js +17 -43
- package/dist/utility/textures/ggxlut.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +4 -4
- package/dist/utility/textures/ltcdata.js.map +1 -1
- package/dist/utility/textures/ltclut.js +16 -6
- package/dist/utility/textures/ltclut.js.map +1 -1
- package/dist/utility/unsupported.js +24 -0
- package/dist/utility/unsupported.js.map +1 -0
- package/dist/values.js +13 -1
- package/dist/values.js.map +1 -1
- package/package.json +25 -12
- package/src/asset/loaders/ktx2/basis/LICENSE +201 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.js +2 -0
- package/src/asset/loaders/ktx2/basis/basis_transcoder.wasm +0 -0
- package/src/asset/meshoptimizer/LICENSE +21 -0
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isZmshBinary, readZmshBinary, decodeZmshBinary } from './zmsh_binary.js';
|
|
2
|
+
import { getMeshoptDecoder } from './meshopt_decoder.js';
|
|
3
|
+
import { DWeakRef, DRef, ASSERT, base64ToUint8Array, Vector3, Vector4, guessMimeType } from '@zephyr3d/base';
|
|
2
4
|
import { WebImageLoader } from './loaders/image/webimage_loader.js';
|
|
3
5
|
import { DDSLoader } from './loaders/dds/dds_loader.js';
|
|
4
6
|
import { HDRLoader } from './loaders/hdr/hdr.js';
|
|
5
|
-
import { Primitive } from '../render/primitive.js';
|
|
6
|
-
import '@zephyr3d/device';
|
|
7
|
-
import { getEngine, getDevice } from '../app/api.js';
|
|
8
|
-
import { CopyBlitter } from '../blitter/copy.js';
|
|
9
7
|
import { getSheenLutLoader } from './builtin.js';
|
|
10
8
|
import { BUILTIN_ASSET_TEXTURE_SHEEN_LUT } from '../values.js';
|
|
11
9
|
import { TGALoader } from './loaders/image/tga_Loader.js';
|
|
10
|
+
import { KTX2Loader } from './loaders/ktx2/ktx2_loader.js';
|
|
11
|
+
import { getEngine, getDevice } from '../app/api.js';
|
|
12
12
|
import '../material/shader/helper.js';
|
|
13
13
|
import '../material/lambert.js';
|
|
14
14
|
import '../material/blinn.js';
|
|
15
15
|
import '../material/unlit.js';
|
|
16
|
+
import '../material/meshmaterial.js';
|
|
16
17
|
import '../material/particle.js';
|
|
17
18
|
import '../material/subsurfaceprofile.js';
|
|
18
|
-
import '../material/
|
|
19
|
+
import '../material/sssprofile.js';
|
|
20
|
+
import '../material/sss.js';
|
|
19
21
|
import '../material/eye.js';
|
|
20
22
|
import { Material } from '../material/material.js';
|
|
21
|
-
import '../material/meshmaterial.js';
|
|
22
23
|
import '../material/hair.js';
|
|
23
24
|
import '../material/hairstrand.js';
|
|
24
25
|
import '../material/grassmaterial.js';
|
|
@@ -35,15 +36,23 @@ import { BoundingBox } from '../utility/bounding_volume.js';
|
|
|
35
36
|
import { MaterialBlueprintIR } from '../utility/blueprint/material/ir.js';
|
|
36
37
|
import { getDefaultTexture2D } from '../utility/blueprint/material/texture.js';
|
|
37
38
|
import '../render/render_queue.js';
|
|
39
|
+
import { Primitive } from '../render/primitive.js';
|
|
40
|
+
import '@zephyr3d/device';
|
|
38
41
|
import '../render/rendergraph/forward_plus_builder.js';
|
|
39
42
|
import '../render/lightpass.js';
|
|
40
43
|
import '../render/sky.js';
|
|
41
44
|
import '../render/clipmap.js';
|
|
42
45
|
import '../render/envlight.js';
|
|
46
|
+
import '../render/lod.js';
|
|
43
47
|
import '../render/dualdepthpeeling_oit.js';
|
|
44
48
|
import '../shaders/atmosphere.js';
|
|
49
|
+
import '../render/water_interaction.js';
|
|
45
50
|
import '../render/rendergraph/scene_render_context.js';
|
|
51
|
+
import '../render/sdf/scene_sdf.js';
|
|
52
|
+
import '../render/sdf/global_sdf.js';
|
|
53
|
+
import '../render/gi/voxelize_pass.js';
|
|
46
54
|
import { FontAsset } from '../text/font/font_asset.js';
|
|
55
|
+
import { getRecordableOptions } from './asset_preload.js';
|
|
47
56
|
|
|
48
57
|
/**
|
|
49
58
|
* Centralized asset manager for loading and caching resources.
|
|
@@ -60,6 +69,24 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
60
69
|
*
|
|
61
70
|
* @public
|
|
62
71
|
*/ class AssetManager {
|
|
72
|
+
/**
|
|
73
|
+
* Optional redirect consulted before a texture or primitive is read, see
|
|
74
|
+
* {@link AssetSourceResolver}. Scene objects keep what they already loaded; call
|
|
75
|
+
* invalidateAsset() on the path when the resolver's answer changes so later
|
|
76
|
+
* loads pick it up.
|
|
77
|
+
*/ assetSourceResolver = null;
|
|
78
|
+
/** @internal */ async resolveAssetSource(url, kind, vfs) {
|
|
79
|
+
// An explicit VFS means the caller wants that file system's bytes, not a substitute
|
|
80
|
+
if (!this.assetSourceResolver || vfs) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
return await this.assetSourceResolver(url, kind);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
console.warn(`Asset source resolver failed for ${url}, loading the file itself: ${err}`);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
63
90
|
/** @internal */ static _builtinTextures = {};
|
|
64
91
|
/** @internal */ static _builtinTextureLoaders = {
|
|
65
92
|
[BUILTIN_ASSET_TEXTURE_SHEEN_LUT]: getSheenLutLoader(64)
|
|
@@ -68,7 +95,8 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
68
95
|
new WebImageLoader(),
|
|
69
96
|
new DDSLoader(),
|
|
70
97
|
new HDRLoader(),
|
|
71
|
-
new TGALoader()
|
|
98
|
+
new TGALoader(),
|
|
99
|
+
new KTX2Loader()
|
|
72
100
|
];
|
|
73
101
|
/** @internal */ _modelLoaders = {};
|
|
74
102
|
/** @internal */ _textures;
|
|
@@ -84,6 +112,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
84
112
|
/** @internal */ _cacheKeysByPath;
|
|
85
113
|
/** @internal */ _cachePathByKey;
|
|
86
114
|
/** @internal */ _resourceManager;
|
|
115
|
+
/** @internal */ _requestListeners;
|
|
87
116
|
/**
|
|
88
117
|
* Creates an instance of AssetManager
|
|
89
118
|
*/ constructor(resourceManager){
|
|
@@ -100,6 +129,42 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
100
129
|
this._jsonDatas = {};
|
|
101
130
|
this._cacheKeysByPath = new Map();
|
|
102
131
|
this._cachePathByKey = new Map();
|
|
132
|
+
this._requestListeners = new Set();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Watches the fetches made from now on, to record them for {@link AssetPreloader}.
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* Only fetches that can be made again from a recording are reported: not those
|
|
139
|
+
* reading from another VFS, loading into an existing texture, or post-processing
|
|
140
|
+
* through a callback. Fetching is unchanged.
|
|
141
|
+
*
|
|
142
|
+
* @param listener - Called with each fetch as it is made, cached or not
|
|
143
|
+
*/ addRequestListener(listener) {
|
|
144
|
+
this._requestListeners.add(listener);
|
|
145
|
+
}
|
|
146
|
+
/** Stops a listener added by {@link AssetManager.addRequestListener} */ removeRequestListener(listener) {
|
|
147
|
+
this._requestListeners.delete(listener);
|
|
148
|
+
}
|
|
149
|
+
/** @internal */ notifyRequest(type, url, options, replayable = true) {
|
|
150
|
+
if (this._requestListeners.size === 0 || !replayable) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const recordable = getRecordableOptions(options);
|
|
154
|
+
if (!recordable) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const request = Object.keys(recordable).length > 0 ? {
|
|
158
|
+
type,
|
|
159
|
+
url,
|
|
160
|
+
options: recordable
|
|
161
|
+
} : {
|
|
162
|
+
type,
|
|
163
|
+
url
|
|
164
|
+
};
|
|
165
|
+
for (const listener of this._requestListeners){
|
|
166
|
+
listener(request);
|
|
167
|
+
}
|
|
103
168
|
}
|
|
104
169
|
/**
|
|
105
170
|
* VFS used to read resources (files, URLs, virtual mounts).
|
|
@@ -306,6 +371,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
306
371
|
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
307
372
|
* @returns A promise that resolves to the loaded (and optionally processed) text.
|
|
308
373
|
*/ async fetchTextData(url, postProcess, httpRequest, options) {
|
|
374
|
+
this.notifyRequest('text', url, options, !postProcess && !httpRequest);
|
|
309
375
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
310
376
|
let P = this._textDatas[hash];
|
|
311
377
|
if (!P) {
|
|
@@ -326,6 +392,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
326
392
|
* @param httpRequest - Optional HttpRequest for custom URL resolution/headers.
|
|
327
393
|
* @returns A promise that resolves to the loaded (and optionally processed) JSON value.
|
|
328
394
|
*/ async fetchJsonData(url, postProcess, httpRequest, options) {
|
|
395
|
+
this.notifyRequest('json', url, options, !postProcess && !httpRequest);
|
|
329
396
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
330
397
|
let P = this._jsonDatas[hash];
|
|
331
398
|
if (!P) {
|
|
@@ -346,6 +413,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
346
413
|
* @param options - Optional fetch options
|
|
347
414
|
* @returns A promise that resolves to the loaded (and optionally processed) ArrayBuffer.
|
|
348
415
|
*/ async fetchBinaryData(url, postProcess, httpRequest, options) {
|
|
416
|
+
this.notifyRequest('binary', url, options, !postProcess && !httpRequest);
|
|
349
417
|
const hash = httpRequest?.urlResolver?.(url) ?? url;
|
|
350
418
|
let P = this._binaryDatas[hash];
|
|
351
419
|
if (!P) {
|
|
@@ -366,6 +434,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
366
434
|
* @param options - Optional MSDF atlas settings bound to the loaded FontAsset.
|
|
367
435
|
* @returns A promise that resolves to the loaded (and optionally processed) font asset.
|
|
368
436
|
*/ async fetchFontAsset(url, options) {
|
|
437
|
+
this.notifyRequest('font', url, options);
|
|
369
438
|
const hash = url;
|
|
370
439
|
let P = this._fontAssets[hash];
|
|
371
440
|
if (!P) {
|
|
@@ -390,6 +459,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
390
459
|
return this._fontAssets[hash] instanceof Promise ? null : this._fontAssets[hash] ?? null;
|
|
391
460
|
}
|
|
392
461
|
async fetchBluePrint(url, options) {
|
|
462
|
+
this.notifyRequest('blueprint', url, options);
|
|
393
463
|
const hash = url;
|
|
394
464
|
let P = this._bluePrints[hash];
|
|
395
465
|
if (!P) {
|
|
@@ -406,6 +476,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
406
476
|
* @param url - Resource URL or VFS path.
|
|
407
477
|
* @returns A promise that resolves to the loaded material.
|
|
408
478
|
*/ async fetchMaterial(url, options) {
|
|
479
|
+
this.notifyRequest('material', url, options);
|
|
409
480
|
const hash = url;
|
|
410
481
|
let P = this._materials[hash];
|
|
411
482
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
@@ -428,6 +499,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
428
499
|
* @param url - Resource URL or VFS path.
|
|
429
500
|
* @returns A promise that resolves to the loaded primitive.
|
|
430
501
|
*/ async fetchPrimitive(url, options) {
|
|
502
|
+
this.notifyRequest('primitive', url, options);
|
|
431
503
|
const hash = url;
|
|
432
504
|
let P = this._primitives[hash];
|
|
433
505
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
@@ -457,6 +529,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
457
529
|
* @param httpRequest - Optional HttpRequest (not used for binary read but may supply URL resolver for hashing).
|
|
458
530
|
* @returns A promise that resolves to the loaded texture.
|
|
459
531
|
*/ async fetchTexture(url, options) {
|
|
532
|
+
this.notifyRequest('texture', url, options);
|
|
460
533
|
if (options?.texture) {
|
|
461
534
|
return this.loadTexture(url, options.mimeType ?? null, !options.linearColorSpace, options.samplerOptions, options.texture, options.overrideVFS);
|
|
462
535
|
} else {
|
|
@@ -487,7 +560,9 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
487
560
|
* @returns A promise that resolves to the SharedModel.
|
|
488
561
|
* @internal
|
|
489
562
|
*/ async fetchModelData(url, options) {
|
|
490
|
-
|
|
563
|
+
this.notifyRequest('model', url, options);
|
|
564
|
+
// The same model with and without levels of detail are different models
|
|
565
|
+
const hash = options?.generateLods ? `${url}#lod:${JSON.stringify(options.generateLods)}` : url;
|
|
491
566
|
let P = this._models[hash];
|
|
492
567
|
if (P instanceof DWeakRef && P.get() && !P.get().disposed) {
|
|
493
568
|
return P.get();
|
|
@@ -598,10 +673,13 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
598
673
|
}
|
|
599
674
|
async loadPrimitive(url, vfs) {
|
|
600
675
|
try {
|
|
601
|
-
const
|
|
602
|
-
encoding: '
|
|
676
|
+
const raw = (await this.resolveAssetSource(url, 'primitive', vfs))?.data ?? await this.readFileFromVFS(url, {
|
|
677
|
+
encoding: 'binary'
|
|
603
678
|
}, vfs);
|
|
604
|
-
|
|
679
|
+
if (isZmshBinary(raw)) {
|
|
680
|
+
return await this.createPrimitiveFromZmshBinary(raw);
|
|
681
|
+
}
|
|
682
|
+
const content = JSON.parse(new TextDecoder().decode(raw));
|
|
605
683
|
ASSERT(content.type === 'Primitive' || content.type === 'Default', `Unsupported primitive type: ${content.type}`);
|
|
606
684
|
if (content.type === 'Primitive') {
|
|
607
685
|
const data = content.data;
|
|
@@ -639,6 +717,25 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
639
717
|
return null;
|
|
640
718
|
}
|
|
641
719
|
}
|
|
720
|
+
/** @internal */ async createPrimitiveFromZmshBinary(raw) {
|
|
721
|
+
const meshopt = readZmshBinary(raw).header.encoding === 'meshopt';
|
|
722
|
+
const { header, vertexData, indexData } = decodeZmshBinary(raw, meshopt ? await getMeshoptDecoder() : null);
|
|
723
|
+
const primitive = new Primitive();
|
|
724
|
+
header.attributes.forEach((a, i)=>primitive.createAndSetVertexBuffer(a.format, vertexData[i]));
|
|
725
|
+
if (indexData) {
|
|
726
|
+
primitive.createAndSetIndexBuffer(indexData);
|
|
727
|
+
}
|
|
728
|
+
primitive.primitiveType = header.primitiveType;
|
|
729
|
+
if (header.lods && header.lods.length > 0) {
|
|
730
|
+
primitive.indexStart = header.lods[0].indexStart;
|
|
731
|
+
primitive.indexCount = header.lods[0].indexCount;
|
|
732
|
+
primitive.lods = header.lods.slice(1);
|
|
733
|
+
} else {
|
|
734
|
+
primitive.indexCount = header.indexCount;
|
|
735
|
+
}
|
|
736
|
+
primitive.setBoundingVolume(new BoundingBox(new Vector3(header.boxMin[0], header.boxMin[1], header.boxMin[2]), new Vector3(header.boxMax[0], header.boxMax[1], header.boxMax[2])));
|
|
737
|
+
return primitive;
|
|
738
|
+
}
|
|
642
739
|
async reloadBluePrintMaterials(filter) {
|
|
643
740
|
const promises = [];
|
|
644
741
|
const paths = [];
|
|
@@ -1038,10 +1135,11 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
1038
1135
|
* @returns A promise that resolves to the created or populated texture.
|
|
1039
1136
|
* @internal
|
|
1040
1137
|
*/ async loadTexture(url, mimeType, srgb, samplerOptions, texture, vfs) {
|
|
1041
|
-
const
|
|
1138
|
+
const redirected = await this.resolveAssetSource(url, 'texture', vfs);
|
|
1139
|
+
const data = redirected?.data ?? await this.readFileFromVFS(url, {
|
|
1042
1140
|
encoding: 'binary'
|
|
1043
1141
|
}, vfs);
|
|
1044
|
-
mimeType = mimeType ?? this.vfs.guessMIMEType(url);
|
|
1142
|
+
mimeType = redirected?.mimeType ?? mimeType ?? this.vfs.guessMIMEType(url);
|
|
1045
1143
|
for (const loader of AssetManager._textureLoaders){
|
|
1046
1144
|
if (!loader.supportMIMEType(mimeType)) {
|
|
1047
1145
|
continue;
|
|
@@ -1055,8 +1153,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
1055
1153
|
throw new Error(`Can not find loader for asset ${url}`);
|
|
1056
1154
|
}
|
|
1057
1155
|
/**
|
|
1058
|
-
* Internal routine that executes the texture load using a specific loader
|
|
1059
|
-
* backend-specific compatibility steps (e.g., WebGL NPOT/sRGB rules).
|
|
1156
|
+
* Internal routine that executes the texture load using a specific loader.
|
|
1060
1157
|
*
|
|
1061
1158
|
* @param loader - Concrete loader to use for decoding/creation.
|
|
1062
1159
|
* @param mimeType - Texture MIME type.
|
|
@@ -1067,54 +1164,7 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
1067
1164
|
* @returns A promise that resolves to the created or populated texture.
|
|
1068
1165
|
* @internal
|
|
1069
1166
|
*/ async doLoadTexture(loader, mimeType, data, srgb, samplerOptions, texture) {
|
|
1070
|
-
|
|
1071
|
-
if (device.type !== 'webgl') {
|
|
1072
|
-
return await loader.load(mimeType, data, srgb, samplerOptions, texture);
|
|
1073
|
-
} else {
|
|
1074
|
-
let tex = await loader.load(mimeType, data, srgb, samplerOptions);
|
|
1075
|
-
if (tex) {
|
|
1076
|
-
if (texture) {
|
|
1077
|
-
const magFilter = tex.width !== texture.width || tex.height !== texture.height ? 'linear' : 'nearest';
|
|
1078
|
-
const minFilter = magFilter;
|
|
1079
|
-
const mipFilter = 'none';
|
|
1080
|
-
const sampler = device.createSampler({
|
|
1081
|
-
addressU: 'clamp',
|
|
1082
|
-
addressV: 'clamp',
|
|
1083
|
-
magFilter,
|
|
1084
|
-
minFilter,
|
|
1085
|
-
mipFilter
|
|
1086
|
-
});
|
|
1087
|
-
const blitter = new CopyBlitter();
|
|
1088
|
-
blitter.blit(tex, texture, sampler);
|
|
1089
|
-
tex = texture;
|
|
1090
|
-
} else {
|
|
1091
|
-
const po2_w = isPowerOf2(tex.width);
|
|
1092
|
-
const po2_h = isPowerOf2(tex.height);
|
|
1093
|
-
const srgb = tex.isSRGBFormat();
|
|
1094
|
-
if (srgb || !po2_w || !po2_h) {
|
|
1095
|
-
const newWidth = po2_w ? tex.width : nextPowerOf2(tex.width);
|
|
1096
|
-
const newHeight = po2_h ? tex.height : nextPowerOf2(tex.height);
|
|
1097
|
-
const magFilter = newWidth !== tex.width || newHeight !== tex.height ? 'linear' : 'nearest';
|
|
1098
|
-
const minFilter = magFilter;
|
|
1099
|
-
const mipFilter = 'none';
|
|
1100
|
-
const sampler = device.createSampler({
|
|
1101
|
-
addressU: 'clamp',
|
|
1102
|
-
addressV: 'clamp',
|
|
1103
|
-
magFilter,
|
|
1104
|
-
minFilter,
|
|
1105
|
-
mipFilter
|
|
1106
|
-
});
|
|
1107
|
-
const destFormat = srgb ? 'rgba8unorm' : tex.format;
|
|
1108
|
-
const blitter = new CopyBlitter();
|
|
1109
|
-
const newTexture = tex.isTexture2D() ? device.createTexture2D(destFormat, newWidth, newHeight) : device.createCubeTexture(destFormat, newWidth);
|
|
1110
|
-
blitter.blit(tex, newTexture, sampler);
|
|
1111
|
-
tex.dispose();
|
|
1112
|
-
tex = newTexture;
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
return tex;
|
|
1117
|
-
}
|
|
1167
|
+
return await loader.load(mimeType, data, srgb, samplerOptions, texture);
|
|
1118
1168
|
}
|
|
1119
1169
|
/**
|
|
1120
1170
|
* Load a model via registered model loaders.
|
|
@@ -1131,7 +1181,9 @@ import { FontAsset } from '../text/font/font_asset.js';
|
|
|
1131
1181
|
const mimeType = options?.mimeType || guessMimeType(url);
|
|
1132
1182
|
const importer = this._modelLoaders[mimeType];
|
|
1133
1183
|
if (importer) {
|
|
1134
|
-
let model = await importer.loadModel(url, vfs
|
|
1184
|
+
let model = await importer.loadModel(url, vfs, options?.generateLods ? {
|
|
1185
|
+
generateLods: options.generateLods
|
|
1186
|
+
} : undefined);
|
|
1135
1187
|
if (!model) {
|
|
1136
1188
|
throw new Error(`Load asset failed: ${url}`);
|
|
1137
1189
|
}
|