@zephyr3d/scene 0.9.27 → 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 +54 -0
- 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 +279 -55
- 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 +171 -1
- 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 +104 -178
- 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 +25436 -15990
- package/dist/index.js +65 -11
- 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/lambert.js +4 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +66 -4
- 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 +191 -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 +333 -191
- 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 +1261 -1438
- 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 +106 -106
- package/dist/posteffect/motionblur.js.map +1 -1
- package/dist/posteffect/postsss.js +572 -0
- package/dist/posteffect/postsss.js.map +1 -0
- package/dist/posteffect/sao.js +2 -6
- 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 +4 -13
- 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 +3 -2
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/clipmap.js +179 -64
- 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 +25 -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 +5 -5
- 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 +5 -10
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/fft_wavegenerator.js +247 -157
- package/dist/render/fft_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +16 -38
- 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/instance_culling.js +499 -0
- package/dist/render/instance_culling.js.map +1 -0
- package/dist/render/lightpass.js +19 -8
- 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/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 +162 -11
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +10 -7
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/blackboard.js +14 -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 +272 -55
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/frame_graph_context.js +41 -0
- package/dist/render/rendergraph/frame_graph_context.js.map +1 -0
- 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 +58 -158
- package/dist/render/underwater.js.map +1 -1
- 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 +134 -319
- package/dist/render/water_caustics.js.map +1 -1
- 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 +3 -3
- 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 +633 -268
- 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/ssgi.js +63 -0
- package/dist/shaders/ssgi.js.map +1 -0
- package/dist/shaders/ssgi_reprojection.js +118 -0
- package/dist/shaders/ssgi_reprojection.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 +32 -82
- package/dist/shaders/water.js.map +1 -1
- package/dist/shaders/water_medium.js +7 -21
- package/dist/shaders/water_medium.js.map +1 -1
- 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 +40 -2
- 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 +34 -6
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +46 -5
- 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 +87 -254
- 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 +1543 -264
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/shprojector.js +10 -22
- 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
- package/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
package/dist/render/clipmap.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { AABB, Vector3, BoxSide, Disposable, Matrix4x4, ClipState
|
|
1
|
+
import { AABB, Vector3, Vector2, BoxSide, Disposable, Matrix4x4, ClipState } from '@zephyr3d/base';
|
|
2
2
|
import { Primitive } from './primitive.js';
|
|
3
3
|
import { getVertexAttributeIndex, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TEXCOORD0, getVertexAttributeFormat } from '@zephyr3d/device';
|
|
4
4
|
|
|
5
5
|
const tmpAABB = new AABB();
|
|
6
6
|
const tmpV3 = new Vector3();
|
|
7
|
+
// Scratch vectors for gather() and calcLevelAABB(), which run per camera every frame
|
|
8
|
+
const tmpSnappedPos = new Vector2();
|
|
9
|
+
const tmpTileSize = new Vector2();
|
|
10
|
+
const tmpBase = new Vector2();
|
|
11
|
+
const tmpOffset = new Vector2();
|
|
12
|
+
const tmpNextSnappedPos = new Vector2();
|
|
13
|
+
const tmpTileCentre = new Vector2();
|
|
14
|
+
const tmpNextBase = new Vector2();
|
|
7
15
|
const rotationValues = [
|
|
8
16
|
0,
|
|
9
17
|
Math.PI * 1.5,
|
|
@@ -13,7 +21,13 @@ const rotationValues = [
|
|
|
13
21
|
/**
|
|
14
22
|
* Frustum plane mask covering everything but the far plane, for a clipmap that
|
|
15
23
|
* reaches past it. @internal
|
|
16
|
-
*/
|
|
24
|
+
*/ /**
|
|
25
|
+
* Instance data is rewritten for every camera every frame: dynamic buffers keep their upload
|
|
26
|
+
* staging buffers for reuse instead of creating and destroying one per upload
|
|
27
|
+
*/ const INSTANCE_BUFFER_OPTIONS = {
|
|
28
|
+
dynamic: true
|
|
29
|
+
};
|
|
30
|
+
const ALL_PLANES_EXCEPT_FAR = 0b111111 & ~(1 << BoxSide.BACK);
|
|
17
31
|
/** @internal */ class Clipmap extends Disposable {
|
|
18
32
|
_instanceDataPool;
|
|
19
33
|
_instanceDataPoolSize;
|
|
@@ -44,6 +58,10 @@ const rotationValues = [
|
|
|
44
58
|
_skirtMesh;
|
|
45
59
|
_skirtMeshLines;
|
|
46
60
|
_wireframe;
|
|
61
|
+
_levelAABBs;
|
|
62
|
+
/** Grid origin of the gather/cull call in progress, see ClipmapGatherContext.gridOriginX */ _originX;
|
|
63
|
+
_originZ;
|
|
64
|
+
_cullScratch;
|
|
47
65
|
constructor(resolution, extraInstanceBuffers, maxMipLevels = 64){
|
|
48
66
|
super();
|
|
49
67
|
if (extraInstanceBuffers && extraInstanceBuffers.findIndex((val)=>getVertexAttributeIndex(val) === VERTEX_ATTRIB_POSITION || getVertexAttributeIndex(val) === VERTEX_ATTRIB_TEXCOORD0 || getVertexAttributeFormat(val) !== 'f32') >= 0) {
|
|
@@ -61,6 +79,10 @@ const rotationValues = [
|
|
|
61
79
|
this._nonInstanceMipLevelDataPool = [];
|
|
62
80
|
this._nonInstanceMipLevelDataPoolSize = 0;
|
|
63
81
|
this._wireframe = false;
|
|
82
|
+
this._levelAABBs = [];
|
|
83
|
+
this._originX = 0;
|
|
84
|
+
this._originZ = 0;
|
|
85
|
+
this._cullScratch = new Map();
|
|
64
86
|
this.generateCrossMesh();
|
|
65
87
|
this.generateFillerMesh();
|
|
66
88
|
this.generateSeamMesh();
|
|
@@ -80,6 +102,7 @@ const rotationValues = [
|
|
|
80
102
|
set tileResolution(val) {
|
|
81
103
|
if (val !== this._tileResolution) {
|
|
82
104
|
this._tileResolution = val;
|
|
105
|
+
this._cullScratch.clear();
|
|
83
106
|
this.generateCrossMesh();
|
|
84
107
|
this.generateFillerMesh();
|
|
85
108
|
this.generateSeamMesh();
|
|
@@ -183,10 +206,10 @@ const rotationValues = [
|
|
|
183
206
|
}
|
|
184
207
|
}
|
|
185
208
|
this._tileMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
186
|
-
this._tileMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
209
|
+
this._tileMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
187
210
|
this._instanceDataPoolSize++;
|
|
188
211
|
for (const fmt of this._extraInstanceBuffers){
|
|
189
|
-
this._tileMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
212
|
+
this._tileMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
190
213
|
this._instanceDataPoolSize++;
|
|
191
214
|
}
|
|
192
215
|
this._tileMesh.createAndSetIndexBuffer(indices);
|
|
@@ -206,10 +229,10 @@ const rotationValues = [
|
|
|
206
229
|
this._tileMeshLines?.dispose();
|
|
207
230
|
this._tileMeshLines = new Primitive();
|
|
208
231
|
this._tileMeshLines.setVertexBuffer(this._tileMesh.getVertexBuffer('position'));
|
|
209
|
-
this._tileMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
232
|
+
this._tileMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
210
233
|
this._instanceDataPoolSize++;
|
|
211
234
|
for (const fmt of this._extraInstanceBuffers){
|
|
212
|
-
this._tileMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
235
|
+
this._tileMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
213
236
|
this._instanceDataPoolSize++;
|
|
214
237
|
}
|
|
215
238
|
this._tileMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -281,10 +304,10 @@ const rotationValues = [
|
|
|
281
304
|
}
|
|
282
305
|
}
|
|
283
306
|
this._fillerMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
284
|
-
this._fillerMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
307
|
+
this._fillerMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
285
308
|
this._instanceDataPoolSize++;
|
|
286
309
|
for (const fmt of this._extraInstanceBuffers){
|
|
287
|
-
this._fillerMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
310
|
+
this._fillerMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
288
311
|
this._instanceDataPoolSize++;
|
|
289
312
|
}
|
|
290
313
|
this._fillerMesh.createAndSetIndexBuffer(indices);
|
|
@@ -304,10 +327,10 @@ const rotationValues = [
|
|
|
304
327
|
this._fillerMeshLines?.dispose();
|
|
305
328
|
this._fillerMeshLines = new Primitive();
|
|
306
329
|
this._fillerMeshLines.setVertexBuffer(this._fillerMesh.getVertexBuffer('position'));
|
|
307
|
-
this._fillerMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
330
|
+
this._fillerMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
308
331
|
this._instanceDataPoolSize++;
|
|
309
332
|
for (const fmt of this._extraInstanceBuffers){
|
|
310
|
-
this._fillerMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
333
|
+
this._fillerMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
311
334
|
this._instanceDataPoolSize++;
|
|
312
335
|
}
|
|
313
336
|
this._fillerMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -358,10 +381,10 @@ const rotationValues = [
|
|
|
358
381
|
indices[n++] = startOfHorizonal + (i + 0) * 2 + 1;
|
|
359
382
|
}
|
|
360
383
|
this._trimMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
361
|
-
this._trimMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
384
|
+
this._trimMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
362
385
|
this._instanceDataPoolSize++;
|
|
363
386
|
for (const fmt of this._extraInstanceBuffers){
|
|
364
|
-
this._trimMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
387
|
+
this._trimMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
365
388
|
this._instanceDataPoolSize++;
|
|
366
389
|
}
|
|
367
390
|
this._trimMesh.createAndSetIndexBuffer(indices);
|
|
@@ -381,10 +404,10 @@ const rotationValues = [
|
|
|
381
404
|
this._trimMeshLines?.dispose();
|
|
382
405
|
this._trimMeshLines = new Primitive();
|
|
383
406
|
this._trimMeshLines.setVertexBuffer(this._trimMesh.getVertexBuffer('position'));
|
|
384
|
-
this._trimMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
407
|
+
this._trimMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
385
408
|
this._instanceDataPoolSize++;
|
|
386
409
|
for (const fmt of this._extraInstanceBuffers){
|
|
387
|
-
this._trimMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
410
|
+
this._trimMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
388
411
|
this._instanceDataPoolSize++;
|
|
389
412
|
}
|
|
390
413
|
this._trimMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -445,10 +468,10 @@ const rotationValues = [
|
|
|
445
468
|
this._crossMesh?.dispose();
|
|
446
469
|
this._crossMesh = new Primitive();
|
|
447
470
|
this._crossMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
448
|
-
this._crossMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
471
|
+
this._crossMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
449
472
|
this._nonInstanceDataPoolSize++;
|
|
450
473
|
for (const fmt of this._extraInstanceBuffers){
|
|
451
|
-
this._crossMesh.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
474
|
+
this._crossMesh.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
452
475
|
this._nonInstanceDataPoolSize++;
|
|
453
476
|
}
|
|
454
477
|
this._crossMesh.createAndSetIndexBuffer(indices);
|
|
@@ -468,10 +491,10 @@ const rotationValues = [
|
|
|
468
491
|
this._crossMeshLines?.dispose();
|
|
469
492
|
this._crossMeshLines = new Primitive();
|
|
470
493
|
this._crossMeshLines.setVertexBuffer(this._crossMesh.getVertexBuffer('position'));
|
|
471
|
-
this._crossMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
494
|
+
this._crossMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
472
495
|
this._nonInstanceDataPoolSize++;
|
|
473
496
|
for (const fmt of this._extraInstanceBuffers){
|
|
474
|
-
this._crossMeshLines.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
497
|
+
this._crossMeshLines.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
475
498
|
this._nonInstanceDataPoolSize++;
|
|
476
499
|
}
|
|
477
500
|
this._crossMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -498,6 +521,16 @@ const rotationValues = [
|
|
|
498
521
|
vertices[(clipmapVertResolution * 3 + i) * 3 + 1] = clipmapVertResolution - i;
|
|
499
522
|
vertices[(clipmapVertResolution * 3 + i) * 3 + 2] = 0;
|
|
500
523
|
}
|
|
524
|
+
// Seam triangles are collinear in XZ by design: each odd vertex is the midpoint between two
|
|
525
|
+
// coarse-level vertices. Flag those midpoints with position.z = -side (1..4) so a shader
|
|
526
|
+
// clamping the grid to a finite region can snap them onto their previous neighbour when
|
|
527
|
+
// the whole seam edge lies outside it; otherwise the flap they form stands up as a vertical
|
|
528
|
+
// curtain along the region border. Negative, so it never reads as the skirt flag.
|
|
529
|
+
for(let side = 0; side < 4; side++){
|
|
530
|
+
for(let i = 1; i < clipmapVertResolution; i += 2){
|
|
531
|
+
vertices[(clipmapVertResolution * side + i) * 3 + 2] = -(side + 1);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
501
534
|
const indices = new Uint16Array(clipmapVertResolution * 6);
|
|
502
535
|
let n = 0;
|
|
503
536
|
for(let i = 0; i < clipmapVertResolution * 4; i += 2){
|
|
@@ -507,10 +540,10 @@ const rotationValues = [
|
|
|
507
540
|
}
|
|
508
541
|
indices[indices.length - 1] = 0;
|
|
509
542
|
this._seamMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
510
|
-
this._seamMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
543
|
+
this._seamMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
511
544
|
this._instanceDataPoolSize++;
|
|
512
545
|
for (const fmt of this._extraInstanceBuffers){
|
|
513
|
-
this._seamMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
546
|
+
this._seamMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
514
547
|
this._instanceDataPoolSize++;
|
|
515
548
|
}
|
|
516
549
|
this._seamMesh.createAndSetIndexBuffer(indices);
|
|
@@ -530,10 +563,10 @@ const rotationValues = [
|
|
|
530
563
|
this._seamMeshLines?.dispose();
|
|
531
564
|
this._seamMeshLines = new Primitive();
|
|
532
565
|
this._seamMeshLines.setVertexBuffer(this._seamMesh.getVertexBuffer('position'));
|
|
533
|
-
this._seamMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
566
|
+
this._seamMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
534
567
|
this._instanceDataPoolSize++;
|
|
535
568
|
for (const fmt of this._extraInstanceBuffers){
|
|
536
|
-
this._seamMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
569
|
+
this._seamMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
537
570
|
this._instanceDataPoolSize++;
|
|
538
571
|
}
|
|
539
572
|
this._seamMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -614,10 +647,10 @@ const rotationValues = [
|
|
|
614
647
|
this._skirtMesh?.dispose();
|
|
615
648
|
this._skirtMesh = new Primitive();
|
|
616
649
|
this._skirtMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
617
|
-
this._skirtMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
650
|
+
this._skirtMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
618
651
|
this._nonInstanceDataPoolSize++;
|
|
619
652
|
for (const fmt of this._extraInstanceBuffers){
|
|
620
|
-
this._skirtMesh.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
653
|
+
this._skirtMesh.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
621
654
|
this._nonInstanceDataPoolSize++;
|
|
622
655
|
}
|
|
623
656
|
this._skirtMesh.createAndSetIndexBuffer(indices);
|
|
@@ -636,10 +669,10 @@ const rotationValues = [
|
|
|
636
669
|
this._skirtMeshLines?.dispose();
|
|
637
670
|
this._skirtMeshLines = new Primitive();
|
|
638
671
|
this._skirtMeshLines.setVertexBuffer(this._skirtMesh.getVertexBuffer('position'));
|
|
639
|
-
this._skirtMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
672
|
+
this._skirtMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
640
673
|
this._nonInstanceDataPoolSize++;
|
|
641
674
|
for (const fmt of this._extraInstanceBuffers){
|
|
642
|
-
this._skirtMeshLines.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
675
|
+
this._skirtMeshLines.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance', INSTANCE_BUFFER_OPTIONS);
|
|
643
676
|
this._nonInstanceDataPoolSize++;
|
|
644
677
|
}
|
|
645
678
|
this._skirtMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
@@ -657,10 +690,10 @@ const rotationValues = [
|
|
|
657
690
|
} else {
|
|
658
691
|
AABB.transform(aabb, Matrix4x4.rotationZ(rotation), tmpAABB);
|
|
659
692
|
}
|
|
660
|
-
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale;
|
|
661
|
-
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale;
|
|
662
|
-
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale;
|
|
663
|
-
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale;
|
|
693
|
+
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale + this._originX;
|
|
694
|
+
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale + this._originX;
|
|
695
|
+
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale + this._originZ;
|
|
696
|
+
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale + this._originZ;
|
|
664
697
|
if (minX < outAABB.minPoint.x) {
|
|
665
698
|
outAABB.minPoint.x = minX;
|
|
666
699
|
}
|
|
@@ -681,11 +714,17 @@ const rotationValues = [
|
|
|
681
714
|
} else {
|
|
682
715
|
AABB.transform(aabb, Matrix4x4.rotationZ(rotation), tmpAABB);
|
|
683
716
|
}
|
|
684
|
-
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale;
|
|
685
|
-
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale;
|
|
686
|
-
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale;
|
|
687
|
-
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale;
|
|
717
|
+
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale + this._originX;
|
|
718
|
+
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale + this._originX;
|
|
719
|
+
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale + this._originZ;
|
|
720
|
+
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale + this._originZ;
|
|
688
721
|
ctx.calcAABB(ctx.userData, minX, maxX, minZ, maxZ, tmpAABB, level);
|
|
722
|
+
if (camera.clipMask) {
|
|
723
|
+
// Shadow cull cameras test only some planes: a directional cascade keeps casters at any
|
|
724
|
+
// depth along the light.
|
|
725
|
+
const mask = ctx.skirt ? camera.clipMask & ALL_PLANES_EXCEPT_FAR : camera.clipMask;
|
|
726
|
+
return tmpAABB.getClipStateWithFrustumMask(camera.frustum, mask) !== ClipState.NOT_CLIPPED;
|
|
727
|
+
}
|
|
689
728
|
if (ctx.skirt) {
|
|
690
729
|
// Every plane except the far one. A skirted clipmap deliberately reaches
|
|
691
730
|
// past the far plane and pins the depth of whatever lands beyond it, so
|
|
@@ -696,20 +735,25 @@ const rotationValues = [
|
|
|
696
735
|
}
|
|
697
736
|
return tmpAABB.getClipStateWithFrustum(camera.frustum) !== ClipState.NOT_CLIPPED;
|
|
698
737
|
}
|
|
699
|
-
calcLevelAABB(camera, minMaxWorldPos, gridScale) {
|
|
738
|
+
calcLevelAABB(camera, minMaxWorldPos, gridScale, gridOriginX = 0, gridOriginZ = 0) {
|
|
739
|
+
this._originX = gridOriginX;
|
|
740
|
+
this._originZ = gridOriginZ;
|
|
700
741
|
const mipLevels = this.calcMipLevels(camera, minMaxWorldPos, gridScale);
|
|
701
742
|
camera.getWorldPosition(tmpV3);
|
|
702
|
-
const snappedPos =
|
|
703
|
-
const tileSize =
|
|
704
|
-
const base =
|
|
705
|
-
const offset =
|
|
706
|
-
const posX = tmpV3.x / gridScale;
|
|
707
|
-
const posY = tmpV3.z / gridScale;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
743
|
+
const snappedPos = tmpSnappedPos;
|
|
744
|
+
const tileSize = tmpTileSize;
|
|
745
|
+
const base = tmpBase;
|
|
746
|
+
const offset = tmpOffset;
|
|
747
|
+
const posX = (tmpV3.x - gridOriginX) / gridScale;
|
|
748
|
+
const posY = (tmpV3.z - gridOriginZ) / gridScale;
|
|
749
|
+
// Reused across calls: callers consume the result before the next one
|
|
750
|
+
const outAABB = this._levelAABBs;
|
|
751
|
+
while(outAABB.length < mipLevels){
|
|
752
|
+
outAABB.push(new AABB());
|
|
753
|
+
}
|
|
754
|
+
outAABB.length = mipLevels;
|
|
755
|
+
for (const aabb of outAABB){
|
|
711
756
|
aabb.beginExtend();
|
|
712
|
-
outAABB.push(aabb);
|
|
713
757
|
}
|
|
714
758
|
snappedPos.setXY(Math.floor(posX), Math.floor(posY));
|
|
715
759
|
// cross
|
|
@@ -735,16 +779,15 @@ const rotationValues = [
|
|
|
735
779
|
// draw filler
|
|
736
780
|
this.updateAABB(this._fillerMeshAABB, null, snappedPos, scale, gridScale, aabb);
|
|
737
781
|
const nextScale = scale * 2;
|
|
738
|
-
const nextSnappedPos =
|
|
782
|
+
const nextSnappedPos = tmpNextSnappedPos.setXY(Math.floor(posX / nextScale) * nextScale, Math.floor(posY / nextScale) * nextScale);
|
|
739
783
|
// draw trim
|
|
740
|
-
const tileCentre =
|
|
741
|
-
const d = new Vector2(posX - nextSnappedPos.x, posY - nextSnappedPos.y);
|
|
784
|
+
const tileCentre = tmpTileCentre.setXY(snappedPos.x + scale * 0.5, snappedPos.y + scale * 0.5);
|
|
742
785
|
let r = 0;
|
|
743
|
-
r |=
|
|
744
|
-
r |=
|
|
786
|
+
r |= posX - nextSnappedPos.x >= scale ? 0 : 2;
|
|
787
|
+
r |= posY - nextSnappedPos.y >= scale ? 0 : 1;
|
|
745
788
|
this.updateAABB(this._trimMeshAABB, rotationValues[r], tileCentre, scale, gridScale, aabb);
|
|
746
789
|
// draw seam
|
|
747
|
-
const nextBase =
|
|
790
|
+
const nextBase = tmpNextBase.setXY(nextSnappedPos.x - (this._tileResolution << l + 1), nextSnappedPos.y - (this._tileResolution << l + 1));
|
|
748
791
|
this.updateAABB(this._seamMeshAABB, null, nextBase, scale, gridScale, aabb);
|
|
749
792
|
}
|
|
750
793
|
return outAABB;
|
|
@@ -778,12 +821,14 @@ const rotationValues = [
|
|
|
778
821
|
const renderData = [];
|
|
779
822
|
const mipLevels = this.calcMipLevels(context.camera, context.minMaxWorldPos, context.gridScale, context.viewDistance);
|
|
780
823
|
context.camera.getWorldPosition(tmpV3);
|
|
781
|
-
const snappedPos =
|
|
782
|
-
const tileSize =
|
|
783
|
-
const base =
|
|
784
|
-
const offset =
|
|
785
|
-
|
|
786
|
-
|
|
824
|
+
const snappedPos = tmpSnappedPos;
|
|
825
|
+
const tileSize = tmpTileSize;
|
|
826
|
+
const base = tmpBase;
|
|
827
|
+
const offset = tmpOffset;
|
|
828
|
+
this._originX = context.gridOriginX ?? 0;
|
|
829
|
+
this._originZ = context.gridOriginZ ?? 0;
|
|
830
|
+
const posX = (tmpV3.x - this._originX) / context.gridScale;
|
|
831
|
+
const posY = (tmpV3.z - this._originZ) / context.gridScale;
|
|
787
832
|
// draw cross
|
|
788
833
|
snappedPos.setXY(Math.floor(posX), Math.floor(posY));
|
|
789
834
|
if (!context.frustumCulling || this.visible(context, this._crossMeshAABB, context.camera, null, snappedPos, 1, context.gridScale, 0)) {
|
|
@@ -844,7 +889,7 @@ const rotationValues = [
|
|
|
844
889
|
// at a raised camera is tens of kilometres and outgrows any sentinel
|
|
845
890
|
// rectangle - dropping the outer tiles and opening a band of sky
|
|
846
891
|
// between the last one drawn and the horizon skirt.
|
|
847
|
-
context.skirt || this.intervalsOverlap(offset.x * context.gridScale, (offset.x + tileSize.x) * context.gridScale, context.minMaxWorldPos.x, context.minMaxWorldPos.z) && this.intervalsOverlap(offset.y * context.gridScale, (offset.y + tileSize.y) * context.gridScale, context.minMaxWorldPos.y, context.minMaxWorldPos.w)) {
|
|
892
|
+
context.skirt || this.intervalsOverlap(offset.x * context.gridScale + this._originX, (offset.x + tileSize.x) * context.gridScale + this._originX, context.minMaxWorldPos.x, context.minMaxWorldPos.z) && this.intervalsOverlap(offset.y * context.gridScale + this._originZ, (offset.y + tileSize.y) * context.gridScale + this._originZ, context.minMaxWorldPos.y, context.minMaxWorldPos.w)) {
|
|
848
893
|
if (!context.frustumCulling || this.visible(context, this._tileMeshBBox, context.camera, null, offset, scale, context.gridScale, l)) {
|
|
849
894
|
this.addInstance(tilePrimitives, rotationValues[0], offset.x, offset.y, scale, l);
|
|
850
895
|
}
|
|
@@ -857,18 +902,17 @@ const rotationValues = [
|
|
|
857
902
|
}
|
|
858
903
|
if (l !== mipLevels - 1) {
|
|
859
904
|
const nextScale = scale * 2;
|
|
860
|
-
const nextSnappedPos =
|
|
905
|
+
const nextSnappedPos = tmpNextSnappedPos.setXY(Math.floor(posX / nextScale) * nextScale, Math.floor(posY / nextScale) * nextScale);
|
|
861
906
|
// draw trim
|
|
862
|
-
const tileCentre =
|
|
863
|
-
const d = new Vector2(posX - nextSnappedPos.x, posY - nextSnappedPos.y);
|
|
907
|
+
const tileCentre = tmpTileCentre.setXY(snappedPos.x + scale * 0.5, snappedPos.y + scale * 0.5);
|
|
864
908
|
let r = 0;
|
|
865
|
-
r |=
|
|
866
|
-
r |=
|
|
909
|
+
r |= posX - nextSnappedPos.x >= scale ? 0 : 2;
|
|
910
|
+
r |= posY - nextSnappedPos.y >= scale ? 0 : 1;
|
|
867
911
|
if (!context.frustumCulling || this.visible(context, this._trimMeshAABB, context.camera, rotationValues[r], tileCentre, scale, context.gridScale, l)) {
|
|
868
912
|
this.addInstance(trimPrimitives, rotationValues[r], tileCentre.x, tileCentre.y, scale, l);
|
|
869
913
|
}
|
|
870
914
|
// draw seam
|
|
871
|
-
const nextBase =
|
|
915
|
+
const nextBase = tmpNextBase.setXY(nextSnappedPos.x - (this._tileResolution << l + 1), nextSnappedPos.y - (this._tileResolution << l + 1));
|
|
872
916
|
if (!context.frustumCulling || this.visible(context, this._seamMeshAABB, context.camera, null, nextBase, scale, context.gridScale, l)) {
|
|
873
917
|
this.addInstance(seamPrimitives, rotationValues[0], nextBase.x, nextBase.y, scale, l);
|
|
874
918
|
}
|
|
@@ -907,6 +951,77 @@ const rotationValues = [
|
|
|
907
951
|
}
|
|
908
952
|
return renderData;
|
|
909
953
|
}
|
|
954
|
+
/**
|
|
955
|
+
* Keeps the instances of a set returned by {@link Clipmap.gather} that `context.camera` can
|
|
956
|
+
* see, and uploads them in place of the gathered ones.
|
|
957
|
+
*
|
|
958
|
+
* For passes that render the same clipmap from several cameras - a shadow map culls each
|
|
959
|
+
* cascade or cube face with its own - gather once without frustum culling, then call this
|
|
960
|
+
* before each draw. The source set is left untouched, so it can be culled again for the next
|
|
961
|
+
* camera; the returned set is only valid until the next call.
|
|
962
|
+
*
|
|
963
|
+
* Non-instanced meshes (the cross and the skirt) are always kept.
|
|
964
|
+
*
|
|
965
|
+
* @param renderData - A set returned by gather() for this clipmap in the current frame
|
|
966
|
+
* @param context - Gather context whose camera is the one to cull with
|
|
967
|
+
* @returns The culled set
|
|
968
|
+
*/ cullInstances(renderData, context) {
|
|
969
|
+
this._originX = context.gridOriginX ?? 0;
|
|
970
|
+
this._originZ = context.gridOriginZ ?? 0;
|
|
971
|
+
const result = [];
|
|
972
|
+
for (const info of renderData){
|
|
973
|
+
const meshAABB = this.getInstancedMeshAABB(info.primitive);
|
|
974
|
+
if (!meshAABB) {
|
|
975
|
+
result.push(info);
|
|
976
|
+
continue;
|
|
977
|
+
}
|
|
978
|
+
let scratch = this._cullScratch.get(info.primitive);
|
|
979
|
+
if (!scratch) {
|
|
980
|
+
scratch = {
|
|
981
|
+
instanceDatas: new Float32Array(info.instanceDatas.length),
|
|
982
|
+
mipLevels: new Float32Array(info.mipLevels.length)
|
|
983
|
+
};
|
|
984
|
+
this._cullScratch.set(info.primitive, scratch);
|
|
985
|
+
}
|
|
986
|
+
let numInstances = 0;
|
|
987
|
+
let maxMiplevel = 0;
|
|
988
|
+
for(let i = 0; i < info.numInstances; i++){
|
|
989
|
+
const rotation = info.instanceDatas[i * 4 + 0];
|
|
990
|
+
const scale = info.instanceDatas[i * 4 + 1];
|
|
991
|
+
const level = info.mipLevels[i];
|
|
992
|
+
tmpOffset.setXY(info.instanceDatas[i * 4 + 2], info.instanceDatas[i * 4 + 3]);
|
|
993
|
+
if (this.visible(context, meshAABB, context.camera, rotation, tmpOffset, scale, context.gridScale, level)) {
|
|
994
|
+
scratch.instanceDatas.set(info.instanceDatas.subarray(i * 4, i * 4 + 4), numInstances * 4);
|
|
995
|
+
scratch.mipLevels[numInstances] = level;
|
|
996
|
+
maxMiplevel = Math.max(maxMiplevel, level);
|
|
997
|
+
numInstances++;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
if (numInstances > 0) {
|
|
1001
|
+
info.primitive.getVertexBuffer('texCoord0').bufferSubData(0, scratch.instanceDatas, 0, numInstances * 4);
|
|
1002
|
+
result.push({
|
|
1003
|
+
primitive: info.primitive,
|
|
1004
|
+
numInstances,
|
|
1005
|
+
instanceDatas: scratch.instanceDatas,
|
|
1006
|
+
mipLevels: scratch.mipLevels,
|
|
1007
|
+
maxMiplevel
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
return result;
|
|
1012
|
+
}
|
|
1013
|
+
/** Local bounds of the instanced mesh behind a primitive, null for the non-instanced ones */ getInstancedMeshAABB(primitive) {
|
|
1014
|
+
if (primitive === this._tileMesh || primitive === this._tileMeshLines) {
|
|
1015
|
+
return this._tileMeshBBox;
|
|
1016
|
+
} else if (primitive === this._fillerMesh || primitive === this._fillerMeshLines) {
|
|
1017
|
+
return this._fillerMeshAABB;
|
|
1018
|
+
} else if (primitive === this._trimMesh || primitive === this._trimMeshLines) {
|
|
1019
|
+
return this._trimMeshAABB;
|
|
1020
|
+
} else if (primitive === this._seamMesh || primitive === this._seamMeshLines) {
|
|
1021
|
+
return this._seamMeshAABB;
|
|
1022
|
+
}
|
|
1023
|
+
return null;
|
|
1024
|
+
}
|
|
910
1025
|
/** Disposes the clipmap and release all meshes */ onDispose() {
|
|
911
1026
|
super.onDispose();
|
|
912
1027
|
this._crossMesh.dispose();
|