@zephyr3d/scene 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +171 -107
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +344 -365
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1000 -131
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1126 -199
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/material/msdf_text_sprite.js +4 -4
- package/dist/material/msdf_text_sprite.js.map +1 -1
- package/dist/material/pbrblueprint.js +102 -102
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/batchgroup.js +11 -13
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +15 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +79 -16
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/scene.js +1 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +203 -2
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/dist/text/msdf/generator.js.map +1 -1
- package/dist/text/msdf/shape.js +4 -1
- package/dist/text/msdf/shape.js.map +1 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js +4 -1
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -1
- package/dist/utility/blueprint/material/inputs.js +1157 -1154
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +22 -9
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +700 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +64 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +187 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1273
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
|
@@ -1,851 +0,0 @@
|
|
|
1
|
-
import { AABB, Vector3, Matrix4x4, ClipState, Vector2 } from '@zephyr3d/base';
|
|
2
|
-
import { Primitive } from './primitive.js';
|
|
3
|
-
import { getVertexAttributeIndex, VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_TEXCOORD0, getVertexAttributeFormat } from '@zephyr3d/device';
|
|
4
|
-
|
|
5
|
-
const tmpAABB = new AABB();
|
|
6
|
-
const tmpV3 = new Vector3();
|
|
7
|
-
const rotationValues = [
|
|
8
|
-
0,
|
|
9
|
-
Math.PI * 1.5,
|
|
10
|
-
Math.PI * 0.5,
|
|
11
|
-
Math.PI
|
|
12
|
-
];
|
|
13
|
-
/** @internal */ class Clipmap {
|
|
14
|
-
_instanceDataPool;
|
|
15
|
-
_instanceDataPoolSize;
|
|
16
|
-
_mipLevelDataPool;
|
|
17
|
-
_mipLevelDataPoolSize;
|
|
18
|
-
_nonInstanceDataPool;
|
|
19
|
-
_nonInstanceDataPoolSize;
|
|
20
|
-
_nonInstanceMipLevelDataPool;
|
|
21
|
-
_nonInstanceMipLevelDataPoolSize;
|
|
22
|
-
_extraInstanceBuffers;
|
|
23
|
-
_tileResolution;
|
|
24
|
-
_maxMipLevels;
|
|
25
|
-
_tileMesh;
|
|
26
|
-
_tileMeshLines;
|
|
27
|
-
_tileMeshBBox;
|
|
28
|
-
_fillerMesh;
|
|
29
|
-
_fillerMeshLines;
|
|
30
|
-
_fillerMeshAABB;
|
|
31
|
-
_trimMesh;
|
|
32
|
-
_trimMeshLines;
|
|
33
|
-
_trimMeshAABB;
|
|
34
|
-
_crossMesh;
|
|
35
|
-
_crossMeshLines;
|
|
36
|
-
_crossMeshAABB;
|
|
37
|
-
_seamMesh;
|
|
38
|
-
_seamMeshLines;
|
|
39
|
-
_seamMeshAABB;
|
|
40
|
-
_wireframe;
|
|
41
|
-
constructor(resolution, extraInstanceBuffers, maxMipLevels = 64){
|
|
42
|
-
if (extraInstanceBuffers && extraInstanceBuffers.findIndex((val)=>getVertexAttributeIndex(val) === VERTEX_ATTRIB_POSITION || getVertexAttributeIndex(val) === VERTEX_ATTRIB_TEXCOORD0 || getVertexAttributeFormat(val) !== 'f32') >= 0) {
|
|
43
|
-
throw new Error('Extra instance buffers must be f32 format and cannot have vertex attribute of POSITOIN and TEXCOORD0');
|
|
44
|
-
}
|
|
45
|
-
this._extraInstanceBuffers = extraInstanceBuffers?.slice() ?? [];
|
|
46
|
-
this._tileResolution = resolution;
|
|
47
|
-
this._maxMipLevels = Math.min(64, Math.max(1, maxMipLevels >>> 0));
|
|
48
|
-
this._instanceDataPool = [];
|
|
49
|
-
this._instanceDataPoolSize = 0;
|
|
50
|
-
this._mipLevelDataPool = [];
|
|
51
|
-
this._mipLevelDataPoolSize = 0;
|
|
52
|
-
this._nonInstanceDataPool = [];
|
|
53
|
-
this._nonInstanceDataPoolSize = 0;
|
|
54
|
-
this._nonInstanceMipLevelDataPool = [];
|
|
55
|
-
this._nonInstanceMipLevelDataPoolSize = 0;
|
|
56
|
-
this._wireframe = false;
|
|
57
|
-
this.generateCrossMesh();
|
|
58
|
-
this.generateFillerMesh();
|
|
59
|
-
this.generateSeamMesh();
|
|
60
|
-
this.generateTileMesh();
|
|
61
|
-
this.generateTrimMesh();
|
|
62
|
-
}
|
|
63
|
-
get wireframe() {
|
|
64
|
-
return this._wireframe;
|
|
65
|
-
}
|
|
66
|
-
set wireframe(val) {
|
|
67
|
-
this._wireframe = !!val;
|
|
68
|
-
}
|
|
69
|
-
get tileResolution() {
|
|
70
|
-
return this._tileResolution;
|
|
71
|
-
}
|
|
72
|
-
set tileResolution(val) {
|
|
73
|
-
if (val !== this._tileResolution) {
|
|
74
|
-
this._tileResolution = val;
|
|
75
|
-
this.generateCrossMesh();
|
|
76
|
-
this.generateFillerMesh();
|
|
77
|
-
this.generateSeamMesh();
|
|
78
|
-
this.generateTileMesh();
|
|
79
|
-
this.generateTrimMesh();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
allocInstanceBuffer() {
|
|
83
|
-
if (this._instanceDataPoolSize === 0) {
|
|
84
|
-
const buffer = new Float32Array(this._maxMipLevels * 16 * 4);
|
|
85
|
-
this._instanceDataPool.push(buffer);
|
|
86
|
-
return buffer;
|
|
87
|
-
} else {
|
|
88
|
-
return this._instanceDataPool[--this._instanceDataPoolSize];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
allocNonInstanceBuffer(x, y, z, w) {
|
|
92
|
-
let buffer;
|
|
93
|
-
if (this._nonInstanceDataPoolSize === 0) {
|
|
94
|
-
buffer = new Float32Array(4);
|
|
95
|
-
this._nonInstanceDataPool.push(buffer);
|
|
96
|
-
} else {
|
|
97
|
-
buffer = this._nonInstanceDataPool[--this._nonInstanceDataPoolSize];
|
|
98
|
-
}
|
|
99
|
-
buffer[0] = x;
|
|
100
|
-
buffer[1] = y;
|
|
101
|
-
buffer[2] = z;
|
|
102
|
-
buffer[3] = w;
|
|
103
|
-
return buffer;
|
|
104
|
-
}
|
|
105
|
-
allocMipLevelBuffer() {
|
|
106
|
-
if (this._mipLevelDataPoolSize === 0) {
|
|
107
|
-
const buffer = new Float32Array(this._maxMipLevels * 16);
|
|
108
|
-
this._mipLevelDataPool.push(buffer);
|
|
109
|
-
return buffer;
|
|
110
|
-
} else {
|
|
111
|
-
return this._mipLevelDataPool[--this._mipLevelDataPoolSize];
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
allocNonInstanceMipLevelBuffer(val) {
|
|
115
|
-
let buffer;
|
|
116
|
-
if (this._nonInstanceMipLevelDataPoolSize === 0) {
|
|
117
|
-
buffer = new Float32Array(1);
|
|
118
|
-
this._nonInstanceMipLevelDataPool.push(buffer);
|
|
119
|
-
} else {
|
|
120
|
-
buffer = this._nonInstanceMipLevelDataPool[--this._nonInstanceMipLevelDataPoolSize];
|
|
121
|
-
}
|
|
122
|
-
buffer[0] = val;
|
|
123
|
-
return buffer;
|
|
124
|
-
}
|
|
125
|
-
patch2d(tileResolution, x, y) {
|
|
126
|
-
return y * (tileResolution + 1) + x;
|
|
127
|
-
}
|
|
128
|
-
calcAABB(vertices) {
|
|
129
|
-
let maxX = -Number.MAX_VALUE;
|
|
130
|
-
let maxY = -Number.MAX_VALUE;
|
|
131
|
-
let minX = Number.MAX_VALUE;
|
|
132
|
-
let minY = Number.MAX_VALUE;
|
|
133
|
-
for(let i = 0; i < vertices.length / 3; i++){
|
|
134
|
-
const x = vertices[i * 3 + 0];
|
|
135
|
-
const y = vertices[i * 3 + 1];
|
|
136
|
-
if (x > maxX) {
|
|
137
|
-
maxX = x;
|
|
138
|
-
}
|
|
139
|
-
if (x < minX) {
|
|
140
|
-
minX = x;
|
|
141
|
-
}
|
|
142
|
-
if (y > maxY) {
|
|
143
|
-
maxY = y;
|
|
144
|
-
}
|
|
145
|
-
if (y < minY) {
|
|
146
|
-
minY = y;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return new AABB(new Vector3(minX, minY, 0), new Vector3(maxX, maxY, 0));
|
|
150
|
-
}
|
|
151
|
-
generateTileMesh() {
|
|
152
|
-
this._tileMesh?.dispose();
|
|
153
|
-
this._tileMesh = new Primitive();
|
|
154
|
-
const patchVertResolution = this._tileResolution + 1;
|
|
155
|
-
const vertices = new Float32Array(patchVertResolution * patchVertResolution * 3);
|
|
156
|
-
let n = 0;
|
|
157
|
-
for(let y = 0; y < patchVertResolution; y++){
|
|
158
|
-
for(let x = 0; x < patchVertResolution; x++){
|
|
159
|
-
vertices[n++] = x;
|
|
160
|
-
vertices[n++] = y;
|
|
161
|
-
vertices[n++] = 0;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
n = 0;
|
|
165
|
-
const indices = new Uint16Array(this._tileResolution * this._tileResolution * 6);
|
|
166
|
-
for(let y = 0; y < this._tileResolution; y++){
|
|
167
|
-
for(let x = 0; x < this._tileResolution; x++){
|
|
168
|
-
indices[n++] = this.patch2d(this._tileResolution, x, y);
|
|
169
|
-
indices[n++] = this.patch2d(this._tileResolution, x, y + 1);
|
|
170
|
-
indices[n++] = this.patch2d(this._tileResolution, x + 1, y + 1);
|
|
171
|
-
indices[n++] = this.patch2d(this._tileResolution, x, y);
|
|
172
|
-
indices[n++] = this.patch2d(this._tileResolution, x + 1, y + 1);
|
|
173
|
-
indices[n++] = this.patch2d(this._tileResolution, x + 1, y);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
this._tileMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
177
|
-
this._tileMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
178
|
-
this._instanceDataPoolSize++;
|
|
179
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
180
|
-
this._tileMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
181
|
-
this._instanceDataPoolSize++;
|
|
182
|
-
}
|
|
183
|
-
this._tileMesh.createAndSetIndexBuffer(indices);
|
|
184
|
-
this._tileMesh.indexStart = 0;
|
|
185
|
-
this._tileMesh.indexCount = indices.length;
|
|
186
|
-
this._tileMesh.primitiveType = 'triangle-list';
|
|
187
|
-
this._tileMeshBBox = this.calcAABB(vertices);
|
|
188
|
-
const indicesLines = new Uint16Array(indices.length * 2);
|
|
189
|
-
for(let i = 0; i < indices.length / 3; i++){
|
|
190
|
-
indicesLines[i * 6 + 0] = indices[i * 3 + 0];
|
|
191
|
-
indicesLines[i * 6 + 1] = indices[i * 3 + 1];
|
|
192
|
-
indicesLines[i * 6 + 2] = indices[i * 3 + 1];
|
|
193
|
-
indicesLines[i * 6 + 3] = indices[i * 3 + 2];
|
|
194
|
-
indicesLines[i * 6 + 4] = indices[i * 3 + 2];
|
|
195
|
-
indicesLines[i * 6 + 5] = indices[i * 3 + 0];
|
|
196
|
-
}
|
|
197
|
-
this._tileMeshLines?.dispose();
|
|
198
|
-
this._tileMeshLines = new Primitive();
|
|
199
|
-
this._tileMeshLines.setVertexBuffer(this._tileMesh.getVertexBuffer('position'));
|
|
200
|
-
this._tileMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
201
|
-
this._instanceDataPoolSize++;
|
|
202
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
203
|
-
this._tileMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
204
|
-
this._instanceDataPoolSize++;
|
|
205
|
-
}
|
|
206
|
-
this._tileMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
207
|
-
this._tileMeshLines.indexStart = 0;
|
|
208
|
-
this._tileMeshLines.indexCount = indicesLines.length;
|
|
209
|
-
this._tileMeshLines.primitiveType = 'line-list';
|
|
210
|
-
}
|
|
211
|
-
generateFillerMesh() {
|
|
212
|
-
this._fillerMesh?.dispose();
|
|
213
|
-
this._fillerMesh = new Primitive();
|
|
214
|
-
const patchVertResolution = this._tileResolution + 1;
|
|
215
|
-
const vertices = new Float32Array(patchVertResolution * 8 * 3);
|
|
216
|
-
let n = 0;
|
|
217
|
-
const offset = this._tileResolution;
|
|
218
|
-
for(let i = 0; i < patchVertResolution; i++){
|
|
219
|
-
vertices[n++] = offset + i + 1;
|
|
220
|
-
vertices[n++] = 0;
|
|
221
|
-
vertices[n++] = 0;
|
|
222
|
-
vertices[n++] = offset + i + 1;
|
|
223
|
-
vertices[n++] = 1;
|
|
224
|
-
vertices[n++] = 0;
|
|
225
|
-
}
|
|
226
|
-
for(let i = 0; i < patchVertResolution; i++){
|
|
227
|
-
vertices[n++] = 1;
|
|
228
|
-
vertices[n++] = offset + i + 1;
|
|
229
|
-
vertices[n++] = 0;
|
|
230
|
-
vertices[n++] = 0;
|
|
231
|
-
vertices[n++] = offset + i + 1;
|
|
232
|
-
vertices[n++] = 0;
|
|
233
|
-
}
|
|
234
|
-
for(let i = 0; i < patchVertResolution; i++){
|
|
235
|
-
vertices[n++] = -offset - i;
|
|
236
|
-
vertices[n++] = 1;
|
|
237
|
-
vertices[n++] = 0;
|
|
238
|
-
vertices[n++] = -offset - i;
|
|
239
|
-
vertices[n++] = 0;
|
|
240
|
-
vertices[n++] = 0;
|
|
241
|
-
}
|
|
242
|
-
for(let i = 0; i < patchVertResolution; i++){
|
|
243
|
-
vertices[n++] = 0;
|
|
244
|
-
vertices[n++] = -offset - i;
|
|
245
|
-
vertices[n++] = 0;
|
|
246
|
-
vertices[n++] = 1;
|
|
247
|
-
vertices[n++] = -offset - i;
|
|
248
|
-
vertices[n++] = 0;
|
|
249
|
-
}
|
|
250
|
-
n = 0;
|
|
251
|
-
const indices = new Uint16Array(this._tileResolution * 24);
|
|
252
|
-
for(let i = 0; i < this._tileResolution * 4; i++){
|
|
253
|
-
const arm = i / this._tileResolution >> 0;
|
|
254
|
-
const bl = (arm + i) * 2 + 0;
|
|
255
|
-
const br = (arm + i) * 2 + 1;
|
|
256
|
-
const tl = (arm + i) * 2 + 2;
|
|
257
|
-
const tr = (arm + i) * 2 + 3;
|
|
258
|
-
if (arm % 2 === 0) {
|
|
259
|
-
indices[n++] = br;
|
|
260
|
-
indices[n++] = tr;
|
|
261
|
-
indices[n++] = bl;
|
|
262
|
-
indices[n++] = bl;
|
|
263
|
-
indices[n++] = tr;
|
|
264
|
-
indices[n++] = tl;
|
|
265
|
-
} else {
|
|
266
|
-
indices[n++] = br;
|
|
267
|
-
indices[n++] = tl;
|
|
268
|
-
indices[n++] = bl;
|
|
269
|
-
indices[n++] = br;
|
|
270
|
-
indices[n++] = tr;
|
|
271
|
-
indices[n++] = tl;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
this._fillerMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
275
|
-
this._fillerMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
276
|
-
this._instanceDataPoolSize++;
|
|
277
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
278
|
-
this._fillerMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
279
|
-
this._instanceDataPoolSize++;
|
|
280
|
-
}
|
|
281
|
-
this._fillerMesh.createAndSetIndexBuffer(indices);
|
|
282
|
-
this._fillerMesh.indexStart = 0;
|
|
283
|
-
this._fillerMesh.indexCount = indices.length;
|
|
284
|
-
this._fillerMesh.primitiveType = 'triangle-list';
|
|
285
|
-
this._fillerMeshAABB = this.calcAABB(vertices);
|
|
286
|
-
const indicesLines = new Uint16Array(indices.length * 2);
|
|
287
|
-
for(let i = 0; i < indices.length / 3; i++){
|
|
288
|
-
indicesLines[i * 6 + 0] = indices[i * 3 + 0];
|
|
289
|
-
indicesLines[i * 6 + 1] = indices[i * 3 + 1];
|
|
290
|
-
indicesLines[i * 6 + 2] = indices[i * 3 + 1];
|
|
291
|
-
indicesLines[i * 6 + 3] = indices[i * 3 + 2];
|
|
292
|
-
indicesLines[i * 6 + 4] = indices[i * 3 + 2];
|
|
293
|
-
indicesLines[i * 6 + 5] = indices[i * 3 + 0];
|
|
294
|
-
}
|
|
295
|
-
this._fillerMeshLines?.dispose();
|
|
296
|
-
this._fillerMeshLines = new Primitive();
|
|
297
|
-
this._fillerMeshLines.setVertexBuffer(this._fillerMesh.getVertexBuffer('position'));
|
|
298
|
-
this._fillerMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
299
|
-
this._instanceDataPoolSize++;
|
|
300
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
301
|
-
this._fillerMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
302
|
-
this._instanceDataPoolSize++;
|
|
303
|
-
}
|
|
304
|
-
this._fillerMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
305
|
-
this._fillerMeshLines.indexStart = 0;
|
|
306
|
-
this._fillerMeshLines.indexCount = indicesLines.length;
|
|
307
|
-
this._fillerMeshLines.primitiveType = 'line-list';
|
|
308
|
-
}
|
|
309
|
-
generateTrimMesh() {
|
|
310
|
-
this._trimMesh?.dispose();
|
|
311
|
-
this._trimMesh = new Primitive();
|
|
312
|
-
const clipmapVertResolution = this._tileResolution * 4 + 2;
|
|
313
|
-
const vertices = new Float32Array((clipmapVertResolution * 2 + 1) * 2 * 3);
|
|
314
|
-
let n = 0;
|
|
315
|
-
const d = 0.5 * (clipmapVertResolution + 1);
|
|
316
|
-
for(let i = 0; i < clipmapVertResolution + 1; i++){
|
|
317
|
-
vertices[n++] = 0 - d;
|
|
318
|
-
vertices[n++] = clipmapVertResolution - i - d;
|
|
319
|
-
vertices[n++] = 0;
|
|
320
|
-
vertices[n++] = 1 - d;
|
|
321
|
-
vertices[n++] = clipmapVertResolution - i - d;
|
|
322
|
-
vertices[n++] = 0;
|
|
323
|
-
}
|
|
324
|
-
const startOfHorizonal = n / 3;
|
|
325
|
-
for(let i = 0; i < clipmapVertResolution; i++){
|
|
326
|
-
vertices[n++] = i + 1 - d;
|
|
327
|
-
vertices[n++] = 0 - d;
|
|
328
|
-
vertices[n++] = 0;
|
|
329
|
-
vertices[n++] = i + 1 - d;
|
|
330
|
-
vertices[n++] = 1 - d;
|
|
331
|
-
vertices[n++] = 0;
|
|
332
|
-
}
|
|
333
|
-
n = 0;
|
|
334
|
-
const indices = new Uint16Array((clipmapVertResolution * 2 - 1) * 6);
|
|
335
|
-
for(let i = 0; i < clipmapVertResolution; i++){
|
|
336
|
-
indices[n++] = (i + 0) * 2 + 1;
|
|
337
|
-
indices[n++] = (i + 1) * 2 + 0;
|
|
338
|
-
indices[n++] = (i + 0) * 2 + 0;
|
|
339
|
-
indices[n++] = (i + 1) * 2 + 1;
|
|
340
|
-
indices[n++] = (i + 1) * 2 + 0;
|
|
341
|
-
indices[n++] = (i + 0) * 2 + 1;
|
|
342
|
-
}
|
|
343
|
-
for(let i = 0; i < clipmapVertResolution - 1; i++){
|
|
344
|
-
indices[n++] = startOfHorizonal + (i + 0) * 2 + 1;
|
|
345
|
-
indices[n++] = startOfHorizonal + (i + 1) * 2 + 0;
|
|
346
|
-
indices[n++] = startOfHorizonal + (i + 0) * 2 + 0;
|
|
347
|
-
indices[n++] = startOfHorizonal + (i + 1) * 2 + 1;
|
|
348
|
-
indices[n++] = startOfHorizonal + (i + 1) * 2 + 0;
|
|
349
|
-
indices[n++] = startOfHorizonal + (i + 0) * 2 + 1;
|
|
350
|
-
}
|
|
351
|
-
this._trimMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
352
|
-
this._trimMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
353
|
-
this._instanceDataPoolSize++;
|
|
354
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
355
|
-
this._trimMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
356
|
-
this._instanceDataPoolSize++;
|
|
357
|
-
}
|
|
358
|
-
this._trimMesh.createAndSetIndexBuffer(indices);
|
|
359
|
-
this._trimMesh.indexStart = 0;
|
|
360
|
-
this._trimMesh.indexCount = indices.length;
|
|
361
|
-
this._trimMesh.primitiveType = 'triangle-list';
|
|
362
|
-
this._trimMeshAABB = this.calcAABB(vertices);
|
|
363
|
-
const indicesLines = new Uint16Array(indices.length * 2);
|
|
364
|
-
for(let i = 0; i < indices.length / 3; i++){
|
|
365
|
-
indicesLines[i * 6 + 0] = indices[i * 3 + 0];
|
|
366
|
-
indicesLines[i * 6 + 1] = indices[i * 3 + 1];
|
|
367
|
-
indicesLines[i * 6 + 2] = indices[i * 3 + 1];
|
|
368
|
-
indicesLines[i * 6 + 3] = indices[i * 3 + 2];
|
|
369
|
-
indicesLines[i * 6 + 4] = indices[i * 3 + 2];
|
|
370
|
-
indicesLines[i * 6 + 5] = indices[i * 3 + 0];
|
|
371
|
-
}
|
|
372
|
-
this._trimMeshLines?.dispose();
|
|
373
|
-
this._trimMeshLines = new Primitive();
|
|
374
|
-
this._trimMeshLines.setVertexBuffer(this._trimMesh.getVertexBuffer('position'));
|
|
375
|
-
this._trimMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
376
|
-
this._instanceDataPoolSize++;
|
|
377
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
378
|
-
this._trimMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
379
|
-
this._instanceDataPoolSize++;
|
|
380
|
-
}
|
|
381
|
-
this._trimMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
382
|
-
this._trimMeshLines.indexStart = 0;
|
|
383
|
-
this._trimMeshLines.indexCount = indicesLines.length;
|
|
384
|
-
this._trimMeshLines.primitiveType = 'line-list';
|
|
385
|
-
}
|
|
386
|
-
generateCrossMesh() {
|
|
387
|
-
const patchVertResolution = this._tileResolution + 1;
|
|
388
|
-
const vertices = new Float32Array(patchVertResolution * 8 * 3);
|
|
389
|
-
let n = 0;
|
|
390
|
-
for(let i = 0; i < patchVertResolution * 2; i++){
|
|
391
|
-
vertices[n++] = i - this._tileResolution;
|
|
392
|
-
vertices[n++] = 0;
|
|
393
|
-
vertices[n++] = 0;
|
|
394
|
-
vertices[n++] = i - this._tileResolution;
|
|
395
|
-
vertices[n++] = 1;
|
|
396
|
-
vertices[n++] = 0;
|
|
397
|
-
}
|
|
398
|
-
const startOfVertical = n / 3;
|
|
399
|
-
for(let i = 0; i < patchVertResolution * 2; i++){
|
|
400
|
-
vertices[n++] = 0;
|
|
401
|
-
vertices[n++] = i - this._tileResolution;
|
|
402
|
-
vertices[n++] = 0;
|
|
403
|
-
vertices[n++] = 1;
|
|
404
|
-
vertices[n++] = i - this._tileResolution;
|
|
405
|
-
vertices[n++] = 0;
|
|
406
|
-
}
|
|
407
|
-
n = 0;
|
|
408
|
-
const indices = new Uint16Array(this._tileResolution * 24 + 6);
|
|
409
|
-
for(let i = 0; i < this._tileResolution * 2 + 1; i++){
|
|
410
|
-
const bl = i * 2 + 0;
|
|
411
|
-
const br = i * 2 + 1;
|
|
412
|
-
const tl = i * 2 + 2;
|
|
413
|
-
const tr = i * 2 + 3;
|
|
414
|
-
indices[n++] = br;
|
|
415
|
-
indices[n++] = tr;
|
|
416
|
-
indices[n++] = bl;
|
|
417
|
-
indices[n++] = bl;
|
|
418
|
-
indices[n++] = tr;
|
|
419
|
-
indices[n++] = tl;
|
|
420
|
-
}
|
|
421
|
-
for(let i = 0; i < this._tileResolution * 2 + 1; i++){
|
|
422
|
-
if (i === this._tileResolution) {
|
|
423
|
-
continue;
|
|
424
|
-
}
|
|
425
|
-
const bl = i * 2 + 0;
|
|
426
|
-
const br = i * 2 + 1;
|
|
427
|
-
const tl = i * 2 + 2;
|
|
428
|
-
const tr = i * 2 + 3;
|
|
429
|
-
indices[n++] = startOfVertical + br;
|
|
430
|
-
indices[n++] = startOfVertical + bl;
|
|
431
|
-
indices[n++] = startOfVertical + tr;
|
|
432
|
-
indices[n++] = startOfVertical + bl;
|
|
433
|
-
indices[n++] = startOfVertical + tl;
|
|
434
|
-
indices[n++] = startOfVertical + tr;
|
|
435
|
-
}
|
|
436
|
-
this._crossMesh?.dispose();
|
|
437
|
-
this._crossMesh = new Primitive();
|
|
438
|
-
this._crossMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
439
|
-
this._crossMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
440
|
-
this._nonInstanceDataPoolSize++;
|
|
441
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
442
|
-
this._crossMesh.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
443
|
-
this._nonInstanceDataPoolSize++;
|
|
444
|
-
}
|
|
445
|
-
this._crossMesh.createAndSetIndexBuffer(indices);
|
|
446
|
-
this._crossMesh.indexStart = 0;
|
|
447
|
-
this._crossMesh.indexCount = indices.length;
|
|
448
|
-
this._crossMesh.primitiveType = 'triangle-list';
|
|
449
|
-
this._crossMeshAABB = this.calcAABB(vertices);
|
|
450
|
-
const indicesLines = new Uint16Array(indices.length * 2);
|
|
451
|
-
for(let i = 0; i < indices.length / 3; i++){
|
|
452
|
-
indicesLines[i * 6 + 0] = indices[i * 3 + 0];
|
|
453
|
-
indicesLines[i * 6 + 1] = indices[i * 3 + 1];
|
|
454
|
-
indicesLines[i * 6 + 2] = indices[i * 3 + 1];
|
|
455
|
-
indicesLines[i * 6 + 3] = indices[i * 3 + 2];
|
|
456
|
-
indicesLines[i * 6 + 4] = indices[i * 3 + 2];
|
|
457
|
-
indicesLines[i * 6 + 5] = indices[i * 3 + 0];
|
|
458
|
-
}
|
|
459
|
-
this._crossMeshLines?.dispose();
|
|
460
|
-
this._crossMeshLines = new Primitive();
|
|
461
|
-
this._crossMeshLines.setVertexBuffer(this._crossMesh.getVertexBuffer('position'));
|
|
462
|
-
this._crossMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
463
|
-
this._nonInstanceDataPoolSize++;
|
|
464
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
465
|
-
this._crossMeshLines.createAndSetVertexBuffer(fmt, this.allocNonInstanceBuffer(0, 0, 0, 0), 'instance');
|
|
466
|
-
this._nonInstanceDataPoolSize++;
|
|
467
|
-
}
|
|
468
|
-
this._crossMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
469
|
-
this._crossMeshLines.indexStart = 0;
|
|
470
|
-
this._crossMeshLines.indexCount = indicesLines.length;
|
|
471
|
-
this._crossMeshLines.primitiveType = 'line-list';
|
|
472
|
-
}
|
|
473
|
-
generateSeamMesh() {
|
|
474
|
-
this._seamMesh?.dispose();
|
|
475
|
-
this._seamMesh = new Primitive();
|
|
476
|
-
const clipmapVertResolution = this._tileResolution * 4 + 2;
|
|
477
|
-
const vertices = new Float32Array(clipmapVertResolution * 4 * 3);
|
|
478
|
-
for(let i = 0; i < clipmapVertResolution; i++){
|
|
479
|
-
vertices[(clipmapVertResolution * 0 + i) * 3 + 0] = i;
|
|
480
|
-
vertices[(clipmapVertResolution * 0 + i) * 3 + 1] = 0;
|
|
481
|
-
vertices[(clipmapVertResolution * 0 + i) * 3 + 2] = 0;
|
|
482
|
-
vertices[(clipmapVertResolution * 1 + i) * 3 + 0] = clipmapVertResolution;
|
|
483
|
-
vertices[(clipmapVertResolution * 1 + i) * 3 + 1] = i;
|
|
484
|
-
vertices[(clipmapVertResolution * 1 + i) * 3 + 2] = 0;
|
|
485
|
-
vertices[(clipmapVertResolution * 2 + i) * 3 + 0] = clipmapVertResolution - i;
|
|
486
|
-
vertices[(clipmapVertResolution * 2 + i) * 3 + 1] = clipmapVertResolution;
|
|
487
|
-
vertices[(clipmapVertResolution * 2 + i) * 3 + 2] = 0;
|
|
488
|
-
vertices[(clipmapVertResolution * 3 + i) * 3 + 0] = 0;
|
|
489
|
-
vertices[(clipmapVertResolution * 3 + i) * 3 + 1] = clipmapVertResolution - i;
|
|
490
|
-
vertices[(clipmapVertResolution * 3 + i) * 3 + 2] = 0;
|
|
491
|
-
}
|
|
492
|
-
const indices = new Uint16Array(clipmapVertResolution * 6);
|
|
493
|
-
let n = 0;
|
|
494
|
-
for(let i = 0; i < clipmapVertResolution * 4; i += 2){
|
|
495
|
-
indices[n++] = i + 1;
|
|
496
|
-
indices[n++] = i + 2;
|
|
497
|
-
indices[n++] = i;
|
|
498
|
-
}
|
|
499
|
-
indices[indices.length - 1] = 0;
|
|
500
|
-
this._seamMesh.createAndSetVertexBuffer('position_f32x3', vertices);
|
|
501
|
-
this._seamMesh.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
502
|
-
this._instanceDataPoolSize++;
|
|
503
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
504
|
-
this._seamMesh.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
505
|
-
this._instanceDataPoolSize++;
|
|
506
|
-
}
|
|
507
|
-
this._seamMesh.createAndSetIndexBuffer(indices);
|
|
508
|
-
this._seamMesh.indexStart = 0;
|
|
509
|
-
this._seamMesh.indexCount = indices.length;
|
|
510
|
-
this._seamMesh.primitiveType = 'triangle-list';
|
|
511
|
-
this._seamMeshAABB = this.calcAABB(vertices);
|
|
512
|
-
const indicesLines = new Uint16Array(indices.length * 2);
|
|
513
|
-
for(let i = 0; i < indices.length / 3; i++){
|
|
514
|
-
indicesLines[i * 6 + 0] = indices[i * 3 + 0];
|
|
515
|
-
indicesLines[i * 6 + 1] = indices[i * 3 + 1];
|
|
516
|
-
indicesLines[i * 6 + 2] = indices[i * 3 + 1];
|
|
517
|
-
indicesLines[i * 6 + 3] = indices[i * 3 + 2];
|
|
518
|
-
indicesLines[i * 6 + 4] = indices[i * 3 + 2];
|
|
519
|
-
indicesLines[i * 6 + 5] = indices[i * 3 + 0];
|
|
520
|
-
}
|
|
521
|
-
this._seamMeshLines?.dispose();
|
|
522
|
-
this._seamMeshLines = new Primitive();
|
|
523
|
-
this._seamMeshLines.setVertexBuffer(this._seamMesh.getVertexBuffer('position'));
|
|
524
|
-
this._seamMeshLines.createAndSetVertexBuffer('tex0_f32x4', this.allocInstanceBuffer(), 'instance');
|
|
525
|
-
this._instanceDataPoolSize++;
|
|
526
|
-
for (const fmt of this._extraInstanceBuffers){
|
|
527
|
-
this._seamMeshLines.createAndSetVertexBuffer(fmt, this.allocInstanceBuffer(), 'instance');
|
|
528
|
-
this._instanceDataPoolSize++;
|
|
529
|
-
}
|
|
530
|
-
this._seamMeshLines.createAndSetIndexBuffer(indicesLines);
|
|
531
|
-
this._seamMeshLines.indexStart = 0;
|
|
532
|
-
this._seamMeshLines.indexCount = indicesLines.length;
|
|
533
|
-
this._seamMeshLines.primitiveType = 'line-list';
|
|
534
|
-
}
|
|
535
|
-
intervalsOverlap(a0, a1, b0, b1) {
|
|
536
|
-
return a0 <= b1 && b0 <= a1;
|
|
537
|
-
}
|
|
538
|
-
updateAABB(aabb, rotation, offset, scale, gridScale, outAABB) {
|
|
539
|
-
if (!rotation) {
|
|
540
|
-
tmpAABB.minPoint.set(aabb.minPoint);
|
|
541
|
-
tmpAABB.maxPoint.set(aabb.maxPoint);
|
|
542
|
-
} else {
|
|
543
|
-
AABB.transform(aabb, Matrix4x4.rotationZ(rotation), tmpAABB);
|
|
544
|
-
}
|
|
545
|
-
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale;
|
|
546
|
-
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale;
|
|
547
|
-
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale;
|
|
548
|
-
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale;
|
|
549
|
-
if (minX < outAABB.minPoint.x) {
|
|
550
|
-
outAABB.minPoint.x = minX;
|
|
551
|
-
}
|
|
552
|
-
if (maxX > outAABB.maxPoint.x) {
|
|
553
|
-
outAABB.maxPoint.x = maxX;
|
|
554
|
-
}
|
|
555
|
-
if (minZ < outAABB.minPoint.z) {
|
|
556
|
-
outAABB.minPoint.z = minZ;
|
|
557
|
-
}
|
|
558
|
-
if (maxZ > outAABB.maxPoint.z) {
|
|
559
|
-
outAABB.maxPoint.z = maxZ;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
visible(ctx, aabb, camera, rotation, offset, scale, gridScale, level) {
|
|
563
|
-
if (!rotation) {
|
|
564
|
-
tmpAABB.minPoint.set(aabb.minPoint);
|
|
565
|
-
tmpAABB.maxPoint.set(aabb.maxPoint);
|
|
566
|
-
} else {
|
|
567
|
-
AABB.transform(aabb, Matrix4x4.rotationZ(rotation), tmpAABB);
|
|
568
|
-
}
|
|
569
|
-
const minX = (tmpAABB.minPoint.x * scale + offset.x) * gridScale;
|
|
570
|
-
const maxX = (tmpAABB.maxPoint.x * scale + offset.x) * gridScale;
|
|
571
|
-
const minZ = (tmpAABB.minPoint.y * scale + offset.y) * gridScale;
|
|
572
|
-
const maxZ = (tmpAABB.maxPoint.y * scale + offset.y) * gridScale;
|
|
573
|
-
ctx.calcAABB(ctx.userData, minX, maxX, minZ, maxZ, tmpAABB, level);
|
|
574
|
-
return tmpAABB.getClipStateWithFrustum(camera.frustum) !== ClipState.NOT_CLIPPED;
|
|
575
|
-
}
|
|
576
|
-
calcLevelAABB(camera, minMaxWorldPos, gridScale) {
|
|
577
|
-
const mipLevels = this.calcMipLevels(camera, minMaxWorldPos, gridScale);
|
|
578
|
-
camera.getWorldPosition(tmpV3);
|
|
579
|
-
const snappedPos = new Vector2();
|
|
580
|
-
const tileSize = new Vector2();
|
|
581
|
-
const base = new Vector2();
|
|
582
|
-
const offset = new Vector2();
|
|
583
|
-
const posX = tmpV3.x / gridScale;
|
|
584
|
-
const posY = tmpV3.z / gridScale;
|
|
585
|
-
const outAABB = [];
|
|
586
|
-
for(let i = 0; i < mipLevels; i++){
|
|
587
|
-
const aabb = new AABB();
|
|
588
|
-
aabb.beginExtend();
|
|
589
|
-
outAABB.push(aabb);
|
|
590
|
-
}
|
|
591
|
-
snappedPos.setXY(Math.floor(posX), Math.floor(posY));
|
|
592
|
-
// cross
|
|
593
|
-
this.updateAABB(this._crossMeshAABB, null, snappedPos, 1, gridScale, outAABB[0]);
|
|
594
|
-
for(let l = 0; l < mipLevels; l++){
|
|
595
|
-
const aabb = outAABB[l];
|
|
596
|
-
const scale = 1 << l;
|
|
597
|
-
snappedPos.setXY(Math.floor(posX / scale) * scale, Math.floor(posY / scale) * scale);
|
|
598
|
-
// draw tiles
|
|
599
|
-
tileSize.setXY(this._tileResolution << l, this._tileResolution << l);
|
|
600
|
-
base.setXY(snappedPos.x - (this._tileResolution << l + 1), snappedPos.y - (this._tileResolution << l + 1));
|
|
601
|
-
for(let x = 0; x < 4; x++){
|
|
602
|
-
for(let y = 0; y < 4; y++){
|
|
603
|
-
if (l !== 0 && (x === 1 || x === 2) && (y === 1 || y === 2)) {
|
|
604
|
-
continue;
|
|
605
|
-
}
|
|
606
|
-
const fillX = x >= 2 ? scale : 0;
|
|
607
|
-
const fillY = y >= 2 ? scale : 0;
|
|
608
|
-
offset.setXY(base.x + x * tileSize.x + fillX, base.y + y * tileSize.y + fillY);
|
|
609
|
-
this.updateAABB(this._tileMeshBBox, null, offset, scale, gridScale, aabb);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
// draw filler
|
|
613
|
-
this.updateAABB(this._fillerMeshAABB, null, snappedPos, scale, gridScale, aabb);
|
|
614
|
-
const nextScale = scale * 2;
|
|
615
|
-
const nextSnappedPos = new Vector2(Math.floor(posX / nextScale) * nextScale, Math.floor(posY / nextScale) * nextScale);
|
|
616
|
-
// draw trim
|
|
617
|
-
const tileCentre = new Vector2(snappedPos.x + scale * 0.5, snappedPos.y + scale * 0.5);
|
|
618
|
-
const d = new Vector2(posX - nextSnappedPos.x, posY - nextSnappedPos.y);
|
|
619
|
-
let r = 0;
|
|
620
|
-
r |= d.x >= scale ? 0 : 2;
|
|
621
|
-
r |= d.y >= scale ? 0 : 1;
|
|
622
|
-
this.updateAABB(this._trimMeshAABB, rotationValues[r], tileCentre, scale, gridScale, aabb);
|
|
623
|
-
// draw seam
|
|
624
|
-
const nextBase = new Vector2(nextSnappedPos.x - (this._tileResolution << l + 1), nextSnappedPos.y - (this._tileResolution << l + 1));
|
|
625
|
-
this.updateAABB(this._seamMeshAABB, null, nextBase, scale, gridScale, aabb);
|
|
626
|
-
}
|
|
627
|
-
return outAABB;
|
|
628
|
-
}
|
|
629
|
-
calcMipLevels(camera, minMaxWorldPos, gridScale) {
|
|
630
|
-
camera.getWorldPosition(tmpV3);
|
|
631
|
-
const distX = Math.max(Math.abs(tmpV3.x - minMaxWorldPos.x), Math.abs(tmpV3.x - minMaxWorldPos.z));
|
|
632
|
-
const distY = Math.max(Math.abs(tmpV3.z - minMaxWorldPos.y), Math.abs(tmpV3.z - minMaxWorldPos.w));
|
|
633
|
-
const maxDist = Math.min(Math.max(distX, distY), camera.getFarPlane());
|
|
634
|
-
return Math.min(Math.max(Math.ceil(Math.log2(maxDist / (this._tileResolution * gridScale))), 0) + 1, this._maxMipLevels);
|
|
635
|
-
}
|
|
636
|
-
addInstance(info, rotation, offsetX, offsetY, scale, mipLevel) {
|
|
637
|
-
info.mipLevels[info.numInstances] = mipLevel;
|
|
638
|
-
info.instanceDatas[info.numInstances * 4 + 0] = rotation;
|
|
639
|
-
info.instanceDatas[info.numInstances * 4 + 1] = scale;
|
|
640
|
-
info.instanceDatas[info.numInstances * 4 + 2] = offsetX;
|
|
641
|
-
info.instanceDatas[info.numInstances * 4 + 3] = offsetY;
|
|
642
|
-
info.maxMiplevel = mipLevel;
|
|
643
|
-
info.numInstances++;
|
|
644
|
-
}
|
|
645
|
-
gather(context) {
|
|
646
|
-
this._instanceDataPoolSize = this._instanceDataPool.length;
|
|
647
|
-
this._mipLevelDataPoolSize = this._mipLevelDataPool.length;
|
|
648
|
-
this._nonInstanceDataPoolSize = this._nonInstanceDataPool.length;
|
|
649
|
-
this._nonInstanceMipLevelDataPoolSize = this._nonInstanceMipLevelDataPool.length;
|
|
650
|
-
const renderData = [];
|
|
651
|
-
const mipLevels = this.calcMipLevels(context.camera, context.minMaxWorldPos, context.gridScale);
|
|
652
|
-
context.camera.getWorldPosition(tmpV3);
|
|
653
|
-
const snappedPos = new Vector2();
|
|
654
|
-
const tileSize = new Vector2();
|
|
655
|
-
const base = new Vector2();
|
|
656
|
-
const offset = new Vector2();
|
|
657
|
-
const posX = tmpV3.x / context.gridScale;
|
|
658
|
-
const posY = tmpV3.z / context.gridScale;
|
|
659
|
-
// draw cross
|
|
660
|
-
snappedPos.setXY(Math.floor(posX), Math.floor(posY));
|
|
661
|
-
if (this.visible(context, this._crossMeshAABB, context.camera, null, snappedPos, 1, context.gridScale, 0)) {
|
|
662
|
-
const crossPrimitives = {
|
|
663
|
-
primitive: this._wireframe ? this._crossMeshLines : this._crossMesh,
|
|
664
|
-
numInstances: 1,
|
|
665
|
-
instanceDatas: this.allocNonInstanceBuffer(rotationValues[0], 1, snappedPos.x, snappedPos.y),
|
|
666
|
-
mipLevels: this.allocNonInstanceMipLevelBuffer(0),
|
|
667
|
-
maxMiplevel: 0
|
|
668
|
-
};
|
|
669
|
-
renderData.push(crossPrimitives);
|
|
670
|
-
}
|
|
671
|
-
const tilePrimitives = {
|
|
672
|
-
primitive: this._wireframe ? this._tileMeshLines : this._tileMesh,
|
|
673
|
-
numInstances: 0,
|
|
674
|
-
instanceDatas: this.allocInstanceBuffer(),
|
|
675
|
-
mipLevels: this.allocMipLevelBuffer(),
|
|
676
|
-
maxMiplevel: 0
|
|
677
|
-
};
|
|
678
|
-
const fillerPrimitives = {
|
|
679
|
-
primitive: this._wireframe ? this._fillerMeshLines : this._fillerMesh,
|
|
680
|
-
numInstances: 0,
|
|
681
|
-
instanceDatas: this.allocInstanceBuffer(),
|
|
682
|
-
mipLevels: this.allocMipLevelBuffer(),
|
|
683
|
-
maxMiplevel: 0
|
|
684
|
-
};
|
|
685
|
-
const trimPrimitives = {
|
|
686
|
-
primitive: this._wireframe ? this._trimMeshLines : this._trimMesh,
|
|
687
|
-
numInstances: 0,
|
|
688
|
-
instanceDatas: this.allocInstanceBuffer(),
|
|
689
|
-
mipLevels: this.allocMipLevelBuffer(),
|
|
690
|
-
maxMiplevel: 0
|
|
691
|
-
};
|
|
692
|
-
const seamPrimitives = {
|
|
693
|
-
primitive: this._wireframe ? this._seamMeshLines : this._seamMesh,
|
|
694
|
-
numInstances: 0,
|
|
695
|
-
instanceDatas: this.allocInstanceBuffer(),
|
|
696
|
-
mipLevels: this.allocMipLevelBuffer(),
|
|
697
|
-
maxMiplevel: 0
|
|
698
|
-
};
|
|
699
|
-
for(let l = 0; l < mipLevels; l++){
|
|
700
|
-
const scale = 1 << l;
|
|
701
|
-
snappedPos.setXY(Math.floor(posX / scale) * scale, Math.floor(posY / scale) * scale);
|
|
702
|
-
// draw tiles
|
|
703
|
-
tileSize.setXY(this._tileResolution << l, this._tileResolution << l);
|
|
704
|
-
base.setXY(snappedPos.x - (this._tileResolution << l + 1), snappedPos.y - (this._tileResolution << l + 1));
|
|
705
|
-
for(let x = 0; x < 4; x++){
|
|
706
|
-
for(let y = 0; y < 4; y++){
|
|
707
|
-
if (l !== 0 && (x === 1 || x === 2) && (y === 1 || y === 2)) {
|
|
708
|
-
continue;
|
|
709
|
-
}
|
|
710
|
-
const fillX = x >= 2 ? scale : 0;
|
|
711
|
-
const fillY = y >= 2 ? scale : 0;
|
|
712
|
-
offset.setXY(base.x + x * tileSize.x + fillX, base.y + y * tileSize.y + fillY);
|
|
713
|
-
if (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)) {
|
|
714
|
-
if (this.visible(context, this._tileMeshBBox, context.camera, null, offset, scale, context.gridScale, l)) {
|
|
715
|
-
this.addInstance(tilePrimitives, rotationValues[0], offset.x, offset.y, scale, l);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
// draw filler
|
|
721
|
-
if (this.visible(context, this._fillerMeshAABB, context.camera, null, snappedPos, scale, context.gridScale, l)) {
|
|
722
|
-
this.addInstance(fillerPrimitives, rotationValues[0], snappedPos.x, snappedPos.y, scale, l);
|
|
723
|
-
}
|
|
724
|
-
if (l !== mipLevels - 1) {
|
|
725
|
-
const nextScale = scale * 2;
|
|
726
|
-
const nextSnappedPos = new Vector2(Math.floor(posX / nextScale) * nextScale, Math.floor(posY / nextScale) * nextScale);
|
|
727
|
-
// draw trim
|
|
728
|
-
const tileCentre = new Vector2(snappedPos.x + scale * 0.5, snappedPos.y + scale * 0.5);
|
|
729
|
-
const d = new Vector2(posX - nextSnappedPos.x, posY - nextSnappedPos.y);
|
|
730
|
-
let r = 0;
|
|
731
|
-
r |= d.x >= scale ? 0 : 2;
|
|
732
|
-
r |= d.y >= scale ? 0 : 1;
|
|
733
|
-
if (this.visible(context, this._trimMeshAABB, context.camera, rotationValues[r], tileCentre, scale, context.gridScale, l)) {
|
|
734
|
-
this.addInstance(trimPrimitives, rotationValues[r], tileCentre.x, tileCentre.y, scale, l);
|
|
735
|
-
}
|
|
736
|
-
// draw seam
|
|
737
|
-
const nextBase = new Vector2(nextSnappedPos.x - (this._tileResolution << l + 1), nextSnappedPos.y - (this._tileResolution << l + 1));
|
|
738
|
-
if (this.visible(context, this._seamMeshAABB, context.camera, null, nextBase, scale, context.gridScale, l)) {
|
|
739
|
-
this.addInstance(seamPrimitives, rotationValues[0], nextBase.x, nextBase.y, scale, l);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
if (tilePrimitives.numInstances > 0) {
|
|
744
|
-
renderData.push(tilePrimitives);
|
|
745
|
-
}
|
|
746
|
-
if (fillerPrimitives.numInstances > 0) {
|
|
747
|
-
renderData.push(fillerPrimitives);
|
|
748
|
-
}
|
|
749
|
-
if (trimPrimitives.numInstances > 0) {
|
|
750
|
-
renderData.push(trimPrimitives);
|
|
751
|
-
}
|
|
752
|
-
if (seamPrimitives.numInstances > 0) {
|
|
753
|
-
renderData.push(seamPrimitives);
|
|
754
|
-
}
|
|
755
|
-
for (const info of renderData){
|
|
756
|
-
info.primitive.getVertexBuffer('texCoord0').bufferSubData(0, info.instanceDatas, 0, info.numInstances * 4);
|
|
757
|
-
}
|
|
758
|
-
return renderData;
|
|
759
|
-
}
|
|
760
|
-
draw(context) {
|
|
761
|
-
let drawn = 0;
|
|
762
|
-
const mipLevels = this.calcMipLevels(context.camera, context.minMaxWorldPos, context.gridScale);
|
|
763
|
-
context.camera.getWorldPosition(tmpV3);
|
|
764
|
-
const snappedPos = new Vector2();
|
|
765
|
-
const tileSize = new Vector2();
|
|
766
|
-
const base = new Vector2();
|
|
767
|
-
const offset = new Vector2();
|
|
768
|
-
const posX = tmpV3.x / context.gridScale;
|
|
769
|
-
const posY = tmpV3.z / context.gridScale;
|
|
770
|
-
// draw cross
|
|
771
|
-
snappedPos.setXY(Math.floor(posX), Math.floor(posY));
|
|
772
|
-
if (this.visible(context, this._crossMeshAABB, context.camera, null, snappedPos, 1, context.gridScale, 0)) {
|
|
773
|
-
context.drawPrimitive(this._wireframe ? this._crossMeshLines : this._crossMesh, rotationValues[0], snappedPos, 1, context.gridScale, 0);
|
|
774
|
-
drawn++;
|
|
775
|
-
}
|
|
776
|
-
for(let l = 0; l < mipLevels; l++){
|
|
777
|
-
const scale = 1 << l;
|
|
778
|
-
snappedPos.setXY(Math.floor(posX / scale) * scale, Math.floor(posY / scale) * scale);
|
|
779
|
-
// draw tiles
|
|
780
|
-
tileSize.setXY(this._tileResolution << l, this._tileResolution << l);
|
|
781
|
-
base.setXY(snappedPos.x - (this._tileResolution << l + 1), snappedPos.y - (this._tileResolution << l + 1));
|
|
782
|
-
for(let x = 0; x < 4; x++){
|
|
783
|
-
for(let y = 0; y < 4; y++){
|
|
784
|
-
if (l !== 0 && (x === 1 || x === 2) && (y === 1 || y === 2)) {
|
|
785
|
-
continue;
|
|
786
|
-
}
|
|
787
|
-
const fillX = x >= 2 ? scale : 0;
|
|
788
|
-
const fillY = y >= 2 ? scale : 0;
|
|
789
|
-
offset.setXY(base.x + x * tileSize.x + fillX, base.y + y * tileSize.y + fillY);
|
|
790
|
-
if (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)) {
|
|
791
|
-
if (this.visible(context, this._tileMeshBBox, context.camera, null, offset, scale, context.gridScale, l)) {
|
|
792
|
-
context.drawPrimitive(this._wireframe ? this._tileMeshLines : this._tileMesh, rotationValues[0], offset, scale, context.gridScale, l);
|
|
793
|
-
drawn++;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
// draw filler
|
|
799
|
-
if (this.visible(context, this._fillerMeshAABB, context.camera, null, snappedPos, scale, context.gridScale, l)) {
|
|
800
|
-
context.drawPrimitive(this._wireframe ? this._fillerMeshLines : this._fillerMesh, rotationValues[0], snappedPos, scale, context.gridScale, l);
|
|
801
|
-
drawn++;
|
|
802
|
-
}
|
|
803
|
-
if (l !== mipLevels - 1) {
|
|
804
|
-
const nextScale = scale * 2;
|
|
805
|
-
const nextSnappedPos = new Vector2(Math.floor(posX / nextScale) * nextScale, Math.floor(posY / nextScale) * nextScale);
|
|
806
|
-
// draw trim
|
|
807
|
-
const tileCentre = new Vector2(snappedPos.x + scale * 0.5, snappedPos.y + scale * 0.5);
|
|
808
|
-
const d = new Vector2(posX - nextSnappedPos.x, posY - nextSnappedPos.y);
|
|
809
|
-
let r = 0;
|
|
810
|
-
r |= d.x >= scale ? 0 : 2;
|
|
811
|
-
r |= d.y >= scale ? 0 : 1;
|
|
812
|
-
if (this.visible(context, this._trimMeshAABB, context.camera, rotationValues[r], tileCentre, scale, context.gridScale, l)) {
|
|
813
|
-
context.drawPrimitive(this._wireframe ? this._trimMeshLines : this._trimMesh, rotationValues[r], tileCentre, scale, context.gridScale, l);
|
|
814
|
-
drawn++;
|
|
815
|
-
}
|
|
816
|
-
// draw seam
|
|
817
|
-
const nextBase = new Vector2(nextSnappedPos.x - (this._tileResolution << l + 1), nextSnappedPos.y - (this._tileResolution << l + 1));
|
|
818
|
-
if (this.visible(context, this._seamMeshAABB, context.camera, null, nextBase, scale, context.gridScale, l)) {
|
|
819
|
-
context.drawPrimitive(this._wireframe ? this._seamMeshLines : this._seamMesh, rotationValues[0], nextBase, scale, context.gridScale, l);
|
|
820
|
-
drawn++;
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
return drawn;
|
|
825
|
-
}
|
|
826
|
-
dispose() {
|
|
827
|
-
this._crossMesh.dispose();
|
|
828
|
-
this._crossMesh = null;
|
|
829
|
-
this._crossMeshLines.dispose();
|
|
830
|
-
this._crossMeshLines = null;
|
|
831
|
-
this._fillerMesh.dispose();
|
|
832
|
-
this._fillerMesh = null;
|
|
833
|
-
this._fillerMeshLines.dispose();
|
|
834
|
-
this._fillerMeshLines = null;
|
|
835
|
-
this._seamMesh.dispose();
|
|
836
|
-
this._seamMesh = null;
|
|
837
|
-
this._seamMeshLines.dispose();
|
|
838
|
-
this._seamMeshLines = null;
|
|
839
|
-
this._trimMesh.dispose();
|
|
840
|
-
this._trimMesh = null;
|
|
841
|
-
this._trimMeshLines.dispose();
|
|
842
|
-
this._trimMeshLines = null;
|
|
843
|
-
this._tileMesh.dispose();
|
|
844
|
-
this._tileMesh = null;
|
|
845
|
-
this._tileMeshLines.dispose();
|
|
846
|
-
this._tileMeshLines = null;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
export { Clipmap };
|
|
851
|
-
//# sourceMappingURL=clipmap.js.map
|