@zephyr3d/scene 0.8.0 → 0.8.2
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/animationset.js +220 -1
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +3 -4
- package/dist/animation/ik/ccd_solver.js.map +1 -1
- package/dist/animation/ik/fabrik_solver.js +3 -4
- package/dist/animation/ik/fabrik_solver.js.map +1 -1
- package/dist/animation/ik/ik_pole_constraint.js +7 -2
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/ik/ik_utils.js +0 -79
- package/dist/animation/ik/ik_utils.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +3 -4
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/skeleton.js +157 -125
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/spring_bone.js +240 -0
- package/dist/animation/spring/spring_bone.js.map +1 -0
- package/dist/animation/spring/spring_bone_collider.js +198 -0
- package/dist/animation/spring/spring_bone_collider.js.map +1 -0
- package/dist/animation/spring/spring_bone_constraint.js +170 -0
- package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
- package/dist/animation/spring/spring_bone_system.js +328 -0
- package/dist/animation/spring/spring_bone_system.js.map +1 -0
- package/dist/asset/model.js +2 -2
- package/dist/index.d.ts +17 -0
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/render/gpu_picking.js +100 -0
- package/dist/render/gpu_picking.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +41 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
- package/dist/render/rendergraph/executor.js +146 -0
- package/dist/render/rendergraph/executor.js.map +1 -0
- package/dist/render/rendergraph/forward_plus_builder.js +414 -0
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +306 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -0
- package/dist/render/rendergraph/types.js +57 -0
- package/dist/render/rendergraph/types.js.map +1 -0
- package/dist/render/sky_motion_vector.js +85 -0
- package/dist/render/sky_motion_vector.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +3 -3
- package/dist/utility/serialization/scene/node.js +1 -1
- 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/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/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
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { Vector3, AABB } from '@zephyr3d/base';
|
|
2
|
-
|
|
3
|
-
const tmpTriangle = [
|
|
4
|
-
0,
|
|
5
|
-
0,
|
|
6
|
-
0
|
|
7
|
-
];
|
|
8
|
-
/**
|
|
9
|
-
* Axis-Aligned Bounding Box Tree
|
|
10
|
-
* @public
|
|
11
|
-
*/ class AABBTree {
|
|
12
|
-
/** @internal */ _primitivesInfo;
|
|
13
|
-
/** @internal */ _nodes;
|
|
14
|
-
constructor(other){
|
|
15
|
-
this._primitivesInfo = null;
|
|
16
|
-
this._nodes = null;
|
|
17
|
-
if (other) {
|
|
18
|
-
this._primitivesInfo = other._primitivesInfo ? {
|
|
19
|
-
vertices: other._primitivesInfo.vertices?.map((value)=>new Vector3(value)),
|
|
20
|
-
indices: other._primitivesInfo.indices?.map((value)=>value),
|
|
21
|
-
primitiveType: other._primitivesInfo.primitiveType
|
|
22
|
-
} : null;
|
|
23
|
-
this._nodes = other._nodes ? other._nodes.map((value)=>{
|
|
24
|
-
return {
|
|
25
|
-
box: new AABB(value.box),
|
|
26
|
-
triangles: value.triangles?.map((val)=>val),
|
|
27
|
-
axis: value.axis,
|
|
28
|
-
left: value.left,
|
|
29
|
-
right: value.right
|
|
30
|
-
};
|
|
31
|
-
}) : null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Build the AABB tree from a polygon soup
|
|
36
|
-
* @param vertices - Vertices of the polygon soup
|
|
37
|
-
* @param indices - indices of the polygon soup
|
|
38
|
-
* @param primitiveType - Prmitive type of the polygon soup
|
|
39
|
-
*/ buildFromPrimitives(vertices, indices, primitiveType) {
|
|
40
|
-
this._primitivesInfo = {
|
|
41
|
-
vertices: [],
|
|
42
|
-
indices: null,
|
|
43
|
-
primitiveType: primitiveType
|
|
44
|
-
};
|
|
45
|
-
for(let i = 0; i < vertices.length; i += 3){
|
|
46
|
-
this._primitivesInfo.vertices.push(new Vector3(vertices[i], vertices[i + 1], vertices[i + 2]));
|
|
47
|
-
}
|
|
48
|
-
if (indices) {
|
|
49
|
-
this._primitivesInfo.indices = [];
|
|
50
|
-
for (const index of indices){
|
|
51
|
-
this._primitivesInfo.indices.push(index);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
this._buildSubNodes();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Checks for intersection between a ray and the AABB tree without calculating the intersection point
|
|
58
|
-
* @param ray - The ray being traced
|
|
59
|
-
* @returns true if the ray hits the AABB tree, false otherwise
|
|
60
|
-
*/ rayIntersectionTest(ray) {
|
|
61
|
-
return this._nodes.length > 0 ? this._rayIntersectionTest(0, ray) : false;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Checks for intersection between a ray and the AABB tree
|
|
65
|
-
* @param ray - The ray being traced
|
|
66
|
-
* @returns The distance between the ray origin and the hit point if the ray hits the AABB tree, null otherwise
|
|
67
|
-
*/ rayIntersectionDistance(ray) {
|
|
68
|
-
return this._nodes.length > 0 ? this._rayIntersectionDistance(0, ray) : null;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Gets the top level bounding box of the tree
|
|
72
|
-
* @returns The top level bounding box
|
|
73
|
-
*/ getTopLevelAABB() {
|
|
74
|
-
return this._nodes.length > 0 ? this._nodes[0].box : null;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Transform the tree by a matrix
|
|
78
|
-
* @param matrix - The transform matrix
|
|
79
|
-
*/ transform(matrix) {
|
|
80
|
-
if (matrix && this._primitivesInfo && this._primitivesInfo.vertices) {
|
|
81
|
-
for (const vert of this._primitivesInfo.vertices){
|
|
82
|
-
matrix.transformPointAffine(vert, vert);
|
|
83
|
-
}
|
|
84
|
-
this._buildSubNodes();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/** @internal */ verify() {
|
|
88
|
-
const numTris = this._verifyNode(0);
|
|
89
|
-
const n = this._getNumTriangles();
|
|
90
|
-
if (numTris !== n) {
|
|
91
|
-
throw new Error(`AABB tree verification failed: triangle count mismatch, got ${numTris}, expect ${n}`);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/** @internal */ _verifyNode(nodeIndex) {
|
|
95
|
-
const node = this._nodes[nodeIndex];
|
|
96
|
-
if (!node) {
|
|
97
|
-
throw new Error(`AABB tree verification failed: invalid node index: ${nodeIndex}`);
|
|
98
|
-
}
|
|
99
|
-
let numTris = 0;
|
|
100
|
-
const extents = node.box.extents[node.axis];
|
|
101
|
-
const tmpTri = [
|
|
102
|
-
0,
|
|
103
|
-
0,
|
|
104
|
-
0
|
|
105
|
-
];
|
|
106
|
-
for (const tri of node.triangles){
|
|
107
|
-
this._getTriangle(tri, tmpTri);
|
|
108
|
-
let max = Number.MIN_VALUE;
|
|
109
|
-
let min = Number.MAX_VALUE;
|
|
110
|
-
for (const v of tmpTri){
|
|
111
|
-
const p = this._primitivesInfo.vertices[v];
|
|
112
|
-
if (!node.box.containsPoint(p)) {
|
|
113
|
-
throw new Error(`AABB tree verification failed: triangle not inside AABB`);
|
|
114
|
-
}
|
|
115
|
-
const t = p[node.axis];
|
|
116
|
-
if (t < min) {
|
|
117
|
-
min = t;
|
|
118
|
-
}
|
|
119
|
-
if (t > max) {
|
|
120
|
-
max = t;
|
|
121
|
-
}
|
|
122
|
-
if (max - min <= extents) {
|
|
123
|
-
throw new Error(`AABB tree verification failed: extents test failed`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
numTris += node.triangles.length;
|
|
128
|
-
if (node.left >= 0) {
|
|
129
|
-
numTris += this._verifyNode(node.left);
|
|
130
|
-
}
|
|
131
|
-
if (node.right >= 0) {
|
|
132
|
-
numTris += this._verifyNode(node.right);
|
|
133
|
-
}
|
|
134
|
-
return numTris;
|
|
135
|
-
}
|
|
136
|
-
/** @internal */ _buildNode(nodeIndex, triangles, triangleMin, triangleMax) {
|
|
137
|
-
const node = this._nodes[nodeIndex];
|
|
138
|
-
if (triangles.length === 1) {
|
|
139
|
-
node.triangles.push(triangles[0]);
|
|
140
|
-
} else {
|
|
141
|
-
const splitAxis = node.axis = this._selectBestSplitAxis(node.box.extents, triangles, triangleMin, triangleMax);
|
|
142
|
-
const sizeMax = node.box.extents[splitAxis];
|
|
143
|
-
const sizeCenter = node.box.center[splitAxis];
|
|
144
|
-
const sizeLeft = sizeCenter - node.box.extents[splitAxis] * 0.5;
|
|
145
|
-
const leftTriangles = [];
|
|
146
|
-
const rightTriangles = [];
|
|
147
|
-
const leftbox = new AABB();
|
|
148
|
-
leftbox.beginExtend();
|
|
149
|
-
const rightbox = new AABB();
|
|
150
|
-
rightbox.beginExtend();
|
|
151
|
-
for (const tri of triangles){
|
|
152
|
-
const min = triangleMin[tri];
|
|
153
|
-
const max = triangleMax[tri];
|
|
154
|
-
const size = max[splitAxis] - min[splitAxis];
|
|
155
|
-
if (size >= sizeMax) {
|
|
156
|
-
node.triangles.push(tri);
|
|
157
|
-
} else if (max[splitAxis] <= sizeCenter || min[splitAxis] <= sizeLeft) {
|
|
158
|
-
leftTriangles.push(tri);
|
|
159
|
-
leftbox.extend3(min[0], min[1], min[2]);
|
|
160
|
-
leftbox.extend3(max[0], max[1], max[2]);
|
|
161
|
-
} else {
|
|
162
|
-
rightTriangles.push(tri);
|
|
163
|
-
rightbox.extend3(min[0], min[1], min[2]);
|
|
164
|
-
rightbox.extend3(max[0], max[1], max[2]);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
if (leftTriangles.length) {
|
|
168
|
-
this._nodes.push({
|
|
169
|
-
box: leftbox,
|
|
170
|
-
triangles: [],
|
|
171
|
-
axis: -1,
|
|
172
|
-
left: -1,
|
|
173
|
-
right: -1
|
|
174
|
-
});
|
|
175
|
-
node.left = this._nodes.length - 1;
|
|
176
|
-
this._buildNode(this._nodes.length - 1, leftTriangles, triangleMin, triangleMax);
|
|
177
|
-
}
|
|
178
|
-
if (rightTriangles.length) {
|
|
179
|
-
this._nodes.push({
|
|
180
|
-
box: rightbox,
|
|
181
|
-
triangles: [],
|
|
182
|
-
axis: -1,
|
|
183
|
-
left: -1,
|
|
184
|
-
right: -1
|
|
185
|
-
});
|
|
186
|
-
node.right = this._nodes.length - 1;
|
|
187
|
-
this._buildNode(this._nodes.length - 1, rightTriangles, triangleMin, triangleMax);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
/** @internal */ _selectBestSplitAxis(extents, triangles, triangleMin, triangleMax) {
|
|
192
|
-
const dx = extents.x, dy = extents.y, dz = extents.z;
|
|
193
|
-
let nx = 0, ny = 0, nz = 0;
|
|
194
|
-
for (const tri of triangles){
|
|
195
|
-
const max = triangleMax[tri];
|
|
196
|
-
const min = triangleMin[tri];
|
|
197
|
-
if (max[0] - min[0] >= dx) {
|
|
198
|
-
nx++;
|
|
199
|
-
}
|
|
200
|
-
if (max[1] - min[1] >= dy) {
|
|
201
|
-
ny++;
|
|
202
|
-
}
|
|
203
|
-
if (max[2] - min[2] >= dz) {
|
|
204
|
-
nz++;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (nx < ny) {
|
|
208
|
-
if (nx < nz) {
|
|
209
|
-
return 0;
|
|
210
|
-
} else {
|
|
211
|
-
return nx === nz ? dx > dz ? 0 : 2 : 2;
|
|
212
|
-
}
|
|
213
|
-
} else if (nx == ny) {
|
|
214
|
-
if (nz < nx) {
|
|
215
|
-
return 2;
|
|
216
|
-
} else if (nz > nx) {
|
|
217
|
-
return dx > dy ? 0 : 1;
|
|
218
|
-
} else {
|
|
219
|
-
if (dx < dy) {
|
|
220
|
-
return dy > dz ? 1 : 2;
|
|
221
|
-
} else {
|
|
222
|
-
return dx > dz ? 0 : 2;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
} else {
|
|
226
|
-
if (ny < nz) {
|
|
227
|
-
return 1;
|
|
228
|
-
} else {
|
|
229
|
-
return ny === nz ? dy > dz ? 1 : 2 : 2;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/** @internal */ _getNumTriangles() {
|
|
234
|
-
const numIndices = this._primitivesInfo.indices ? this._primitivesInfo.indices.length : this._primitivesInfo.vertices.length;
|
|
235
|
-
switch(this._primitivesInfo.primitiveType){
|
|
236
|
-
case 'triangle-list':
|
|
237
|
-
return Math.floor(numIndices / 3);
|
|
238
|
-
case 'triangle-strip':
|
|
239
|
-
return numIndices - 2;
|
|
240
|
-
case 'triangle-fan':
|
|
241
|
-
return numIndices - 2;
|
|
242
|
-
default:
|
|
243
|
-
return 0;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/** @internal */ _rayIntersectionDistance(nodeIndex, ray) {
|
|
247
|
-
const node = this._nodes[nodeIndex];
|
|
248
|
-
if (!ray.bboxIntersectionTest(node.box)) {
|
|
249
|
-
return null;
|
|
250
|
-
}
|
|
251
|
-
let minDist = Number.MAX_VALUE;
|
|
252
|
-
for (const tri of node.triangles){
|
|
253
|
-
this._getTriangle(tri, tmpTriangle);
|
|
254
|
-
const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];
|
|
255
|
-
const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];
|
|
256
|
-
const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];
|
|
257
|
-
const dist = ray.intersectionTestTriangle(v0, v1, v2, false);
|
|
258
|
-
if (dist !== null && dist >= 0 && dist < minDist) {
|
|
259
|
-
minDist = dist;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
let a, b;
|
|
263
|
-
if (node.axis >= 0) {
|
|
264
|
-
if (ray.direction[node.axis] < 0) {
|
|
265
|
-
a = node.right;
|
|
266
|
-
b = node.left;
|
|
267
|
-
} else {
|
|
268
|
-
a = node.left;
|
|
269
|
-
b = node.right;
|
|
270
|
-
}
|
|
271
|
-
if (a >= 0) {
|
|
272
|
-
const dist = this._rayIntersectionDistance(a, ray);
|
|
273
|
-
if (dist !== null && dist >= 0 && dist < minDist) {
|
|
274
|
-
minDist = dist;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (b >= 0) {
|
|
278
|
-
const dist = this._rayIntersectionDistance(b, ray);
|
|
279
|
-
if (dist !== null && dist >= 0 && dist < minDist) {
|
|
280
|
-
minDist = dist;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
return minDist === Number.MAX_VALUE ? null : minDist;
|
|
285
|
-
}
|
|
286
|
-
/** @internal */ _rayIntersectionTest(nodeIndex, ray) {
|
|
287
|
-
const node = this._nodes[nodeIndex];
|
|
288
|
-
if (!ray.bboxIntersectionTest(node.box)) {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
for (const tri of node.triangles){
|
|
292
|
-
this._getTriangle(tri, tmpTriangle);
|
|
293
|
-
const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];
|
|
294
|
-
const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];
|
|
295
|
-
const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];
|
|
296
|
-
const dist = ray.intersectionTestTriangle(v0, v1, v2, false);
|
|
297
|
-
if (dist !== null && dist > 0) {
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
let a, b;
|
|
302
|
-
if (node.axis >= 0) {
|
|
303
|
-
if (ray.direction[node.axis] < 0) {
|
|
304
|
-
a = node.right;
|
|
305
|
-
b = node.left;
|
|
306
|
-
} else {
|
|
307
|
-
a = node.left;
|
|
308
|
-
b = node.right;
|
|
309
|
-
}
|
|
310
|
-
if (a >= 0 && this._rayIntersectionTest(a, ray)) {
|
|
311
|
-
return true;
|
|
312
|
-
}
|
|
313
|
-
if (b >= 0 && this._rayIntersectionTest(b, ray)) {
|
|
314
|
-
return true;
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
/** @internal */ _getTriangle(n, out) {
|
|
320
|
-
const indices = this._primitivesInfo.indices;
|
|
321
|
-
let v0, v1, v2;
|
|
322
|
-
out = out || [
|
|
323
|
-
0,
|
|
324
|
-
0,
|
|
325
|
-
0
|
|
326
|
-
];
|
|
327
|
-
switch(this._primitivesInfo.primitiveType){
|
|
328
|
-
case 'triangle-list':
|
|
329
|
-
v0 = n * 3;
|
|
330
|
-
v1 = v0 + 1;
|
|
331
|
-
v2 = v0 + 2;
|
|
332
|
-
break;
|
|
333
|
-
case 'triangle-strip':
|
|
334
|
-
{
|
|
335
|
-
const r = n % 2;
|
|
336
|
-
v0 = n + r;
|
|
337
|
-
v1 = n - r + 1;
|
|
338
|
-
v2 = n + 2;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
case 'triangle-fan':
|
|
342
|
-
v0 = 0;
|
|
343
|
-
v1 = n + 1;
|
|
344
|
-
v2 = n + 2;
|
|
345
|
-
break;
|
|
346
|
-
default:
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
out[0] = indices ? indices[v0] : v0;
|
|
350
|
-
out[1] = indices ? indices[v1] : v1;
|
|
351
|
-
out[2] = indices ? indices[v2] : v2;
|
|
352
|
-
return out;
|
|
353
|
-
}
|
|
354
|
-
/** @internal */ _buildSubNodes() {
|
|
355
|
-
const triangleMin = [];
|
|
356
|
-
const triangleMax = [];
|
|
357
|
-
const triangles = [];
|
|
358
|
-
const numTriangles = this._getNumTriangles();
|
|
359
|
-
const rootNode = {
|
|
360
|
-
box: new AABB(),
|
|
361
|
-
triangles: [],
|
|
362
|
-
axis: -1,
|
|
363
|
-
left: -1,
|
|
364
|
-
right: -1
|
|
365
|
-
};
|
|
366
|
-
rootNode.box.beginExtend();
|
|
367
|
-
for(let i = 0; i < numTriangles; i++){
|
|
368
|
-
triangles.push(i);
|
|
369
|
-
this._getTriangle(i, tmpTriangle);
|
|
370
|
-
const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];
|
|
371
|
-
const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];
|
|
372
|
-
const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];
|
|
373
|
-
const min = [
|
|
374
|
-
Math.min(Math.min(v0.x, v1.x), v2.x),
|
|
375
|
-
Math.min(Math.min(v0.y, v1.y), v2.y),
|
|
376
|
-
Math.min(Math.min(v0.z, v1.z), v2.z)
|
|
377
|
-
];
|
|
378
|
-
rootNode.box.extend3(min[0], min[1], min[2]);
|
|
379
|
-
triangleMin.push(min);
|
|
380
|
-
const max = [
|
|
381
|
-
Math.max(Math.max(v0.x, v1.x), v2.x),
|
|
382
|
-
Math.max(Math.max(v0.y, v1.y), v2.y),
|
|
383
|
-
Math.max(Math.max(v0.z, v1.z), v2.z)
|
|
384
|
-
];
|
|
385
|
-
rootNode.box.extend3(max[0], max[1], max[2]);
|
|
386
|
-
triangleMax.push(max);
|
|
387
|
-
}
|
|
388
|
-
if (rootNode.box.isValid()) {
|
|
389
|
-
this._nodes = [
|
|
390
|
-
rootNode
|
|
391
|
-
];
|
|
392
|
-
this._buildNode(0, triangles, triangleMin, triangleMax);
|
|
393
|
-
} else {
|
|
394
|
-
this._nodes = [];
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
export { AABBTree };
|
|
400
|
-
//# sourceMappingURL=aabbtree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"aabbtree.js","sources":["../../../src/utility/aabbtree.ts"],"sourcesContent":["import type { TypedArray, Matrix4x4, Ray } from '@zephyr3d/base';\r\nimport { AABB, Vector3 } from '@zephyr3d/base';\r\nimport type { PrimitiveType } from '@zephyr3d/device';\r\n\r\ninterface PrimitivesInfo {\r\n vertices: Vector3[];\r\n indices: number[];\r\n primitiveType: PrimitiveType;\r\n}\r\n\r\ninterface AABBTreeNode {\r\n box: AABB;\r\n triangles: number[];\r\n axis: number;\r\n left: number;\r\n right: number;\r\n}\r\n\r\nconst tmpTriangle: [number, number, number] = [0, 0, 0];\r\n\r\n/**\r\n * Axis-Aligned Bounding Box Tree\r\n * @public\r\n */\r\nexport class AABBTree {\r\n /** @internal */\r\n private _primitivesInfo: PrimitivesInfo;\r\n /** @internal */\r\n private _nodes: AABBTreeNode[];\r\n /** Creates an empty AABB tree */\r\n constructor();\r\n /** Creates an AABB tree by copying from another AABB tree */\r\n constructor(rhs: AABBTree);\r\n constructor(other?: AABBTree) {\r\n this._primitivesInfo = null;\r\n this._nodes = null;\r\n if (other) {\r\n this._primitivesInfo = other._primitivesInfo\r\n ? {\r\n vertices: other._primitivesInfo.vertices?.map((value) => new Vector3(value)),\r\n indices: other._primitivesInfo.indices?.map((value) => value),\r\n primitiveType: other._primitivesInfo.primitiveType\r\n }\r\n : null;\r\n this._nodes = other._nodes\r\n ? other._nodes.map((value) => {\r\n return {\r\n box: new AABB(value.box),\r\n triangles: value.triangles?.map((val) => val),\r\n axis: value.axis,\r\n left: value.left,\r\n right: value.right\r\n };\r\n })\r\n : null;\r\n }\r\n }\r\n /**\r\n * Build the AABB tree from a polygon soup\r\n * @param vertices - Vertices of the polygon soup\r\n * @param indices - indices of the polygon soup\r\n * @param primitiveType - Prmitive type of the polygon soup\r\n */\r\n buildFromPrimitives(\r\n vertices: number[] | TypedArray,\r\n indices: number[] | TypedArray,\r\n primitiveType: PrimitiveType\r\n ): void {\r\n this._primitivesInfo = {\r\n vertices: [],\r\n indices: null,\r\n primitiveType: primitiveType\r\n };\r\n for (let i = 0; i < vertices.length; i += 3) {\r\n this._primitivesInfo.vertices.push(\r\n new Vector3(vertices[i] as number, vertices[i + 1] as number, vertices[i + 2] as number)\r\n );\r\n }\r\n if (indices) {\r\n this._primitivesInfo.indices = [];\r\n for (const index of indices) {\r\n this._primitivesInfo.indices.push(index as number);\r\n }\r\n }\r\n this._buildSubNodes();\r\n }\r\n /**\r\n * Checks for intersection between a ray and the AABB tree without calculating the intersection point\r\n * @param ray - The ray being traced\r\n * @returns true if the ray hits the AABB tree, false otherwise\r\n */\r\n rayIntersectionTest(ray: Ray): boolean {\r\n return this._nodes.length > 0 ? this._rayIntersectionTest(0, ray) : false;\r\n }\r\n /**\r\n * Checks for intersection between a ray and the AABB tree\r\n * @param ray - The ray being traced\r\n * @returns The distance between the ray origin and the hit point if the ray hits the AABB tree, null otherwise\r\n */\r\n rayIntersectionDistance(ray: Ray): number {\r\n return this._nodes.length > 0 ? this._rayIntersectionDistance(0, ray) : null;\r\n }\r\n /**\r\n * Gets the top level bounding box of the tree\r\n * @returns The top level bounding box\r\n */\r\n getTopLevelAABB(): AABB {\r\n return this._nodes.length > 0 ? this._nodes[0].box : null;\r\n }\r\n /**\r\n * Transform the tree by a matrix\r\n * @param matrix - The transform matrix\r\n */\r\n transform(matrix: Matrix4x4): void {\r\n if (matrix && this._primitivesInfo && this._primitivesInfo.vertices) {\r\n for (const vert of this._primitivesInfo.vertices) {\r\n matrix.transformPointAffine(vert, vert);\r\n }\r\n this._buildSubNodes();\r\n }\r\n }\r\n /** @internal */\r\n verify() {\r\n const numTris = this._verifyNode(0);\r\n const n = this._getNumTriangles();\r\n if (numTris !== n) {\r\n throw new Error(`AABB tree verification failed: triangle count mismatch, got ${numTris}, expect ${n}`);\r\n }\r\n }\r\n /** @internal */\r\n private _verifyNode(nodeIndex: number): number {\r\n const node = this._nodes[nodeIndex];\r\n if (!node) {\r\n throw new Error(`AABB tree verification failed: invalid node index: ${nodeIndex}`);\r\n }\r\n let numTris = 0;\r\n const extents = node.box.extents[node.axis];\r\n const tmpTri: [number, number, number] = [0, 0, 0];\r\n for (const tri of node.triangles) {\r\n this._getTriangle(tri, tmpTri);\r\n let max = Number.MIN_VALUE;\r\n let min = Number.MAX_VALUE;\r\n for (const v of tmpTri) {\r\n const p = this._primitivesInfo.vertices[v];\r\n if (!node.box.containsPoint(p)) {\r\n throw new Error(`AABB tree verification failed: triangle not inside AABB`);\r\n }\r\n const t = p[node.axis];\r\n if (t < min) {\r\n min = t;\r\n }\r\n if (t > max) {\r\n max = t;\r\n }\r\n if (max - min <= extents) {\r\n throw new Error(`AABB tree verification failed: extents test failed`);\r\n }\r\n }\r\n }\r\n numTris += node.triangles.length;\r\n if (node.left >= 0) {\r\n numTris += this._verifyNode(node.left);\r\n }\r\n if (node.right >= 0) {\r\n numTris += this._verifyNode(node.right);\r\n }\r\n return numTris;\r\n }\r\n /** @internal */\r\n private _buildNode(\r\n nodeIndex: number,\r\n triangles: number[],\r\n triangleMin: [number, number, number][],\r\n triangleMax: [number, number, number][]\r\n ) {\r\n const node = this._nodes[nodeIndex];\r\n if (triangles.length === 1) {\r\n node.triangles.push(triangles[0]);\r\n } else {\r\n const splitAxis = (node.axis = this._selectBestSplitAxis(\r\n node.box.extents,\r\n triangles,\r\n triangleMin,\r\n triangleMax\r\n ));\r\n const sizeMax = node.box.extents[splitAxis];\r\n const sizeCenter = node.box.center[splitAxis];\r\n const sizeLeft = sizeCenter - node.box.extents[splitAxis] * 0.5;\r\n const leftTriangles: number[] = [];\r\n const rightTriangles: number[] = [];\r\n const leftbox = new AABB();\r\n leftbox.beginExtend();\r\n const rightbox = new AABB();\r\n rightbox.beginExtend();\r\n for (const tri of triangles) {\r\n const min = triangleMin[tri];\r\n const max = triangleMax[tri];\r\n const size = max[splitAxis] - min[splitAxis];\r\n if (size >= sizeMax) {\r\n node.triangles.push(tri);\r\n } else if (max[splitAxis] <= sizeCenter || min[splitAxis] <= sizeLeft) {\r\n leftTriangles.push(tri);\r\n leftbox.extend3(min[0], min[1], min[2]);\r\n leftbox.extend3(max[0], max[1], max[2]);\r\n } else {\r\n rightTriangles.push(tri);\r\n rightbox.extend3(min[0], min[1], min[2]);\r\n rightbox.extend3(max[0], max[1], max[2]);\r\n }\r\n }\r\n if (leftTriangles.length) {\r\n this._nodes.push({\r\n box: leftbox,\r\n triangles: [],\r\n axis: -1,\r\n left: -1,\r\n right: -1\r\n });\r\n node.left = this._nodes.length - 1;\r\n this._buildNode(this._nodes.length - 1, leftTriangles, triangleMin, triangleMax);\r\n }\r\n if (rightTriangles.length) {\r\n this._nodes.push({\r\n box: rightbox,\r\n triangles: [],\r\n axis: -1,\r\n left: -1,\r\n right: -1\r\n });\r\n node.right = this._nodes.length - 1;\r\n this._buildNode(this._nodes.length - 1, rightTriangles, triangleMin, triangleMax);\r\n }\r\n }\r\n }\r\n /** @internal */\r\n private _selectBestSplitAxis(\r\n extents: Vector3,\r\n triangles: number[],\r\n triangleMin: [number, number, number][],\r\n triangleMax: [number, number, number][]\r\n ): number {\r\n const dx = extents.x,\r\n dy = extents.y,\r\n dz = extents.z;\r\n let nx = 0,\r\n ny = 0,\r\n nz = 0;\r\n for (const tri of triangles) {\r\n const max = triangleMax[tri];\r\n const min = triangleMin[tri];\r\n if (max[0] - min[0] >= dx) {\r\n nx++;\r\n }\r\n if (max[1] - min[1] >= dy) {\r\n ny++;\r\n }\r\n if (max[2] - min[2] >= dz) {\r\n nz++;\r\n }\r\n }\r\n if (nx < ny) {\r\n if (nx < nz) {\r\n return 0;\r\n } else {\r\n return nx === nz ? (dx > dz ? 0 : 2) : 2;\r\n }\r\n } else if (nx == ny) {\r\n if (nz < nx) {\r\n return 2;\r\n } else if (nz > nx) {\r\n return dx > dy ? 0 : 1;\r\n } else {\r\n if (dx < dy) {\r\n return dy > dz ? 1 : 2;\r\n } else {\r\n return dx > dz ? 0 : 2;\r\n }\r\n }\r\n } else {\r\n if (ny < nz) {\r\n return 1;\r\n } else {\r\n return ny === nz ? (dy > dz ? 1 : 2) : 2;\r\n }\r\n }\r\n }\r\n /** @internal */\r\n private _getNumTriangles() {\r\n const numIndices = this._primitivesInfo.indices\r\n ? this._primitivesInfo.indices.length\r\n : this._primitivesInfo.vertices.length;\r\n switch (this._primitivesInfo.primitiveType) {\r\n case 'triangle-list':\r\n return Math.floor(numIndices / 3);\r\n case 'triangle-strip':\r\n return numIndices - 2;\r\n case 'triangle-fan':\r\n return numIndices - 2;\r\n default:\r\n return 0;\r\n }\r\n }\r\n /** @internal */\r\n private _rayIntersectionDistance(nodeIndex: number, ray: Ray): number {\r\n const node = this._nodes[nodeIndex];\r\n if (!ray.bboxIntersectionTest(node.box)) {\r\n return null;\r\n }\r\n let minDist = Number.MAX_VALUE;\r\n for (const tri of node.triangles) {\r\n this._getTriangle(tri, tmpTriangle);\r\n const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];\r\n const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];\r\n const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];\r\n const dist = ray.intersectionTestTriangle(v0, v1, v2, false);\r\n if (dist !== null && dist >= 0 && dist < minDist) {\r\n minDist = dist;\r\n }\r\n }\r\n let a: number, b: number;\r\n if (node.axis >= 0) {\r\n if (ray.direction[node.axis] < 0) {\r\n a = node.right;\r\n b = node.left;\r\n } else {\r\n a = node.left;\r\n b = node.right;\r\n }\r\n if (a >= 0) {\r\n const dist = this._rayIntersectionDistance(a, ray);\r\n if (dist !== null && dist >= 0 && dist < minDist) {\r\n minDist = dist;\r\n }\r\n }\r\n if (b >= 0) {\r\n const dist = this._rayIntersectionDistance(b, ray);\r\n if (dist !== null && dist >= 0 && dist < minDist) {\r\n minDist = dist;\r\n }\r\n }\r\n }\r\n return minDist === Number.MAX_VALUE ? null : minDist;\r\n }\r\n /** @internal */\r\n private _rayIntersectionTest(nodeIndex: number, ray: Ray): boolean {\r\n const node = this._nodes[nodeIndex];\r\n if (!ray.bboxIntersectionTest(node.box)) {\r\n return false;\r\n }\r\n for (const tri of node.triangles) {\r\n this._getTriangle(tri, tmpTriangle);\r\n const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];\r\n const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];\r\n const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];\r\n const dist = ray.intersectionTestTriangle(v0, v1, v2, false);\r\n if (dist !== null && dist > 0) {\r\n return true;\r\n }\r\n }\r\n let a: number, b: number;\r\n if (node.axis >= 0) {\r\n if (ray.direction[node.axis] < 0) {\r\n a = node.right;\r\n b = node.left;\r\n } else {\r\n a = node.left;\r\n b = node.right;\r\n }\r\n if (a >= 0 && this._rayIntersectionTest(a, ray)) {\r\n return true;\r\n }\r\n if (b >= 0 && this._rayIntersectionTest(b, ray)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** @internal */\r\n private _getTriangle(n: number, out: [number, number, number]): [number, number, number] {\r\n const indices = this._primitivesInfo.indices;\r\n let v0: number, v1: number, v2: number;\r\n out = out || [0, 0, 0];\r\n switch (this._primitivesInfo.primitiveType) {\r\n case 'triangle-list':\r\n v0 = n * 3;\r\n v1 = v0 + 1;\r\n v2 = v0 + 2;\r\n break;\r\n case 'triangle-strip': {\r\n const r = n % 2;\r\n v0 = n + r;\r\n v1 = n - r + 1;\r\n v2 = n + 2;\r\n break;\r\n }\r\n case 'triangle-fan':\r\n v0 = 0;\r\n v1 = n + 1;\r\n v2 = n + 2;\r\n break;\r\n default:\r\n return null;\r\n }\r\n out[0] = indices ? indices[v0] : v0;\r\n out[1] = indices ? indices[v1] : v1;\r\n out[2] = indices ? indices[v2] : v2;\r\n return out;\r\n }\r\n /** @internal */\r\n _buildSubNodes() {\r\n const triangleMin: [number, number, number][] = [];\r\n const triangleMax: [number, number, number][] = [];\r\n const triangles: number[] = [];\r\n const numTriangles = this._getNumTriangles();\r\n const rootNode = {\r\n box: new AABB(),\r\n triangles: [],\r\n axis: -1,\r\n left: -1,\r\n right: -1\r\n };\r\n rootNode.box.beginExtend();\r\n for (let i = 0; i < numTriangles; i++) {\r\n triangles.push(i);\r\n this._getTriangle(i, tmpTriangle);\r\n const v0 = this._primitivesInfo.vertices[tmpTriangle[0]];\r\n const v1 = this._primitivesInfo.vertices[tmpTriangle[1]];\r\n const v2 = this._primitivesInfo.vertices[tmpTriangle[2]];\r\n const min: [number, number, number] = [\r\n Math.min(Math.min(v0.x, v1.x), v2.x),\r\n Math.min(Math.min(v0.y, v1.y), v2.y),\r\n Math.min(Math.min(v0.z, v1.z), v2.z)\r\n ];\r\n rootNode.box.extend3(min[0], min[1], min[2]);\r\n triangleMin.push(min);\r\n const max: [number, number, number] = [\r\n Math.max(Math.max(v0.x, v1.x), v2.x),\r\n Math.max(Math.max(v0.y, v1.y), v2.y),\r\n Math.max(Math.max(v0.z, v1.z), v2.z)\r\n ];\r\n rootNode.box.extend3(max[0], max[1], max[2]);\r\n triangleMax.push(max);\r\n }\r\n if (rootNode.box.isValid()) {\r\n this._nodes = [rootNode];\r\n this._buildNode(0, triangles, triangleMin, triangleMax);\r\n } else {\r\n this._nodes = [];\r\n }\r\n }\r\n}\r\n"],"names":["tmpTriangle","AABBTree","other","_primitivesInfo","_nodes","vertices","map","value","Vector3","indices","primitiveType","box","AABB","triangles","val","axis","left","right","buildFromPrimitives","i","length","push","index","_buildSubNodes","rayIntersectionTest","ray","_rayIntersectionTest","rayIntersectionDistance","_rayIntersectionDistance","getTopLevelAABB","transform","matrix","vert","transformPointAffine","verify","numTris","_verifyNode","n","_getNumTriangles","Error","nodeIndex","node","extents","tmpTri","tri","_getTriangle","max","Number","MIN_VALUE","min","MAX_VALUE","v","p","containsPoint","t","_buildNode","triangleMin","triangleMax","splitAxis","_selectBestSplitAxis","sizeMax","sizeCenter","center","sizeLeft","leftTriangles","rightTriangles","leftbox","beginExtend","rightbox","size","extend3","dx","x","dy","y","dz","z","nx","ny","nz","numIndices","Math","floor","bboxIntersectionTest","minDist","v0","v1","v2","dist","intersectionTestTriangle","a","b","direction","out","r","numTriangles","rootNode","isValid"],"mappings":";;AAkBA,MAAMA,WAAwC,GAAA;AAAC,IAAA,CAAA;AAAG,IAAA,CAAA;AAAG,IAAA;AAAE,CAAA;AAEvD;;;AAGC,IACM,MAAMC,QAAAA,CAAAA;qBAEX,eAAwC;qBAExC,MAA+B;AAK/B,IAAA,WAAA,CAAYC,KAAgB,CAAE;QAC5B,IAAI,CAACC,eAAe,GAAG,IAAA;QACvB,IAAI,CAACC,MAAM,GAAG,IAAA;AACd,QAAA,IAAIF,KAAO,EAAA;AACT,YA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AACuC,EAAAA,CAAGb,CAAC,EAAEc,EAAGd,CAAAA,CAAC,CAAGe,EAAAA,EAAAA,CAAGf,CAAC,CAAA;AACnCS,gBAAAA,IAAAA,CAAKnC,GAAG,CAACmC,IAAKnC,CAAAA,GAAG,CAACuC,EAAAA,CAAGX,CAAC,EAAEY,EAAGZ,CAAAA,CAAC,CAAGa,EAAAA,EAAAA,CAAGb,CAAC,CAAA;AACnCO,gBAAAA,IAAAA,CAAKnC,GAAG,CAACmC,IAAKnC,CAAAA,GAAG,CAACuC,EAAAA,CAAGT,CAAC,EAAEU,EAAGV,CAAAA,CAAC,CAAGW,EAAAA,EAAAA,CAAGX,CAAC;AACpC,aAAA;AACDoB,YAAAA,QAAAA,CAASrF,GAAG,CAAC2D,OAAO,CAACxB,GAAG,CAAC,CAAA,CAAE,EAAEA,GAAG,CAAC,CAAA,CAAE,EAAEA,GAAG,CAAC,CAAE,CAAA,CAAA;AAC3CW,YAAAA,WAAAA,CAAYpC,IAAI,CAACyB,GAAAA,CAAAA;AACnB;AACA,QAAA,IAAIkD,QAASrF,CAAAA,GAAG,CAACsF,OAAO,EAAI,EAAA;YAC1B,IAAI,CAAC7F,MAAM,GAAG;AAAC4F,gBAAAA;AAAS,aAAA;AACxB,YAAA,IAAI,CAACzC,UAAU,CAAC,CAAA,EAAG1C,WAAW2C,WAAaC,EAAAA,WAAAA,CAAAA;SACtC,MAAA;YACL,IAAI,CAACrD,MAAM,GAAG,EAAE;AAClB;AACF;AACF;;;;"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AABB, Frustum, ClipState } from '@zephyr3d/base';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The bounding box class
|
|
5
|
-
* @public
|
|
6
|
-
*/ class BoundingBox extends AABB {
|
|
7
|
-
constructor(arg0, arg1){
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
super(arg0, arg1);
|
|
10
|
-
}
|
|
11
|
-
/** {@inheritDoc BoundingVolume.behindPlane} */ behindPlane(plane) {
|
|
12
|
-
return this.toAABB().behindPlane(plane);
|
|
13
|
-
}
|
|
14
|
-
/** {@inheritDoc BoundingVolume.clone} */ clone() {
|
|
15
|
-
return new BoundingBox(this);
|
|
16
|
-
}
|
|
17
|
-
/** {@inheritDoc BoundingVolume.transform} */ transform(matrix) {
|
|
18
|
-
return new BoundingBox(AABB.transform(this, matrix));
|
|
19
|
-
}
|
|
20
|
-
/** {@inheritDoc BoundingVolume.outsideFrustum} */ outsideFrustum(frustum) {
|
|
21
|
-
return (frustum instanceof Frustum ? this.getClipStateWithFrustum(frustum) : this.getClipState(frustum)) === ClipState.NOT_CLIPPED;
|
|
22
|
-
}
|
|
23
|
-
/** {@inheritDoc BoundingVolume.toAABB} */ toAABB() {
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { BoundingBox };
|
|
29
|
-
//# sourceMappingURL=bounding_volume.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bounding_volume.js","sources":["../../../src/utility/bounding_volume.ts"],"sourcesContent":["import type { Vector3, Matrix4x4, Plane } from '@zephyr3d/base';\r\nimport { Frustum, AABB, ClipState } from '@zephyr3d/base';\r\n\r\n/**\r\n * Base interface for any kind of bounding volumes\r\n * @public\r\n */\r\nexport interface BoundingVolume {\r\n /**\r\n * Creates a new bounding volume by copying from this bounding volume\r\n */\r\n clone(): BoundingVolume;\r\n /**\r\n * Creates a new bounding volume by tranforming this bounding volume by a matrix\r\n * @param matrix - The transform matrix\r\n * @returns The created bounding volume\r\n */\r\n transform(matrix: Matrix4x4): BoundingVolume;\r\n /**\r\n * Check if this bounding volume is behind a plane\r\n * @param plane - The plane to check\r\n * @returns true if the bounding volume behinds the plane, false otherwise\r\n */\r\n behindPlane(plane: Plane): boolean;\r\n /**\r\n * Check if this bounding volume is outside a frustum\r\n * @param frustum - The frustum to check\r\n * @returns true if the bounding volume outsides the frustum, false otherwise\r\n */\r\n outsideFrustum(frustum: Frustum | Matrix4x4): boolean;\r\n /**\r\n * Gets the minimum AABB that contains the bounding volume\r\n * @returns The mimimum AABB that contains the bounding volume\r\n */\r\n toAABB(): AABB;\r\n}\r\n\r\n/**\r\n * The bounding box class\r\n * @public\r\n */\r\nexport class BoundingBox extends AABB implements BoundingVolume {\r\n /**\r\n * Creates an empty bounding box\r\n */\r\n constructor();\r\n /**\r\n * Creates a bounding box from an AABB\r\n * @param box - The AABB\r\n */\r\n constructor(box: AABB);\r\n /**\r\n * Creates a bounding box from the min point and the max point\r\n * @param minPoint - Min point of the box\r\n * @param maxPoint - Max point of the box\r\n */\r\n constructor(minPoint: Vector3, maxPoint: Vector3);\r\n constructor(arg0?: Vector3 | AABB, arg1?: Vector3) {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n super(arg0 as any, arg1);\r\n }\r\n /** {@inheritDoc BoundingVolume.behindPlane} */\r\n behindPlane(plane: Plane): boolean {\r\n return this.toAABB().behindPlane(plane);\r\n }\r\n /** {@inheritDoc BoundingVolume.clone} */\r\n clone(): BoundingVolume {\r\n return new BoundingBox(this);\r\n }\r\n /** {@inheritDoc BoundingVolume.transform} */\r\n transform(matrix: Matrix4x4): BoundingVolume {\r\n return new BoundingBox(AABB.transform(this, matrix));\r\n }\r\n /** {@inheritDoc BoundingVolume.outsideFrustum} */\r\n outsideFrustum(frustum: Frustum | Matrix4x4): boolean {\r\n return (\r\n (frustum instanceof Frustum ? this.getClipStateWithFrustum(frustum) : this.getClipState(frustum)) ===\r\n ClipState.NOT_CLIPPED\r\n );\r\n }\r\n /** {@inheritDoc BoundingVolume.toAABB} */\r\n toAABB(): AABB {\r\n return this;\r\n }\r\n}\r\n"],"names":["BoundingBox","AABB","arg0","arg1","behindPlane","plane","toAABB","clone","transform","matrix","outsideFrustum","frustum","Frustum","getClipStateWithFrustum","getClipState","ClipState","NOT_CLIPPED"],"mappings":";;AAqCA;;;IAIO,MAAMA,WAAoBC,SAAAA,IAAAA,CAAAA;IAgB/B,WAAYC,CAAAA,IAAqB,EAAEC,IAAc,CAAE;;AAEjD,QAAA,KAAK,CAACD,IAAaC,EAAAA,IAAAA,CAAAA;AACrB;oDAEAC,WAAYC,CAAAA,KAAY,EAAW;AACjC,QAAA,OAAO,IAAI,CAACC,MAAM,EAAA,CAAGF,WAAW,CAACC,KAAAA,CAAAA;AACnC;AACA,8CACAE,KAAwB,GAAA;QACtB,OAAO,IAAIP,YAAY,IAAI,CAAA;AAC7B;kDAEAQ,SAAUC,CAAAA,MAAiB,EAAkB;AAC3C,QAAA,OAAO,IAAIT,WAAYC,CAAAA,IAAAA,CAAKO,SAAS,CAAC,IAAI,EAAEC,MAAAA,CAAAA,CAAAA;AAC9C;uDAEAC,cAAeC,CAAAA,OAA4B,EAAW;AACpD,QAAA,OACE,CAACA,OAAAA,YAAmBC,OAAU,GAAA,IAAI,CAACC,uBAAuB,CAACF,OAAW,CAAA,GAAA,IAAI,CAACG,YAAY,CAACH,OAAO,CAAA,MAC/FI,UAAUC,WAAW;AAEzB;AACA,+CACAV,MAAe,GAAA;AACb,QAAA,OAAO,IAAI;AACb;AACF;;;;"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { copyTexture, fetchSampler } from './misc.js';
|
|
2
|
-
|
|
3
|
-
const debugFrameBuffer = {};
|
|
4
|
-
/**
|
|
5
|
-
* Copies texture to an intermidate texture for debugging with inspector
|
|
6
|
-
* @param tex - The texture to debug
|
|
7
|
-
* @param label - Label for the intermidate texture
|
|
8
|
-
* @internal
|
|
9
|
-
*/ function debugTexture(tex, label) {
|
|
10
|
-
let fb = debugFrameBuffer[label];
|
|
11
|
-
if (!fb || fb.getWidth() !== tex.width || fb.getHeight() !== tex.height) {
|
|
12
|
-
fb?.getColorAttachments()[0]?.dispose();
|
|
13
|
-
fb?.dispose();
|
|
14
|
-
fb = tex.device.createFrameBuffer([
|
|
15
|
-
tex.device.createTexture2D(tex.format, tex.width, tex.height, {
|
|
16
|
-
samplerOptions: {
|
|
17
|
-
mipFilter: 'none'
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
], null);
|
|
21
|
-
fb.getColorAttachments()[0].name = label ?? 'Debug';
|
|
22
|
-
debugFrameBuffer[label] = fb;
|
|
23
|
-
}
|
|
24
|
-
copyTexture(tex, fb, fetchSampler('clamp_nearest_nomip'));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { debugTexture };
|
|
28
|
-
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sources":["../../../src/utility/debug.ts"],"sourcesContent":["import type { BaseTexture, FrameBuffer } from '@zephyr3d/device';\r\nimport { copyTexture, fetchSampler } from './misc';\r\n\r\nconst debugFrameBuffer: Record<string, FrameBuffer> = {};\r\n\r\n/**\r\n * Copies texture to an intermidate texture for debugging with inspector\r\n * @param tex - The texture to debug\r\n * @param label - Label for the intermidate texture\r\n * @internal\r\n */\r\nexport function debugTexture(tex: BaseTexture, label: string) {\r\n let fb = debugFrameBuffer[label];\r\n if (!fb || fb.getWidth() !== tex.width || fb.getHeight() !== tex.height) {\r\n fb?.getColorAttachments()[0]?.dispose();\r\n fb?.dispose();\r\n fb = tex.device.createFrameBuffer(\r\n [\r\n tex.device.createTexture2D(tex.format, tex.width, tex.height, {\r\n samplerOptions: {\r\n mipFilter: 'none'\r\n }\r\n })\r\n ],\r\n null\r\n );\r\n fb.getColorAttachments()[0].name = label ?? 'Debug';\r\n debugFrameBuffer[label] = fb;\r\n }\r\n copyTexture(tex, fb, fetchSampler('clamp_nearest_nomip'));\r\n}\r\n"],"names":["debugFrameBuffer","debugTexture","tex","label","fb","getWidth","width","getHeight","height","getColorAttachments","dispose","device","createFrameBuffer","createTexture2D","format","samplerOptions","mipFilter","name","copyTexture","fetchSampler"],"mappings":";;AAGA,MAAMA,mBAAgD,EAAC;AAEvD;;;;;AAKC,IACM,SAASC,YAAaC,CAAAA,GAAgB,EAAEC,KAAa,EAAA;IAC1D,IAAIC,EAAAA,GAAKJ,gBAAgB,CAACG,KAAM,CAAA;AAChC,IAAA,IAAI,CAACC,EAAAA,IAAMA,EAAGC,CAAAA,QAAQ,EAAOH,KAAAA,GAAAA,CAAII,KAAK,IAAIF,EAAGG,CAAAA,SAAS,EAAOL,KAAAA,GAAAA,CAAIM,MAAM,EAAE;QACvEJ,EAAIK,EAAAA,mBAAAA,EAAqB,CAAC,CAAA,CAAE,EAAEC,OAAAA,EAAAA;QAC9BN,EAAIM,EAAAA,OAAAA,EAAAA;AACJN,QAAAA,EAAAA,GAAKF,GAAIS,CAAAA,MAAM,CAACC,iBAAiB,CAC/B;AACEV,YAAAA,GAAAA,CAAIS,MAAM,CAACE,eAAe,CAACX,GAAIY,CAAAA,MAAM,EAAEZ,GAAAA,CAAII,KAAK,EAAEJ,GAAIM,CAAAA,MAAM,EAAE;gBAC5DO,cAAgB,EAAA;oBACdC,SAAW,EAAA;AACb;AACF,aAAA;SACD,EACD,IAAA,CAAA;AAEFZ,QAAAA,EAAAA,CAAGK,mBAAmB,EAAE,CAAC,EAAE,CAACQ,IAAI,GAAGd,KAAS,IAAA,OAAA;QAC5CH,gBAAgB,CAACG,MAAM,GAAGC,EAAAA;AAC5B;IACAc,WAAYhB,CAAAA,GAAAA,EAAKE,IAAIe,YAAa,CAAA,qBAAA,CAAA,CAAA;AACpC;;;;"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
class DracoMeshDecoder {
|
|
2
|
-
_module;
|
|
3
|
-
_decoder;
|
|
4
|
-
_mesh;
|
|
5
|
-
constructor(data, decoderModule){
|
|
6
|
-
this._module = decoderModule;
|
|
7
|
-
this._decoder = new this._module.Decoder();
|
|
8
|
-
const buffer = new this._module.DecoderBuffer();
|
|
9
|
-
buffer.Init(data, data.byteLength);
|
|
10
|
-
const geometryType = this._decoder.GetEncodedGeometryType(buffer);
|
|
11
|
-
if (geometryType !== this._module.TRIANGULAR_MESH) {
|
|
12
|
-
this._module.destroy(buffer);
|
|
13
|
-
this._module.destroy(this._decoder);
|
|
14
|
-
this._decoder = null;
|
|
15
|
-
throw new Error(`Unsupported geometry type: ${geometryType}`);
|
|
16
|
-
}
|
|
17
|
-
this._mesh = new this._module.Mesh();
|
|
18
|
-
const status = this._decoder.DecodeBufferToMesh(buffer, this._mesh);
|
|
19
|
-
this._module.destroy(buffer);
|
|
20
|
-
if (!status.ok() || this._mesh.ptr === 0) {
|
|
21
|
-
this._module.destroy(this._decoder);
|
|
22
|
-
this._decoder = null;
|
|
23
|
-
this._module.destroy(this._mesh);
|
|
24
|
-
this._mesh = null;
|
|
25
|
-
throw new Error(status.error_msg());
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
getIndexBuffer() {
|
|
29
|
-
if (!this._decoder || !this._mesh) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const numFaces = this._mesh.num_faces();
|
|
33
|
-
const numIndices = numFaces * 3;
|
|
34
|
-
// Uint32
|
|
35
|
-
const indexBuffer = new Uint32Array(numIndices);
|
|
36
|
-
const ptr = this._module._malloc(indexBuffer.byteLength);
|
|
37
|
-
this._decoder.GetTrianglesUInt32Array(this._mesh, indexBuffer.byteLength, ptr);
|
|
38
|
-
const tmpBuffer = new Uint32Array(this._module.HEAPU32.buffer, ptr, numIndices);
|
|
39
|
-
indexBuffer.set(tmpBuffer);
|
|
40
|
-
this._module._free(ptr);
|
|
41
|
-
return indexBuffer;
|
|
42
|
-
}
|
|
43
|
-
getAttributeBuffer(id, buffer) {
|
|
44
|
-
if (!this._decoder || !this._mesh) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const attribute = this._decoder.GetAttributeByUniqueId(this._mesh, id);
|
|
48
|
-
if (!attribute) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
const numComponents = attribute.num_components();
|
|
52
|
-
const numPoints = this._mesh.num_points();
|
|
53
|
-
const numValues = numPoints * numComponents;
|
|
54
|
-
if (buffer.length !== numValues) {
|
|
55
|
-
console.error(`getAttributeBuffer(): buffer length must be ${numValues}`);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const ptr = this._module._malloc(buffer.byteLength);
|
|
59
|
-
this._decoder.GetAttributeDataArrayForAllPoints(this._mesh, attribute, this.getDracoDataType(buffer), buffer.byteLength, ptr);
|
|
60
|
-
const tmpBuffer = new buffer.constructor(this.getDracoHeap(buffer).buffer, ptr, numValues);
|
|
61
|
-
buffer.set(tmpBuffer);
|
|
62
|
-
this._module._free(ptr);
|
|
63
|
-
return buffer;
|
|
64
|
-
}
|
|
65
|
-
getDracoDataType(buffer) {
|
|
66
|
-
if (buffer instanceof Float32Array) {
|
|
67
|
-
return this._module.DT_FLOAT32;
|
|
68
|
-
}
|
|
69
|
-
if (buffer instanceof Int8Array) {
|
|
70
|
-
return this._module.DT_INT8;
|
|
71
|
-
}
|
|
72
|
-
if (buffer instanceof Int16Array) {
|
|
73
|
-
return this._module.DT_INT16;
|
|
74
|
-
}
|
|
75
|
-
if (buffer instanceof Int32Array) {
|
|
76
|
-
return this._module.DT_INT32;
|
|
77
|
-
}
|
|
78
|
-
if (buffer instanceof Uint8Array) {
|
|
79
|
-
return this._module.DT_UINT8;
|
|
80
|
-
}
|
|
81
|
-
if (buffer instanceof Uint16Array) {
|
|
82
|
-
return this._module.DT_UINT16;
|
|
83
|
-
}
|
|
84
|
-
if (buffer instanceof Uint32Array) {
|
|
85
|
-
return this._module.DT_UINT32;
|
|
86
|
-
}
|
|
87
|
-
throw new Error(`getDracoDataType(): invalid buffer type`);
|
|
88
|
-
}
|
|
89
|
-
getDracoHeap(buffer) {
|
|
90
|
-
if (buffer instanceof Float32Array) {
|
|
91
|
-
return this._module.HEAPF32;
|
|
92
|
-
}
|
|
93
|
-
if (buffer instanceof Int8Array) {
|
|
94
|
-
return this._module.HEAP8;
|
|
95
|
-
}
|
|
96
|
-
if (buffer instanceof Int16Array) {
|
|
97
|
-
return this._module.HEAP16;
|
|
98
|
-
}
|
|
99
|
-
if (buffer instanceof Int32Array) {
|
|
100
|
-
return this._module.HEAP32;
|
|
101
|
-
}
|
|
102
|
-
if (buffer instanceof Uint8Array) {
|
|
103
|
-
return this._module.HEAPU8;
|
|
104
|
-
}
|
|
105
|
-
if (buffer instanceof Uint16Array) {
|
|
106
|
-
return this._module.HEAPU16;
|
|
107
|
-
}
|
|
108
|
-
if (buffer instanceof Uint32Array) {
|
|
109
|
-
return this._module.HEAPU32;
|
|
110
|
-
}
|
|
111
|
-
throw new Error(`getDracoHeap(): invalid buffer type`);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export { DracoMeshDecoder };
|
|
116
|
-
//# sourceMappingURL=decoder.js.map
|