@zephyr3d/scene 0.7.1 → 0.8.1
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 +0 -18
- package/dist/animation/animation.js.map +1 -1
- package/dist/animation/animationset.js +200 -3
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +371 -0
- package/dist/animation/ik/ccd_solver.js.map +1 -0
- package/dist/animation/ik/fabrik_solver.js +398 -0
- package/dist/animation/ik/fabrik_solver.js.map +1 -0
- package/dist/animation/ik/ik_angle_constraint.js +181 -0
- package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
- package/dist/animation/ik/ik_chain.js +163 -0
- package/dist/animation/ik/ik_chain.js.map +1 -0
- package/dist/animation/ik/ik_constraint.js +25 -0
- package/dist/animation/ik/ik_constraint.js.map +1 -0
- package/dist/animation/ik/ik_pole_constraint.js +128 -0
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
- package/dist/animation/ik/ik_solver.js +48 -0
- package/dist/animation/ik/ik_solver.js.map +1 -0
- package/dist/animation/ik/ik_track.js +96 -0
- package/dist/animation/ik/ik_track.js.map +1 -0
- package/dist/animation/ik/ik_utils.js +191 -0
- package/dist/animation/ik/ik_utils.js.map +1 -0
- package/dist/animation/ik/two_bone_ik_solver.js +331 -0
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
- package/dist/animation/ik_modifier.js +61 -0
- package/dist/animation/ik_modifier.js.map +1 -0
- package/dist/animation/ik_postprocessor.js +71 -0
- package/dist/animation/ik_postprocessor.js.map +1 -0
- package/dist/animation/manual_transform_processor.js +156 -0
- package/dist/animation/manual_transform_processor.js.map +1 -0
- package/dist/animation/skeleton.js +55 -51
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js +38 -0
- package/dist/animation/skeleton_modifier.js.map +1 -0
- package/dist/animation/skeleton_postprocessor.js +50 -0
- package/dist/animation/skeleton_postprocessor.js.map +1 -0
- package/dist/animation/spring/multi_chain_spring_system.js +503 -0
- package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
- 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/animation/spring/spring_chain.js +103 -0
- package/dist/animation/spring/spring_chain.js.map +1 -0
- package/dist/animation/spring/spring_collider.js +247 -0
- package/dist/animation/spring/spring_collider.js.map +1 -0
- package/dist/animation/spring/spring_constraint.js +21 -0
- package/dist/animation/spring/spring_constraint.js.map +1 -0
- package/dist/animation/spring/spring_particle.js +20 -0
- package/dist/animation/spring/spring_particle.js.map +1 -0
- package/dist/animation/spring/spring_system.js +526 -0
- package/dist/animation/spring/spring_system.js.map +1 -0
- package/dist/animation/spring_modifier.js +45 -0
- package/dist/animation/spring_modifier.js.map +1 -0
- package/dist/animation/spring_postprocessor.js +54 -0
- package/dist/animation/spring_postprocessor.js.map +1 -0
- package/dist/app/screen.js +1 -1
- package/dist/app/screen.js.map +1 -1
- package/dist/asset/model.js +10 -6
- package/dist/asset/model.js.map +1 -1
- package/dist/camera/perspectivecamera.js +3 -3
- package/dist/camera/perspectivecamera.js.map +1 -1
- package/dist/index.d.ts +1400 -4
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/shader/helper.js +5 -3
- package/dist/material/shader/helper.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/scene/mesh.js +15 -23
- package/dist/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +24 -23
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +62 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +1 -1
- package/package.json +3 -3
- 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,152 +0,0 @@
|
|
|
1
|
-
import { Application } from '../app/app.js';
|
|
2
|
-
|
|
3
|
-
class RenderBundleWrapper {
|
|
4
|
-
_renderBundles;
|
|
5
|
-
_disposed;
|
|
6
|
-
static _drawableContainer = new WeakMap();
|
|
7
|
-
static _materialContainer = new WeakMap();
|
|
8
|
-
static _primitiveContainer = new WeakMap();
|
|
9
|
-
/** @internal */ static addDrawable(drawable, material, primitive, wrapper, hash) {
|
|
10
|
-
let renderBundles = this._drawableContainer.get(drawable);
|
|
11
|
-
if (!renderBundles) {
|
|
12
|
-
renderBundles = [];
|
|
13
|
-
this._drawableContainer.set(drawable, renderBundles);
|
|
14
|
-
}
|
|
15
|
-
const index = renderBundles.findIndex((rb)=>rb.wrapper === wrapper);
|
|
16
|
-
if (index < 0) {
|
|
17
|
-
renderBundles.push({
|
|
18
|
-
wrapper: wrapper,
|
|
19
|
-
hashes: [
|
|
20
|
-
hash
|
|
21
|
-
]
|
|
22
|
-
});
|
|
23
|
-
} else {
|
|
24
|
-
if (!renderBundles[index].hashes.includes(hash)) {
|
|
25
|
-
renderBundles[index].hashes.push(hash);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (material) {
|
|
29
|
-
let ownDrawables = this._materialContainer.get(material);
|
|
30
|
-
if (!ownDrawables) {
|
|
31
|
-
ownDrawables = new Set();
|
|
32
|
-
this._materialContainer.set(material, ownDrawables);
|
|
33
|
-
}
|
|
34
|
-
ownDrawables.add(drawable);
|
|
35
|
-
}
|
|
36
|
-
if (primitive) {
|
|
37
|
-
let ownDrawables = this._primitiveContainer.get(primitive);
|
|
38
|
-
if (!ownDrawables) {
|
|
39
|
-
ownDrawables = new Set();
|
|
40
|
-
this._primitiveContainer.set(primitive, ownDrawables);
|
|
41
|
-
}
|
|
42
|
-
ownDrawables.add(drawable);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/** @internal */ static drawableChanged(drawable) {
|
|
46
|
-
const renderBundles = this._drawableContainer.get(drawable);
|
|
47
|
-
if (renderBundles) {
|
|
48
|
-
for(let i = renderBundles.length - 1; i >= 0; i--){
|
|
49
|
-
const renderBundle = renderBundles[i].wrapper;
|
|
50
|
-
if (renderBundle.disposed) {
|
|
51
|
-
renderBundles.splice(i, 1);
|
|
52
|
-
} else {
|
|
53
|
-
for (const hash of renderBundles[i].hashes){
|
|
54
|
-
renderBundles[i].wrapper.invalidate(hash);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** @internal */ static primitiveChanged(primitive) {
|
|
61
|
-
const ownDrawables = this._primitiveContainer.get(primitive);
|
|
62
|
-
if (ownDrawables) {
|
|
63
|
-
for (const drawable of ownDrawables){
|
|
64
|
-
this.drawableChanged(drawable);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/** @internal */ static primitiveAttached(primitive, drawable) {
|
|
69
|
-
if (this._drawableContainer.has(drawable)) {
|
|
70
|
-
const ownDrawables = this._primitiveContainer.get(primitive);
|
|
71
|
-
if (!ownDrawables) {
|
|
72
|
-
this._primitiveContainer.set(primitive, new Set([
|
|
73
|
-
drawable
|
|
74
|
-
]));
|
|
75
|
-
} else {
|
|
76
|
-
ownDrawables.add(drawable);
|
|
77
|
-
}
|
|
78
|
-
this.drawableChanged(drawable);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/** @internal */ static primitiveDetached(primitive, drawable) {
|
|
82
|
-
const ownDrawables = this._primitiveContainer.get(primitive);
|
|
83
|
-
if (ownDrawables && ownDrawables.has(drawable)) {
|
|
84
|
-
ownDrawables.delete(drawable);
|
|
85
|
-
this.drawableChanged(drawable);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/** @internal */ static materialChanged(material) {
|
|
89
|
-
const ownDrawables = this._materialContainer.get(material);
|
|
90
|
-
if (ownDrawables) {
|
|
91
|
-
for (const drawable of ownDrawables){
|
|
92
|
-
this.drawableChanged(drawable);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/** @internal */ static materialUniformsChanged(material) {
|
|
97
|
-
const ownDrawables = this._materialContainer.get(material);
|
|
98
|
-
if (ownDrawables) {
|
|
99
|
-
for (const drawable of ownDrawables){
|
|
100
|
-
if (drawable.isBatchable()) {
|
|
101
|
-
drawable.applyMaterialUniformsAll();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/** @internal */ static materialAttached(material, drawable) {
|
|
107
|
-
if (this._drawableContainer.has(drawable)) {
|
|
108
|
-
const ownDrawables = this._materialContainer.get(material);
|
|
109
|
-
if (!ownDrawables) {
|
|
110
|
-
this._materialContainer.set(material, new Set([
|
|
111
|
-
drawable
|
|
112
|
-
]));
|
|
113
|
-
} else {
|
|
114
|
-
ownDrawables.add(drawable);
|
|
115
|
-
}
|
|
116
|
-
this.drawableChanged(drawable);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/** @internal */ static materialDetached(material, drawable) {
|
|
120
|
-
const ownDrawables = this._materialContainer.get(material);
|
|
121
|
-
if (ownDrawables && ownDrawables.has(drawable)) {
|
|
122
|
-
ownDrawables.delete(drawable);
|
|
123
|
-
this.drawableChanged(drawable);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
constructor(){
|
|
127
|
-
this._renderBundles = {};
|
|
128
|
-
this._disposed = false;
|
|
129
|
-
}
|
|
130
|
-
get disposed() {
|
|
131
|
-
return this._disposed;
|
|
132
|
-
}
|
|
133
|
-
getRenderBundle(hash) {
|
|
134
|
-
return this._renderBundles[hash] ?? null;
|
|
135
|
-
}
|
|
136
|
-
beginRenderBundle() {
|
|
137
|
-
Application.instance.device.beginCapture();
|
|
138
|
-
}
|
|
139
|
-
endRenderBundle(hash) {
|
|
140
|
-
this._renderBundles[hash] = Application.instance.device.endCapture();
|
|
141
|
-
}
|
|
142
|
-
invalidate(hash) {
|
|
143
|
-
this._renderBundles[hash] = undefined;
|
|
144
|
-
}
|
|
145
|
-
dispose() {
|
|
146
|
-
this._renderBundles = {};
|
|
147
|
-
this._disposed = true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export { RenderBundleWrapper };
|
|
152
|
-
//# sourceMappingURL=renderbundle_wrapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderbundle_wrapper.js","sources":["../../../src/render/renderbundle_wrapper.ts"],"sourcesContent":["import type { RenderBundle } from '@zephyr3d/device';\r\nimport { Application } from '../app';\r\nimport type { Material } from '../material';\r\nimport type { Drawable } from './drawable';\r\nimport type { Primitive } from './primitive';\r\n\r\nexport class RenderBundleWrapper {\r\n private _renderBundles: Record<string, RenderBundle>;\r\n private _disposed: boolean;\r\n private static readonly _drawableContainer: WeakMap<\r\n Drawable,\r\n { wrapper: RenderBundleWrapper; hashes: string[] }[]\r\n > = new WeakMap();\r\n private static readonly _materialContainer: WeakMap<Material, Set<Drawable>> = new WeakMap();\r\n private static readonly _primitiveContainer: WeakMap<Primitive, Set<Drawable>> = new WeakMap();\r\n /** @internal */\r\n static addDrawable(\r\n drawable: Drawable,\r\n material: Material,\r\n primitive: Primitive,\r\n wrapper: RenderBundleWrapper,\r\n hash: string\r\n ) {\r\n let renderBundles = this._drawableContainer.get(drawable);\r\n if (!renderBundles) {\r\n renderBundles = [];\r\n this._drawableContainer.set(drawable, renderBundles);\r\n }\r\n const index = renderBundles.findIndex((rb) => rb.wrapper === wrapper);\r\n if (index < 0) {\r\n renderBundles.push({ wrapper: wrapper, hashes: [hash] });\r\n } else {\r\n if (!renderBundles[index].hashes.includes(hash)) {\r\n renderBundles[index].hashes.push(hash);\r\n }\r\n }\r\n if (material) {\r\n let ownDrawables = this._materialContainer.get(material);\r\n if (!ownDrawables) {\r\n ownDrawables = new Set();\r\n this._materialContainer.set(material, ownDrawables);\r\n }\r\n ownDrawables.add(drawable);\r\n }\r\n if (primitive) {\r\n let ownDrawables = this._primitiveContainer.get(primitive);\r\n if (!ownDrawables) {\r\n ownDrawables = new Set();\r\n this._primitiveContainer.set(primitive, ownDrawables);\r\n }\r\n ownDrawables.add(drawable);\r\n }\r\n }\r\n /** @internal */\r\n static drawableChanged(drawable: Drawable) {\r\n const renderBundles = this._drawableContainer.get(drawable);\r\n if (renderBundles) {\r\n for (let i = renderBundles.length - 1; i >= 0; i--) {\r\n const renderBundle = renderBundles[i].wrapper;\r\n if (renderBundle.disposed) {\r\n renderBundles.splice(i, 1);\r\n } else {\r\n for (const hash of renderBundles[i].hashes) {\r\n renderBundles[i].wrapper.invalidate(hash);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** @internal */\r\n static primitiveChanged(primitive: Primitive) {\r\n const ownDrawables = this._primitiveContainer.get(primitive);\r\n if (ownDrawables) {\r\n for (const drawable of ownDrawables) {\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n }\r\n /** @internal */\r\n static primitiveAttached(primitive: Primitive, drawable: Drawable) {\r\n if (this._drawableContainer.has(drawable)) {\r\n const ownDrawables = this._primitiveContainer.get(primitive);\r\n if (!ownDrawables) {\r\n this._primitiveContainer.set(primitive, new Set([drawable]));\r\n } else {\r\n ownDrawables.add(drawable);\r\n }\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n /** @internal */\r\n static primitiveDetached(primitive: Primitive, drawable: Drawable) {\r\n const ownDrawables = this._primitiveContainer.get(primitive);\r\n if (ownDrawables && ownDrawables.has(drawable)) {\r\n ownDrawables.delete(drawable);\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n /** @internal */\r\n static materialChanged(material: Material) {\r\n const ownDrawables = this._materialContainer.get(material);\r\n if (ownDrawables) {\r\n for (const drawable of ownDrawables) {\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n }\r\n /** @internal */\r\n static materialUniformsChanged(material: Material) {\r\n const ownDrawables = this._materialContainer.get(material);\r\n if (ownDrawables) {\r\n for (const drawable of ownDrawables) {\r\n if (drawable.isBatchable()) {\r\n drawable.applyMaterialUniformsAll();\r\n }\r\n }\r\n }\r\n }\r\n /** @internal */\r\n static materialAttached(material: Material, drawable: Drawable) {\r\n if (this._drawableContainer.has(drawable)) {\r\n const ownDrawables = this._materialContainer.get(material);\r\n if (!ownDrawables) {\r\n this._materialContainer.set(material, new Set([drawable]));\r\n } else {\r\n ownDrawables.add(drawable);\r\n }\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n /** @internal */\r\n static materialDetached(material: Material, drawable: Drawable) {\r\n const ownDrawables = this._materialContainer.get(material);\r\n if (ownDrawables && ownDrawables.has(drawable)) {\r\n ownDrawables.delete(drawable);\r\n this.drawableChanged(drawable);\r\n }\r\n }\r\n constructor() {\r\n this._renderBundles = {};\r\n this._disposed = false;\r\n }\r\n get disposed() {\r\n return this._disposed;\r\n }\r\n getRenderBundle(hash: string) {\r\n return this._renderBundles[hash] ?? null;\r\n }\r\n beginRenderBundle() {\r\n Application.instance.device.beginCapture();\r\n }\r\n endRenderBundle(hash: string) {\r\n this._renderBundles[hash] = Application.instance.device.endCapture();\r\n }\r\n invalidate(hash: string) {\r\n this._renderBundles[hash] = undefined;\r\n }\r\n dispose() {\r\n this._renderBundles = {};\r\n this._disposed = true;\r\n }\r\n}\r\n"],"names":["RenderBundleWrapper","_renderBundles","_disposed","_drawableContainer","WeakMap","_materialContainer","_primitiveContainer","addDrawable","drawable","material","primitive","wrapper","hash","renderBundles","get","set","index","findIndex","rb","push","hashes","includes","ownDrawables","Set","add","drawableChanged","i","length","renderBundle","disposed","splice","invalidate","primitiveChanged","primitiveAttached","has","primitiveDetached","delete","materialChanged","materialUniformsChanged","isBatchable","applyMaterialUniformsAll","materialAttached","materialDetached","getRenderBundle","beginRenderBundle","Application","instance","device","beginCapture","endRenderBundle","endCapture","undefined","dispose"],"mappings":"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"}
|
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import { LightPass } from './lightpass.js';
|
|
2
|
-
import { ShadowMapPass } from './shadowmap_pass.js';
|
|
3
|
-
import { DepthPass } from './depthpass.js';
|
|
4
|
-
import { Vector4, isPowerOf2, nextPowerOf2, Matrix4x4, Vector3 } from '@zephyr3d/base';
|
|
5
|
-
import { Application } from '../app/app.js';
|
|
6
|
-
import '@zephyr3d/device';
|
|
7
|
-
import { CopyBlitter } from '../blitter/copy.js';
|
|
8
|
-
import { Camera } from '../camera/camera.js';
|
|
9
|
-
import { PostEffectLayer, AbstractPostEffect } from '../posteffect/posteffect.js';
|
|
10
|
-
import { ClusteredLight } from './cluster_light.js';
|
|
11
|
-
import { GlobalBindGroupAllocator } from './globalbindgroup_allocator.js';
|
|
12
|
-
import { ObjectColorPass } from './objectcolorpass.js';
|
|
13
|
-
import { buildHiZ } from './hzb.js';
|
|
14
|
-
import { MaterialVaryingFlags } from '../values.js';
|
|
15
|
-
import { fetchSampler } from '../utility/misc.js';
|
|
16
|
-
import { BoxShape } from '../shapes/box.js';
|
|
17
|
-
import '../shapes/cylinder.js';
|
|
18
|
-
import '../shapes/torus.js';
|
|
19
|
-
import '../shapes/plane.js';
|
|
20
|
-
import '../shapes/sphere.js';
|
|
21
|
-
import '../shapes/tetrahedron.js';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Forward render scheme
|
|
25
|
-
* @internal
|
|
26
|
-
*/ class SceneRenderer {
|
|
27
|
-
/** @internal */ static _skyMotionVectorProgram = null;
|
|
28
|
-
/** @internal */ static _skyMotionVectorBindGroup = null;
|
|
29
|
-
static _box = null;
|
|
30
|
-
/** @internal */ static _pickCamera = new Camera(null);
|
|
31
|
-
/** @internal */ static _scenePass = new LightPass();
|
|
32
|
-
/** @internal */ static _depthPass = new DepthPass();
|
|
33
|
-
/** @internal */ static _shadowMapPass = new ShadowMapPass();
|
|
34
|
-
/** @internal */ static _objectColorPass = new ObjectColorPass();
|
|
35
|
-
/** @internal */ static _frontDepthColorState = null;
|
|
36
|
-
/** @internal */ static _backDepthColorState = null;
|
|
37
|
-
/** @internal */ static _clusters = [];
|
|
38
|
-
/** lighting render pass */ static get sceneRenderPass() {
|
|
39
|
-
return this._scenePass;
|
|
40
|
-
}
|
|
41
|
-
/** depth render pass */ static get depthRenderPass() {
|
|
42
|
-
return this._depthPass;
|
|
43
|
-
}
|
|
44
|
-
/** shadow map render pass */ static get shadowMapRenderPass() {
|
|
45
|
-
return this._shadowMapPass;
|
|
46
|
-
}
|
|
47
|
-
/** @internal */ static getClusteredLight() {
|
|
48
|
-
if (this._clusters.length > 0) {
|
|
49
|
-
return this._clusters.pop();
|
|
50
|
-
}
|
|
51
|
-
return new ClusteredLight();
|
|
52
|
-
}
|
|
53
|
-
/** @internal */ static freeClusteredLight(clusteredLight) {
|
|
54
|
-
this._clusters.push(clusteredLight);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Renders a scene by given camera
|
|
58
|
-
* @param scene - The scene tondered
|
|
59
|
-
* @param camera - The camera that will be used to render the scene
|
|
60
|
-
* @param compositor - The compositor that will be used to apply postprocess effects
|
|
61
|
-
*/ static renderScene(scene, camera) {
|
|
62
|
-
const device = Application.instance.device;
|
|
63
|
-
const colorFormat = device.getDeviceCaps().textureCaps.supportHalfFloatColorBuffer ? 'rgba16f' : 'rgba8unorm';
|
|
64
|
-
const depthFormat = device.getDeviceCaps().framebufferCaps.supportDepth32floatStencil8 ? 'd32fs8' : 'd24s8';
|
|
65
|
-
const globalBindGroupAllocator = GlobalBindGroupAllocator.get();
|
|
66
|
-
scene.frameUpdate();
|
|
67
|
-
scene.frameUpdatePerCamera(camera);
|
|
68
|
-
if (camera && !device.isContextLost()) {
|
|
69
|
-
const defaultViewport = !camera.viewport && !camera.scissor;
|
|
70
|
-
const renderX = camera.viewport ? device.screenToDevice(camera.viewport[0]) : 0;
|
|
71
|
-
const renderY = camera.viewport ? device.screenToDevice(camera.viewport[1]) : 0;
|
|
72
|
-
const renderWidth = camera.viewport ? device.screenToDevice(camera.viewport[2]) : device.getDrawingBufferWidth();
|
|
73
|
-
const renderHeight = camera.viewport ? device.screenToDevice(camera.viewport[3]) : device.getDrawingBufferHeight();
|
|
74
|
-
if (renderWidth <= 0 || renderHeight <= 0) {
|
|
75
|
-
camera.getPickResultResolveFunc()?.(null);
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const tmpFramebuffer = defaultViewport ? null : device.pool.fetchTemporalFramebuffer(false, renderWidth, renderHeight, colorFormat, depthFormat);
|
|
79
|
-
const originFramebuffer = device.getFramebuffer();
|
|
80
|
-
if (tmpFramebuffer) {
|
|
81
|
-
device.pushDeviceStates();
|
|
82
|
-
device.setFramebuffer(tmpFramebuffer);
|
|
83
|
-
}
|
|
84
|
-
const SSR = camera.SSR && scene.env.light.envLight && scene.env.light.envLight.hasRadiance();
|
|
85
|
-
const ctx = {
|
|
86
|
-
device,
|
|
87
|
-
scene,
|
|
88
|
-
renderWidth,
|
|
89
|
-
renderHeight,
|
|
90
|
-
primaryCamera: camera,
|
|
91
|
-
picking: false,
|
|
92
|
-
oit: null,
|
|
93
|
-
motionVectors: device.type !== 'webgl' && (camera.TAA || camera.motionBlur),
|
|
94
|
-
HiZ: camera.HiZ && device.type !== 'webgl',
|
|
95
|
-
HiZTexture: null,
|
|
96
|
-
globalBindGroupAllocator,
|
|
97
|
-
camera,
|
|
98
|
-
compositor: camera.compositor,
|
|
99
|
-
timestamp: device.frameInfo.frameTimestamp,
|
|
100
|
-
queue: 0,
|
|
101
|
-
lightBlending: false,
|
|
102
|
-
renderPass: null,
|
|
103
|
-
renderPassHash: null,
|
|
104
|
-
fogFlags: 0,
|
|
105
|
-
flip: false,
|
|
106
|
-
depthFormat,
|
|
107
|
-
colorFormat,
|
|
108
|
-
drawEnvLight: false,
|
|
109
|
-
env: null,
|
|
110
|
-
materialFlags: 0,
|
|
111
|
-
TAA: camera.TAA,
|
|
112
|
-
SSR,
|
|
113
|
-
SSRCalcThickness: SSR && camera.ssrCalcThickness,
|
|
114
|
-
SSRRoughnessTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),
|
|
115
|
-
SSRNormalTexture: device.pool.fetchTemporalTexture2D(true, 'rgba8unorm', renderWidth, renderHeight),
|
|
116
|
-
finalFramebuffer: device.getFramebuffer(),
|
|
117
|
-
intermediateFramebuffer: null
|
|
118
|
-
};
|
|
119
|
-
this._renderScene(ctx);
|
|
120
|
-
if (tmpFramebuffer) {
|
|
121
|
-
device.popDeviceStates();
|
|
122
|
-
const oversizedViewport = renderX < 0 || renderY < 0 || renderX + renderWidth > device.getDrawingBufferWidth() || renderY + renderHeight > device.getDrawingBufferHeight();
|
|
123
|
-
const blitter = new CopyBlitter();
|
|
124
|
-
if (oversizedViewport) {
|
|
125
|
-
blitter.destRect = [
|
|
126
|
-
renderX,
|
|
127
|
-
renderY,
|
|
128
|
-
renderWidth,
|
|
129
|
-
renderHeight
|
|
130
|
-
];
|
|
131
|
-
} else {
|
|
132
|
-
blitter.viewport = camera.viewport;
|
|
133
|
-
}
|
|
134
|
-
blitter.scissor = camera.scissor;
|
|
135
|
-
blitter.blit(tmpFramebuffer.getColorAttachments()[0], originFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
136
|
-
device.pool.releaseFrameBuffer(tmpFramebuffer);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
GlobalBindGroupAllocator.release(globalBindGroupAllocator);
|
|
140
|
-
}
|
|
141
|
-
static renderSceneDepth(ctx, renderQueue, depthFramebuffer) {
|
|
142
|
-
const transmission = !!depthFramebuffer;
|
|
143
|
-
if (!depthFramebuffer) {
|
|
144
|
-
const format = ctx.device.type === 'webgl' ? ctx.SSRCalcThickness ? 'rgba16f' : 'rgba8unorm' : ctx.SSRCalcThickness ? 'rg32f' : 'r32f';
|
|
145
|
-
const mvFormat = ctx.device.type === 'webgl' ? 'rgba16f' : 'rgba16f';
|
|
146
|
-
if (!ctx.finalFramebuffer) {
|
|
147
|
-
depthFramebuffer = ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
148
|
-
format,
|
|
149
|
-
mvFormat
|
|
150
|
-
] : format, ctx.depthFormat, false);
|
|
151
|
-
} else {
|
|
152
|
-
const originDepth = ctx.finalFramebuffer?.getDepthAttachment();
|
|
153
|
-
depthFramebuffer = originDepth?.isTexture2D() ? ctx.device.pool.fetchTemporalFramebuffer(true, originDepth.width, originDepth.height, ctx.motionVectors ? [
|
|
154
|
-
format,
|
|
155
|
-
mvFormat
|
|
156
|
-
] : format, originDepth, false) : ctx.device.pool.fetchTemporalFramebuffer(true, ctx.renderWidth, ctx.renderHeight, ctx.motionVectors ? [
|
|
157
|
-
format,
|
|
158
|
-
mvFormat
|
|
159
|
-
] : format, ctx.depthFormat, false);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
ctx.device.pushDeviceStates();
|
|
163
|
-
ctx.device.setFramebuffer(depthFramebuffer);
|
|
164
|
-
this._depthPass.encodeDepth = depthFramebuffer.getColorAttachments()[0].format === 'rgba8unorm';
|
|
165
|
-
this._depthPass.clearColor = transmission ? null : this._depthPass.encodeDepth ? new Vector4(0, 0, 0, 1) : new Vector4(1, 1, 1, 1);
|
|
166
|
-
this._depthPass.clearDepth = transmission ? null : 1;
|
|
167
|
-
this._depthPass.clearStencil = null;
|
|
168
|
-
this._depthPass.transmission = transmission;
|
|
169
|
-
if (ctx.SSRCalcThickness && !transmission) {
|
|
170
|
-
if (!this._backDepthColorState) {
|
|
171
|
-
this._backDepthColorState = ctx.device.createColorState().setColorMask(false, true, false, false);
|
|
172
|
-
}
|
|
173
|
-
if (!this._frontDepthColorState) {
|
|
174
|
-
this._frontDepthColorState = ctx.device.createColorState().setColorMask(true, false, false, false);
|
|
175
|
-
}
|
|
176
|
-
ctx.forceColorState = this._backDepthColorState;
|
|
177
|
-
ctx.forceCullMode = 'front';
|
|
178
|
-
this._depthPass.renderBackface = true;
|
|
179
|
-
this._depthPass.transmission = false;
|
|
180
|
-
this._depthPass.render(ctx, null, renderQueue);
|
|
181
|
-
this._depthPass.clearColor = null;
|
|
182
|
-
this._depthPass.renderBackface = false;
|
|
183
|
-
ctx.forceColorState = this._frontDepthColorState;
|
|
184
|
-
ctx.forceCullMode = null;
|
|
185
|
-
}
|
|
186
|
-
this._depthPass.render(ctx, null, renderQueue);
|
|
187
|
-
ctx.forceColorState = null;
|
|
188
|
-
ctx.device.popDeviceStates();
|
|
189
|
-
if (!transmission) {
|
|
190
|
-
ctx.motionVectorTexture = ctx.motionVectors ? depthFramebuffer.getColorAttachments()[1] : null;
|
|
191
|
-
ctx.linearDepthTexture = depthFramebuffer.getColorAttachments()[0];
|
|
192
|
-
ctx.depthTexture = depthFramebuffer.getDepthAttachment();
|
|
193
|
-
if (ctx.motionVectorTexture) {
|
|
194
|
-
this.renderSkyMotionVectors(ctx);
|
|
195
|
-
}
|
|
196
|
-
if (ctx.HiZ) {
|
|
197
|
-
let w = isPowerOf2(ctx.linearDepthTexture.width) ? ctx.linearDepthTexture.width : nextPowerOf2(ctx.linearDepthTexture.width);
|
|
198
|
-
let h = isPowerOf2(ctx.linearDepthTexture.height) ? ctx.linearDepthTexture.height : nextPowerOf2(ctx.linearDepthTexture.height);
|
|
199
|
-
w = Math.max(1, w >> 1);
|
|
200
|
-
h = Math.max(1, h >> 1);
|
|
201
|
-
w = ctx.linearDepthTexture.width;
|
|
202
|
-
h = ctx.linearDepthTexture.height;
|
|
203
|
-
const HiZFrameBuffer = ctx.device.pool.fetchTemporalFramebuffer(true, w, h, ctx.linearDepthTexture.format, null, true);
|
|
204
|
-
buildHiZ(ctx.depthTexture, HiZFrameBuffer);
|
|
205
|
-
ctx.HiZTexture = HiZFrameBuffer.getColorAttachments()[0];
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return depthFramebuffer;
|
|
209
|
-
}
|
|
210
|
-
/** @internal */ static _renderScene(ctx) {
|
|
211
|
-
const device = ctx.device;
|
|
212
|
-
// Cull scene
|
|
213
|
-
const renderQueue = this._scenePass.cullScene(ctx, ctx.camera);
|
|
214
|
-
// Update sky
|
|
215
|
-
const sunLightColor = ctx.scene.env.sky.update(ctx);
|
|
216
|
-
// Gather lights
|
|
217
|
-
ctx.clusteredLight = this.getClusteredLight();
|
|
218
|
-
ctx.clusteredLight.calculateLightIndex(ctx.camera, renderQueue);
|
|
219
|
-
// Do GPU ray picking if required
|
|
220
|
-
const pickResolveFunc = ctx.camera.getPickResultResolveFunc();
|
|
221
|
-
if (pickResolveFunc) {
|
|
222
|
-
this.renderObjectColors(ctx, pickResolveFunc, renderQueue);
|
|
223
|
-
}
|
|
224
|
-
// Render shadow maps
|
|
225
|
-
this.renderShadowMaps(ctx, renderQueue.shadowedLights);
|
|
226
|
-
// Render scene depth first
|
|
227
|
-
const depthFramebuffer = this.renderSceneDepth(ctx, renderQueue, null);
|
|
228
|
-
if (ctx.depthTexture === ctx.finalFramebuffer?.getDepthAttachment()) {
|
|
229
|
-
ctx.intermediateFramebuffer = ctx.finalFramebuffer;
|
|
230
|
-
} else {
|
|
231
|
-
// TODO: fetch resizable framebuffer if ctx.defaultViewport is true
|
|
232
|
-
ctx.intermediateFramebuffer = device.pool.fetchTemporalFramebuffer(false, ctx.depthTexture.width, ctx.depthTexture.height, ctx.colorFormat, ctx.depthTexture);
|
|
233
|
-
}
|
|
234
|
-
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
235
|
-
device.pushDeviceStates();
|
|
236
|
-
device.setFramebuffer(ctx.intermediateFramebuffer);
|
|
237
|
-
} else {
|
|
238
|
-
device.setViewport(null);
|
|
239
|
-
device.setScissor(null);
|
|
240
|
-
}
|
|
241
|
-
this._scenePass.transmission = false; // transmission
|
|
242
|
-
this._scenePass.clearDepth = ctx.depthTexture ? null : 1;
|
|
243
|
-
this._scenePass.clearStencil = ctx.depthTexture ? null : 0;
|
|
244
|
-
if (ctx.SSR && !renderQueue.needSceneColor()) {
|
|
245
|
-
ctx.materialFlags |= MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
246
|
-
}
|
|
247
|
-
ctx.compositor?.begin(ctx);
|
|
248
|
-
if (renderQueue.needSceneColor()) {
|
|
249
|
-
const compositor = ctx.compositor;
|
|
250
|
-
ctx.compositor = null;
|
|
251
|
-
const sceneColorFramebuffer = device.pool.fetchTemporalFramebuffer(true, ctx.depthTexture.width, ctx.depthTexture.height, ctx.materialFlags & MaterialVaryingFlags.SSR_STORE_ROUGHNESS ? [
|
|
252
|
-
ctx.colorFormat,
|
|
253
|
-
device.getFramebuffer().getColorAttachments()[1],
|
|
254
|
-
device.getFramebuffer().getColorAttachments()[2]
|
|
255
|
-
] : ctx.colorFormat, ctx.depthTexture, false);
|
|
256
|
-
device.pushDeviceStates();
|
|
257
|
-
device.setFramebuffer(sceneColorFramebuffer);
|
|
258
|
-
this._scenePass.transmission = false;
|
|
259
|
-
this._scenePass.render(ctx, null, renderQueue);
|
|
260
|
-
device.popDeviceStates();
|
|
261
|
-
ctx.sceneColorTexture = sceneColorFramebuffer.getColorAttachments()[0];
|
|
262
|
-
new CopyBlitter().blit(ctx.sceneColorTexture, device.getFramebuffer() ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
263
|
-
this._scenePass.transmission = true;
|
|
264
|
-
this._scenePass.clearColor = null;
|
|
265
|
-
this._scenePass.clearDepth = null;
|
|
266
|
-
this._scenePass.clearStencil = null;
|
|
267
|
-
ctx.compositor = compositor;
|
|
268
|
-
}
|
|
269
|
-
this._scenePass.render(ctx, null, renderQueue);
|
|
270
|
-
if (renderQueue.needSceneColor()) {
|
|
271
|
-
this.renderSceneDepth(ctx, renderQueue, depthFramebuffer);
|
|
272
|
-
}
|
|
273
|
-
ctx.compositor?.drawPostEffects(ctx, PostEffectLayer.end, ctx.linearDepthTexture);
|
|
274
|
-
ctx.compositor?.end(ctx);
|
|
275
|
-
renderQueue.dispose();
|
|
276
|
-
ctx.materialFlags &= ~MaterialVaryingFlags.SSR_STORE_ROUGHNESS;
|
|
277
|
-
if (ctx.intermediateFramebuffer && ctx.intermediateFramebuffer !== ctx.finalFramebuffer) {
|
|
278
|
-
const blitter = new CopyBlitter();
|
|
279
|
-
blitter.srgbOut = !ctx.finalFramebuffer;
|
|
280
|
-
const srcTex = ctx.intermediateFramebuffer.getColorAttachments()[0];
|
|
281
|
-
blitter.blit(srcTex, ctx.finalFramebuffer ?? null, fetchSampler('clamp_nearest_nomip'));
|
|
282
|
-
device.popDeviceStates();
|
|
283
|
-
device.pool.releaseFrameBuffer(ctx.intermediateFramebuffer);
|
|
284
|
-
}
|
|
285
|
-
//ShadowMapper.releaseTemporalResources(ctx);
|
|
286
|
-
this.freeClusteredLight(ctx.clusteredLight);
|
|
287
|
-
// Restore sun color
|
|
288
|
-
if (sunLightColor) {
|
|
289
|
-
ctx.sunLight.color = sunLightColor;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
static _getSkyMotionVectorProgram(ctx) {
|
|
293
|
-
if (!this._skyMotionVectorProgram) {
|
|
294
|
-
this._skyMotionVectorProgram = ctx.device.buildRenderProgram({
|
|
295
|
-
vertex (pb) {
|
|
296
|
-
this.$inputs.pos = pb.vec3().attrib('position');
|
|
297
|
-
this.VPMatrix = pb.mat4().uniform(0);
|
|
298
|
-
this.prevVPMatrix = pb.mat4().uniform(0);
|
|
299
|
-
this.cameraPos = pb.vec3().uniform(0);
|
|
300
|
-
this.prevCameraPos = pb.vec3().uniform(0);
|
|
301
|
-
pb.main(function() {
|
|
302
|
-
this.$l.worldPos = pb.add(this.$inputs.pos, this.cameraPos);
|
|
303
|
-
this.$l.prevWorldPos = pb.add(this.$inputs.pos, this.prevCameraPos);
|
|
304
|
-
this.$l.clipPos = pb.mul(this.VPMatrix, pb.vec4(this.worldPos, 1));
|
|
305
|
-
this.$l.prevClipPos = pb.mul(this.prevVPMatrix, pb.vec4(this.prevWorldPos, 1));
|
|
306
|
-
this.clipPos.z = this.clipPos.w;
|
|
307
|
-
this.$builtins.position = this.clipPos;
|
|
308
|
-
this.$outputs.currentPos = this.clipPos;
|
|
309
|
-
this.$outputs.prevPos = this.prevClipPos;
|
|
310
|
-
});
|
|
311
|
-
},
|
|
312
|
-
fragment (pb) {
|
|
313
|
-
this.$outputs.color = pb.vec4();
|
|
314
|
-
pb.main(function() {
|
|
315
|
-
this.$l.motionVector = pb.mul(pb.sub(pb.div(this.$inputs.currentPos.xy, this.$inputs.currentPos.w), pb.div(this.$inputs.prevPos.xy, this.$inputs.prevPos.w)), 0.5);
|
|
316
|
-
this.$outputs.color = pb.vec4(this.motionVector, 0, 1);
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
return this._skyMotionVectorProgram;
|
|
322
|
-
}
|
|
323
|
-
static _getBox(_ctx) {
|
|
324
|
-
if (!this._box) {
|
|
325
|
-
this._box = new BoxShape({
|
|
326
|
-
size: 2,
|
|
327
|
-
needNormal: false,
|
|
328
|
-
needUV: false
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
return this._box;
|
|
332
|
-
}
|
|
333
|
-
/** @internal */ static renderSkyMotionVectors(ctx) {
|
|
334
|
-
if (!ctx.motionVectorTexture) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 0, 0, ctx.motionVectorTexture, ctx.depthTexture);
|
|
338
|
-
const program = this._getSkyMotionVectorProgram(ctx);
|
|
339
|
-
if (!this._skyMotionVectorBindGroup) {
|
|
340
|
-
this._skyMotionVectorBindGroup = ctx.device.createBindGroup(program.bindGroupLayouts[0]);
|
|
341
|
-
}
|
|
342
|
-
const box = this._getBox(ctx);
|
|
343
|
-
this._skyMotionVectorBindGroup.setValue('VPMatrix', ctx.camera.viewProjectionMatrix);
|
|
344
|
-
this._skyMotionVectorBindGroup.setValue('prevVPMatrix', ctx.camera.prevVPMatrix);
|
|
345
|
-
this._skyMotionVectorBindGroup.setValue('cameraPos', ctx.camera.getWorldPosition());
|
|
346
|
-
this._skyMotionVectorBindGroup.setValue('prevCameraPos', ctx.camera.prevPosition);
|
|
347
|
-
ctx.device.pushDeviceStates();
|
|
348
|
-
ctx.device.setProgram(program);
|
|
349
|
-
ctx.device.setBindGroup(0, this._skyMotionVectorBindGroup);
|
|
350
|
-
ctx.device.setRenderStates(AbstractPostEffect.getDefaultRenderState(ctx, 'le'));
|
|
351
|
-
ctx.device.setFramebuffer(fb);
|
|
352
|
-
box.draw();
|
|
353
|
-
ctx.device.popDeviceStates();
|
|
354
|
-
ctx.device.pool.releaseFrameBuffer(fb);
|
|
355
|
-
}
|
|
356
|
-
/** @internal */ static renderShadowMaps(ctx, lights) {
|
|
357
|
-
ctx.renderPass = this._shadowMapPass;
|
|
358
|
-
ctx.device.pushDeviceStates();
|
|
359
|
-
for (const light of lights){
|
|
360
|
-
light.shadow.render(ctx, this._shadowMapPass);
|
|
361
|
-
}
|
|
362
|
-
ctx.device.popDeviceStates();
|
|
363
|
-
}
|
|
364
|
-
/** @internal */ static decodeNormalizedFloat(rgba) {
|
|
365
|
-
const a = rgba[0] / 255;
|
|
366
|
-
const b = rgba[1] / 255;
|
|
367
|
-
const c = rgba[2] / 255;
|
|
368
|
-
const d = rgba[3] / 255;
|
|
369
|
-
return a / (256 * 256 * 256) + b / (256 * 256) + c / 256 + d;
|
|
370
|
-
}
|
|
371
|
-
/** @internal */ static renderObjectColors(ctx, pickResolveFunc, renderQueue) {
|
|
372
|
-
const camera = ctx.camera;
|
|
373
|
-
const isWebGL1 = ctx.device.type === 'webgl';
|
|
374
|
-
ctx.renderPass = this._objectColorPass;
|
|
375
|
-
ctx.device.pushDeviceStates();
|
|
376
|
-
const fb = ctx.device.pool.fetchTemporalFramebuffer(false, 1, 1, isWebGL1 ? [
|
|
377
|
-
'rgba8unorm',
|
|
378
|
-
'rgba8unorm'
|
|
379
|
-
] : [
|
|
380
|
-
'rgba8unorm',
|
|
381
|
-
'rgba32f'
|
|
382
|
-
], ctx.depthFormat, false);
|
|
383
|
-
ctx.device.setViewport(camera.viewport);
|
|
384
|
-
const vp = ctx.device.getViewport();
|
|
385
|
-
const windowX = camera.getPickPosX() / vp.width;
|
|
386
|
-
const windowY = (vp.height - camera.getPickPosY() - 1) / vp.height;
|
|
387
|
-
const windowW = 1 / vp.width;
|
|
388
|
-
const windowH = 1 / vp.height;
|
|
389
|
-
camera.worldMatrix.decompose(this._pickCamera.scale, this._pickCamera.rotation, this._pickCamera.position);
|
|
390
|
-
let left = camera.getProjectionMatrix().getLeftPlane();
|
|
391
|
-
let right = camera.getProjectionMatrix().getRightPlane();
|
|
392
|
-
let bottom = camera.getProjectionMatrix().getBottomPlane();
|
|
393
|
-
let top = camera.getProjectionMatrix().getTopPlane();
|
|
394
|
-
const near = camera.getProjectionMatrix().getNearPlane();
|
|
395
|
-
const far = camera.getProjectionMatrix().getFarPlane();
|
|
396
|
-
const width = right - left;
|
|
397
|
-
const height = top - bottom;
|
|
398
|
-
left += width * windowX;
|
|
399
|
-
bottom += height * windowY;
|
|
400
|
-
right = left + width * windowW;
|
|
401
|
-
top = bottom + height * windowH;
|
|
402
|
-
this._pickCamera.setProjectionMatrix(camera.isPerspective() ? Matrix4x4.frustum(left, right, bottom, top, near, far) : Matrix4x4.ortho(left, right, bottom, top, near, far));
|
|
403
|
-
const cameraPos = isWebGL1 ? new Vector3(this._pickCamera.position) : null;
|
|
404
|
-
const ray = isWebGL1 ? camera.constructRay(camera.getPickPosX(), camera.getPickPosY()) : null;
|
|
405
|
-
ctx.device.setFramebuffer(fb);
|
|
406
|
-
this._objectColorPass.clearColor = Vector4.zero();
|
|
407
|
-
this._objectColorPass.clearDepth = 1;
|
|
408
|
-
const rq = this._objectColorPass.cullScene(ctx, this._pickCamera);
|
|
409
|
-
ctx.camera = this._pickCamera;
|
|
410
|
-
this._objectColorPass.render(ctx, null, rq);
|
|
411
|
-
ctx.camera = camera;
|
|
412
|
-
ctx.device.popDeviceStates();
|
|
413
|
-
const colorTex = fb.getColorAttachments()[0];
|
|
414
|
-
const distanceTex = fb.getColorAttachments()[1];
|
|
415
|
-
const colorPixels = new Uint8Array(4);
|
|
416
|
-
const distancePixels = isWebGL1 ? new Uint8Array(4) : new Float32Array(4);
|
|
417
|
-
const device = ctx.device;
|
|
418
|
-
let fence;
|
|
419
|
-
if (ctx.device.type === 'webgl') {
|
|
420
|
-
fence = Promise.all([
|
|
421
|
-
ctx.device.runNextFrameAsync(()=>colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels)),
|
|
422
|
-
ctx.device.runNextFrameAsync(()=>distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels))
|
|
423
|
-
]);
|
|
424
|
-
} else {
|
|
425
|
-
fence = Promise.all([
|
|
426
|
-
colorTex.readPixels(0, 0, 1, 1, 0, 0, colorPixels),
|
|
427
|
-
distanceTex.readPixels(0, 0, 1, 1, 0, 0, distancePixels)
|
|
428
|
-
]);
|
|
429
|
-
}
|
|
430
|
-
fence.then(()=>{
|
|
431
|
-
const drawable = renderQueue.getDrawableByColor(colorPixels);
|
|
432
|
-
let d = isWebGL1 ? this.decodeNormalizedFloat(distancePixels) * far : distancePixels[0];
|
|
433
|
-
const intersectedPoint = new Vector3(distancePixels[0], distancePixels[1], distancePixels[2]);
|
|
434
|
-
if (isWebGL1) {
|
|
435
|
-
intersectedPoint.x = cameraPos.x + ray.direction.x * d;
|
|
436
|
-
intersectedPoint.y = cameraPos.y + ray.direction.y * d;
|
|
437
|
-
intersectedPoint.z = cameraPos.z + ray.direction.z * d;
|
|
438
|
-
d = Vector3.distance(intersectedPoint, cameraPos);
|
|
439
|
-
}
|
|
440
|
-
pickResolveFunc(drawable ? {
|
|
441
|
-
distance: d,
|
|
442
|
-
intersectedPoint,
|
|
443
|
-
drawable,
|
|
444
|
-
target: drawable.getPickTarget()
|
|
445
|
-
} : null);
|
|
446
|
-
device.pool.releaseFrameBuffer(fb);
|
|
447
|
-
}).catch((_err)=>{
|
|
448
|
-
camera.getPickResultResolveFunc()?.(null);
|
|
449
|
-
device.pool.releaseFrameBuffer(fb);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
export { SceneRenderer };
|
|
455
|
-
//# sourceMappingURL=renderer.js.map
|