@zephyr3d/scene 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animation/animationset.js +220 -1
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/ik/ccd_solver.js +3 -4
- package/dist/animation/ik/ccd_solver.js.map +1 -1
- package/dist/animation/ik/fabrik_solver.js +3 -4
- package/dist/animation/ik/fabrik_solver.js.map +1 -1
- package/dist/animation/ik/ik_pole_constraint.js +7 -2
- package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
- package/dist/animation/ik/ik_utils.js +0 -79
- package/dist/animation/ik/ik_utils.js.map +1 -1
- package/dist/animation/ik/two_bone_ik_solver.js +3 -4
- package/dist/animation/ik/two_bone_ik_solver.js.map +1 -1
- package/dist/animation/skeleton.js +157 -125
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/spring/spring_bone.js +240 -0
- package/dist/animation/spring/spring_bone.js.map +1 -0
- package/dist/animation/spring/spring_bone_collider.js +198 -0
- package/dist/animation/spring/spring_bone_collider.js.map +1 -0
- package/dist/animation/spring/spring_bone_constraint.js +170 -0
- package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
- package/dist/animation/spring/spring_bone_system.js +328 -0
- package/dist/animation/spring/spring_bone_system.js.map +1 -0
- package/dist/asset/model.js +2 -2
- package/dist/index.d.ts +17 -0
- package/dist/material/mixins/pbr/common.js +20 -17
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/render/gpu_picking.js +100 -0
- package/dist/render/gpu_picking.js.map +1 -0
- package/dist/render/rendergraph/device_pool_allocator.js +41 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
- package/dist/render/rendergraph/executor.js +146 -0
- package/dist/render/rendergraph/executor.js.map +1 -0
- package/dist/render/rendergraph/forward_plus_builder.js +414 -0
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
- package/dist/render/rendergraph/rendergraph.js +306 -0
- package/dist/render/rendergraph/rendergraph.js.map +1 -0
- package/dist/render/rendergraph/types.js +57 -0
- package/dist/render/rendergraph/types.js.map +1 -0
- package/dist/render/sky_motion_vector.js +85 -0
- package/dist/render/sky_motion_vector.js.map +1 -0
- package/dist/utility/serialization/scene/animation.js +3 -3
- package/dist/utility/serialization/scene/node.js +1 -1
- package/package.json +2 -2
- package/dist/animation/ik/ik_chain_builder.js +0 -68
- package/dist/animation/ik/ik_chain_builder.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
- package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
- package/dist/src/animation/animation.js +0 -127
- package/dist/src/animation/animation.js.map +0 -1
- package/dist/src/animation/animationset.js +0 -255
- package/dist/src/animation/animationset.js.map +0 -1
- package/dist/src/animation/animationtrack.js +0 -34
- package/dist/src/animation/animationtrack.js.map +0 -1
- package/dist/src/animation/eulerrotationtrack.js +0 -52
- package/dist/src/animation/eulerrotationtrack.js.map +0 -1
- package/dist/src/animation/morphtarget.js +0 -93
- package/dist/src/animation/morphtarget.js.map +0 -1
- package/dist/src/animation/morphtrack.js +0 -70
- package/dist/src/animation/morphtrack.js.map +0 -1
- package/dist/src/animation/proptrack.js +0 -161
- package/dist/src/animation/proptrack.js.map +0 -1
- package/dist/src/animation/rotationtrack.js +0 -51
- package/dist/src/animation/rotationtrack.js.map +0 -1
- package/dist/src/animation/scaletrack.js +0 -50
- package/dist/src/animation/scaletrack.js.map +0 -1
- package/dist/src/animation/skeleton.js +0 -204
- package/dist/src/animation/skeleton.js.map +0 -1
- package/dist/src/animation/translationtrack.js +0 -50
- package/dist/src/animation/translationtrack.js.map +0 -1
- package/dist/src/app/app.js +0 -129
- package/dist/src/app/app.js.map +0 -1
- package/dist/src/app/inputmgr.js +0 -267
- package/dist/src/app/inputmgr.js.map +0 -1
- package/dist/src/asset/assetmanager.js +0 -404
- package/dist/src/asset/assetmanager.js.map +0 -1
- package/dist/src/asset/builtin.js +0 -337
- package/dist/src/asset/builtin.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds.js +0 -470
- package/dist/src/asset/loaders/dds/dds.js.map +0 -1
- package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
- package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
- package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
- package/dist/src/asset/loaders/gltf/helpers.js +0 -327
- package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
- package/dist/src/asset/loaders/hdr/hdr.js +0 -180
- package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
- package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
- package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
- package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
- package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
- package/dist/src/asset/loaders/loader.js +0 -45
- package/dist/src/asset/loaders/loader.js.map +0 -1
- package/dist/src/asset/model.js +0 -414
- package/dist/src/asset/model.js.map +0 -1
- package/dist/src/blitter/bilateralblur.js +0 -221
- package/dist/src/blitter/bilateralblur.js.map +0 -1
- package/dist/src/blitter/blitter.js +0 -390
- package/dist/src/blitter/blitter.js.map +0 -1
- package/dist/src/blitter/box.js +0 -118
- package/dist/src/blitter/box.js.map +0 -1
- package/dist/src/blitter/copy.js +0 -22
- package/dist/src/blitter/copy.js.map +0 -1
- package/dist/src/blitter/gaussianblur.js +0 -228
- package/dist/src/blitter/gaussianblur.js.map +0 -1
- package/dist/src/camera/base.js +0 -92
- package/dist/src/camera/base.js.map +0 -1
- package/dist/src/camera/camera.js +0 -1005
- package/dist/src/camera/camera.js.map +0 -1
- package/dist/src/camera/fps.js +0 -238
- package/dist/src/camera/fps.js.map +0 -1
- package/dist/src/camera/orbit.js +0 -245
- package/dist/src/camera/orbit.js.map +0 -1
- package/dist/src/camera/orthocamera.js +0 -167
- package/dist/src/camera/orthocamera.js.map +0 -1
- package/dist/src/camera/perspectivecamera.js +0 -141
- package/dist/src/camera/perspectivecamera.js.map +0 -1
- package/dist/src/index.js +0 -120
- package/dist/src/index.js.map +0 -1
- package/dist/src/material/blinn.js +0 -81
- package/dist/src/material/blinn.js.map +0 -1
- package/dist/src/material/grassmaterial.js +0 -113
- package/dist/src/material/grassmaterial.js.map +0 -1
- package/dist/src/material/lambert.js +0 -92
- package/dist/src/material/lambert.js.map +0 -1
- package/dist/src/material/material.js +0 -301
- package/dist/src/material/material.js.map +0 -1
- package/dist/src/material/meshmaterial.js +0 -704
- package/dist/src/material/meshmaterial.js.map +0 -1
- package/dist/src/material/mixins/albedocolor.js +0 -76
- package/dist/src/material/mixins/albedocolor.js.map +0 -1
- package/dist/src/material/mixins/foliage.js +0 -47
- package/dist/src/material/mixins/foliage.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
- package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
- package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
- package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
- package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
- package/dist/src/material/mixins/lit.js +0 -476
- package/dist/src/material/mixins/lit.js.map +0 -1
- package/dist/src/material/mixins/pbr/common.js +0 -918
- package/dist/src/material/mixins/pbr/common.js.map +0 -1
- package/dist/src/material/mixins/texture.js +0 -172
- package/dist/src/material/mixins/texture.js.map +0 -1
- package/dist/src/material/mixins/vertexcolor.js +0 -56
- package/dist/src/material/mixins/vertexcolor.js.map +0 -1
- package/dist/src/material/particle.js +0 -178
- package/dist/src/material/particle.js.map +0 -1
- package/dist/src/material/pbrmr.js +0 -97
- package/dist/src/material/pbrmr.js.map +0 -1
- package/dist/src/material/pbrsg.js +0 -97
- package/dist/src/material/pbrsg.js.map +0 -1
- package/dist/src/material/shader/helper.js +0 -1209
- package/dist/src/material/shader/helper.js.map +0 -1
- package/dist/src/material/terrain-cm.js +0 -606
- package/dist/src/material/terrain-cm.js.map +0 -1
- package/dist/src/material/terrainmaterial.js +0 -375
- package/dist/src/material/terrainmaterial.js.map +0 -1
- package/dist/src/material/unlit.js +0 -41
- package/dist/src/material/unlit.js.map +0 -1
- package/dist/src/material/water.js +0 -417
- package/dist/src/material/water.js.map +0 -1
- package/dist/src/posteffect/bloom.js +0 -361
- package/dist/src/posteffect/bloom.js.map +0 -1
- package/dist/src/posteffect/compositor.js +0 -226
- package/dist/src/posteffect/compositor.js.map +0 -1
- package/dist/src/posteffect/fxaa.js +0 -273
- package/dist/src/posteffect/fxaa.js.map +0 -1
- package/dist/src/posteffect/grayscale.js +0 -69
- package/dist/src/posteffect/grayscale.js.map +0 -1
- package/dist/src/posteffect/motionblur.js +0 -96
- package/dist/src/posteffect/motionblur.js.map +0 -1
- package/dist/src/posteffect/posteffect.js +0 -126
- package/dist/src/posteffect/posteffect.js.map +0 -1
- package/dist/src/posteffect/sao.js +0 -324
- package/dist/src/posteffect/sao.js.map +0 -1
- package/dist/src/posteffect/ssr.js +0 -489
- package/dist/src/posteffect/ssr.js.map +0 -1
- package/dist/src/posteffect/taa.js +0 -172
- package/dist/src/posteffect/taa.js.map +0 -1
- package/dist/src/posteffect/tonemap.js +0 -94
- package/dist/src/posteffect/tonemap.js.map +0 -1
- package/dist/src/render/abuffer_oit.js +0 -361
- package/dist/src/render/abuffer_oit.js.map +0 -1
- package/dist/src/render/clipmap.js +0 -851
- package/dist/src/render/clipmap.js.map +0 -1
- package/dist/src/render/cluster_light.js +0 -333
- package/dist/src/render/cluster_light.js.map +0 -1
- package/dist/src/render/cull_visitor.js +0 -187
- package/dist/src/render/cull_visitor.js.map +0 -1
- package/dist/src/render/depthpass.js +0 -68
- package/dist/src/render/depthpass.js.map +0 -1
- package/dist/src/render/drawable_mixin.js +0 -227
- package/dist/src/render/drawable_mixin.js.map +0 -1
- package/dist/src/render/envlight.js +0 -463
- package/dist/src/render/envlight.js.map +0 -1
- package/dist/src/render/fbm_wavegenerator.js +0 -251
- package/dist/src/render/fbm_wavegenerator.js.map +0 -1
- package/dist/src/render/fft_wavegenerator.js +0 -1006
- package/dist/src/render/fft_wavegenerator.js.map +0 -1
- package/dist/src/render/fullscreenquad.js +0 -38
- package/dist/src/render/fullscreenquad.js.map +0 -1
- package/dist/src/render/gerstner_wavegenerator.js +0 -314
- package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
- package/dist/src/render/globalbindgroup_allocator.js +0 -60
- package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
- package/dist/src/render/hzb.js +0 -273
- package/dist/src/render/hzb.js.map +0 -1
- package/dist/src/render/lightpass.js +0 -172
- package/dist/src/render/lightpass.js.map +0 -1
- package/dist/src/render/objectcolorpass.js +0 -51
- package/dist/src/render/objectcolorpass.js.map +0 -1
- package/dist/src/render/primitive.js +0 -364
- package/dist/src/render/primitive.js.map +0 -1
- package/dist/src/render/render_queue.js +0 -467
- package/dist/src/render/render_queue.js.map +0 -1
- package/dist/src/render/renderbundle_wrapper.js +0 -152
- package/dist/src/render/renderbundle_wrapper.js.map +0 -1
- package/dist/src/render/renderer.js +0 -455
- package/dist/src/render/renderer.js.map +0 -1
- package/dist/src/render/renderpass.js +0 -200
- package/dist/src/render/renderpass.js.map +0 -1
- package/dist/src/render/shadowmap_pass.js +0 -56
- package/dist/src/render/shadowmap_pass.js.map +0 -1
- package/dist/src/render/sky.js +0 -1103
- package/dist/src/render/sky.js.map +0 -1
- package/dist/src/render/weightedblended_oit.js +0 -168
- package/dist/src/render/weightedblended_oit.js.map +0 -1
- package/dist/src/scene/batchgroup.js +0 -162
- package/dist/src/scene/batchgroup.js.map +0 -1
- package/dist/src/scene/environment.js +0 -209
- package/dist/src/scene/environment.js.map +0 -1
- package/dist/src/scene/graph_node.js +0 -72
- package/dist/src/scene/graph_node.js.map +0 -1
- package/dist/src/scene/light.js +0 -416
- package/dist/src/scene/light.js.map +0 -1
- package/dist/src/scene/mesh.js +0 -341
- package/dist/src/scene/mesh.js.map +0 -1
- package/dist/src/scene/octree.js +0 -649
- package/dist/src/scene/octree.js.map +0 -1
- package/dist/src/scene/particlesys.js +0 -738
- package/dist/src/scene/particlesys.js.map +0 -1
- package/dist/src/scene/raycast_visitor.js +0 -103
- package/dist/src/scene/raycast_visitor.js.map +0 -1
- package/dist/src/scene/scene.js +0 -284
- package/dist/src/scene/scene.js.map +0 -1
- package/dist/src/scene/scene_node.js +0 -732
- package/dist/src/scene/scene_node.js.map +0 -1
- package/dist/src/scene/terrain/grass.js +0 -278
- package/dist/src/scene/terrain/grass.js.map +0 -1
- package/dist/src/scene/terrain/heightfield.js +0 -475
- package/dist/src/scene/terrain/heightfield.js.map +0 -1
- package/dist/src/scene/terrain/patch.js +0 -530
- package/dist/src/scene/terrain/patch.js.map +0 -1
- package/dist/src/scene/terrain/quadtree.js +0 -461
- package/dist/src/scene/terrain/quadtree.js.map +0 -1
- package/dist/src/scene/terrain/terrain.js +0 -246
- package/dist/src/scene/terrain/terrain.js.map +0 -1
- package/dist/src/scene/terrain-cm/grass.js +0 -594
- package/dist/src/scene/terrain-cm/grass.js.map +0 -1
- package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
- package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
- package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
- package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
- package/dist/src/scene/water.js +0 -374
- package/dist/src/scene/water.js.map +0 -1
- package/dist/src/shaders/atmosphere.js +0 -957
- package/dist/src/shaders/atmosphere.js.map +0 -1
- package/dist/src/shaders/fog.js +0 -112
- package/dist/src/shaders/fog.js.map +0 -1
- package/dist/src/shaders/misc.js +0 -266
- package/dist/src/shaders/misc.js.map +0 -1
- package/dist/src/shaders/noise.js +0 -222
- package/dist/src/shaders/noise.js.map +0 -1
- package/dist/src/shaders/pbr.js +0 -51
- package/dist/src/shaders/pbr.js.map +0 -1
- package/dist/src/shaders/shadow.js +0 -636
- package/dist/src/shaders/shadow.js.map +0 -1
- package/dist/src/shaders/ssr.js +0 -490
- package/dist/src/shaders/ssr.js.map +0 -1
- package/dist/src/shaders/temporal.js +0 -215
- package/dist/src/shaders/temporal.js.map +0 -1
- package/dist/src/shaders/water.js +0 -756
- package/dist/src/shaders/water.js.map +0 -1
- package/dist/src/shadow/esm.js +0 -237
- package/dist/src/shadow/esm.js.map +0 -1
- package/dist/src/shadow/pcf_opt.js +0 -181
- package/dist/src/shadow/pcf_opt.js.map +0 -1
- package/dist/src/shadow/pcf_pd.js +0 -189
- package/dist/src/shadow/pcf_pd.js.map +0 -1
- package/dist/src/shadow/shader.js +0 -37
- package/dist/src/shadow/shader.js.map +0 -1
- package/dist/src/shadow/shadow_impl.js +0 -15
- package/dist/src/shadow/shadow_impl.js.map +0 -1
- package/dist/src/shadow/shadowmapper.js +0 -790
- package/dist/src/shadow/shadowmapper.js.map +0 -1
- package/dist/src/shadow/ssm.js +0 -159
- package/dist/src/shadow/ssm.js.map +0 -1
- package/dist/src/shadow/vsm.js +0 -297
- package/dist/src/shadow/vsm.js.map +0 -1
- package/dist/src/shapes/box.js +0 -386
- package/dist/src/shapes/box.js.map +0 -1
- package/dist/src/shapes/cylinder.js +0 -125
- package/dist/src/shapes/cylinder.js.map +0 -1
- package/dist/src/shapes/plane.js +0 -88
- package/dist/src/shapes/plane.js.map +0 -1
- package/dist/src/shapes/shape.js +0 -87
- package/dist/src/shapes/shape.js.map +0 -1
- package/dist/src/shapes/sphere.js +0 -114
- package/dist/src/shapes/sphere.js.map +0 -1
- package/dist/src/shapes/tetrahedron.js +0 -188
- package/dist/src/shapes/tetrahedron.js.map +0 -1
- package/dist/src/shapes/torus.js +0 -111
- package/dist/src/shapes/torus.js.map +0 -1
- package/dist/src/utility/aabbtree.js +0 -400
- package/dist/src/utility/aabbtree.js.map +0 -1
- package/dist/src/utility/bounding_volume.js +0 -29
- package/dist/src/utility/bounding_volume.js.map +0 -1
- package/dist/src/utility/debug.js +0 -28
- package/dist/src/utility/debug.js.map +0 -1
- package/dist/src/utility/draco/decoder.js +0 -116
- package/dist/src/utility/draco/decoder.js.map +0 -1
- package/dist/src/utility/misc.js +0 -105
- package/dist/src/utility/misc.js.map +0 -1
- package/dist/src/utility/panorama.js +0 -163
- package/dist/src/utility/panorama.js.map +0 -1
- package/dist/src/utility/pmrem.js +0 -354
- package/dist/src/utility/pmrem.js.map +0 -1
- package/dist/src/utility/rendermipmap.js +0 -115
- package/dist/src/utility/rendermipmap.js.map +0 -1
- package/dist/src/utility/serialization/json.js +0 -402
- package/dist/src/utility/serialization/json.js.map +0 -1
- package/dist/src/utility/serialization/manager.js +0 -623
- package/dist/src/utility/serialization/manager.js.map +0 -1
- package/dist/src/utility/serialization/scene/animation.js +0 -248
- package/dist/src/utility/serialization/scene/animation.js.map +0 -1
- package/dist/src/utility/serialization/scene/batch.js +0 -59
- package/dist/src/utility/serialization/scene/batch.js.map +0 -1
- package/dist/src/utility/serialization/scene/camera.js +0 -790
- package/dist/src/utility/serialization/scene/camera.js.map +0 -1
- package/dist/src/utility/serialization/scene/common.js +0 -222
- package/dist/src/utility/serialization/scene/common.js.map +0 -1
- package/dist/src/utility/serialization/scene/light.js +0 -575
- package/dist/src/utility/serialization/scene/light.js.map +0 -1
- package/dist/src/utility/serialization/scene/material.js +0 -1111
- package/dist/src/utility/serialization/scene/material.js.map +0 -1
- package/dist/src/utility/serialization/scene/mesh.js +0 -148
- package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
- package/dist/src/utility/serialization/scene/misc.js +0 -39
- package/dist/src/utility/serialization/scene/misc.js.map +0 -1
- package/dist/src/utility/serialization/scene/node.js +0 -451
- package/dist/src/utility/serialization/scene/node.js.map +0 -1
- package/dist/src/utility/serialization/scene/particle.js +0 -425
- package/dist/src/utility/serialization/scene/particle.js.map +0 -1
- package/dist/src/utility/serialization/scene/primitive.js +0 -692
- package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
- package/dist/src/utility/serialization/scene/scene.js +0 -704
- package/dist/src/utility/serialization/scene/scene.js.map +0 -1
- package/dist/src/utility/serialization/scene/terrain.js +0 -488
- package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
- package/dist/src/utility/serialization/scene/water.js +0 -465
- package/dist/src/utility/serialization/scene/water.js.map +0 -1
- package/dist/src/utility/shprojector.js +0 -297
- package/dist/src/utility/shprojector.js.map +0 -1
- package/dist/src/utility/textures/ggxlut.js +0 -213
- package/dist/src/utility/textures/ggxlut.js.map +0 -1
- package/dist/src/utility/textures/gradientnoise.js +0 -62
- package/dist/src/utility/textures/gradientnoise.js.map +0 -1
- package/dist/src/utility/textures/randomnoise.js +0 -41
- package/dist/src/utility/textures/randomnoise.js.map +0 -1
- package/dist/src/values.js +0 -162
- package/dist/src/values.js.map +0 -1
- package/dist/utility/blueprint/material/common.js +0 -7
- package/dist/utility/blueprint/material/common.js.map +0 -1
- package/dist/utility/serialization/blueprint/constants.js +0 -255
- package/dist/utility/serialization/blueprint/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/constants.js +0 -203
- package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
- package/dist/utility/serialization/blueprint/material/texture.js +0 -165
- package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
|
@@ -1,623 +0,0 @@
|
|
|
1
|
-
import { getAABBClass } from './scene/misc.js';
|
|
2
|
-
import { getNodeHierarchyClass, getSceneNodeClass, getGraphNodeClass } from './scene/node.js';
|
|
3
|
-
import { getBatchGroupClass } from './scene/batch.js';
|
|
4
|
-
import { getCameraClass, getPerspectiveCameraClass, getOrthoCameraClass } from './scene/camera.js';
|
|
5
|
-
import { getPunctualLightClass, getDirectionalLightClass, getSpotLightClass, getPointLightClass } from './scene/light.js';
|
|
6
|
-
import { getMeshMaterialClass, getUnlitMaterialClass, getLambertMaterialClass, getBlinnMaterialClass, getPBRMetallicRoughnessMaterialClass, getPBRSpecularGlossinessMaterialClass, getParticleMaterialClass } from './scene/material.js';
|
|
7
|
-
import { getMeshClass } from './scene/mesh.js';
|
|
8
|
-
import { getParticleNodeClass } from './scene/particle.js';
|
|
9
|
-
import { getPrimitiveClass, getBoxShapeClass, getBoxFrameShapeClass, getSphereShapeClass, getTorusShapeClass, getCylinderShapeClass, getPlaneShapeClass } from './scene/primitive.js';
|
|
10
|
-
import { getSceneClass } from './scene/scene.js';
|
|
11
|
-
import { getTerrainClass } from './scene/terrain.js';
|
|
12
|
-
import { getWaterClass, getFFTWaveGeneratorClass, getFBMWaveGeneratorClass } from './scene/water.js';
|
|
13
|
-
import { getInterpolatorClass, getAnimationClass, getPropTrackClass } from './scene/animation.js';
|
|
14
|
-
import { AssetManager } from '../../asset/assetmanager.js';
|
|
15
|
-
import '@zephyr3d/base';
|
|
16
|
-
import '../../scene/mesh.js';
|
|
17
|
-
import '../../animation/eulerrotationtrack.js';
|
|
18
|
-
import '../../animation/skeleton.js';
|
|
19
|
-
import '@zephyr3d/device';
|
|
20
|
-
import { Application } from '../../app/app.js';
|
|
21
|
-
import '../../values.js';
|
|
22
|
-
import '../../material/shader/helper.js';
|
|
23
|
-
import { getJSONPropClass, getJSONNumberClass, getJSONStringClass, getJSONBoolClass, getJSONObjectClass, getJSONArrayClass } from './json.js';
|
|
24
|
-
|
|
25
|
-
const defaultValues = {
|
|
26
|
-
bool: false,
|
|
27
|
-
float: 0,
|
|
28
|
-
int: 0,
|
|
29
|
-
int2: [
|
|
30
|
-
0,
|
|
31
|
-
0
|
|
32
|
-
],
|
|
33
|
-
int3: [
|
|
34
|
-
0,
|
|
35
|
-
0,
|
|
36
|
-
0
|
|
37
|
-
],
|
|
38
|
-
int4: [
|
|
39
|
-
0,
|
|
40
|
-
0,
|
|
41
|
-
0,
|
|
42
|
-
0
|
|
43
|
-
],
|
|
44
|
-
object: null,
|
|
45
|
-
object_array: [],
|
|
46
|
-
embedded: '',
|
|
47
|
-
rgb: [
|
|
48
|
-
0,
|
|
49
|
-
0,
|
|
50
|
-
0
|
|
51
|
-
],
|
|
52
|
-
rgba: [
|
|
53
|
-
0,
|
|
54
|
-
0,
|
|
55
|
-
0,
|
|
56
|
-
0
|
|
57
|
-
],
|
|
58
|
-
string: '',
|
|
59
|
-
vec2: [
|
|
60
|
-
0,
|
|
61
|
-
0
|
|
62
|
-
],
|
|
63
|
-
vec3: [
|
|
64
|
-
0,
|
|
65
|
-
0,
|
|
66
|
-
0
|
|
67
|
-
],
|
|
68
|
-
vec4: [
|
|
69
|
-
0,
|
|
70
|
-
0,
|
|
71
|
-
0,
|
|
72
|
-
0
|
|
73
|
-
],
|
|
74
|
-
command: null
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Serialization manager class
|
|
78
|
-
* @public
|
|
79
|
-
*/ class SerializationManager {
|
|
80
|
-
_classMap;
|
|
81
|
-
_vfs;
|
|
82
|
-
_propMap;
|
|
83
|
-
_propNameMap;
|
|
84
|
-
_clsPropMap;
|
|
85
|
-
_assetManager;
|
|
86
|
-
_allocated;
|
|
87
|
-
constructor(vfs){
|
|
88
|
-
this._vfs = vfs;
|
|
89
|
-
this._allocated = new WeakMap();
|
|
90
|
-
this._assetManager = new AssetManager(this._vfs);
|
|
91
|
-
this._propMap = {};
|
|
92
|
-
this._propNameMap = new Map();
|
|
93
|
-
this._clsPropMap = new Map();
|
|
94
|
-
this._classMap = new Map([
|
|
95
|
-
getJSONPropClass(),
|
|
96
|
-
getJSONNumberClass(),
|
|
97
|
-
getJSONStringClass(),
|
|
98
|
-
getJSONBoolClass(),
|
|
99
|
-
getJSONObjectClass(),
|
|
100
|
-
getJSONArrayClass(),
|
|
101
|
-
getAABBClass(),
|
|
102
|
-
getInterpolatorClass(),
|
|
103
|
-
getNodeHierarchyClass(),
|
|
104
|
-
getAnimationClass(this),
|
|
105
|
-
getPropTrackClass(this),
|
|
106
|
-
getSceneNodeClass(this),
|
|
107
|
-
getGraphNodeClass(),
|
|
108
|
-
getMeshClass(),
|
|
109
|
-
getWaterClass(this),
|
|
110
|
-
getTerrainClass(this),
|
|
111
|
-
getFFTWaveGeneratorClass(),
|
|
112
|
-
getFBMWaveGeneratorClass(),
|
|
113
|
-
getParticleNodeClass(),
|
|
114
|
-
getPunctualLightClass(),
|
|
115
|
-
getDirectionalLightClass(),
|
|
116
|
-
getSpotLightClass(),
|
|
117
|
-
getPointLightClass(),
|
|
118
|
-
getCameraClass(),
|
|
119
|
-
getPerspectiveCameraClass(),
|
|
120
|
-
getOrthoCameraClass(),
|
|
121
|
-
getBatchGroupClass(),
|
|
122
|
-
getSceneClass(this),
|
|
123
|
-
getMeshMaterialClass(),
|
|
124
|
-
getUnlitMaterialClass(this),
|
|
125
|
-
getLambertMaterialClass(this),
|
|
126
|
-
getBlinnMaterialClass(this),
|
|
127
|
-
getPBRMetallicRoughnessMaterialClass(this),
|
|
128
|
-
getPBRSpecularGlossinessMaterialClass(this),
|
|
129
|
-
getParticleMaterialClass(this),
|
|
130
|
-
getPrimitiveClass(),
|
|
131
|
-
getBoxShapeClass(),
|
|
132
|
-
getBoxFrameShapeClass(),
|
|
133
|
-
getSphereShapeClass(),
|
|
134
|
-
getTorusShapeClass(),
|
|
135
|
-
getCylinderShapeClass(),
|
|
136
|
-
getPlaneShapeClass()
|
|
137
|
-
].map((val)=>[
|
|
138
|
-
val.ctor,
|
|
139
|
-
val
|
|
140
|
-
]));
|
|
141
|
-
for (const k of this._classMap){
|
|
142
|
-
this.registerProps(k[1]);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
get vfs() {
|
|
146
|
-
return this._vfs;
|
|
147
|
-
}
|
|
148
|
-
getClasses() {
|
|
149
|
-
return [
|
|
150
|
-
...this._classMap.values()
|
|
151
|
-
];
|
|
152
|
-
}
|
|
153
|
-
getClassByConstructor(ctor) {
|
|
154
|
-
return this._classMap.get(ctor) ?? null;
|
|
155
|
-
}
|
|
156
|
-
getClassByObject(obj) {
|
|
157
|
-
return this.getClassByConstructor(obj.constructor);
|
|
158
|
-
}
|
|
159
|
-
getClassByName(className) {
|
|
160
|
-
for (const val of this._classMap){
|
|
161
|
-
if (val[0].name === className) {
|
|
162
|
-
return val[1];
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
getClassByProperty(prop) {
|
|
168
|
-
for (const k of this._clsPropMap){
|
|
169
|
-
if (k[1].indexOf(prop) >= 0) {
|
|
170
|
-
return k[0];
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
getPropertiesByClass(cls) {
|
|
176
|
-
return this._clsPropMap.get(cls) ?? null;
|
|
177
|
-
}
|
|
178
|
-
getPropertyByClass(cls, name) {
|
|
179
|
-
return this.getPropertiesByClass(cls)?.find((value)=>value.name === name) ?? null;
|
|
180
|
-
}
|
|
181
|
-
getPropertyByName(name) {
|
|
182
|
-
return this._propMap[name] ?? null;
|
|
183
|
-
}
|
|
184
|
-
getPropertyName(prop) {
|
|
185
|
-
return this._propNameMap.get(prop) ?? null;
|
|
186
|
-
}
|
|
187
|
-
registerClass(cls) {
|
|
188
|
-
if (!this._classMap.has(cls.ctor)) {
|
|
189
|
-
this._classMap.set(cls.ctor, cls);
|
|
190
|
-
this.registerProps(cls);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
getAssetId(asset) {
|
|
194
|
-
return this._allocated.get(asset) ?? null;
|
|
195
|
-
}
|
|
196
|
-
async fetchBinary(id) {
|
|
197
|
-
const data = await this.doFetchBinary(id);
|
|
198
|
-
if (data) {
|
|
199
|
-
this._allocated.set(data, id);
|
|
200
|
-
}
|
|
201
|
-
return data;
|
|
202
|
-
}
|
|
203
|
-
serializeObject(obj, json, asyncTasks) {
|
|
204
|
-
if (obj === null || obj === undefined) {
|
|
205
|
-
return obj;
|
|
206
|
-
}
|
|
207
|
-
const cls = this.getClasses();
|
|
208
|
-
const index = cls.findIndex((val)=>val.ctor === obj.constructor);
|
|
209
|
-
if (index < 0) {
|
|
210
|
-
throw new Error('Serialize object failed: Cannot found serialization meta data');
|
|
211
|
-
}
|
|
212
|
-
let info = cls[index];
|
|
213
|
-
const initParams = info?.getInitParams?.(obj);
|
|
214
|
-
json = json ?? {};
|
|
215
|
-
json.ClassName = info.name;
|
|
216
|
-
json.Object = {};
|
|
217
|
-
if (initParams !== undefined && initParams !== null) {
|
|
218
|
-
json.Init = initParams;
|
|
219
|
-
}
|
|
220
|
-
while(info){
|
|
221
|
-
this.serializeObjectProps(obj, info, json.Object, asyncTasks);
|
|
222
|
-
info = this.getClassByConstructor(info.parent);
|
|
223
|
-
}
|
|
224
|
-
return json;
|
|
225
|
-
}
|
|
226
|
-
async deserializeObject(ctx, json) {
|
|
227
|
-
const cls = this.getClasses();
|
|
228
|
-
const className = json['ClassName'];
|
|
229
|
-
const index = cls.findIndex((val)=>val.name === className);
|
|
230
|
-
if (index < 0) {
|
|
231
|
-
throw new Error('Deserialize object failed: Cannot found serialization meta data');
|
|
232
|
-
}
|
|
233
|
-
let info = cls[index];
|
|
234
|
-
const initParams = json['Init'];
|
|
235
|
-
json = json['Object'];
|
|
236
|
-
let p;
|
|
237
|
-
let loadProps = true;
|
|
238
|
-
if (info.createFunc) {
|
|
239
|
-
let result = info.createFunc(ctx, initParams);
|
|
240
|
-
if (result instanceof Promise) {
|
|
241
|
-
result = await result;
|
|
242
|
-
}
|
|
243
|
-
p = result.obj;
|
|
244
|
-
loadProps = result.loadProps ?? true;
|
|
245
|
-
} else {
|
|
246
|
-
p = new info.ctor();
|
|
247
|
-
}
|
|
248
|
-
//const p: T | Promise<T> = info.createFunc ? info.createFunc(ctx, initParams) : new info.ctor();
|
|
249
|
-
if (!p) {
|
|
250
|
-
return null;
|
|
251
|
-
}
|
|
252
|
-
const obj = p instanceof Promise ? await p : p;
|
|
253
|
-
if (loadProps) {
|
|
254
|
-
while(info){
|
|
255
|
-
await this.deserializeObjectProps(obj, info, json);
|
|
256
|
-
info = this.getClassByConstructor(info.parent);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return obj;
|
|
260
|
-
}
|
|
261
|
-
async doFetchBinary(path) {
|
|
262
|
-
return await this._assetManager.fetchBinaryData(path, null);
|
|
263
|
-
}
|
|
264
|
-
async doFetchModel(path, scene, options) {
|
|
265
|
-
return await this._assetManager.fetchModel(scene, path, options);
|
|
266
|
-
}
|
|
267
|
-
async doFetchTexture(path, options) {
|
|
268
|
-
return await this._assetManager.fetchTexture(path, options);
|
|
269
|
-
}
|
|
270
|
-
async fetchModel(id, scene, options) {
|
|
271
|
-
const model = await this.doFetchModel(id, scene, options);
|
|
272
|
-
if (model) {
|
|
273
|
-
this._allocated.set(model.group, id);
|
|
274
|
-
}
|
|
275
|
-
return model;
|
|
276
|
-
}
|
|
277
|
-
async fetchTexture(id, options) {
|
|
278
|
-
const texture = await this.doFetchTexture(id, options);
|
|
279
|
-
if (texture) {
|
|
280
|
-
this._allocated.set(texture, id);
|
|
281
|
-
}
|
|
282
|
-
return texture;
|
|
283
|
-
}
|
|
284
|
-
async loadScene(filename) {
|
|
285
|
-
const content = await this._vfs.readFile(filename, {
|
|
286
|
-
encoding: 'utf8'
|
|
287
|
-
});
|
|
288
|
-
const json = JSON.parse(content);
|
|
289
|
-
const scene = await this.deserializeObject(null, json);
|
|
290
|
-
if (scene) {
|
|
291
|
-
const P = [];
|
|
292
|
-
scene.rootNode.iterate((node)=>{
|
|
293
|
-
if (node.script) {
|
|
294
|
-
P.push(Application.instance.runtimeManager.attachScript(node, node.script));
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
if (P.length > 0) {
|
|
298
|
-
await Promise.all(P);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
return scene;
|
|
302
|
-
}
|
|
303
|
-
async saveScene(scene, filename) {
|
|
304
|
-
const asyncTasks = [];
|
|
305
|
-
const content = await this.serializeObject(scene, null, asyncTasks);
|
|
306
|
-
await Promise.all(asyncTasks);
|
|
307
|
-
await this._vfs.writeFile(filename, JSON.stringify(content), {
|
|
308
|
-
encoding: 'utf8',
|
|
309
|
-
create: true
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
static _pathPattern = /^([^\[\]]+)(?:\[(\d+)\])?$/;
|
|
313
|
-
static parsePropertyPath(str) {
|
|
314
|
-
const match = str.match(this._pathPattern);
|
|
315
|
-
if (match) {
|
|
316
|
-
return {
|
|
317
|
-
original: match[0],
|
|
318
|
-
prefix: match[1],
|
|
319
|
-
index: match[2] || null,
|
|
320
|
-
indexValue: match[2] ? parseInt(match[2], 10) : null,
|
|
321
|
-
hasIndex: !!match[2]
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
findAnimationTarget(node, track) {
|
|
327
|
-
const target = track.target ?? '';
|
|
328
|
-
const value = {
|
|
329
|
-
object: []
|
|
330
|
-
};
|
|
331
|
-
const parts = target.split('/').filter((val)=>!!val);
|
|
332
|
-
let targetObj = node;
|
|
333
|
-
while(parts.length > 0){
|
|
334
|
-
const propName = parts.shift();
|
|
335
|
-
const info = SerializationManager.parsePropertyPath(propName);
|
|
336
|
-
if (!info) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const cls = this.getClassByConstructor(targetObj.constructor);
|
|
340
|
-
if (!cls) {
|
|
341
|
-
return null;
|
|
342
|
-
}
|
|
343
|
-
const prop = this.getPropertyByClass(cls, info.prefix);
|
|
344
|
-
if (!prop) {
|
|
345
|
-
return null;
|
|
346
|
-
}
|
|
347
|
-
if (info.hasIndex) {
|
|
348
|
-
if (prop.type !== 'object_array') {
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
prop.get.call(targetObj, value);
|
|
352
|
-
targetObj = value.object?.[info.indexValue] ?? null;
|
|
353
|
-
} else {
|
|
354
|
-
if (prop.type !== 'object') {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
prop.get.call(targetObj, value);
|
|
358
|
-
targetObj = value.object?.[0] ?? null;
|
|
359
|
-
}
|
|
360
|
-
if (!targetObj) {
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
return targetObj;
|
|
365
|
-
}
|
|
366
|
-
/** @internal */ registerProps(cls) {
|
|
367
|
-
if (!this._clsPropMap.get(cls)) {
|
|
368
|
-
const props = cls.getProps() ?? [];
|
|
369
|
-
this._clsPropMap.set(cls, props);
|
|
370
|
-
for (const prop of props){
|
|
371
|
-
const path = `/${cls.name}/${prop.name}`;
|
|
372
|
-
if (this._propMap[path]) {
|
|
373
|
-
throw new Error(`Cannot register property ${path}: property name already exists`);
|
|
374
|
-
}
|
|
375
|
-
this._propMap[path] = prop;
|
|
376
|
-
this._propNameMap.set(prop, path);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
getDefaultValue(obj, prop) {
|
|
381
|
-
let v = prop.getDefaultValue?.call(obj) ?? prop.default;
|
|
382
|
-
if (v === undefined) {
|
|
383
|
-
v = defaultValues[prop.type];
|
|
384
|
-
}
|
|
385
|
-
return v;
|
|
386
|
-
}
|
|
387
|
-
async deserializeObjectProps(obj, cls, json) {
|
|
388
|
-
const props = (this.getPropertiesByClass(cls) ?? []).sort((a, b)=>(a.phase ?? 0) - (b.phase ?? 0));
|
|
389
|
-
let currentPhase = undefined;
|
|
390
|
-
const promises = [];
|
|
391
|
-
for (const prop of props){
|
|
392
|
-
const phase = prop.phase ?? 0;
|
|
393
|
-
if (phase !== currentPhase) {
|
|
394
|
-
currentPhase = phase;
|
|
395
|
-
if (promises.length > 0) {
|
|
396
|
-
await Promise.all(promises);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
if (prop.type === 'command') {
|
|
400
|
-
continue;
|
|
401
|
-
}
|
|
402
|
-
if (!prop.set) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
if (prop.isValid && !prop.isValid.call(obj)) {
|
|
406
|
-
continue;
|
|
407
|
-
}
|
|
408
|
-
const persistent = prop.persistent ?? true;
|
|
409
|
-
if (!persistent) {
|
|
410
|
-
continue;
|
|
411
|
-
}
|
|
412
|
-
const k = prop.name;
|
|
413
|
-
const v = json[k] ?? this.getDefaultValue(obj, prop);
|
|
414
|
-
const tmpVal = {
|
|
415
|
-
num: [
|
|
416
|
-
0,
|
|
417
|
-
0,
|
|
418
|
-
0,
|
|
419
|
-
0
|
|
420
|
-
],
|
|
421
|
-
str: [
|
|
422
|
-
''
|
|
423
|
-
],
|
|
424
|
-
bool: [
|
|
425
|
-
false
|
|
426
|
-
],
|
|
427
|
-
object: [
|
|
428
|
-
null
|
|
429
|
-
]
|
|
430
|
-
};
|
|
431
|
-
switch(prop.type){
|
|
432
|
-
case 'object':
|
|
433
|
-
if (typeof v === 'string' && v) {
|
|
434
|
-
tmpVal.str[0] = v;
|
|
435
|
-
} else {
|
|
436
|
-
tmpVal.object[0] = v ? await this.deserializeObject(obj, v) ?? null : null;
|
|
437
|
-
}
|
|
438
|
-
break;
|
|
439
|
-
case 'object_array':
|
|
440
|
-
tmpVal.object = [];
|
|
441
|
-
if (Array.isArray(v)) {
|
|
442
|
-
for (const p of v){
|
|
443
|
-
if (typeof p === 'string' && p) {
|
|
444
|
-
tmpVal.str[0] = p;
|
|
445
|
-
} else {
|
|
446
|
-
tmpVal.object.push(p ? await this.deserializeObject(obj, p) ?? null : null);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
break;
|
|
451
|
-
case 'embedded':
|
|
452
|
-
if (typeof v === 'string' && v) {
|
|
453
|
-
tmpVal.str[0] = v;
|
|
454
|
-
}
|
|
455
|
-
break;
|
|
456
|
-
case 'float':
|
|
457
|
-
case 'int':
|
|
458
|
-
tmpVal.num[0] = v;
|
|
459
|
-
break;
|
|
460
|
-
case 'string':
|
|
461
|
-
tmpVal.str[0] = v;
|
|
462
|
-
break;
|
|
463
|
-
case 'bool':
|
|
464
|
-
tmpVal.bool[0] = v;
|
|
465
|
-
break;
|
|
466
|
-
case 'vec2':
|
|
467
|
-
case 'int2':
|
|
468
|
-
tmpVal.num[0] = v[0];
|
|
469
|
-
tmpVal.num[1] = v[1];
|
|
470
|
-
break;
|
|
471
|
-
case 'vec3':
|
|
472
|
-
case 'int3':
|
|
473
|
-
case 'rgb':
|
|
474
|
-
tmpVal.num[0] = v[0];
|
|
475
|
-
tmpVal.num[1] = v[1];
|
|
476
|
-
tmpVal.num[2] = v[2];
|
|
477
|
-
break;
|
|
478
|
-
case 'vec4':
|
|
479
|
-
case 'int4':
|
|
480
|
-
case 'rgba':
|
|
481
|
-
tmpVal.num[0] = v[0];
|
|
482
|
-
tmpVal.num[1] = v[1];
|
|
483
|
-
tmpVal.num[2] = v[2];
|
|
484
|
-
tmpVal.num[3] = v[3];
|
|
485
|
-
break;
|
|
486
|
-
}
|
|
487
|
-
promises.push(Promise.resolve(prop.set.call(obj, tmpVal, -1)));
|
|
488
|
-
}
|
|
489
|
-
if (promises.length > 0) {
|
|
490
|
-
await Promise.all(promises);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
serializeObjectProps(obj, cls, json, asyncTasks) {
|
|
494
|
-
const props = this.getPropertiesByClass(cls) ?? [];
|
|
495
|
-
for (const prop of props){
|
|
496
|
-
if (prop.isValid && !prop.isValid.call(obj)) {
|
|
497
|
-
continue;
|
|
498
|
-
}
|
|
499
|
-
if (prop.type === 'command') {
|
|
500
|
-
continue;
|
|
501
|
-
}
|
|
502
|
-
const persistent = prop.persistent ?? true;
|
|
503
|
-
if (!persistent) {
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
const tmpVal = {
|
|
507
|
-
num: [
|
|
508
|
-
0,
|
|
509
|
-
0,
|
|
510
|
-
0,
|
|
511
|
-
0
|
|
512
|
-
],
|
|
513
|
-
str: [
|
|
514
|
-
''
|
|
515
|
-
],
|
|
516
|
-
bool: [
|
|
517
|
-
false
|
|
518
|
-
],
|
|
519
|
-
object: [
|
|
520
|
-
null
|
|
521
|
-
]
|
|
522
|
-
};
|
|
523
|
-
const k = prop.name;
|
|
524
|
-
prop.get.call(obj, tmpVal);
|
|
525
|
-
switch(prop.type){
|
|
526
|
-
case 'object':
|
|
527
|
-
{
|
|
528
|
-
const value = typeof tmpVal.str[0] === 'string' && tmpVal.str[0] ? tmpVal.str[0] : tmpVal.object[0] ? this.serializeObject(tmpVal.object[0], {}, asyncTasks) : null;
|
|
529
|
-
if (value) {
|
|
530
|
-
json[k] = value;
|
|
531
|
-
}
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
case 'object_array':
|
|
535
|
-
json[k] = [];
|
|
536
|
-
for (const p of tmpVal.object){
|
|
537
|
-
json[k].push(this.serializeObject(p, {}, asyncTasks));
|
|
538
|
-
}
|
|
539
|
-
break;
|
|
540
|
-
case 'embedded':
|
|
541
|
-
{
|
|
542
|
-
const relativePath = tmpVal.str[0].startsWith('/') ? tmpVal.str[0].slice(1) : tmpVal.str[0];
|
|
543
|
-
json[k] = relativePath;
|
|
544
|
-
if (asyncTasks) {
|
|
545
|
-
const resource = tmpVal.object[0];
|
|
546
|
-
asyncTasks.push((async ()=>{
|
|
547
|
-
console.log(k);
|
|
548
|
-
const buffer = await resource;
|
|
549
|
-
await this.vfs.writeFile(relativePath, buffer, {
|
|
550
|
-
encoding: 'binary',
|
|
551
|
-
create: true
|
|
552
|
-
});
|
|
553
|
-
})());
|
|
554
|
-
}
|
|
555
|
-
break;
|
|
556
|
-
}
|
|
557
|
-
case 'float':
|
|
558
|
-
case 'int':
|
|
559
|
-
if (prop.default === undefined && !prop.getDefaultValue || this.getDefaultValue(obj, prop) !== tmpVal.num[0]) {
|
|
560
|
-
json[k] = tmpVal.num[0];
|
|
561
|
-
}
|
|
562
|
-
break;
|
|
563
|
-
case 'string':
|
|
564
|
-
if (prop.default === undefined && !prop.getDefaultValue || this.getDefaultValue(obj, prop) !== tmpVal.str[0]) {
|
|
565
|
-
json[k] = tmpVal.str[0];
|
|
566
|
-
}
|
|
567
|
-
break;
|
|
568
|
-
case 'bool':
|
|
569
|
-
if (prop.default === undefined && !prop.getDefaultValue || this.getDefaultValue(obj, prop) !== tmpVal.bool[0]) {
|
|
570
|
-
json[k] = tmpVal.bool[0];
|
|
571
|
-
}
|
|
572
|
-
break;
|
|
573
|
-
case 'vec2':
|
|
574
|
-
case 'int2':
|
|
575
|
-
if (prop.default !== undefined || !!prop.getDefaultValue) {
|
|
576
|
-
const v = this.getDefaultValue(obj, prop);
|
|
577
|
-
if (v[0] === tmpVal.num[0] && v[1] === tmpVal.num[1]) {
|
|
578
|
-
break;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
json[k] = [
|
|
582
|
-
tmpVal.num[0],
|
|
583
|
-
tmpVal.num[1]
|
|
584
|
-
];
|
|
585
|
-
break;
|
|
586
|
-
case 'vec3':
|
|
587
|
-
case 'int3':
|
|
588
|
-
case 'rgb':
|
|
589
|
-
if (prop.default !== undefined || !!prop.getDefaultValue) {
|
|
590
|
-
const v = this.getDefaultValue(obj, prop);
|
|
591
|
-
if (v[0] === tmpVal.num[0] && v[1] === tmpVal.num[1] && v[2] === tmpVal.num[2]) {
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
json[k] = [
|
|
596
|
-
tmpVal.num[0],
|
|
597
|
-
tmpVal.num[1],
|
|
598
|
-
tmpVal.num[2]
|
|
599
|
-
];
|
|
600
|
-
break;
|
|
601
|
-
case 'vec4':
|
|
602
|
-
case 'int4':
|
|
603
|
-
case 'rgba':
|
|
604
|
-
if (prop.default !== undefined || !!prop.getDefaultValue) {
|
|
605
|
-
const v = this.getDefaultValue(obj, prop);
|
|
606
|
-
if (v[0] === tmpVal.num[0] && v[1] === tmpVal.num[1] && v[2] === tmpVal.num[2] && v[3] === tmpVal.num[3]) {
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
json[k] = [
|
|
611
|
-
tmpVal.num[0],
|
|
612
|
-
tmpVal.num[1],
|
|
613
|
-
tmpVal.num[2],
|
|
614
|
-
tmpVal.num[3]
|
|
615
|
-
];
|
|
616
|
-
break;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
export { SerializationManager };
|
|
623
|
-
//# sourceMappingURL=manager.js.map
|