@zephyr3d/editor 0.3.4 → 0.3.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/assets/{index-DzQzWsCG.js → index-ySiLtSxz.js} +3 -3
- package/dist/assistant/zephyr-types-index.json +14217 -7895
- package/dist/index.html +1 -1
- package/dist/modules/zephyr3d_backend-webgl.js.map +1 -1
- package/dist/modules/zephyr3d_backend-webgpu.js +13 -12
- package/dist/modules/zephyr3d_backend-webgpu.js.map +1 -1
- package/dist/modules/zephyr3d_device.js +15 -15
- package/dist/modules/zephyr3d_device.js.map +1 -1
- package/dist/modules/zephyr3d_imgui.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +3276 -1089
- package/dist/modules/zephyr3d_scene.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgl/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js +7 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/capabilities_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js +6 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/device/dist/device.js +15 -15
- package/dist/vendor/zephyr3d/device/dist/device.js.map +1 -1
- package/dist/vendor/zephyr3d/imgui/dist/index.d.ts +7 -0
- package/dist/vendor/zephyr3d/imgui/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animation.js +87 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationcontroller.js +503 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/animationcontroller.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +686 -63
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationtimeline.js +974 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/animationtimeline.js.map +1 -0
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js +19 -19
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js +131 -131
- package/dist/vendor/zephyr3d/scene/dist/app/engine.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js +17 -12
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js +2 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js +13 -13
- package/dist/vendor/zephyr3d/scene/dist/avatar/wardrobe.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js +201 -201
- package/dist/vendor/zephyr3d/scene/dist/camera/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/index.d.ts +1271 -10
- package/dist/vendor/zephyr3d/scene/dist/index.js +3 -1
- package/dist/vendor/zephyr3d/scene/dist/index.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lit.js +7 -3
- package/dist/vendor/zephyr3d/scene/dist/material/mixins/lit.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js +4 -4
- package/dist/vendor/zephyr3d/scene/dist/material/mtoon.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js +11 -11
- package/dist/vendor/zephyr3d/scene/dist/material/pbrblueprint.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js +284 -284
- package/dist/vendor/zephyr3d/scene/dist/material/shader/helper.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js +9 -9
- package/dist/vendor/zephyr3d/scene/dist/posteffect/ssr.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js +5 -5
- package/dist/vendor/zephyr3d/scene/dist/render/lightpass.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js +7 -7
- package/dist/vendor/zephyr3d/scene/dist/render/renderer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/esm.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js +45 -45
- package/dist/vendor/zephyr3d/scene/dist/shadow/shadow_region.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js +276 -275
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js +4 -3
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js +3 -2
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/package.json +8 -8
|
@@ -58,6 +58,7 @@ import '../../scene/terrain-cm/grass.js';
|
|
|
58
58
|
import '../../scene/raycast_visitor.js';
|
|
59
59
|
import { AssetManager } from '../../asset/assetmanager.js';
|
|
60
60
|
import '../../animation/skeleton.js';
|
|
61
|
+
import '../../animation/animationset.js';
|
|
61
62
|
import '../../animation/eulerrotationtrack.js';
|
|
62
63
|
import '../../animation/joint_dynamics/collision.js';
|
|
63
64
|
import '../../animation/joint_dynamics/solver.js';
|
|
@@ -117,29 +118,29 @@ const defaultValues = {
|
|
|
117
118
|
],
|
|
118
119
|
command: null
|
|
119
120
|
};
|
|
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
|
|
121
|
+
/**
|
|
122
|
+
* Manages serialization and deserialization of engine objects to/from JSON,
|
|
123
|
+
* including asset resolution via a virtual file system (VFS) and asset manager.
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* - Keeps a registry of serializable classes and their properties.
|
|
127
|
+
* - Converts object graphs to JSON using per-class metadata and property accessors.
|
|
128
|
+
* - Supports async asset embedding/export and lazy deserialization via phases.
|
|
129
|
+
* - Maps loaded assets/objects back to their source IDs for caching and deduplication.
|
|
130
|
+
*
|
|
131
|
+
* Typical workflow:
|
|
132
|
+
* 1. Construct with a `VFS`.
|
|
133
|
+
* 2. Optionally `registerClass` for custom types.
|
|
134
|
+
* 3. Use `serializeObject` and `deserializeObject` to convert between runtime objects and JSON.
|
|
135
|
+
* 4. Use `saveScene` / `loadScene` for scene I/O.
|
|
136
|
+
*
|
|
137
|
+
* Caching:
|
|
138
|
+
* - `getAssetId` returns the known source ID for an allocated asset when available.
|
|
139
|
+
*
|
|
140
|
+
* Threading:
|
|
141
|
+
* - Methods returning Promises perform async I/O using the provided `VFS`/AssetManager.
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
143
144
|
*/ class ResourceManager {
|
|
144
145
|
_classMap;
|
|
145
146
|
_vfs;
|
|
@@ -149,10 +150,10 @@ const defaultValues = {
|
|
|
149
150
|
_assetManager;
|
|
150
151
|
_editorMode;
|
|
151
152
|
_allocated;
|
|
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
|
+
/**
|
|
154
|
+
* Create a ResourceManager bound to a virtual file system.
|
|
155
|
+
*
|
|
156
|
+
* @param vfs - Virtual file system used for reading/writing assets and scenes.
|
|
156
157
|
*/ constructor(vfs, editorMode = false){
|
|
157
158
|
this._vfs = vfs;
|
|
158
159
|
this._editorMode = editorMode;
|
|
@@ -347,67 +348,67 @@ const defaultValues = {
|
|
|
347
348
|
this.registerProps(k[1]);
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
|
-
/**
|
|
351
|
-
* The virtual file system used by this manager.
|
|
352
|
-
*
|
|
353
|
-
* @remarks
|
|
354
|
-
* Used by asset fetchers and scene save/load operations.
|
|
351
|
+
/**
|
|
352
|
+
* The virtual file system used by this manager.
|
|
353
|
+
*
|
|
354
|
+
* @remarks
|
|
355
|
+
* Used by asset fetchers and scene save/load operations.
|
|
355
356
|
*/ get VFS() {
|
|
356
357
|
return this._vfs;
|
|
357
358
|
}
|
|
358
359
|
set VFS(vfs) {
|
|
359
360
|
this._vfs = vfs;
|
|
360
361
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Wethether editor mode is enabled
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
* In editor mode, some properties will be disabled
|
|
362
|
+
/**
|
|
363
|
+
* Wethether editor mode is enabled
|
|
364
|
+
*
|
|
365
|
+
* @remarks
|
|
366
|
+
* In editor mode, some properties will be disabled
|
|
366
367
|
*/ get editorMode() {
|
|
367
368
|
return this._editorMode;
|
|
368
369
|
}
|
|
369
|
-
/**
|
|
370
|
-
* AssetManager
|
|
370
|
+
/**
|
|
371
|
+
* AssetManager
|
|
371
372
|
*/ get assetManager() {
|
|
372
373
|
return this._assetManager;
|
|
373
374
|
}
|
|
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.
|
|
375
|
+
/**
|
|
376
|
+
* Get the list of all registered serializable classes.
|
|
377
|
+
*
|
|
378
|
+
* @remarks
|
|
379
|
+
* Includes built-in classes registered during construction and any custom classes
|
|
380
|
+
* registered via `registerClass`.
|
|
381
|
+
*
|
|
382
|
+
* @returns An array of `SerializableClass` metadata.
|
|
382
383
|
*/ getClasses() {
|
|
383
384
|
return [
|
|
384
385
|
...this._classMap.values()
|
|
385
386
|
];
|
|
386
387
|
}
|
|
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
|
+
/**
|
|
389
|
+
* Get serialization metadata by a constructor function.
|
|
390
|
+
*
|
|
391
|
+
* @param ctor - The class constructor to look up.
|
|
392
|
+
*
|
|
393
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
393
394
|
*/ getClassByConstructor(ctor) {
|
|
394
395
|
return this._classMap.get(ctor) ?? null;
|
|
395
396
|
}
|
|
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.
|
|
397
|
+
/**
|
|
398
|
+
* Get serialization metadata by an object instance.
|
|
399
|
+
*
|
|
400
|
+
* @param obj - The object whose constructor will be used for the lookup.
|
|
401
|
+
*
|
|
402
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
402
403
|
*/ getClassByObject(obj) {
|
|
403
404
|
return this.getClassByConstructor(obj.constructor);
|
|
404
405
|
}
|
|
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.
|
|
406
|
+
/**
|
|
407
|
+
* Get serialization metadata by class name.
|
|
408
|
+
*
|
|
409
|
+
* @param className - Fully qualified class name as stored in JSON.
|
|
410
|
+
*
|
|
411
|
+
* @returns The `SerializableClass` metadata, or `null` if not found.
|
|
411
412
|
*/ getClassByName(className) {
|
|
412
413
|
for (const val of this._classMap){
|
|
413
414
|
if (val[0].name === className) {
|
|
@@ -416,12 +417,12 @@ const defaultValues = {
|
|
|
416
417
|
}
|
|
417
418
|
return null;
|
|
418
419
|
}
|
|
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.
|
|
420
|
+
/**
|
|
421
|
+
* Find the class that owns a given property accessor.
|
|
422
|
+
*
|
|
423
|
+
* @param prop - Property accessor to search for.
|
|
424
|
+
*
|
|
425
|
+
* @returns The `SerializableClass` that declares the property, or `null` if unknown.
|
|
425
426
|
*/ getClassByProperty(prop) {
|
|
426
427
|
for (const k of this._clsPropMap){
|
|
427
428
|
if (k[1].indexOf(prop) >= 0) {
|
|
@@ -430,17 +431,17 @@ const defaultValues = {
|
|
|
430
431
|
}
|
|
431
432
|
return null;
|
|
432
433
|
}
|
|
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.
|
|
434
|
+
/**
|
|
435
|
+
* Get the properties declared on a given class.
|
|
436
|
+
*
|
|
437
|
+
* @param cls - Serializable class metadata.
|
|
438
|
+
*
|
|
439
|
+
* @returns An array of `PropertyAccessor` entries, or `null` if none.
|
|
439
440
|
*/ getPropertiesByClass(cls) {
|
|
440
441
|
return this._clsPropMap.get(cls) ?? null;
|
|
441
442
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Get all properties declared on a class, including inherited serializable properties.
|
|
443
|
+
/**
|
|
444
|
+
* Get all properties declared on a class, including inherited serializable properties.
|
|
444
445
|
*/ getAllPropertiesByClass(cls) {
|
|
445
446
|
const props = [];
|
|
446
447
|
let current = cls;
|
|
@@ -450,72 +451,72 @@ const defaultValues = {
|
|
|
450
451
|
}
|
|
451
452
|
return props;
|
|
452
453
|
}
|
|
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.
|
|
454
|
+
/**
|
|
455
|
+
* Get a property accessor by class and property name.
|
|
456
|
+
*
|
|
457
|
+
* @param cls - Serializable class metadata.
|
|
458
|
+
* @param name - Property name to search for.
|
|
459
|
+
*
|
|
460
|
+
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
460
461
|
*/ getPropertyByClass(cls, name) {
|
|
461
462
|
return this.getPropertiesByClass(cls)?.find((value)=>value.name === name) ?? null;
|
|
462
463
|
}
|
|
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.
|
|
464
|
+
/**
|
|
465
|
+
* Get a property accessor by its canonical path.
|
|
466
|
+
*
|
|
467
|
+
* @remarks
|
|
468
|
+
* The canonical path format is `/ClassName/propName`.
|
|
469
|
+
*
|
|
470
|
+
* @param name - Canonical property path.
|
|
471
|
+
*
|
|
472
|
+
* @returns The `PropertyAccessor`, or `null` if not found.
|
|
472
473
|
*/ getPropertyByName(name) {
|
|
473
474
|
return this._propMap[name] ?? null;
|
|
474
475
|
}
|
|
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.
|
|
476
|
+
/**
|
|
477
|
+
* Get the canonical path for a property accessor.
|
|
478
|
+
*
|
|
479
|
+
* @remarks
|
|
480
|
+
* Returns a string like `/ClassName/propName` if the property is registered.
|
|
481
|
+
*
|
|
482
|
+
* @param prop - Property accessor.
|
|
483
|
+
*
|
|
484
|
+
* @returns The canonical path, or `null` if unknown.
|
|
484
485
|
*/ getPropertyName(prop) {
|
|
485
486
|
return this._propNameMap.get(prop) ?? null;
|
|
486
487
|
}
|
|
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.
|
|
488
|
+
/**
|
|
489
|
+
* Register a serializable class and its properties.
|
|
490
|
+
*
|
|
491
|
+
* @remarks
|
|
492
|
+
* - No effect if the class is already registered.
|
|
493
|
+
* - Also registers the class's properties with canonical paths.
|
|
494
|
+
*
|
|
495
|
+
* @param cls - Serializable class metadata to register.
|
|
495
496
|
*/ registerClass(cls) {
|
|
496
497
|
if (!this._classMap.has(cls.ctor)) {
|
|
497
498
|
this._classMap.set(cls.ctor, cls);
|
|
498
499
|
this.registerProps(cls);
|
|
499
500
|
}
|
|
500
501
|
}
|
|
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.
|
|
502
|
+
/**
|
|
503
|
+
* Get the known asset ID previously associated with a loaded/allocated asset.
|
|
504
|
+
*
|
|
505
|
+
* @remarks
|
|
506
|
+
* Returns `null` if the asset was not loaded or tracked by this manager.
|
|
507
|
+
*
|
|
508
|
+
* @param asset - Asset instance (e.g., texture, model group) to look up.
|
|
509
|
+
*
|
|
510
|
+
* @returns The asset ID string, or `null` if unknown.
|
|
510
511
|
*/ getAssetId(asset) {
|
|
511
512
|
return this._allocated.get(asset) ?? null;
|
|
512
513
|
}
|
|
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
|
-
*
|
|
514
|
+
/**
|
|
515
|
+
* Associate an asset ID to a loaded/allocated asset.
|
|
516
|
+
*
|
|
517
|
+
* @param asset - Asset instance (e.g., texture, model group) to set Id.
|
|
518
|
+
* @param id - Asset ID to associated to this asset.
|
|
519
|
+
*
|
|
519
520
|
*/ setAssetId(asset, id) {
|
|
520
521
|
if (asset) {
|
|
521
522
|
if (id) {
|
|
@@ -525,16 +526,16 @@ const defaultValues = {
|
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
}
|
|
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.
|
|
529
|
+
/**
|
|
530
|
+
* Fetch a binary asset by ID via the asset manager.
|
|
531
|
+
*
|
|
532
|
+
* @remarks
|
|
533
|
+
* - Associates the returned data with the given ID for future reverse lookup.
|
|
534
|
+
* - The ID is typically a VFS path or locator.
|
|
535
|
+
*
|
|
536
|
+
* @param id - Asset identifier or path.
|
|
537
|
+
*
|
|
538
|
+
* @returns A Promise that resolves to the binary content, or `null` if not found.
|
|
538
539
|
*/ async fetchBinary(id) {
|
|
539
540
|
const data = await this._assetManager.fetchBinaryData(id);
|
|
540
541
|
if (data) {
|
|
@@ -542,18 +543,18 @@ const defaultValues = {
|
|
|
542
543
|
}
|
|
543
544
|
return data;
|
|
544
545
|
}
|
|
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.
|
|
546
|
+
/**
|
|
547
|
+
* Serialize an object to a JSON structure using registered class metadata.
|
|
548
|
+
*
|
|
549
|
+
* @remarks
|
|
550
|
+
* - Throws if the object's class is not registered.
|
|
551
|
+
* - Populates `asyncTasks` with pending I/O tasks for embedded resources.
|
|
552
|
+
*
|
|
553
|
+
* @param obj - The object to serialize.
|
|
554
|
+
* @param json - Optional existing JSON object to fill.
|
|
555
|
+
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
556
|
+
*
|
|
557
|
+
* @returns The serialized JSON structure.
|
|
557
558
|
*/ async serializeObject(obj, json, asyncTasks) {
|
|
558
559
|
if (obj === null || obj === undefined) {
|
|
559
560
|
return obj;
|
|
@@ -579,14 +580,14 @@ const defaultValues = {
|
|
|
579
580
|
}
|
|
580
581
|
return json;
|
|
581
582
|
}
|
|
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.
|
|
583
|
+
/**
|
|
584
|
+
* Serialize object properties into a JSON structure.
|
|
585
|
+
*
|
|
586
|
+
* @param obj - The target object to serialize.
|
|
587
|
+
* @param json - The JSON structure to populate.
|
|
588
|
+
* @param asyncTasks - Optional list to collect async tasks for embedded asset export.
|
|
589
|
+
* @param info - Optional serialization metadata for the object's class.
|
|
590
|
+
* @returns A Promise that resolves when serialization is complete.
|
|
590
591
|
*/ async serializeObjectProps(obj, json, asyncTasks, info) {
|
|
591
592
|
if (!info) {
|
|
592
593
|
const cls = this.getClasses();
|
|
@@ -603,17 +604,17 @@ const defaultValues = {
|
|
|
603
604
|
}
|
|
604
605
|
return json;
|
|
605
606
|
}
|
|
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.
|
|
607
|
+
/**
|
|
608
|
+
* Deserialize a JSON structure into an object instance.
|
|
609
|
+
*
|
|
610
|
+
* @remarks
|
|
611
|
+
* - Uses the `ClassName` field to locate the registered class.
|
|
612
|
+
* - Supports custom `createFunc` and phased property loading.
|
|
613
|
+
*
|
|
614
|
+
* @param ctx - Context object passed to custom constructors/resolvers.
|
|
615
|
+
* @param json - The serialized JSON structure.
|
|
616
|
+
*
|
|
617
|
+
* @returns A Promise resolving to the reconstructed object instance, or `null` on failure.
|
|
617
618
|
*/ async deserializeObject(ctx, json) {
|
|
618
619
|
const cls = this.getClasses();
|
|
619
620
|
const className = json['ClassName'];
|
|
@@ -646,12 +647,12 @@ const defaultValues = {
|
|
|
646
647
|
}
|
|
647
648
|
return obj;
|
|
648
649
|
}
|
|
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.
|
|
650
|
+
/**
|
|
651
|
+
* Deserialize object properties from JSON into an existing object instance.
|
|
652
|
+
*
|
|
653
|
+
* @param obj - The target object to populate.
|
|
654
|
+
* @param json - The JSON structure containing serialized properties.
|
|
655
|
+
* @param info - Optional serialization metadata for the object's class.
|
|
655
656
|
*/ async deserializeObjectProps(obj, json, info) {
|
|
656
657
|
if (!info) {
|
|
657
658
|
const cls = this.getClasses();
|
|
@@ -666,14 +667,14 @@ const defaultValues = {
|
|
|
666
667
|
info = this.getClassByConstructor(info.parent);
|
|
667
668
|
}
|
|
668
669
|
}
|
|
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.
|
|
670
|
+
/**
|
|
671
|
+
* Load a model by ID and track the allocation for reverse lookup.
|
|
672
|
+
*
|
|
673
|
+
* @param id - Model identifier or path.
|
|
674
|
+
* @param scene - Scene into which the model is loaded.
|
|
675
|
+
* @param options - Optional model fetch options.
|
|
676
|
+
*
|
|
677
|
+
* @returns A Promise resolving to the loaded model object, or `null` if failed.
|
|
677
678
|
*/ async fetchModel(path, scene, options) {
|
|
678
679
|
const id = this.VFS.normalizePath(path);
|
|
679
680
|
const model = await this._assetManager.fetchModel(scene, id, options);
|
|
@@ -683,29 +684,29 @@ const defaultValues = {
|
|
|
683
684
|
}
|
|
684
685
|
return model;
|
|
685
686
|
}
|
|
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.
|
|
687
|
+
/**
|
|
688
|
+
* Load a texture directly from an ArrayBuffer or typed array.
|
|
689
|
+
*
|
|
690
|
+
* - Chooses an appropriate loader based on the provided MIME type.
|
|
691
|
+
* - Can upload into an existing texture if `texture` is specified.
|
|
692
|
+
*
|
|
693
|
+
* @typeParam T - Expected concrete texture type.
|
|
694
|
+
* @param arrayBuffer - Raw texture data buffer.
|
|
695
|
+
* @param mimeType - MIME type of the texture (must be supported by a registered loader).
|
|
696
|
+
* @param srgb - If true, treat image as sRGB; otherwise linear.
|
|
697
|
+
* @param samplerOptions - Optional sampler options passed to the loader path.
|
|
698
|
+
* @param texture - Optional destination texture to populate.
|
|
699
|
+
* @returns A promise that resolves to the created or populated texture.
|
|
699
700
|
*/ async loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture) {
|
|
700
701
|
return this._assetManager.loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture);
|
|
701
702
|
}
|
|
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.
|
|
703
|
+
/**
|
|
704
|
+
* Load a texture by ID and track the allocation for reverse lookup.
|
|
705
|
+
*
|
|
706
|
+
* @param id - Texture identifier or path.
|
|
707
|
+
* @param options - Optional texture fetch options.
|
|
708
|
+
*
|
|
709
|
+
* @returns A Promise resolving to the loaded texture, or `null` if failed.
|
|
709
710
|
*/ async fetchTexture(id, options) {
|
|
710
711
|
const texture = await this._assetManager.fetchTexture(id, options);
|
|
711
712
|
if (texture) {
|
|
@@ -713,12 +714,12 @@ const defaultValues = {
|
|
|
713
714
|
}
|
|
714
715
|
return texture;
|
|
715
716
|
}
|
|
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.
|
|
717
|
+
/**
|
|
718
|
+
* Load a material by ID and track the allocation for reverse lookup.
|
|
719
|
+
*
|
|
720
|
+
* @param id - Material identifier or path.
|
|
721
|
+
*
|
|
722
|
+
* @returns A Promise resolving to the loaded material, or `null` if failed.
|
|
722
723
|
*/ async fetchMaterial(id, options) {
|
|
723
724
|
const material = await this._assetManager.fetchMaterial(id, options);
|
|
724
725
|
if (material) {
|
|
@@ -726,31 +727,31 @@ const defaultValues = {
|
|
|
726
727
|
}
|
|
727
728
|
return material;
|
|
728
729
|
}
|
|
729
|
-
/**
|
|
730
|
-
* Reload specific blue print materials
|
|
731
|
-
*
|
|
732
|
-
* @param filter - Determine whether a blue print material should reload.
|
|
733
|
-
*
|
|
730
|
+
/**
|
|
731
|
+
* Reload specific blue print materials
|
|
732
|
+
*
|
|
733
|
+
* @param filter - Determine whether a blue print material should reload.
|
|
734
|
+
*
|
|
734
735
|
*/ async reloadBluePrintMaterials(filter) {
|
|
735
736
|
await this._assetManager.reloadBluePrintMaterials(filter);
|
|
736
737
|
}
|
|
737
|
-
/**
|
|
738
|
-
* Mark specific blue print as changed
|
|
739
|
-
* @param path - BluePrint file path
|
|
738
|
+
/**
|
|
739
|
+
* Mark specific blue print as changed
|
|
740
|
+
* @param path - BluePrint file path
|
|
740
741
|
*/ invalidateBluePrint(path) {
|
|
741
742
|
this._assetManager.invalidateBluePrint(path);
|
|
742
743
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Register a model loader by MIME type.
|
|
744
|
+
/**
|
|
745
|
+
* Register a model loader by MIME type.
|
|
745
746
|
*/ setModelLoader(mimeType, loader) {
|
|
746
747
|
this._assetManager.setModelLoader(mimeType, loader);
|
|
747
748
|
}
|
|
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.
|
|
749
|
+
/**
|
|
750
|
+
* Load a primitive by ID and track the allocation for reverse lookup.
|
|
751
|
+
*
|
|
752
|
+
* @param id - Primitive identifier or path.
|
|
753
|
+
*
|
|
754
|
+
* @returns A Promise resolving to the loaded primitive, or `null` if failed.
|
|
754
755
|
*/ async fetchPrimitive(id, options) {
|
|
755
756
|
const primitive = await this._assetManager.fetchPrimitive(id, options);
|
|
756
757
|
if (primitive) {
|
|
@@ -758,8 +759,8 @@ const defaultValues = {
|
|
|
758
759
|
}
|
|
759
760
|
return primitive;
|
|
760
761
|
}
|
|
761
|
-
/**
|
|
762
|
-
* Load a font asset by path and track the allocation for reverse lookup.
|
|
762
|
+
/**
|
|
763
|
+
* Load a font asset by path and track the allocation for reverse lookup.
|
|
763
764
|
*/ async fetchFontAsset(path, options) {
|
|
764
765
|
const id = this.VFS.normalizePath(path);
|
|
765
766
|
const fontAsset = await this._assetManager.fetchFontAsset(id, options);
|
|
@@ -768,21 +769,21 @@ const defaultValues = {
|
|
|
768
769
|
}
|
|
769
770
|
return fontAsset;
|
|
770
771
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Returns the cached font asset if it is already loaded.
|
|
772
|
+
/**
|
|
773
|
+
* Returns the cached font asset if it is already loaded.
|
|
773
774
|
*/ getFontAsset(path) {
|
|
774
775
|
return this._assetManager.getFontAsset(this.VFS.normalizePath(path));
|
|
775
776
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Releases a cached font asset.
|
|
777
|
+
/**
|
|
778
|
+
* Releases a cached font asset.
|
|
778
779
|
*/ releaseFontAsset(asset) {
|
|
779
780
|
const path = typeof asset === 'string' ? asset : this.getAssetId(asset);
|
|
780
781
|
return path ? this._assetManager.releaseFontAsset(this.VFS.normalizePath(path)) : false;
|
|
781
782
|
}
|
|
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.
|
|
783
|
+
/**
|
|
784
|
+
* Load a prefab content.
|
|
785
|
+
* @param path - Path to the prefab JSON file in VFS.
|
|
786
|
+
* @returns A Promise resolving to the prefab json object, or `null` on failure.
|
|
786
787
|
*/ async loadPrefabContent(path) {
|
|
787
788
|
try {
|
|
788
789
|
const content = await this._vfs.readFile(path, {
|
|
@@ -795,11 +796,11 @@ const defaultValues = {
|
|
|
795
796
|
return null;
|
|
796
797
|
}
|
|
797
798
|
}
|
|
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.
|
|
799
|
+
/**
|
|
800
|
+
* Instantiate a prefab from a JSON file via VFS.
|
|
801
|
+
* @param parent - Parent node to attach the instantiated prefab to.
|
|
802
|
+
* @param path - Path to the prefab JSON file in VFS.
|
|
803
|
+
* @returns A Promise resolving to the instantiated `SceneNode`, or `null` on failure.
|
|
803
804
|
*/ async instantiatePrefab(parent, path) {
|
|
804
805
|
try {
|
|
805
806
|
const json = await this.loadPrefabContent(path);
|
|
@@ -818,16 +819,16 @@ const defaultValues = {
|
|
|
818
819
|
return null;
|
|
819
820
|
}
|
|
820
821
|
}
|
|
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`.
|
|
822
|
+
/**
|
|
823
|
+
* Load a scene from a JSON file via VFS.
|
|
824
|
+
*
|
|
825
|
+
* @remarks
|
|
826
|
+
* - Deserializes the scene graph.
|
|
827
|
+
* - Attaches scripts referenced by nodes after load (asynchronous).
|
|
828
|
+
*
|
|
829
|
+
* @param filename - Path to the scene JSON file in VFS.
|
|
830
|
+
*
|
|
831
|
+
* @returns A Promise resolving to the loaded `Scene`.
|
|
831
832
|
*/ async loadScene(filename) {
|
|
832
833
|
const content = await this._vfs.readFile(filename, {
|
|
833
834
|
encoding: 'utf8'
|
|
@@ -835,15 +836,15 @@ const defaultValues = {
|
|
|
835
836
|
const json = JSON.parse(content);
|
|
836
837
|
return await this.deserializeObject(null, json);
|
|
837
838
|
}
|
|
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.
|
|
839
|
+
/**
|
|
840
|
+
* Save a scene to a JSON file via VFS.
|
|
841
|
+
*
|
|
842
|
+
* @remarks
|
|
843
|
+
* - Collects async export tasks for embedded resources and awaits them.
|
|
844
|
+
* - Writes a UTF-8 JSON representation to VFS.
|
|
845
|
+
*
|
|
846
|
+
* @param scene - Scene to serialize and save.
|
|
847
|
+
* @param filename - Destination path in VFS.
|
|
847
848
|
*/ async saveScene(scene, filename) {
|
|
848
849
|
const asyncTasks = [];
|
|
849
850
|
const content = await this.serializeObject(scene, null, asyncTasks);
|
|
@@ -975,11 +976,11 @@ const defaultValues = {
|
|
|
975
976
|
async loadBluePrint(path) {
|
|
976
977
|
return this._assetManager.loadBluePrint(path);
|
|
977
978
|
}
|
|
978
|
-
/**
|
|
979
|
-
* Clear cached allocations and asset-manager caches.
|
|
980
|
-
*
|
|
981
|
-
* @remarks
|
|
982
|
-
* Useful when reloading content or changing VFS mounts.
|
|
979
|
+
/**
|
|
980
|
+
* Clear cached allocations and asset-manager caches.
|
|
981
|
+
*
|
|
982
|
+
* @remarks
|
|
983
|
+
* Useful when reloading content or changing VFS mounts.
|
|
983
984
|
*/ clearCache() {
|
|
984
985
|
this._allocated = new WeakMap();
|
|
985
986
|
this._assetManager.clearCache();
|
|
@@ -998,18 +999,18 @@ const defaultValues = {
|
|
|
998
999
|
}
|
|
999
1000
|
return null;
|
|
1000
1001
|
}
|
|
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.
|
|
1002
|
+
/**
|
|
1003
|
+
* Find the object targeted by an animation track starting from a node.
|
|
1004
|
+
*
|
|
1005
|
+
* @remarks
|
|
1006
|
+
* - Parses a target path like `prop/subprop[0]/child` where indexed entries
|
|
1007
|
+
* require `object_array` type and non-indexed entries require `object` type.
|
|
1008
|
+
* - Returns `null` if any segment cannot be resolved through registered metadata.
|
|
1009
|
+
*
|
|
1010
|
+
* @param node - Root node used as the starting point.
|
|
1011
|
+
* @param track - Property track containing a target path.
|
|
1012
|
+
*
|
|
1013
|
+
* @returns The resolved target object, or `null` if not found.
|
|
1013
1014
|
*/ findAnimationTarget(node, track) {
|
|
1014
1015
|
const target = track.target ?? '';
|
|
1015
1016
|
const value = {
|