@zephyr3d/scene 0.9.6 → 0.9.7
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/joint_dynamics/controller.js +92 -32
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/convex_collider.js +320 -0
- package/dist/animation/joint_dynamics/convex_collider.js.map +1 -0
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +57 -19
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +71 -27
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +21 -20
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/skeleton.js +7 -10
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/app/engine.js +134 -140
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +47 -16
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +3 -1
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/model.js +346 -7
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +20 -16
- package/dist/avatar/wardrobe.js.map +1 -1
- package/dist/camera/camera.js +416 -210
- package/dist/camera/camera.js.map +1 -1
- package/dist/index.d.ts +1349 -621
- package/dist/index.js +6 -11
- package/dist/index.js.map +1 -1
- package/dist/material/blinn.js +1 -1
- package/dist/material/blinn.js.map +1 -1
- package/dist/material/lambert.js +1 -1
- package/dist/material/lambert.js.map +1 -1
- package/dist/material/material.js +23 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/meshmaterial.js +178 -23
- package/dist/material/meshmaterial.js.map +1 -1
- package/dist/material/mixins/albedocolor.js +4 -4
- package/dist/material/mixins/albedocolor.js.map +1 -1
- package/dist/material/mixins/lightmodel/blinnphong.js +2 -1
- package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
- package/dist/material/mixins/lightmodel/lambert.js +2 -1
- package/dist/material/mixins/lightmodel/lambert.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js +63 -16
- package/dist/material/mixins/lightmodel/pbrblueprintmixin.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +105 -32
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js +16 -6
- package/dist/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -1
- package/dist/material/mixins/lit.js +1 -1
- package/dist/material/mixins/lit.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +276 -65
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/mixins/texture.js +3 -3
- package/dist/material/mixins/texture.js.map +1 -1
- package/dist/material/mixins/vertexcolor.js +2 -2
- package/dist/material/mixins/vertexcolor.js.map +1 -1
- package/dist/material/mtoon.js +574 -0
- package/dist/material/mtoon.js.map +1 -0
- package/dist/material/pbrblueprint.js +499 -336
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/pbrmr.js +118 -100
- package/dist/material/pbrmr.js.map +1 -1
- package/dist/material/pbrsg.js +1 -1
- package/dist/material/pbrsg.js.map +1 -1
- package/dist/material/shader/helper.js +324 -294
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/subsurfaceprofile.js +812 -0
- package/dist/material/subsurfaceprofile.js.map +1 -0
- package/dist/material/unlit.js +1 -1
- package/dist/material/unlit.js.map +1 -1
- package/dist/posteffect/compositor.js +46 -11
- package/dist/posteffect/compositor.js.map +1 -1
- package/dist/posteffect/ssr.js +422 -96
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/posteffect/sss.js +1053 -0
- package/dist/posteffect/sss.js.map +1 -0
- package/dist/posteffect/taa.js +61 -60
- package/dist/posteffect/taa.js.map +1 -1
- package/dist/render/abuffer_oit.js +63 -12
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js +6 -5
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/drawable.js +1 -5
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +2 -1
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +2 -1
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +2 -1
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +2 -1
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/lightpass.js +110 -23
- package/dist/render/lightpass.js.map +1 -1
- package/dist/render/render_queue.js +51 -8
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/renderer.js +80 -66
- package/dist/render/renderer.js.map +1 -1
- package/dist/render/rendergraph/device_pool_allocator.js +8 -0
- package/dist/render/rendergraph/device_pool_allocator.js.map +1 -1
- package/dist/render/rendergraph/forward_plus_builder.js +481 -95
- package/dist/render/rendergraph/forward_plus_builder.js.map +1 -1
- package/dist/render/rendergraph/history_resource_manager.js +55 -0
- package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
- package/dist/render/rendergraph/history_resources.js +3 -1
- package/dist/render/rendergraph/history_resources.js.map +1 -1
- package/dist/render/rendergraph/types.js.map +1 -1
- package/dist/render/renderpass.js +10 -4
- package/dist/render/renderpass.js.map +1 -1
- package/dist/render/sky.js +31 -1
- package/dist/render/sky.js.map +1 -1
- package/dist/render/weightedblended_oit.js +23 -5
- package/dist/render/weightedblended_oit.js.map +1 -1
- package/dist/scene/basesprite.js +4 -2
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +3 -1
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +11 -1
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/light.js +21 -3
- package/dist/scene/light.js.map +1 -1
- package/dist/scene/mesh.js +29 -14
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +6 -0
- package/dist/scene/meshdrawable.js.map +1 -1
- package/dist/scene/msdftext.js +5 -2
- package/dist/scene/msdftext.js.map +1 -1
- package/dist/scene/msdftextsprite.js +5 -3
- package/dist/scene/msdftextsprite.js.map +1 -1
- package/dist/scene/particlesys.js +3 -1
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +6 -5
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/terrain-cm/grass.js +4 -2
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +2 -1
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +4 -2
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/water.js +4 -2
- package/dist/scene/water.js.map +1 -1
- package/dist/shaders/shadow.js +26 -393
- package/dist/shaders/shadow.js.map +1 -1
- package/dist/shadow/esm.js +112 -12
- package/dist/shadow/esm.js.map +1 -1
- package/dist/shadow/pcf_opt.js +2 -2
- package/dist/shadow/pcf_opt.js.map +1 -1
- package/dist/shadow/pcf_pd.js +19 -10
- package/dist/shadow/pcf_pd.js.map +1 -1
- package/dist/shadow/shader.js +58 -7
- package/dist/shadow/shader.js.map +1 -1
- package/dist/shadow/shadow_impl.js +6 -0
- package/dist/shadow/shadow_impl.js.map +1 -1
- package/dist/shadow/shadow_region.js +229 -0
- package/dist/shadow/shadow_region.js.map +1 -0
- package/dist/shadow/shadowmapper.js +67 -59
- package/dist/shadow/shadowmapper.js.map +1 -1
- package/dist/shadow/vsm.js +45 -19
- package/dist/shadow/vsm.js.map +1 -1
- package/dist/utility/blueprint/common/constants.js +8 -8
- package/dist/utility/blueprint/common/constants.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +31 -4
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/blueprint/material/texture.js +1 -17
- package/dist/utility/blueprint/material/texture.js.map +1 -1
- package/dist/utility/serialization/manager.js +327 -359
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +5 -2
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +4 -1
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +249 -54
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/common.js +37 -1
- package/dist/utility/serialization/scene/common.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +42 -3
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1112 -646
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +7 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +31 -12
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +4 -1
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +3 -1
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/scene.js +18 -0
- package/dist/utility/serialization/scene/scene.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +6 -3
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +5 -2
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +3 -1
- package/dist/utility/serialization/scene/text.js.map +1 -1
- package/dist/utility/serialization/scene/water.js +4 -1
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/textures/ltcdata.js +6 -0
- package/dist/utility/textures/ltcdata.js.map +1 -0
- package/dist/utility/textures/ltclut.js +61 -0
- package/dist/utility/textures/ltclut.js.map +1 -0
- package/dist/values.js +9 -1
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
|
@@ -3,16 +3,16 @@ import { getAABBClass } from './scene/misc.js';
|
|
|
3
3
|
import { getSceneNodeClass, getGraphNodeClass } from './scene/node.js';
|
|
4
4
|
import { getBatchGroupClass } from './scene/batch.js';
|
|
5
5
|
import { getCameraClass, getPerspectiveCameraClass, getOrthoCameraClass } from './scene/camera.js';
|
|
6
|
-
import { getPunctualLightClass, getDirectionalLightClass, getSpotLightClass,
|
|
7
|
-
import { getMeshMaterialClass, getPBRBluePrintMaterialClass, getSpriteBlueprintMaterialClass, getUnlitMaterialClass, getLambertMaterialClass, getBlinnMaterialClass, getPBRMetallicRoughnessMaterialClass, getPBRSpecularGlossinessMaterialClass, getParticleMaterialClass, getSpriteMaterialClass, getStandardSpriteMaterialClass } from './scene/material.js';
|
|
6
|
+
import { getPunctualLightClass, getDirectionalLightClass, getSpotLightClass, getPointLightClass, getRectLightClass } from './scene/light.js';
|
|
7
|
+
import { getSubsurfaceProfileClass, getMeshMaterialClass, getPBRBluePrintMaterialClass, getSpriteBlueprintMaterialClass, getUnlitMaterialClass, getMToonMaterialClass, getLambertMaterialClass, getBlinnMaterialClass, getPBRMetallicRoughnessMaterialClass, getPBRSpecularGlossinessMaterialClass, getParticleMaterialClass, getSpriteMaterialClass, getStandardSpriteMaterialClass } from './scene/material.js';
|
|
8
8
|
import { getMeshClass } from './scene/mesh.js';
|
|
9
9
|
import { getParticleNodeClass } from './scene/particle.js';
|
|
10
|
-
import { getBoxShapeClass, getBoxFrameShapeClass, getSphereShapeClass, getTorusShapeClass, getCylinderShapeClass, getPlaneShapeClass, getTetrahedronShapeClass
|
|
10
|
+
import { getBoxShapeClass, getBoxFrameShapeClass, getCapsuleShapeClass, getSphereShapeClass, getTorusShapeClass, getCylinderShapeClass, getPlaneShapeClass, getTetrahedronShapeClass } from './scene/primitive.js';
|
|
11
11
|
import { getSceneClass } from './scene/scene.js';
|
|
12
|
-
import { getScriptAttachmentClass } from './scene/script.js';
|
|
13
12
|
import { getTerrainClass } from './scene/terrain.js';
|
|
14
13
|
import { getWaterClass, getFFTWaveGeneratorClass, getFBMWaveGeneratorClass } from './scene/water.js';
|
|
15
|
-
import {
|
|
14
|
+
import { getTextSpriteClass, getMSDFTextSpriteClass, getMSDFTextClass } from './scene/text.js';
|
|
15
|
+
import { getInterpolatorClass, getSkeletonClass, getSkeletonRigClass, getSkinBindingClass, getJointDynamicsModifierClass, getAnimationClass, getPropTrackClass, getNodeRotationTrackClass, getNodeScaleTrackClass, getNodeTranslationTrackClass, getNodeEulerRotationTrackClass, getFixedGeometryCacheTrackClass, getPCAGeometryCacheTrackClass, getMorphTrackClass } from './scene/animation.js';
|
|
16
16
|
import '../../scene/scene.js';
|
|
17
17
|
import '../../values.js';
|
|
18
18
|
import '../../render/render_queue.js';
|
|
@@ -23,22 +23,24 @@ import '../../material/lambert.js';
|
|
|
23
23
|
import '../../material/blinn.js';
|
|
24
24
|
import '../../material/unlit.js';
|
|
25
25
|
import '../../material/particle.js';
|
|
26
|
+
import '../../material/subsurfaceprofile.js';
|
|
26
27
|
import '../../material/meshmaterial.js';
|
|
27
28
|
import '../../material/grassmaterial.js';
|
|
28
29
|
import '../../material/terrain-cm.js';
|
|
29
30
|
import '../../material/pbrmr.js';
|
|
30
31
|
import '../../material/pbrsg.js';
|
|
32
|
+
import '../../material/mtoon.js';
|
|
31
33
|
import '../../material/pbrblueprint.js';
|
|
32
34
|
import '../../material/sprite.js';
|
|
33
35
|
import '../../material/sprite_std.js';
|
|
34
|
-
import '../../material/msdf_text.js';
|
|
35
36
|
import { PBRBlockNode, SpriteBlockNode, VertexBlockNode } from '../blueprint/material/pbr.js';
|
|
36
37
|
import { ConstantScalarNode, ConstantVec2Node, ConstantVec3Node, ConstantVec4Node, ConstantBooleanNode, ConstantBVec2Node, ConstantBVec3Node, ConstantBVec4Node } from '../blueprint/common/constants.js';
|
|
37
38
|
import { ConstantTexture2DNode, ConstantTexture2DArrayNode, ConstantTextureCubeNode, PannerNode, TextureSampleNode } from '../blueprint/material/texture.js';
|
|
38
39
|
import { MakeVectorNode, SwizzleNode, EqualNode, NotEqualNode, LogicallyAndNode, LogicallyOrNode, CompComparisonNode, AnyConditionNode, AllConditionNode, SelectionNode, Degrees2RadiansNode, Radians2DegreesNode, SinNode, CosNode, TanNode, ArcSinNode, ArcCosNode, ArcTanNode, ArcTan2Node, SinHNode, CosHNode, TanHNode, ArcsineHNode, ArccosineHNode, ArctangentHNode, ExpNode, Exp2Node, LogNode, Log2Node, SqrtNode, InvSqrtNode, AbsNode, SignNode, FloorNode, CeilNode, FractNode, DDXNode, DDYNode, FWidthNode, CompAddNode, CompSubNode, CompMulNode, CompDivNode, ModNode, MinNode, MaxNode, PowNode, StepNode, SmoothStepNode, FmaNode, ClampNode, SaturateNode, MixNode, NormalizeNode, TransformNode, RotateAboutAxisNode, FaceForwardNode, ReflectNode, RefractNode, LengthNode, DistanceNode, DotProductNode, CrossProductNode, Hash1Node, Hash2Node, Hash3Node, SimplexNoise2DNode, PerlinNoise2DNode } from '../blueprint/common/math.js';
|
|
39
|
-
import {
|
|
40
|
+
import { VertexColorNode, VertexUVNode, VertexPositionNode, PixelWorldPositionNode, VertexNormalNode, PixelNormalNode, VertexTangentNode, VertexBinormalNode, ViewMatrixNode, ProjectionMatrixNode, ViewProjMatrixNode, InvProjMatrixNode, InvViewProjMatrixNode, BillboardMatrixNode, CameraPositionNode, CameraVectorNode, CameraNearFarNode, SkyEnvTextureNode, ElapsedTimeNode, ResolveVertexPositionNode, ResolveVertexTangentNode, ResolveVertexNormalNode, VertexOutputNode, VertexIndexNode, InstanceIndexNode } from '../blueprint/material/inputs.js';
|
|
40
41
|
import { FunctionInputNode, FunctionOutputNode, FunctionCallNode } from '../blueprint/material/func.js';
|
|
41
42
|
import '../../render/rendergraph/forward_plus_builder.js';
|
|
43
|
+
import '../../render/lightpass.js';
|
|
42
44
|
import '../../render/sky.js';
|
|
43
45
|
import '../../render/clipmap.js';
|
|
44
46
|
import '../../shaders/atmosphere.js';
|
|
@@ -47,6 +49,7 @@ import '../../shadow/shadowmapper.js';
|
|
|
47
49
|
import '../../scene/mesh.js';
|
|
48
50
|
import '../../scene/basesprite.js';
|
|
49
51
|
import '../../scene/meshdrawable.js';
|
|
52
|
+
import '../../material/msdf_text.js';
|
|
50
53
|
import '../../scene/water.js';
|
|
51
54
|
import '../../scene/particlesys.js';
|
|
52
55
|
import '../../scene/batchgroup.js';
|
|
@@ -60,8 +63,8 @@ import '../../animation/joint_dynamics/collision.js';
|
|
|
60
63
|
import '../../animation/joint_dynamics/solver.js';
|
|
61
64
|
import '../../animation/joint_dynamics/joint_dynamics_system.js';
|
|
62
65
|
import { getJSONPropClass, getJSONNumberClass, getJSONStringClass, getJSONBoolClass, getJSONObjectClass, getJSONArrayClass } from './json.js';
|
|
66
|
+
import { getScriptAttachmentClass } from './scene/script.js';
|
|
63
67
|
import { getSpriteClass } from './scene/sprite.js';
|
|
64
|
-
import { getTextSpriteClass, getMSDFTextSpriteClass, getMSDFTextClass } from './scene/text.js';
|
|
65
68
|
|
|
66
69
|
const defaultValues = {
|
|
67
70
|
bool: false,
|
|
@@ -114,29 +117,29 @@ const defaultValues = {
|
|
|
114
117
|
],
|
|
115
118
|
command: null
|
|
116
119
|
};
|
|
117
|
-
/**
|
|
118
|
-
* Manages serialization and deserialization of engine objects to/from JSON,
|
|
119
|
-
* including asset resolution via a virtual file system (VFS) and asset manager.
|
|
120
|
-
*
|
|
121
|
-
* @remarks
|
|
122
|
-
* - Keeps a registry of serializable classes and their properties.
|
|
123
|
-
* - Converts object graphs to JSON using per-class metadata and property accessors.
|
|
124
|
-
* - Supports async asset embedding/export and lazy deserialization via phases.
|
|
125
|
-
* - Maps loaded assets/objects back to their source IDs for caching and deduplication.
|
|
126
|
-
*
|
|
127
|
-
* Typical workflow:
|
|
128
|
-
* 1. Construct with a `VFS`.
|
|
129
|
-
* 2. Optionally `registerClass` for custom types.
|
|
130
|
-
* 3. Use `serializeObject` and `deserializeObject` to convert between runtime objects and JSON.
|
|
131
|
-
* 4. Use `saveScene` / `loadScene` for scene I/O.
|
|
132
|
-
*
|
|
133
|
-
* Caching:
|
|
134
|
-
* - `getAssetId` returns the known source ID for an allocated asset when available.
|
|
135
|
-
*
|
|
136
|
-
* Threading:
|
|
137
|
-
* - Methods returning Promises perform async I/O using the provided `VFS`/AssetManager.
|
|
138
|
-
*
|
|
139
|
-
* @public
|
|
120
|
+
/**
|
|
121
|
+
* Manages serialization and deserialization of engine objects to/from JSON,
|
|
122
|
+
* including asset resolution via a virtual file system (VFS) and asset manager.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* - Keeps a registry of serializable classes and their properties.
|
|
126
|
+
* - Converts object graphs to JSON using per-class metadata and property accessors.
|
|
127
|
+
* - Supports async asset embedding/export and lazy deserialization via phases.
|
|
128
|
+
* - Maps loaded assets/objects back to their source IDs for caching and deduplication.
|
|
129
|
+
*
|
|
130
|
+
* Typical workflow:
|
|
131
|
+
* 1. Construct with a `VFS`.
|
|
132
|
+
* 2. Optionally `registerClass` for custom types.
|
|
133
|
+
* 3. Use `serializeObject` and `deserializeObject` to convert between runtime objects and JSON.
|
|
134
|
+
* 4. Use `saveScene` / `loadScene` for scene I/O.
|
|
135
|
+
*
|
|
136
|
+
* Caching:
|
|
137
|
+
* - `getAssetId` returns the known source ID for an allocated asset when available.
|
|
138
|
+
*
|
|
139
|
+
* Threading:
|
|
140
|
+
* - Methods returning Promises perform async I/O using the provided `VFS`/AssetManager.
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
140
143
|
*/ class ResourceManager {
|
|
141
144
|
_classMap;
|
|
142
145
|
_vfs;
|
|
@@ -146,10 +149,10 @@ const defaultValues = {
|
|
|
146
149
|
_assetManager;
|
|
147
150
|
_editorMode;
|
|
148
151
|
_allocated;
|
|
149
|
-
/**
|
|
150
|
-
* Create a ResourceManager bound to a virtual file system.
|
|
151
|
-
*
|
|
152
|
-
* @param vfs - Virtual file system used for reading/writing assets and scenes.
|
|
152
|
+
/**
|
|
153
|
+
* Create a ResourceManager bound to a virtual file system.
|
|
154
|
+
*
|
|
155
|
+
* @param vfs - Virtual file system used for reading/writing assets and scenes.
|
|
153
156
|
*/ constructor(vfs, editorMode = false){
|
|
154
157
|
this._vfs = vfs;
|
|
155
158
|
this._editorMode = editorMode;
|
|
@@ -168,9 +171,9 @@ const defaultValues = {
|
|
|
168
171
|
getScriptAttachmentClass(),
|
|
169
172
|
getAABBClass(),
|
|
170
173
|
getInterpolatorClass(),
|
|
174
|
+
getSkeletonClass(),
|
|
171
175
|
getSkeletonRigClass(),
|
|
172
176
|
getSkinBindingClass(),
|
|
173
|
-
getSkeletonClass(),
|
|
174
177
|
getJointDynamicsModifierClass(),
|
|
175
178
|
getAnimationClass(this),
|
|
176
179
|
getPropTrackClass(this),
|
|
@@ -196,17 +199,19 @@ const defaultValues = {
|
|
|
196
199
|
getPunctualLightClass(),
|
|
197
200
|
getDirectionalLightClass(),
|
|
198
201
|
getSpotLightClass(),
|
|
199
|
-
getRectLightClass(),
|
|
200
202
|
getPointLightClass(),
|
|
203
|
+
getRectLightClass(),
|
|
201
204
|
getCameraClass(),
|
|
202
205
|
getPerspectiveCameraClass(),
|
|
203
206
|
getOrthoCameraClass(),
|
|
204
207
|
getBatchGroupClass(),
|
|
205
208
|
getSceneClass(this),
|
|
209
|
+
getSubsurfaceProfileClass(),
|
|
206
210
|
...getMeshMaterialClass(),
|
|
207
211
|
...getPBRBluePrintMaterialClass(),
|
|
208
212
|
...getSpriteBlueprintMaterialClass(),
|
|
209
213
|
...getUnlitMaterialClass(this),
|
|
214
|
+
...getMToonMaterialClass(this),
|
|
210
215
|
...getLambertMaterialClass(this),
|
|
211
216
|
...getBlinnMaterialClass(this),
|
|
212
217
|
...getPBRMetallicRoughnessMaterialClass(this),
|
|
@@ -216,12 +221,12 @@ const defaultValues = {
|
|
|
216
221
|
...getStandardSpriteMaterialClass(this),
|
|
217
222
|
getBoxShapeClass(),
|
|
218
223
|
getBoxFrameShapeClass(),
|
|
224
|
+
getCapsuleShapeClass(),
|
|
219
225
|
getSphereShapeClass(),
|
|
220
226
|
getTorusShapeClass(),
|
|
221
227
|
getCylinderShapeClass(),
|
|
222
228
|
getPlaneShapeClass(),
|
|
223
229
|
getTetrahedronShapeClass(),
|
|
224
|
-
getCapsuleShapeClass(),
|
|
225
230
|
ConstantScalarNode.getSerializationCls(),
|
|
226
231
|
ConstantVec2Node.getSerializationCls(),
|
|
227
232
|
ConstantVec3Node.getSerializationCls(),
|
|
@@ -301,9 +306,6 @@ const defaultValues = {
|
|
|
301
306
|
Hash3Node.getSerializationCls(),
|
|
302
307
|
SimplexNoise2DNode.getSerializationCls(),
|
|
303
308
|
PerlinNoise2DNode.getSerializationCls(),
|
|
304
|
-
VertexOutputNode.getSerializationCls(),
|
|
305
|
-
VertexIndexNode.getSerializationCls(),
|
|
306
|
-
InstanceIndexNode.getSerializationCls(),
|
|
307
309
|
VertexColorNode.getSerializationCls(),
|
|
308
310
|
VertexUVNode.getSerializationCls(),
|
|
309
311
|
VertexPositionNode.getSerializationCls(),
|
|
@@ -333,7 +335,10 @@ const defaultValues = {
|
|
|
333
335
|
FunctionOutputNode.getSerializationCls(),
|
|
334
336
|
FunctionCallNode.getSerializationCls(this),
|
|
335
337
|
PannerNode.getSerializationCls(),
|
|
336
|
-
TextureSampleNode.getSerializationCls()
|
|
338
|
+
TextureSampleNode.getSerializationCls(),
|
|
339
|
+
VertexOutputNode.getSerializationCls(),
|
|
340
|
+
VertexIndexNode.getSerializationCls(),
|
|
341
|
+
InstanceIndexNode.getSerializationCls()
|
|
337
342
|
].map((val)=>[
|
|
338
343
|
val.ctor,
|
|
339
344
|
val
|
|
@@ -342,75 +347,67 @@ const defaultValues = {
|
|
|
342
347
|
this.registerProps(k[1]);
|
|
343
348
|
}
|
|
344
349
|
}
|
|
345
|
-
/**
|
|
346
|
-
* The virtual file system used by this manager.
|
|
347
|
-
*
|
|
348
|
-
* @remarks
|
|
349
|
-
* Used by asset fetchers and scene save/load operations.
|
|
350
|
+
/**
|
|
351
|
+
* The virtual file system used by this manager.
|
|
352
|
+
*
|
|
353
|
+
* @remarks
|
|
354
|
+
* Used by asset fetchers and scene save/load operations.
|
|
350
355
|
*/ get VFS() {
|
|
351
356
|
return this._vfs;
|
|
352
357
|
}
|
|
353
358
|
set VFS(vfs) {
|
|
354
359
|
this._vfs = vfs;
|
|
355
360
|
}
|
|
356
|
-
/**
|
|
357
|
-
* Wethether editor mode is enabled
|
|
358
|
-
*
|
|
359
|
-
* @remarks
|
|
360
|
-
* In editor mode, some properties will be disabled
|
|
361
|
+
/**
|
|
362
|
+
* Wethether editor mode is enabled
|
|
363
|
+
*
|
|
364
|
+
* @remarks
|
|
365
|
+
* In editor mode, some properties will be disabled
|
|
361
366
|
*/ get editorMode() {
|
|
362
367
|
return this._editorMode;
|
|
363
368
|
}
|
|
364
|
-
/**
|
|
365
|
-
* AssetManager
|
|
369
|
+
/**
|
|
370
|
+
* AssetManager
|
|
366
371
|
*/ get assetManager() {
|
|
367
372
|
return this._assetManager;
|
|
368
373
|
}
|
|
369
|
-
/**
|
|
370
|
-
* Get the list of all registered serializable classes.
|
|
371
|
-
*
|
|
372
|
-
* @remarks
|
|
373
|
-
* Includes built-in classes registered during construction and any custom classes
|
|
374
|
-
* registered via `registerClass`.
|
|
375
|
-
*
|
|
376
|
-
* @returns An array of `SerializableClass` metadata.
|
|
374
|
+
/**
|
|
375
|
+
* Get the list of all registered serializable classes.
|
|
376
|
+
*
|
|
377
|
+
* @remarks
|
|
378
|
+
* Includes built-in classes registered during construction and any custom classes
|
|
379
|
+
* registered via `registerClass`.
|
|
380
|
+
*
|
|
381
|
+
* @returns An array of `SerializableClass` metadata.
|
|
377
382
|
*/ getClasses() {
|
|
378
383
|
return [
|
|
379
384
|
...this._classMap.values()
|
|
380
385
|
];
|
|
381
386
|
}
|
|
382
|
-
/**
|
|
383
|
-
* Get serialization metadata by a constructor function.
|
|
384
|
-
*
|
|
385
|
-
* @param ctor - The class constructor to look up.
|
|
386
|
-
*
|
|
387
|
-
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
387
|
+
/**
|
|
388
|
+
* Get serialization metadata by a constructor function.
|
|
389
|
+
*
|
|
390
|
+
* @param ctor - The class constructor to look up.
|
|
391
|
+
*
|
|
392
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
388
393
|
*/ getClassByConstructor(ctor) {
|
|
389
|
-
|
|
390
|
-
while(typeof current === 'function' && current !== Function.prototype){
|
|
391
|
-
const cls = this._classMap.get(current);
|
|
392
|
-
if (cls) {
|
|
393
|
-
return cls;
|
|
394
|
-
}
|
|
395
|
-
current = Object.getPrototypeOf(current);
|
|
396
|
-
}
|
|
397
|
-
return null;
|
|
394
|
+
return this._classMap.get(ctor) ?? null;
|
|
398
395
|
}
|
|
399
|
-
/**
|
|
400
|
-
* Get serialization metadata by an object instance.
|
|
401
|
-
*
|
|
402
|
-
* @param obj - The object whose constructor will be used for the lookup.
|
|
403
|
-
*
|
|
404
|
-
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
396
|
+
/**
|
|
397
|
+
* Get serialization metadata by an object instance.
|
|
398
|
+
*
|
|
399
|
+
* @param obj - The object whose constructor will be used for the lookup.
|
|
400
|
+
*
|
|
401
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
405
402
|
*/ getClassByObject(obj) {
|
|
406
403
|
return this.getClassByConstructor(obj.constructor);
|
|
407
404
|
}
|
|
408
|
-
/**
|
|
409
|
-
* Get serialization metadata by class name.
|
|
410
|
-
*
|
|
411
|
-
* @param className - Fully qualified class name as stored in JSON.
|
|
412
|
-
*
|
|
413
|
-
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
405
|
+
/**
|
|
406
|
+
* Get serialization metadata by class name.
|
|
407
|
+
*
|
|
408
|
+
* @param className - Fully qualified class name as stored in JSON.
|
|
409
|
+
*
|
|
410
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
414
411
|
*/ getClassByName(className) {
|
|
415
412
|
for (const val of this._classMap){
|
|
416
413
|
if (val[0].name === className) {
|
|
@@ -419,12 +416,12 @@ const defaultValues = {
|
|
|
419
416
|
}
|
|
420
417
|
return null;
|
|
421
418
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Find the class that owns a given property accessor.
|
|
424
|
-
*
|
|
425
|
-
* @param prop - Property accessor to search for.
|
|
426
|
-
*
|
|
427
|
-
* @returns The `SerializableClass` that declares the property, or `null` if unknown.
|
|
419
|
+
/**
|
|
420
|
+
* Find the class that owns a given property accessor.
|
|
421
|
+
*
|
|
422
|
+
* @param prop - Property accessor to search for.
|
|
423
|
+
*
|
|
424
|
+
* @returns The `SerializableClass` that declares the property, or `null` if unknown.
|
|
428
425
|
*/ getClassByProperty(prop) {
|
|
429
426
|
for (const k of this._clsPropMap){
|
|
430
427
|
if (k[1].indexOf(prop) >= 0) {
|
|
@@ -433,104 +430,92 @@ const defaultValues = {
|
|
|
433
430
|
}
|
|
434
431
|
return null;
|
|
435
432
|
}
|
|
436
|
-
/**
|
|
437
|
-
* Get the properties declared on a given class.
|
|
438
|
-
*
|
|
439
|
-
* @param cls - Serializable class metadata.
|
|
440
|
-
*
|
|
441
|
-
* @returns An array of `PropertyAccessor` entries, or `null` if none.
|
|
433
|
+
/**
|
|
434
|
+
* Get the properties declared on a given class.
|
|
435
|
+
*
|
|
436
|
+
* @param cls - Serializable class metadata.
|
|
437
|
+
*
|
|
438
|
+
* @returns An array of `PropertyAccessor` entries, or `null` if none.
|
|
442
439
|
*/ getPropertiesByClass(cls) {
|
|
443
440
|
return this._clsPropMap.get(cls) ?? null;
|
|
444
441
|
}
|
|
445
|
-
/**
|
|
446
|
-
* Get all properties declared on a
|
|
447
|
-
*
|
|
448
|
-
* @param cls - Serializable class metadata.
|
|
449
|
-
*
|
|
450
|
-
* @returns An array of `PropertyAccessor` entries, or `null` if none.
|
|
442
|
+
/**
|
|
443
|
+
* Get all properties declared on a class, including inherited serializable properties.
|
|
451
444
|
*/ getAllPropertiesByClass(cls) {
|
|
452
|
-
const props =
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (!props.has(prop.name)) {
|
|
458
|
-
props.set(prop.name, prop);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
cls = this.getClassByConstructor(cls.parent);
|
|
445
|
+
const props = [];
|
|
446
|
+
let current = cls;
|
|
447
|
+
while(current){
|
|
448
|
+
props.unshift(...this.getPropertiesByClass(current) ?? []);
|
|
449
|
+
current = current.parent ? this.getClassByConstructor(current.parent) : null;
|
|
463
450
|
}
|
|
464
|
-
return
|
|
465
|
-
...props.values()
|
|
466
|
-
];
|
|
451
|
+
return props;
|
|
467
452
|
}
|
|
468
|
-
/**
|
|
469
|
-
* Get a property accessor by class and property name.
|
|
470
|
-
*
|
|
471
|
-
* @param cls - Serializable class metadata.
|
|
472
|
-
* @param name - Property name to search for.
|
|
473
|
-
*
|
|
474
|
-
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
453
|
+
/**
|
|
454
|
+
* Get a property accessor by class and property name.
|
|
455
|
+
*
|
|
456
|
+
* @param cls - Serializable class metadata.
|
|
457
|
+
* @param name - Property name to search for.
|
|
458
|
+
*
|
|
459
|
+
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
475
460
|
*/ getPropertyByClass(cls, name) {
|
|
476
461
|
return this.getPropertiesByClass(cls)?.find((value)=>value.name === name) ?? null;
|
|
477
462
|
}
|
|
478
|
-
/**
|
|
479
|
-
* Get a property accessor by its canonical path.
|
|
480
|
-
*
|
|
481
|
-
* @remarks
|
|
482
|
-
* The canonical path format is `/ClassName/propName`.
|
|
483
|
-
*
|
|
484
|
-
* @param name - Canonical property path.
|
|
485
|
-
*
|
|
486
|
-
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
463
|
+
/**
|
|
464
|
+
* Get a property accessor by its canonical path.
|
|
465
|
+
*
|
|
466
|
+
* @remarks
|
|
467
|
+
* The canonical path format is `/ClassName/propName`.
|
|
468
|
+
*
|
|
469
|
+
* @param name - Canonical property path.
|
|
470
|
+
*
|
|
471
|
+
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
487
472
|
*/ getPropertyByName(name) {
|
|
488
473
|
return this._propMap[name] ?? null;
|
|
489
474
|
}
|
|
490
|
-
/**
|
|
491
|
-
* Get the canonical path for a property accessor.
|
|
492
|
-
*
|
|
493
|
-
* @remarks
|
|
494
|
-
* Returns a string like `/ClassName/propName` if the property is registered.
|
|
495
|
-
*
|
|
496
|
-
* @param prop - Property accessor.
|
|
497
|
-
*
|
|
498
|
-
* @returns The canonical path, or `null` if unknown.
|
|
475
|
+
/**
|
|
476
|
+
* Get the canonical path for a property accessor.
|
|
477
|
+
*
|
|
478
|
+
* @remarks
|
|
479
|
+
* Returns a string like `/ClassName/propName` if the property is registered.
|
|
480
|
+
*
|
|
481
|
+
* @param prop - Property accessor.
|
|
482
|
+
*
|
|
483
|
+
* @returns The canonical path, or `null` if unknown.
|
|
499
484
|
*/ getPropertyName(prop) {
|
|
500
485
|
return this._propNameMap.get(prop) ?? null;
|
|
501
486
|
}
|
|
502
|
-
/**
|
|
503
|
-
* Register a serializable class and its properties.
|
|
504
|
-
*
|
|
505
|
-
* @remarks
|
|
506
|
-
* - No effect if the class is already registered.
|
|
507
|
-
* - Also registers the class's properties with canonical paths.
|
|
508
|
-
*
|
|
509
|
-
* @param cls - Serializable class metadata to register.
|
|
487
|
+
/**
|
|
488
|
+
* Register a serializable class and its properties.
|
|
489
|
+
*
|
|
490
|
+
* @remarks
|
|
491
|
+
* - No effect if the class is already registered.
|
|
492
|
+
* - Also registers the class's properties with canonical paths.
|
|
493
|
+
*
|
|
494
|
+
* @param cls - Serializable class metadata to register.
|
|
510
495
|
*/ registerClass(cls) {
|
|
511
496
|
if (!this._classMap.has(cls.ctor)) {
|
|
512
497
|
this._classMap.set(cls.ctor, cls);
|
|
513
498
|
this.registerProps(cls);
|
|
514
499
|
}
|
|
515
500
|
}
|
|
516
|
-
/**
|
|
517
|
-
* Get the known asset ID previously associated with a loaded/allocated asset.
|
|
518
|
-
*
|
|
519
|
-
* @remarks
|
|
520
|
-
* Returns `null` if the asset was not loaded or tracked by this manager.
|
|
521
|
-
*
|
|
522
|
-
* @param asset - Asset instance (e.g., texture, model group) to look up.
|
|
523
|
-
*
|
|
524
|
-
* @returns The asset ID string, or `null` if unknown.
|
|
501
|
+
/**
|
|
502
|
+
* Get the known asset ID previously associated with a loaded/allocated asset.
|
|
503
|
+
*
|
|
504
|
+
* @remarks
|
|
505
|
+
* Returns `null` if the asset was not loaded or tracked by this manager.
|
|
506
|
+
*
|
|
507
|
+
* @param asset - Asset instance (e.g., texture, model group) to look up.
|
|
508
|
+
*
|
|
509
|
+
* @returns The asset ID string, or `null` if unknown.
|
|
525
510
|
*/ getAssetId(asset) {
|
|
526
511
|
return this._allocated.get(asset) ?? null;
|
|
527
512
|
}
|
|
528
|
-
/**
|
|
529
|
-
* Associate an asset ID to a loaded/allocated asset.
|
|
530
|
-
*
|
|
531
|
-
* @param asset - Asset instance (e.g., texture, model group) to set Id.
|
|
532
|
-
* @param id - Asset ID to associated to this asset.
|
|
533
|
-
*
|
|
513
|
+
/**
|
|
514
|
+
* Associate an asset ID to a loaded/allocated asset.
|
|
515
|
+
*
|
|
516
|
+
* @param asset - Asset instance (e.g., texture, model group) to set Id.
|
|
517
|
+
* @param id - Asset ID to associated to this asset.
|
|
518
|
+
*
|
|
534
519
|
*/ setAssetId(asset, id) {
|
|
535
520
|
if (asset) {
|
|
536
521
|
if (id) {
|
|
@@ -540,74 +525,35 @@ const defaultValues = {
|
|
|
540
525
|
}
|
|
541
526
|
}
|
|
542
527
|
}
|
|
543
|
-
/**
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
* @
|
|
547
|
-
*
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
*
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
* - Associates the returned data with the given ID for future reverse lookup.
|
|
556
|
-
* - The ID is typically a VFS path or locator.
|
|
557
|
-
*
|
|
558
|
-
* @param path - VFS path of the binary asset.
|
|
559
|
-
*
|
|
560
|
-
* @returns A Promise that resolves to the binary content, or `null` if not found.
|
|
561
|
-
*/ async fetchBinary(path, options) {
|
|
562
|
-
const id = this.VFS.normalizePath(path);
|
|
563
|
-
const data = await this._assetManager.fetchBinaryData(id, null, null, options);
|
|
528
|
+
/**
|
|
529
|
+
* Fetch a binary asset by ID via the asset manager.
|
|
530
|
+
*
|
|
531
|
+
* @remarks
|
|
532
|
+
* - Associates the returned data with the given ID for future reverse lookup.
|
|
533
|
+
* - The ID is typically a VFS path or locator.
|
|
534
|
+
*
|
|
535
|
+
* @param id - Asset identifier or path.
|
|
536
|
+
*
|
|
537
|
+
* @returns A Promise that resolves to the binary content, or `null` if not found.
|
|
538
|
+
*/ async fetchBinary(id) {
|
|
539
|
+
const data = await this._assetManager.fetchBinaryData(id);
|
|
564
540
|
if (data) {
|
|
565
541
|
this._allocated.set(data, id);
|
|
566
542
|
}
|
|
567
543
|
return data;
|
|
568
544
|
}
|
|
569
|
-
/**
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* @
|
|
573
|
-
*
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Get a cached font asset by ID if already loaded.
|
|
584
|
-
*
|
|
585
|
-
* @param path - VFS path of TTF/OTF file.
|
|
586
|
-
* @returns The cached FontAsset if it exists and is loaded, or null if not cached or still loading.
|
|
587
|
-
*/ getFontAsset(path) {
|
|
588
|
-
return this._assetManager.getFontAsset(this.VFS.normalizePath(path));
|
|
589
|
-
}
|
|
590
|
-
/**
|
|
591
|
-
* Removes a cached font asset entry by asset instance or asset ID.
|
|
592
|
-
*
|
|
593
|
-
* @param asset - Loaded font asset instance or its asset ID/path.
|
|
594
|
-
* @returns `true` if a cache entry existed and was removed.
|
|
595
|
-
*/ releaseFontAsset(asset) {
|
|
596
|
-
const path = typeof asset === 'string' ? asset : this.getAssetId(asset);
|
|
597
|
-
return path ? this._assetManager.releaseFontAsset(this.VFS.normalizePath(path)) : false;
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Serialize an object to a JSON structure using registered class metadata.
|
|
601
|
-
*
|
|
602
|
-
* @remarks
|
|
603
|
-
* - Throws if the object's class is not registered.
|
|
604
|
-
* - Populates `asyncTasks` with pending I/O tasks for embedded resources.
|
|
605
|
-
*
|
|
606
|
-
* @param obj - The object to serialize.
|
|
607
|
-
* @param json - Optional existing JSON object to fill.
|
|
608
|
-
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
609
|
-
*
|
|
610
|
-
* @returns The serialized JSON structure.
|
|
545
|
+
/**
|
|
546
|
+
* Serialize an object to a JSON structure using registered class metadata.
|
|
547
|
+
*
|
|
548
|
+
* @remarks
|
|
549
|
+
* - Throws if the object's class is not registered.
|
|
550
|
+
* - Populates `asyncTasks` with pending I/O tasks for embedded resources.
|
|
551
|
+
*
|
|
552
|
+
* @param obj - The object to serialize.
|
|
553
|
+
* @param json - Optional existing JSON object to fill.
|
|
554
|
+
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
555
|
+
*
|
|
556
|
+
* @returns The serialized JSON structure.
|
|
611
557
|
*/ async serializeObject(obj, json, asyncTasks) {
|
|
612
558
|
if (obj === null || obj === undefined) {
|
|
613
559
|
return obj;
|
|
@@ -633,14 +579,14 @@ const defaultValues = {
|
|
|
633
579
|
}
|
|
634
580
|
return json;
|
|
635
581
|
}
|
|
636
|
-
/**
|
|
637
|
-
* Serialize object properties into a JSON structure.
|
|
638
|
-
*
|
|
639
|
-
* @param obj - The target object to serialize.
|
|
640
|
-
* @param json - The JSON structure to populate.
|
|
641
|
-
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
642
|
-
* @param info - Optional serialization metadata for the object's class.
|
|
643
|
-
* @returns A Promise that resolves when serialization is complete.
|
|
582
|
+
/**
|
|
583
|
+
* Serialize object properties into a JSON structure.
|
|
584
|
+
*
|
|
585
|
+
* @param obj - The target object to serialize.
|
|
586
|
+
* @param json - The JSON structure to populate.
|
|
587
|
+
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
588
|
+
* @param info - Optional serialization metadata for the object's class.
|
|
589
|
+
* @returns A Promise that resolves when serialization is complete.
|
|
644
590
|
*/ async serializeObjectProps(obj, json, asyncTasks, info) {
|
|
645
591
|
if (!info) {
|
|
646
592
|
const cls = this.getClasses();
|
|
@@ -657,17 +603,17 @@ const defaultValues = {
|
|
|
657
603
|
}
|
|
658
604
|
return json;
|
|
659
605
|
}
|
|
660
|
-
/**
|
|
661
|
-
* Deserialize a JSON structure into an object instance.
|
|
662
|
-
*
|
|
663
|
-
* @remarks
|
|
664
|
-
* - Uses the `ClassName` field to locate the registered class.
|
|
665
|
-
* - Supports custom `createFunc` and phased property loading.
|
|
666
|
-
*
|
|
667
|
-
* @param ctx - Context object passed to custom constructors/resolvers.
|
|
668
|
-
* @param json - The serialized JSON structure.
|
|
669
|
-
*
|
|
670
|
-
* @returns A Promise resolving to the reconstructed object instance, or `null` on failure.
|
|
606
|
+
/**
|
|
607
|
+
* Deserialize a JSON structure into an object instance.
|
|
608
|
+
*
|
|
609
|
+
* @remarks
|
|
610
|
+
* - Uses the `ClassName` field to locate the registered class.
|
|
611
|
+
* - Supports custom `createFunc` and phased property loading.
|
|
612
|
+
*
|
|
613
|
+
* @param ctx - Context object passed to custom constructors/resolvers.
|
|
614
|
+
* @param json - The serialized JSON structure.
|
|
615
|
+
*
|
|
616
|
+
* @returns A Promise resolving to the reconstructed object instance, or `null` on failure.
|
|
671
617
|
*/ async deserializeObject(ctx, json) {
|
|
672
618
|
const cls = this.getClasses();
|
|
673
619
|
const className = json['ClassName'];
|
|
@@ -700,12 +646,12 @@ const defaultValues = {
|
|
|
700
646
|
}
|
|
701
647
|
return obj;
|
|
702
648
|
}
|
|
703
|
-
/**
|
|
704
|
-
* Deserialize object properties from JSON into an existing object instance.
|
|
705
|
-
*
|
|
706
|
-
* @param obj - The target object to populate.
|
|
707
|
-
* @param json - The JSON structure containing serialized properties.
|
|
708
|
-
* @param info - Optional serialization metadata for the object's class.
|
|
649
|
+
/**
|
|
650
|
+
* Deserialize object properties from JSON into an existing object instance.
|
|
651
|
+
*
|
|
652
|
+
* @param obj - The target object to populate.
|
|
653
|
+
* @param json - The JSON structure containing serialized properties.
|
|
654
|
+
* @param info - Optional serialization metadata for the object's class.
|
|
709
655
|
*/ async deserializeObjectProps(obj, json, info) {
|
|
710
656
|
if (!info) {
|
|
711
657
|
const cls = this.getClasses();
|
|
@@ -720,14 +666,14 @@ const defaultValues = {
|
|
|
720
666
|
info = this.getClassByConstructor(info.parent);
|
|
721
667
|
}
|
|
722
668
|
}
|
|
723
|
-
/**
|
|
724
|
-
* Load a model by ID and track the allocation for reverse lookup.
|
|
725
|
-
*
|
|
726
|
-
* @param
|
|
727
|
-
* @param scene - Scene into which the model is loaded.
|
|
728
|
-
* @param options - Optional model fetch options.
|
|
729
|
-
*
|
|
730
|
-
* @returns A Promise resolving to the loaded model object, or `null` if failed.
|
|
669
|
+
/**
|
|
670
|
+
* Load a model by ID and track the allocation for reverse lookup.
|
|
671
|
+
*
|
|
672
|
+
* @param id - Model identifier or path.
|
|
673
|
+
* @param scene - Scene into which the model is loaded.
|
|
674
|
+
* @param options - Optional model fetch options.
|
|
675
|
+
*
|
|
676
|
+
* @returns A Promise resolving to the loaded model object, or `null` if failed.
|
|
731
677
|
*/ async fetchModel(path, scene, options) {
|
|
732
678
|
const id = this.VFS.normalizePath(path);
|
|
733
679
|
const model = await this._assetManager.fetchModel(scene, id, options);
|
|
@@ -737,83 +683,106 @@ const defaultValues = {
|
|
|
737
683
|
}
|
|
738
684
|
return model;
|
|
739
685
|
}
|
|
740
|
-
/**
|
|
741
|
-
* Load a texture directly from an ArrayBuffer or typed array.
|
|
742
|
-
*
|
|
743
|
-
* - Chooses an appropriate loader based on the provided MIME type.
|
|
744
|
-
* - Can upload into an existing texture if `texture` is specified.
|
|
745
|
-
*
|
|
746
|
-
* @typeParam T - Expected concrete texture type.
|
|
747
|
-
* @param arrayBuffer - Raw texture data buffer.
|
|
748
|
-
* @param mimeType - MIME type of the texture (must be supported by a registered loader).
|
|
749
|
-
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
750
|
-
* @param samplerOptions - Optional sampler options passed to the loader path.
|
|
751
|
-
* @param texture - Optional destination texture to populate.
|
|
752
|
-
* @returns A promise that resolves to the created or populated texture.
|
|
686
|
+
/**
|
|
687
|
+
* Load a texture directly from an ArrayBuffer or typed array.
|
|
688
|
+
*
|
|
689
|
+
* - Chooses an appropriate loader based on the provided MIME type.
|
|
690
|
+
* - Can upload into an existing texture if `texture` is specified.
|
|
691
|
+
*
|
|
692
|
+
* @typeParam T - Expected concrete texture type.
|
|
693
|
+
* @param arrayBuffer - Raw texture data buffer.
|
|
694
|
+
* @param mimeType - MIME type of the texture (must be supported by a registered loader).
|
|
695
|
+
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
696
|
+
* @param samplerOptions - Optional sampler options passed to the loader path.
|
|
697
|
+
* @param texture - Optional destination texture to populate.
|
|
698
|
+
* @returns A promise that resolves to the created or populated texture.
|
|
753
699
|
*/ async loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture) {
|
|
754
700
|
return this._assetManager.loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture);
|
|
755
701
|
}
|
|
756
|
-
/**
|
|
757
|
-
* Load a texture by ID and track the allocation for reverse lookup.
|
|
758
|
-
*
|
|
759
|
-
* @param
|
|
760
|
-
* @param options - Optional texture fetch options.
|
|
761
|
-
*
|
|
762
|
-
* @returns A Promise resolving to the loaded texture, or `null` if failed.
|
|
763
|
-
*/ async fetchTexture(
|
|
764
|
-
const id = this.VFS.normalizePath(path);
|
|
702
|
+
/**
|
|
703
|
+
* Load a texture by ID and track the allocation for reverse lookup.
|
|
704
|
+
*
|
|
705
|
+
* @param id - Texture identifier or path.
|
|
706
|
+
* @param options - Optional texture fetch options.
|
|
707
|
+
*
|
|
708
|
+
* @returns A Promise resolving to the loaded texture, or `null` if failed.
|
|
709
|
+
*/ async fetchTexture(id, options) {
|
|
765
710
|
const texture = await this._assetManager.fetchTexture(id, options);
|
|
766
711
|
if (texture) {
|
|
767
712
|
this._allocated.set(texture, id);
|
|
768
713
|
}
|
|
769
714
|
return texture;
|
|
770
715
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Load a material by ID and track the allocation for reverse lookup.
|
|
773
|
-
*
|
|
774
|
-
* @param
|
|
775
|
-
*
|
|
776
|
-
* @returns A Promise resolving to the loaded material, or `null` if failed.
|
|
777
|
-
*/ async fetchMaterial(
|
|
778
|
-
const id = this.VFS.normalizePath(path);
|
|
716
|
+
/**
|
|
717
|
+
* Load a material by ID and track the allocation for reverse lookup.
|
|
718
|
+
*
|
|
719
|
+
* @param id - Material identifier or path.
|
|
720
|
+
*
|
|
721
|
+
* @returns A Promise resolving to the loaded material, or `null` if failed.
|
|
722
|
+
*/ async fetchMaterial(id, options) {
|
|
779
723
|
const material = await this._assetManager.fetchMaterial(id, options);
|
|
780
724
|
if (material) {
|
|
781
725
|
this._allocated.set(material, id);
|
|
782
726
|
}
|
|
783
727
|
return material;
|
|
784
728
|
}
|
|
785
|
-
/**
|
|
786
|
-
* Reload specific blue print materials
|
|
787
|
-
*
|
|
788
|
-
* @param filter - Determine whether a blue print material should reload.
|
|
789
|
-
*
|
|
729
|
+
/**
|
|
730
|
+
* Reload specific blue print materials
|
|
731
|
+
*
|
|
732
|
+
* @param filter - Determine whether a blue print material should reload.
|
|
733
|
+
*
|
|
790
734
|
*/ async reloadBluePrintMaterials(filter) {
|
|
791
735
|
await this._assetManager.reloadBluePrintMaterials(filter);
|
|
792
736
|
}
|
|
793
|
-
/**
|
|
794
|
-
* Mark specific blue print as changed
|
|
795
|
-
* @param path - BluePrint file path
|
|
737
|
+
/**
|
|
738
|
+
* Mark specific blue print as changed
|
|
739
|
+
* @param path - BluePrint file path
|
|
796
740
|
*/ invalidateBluePrint(path) {
|
|
797
741
|
this._assetManager.invalidateBluePrint(path);
|
|
798
742
|
}
|
|
799
|
-
/**
|
|
800
|
-
*
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
743
|
+
/**
|
|
744
|
+
* Register a model loader by MIME type.
|
|
745
|
+
*/ setModelLoader(mimeType, loader) {
|
|
746
|
+
this._assetManager.setModelLoader(mimeType, loader);
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Load a primitive by ID and track the allocation for reverse lookup.
|
|
750
|
+
*
|
|
751
|
+
* @param id - Primitive identifier or path.
|
|
752
|
+
*
|
|
753
|
+
* @returns A Promise resolving to the loaded primitive, or `null` if failed.
|
|
754
|
+
*/ async fetchPrimitive(id, options) {
|
|
807
755
|
const primitive = await this._assetManager.fetchPrimitive(id, options);
|
|
808
756
|
if (primitive) {
|
|
809
757
|
this._allocated.set(primitive, id);
|
|
810
758
|
}
|
|
811
759
|
return primitive;
|
|
812
760
|
}
|
|
813
|
-
/**
|
|
814
|
-
* Load a
|
|
815
|
-
|
|
816
|
-
|
|
761
|
+
/**
|
|
762
|
+
* Load a font asset by path and track the allocation for reverse lookup.
|
|
763
|
+
*/ async fetchFontAsset(path, options) {
|
|
764
|
+
const id = this.VFS.normalizePath(path);
|
|
765
|
+
const fontAsset = await this._assetManager.fetchFontAsset(id, options);
|
|
766
|
+
if (fontAsset) {
|
|
767
|
+
this._allocated.set(fontAsset, id);
|
|
768
|
+
}
|
|
769
|
+
return fontAsset;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Returns the cached font asset if it is already loaded.
|
|
773
|
+
*/ getFontAsset(path) {
|
|
774
|
+
return this._assetManager.getFontAsset(this.VFS.normalizePath(path));
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Releases a cached font asset.
|
|
778
|
+
*/ releaseFontAsset(asset) {
|
|
779
|
+
const path = typeof asset === 'string' ? asset : this.getAssetId(asset);
|
|
780
|
+
return path ? this._assetManager.releaseFontAsset(this.VFS.normalizePath(path)) : false;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Load a prefab content.
|
|
784
|
+
* @param path - Path to the prefab JSON file in VFS.
|
|
785
|
+
* @returns A Promise resolving to the prefab json object, or `null` on failure.
|
|
817
786
|
*/ async loadPrefabContent(path) {
|
|
818
787
|
try {
|
|
819
788
|
const content = await this._vfs.readFile(path, {
|
|
@@ -826,11 +795,11 @@ const defaultValues = {
|
|
|
826
795
|
return null;
|
|
827
796
|
}
|
|
828
797
|
}
|
|
829
|
-
/**
|
|
830
|
-
* Instantiate a prefab from a JSON file via VFS.
|
|
831
|
-
* @param parent - Parent node to attach the instantiated prefab to.
|
|
832
|
-
* @param path - Path to the prefab JSON file in VFS.
|
|
833
|
-
* @returns A Promise resolving to the instantiated `SceneNode`, or `null` on failure.
|
|
798
|
+
/**
|
|
799
|
+
* Instantiate a prefab from a JSON file via VFS.
|
|
800
|
+
* @param parent - Parent node to attach the instantiated prefab to.
|
|
801
|
+
* @param path - Path to the prefab JSON file in VFS.
|
|
802
|
+
* @returns A Promise resolving to the instantiated `SceneNode`, or `null` on failure.
|
|
834
803
|
*/ async instantiatePrefab(parent, path) {
|
|
835
804
|
try {
|
|
836
805
|
const json = await this.loadPrefabContent(path);
|
|
@@ -842,7 +811,6 @@ const defaultValues = {
|
|
|
842
811
|
node.prefabId = tmpNode.get().prefabId;
|
|
843
812
|
node.parent = parent;
|
|
844
813
|
node.persistentId = randomUUID();
|
|
845
|
-
node.animationSet.resetSkeletonModifiers();
|
|
846
814
|
tmpNode.dispose();
|
|
847
815
|
return node;
|
|
848
816
|
} catch (err) {
|
|
@@ -850,16 +818,16 @@ const defaultValues = {
|
|
|
850
818
|
return null;
|
|
851
819
|
}
|
|
852
820
|
}
|
|
853
|
-
/**
|
|
854
|
-
* Load a scene from a JSON file via VFS.
|
|
855
|
-
*
|
|
856
|
-
* @remarks
|
|
857
|
-
* - Deserializes the scene graph.
|
|
858
|
-
* - Attaches scripts referenced by nodes after load (asynchronous).
|
|
859
|
-
*
|
|
860
|
-
* @param filename - Path to the scene JSON file in VFS.
|
|
861
|
-
*
|
|
862
|
-
* @returns A Promise resolving to the loaded `Scene`.
|
|
821
|
+
/**
|
|
822
|
+
* Load a scene from a JSON file via VFS.
|
|
823
|
+
*
|
|
824
|
+
* @remarks
|
|
825
|
+
* - Deserializes the scene graph.
|
|
826
|
+
* - Attaches scripts referenced by nodes after load (asynchronous).
|
|
827
|
+
*
|
|
828
|
+
* @param filename - Path to the scene JSON file in VFS.
|
|
829
|
+
*
|
|
830
|
+
* @returns A Promise resolving to the loaded `Scene`.
|
|
863
831
|
*/ async loadScene(filename) {
|
|
864
832
|
const content = await this._vfs.readFile(filename, {
|
|
865
833
|
encoding: 'utf8'
|
|
@@ -867,15 +835,15 @@ const defaultValues = {
|
|
|
867
835
|
const json = JSON.parse(content);
|
|
868
836
|
return await this.deserializeObject(null, json);
|
|
869
837
|
}
|
|
870
|
-
/**
|
|
871
|
-
* Save a scene to a JSON file via VFS.
|
|
872
|
-
*
|
|
873
|
-
* @remarks
|
|
874
|
-
* - Collects async export tasks for embedded resources and awaits them.
|
|
875
|
-
* - Writes a UTF-8 JSON representation to VFS.
|
|
876
|
-
*
|
|
877
|
-
* @param scene - Scene to serialize and save.
|
|
878
|
-
* @param filename - Destination path in VFS.
|
|
838
|
+
/**
|
|
839
|
+
* Save a scene to a JSON file via VFS.
|
|
840
|
+
*
|
|
841
|
+
* @remarks
|
|
842
|
+
* - Collects async export tasks for embedded resources and awaits them.
|
|
843
|
+
* - Writes a UTF-8 JSON representation to VFS.
|
|
844
|
+
*
|
|
845
|
+
* @param scene - Scene to serialize and save.
|
|
846
|
+
* @param filename - Destination path in VFS.
|
|
879
847
|
*/ async saveScene(scene, filename) {
|
|
880
848
|
const asyncTasks = [];
|
|
881
849
|
const content = await this.serializeObject(scene, null, asyncTasks);
|
|
@@ -925,7 +893,7 @@ const defaultValues = {
|
|
|
925
893
|
const u = q.shift();
|
|
926
894
|
const ins = gs.incoming[u] || [];
|
|
927
895
|
for (const conn of ins){
|
|
928
|
-
const v = conn.targetNodeId; //
|
|
896
|
+
const v = conn.targetNodeId; // 前驱
|
|
929
897
|
if (!reachable.has(v)) {
|
|
930
898
|
reachable.add(v);
|
|
931
899
|
q.push(v);
|
|
@@ -965,7 +933,7 @@ const defaultValues = {
|
|
|
965
933
|
for (const u of currentLevel){
|
|
966
934
|
const ins = gs.incoming[u] || [];
|
|
967
935
|
for (const conn of ins){
|
|
968
|
-
const v = conn.targetNodeId; //
|
|
936
|
+
const v = conn.targetNodeId; // 前驱
|
|
969
937
|
if (!sub.has(v)) {
|
|
970
938
|
continue;
|
|
971
939
|
}
|
|
@@ -1007,11 +975,11 @@ const defaultValues = {
|
|
|
1007
975
|
async loadBluePrint(path) {
|
|
1008
976
|
return this._assetManager.loadBluePrint(path);
|
|
1009
977
|
}
|
|
1010
|
-
/**
|
|
1011
|
-
* Clear cached allocations and asset-manager caches.
|
|
1012
|
-
*
|
|
1013
|
-
* @remarks
|
|
1014
|
-
* Useful when reloading content or changing VFS mounts.
|
|
978
|
+
/**
|
|
979
|
+
* Clear cached allocations and asset-manager caches.
|
|
980
|
+
*
|
|
981
|
+
* @remarks
|
|
982
|
+
* Useful when reloading content or changing VFS mounts.
|
|
1015
983
|
*/ clearCache() {
|
|
1016
984
|
this._allocated = new WeakMap();
|
|
1017
985
|
this._assetManager.clearCache();
|
|
@@ -1030,18 +998,18 @@ const defaultValues = {
|
|
|
1030
998
|
}
|
|
1031
999
|
return null;
|
|
1032
1000
|
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Find the object targeted by an animation track starting from a node.
|
|
1035
|
-
*
|
|
1036
|
-
* @remarks
|
|
1037
|
-
* - Parses a target path like `prop/subprop[0]/child` where indexed entries
|
|
1038
|
-
* require `object_array` type and non-indexed entries require `object` type.
|
|
1039
|
-
* - Returns `null` if any segment cannot be resolved through registered metadata.
|
|
1040
|
-
*
|
|
1041
|
-
* @param node - Root node used as the starting point.
|
|
1042
|
-
* @param track - Property track containing a target path.
|
|
1043
|
-
*
|
|
1044
|
-
* @returns The resolved target object, or `null` if not found.
|
|
1001
|
+
/**
|
|
1002
|
+
* Find the object targeted by an animation track starting from a node.
|
|
1003
|
+
*
|
|
1004
|
+
* @remarks
|
|
1005
|
+
* - Parses a target path like `prop/subprop[0]/child` where indexed entries
|
|
1006
|
+
* require `object_array` type and non-indexed entries require `object` type.
|
|
1007
|
+
* - Returns `null` if any segment cannot be resolved through registered metadata.
|
|
1008
|
+
*
|
|
1009
|
+
* @param node - Root node used as the starting point.
|
|
1010
|
+
* @param track - Property track containing a target path.
|
|
1011
|
+
*
|
|
1012
|
+
* @returns The resolved target object, or `null` if not found.
|
|
1045
1013
|
*/ findAnimationTarget(node, track) {
|
|
1046
1014
|
const target = track.target ?? '';
|
|
1047
1015
|
const value = {
|