@zephyr3d/scene 0.9.5 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/material/msdf_text.js +3 -3
- package/dist/material/msdf_text.js.map +1 -1
- package/dist/text/font/cff_font.js +890 -0
- package/dist/text/font/cff_font.js.map +1 -0
- package/dist/text/font/font_asset.js +17 -3
- package/dist/text/font/font_asset.js.map +1 -1
- package/package.json +1 -1
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/animation/ik/ik_pole_constraint.js +0 -123
- package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
- package/dist/animation/ik/ik_track.js +0 -96
- package/dist/animation/ik/ik_track.js.map +0 -1
- package/dist/animation/ik_postprocessor.js +0 -71
- package/dist/animation/ik_postprocessor.js.map +0 -1
- package/dist/animation/joint_dynamics/math.js +0 -16
- package/dist/animation/joint_dynamics/math.js.map +0 -1
- package/dist/animation/manual_transform_processor.js +0 -156
- package/dist/animation/manual_transform_processor.js.map +0 -1
- package/dist/animation/skeleton_postprocessor.js +0 -50
- package/dist/animation/skeleton_postprocessor.js.map +0 -1
- package/dist/animation/spring2/collision.js +0 -469
- package/dist/animation/spring2/collision.js.map +0 -1
- package/dist/animation/spring2/constraints.js +0 -329
- package/dist/animation/spring2/constraints.js.map +0 -1
- package/dist/animation/spring2/controller.js +0 -434
- package/dist/animation/spring2/controller.js.map +0 -1
- package/dist/animation/spring2/math.js +0 -16
- package/dist/animation/spring2/math.js.map +0 -1
- package/dist/animation/spring2/solver.js +0 -624
- package/dist/animation/spring2/solver.js.map +0 -1
- package/dist/animation/spring2/spring_system.js +0 -118
- package/dist/animation/spring2/spring_system.js.map +0 -1
- package/dist/animation/spring2/types.js +0 -19
- package/dist/animation/spring2/types.js.map +0 -1
- package/dist/animation/spring_postprocessor.js +0 -54
- package/dist/animation/spring_postprocessor.js.map +0 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +0 -1276
- package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/asset/loaders/gltf/helpers.js +0 -331
- package/dist/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/material/sprite3d.js +0 -301
- package/dist/material/sprite3d.js.map +0 -1
- package/dist/material/sprite3d_std.js +0 -116
- package/dist/material/sprite3d_std.js.map +0 -1
- package/dist/material/sprite3dblueprint.js +0 -235
- package/dist/material/sprite3dblueprint.js.map +0 -1
- package/dist/material/sprite_sdf.js +0 -106
- package/dist/material/sprite_sdf.js.map +0 -1
- package/dist/material/terrainmaterial.js +0 -368
- package/dist/material/terrainmaterial.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/render/deferredlightpass.js +0 -510
- package/dist/render/deferredlightpass.js.map +0 -1
- package/dist/render/deferredshadowlightpass.js +0 -428
- package/dist/render/deferredshadowlightpass.js.map +0 -1
- package/dist/render/gbufferpass.js +0 -50
- package/dist/render/gbufferpass.js.map +0 -1
- package/dist/scene/sdftextsprite.js +0 -322
- package/dist/scene/sdftextsprite.js.map +0 -1
- package/dist/scene/sprite3d.js +0 -18
- package/dist/scene/sprite3d.js.map +0 -1
- package/dist/scene/terrain/grass.js +0 -280
- package/dist/scene/terrain/grass.js.map +0 -1
- package/dist/scene/terrain/heightfield.js +0 -475
- package/dist/scene/terrain/heightfield.js.map +0 -1
- package/dist/scene/terrain/patch.js +0 -532
- package/dist/scene/terrain/patch.js.map +0 -1
- package/dist/scene/terrain/quadtree.js +0 -461
- package/dist/scene/terrain/quadtree.js.map +0 -1
- package/dist/scene/terrain/terrain.js +0 -231
- package/dist/scene/terrain/terrain.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
- package/dist/utility/serialization/scene/cloth_script.js +0 -834
- package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
- package/dist/utility/serialization/scene/spring_script.js +0 -596
- package/dist/utility/serialization/scene/spring_script.js.map +0 -1
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Interpolator, Vector3 } from '@zephyr3d/base';
|
|
2
|
-
import { AnimationTrack } from './animationtrack.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Scale animation track
|
|
6
|
-
* @public
|
|
7
|
-
*/ class NodeScaleTrack extends AnimationTrack {
|
|
8
|
-
_state;
|
|
9
|
-
_interpolator;
|
|
10
|
-
constructor(modeOrInterpolator, keyFramesOrEmbedded, embedded){
|
|
11
|
-
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
|
-
if (modeOrInterpolator.target !== 'vec3') {
|
|
13
|
-
throw new Error(`ScaleTrack(): interpolator target must be 'vec3'`);
|
|
14
|
-
}
|
|
15
|
-
super(keyFramesOrEmbedded ?? false);
|
|
16
|
-
this._interpolator = modeOrInterpolator;
|
|
17
|
-
} else {
|
|
18
|
-
const keyFrames = keyFramesOrEmbedded;
|
|
19
|
-
const inputs = new Float32Array(keyFrames.map((val)=>val.time));
|
|
20
|
-
const outputs = new Float32Array(keyFrames.length * 3);
|
|
21
|
-
for(let i = 0; i < keyFrames.length; i++){
|
|
22
|
-
outputs[i * 3 + 0] = keyFrames[i].value.x;
|
|
23
|
-
outputs[i * 3 + 1] = keyFrames[i].value.y;
|
|
24
|
-
outputs[i * 3 + 2] = keyFrames[i].value.z;
|
|
25
|
-
}
|
|
26
|
-
super(embedded ?? false);
|
|
27
|
-
this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
28
|
-
}
|
|
29
|
-
this._state = new Vector3();
|
|
30
|
-
}
|
|
31
|
-
calculateState(target, currentTime) {
|
|
32
|
-
this._interpolator.interpolate(currentTime, this._state);
|
|
33
|
-
return this._state;
|
|
34
|
-
}
|
|
35
|
-
applyState(node, state) {
|
|
36
|
-
node.scale.set(state);
|
|
37
|
-
}
|
|
38
|
-
mixState(a, b, t) {
|
|
39
|
-
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
40
|
-
}
|
|
41
|
-
getBlendId() {
|
|
42
|
-
return 'node-scale';
|
|
43
|
-
}
|
|
44
|
-
getDuration() {
|
|
45
|
-
return this._interpolator.maxTime;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { NodeScaleTrack };
|
|
50
|
-
//# sourceMappingURL=scaletrack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scaletrack.js","sources":["../../../src/animation/scaletrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Scale animation track\r\n * @public\r\n */\r\nexport class NodeScaleTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private readonly _interpolator: Interpolator;\r\n /**\r\n * Create an instance of ScaleTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of ScaleTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`ScaleTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n }\r\n calculateState(target: object, currentTime: number): Vector3 {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.scale.set(state);\r\n }\r\n mixState(a: Vector3, b: Vector3, t: number): Vector3 {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n getBlendId(): unknown {\r\n return 'node-scale';\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeScaleTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","calculateState","currentTime","interpolate","applyState","node","state","scale","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,cAAuBC,SAAAA,cAAAA,CAAAA;IACjBC,MAAgB;IAChBC,aAA4B;AAc7C,IAAA,WAAA,CACEC,kBAAqD,EACrDC,mBAAkE,EAClEC,QAAkB,CAClB;AACA,QAAA,IAAIF,8BAA8BG,YAAc,EAAA;YAC9C,IAAIH,kBAAAA,CAAmBI,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,gDAAgD,CAAC,CAAA;AACpE;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACN,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMM,SAAYL,GAAAA,mBAAAA;YAClB,MAAMM,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,IAAI,CAAA,CAAA;AAC/D,YAAA,MAAMC,OAAU,GAAA,IAAIJ,YAAaF,CAAAA,SAAAA,CAAUO,MAAM,GAAG,CAAA,CAAA;AACpD,YAAA,IAAK,IAAIC,CAAI,GAAA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AAC,GAAGa,CAAAA,IAAKD,CAAEZ,CAAAA,CAAC,GAAGW,CAAAA,CAAEX,CAAC,CAADA,CAAAA;AACtF;IACAc,UAAsB,GAAA;QACpB,OAAO,YAAA;AACT;IACAC,WAAsB,GAAA;AACpB,QAAA,OAAO,IAAI,CAAClC,aAAa,CAACmC,OAAO;AACnC;AACF;;;;"}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { Vector3, Matrix4x4, nextPowerOf2 } from '@zephyr3d/base';
|
|
2
|
-
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
-
import { Application } from '../app/app.js';
|
|
4
|
-
|
|
5
|
-
const tmpV0 = new Vector3();
|
|
6
|
-
const tmpV1 = new Vector3();
|
|
7
|
-
const tmpV2 = new Vector3();
|
|
8
|
-
const tmpV3 = new Vector3();
|
|
9
|
-
/**
|
|
10
|
-
* Skeleton for skinned animation
|
|
11
|
-
* @public
|
|
12
|
-
*/ class Skeleton {
|
|
13
|
-
/** @internal */ _meshes;
|
|
14
|
-
/** @internal */ _joints;
|
|
15
|
-
/** @internal */ _inverseBindMatrices;
|
|
16
|
-
/** @internal */ _bindPoseMatrices;
|
|
17
|
-
/** @internal */ _jointMatrices;
|
|
18
|
-
/** @internal */ _jointOffsets;
|
|
19
|
-
/** @internal */ _jointMatrixArray;
|
|
20
|
-
/** @internal */ _jointTexture;
|
|
21
|
-
/**
|
|
22
|
-
* Creates an instance of skeleton
|
|
23
|
-
* @param joints - The joint nodes
|
|
24
|
-
* @param inverseBindMatrices - The inverse binding matrices of the joints
|
|
25
|
-
* @param bindPoseMatrices - The binding pose matrices of the joints
|
|
26
|
-
*/ constructor(joints, inverseBindMatrices, bindPoseMatrices, meshes, bounding){
|
|
27
|
-
this._joints = joints;
|
|
28
|
-
this._inverseBindMatrices = inverseBindMatrices;
|
|
29
|
-
this._bindPoseMatrices = bindPoseMatrices;
|
|
30
|
-
this._jointMatrixArray = null;
|
|
31
|
-
this._jointMatrices = null;
|
|
32
|
-
this._jointOffsets = null;
|
|
33
|
-
this._jointTexture = null;
|
|
34
|
-
this.updateJointMatrices();
|
|
35
|
-
this._meshes = meshes.map((mesh, index)=>{
|
|
36
|
-
return {
|
|
37
|
-
mesh,
|
|
38
|
-
bounding: this.getBoundingInfo(bounding[index]),
|
|
39
|
-
box: new BoundingBox()
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Disposes self
|
|
45
|
-
*/ dispose() {
|
|
46
|
-
this._jointTexture?.dispose();
|
|
47
|
-
this._jointTexture = null;
|
|
48
|
-
this._joints = null;
|
|
49
|
-
this._inverseBindMatrices = null;
|
|
50
|
-
this._bindPoseMatrices = null;
|
|
51
|
-
this._jointMatrices = null;
|
|
52
|
-
this._jointMatrixArray = null;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* The texture that contains the transform matrices of all the joints
|
|
56
|
-
*/ get jointTexture() {
|
|
57
|
-
return this._jointTexture;
|
|
58
|
-
}
|
|
59
|
-
/** @internal */ updateJointMatrices(jointTransforms, worldMatrix) {
|
|
60
|
-
if (!this._jointTexture) {
|
|
61
|
-
this._createJointTexture();
|
|
62
|
-
}
|
|
63
|
-
if (this._jointOffsets[0] === 0) {
|
|
64
|
-
this._jointOffsets[0] = 1;
|
|
65
|
-
this._jointOffsets[1] = 1;
|
|
66
|
-
} else {
|
|
67
|
-
this._jointOffsets[1] = this._jointOffsets[0];
|
|
68
|
-
this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;
|
|
69
|
-
}
|
|
70
|
-
for(let i = 0; i < this._joints.length; i++){
|
|
71
|
-
const mat = this._jointMatrices[i + this._jointOffsets[0] - 1];
|
|
72
|
-
const jointTransform = jointTransforms ? jointTransforms[i] : this._joints[i].worldMatrix;
|
|
73
|
-
if (worldMatrix) {
|
|
74
|
-
Matrix4x4.multiplyAffine(worldMatrix, jointTransform, jointTransform);
|
|
75
|
-
}
|
|
76
|
-
Matrix4x4.multiply(jointTransform, this._inverseBindMatrices[i], mat);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** @internal */ computeBindPose(model) {
|
|
80
|
-
this.updateJointMatrices(this._bindPoseMatrices, model.worldMatrix);
|
|
81
|
-
this._jointOffsets[1] = this._jointOffsets[0];
|
|
82
|
-
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
83
|
-
}
|
|
84
|
-
/** @internal */ computeJoints() {
|
|
85
|
-
this.updateJointMatrices();
|
|
86
|
-
this._jointTexture.update(this._jointMatrixArray, 0, 0, this._jointTexture.width, this._jointTexture.height);
|
|
87
|
-
}
|
|
88
|
-
/** @internal */ apply() {
|
|
89
|
-
this.computeJoints();
|
|
90
|
-
for (const mesh of this._meshes){
|
|
91
|
-
this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);
|
|
92
|
-
mesh.mesh.setBoneMatrices(this.jointTexture);
|
|
93
|
-
mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/** @internal */ reset() {
|
|
97
|
-
for (const mesh of this._meshes){
|
|
98
|
-
mesh.mesh.setBoneMatrices(null);
|
|
99
|
-
mesh.mesh.setAnimatedBoundingBox(null);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/** @internal */ computeBoundingBox(info, invWorldMatrix) {
|
|
103
|
-
info.boundingBox.beginExtend();
|
|
104
|
-
for(let i = 0; i < info.boundingVertices.length; i++){
|
|
105
|
-
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV0).scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);
|
|
106
|
-
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV1).scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);
|
|
107
|
-
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV2).scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);
|
|
108
|
-
this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1].transformPointAffine(info.boundingVertices[i], tmpV3).scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);
|
|
109
|
-
tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);
|
|
110
|
-
invWorldMatrix.transformPointAffine(tmpV0, tmpV0);
|
|
111
|
-
info.boundingBox.extend(tmpV0);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/** @internal */ _createJointTexture() {
|
|
115
|
-
const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));
|
|
116
|
-
const device = Application.instance.device;
|
|
117
|
-
this._jointTexture = device.createTexture2D('rgba32f', textureWidth, textureWidth, {
|
|
118
|
-
samplerOptions: {
|
|
119
|
-
magFilter: 'nearest',
|
|
120
|
-
minFilter: 'nearest',
|
|
121
|
-
mipFilter: 'none'
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);
|
|
125
|
-
const buffer = this._jointMatrixArray.buffer;
|
|
126
|
-
this._jointOffsets = new Float32Array(buffer);
|
|
127
|
-
this._jointOffsets[0] = 0;
|
|
128
|
-
this._jointOffsets[1] = 0;
|
|
129
|
-
this._jointMatrices = Array.from({
|
|
130
|
-
length: this._joints.length * 2
|
|
131
|
-
}).map((val, index)=>new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT));
|
|
132
|
-
}
|
|
133
|
-
/** @internal */ getBoundingInfo(meshData) {
|
|
134
|
-
const indices = [
|
|
135
|
-
0,
|
|
136
|
-
0,
|
|
137
|
-
0,
|
|
138
|
-
0,
|
|
139
|
-
0,
|
|
140
|
-
0
|
|
141
|
-
];
|
|
142
|
-
let minx = Number.MAX_VALUE;
|
|
143
|
-
let maxx = -Number.MAX_VALUE;
|
|
144
|
-
let miny = Number.MAX_VALUE;
|
|
145
|
-
let maxy = -Number.MAX_VALUE;
|
|
146
|
-
let minz = Number.MAX_VALUE;
|
|
147
|
-
let maxz = -Number.MAX_VALUE;
|
|
148
|
-
const v = meshData.rawPositions;
|
|
149
|
-
const vert = new Vector3();
|
|
150
|
-
const tmpV0 = new Vector3();
|
|
151
|
-
const tmpV1 = new Vector3();
|
|
152
|
-
const tmpV2 = new Vector3();
|
|
153
|
-
const tmpV3 = new Vector3();
|
|
154
|
-
const numVertices = Math.floor(v.length / 3);
|
|
155
|
-
for(let i = 0; i < numVertices; i++){
|
|
156
|
-
vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);
|
|
157
|
-
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV0).scaleBy(meshData.rawJointWeights[i * 4 + 0]);
|
|
158
|
-
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV1).scaleBy(meshData.rawJointWeights[i * 4 + 1]);
|
|
159
|
-
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV2).scaleBy(meshData.rawJointWeights[i * 4 + 2]);
|
|
160
|
-
this._jointMatrices[meshData.rawBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1].transformPointAffine(vert, tmpV3).scaleBy(meshData.rawJointWeights[i * 4 + 3]);
|
|
161
|
-
tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);
|
|
162
|
-
if (tmpV0.x < minx) {
|
|
163
|
-
minx = tmpV0.x;
|
|
164
|
-
indices[0] = i;
|
|
165
|
-
}
|
|
166
|
-
if (tmpV0.x > maxx) {
|
|
167
|
-
maxx = tmpV0.x;
|
|
168
|
-
indices[1] = i;
|
|
169
|
-
}
|
|
170
|
-
if (tmpV0.y < miny) {
|
|
171
|
-
miny = tmpV0.y;
|
|
172
|
-
indices[2] = i;
|
|
173
|
-
}
|
|
174
|
-
if (tmpV0.y > maxy) {
|
|
175
|
-
maxy = tmpV0.y;
|
|
176
|
-
indices[3] = i;
|
|
177
|
-
}
|
|
178
|
-
if (tmpV0.z < minz) {
|
|
179
|
-
minz = tmpV0.z;
|
|
180
|
-
indices[4] = i;
|
|
181
|
-
}
|
|
182
|
-
if (tmpV0.z > maxz) {
|
|
183
|
-
maxz = tmpV0.z;
|
|
184
|
-
indices[5] = i;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const info = {
|
|
188
|
-
boundingVertexBlendIndices: new Float32Array(Array.from({
|
|
189
|
-
length: 6 * 4
|
|
190
|
-
}).map((val, index)=>meshData.rawBlendIndices[indices[index >> 2] * 4 + index % 4])),
|
|
191
|
-
boundingVertexJointWeights: new Float32Array(Array.from({
|
|
192
|
-
length: 6 * 4
|
|
193
|
-
}).map((val, index)=>meshData.rawJointWeights[indices[index >> 2] * 4 + index % 4])),
|
|
194
|
-
boundingVertices: Array.from({
|
|
195
|
-
length: 6
|
|
196
|
-
}).map((val, index)=>new Vector3(meshData.rawPositions[indices[index] * 3], meshData.rawPositions[indices[index] * 3 + 1], meshData.rawPositions[indices[index] * 3 + 2])),
|
|
197
|
-
boundingBox: new BoundingBox()
|
|
198
|
-
};
|
|
199
|
-
return info;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export { Skeleton };
|
|
204
|
-
//# sourceMappingURL=skeleton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton.js","sources":["../../../src/animation/skeleton.ts"],"sourcesContent":["import { Matrix4x4, Vector3, nextPowerOf2 } from '@zephyr3d/base';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { SceneNode } from '../scene/scene_node';\r\nimport type { Mesh } from '../scene';\r\nimport { BoundingBox } from '../utility/bounding_volume';\r\nimport type { AssetSubMeshData } from '../asset';\r\nimport { Application } from '../app/app';\r\n\r\ninterface SkinnedBoundingBox {\r\n boundingVertices: Vector3[];\r\n boundingVertexBlendIndices: Float32Array;\r\n boundingVertexJointWeights: Float32Array;\r\n boundingBox: BoundingBox;\r\n}\r\n\r\nconst tmpV0 = new Vector3();\r\nconst tmpV1 = new Vector3();\r\nconst tmpV2 = new Vector3();\r\nconst tmpV3 = new Vector3();\r\n\r\n/**\r\n * Skeleton for skinned animation\r\n * @public\r\n */\r\nexport class Skeleton {\r\n /** @internal */\r\n protected _meshes: { mesh: Mesh; bounding: SkinnedBoundingBox; box: BoundingBox }[];\r\n /** @internal */\r\n protected _joints: SceneNode[];\r\n /** @internal */\r\n protected _inverseBindMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _bindPoseMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _jointMatrices: Matrix4x4[];\r\n /** @internal */\r\n protected _jointOffsets: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointMatrixArray: Float32Array<ArrayBuffer>;\r\n /** @internal */\r\n protected _jointTexture: Texture2D;\r\n /**\r\n * Creates an instance of skeleton\r\n * @param joints - The joint nodes\r\n * @param inverseBindMatrices - The inverse binding matrices of the joints\r\n * @param bindPoseMatrices - The binding pose matrices of the joints\r\n */\r\n constructor(\r\n joints: SceneNode[],\r\n inverseBindMatrices: Matrix4x4[],\r\n bindPoseMatrices: Matrix4x4[],\r\n meshes: Mesh[],\r\n bounding: AssetSubMeshData[]\r\n ) {\r\n this._joints = joints;\r\n this._inverseBindMatrices = inverseBindMatrices;\r\n this._bindPoseMatrices = bindPoseMatrices;\r\n this._jointMatrixArray = null;\r\n this._jointMatrices = null;\r\n this._jointOffsets = null;\r\n this._jointTexture = null;\r\n this.updateJointMatrices();\r\n this._meshes = meshes.map((mesh, index) => {\r\n return {\r\n mesh,\r\n bounding: this.getBoundingInfo(bounding[index]),\r\n box: new BoundingBox()\r\n };\r\n });\r\n }\r\n /**\r\n * Disposes self\r\n */\r\n dispose() {\r\n this._jointTexture?.dispose();\r\n this._jointTexture = null;\r\n this._joints = null;\r\n this._inverseBindMatrices = null;\r\n this._bindPoseMatrices = null;\r\n this._jointMatrices = null;\r\n this._jointMatrixArray = null;\r\n }\r\n /**\r\n * The texture that contains the transform matrices of all the joints\r\n */\r\n get jointTexture(): Texture2D {\r\n return this._jointTexture;\r\n }\r\n /** @internal */\r\n updateJointMatrices(jointTransforms?: Matrix4x4[], worldMatrix?: Matrix4x4) {\r\n if (!this._jointTexture) {\r\n this._createJointTexture();\r\n }\r\n if (this._jointOffsets[0] === 0) {\r\n this._jointOffsets[0] = 1;\r\n this._jointOffsets[1] = 1;\r\n } else {\r\n this._jointOffsets[1] = this._jointOffsets[0];\r\n this._jointOffsets[0] = this._joints.length - this._jointOffsets[0] + 2;\r\n }\r\n for (let i = 0; i < this._joints.length; i++) {\r\n const mat = this._jointMatrices[i + this._jointOffsets[0] - 1];\r\n const jointTransform = jointTransforms ? jointTransforms[i] : this._joints[i].worldMatrix;\r\n if (worldMatrix) {\r\n Matrix4x4.multiplyAffine(worldMatrix, jointTransform, jointTransform);\r\n }\r\n Matrix4x4.multiply(jointTransform, this._inverseBindMatrices[i], mat);\r\n }\r\n }\r\n /** @internal */\r\n computeBindPose(model: SceneNode) {\r\n this.updateJointMatrices(this._bindPoseMatrices, model.worldMatrix);\r\n this._jointOffsets[1] = this._jointOffsets[0];\r\n this._jointTexture.update(\r\n this._jointMatrixArray,\r\n 0,\r\n 0,\r\n this._jointTexture.width,\r\n this._jointTexture.height\r\n );\r\n }\r\n /** @internal */\r\n computeJoints() {\r\n this.updateJointMatrices();\r\n this._jointTexture.update(\r\n this._jointMatrixArray,\r\n 0,\r\n 0,\r\n this._jointTexture.width,\r\n this._jointTexture.height\r\n );\r\n }\r\n /** @internal */\r\n apply() {\r\n this.computeJoints();\r\n for (const mesh of this._meshes) {\r\n this.computeBoundingBox(mesh.bounding, mesh.mesh.invWorldMatrix);\r\n mesh.mesh.setBoneMatrices(this.jointTexture);\r\n mesh.mesh.setAnimatedBoundingBox(mesh.bounding.boundingBox);\r\n }\r\n }\r\n /** @internal */\r\n reset() {\r\n for (const mesh of this._meshes) {\r\n mesh.mesh.setBoneMatrices(null);\r\n mesh.mesh.setAnimatedBoundingBox(null);\r\n }\r\n }\r\n /** @internal */\r\n computeBoundingBox(info: SkinnedBoundingBox, invWorldMatrix: Matrix4x4) {\r\n info.boundingBox.beginExtend();\r\n for (let i = 0; i < info.boundingVertices.length; i++) {\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV0)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 0]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV1)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 1]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV2)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 2]);\r\n this._jointMatrices[info.boundingVertexBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(info.boundingVertices[i], tmpV3)\r\n .scaleBy(info.boundingVertexJointWeights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n invWorldMatrix.transformPointAffine(tmpV0, tmpV0);\r\n info.boundingBox.extend(tmpV0);\r\n }\r\n }\r\n /** @internal */\r\n private _createJointTexture() {\r\n const textureWidth = nextPowerOf2(Math.max(4, Math.ceil(Math.sqrt((this._joints.length * 2 + 1) * 4))));\r\n const device = Application.instance.device;\r\n this._jointTexture = device.createTexture2D('rgba32f', textureWidth, textureWidth, {\r\n samplerOptions: {\r\n magFilter: 'nearest',\r\n minFilter: 'nearest',\r\n mipFilter: 'none'\r\n }\r\n });\r\n this._jointMatrixArray = new Float32Array(textureWidth * textureWidth * 4);\r\n const buffer = this._jointMatrixArray.buffer;\r\n this._jointOffsets = new Float32Array(buffer);\r\n this._jointOffsets[0] = 0;\r\n this._jointOffsets[1] = 0;\r\n this._jointMatrices = Array.from({ length: this._joints.length * 2 }).map(\r\n (val, index) => new Matrix4x4(buffer, (index + 1) * 16 * Float32Array.BYTES_PER_ELEMENT)\r\n );\r\n }\r\n /** @internal */\r\n private getBoundingInfo(meshData: AssetSubMeshData): SkinnedBoundingBox {\r\n const indices = [0, 0, 0, 0, 0, 0];\r\n let minx = Number.MAX_VALUE;\r\n let maxx = -Number.MAX_VALUE;\r\n let miny = Number.MAX_VALUE;\r\n let maxy = -Number.MAX_VALUE;\r\n let minz = Number.MAX_VALUE;\r\n let maxz = -Number.MAX_VALUE;\r\n const v = meshData.rawPositions;\r\n const vert = new Vector3();\r\n const tmpV0 = new Vector3();\r\n const tmpV1 = new Vector3();\r\n const tmpV2 = new Vector3();\r\n const tmpV3 = new Vector3();\r\n const numVertices = Math.floor(v.length / 3);\r\n for (let i = 0; i < numVertices; i++) {\r\n vert.setXYZ(v[i * 3], v[i * 3 + 1], v[i * 3 + 2]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 0] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV0)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 0]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 1] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV1)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 1]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 2] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV2)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 2]);\r\n this._jointMatrices[meshData.rawBlendIndices[i * 4 + 3] + this._jointOffsets[0] - 1]\r\n .transformPointAffine(vert, tmpV3)\r\n .scaleBy(meshData.rawJointWeights[i * 4 + 3]);\r\n tmpV0.addBy(tmpV1).addBy(tmpV2).addBy(tmpV3);\r\n if (tmpV0.x < minx) {\r\n minx = tmpV0.x;\r\n indices[0] = i;\r\n }\r\n if (tmpV0.x > maxx) {\r\n maxx = tmpV0.x;\r\n indices[1] = i;\r\n }\r\n if (tmpV0.y < miny) {\r\n miny = tmpV0.y;\r\n indices[2] = i;\r\n }\r\n if (tmpV0.y > maxy) {\r\n maxy = tmpV0.y;\r\n indices[3] = i;\r\n }\r\n if (tmpV0.z < minz) {\r\n minz = tmpV0.z;\r\n indices[4] = i;\r\n }\r\n if (tmpV0.z > maxz) {\r\n maxz = tmpV0.z;\r\n indices[5] = i;\r\n }\r\n }\r\n const info: SkinnedBoundingBox = {\r\n boundingVertexBlendIndices: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map(\r\n (val, index) => meshData.rawBlendIndices[indices[index >> 2] * 4 + (index % 4)]\r\n )\r\n ),\r\n boundingVertexJointWeights: new Float32Array(\r\n Array.from({ length: 6 * 4 }).map(\r\n (val, index) => meshData.rawJointWeights[indices[index >> 2] * 4 + (index % 4)]\r\n )\r\n ),\r\n boundingVertices: Array.from({ length: 6 }).map(\r\n (val, index) =>\r\n new Vector3(\r\n meshData.rawPositions[indices[index] * 3],\r\n meshData.rawPositions[indices[index] * 3 + 1],\r\n meshData.rawPositions[indices[index] * 3 + 2]\r\n )\r\n ),\r\n boundingBox: new BoundingBox()\r\n };\r\n return info;\r\n }\r\n}\r\n"],"names":["tmpV0","Vector3","tmpV1","tmpV2","tmpV3","Skeleton","joints","inverseBindMatrices","bindPoseMatrices","meshes","bounding","_joints","_inverseBindMatrices","_bindPoseMatrices","_jointMatrixArray","_jointMatrices","_jointOffsets","_jointTexture","updateJointMatrices","_meshes","map","mesh","index","getBoundingInfo","box","BoundingBox","dispose","jointTexture","jointTransforms","worldMatrix","_createJointTexture","length","i","mat","jointTransform","Matrix4x4","multiplyAffine","multiply","computeBindPose","model","update","width","height","computeJoints","apply","computeBoundingBox","invWorldMatrix","setBoneMatrices","setAnimatedBoundingBox","boundingBox","reset","info","beginExtend","boundingVertices","boundingVertexBlendIndices","transformPointAffine","scaleBy","boundingVertexJointWeights","addBy","extend","textureWidth","nextPowerOf2","Math","max","ceil","sqrt","device","Application","instance","createTexture2D","samplerOptions","magFilter","minFilter","mipFilter","Float32Array","buffer","Array","from","val","BYTES_PER_ELEMENT","meshData","indices","minx","Number","MAX_VALUE","maxx","miny","maxy","minz","maxz","v","rawPositions","vert","numVertices","floor","setXYZ","rawBlendIndices","rawJointWeights","x","y","z"],"mappings":";;;;AAeA,MAAMA,QAAQ,IAAIC,OAAAA,EAAAA;AAClB,MAAMC,QAAQ,IAAID,OAAAA,EAAAA;AAClB,MAAME,QAAQ,IAAIF,OAAAA,EAAAA;AAClB,MAAMG,QAAQ,IAAIH,OAAAA,EAAAA;AAElB;;;AAGC,IACM,MAAMI,QAAAA,CAAAA;qBAEX,OAAoF;qBAEpF,OAA+B;qBAE/B,oBAA4C;qBAE5C,iBAAyC;qBAEzC,cAAsC;qBAEtC,aAAmD;qBAEnD,iBAAuD;qBAEvD,aAAmC;AACnC;;;;;MAMA,WAAA,CACEC,MAAmB,EACnBC,mBAAgC,EAChCC,gBAA6B,EAC7BC,MAAc,EACdC,QAA4B,CAC5B;QACA,IAAI,CAACC,OAAO,GAAGL,MAAAA;QACf,IAAI,CAACM,oBAAoB,GAAGL,mBAAAA;QAC5B,IAAI,CAACM,iBAAiB,GAAGL,gBAAAA;QACzB,IAAI,CAACM,iBAAiB,GAAG,IAAA;QACzB,IAAI,CAACC,cAAc,GAAG,IAAA;QACtB,IAAI,CAACC,aAAa,GAAG,IAAA;QACrB,IAAI,CAACC,aAAa,GAAG,IAAA;AACrB,QAAA,IAAI,CAACC,mB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AAC3D,KAAS,IAAA,CAAA,CAAE,GAAG,CAAA,GAAKA,QAAQ,CAAG,CAAA,CAAA,CAAA;AAGnFmC,YAAAA,0BAAAA,EAA4B,IAAIiB,YAAAA,CAC9BE,KAAMC,CAAAA,IAAI,CAAC;AAAE9C,gBAAAA,MAAAA,EAAQ,CAAI,GAAA;AAAE,aAAA,CAAA,CAAGX,GAAG,CAC/B,CAAC0D,GAAAA,EAAKxD,QAAU0D,QAASiB,CAAAA,eAAe,CAAChB,OAAO,CAAC3D,KAAS,IAAA,CAAA,CAAE,GAAG,CAAA,GAAKA,QAAQ,CAAG,CAAA,CAAA,CAAA;YAGnF+B,gBAAkBuB,EAAAA,KAAAA,CAAMC,IAAI,CAAC;gBAAE9C,MAAQ,EAAA;AAAE,aAAA,CAAA,CAAGX,GAAG,CAC7C,CAAC0D,GAAAA,EAAKxD,QACJ,IAAIrB,OAAAA,CACF+E,QAASW,CAAAA,YAAY,CAACV,OAAO,CAAC3D,KAAM,CAAA,GAAG,EAAE,EACzC0D,QAAAA,CAASW,YAAY,CAACV,OAAO,CAAC3D,KAAM,CAAA,GAAG,IAAI,CAAE,CAAA,EAC7C0D,QAASW,CAAAA,YAAY,CAACV,OAAO,CAAC3D,KAAM,CAAA,GAAG,IAAI,CAAE,CAAA,CAAA,CAAA;AAGnD2B,YAAAA,WAAAA,EAAa,IAAIxB,WAAAA;AACnB,SAAA;QACA,OAAO0B,IAAAA;AACT;AACF;;;;"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Interpolator, Vector3 } from '@zephyr3d/base';
|
|
2
|
-
import { AnimationTrack } from './animationtrack.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Translate animation track
|
|
6
|
-
* @public
|
|
7
|
-
*/ class NodeTranslationTrack extends AnimationTrack {
|
|
8
|
-
_state;
|
|
9
|
-
_interpolator;
|
|
10
|
-
constructor(modeOrInterpolator, keyFramesOrEmbedded, embedded){
|
|
11
|
-
if (modeOrInterpolator instanceof Interpolator) {
|
|
12
|
-
if (modeOrInterpolator.target !== 'vec3') {
|
|
13
|
-
throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);
|
|
14
|
-
}
|
|
15
|
-
super(keyFramesOrEmbedded ?? false);
|
|
16
|
-
this._interpolator = modeOrInterpolator;
|
|
17
|
-
} else {
|
|
18
|
-
const keyFrames = keyFramesOrEmbedded;
|
|
19
|
-
const inputs = new Float32Array(keyFrames.map((val)=>val.time));
|
|
20
|
-
const outputs = new Float32Array(keyFrames.length * 3);
|
|
21
|
-
for(let i = 0; i < keyFrames.length; i++){
|
|
22
|
-
outputs[i * 3 + 0] = keyFrames[i].value.x;
|
|
23
|
-
outputs[i * 3 + 1] = keyFrames[i].value.y;
|
|
24
|
-
outputs[i * 3 + 2] = keyFrames[i].value.z;
|
|
25
|
-
}
|
|
26
|
-
super(embedded ?? false);
|
|
27
|
-
this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);
|
|
28
|
-
}
|
|
29
|
-
this._state = new Vector3();
|
|
30
|
-
}
|
|
31
|
-
calculateState(target, currentTime) {
|
|
32
|
-
this._interpolator.interpolate(currentTime, this._state);
|
|
33
|
-
return this._state;
|
|
34
|
-
}
|
|
35
|
-
applyState(node, state) {
|
|
36
|
-
node.position.set(state);
|
|
37
|
-
}
|
|
38
|
-
mixState(a, b, t) {
|
|
39
|
-
return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));
|
|
40
|
-
}
|
|
41
|
-
getBlendId() {
|
|
42
|
-
return 'node-translation';
|
|
43
|
-
}
|
|
44
|
-
getDuration() {
|
|
45
|
-
return this._interpolator.maxTime;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export { NodeTranslationTrack };
|
|
50
|
-
//# sourceMappingURL=translationtrack.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translationtrack.js","sources":["../../../src/animation/translationtrack.ts"],"sourcesContent":["import type { InterpolationMode } from '@zephyr3d/base';\r\nimport { Interpolator, Vector3 } from '@zephyr3d/base';\r\nimport { AnimationTrack } from './animationtrack';\r\nimport type { SceneNode } from '../scene';\r\n\r\n/**\r\n * Translate animation track\r\n * @public\r\n */\r\nexport class NodeTranslationTrack extends AnimationTrack<Vector3> {\r\n private readonly _state: Vector3;\r\n private readonly _interpolator: Interpolator;\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param interpolator - Interpolator object that contains the keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(interpolator: Interpolator, embedded?: boolean);\r\n /**\r\n * Create an instance of TranslationTrack from keyframe values\r\n * @param mode - The interpolation mode of keyframes\r\n * @param keyFrames - Keyframe values\r\n * @param embedded - Whether this track be an embedded track\r\n */\r\n constructor(mode: InterpolationMode, keyFrames: { time: number; value: Vector3 }[], embedded?: boolean);\r\n constructor(\r\n modeOrInterpolator?: Interpolator | InterpolationMode,\r\n keyFramesOrEmbedded?: { time: number; value: Vector3 }[] | boolean,\r\n embedded?: boolean\r\n ) {\r\n if (modeOrInterpolator instanceof Interpolator) {\r\n if (modeOrInterpolator.target !== 'vec3') {\r\n throw new Error(`TranslationTrack(): interpolator target must be 'vec3'`);\r\n }\r\n super((keyFramesOrEmbedded as boolean) ?? false);\r\n this._interpolator = modeOrInterpolator;\r\n } else {\r\n const keyFrames = keyFramesOrEmbedded as { time: number; value: Vector3 }[];\r\n const inputs = new Float32Array(keyFrames.map((val) => val.time));\r\n const outputs = new Float32Array(keyFrames.length * 3);\r\n for (let i = 0; i < keyFrames.length; i++) {\r\n outputs[i * 3 + 0] = keyFrames[i].value.x;\r\n outputs[i * 3 + 1] = keyFrames[i].value.y;\r\n outputs[i * 3 + 2] = keyFrames[i].value.z;\r\n }\r\n super(embedded ?? false);\r\n this._interpolator = new Interpolator(modeOrInterpolator, 'vec3', inputs, outputs);\r\n }\r\n this._state = new Vector3();\r\n }\r\n calculateState(target: object, currentTime: number): Vector3 {\r\n this._interpolator.interpolate(currentTime, this._state);\r\n return this._state;\r\n }\r\n applyState(node: SceneNode, state: Vector3) {\r\n node.position.set(state);\r\n }\r\n mixState(a: Vector3, b: Vector3, t: number): Vector3 {\r\n return new Vector3(a.x + t * (b.x - a.x), a.y + t * (b.y - a.y), a.z + t * (b.z - a.z));\r\n }\r\n getBlendId(): unknown {\r\n return 'node-translation';\r\n }\r\n getDuration(): number {\r\n return this._interpolator.maxTime;\r\n }\r\n}\r\n"],"names":["NodeTranslationTrack","AnimationTrack","_state","_interpolator","modeOrInterpolator","keyFramesOrEmbedded","embedded","Interpolator","target","Error","keyFrames","inputs","Float32Array","map","val","time","outputs","length","i","value","x","y","z","Vector3","calculateState","currentTime","interpolate","applyState","node","state","position","set","mixState","a","b","t","getBlendId","getDuration","maxTime"],"mappings":";;;AAKA;;;IAIO,MAAMA,oBAA6BC,SAAAA,cAAAA,CAAAA;IACvBC,MAAgB;IAChBC,aAA4B;AAc7C,IAAA,WAAA,CACEC,kBAAqD,EACrDC,mBAAkE,EAClEC,QAAkB,CAClB;AACA,QAAA,IAAIF,8BAA8BG,YAAc,EAAA;YAC9C,IAAIH,kBAAAA,CAAmBI,MAAM,KAAK,MAAQ,EAAA;AACxC,gBAAA,MAAM,IAAIC,KAAAA,CAAM,CAAC,sDAAsD,CAAC,CAAA;AAC1E;YACA,KAAK,CAAC,mBAAoC,IAAA,KAAA,CAAA;YAC1C,IAAI,CAACN,aAAa,GAAGC,kBAAAA;SAChB,MAAA;AACL,YAAA,MAAMM,SAAYL,GAAAA,mBAAAA;YAClB,MAAMM,MAAAA,GAAS,IAAIC,YAAaF,CAAAA,SAAAA,CAAUG,GAAG,CAAC,CAACC,GAAQA,GAAAA,GAAAA,CAAIC,IAAI,CAAA,CAAA;AAC/D,YAAA,MAAMC,OAAU,GAAA,IAAIJ,YAAaF,CAAAA,SAAAA,CAAUO,MAAM,GAAG,CAAA,CAAA;AACpD,YAAA,IAAK,IAAIC,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EX,CAAAA,CAAC,GAAGa,CAAAA,IAAKD,CAAEZ,CAAAA,CAAC,GAAGW,CAAAA,CAAEX,CAAC,CAADA,CAAAA;AACtF;IACAc,UAAsB,GAAA;QACpB,OAAO,kBAAA;AACT;IACAC,WAAsB,GAAA;AACpB,QAAA,OAAO,IAAI,CAAClC,aAAa,CAACmC,OAAO;AACnC;AACF;;;;"}
|
package/dist/src/app/app.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { Observable, flushPendingDisposals } from '@zephyr3d/base';
|
|
2
|
-
import { InputManager } from './inputmgr.js';
|
|
3
|
-
import { RuntimeManager } from '../../node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Application class
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* This is the entry point of your application.
|
|
10
|
-
* The Application is responsible for initializing the rendering device
|
|
11
|
-
* and doing the rendering loop.
|
|
12
|
-
* The Application can not be created more than once. You can get the
|
|
13
|
-
* instance by calling the 'Application.instance' static method.
|
|
14
|
-
*
|
|
15
|
-
* @public
|
|
16
|
-
*/ class Application extends Observable {
|
|
17
|
-
_options;
|
|
18
|
-
_device;
|
|
19
|
-
_inputManager;
|
|
20
|
-
_runtimeManager;
|
|
21
|
-
_ready;
|
|
22
|
-
_logger;
|
|
23
|
-
static _instance;
|
|
24
|
-
/**
|
|
25
|
-
* Creates an instance of Application
|
|
26
|
-
* @param opt - The creation options
|
|
27
|
-
*/ constructor(opt){
|
|
28
|
-
super();
|
|
29
|
-
if (Application._instance) {
|
|
30
|
-
throw new Error('It is not allowed to have multiple Application instances');
|
|
31
|
-
}
|
|
32
|
-
Application._instance = this;
|
|
33
|
-
this._options = {
|
|
34
|
-
backend: opt.backend,
|
|
35
|
-
enableMSAA: opt.enableMSAA ?? false,
|
|
36
|
-
pixelRatio: opt.pixelRatio ?? window.devicePixelRatio ?? 1,
|
|
37
|
-
canvas: opt.canvas
|
|
38
|
-
};
|
|
39
|
-
this._inputManager = new InputManager(this);
|
|
40
|
-
this._runtimeManager = new RuntimeManager(opt.runtimeOptions.VFS, opt.runtimeOptions.scriptsRoot, opt.runtimeOptions.editorMode, opt.runtimeOptions.enabled);
|
|
41
|
-
this._ready = false;
|
|
42
|
-
this._logger = {
|
|
43
|
-
log (text, mode) {
|
|
44
|
-
if (mode === 'warn') {
|
|
45
|
-
console.warn(text);
|
|
46
|
-
} else if (mode === 'error') {
|
|
47
|
-
console.error(text);
|
|
48
|
-
} else if (mode === 'debug') {
|
|
49
|
-
console.debug(text);
|
|
50
|
-
} else if (mode === 'info') {
|
|
51
|
-
console.info(text);
|
|
52
|
-
} else {
|
|
53
|
-
console.log(text);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/** The input manager instance */ get inputManager() {
|
|
59
|
-
return this._inputManager;
|
|
60
|
-
}
|
|
61
|
-
/** The runtime manager instance */ get runtimeManager() {
|
|
62
|
-
return this._runtimeManager;
|
|
63
|
-
}
|
|
64
|
-
/** The options that was used to create the application */ get options() {
|
|
65
|
-
return this._options;
|
|
66
|
-
}
|
|
67
|
-
/** Gets the singleton instance of the application */ static get instance() {
|
|
68
|
-
return this._instance;
|
|
69
|
-
}
|
|
70
|
-
/** The rendering device that was initialized by the application */ get device() {
|
|
71
|
-
return this._device;
|
|
72
|
-
}
|
|
73
|
-
/** Gets the device type */ get deviceType() {
|
|
74
|
-
return this._options.backend.typeName();
|
|
75
|
-
}
|
|
76
|
-
/** The logger object */ get logger() {
|
|
77
|
-
return this._logger;
|
|
78
|
-
}
|
|
79
|
-
set logger(val) {
|
|
80
|
-
this._logger = val;
|
|
81
|
-
}
|
|
82
|
-
/** Set focus */ focus() {
|
|
83
|
-
this._device.canvas.focus();
|
|
84
|
-
}
|
|
85
|
-
/** Wait until the application is ready. */ async ready() {
|
|
86
|
-
if (!this._ready) {
|
|
87
|
-
this._device = await this._options.backend.createDevice(this._options.canvas, {
|
|
88
|
-
dpr: this._options.pixelRatio,
|
|
89
|
-
msaa: !!this._options.enableMSAA
|
|
90
|
-
});
|
|
91
|
-
if (!this._device) {
|
|
92
|
-
throw new Error('App.init(): create device failed');
|
|
93
|
-
}
|
|
94
|
-
this._device.canvas.focus();
|
|
95
|
-
this._inputManager.start();
|
|
96
|
-
this._device.on('resize', (width, height)=>{
|
|
97
|
-
this.dispatchEvent('resize', width, height);
|
|
98
|
-
});
|
|
99
|
-
this._ready = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/** Render one frame */ frame() {
|
|
103
|
-
// Processes all pending disposals from the previous frame.
|
|
104
|
-
flushPendingDisposals();
|
|
105
|
-
if (this._ready) {
|
|
106
|
-
this.device.setFramebuffer(null);
|
|
107
|
-
this.device.setViewport(null);
|
|
108
|
-
this.device.setScissor(null);
|
|
109
|
-
const dt = this.device.frameInfo.elapsedFrame;
|
|
110
|
-
const elapsed = this.device.frameInfo.elapsedOverall;
|
|
111
|
-
this._runtimeManager.update(dt, elapsed);
|
|
112
|
-
this.dispatchEvent('tick', dt, elapsed);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/** Start running the rendering loop */ run() {
|
|
116
|
-
this.device.runLoop(()=>{
|
|
117
|
-
this.frame();
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
/** Stop running the rendering loop */ stop() {
|
|
121
|
-
this.device.exitLoop();
|
|
122
|
-
}
|
|
123
|
-
/** Message log */ log(text, mode) {
|
|
124
|
-
this._logger?.log(text, mode);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export { Application };
|
|
129
|
-
//# sourceMappingURL=app.js.map
|
package/dist/src/app/app.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sources":["../../../src/app/app.ts"],"sourcesContent":["import { Observable, VFS, flushPendingDisposals } from '@zephyr3d/base';\r\nimport type { AbstractDevice, DeviceBackend } from '@zephyr3d/device';\r\nimport { InputManager } from './inputmgr';\r\nimport { RuntimeManager } from '@zephyr3d/runtime';\r\n\r\ntype appEventMap = {\r\n resize: [width: number, height: number];\r\n tick: [deltaTimeMs: number, elapsedTimeMs: number];\r\n click: [evt: PointerEvent];\r\n dblclick: [evt: PointerEvent];\r\n pointerdown: [evt: PointerEvent];\r\n pointerup: [evt: PointerEvent];\r\n pointermove: [evt: PointerEvent];\r\n pointercancel: [evt: PointerEvent];\r\n pointerenter: [evt: PointerEvent];\r\n pointerleave: [evt: PointerEvent];\r\n pointerover: [evt: PointerEvent];\r\n pointerout: [evt: PointerEvent];\r\n wheel: [evt: WheelEvent];\r\n keydown: [evt: KeyboardEvent];\r\n keyup: [evt: KeyboardEvent];\r\n keypress: [evt: KeyboardEvent];\r\n drag: [evt: DragEvent];\r\n dragenter: [evt: DragEvent];\r\n dragleave: [evt: DragEvent];\r\n dragover: [evt: DragEvent];\r\n dragstart: [evt: DragEvent];\r\n dragend: [evt: DragEvent];\r\n drop: [evt: DragEvent];\r\n};\r\n\r\n/**\r\n * The creation options for Application\r\n * @public\r\n */\r\nexport type AppOptions = {\r\n /** The canvas element */\r\n canvas: HTMLCanvasElement;\r\n /** The backend that will be used to create the rendering device */\r\n backend: DeviceBackend;\r\n /** Whether to enable MSAA */\r\n enableMSAA?: boolean;\r\n /** The device pixel ratio */\r\n pixelRatio?: number;\r\n /** Options for runtime scripting system */\r\n runtimeOptions?: {\r\n /** VFS for reading script files, default is HttpFS at '.' */\r\n VFS?: VFS;\r\n /** Root directory for script files, default is '/' */\r\n scriptsRoot?: string;\r\n /** Whether application is running in editor mode, should always be true for user application */\r\n editorMode?: boolean;\r\n /** Wether enable runtime scripting system, should always be true for user application */\r\n enabled?: boolean;\r\n };\r\n};\r\n\r\n/**\r\n * Log mode\r\n * @public\r\n */\r\nexport type LogMode = 'info' | 'warn' | 'error' | 'debug';\r\n\r\n/**\r\n * Logger interface\r\n * @public\r\n */\r\nexport interface Logger {\r\n log(text: string, mode?: LogMode): void;\r\n}\r\n\r\n/**\r\n * Application class\r\n *\r\n * @remarks\r\n * This is the entry point of your application.\r\n * The Application is responsible for initializing the rendering device\r\n * and doing the rendering loop.\r\n * The Application can not be created more than once. You can get the\r\n * instance by calling the 'Application.instance' static method.\r\n *\r\n * @public\r\n */\r\nexport class Application extends Observable<appEventMap> {\r\n private readonly _options: AppOptions;\r\n private _device: AbstractDevice;\r\n private readonly _inputManager: InputManager;\r\n private readonly _runtimeManager: RuntimeManager;\r\n private _ready: boolean;\r\n private _logger: Logger;\r\n private static _instance: Application;\r\n /**\r\n * Creates an instance of Application\r\n * @param opt - The creation options\r\n */\r\n constructor(opt: Partial<AppOptions>) {\r\n super();\r\n if (Application._instance) {\r\n throw new Error('It is not allowed to have multiple Application instances');\r\n }\r\n Application._instance = this;\r\n this._options = {\r\n backend: opt.backend,\r\n enableMSAA: opt.enableMSAA ?? false,\r\n pixelRatio: opt.pixelRatio ?? window.devicePixelRatio ?? 1,\r\n canvas: opt.canvas\r\n };\r\n this._inputManager = new InputManager(this);\r\n this._runtimeManager = new RuntimeManager(\r\n opt.runtimeOptions.VFS,\r\n opt.runtimeOptions.scriptsRoot,\r\n opt.runtimeOptions.editorMode,\r\n opt.runtimeOptions.enabled\r\n );\r\n this._ready = false;\r\n this._logger = {\r\n log(text: string, mode?: LogMode) {\r\n if (mode === 'warn') {\r\n console.warn(text);\r\n } else if (mode === 'error') {\r\n console.error(text);\r\n } else if (mode === 'debug') {\r\n console.debug(text);\r\n } else if (mode === 'info') {\r\n console.info(text);\r\n } else {\r\n console.log(text);\r\n }\r\n }\r\n };\r\n }\r\n /** The input manager instance */\r\n get inputManager(): InputManager {\r\n return this._inputManager;\r\n }\r\n /** The runtime manager instance */\r\n get runtimeManager(): RuntimeManager {\r\n return this._runtimeManager;\r\n }\r\n /** The options that was used to create the application */\r\n get options(): AppOptions {\r\n return this._options;\r\n }\r\n /** Gets the singleton instance of the application */\r\n static get instance(): Application {\r\n return this._instance;\r\n }\r\n /** The rendering device that was initialized by the application */\r\n get device(): AbstractDevice {\r\n return this._device;\r\n }\r\n /** Gets the device type */\r\n get deviceType(): string {\r\n return this._options.backend.typeName();\r\n }\r\n /** The logger object */\r\n get logger(): Logger {\r\n return this._logger;\r\n }\r\n set logger(val: Logger) {\r\n this._logger = val;\r\n }\r\n /** Set focus */\r\n focus() {\r\n this._device.canvas.focus();\r\n }\r\n /** Wait until the application is ready. */\r\n async ready() {\r\n if (!this._ready) {\r\n this._device = await this._options.backend.createDevice(this._options.canvas, {\r\n dpr: this._options.pixelRatio,\r\n msaa: !!this._options.enableMSAA\r\n });\r\n if (!this._device) {\r\n throw new Error('App.init(): create device failed');\r\n }\r\n this._device.canvas.focus();\r\n this._inputManager.start();\r\n this._device.on('resize', (width, height) => {\r\n this.dispatchEvent('resize', width, height);\r\n });\r\n this._ready = true;\r\n }\r\n }\r\n /** Render one frame */\r\n frame() {\r\n // Processes all pending disposals from the previous frame.\r\n flushPendingDisposals();\r\n if (this._ready) {\r\n this.device.setFramebuffer(null);\r\n this.device.setViewport(null);\r\n this.device.setScissor(null);\r\n const dt = this.device.frameInfo.elapsedFrame;\r\n const elapsed = this.device.frameInfo.elapsedOverall;\r\n this._runtimeManager.update(dt, elapsed);\r\n this.dispatchEvent('tick', dt, elapsed);\r\n }\r\n }\r\n /** Start running the rendering loop */\r\n run() {\r\n this.device.runLoop(() => {\r\n this.frame();\r\n });\r\n }\r\n /** Stop running the rendering loop */\r\n stop() {\r\n this.device.exitLoop();\r\n }\r\n /** Message log */\r\n log(text: string, mode?: LogMode) {\r\n this._logger?.log(text, mode);\r\n }\r\n}\r\n"],"names":["Application","Observable","_options","_device","_inputManager","_runtimeManager","_ready","_logger","_instance","opt","Error","backend","enableMSAA","pixelRatio","window","devicePixelRatio","canvas","InputManager","RuntimeManager","runtimeOptions","VFS","scriptsRoot","editorMode","enabled","log","text","mode","console","warn","error","debug","info","inputManager","runtimeManager","options","instance","device","deviceType","typeName","logger","val","focus","ready","createDevice","dpr","msaa","start","on","width","height","dispatchEvent","frame","flushPendingDisposals","setFramebuffer","setViewport","setScissor","dt","frameInfo","elapsedFrame","elapsed","elapsedOverall","update","run","runLoop","stop","exitLoop"],"mappings":";;;;AAuEA;;;;;;;;;;;IAYO,MAAMA,WAAoBC,SAAAA,UAAAA,CAAAA;IACdC,QAAqB;IAC9BC,OAAwB;IACfC,aAA4B;IAC5BC,eAAgC;IACzCC,MAAgB;IAChBC,OAAgB;AACxB,IAAA,OAAeC,SAAuB;AACtC;;;MAIA,WAAA,CAAYC,GAAwB,CAAE;QACpC,KAAK,EAAA;QACL,IAAIT,WAAAA,CAAYQ,SAAS,EAAE;AACzB,YAAA,MAAM,IAAIE,KAAM,CAAA,0DAAA,CAAA;AAClB;QACAV,WAAYQ,CAAAA,SAAS,GAAG,IAAI;QAC5B,IAAI,CAACN,QAAQ,GAAG;AACdS,YAAAA,OAAAA,EAASF,IAAIE,OAAO;YACpBC,UAAYH,EAAAA,GAAAA,CAAIG,UAAU,IAAI,KAAA;AAC9BC,YAAAA,UAAAA,EAAYJ,GAAII,CAAAA,UAAU,IAAIC,MAAAA,CAAOC,gBAAgB,IAAI,CAAA;AACzDC,YAAAA,MAAAA,EAAQP,IAAIO;AACd,SAAA;AACA,QAAA,IAAI,CAACZ,aAAa,GAAG,IAAIa,aAAa,IAAI,CAAA;QAC1C,IAAI,CAACZ,eAAe,GAAG,IAAIa,eACzBT,GAAIU,CAAAA,cAAc,CAACC,GAAG,EACtBX,GAAAA,CAAIU,cAAc,CAACE,WAAW,EAC9BZ,GAAAA,CAAIU,cAAc,CAACG,UAAU,EAC7Bb,GAAAA,CAAIU,cAAc,CAACI,OAAO,CAAA;QAE5B,IAAI,CAACjB,MAAM,GAAG,KAAA;QACd,IAAI,CAACC,OAAO,GAAG;YACbiB,GAAIC,CAAAA,CAAAA,IAAY,EAAEC,IAAc,EAAA;AAC9B,gBAAA,IAAIA,SAAS,MAAQ,EAAA;AACn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