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