@zephyr3d/editor 0.3.4 → 0.3.5
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-DlnbO59X.js} +2 -2
- package/dist/assistant/zephyr-types-index.json +9 -10
- package/dist/index.html +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_base.js +152 -152
- package/dist/modules/zephyr3d_base.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_loaders.js +6 -6
- package/dist/modules/zephyr3d_loaders.js.map +1 -1
- package/dist/modules/zephyr3d_scene.js +1382 -1385
- package/dist/modules/zephyr3d_scene.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/renderpass_webgpu.js +6 -6
- package/dist/vendor/zephyr3d/backend-webgpu/dist/renderpass_webgpu.js.map +1 -1
- package/dist/vendor/zephyr3d/base/dist/vfs/common.js +152 -152
- package/dist/vendor/zephyr3d/base/dist/vfs/common.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/loaders/dist/gltf/gltf_importer.js +6 -6
- package/dist/vendor/zephyr3d/loaders/dist/gltf/gltf_importer.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js +191 -194
- package/dist/vendor/zephyr3d/scene/dist/animation/animationset.js.map +1 -1
- 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 +119 -119
- package/dist/vendor/zephyr3d/scene/dist/app/scriptregistry.js.map +1 -1
- package/dist/vendor/zephyr3d/scene/dist/asset/model.js +62 -62
- 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 +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/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 +275 -275
- package/dist/vendor/zephyr3d/scene/dist/utility/serialization/manager.js.map +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/sprite.js.map +1 -1
- package/package.json +3 -3
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js +0 -320
- package/dist/vendor/zephyr3d/scene/dist/animation/joint_dynamics/convex_collider.js.map +0 -1
|
@@ -117,29 +117,29 @@ const defaultValues = {
|
|
|
117
117
|
],
|
|
118
118
|
command: null
|
|
119
119
|
};
|
|
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
|
|
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
|
|
143
143
|
*/ class ResourceManager {
|
|
144
144
|
_classMap;
|
|
145
145
|
_vfs;
|
|
@@ -149,10 +149,10 @@ const defaultValues = {
|
|
|
149
149
|
_assetManager;
|
|
150
150
|
_editorMode;
|
|
151
151
|
_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.
|
|
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.
|
|
156
156
|
*/ constructor(vfs, editorMode = false){
|
|
157
157
|
this._vfs = vfs;
|
|
158
158
|
this._editorMode = editorMode;
|
|
@@ -347,67 +347,67 @@ const defaultValues = {
|
|
|
347
347
|
this.registerProps(k[1]);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
/**
|
|
351
|
-
* The virtual file system used by this manager.
|
|
352
|
-
*
|
|
353
|
-
* @remarks
|
|
354
|
-
* 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.
|
|
355
355
|
*/ get VFS() {
|
|
356
356
|
return this._vfs;
|
|
357
357
|
}
|
|
358
358
|
set VFS(vfs) {
|
|
359
359
|
this._vfs = vfs;
|
|
360
360
|
}
|
|
361
|
-
/**
|
|
362
|
-
* Wethether editor mode is enabled
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
* 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
|
|
366
366
|
*/ get editorMode() {
|
|
367
367
|
return this._editorMode;
|
|
368
368
|
}
|
|
369
|
-
/**
|
|
370
|
-
* AssetManager
|
|
369
|
+
/**
|
|
370
|
+
* AssetManager
|
|
371
371
|
*/ get assetManager() {
|
|
372
372
|
return this._assetManager;
|
|
373
373
|
}
|
|
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.
|
|
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.
|
|
382
382
|
*/ getClasses() {
|
|
383
383
|
return [
|
|
384
384
|
...this._classMap.values()
|
|
385
385
|
];
|
|
386
386
|
}
|
|
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.
|
|
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.
|
|
393
393
|
*/ getClassByConstructor(ctor) {
|
|
394
394
|
return this._classMap.get(ctor) ?? null;
|
|
395
395
|
}
|
|
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.
|
|
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.
|
|
402
402
|
*/ getClassByObject(obj) {
|
|
403
403
|
return this.getClassByConstructor(obj.constructor);
|
|
404
404
|
}
|
|
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.
|
|
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.
|
|
411
411
|
*/ getClassByName(className) {
|
|
412
412
|
for (const val of this._classMap){
|
|
413
413
|
if (val[0].name === className) {
|
|
@@ -416,12 +416,12 @@ const defaultValues = {
|
|
|
416
416
|
}
|
|
417
417
|
return null;
|
|
418
418
|
}
|
|
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.
|
|
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.
|
|
425
425
|
*/ getClassByProperty(prop) {
|
|
426
426
|
for (const k of this._clsPropMap){
|
|
427
427
|
if (k[1].indexOf(prop) >= 0) {
|
|
@@ -430,17 +430,17 @@ const defaultValues = {
|
|
|
430
430
|
}
|
|
431
431
|
return null;
|
|
432
432
|
}
|
|
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.
|
|
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.
|
|
439
439
|
*/ getPropertiesByClass(cls) {
|
|
440
440
|
return this._clsPropMap.get(cls) ?? null;
|
|
441
441
|
}
|
|
442
|
-
/**
|
|
443
|
-
* Get all properties declared on a class, including inherited serializable properties.
|
|
442
|
+
/**
|
|
443
|
+
* Get all properties declared on a class, including inherited serializable properties.
|
|
444
444
|
*/ getAllPropertiesByClass(cls) {
|
|
445
445
|
const props = [];
|
|
446
446
|
let current = cls;
|
|
@@ -450,72 +450,72 @@ const defaultValues = {
|
|
|
450
450
|
}
|
|
451
451
|
return props;
|
|
452
452
|
}
|
|
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.
|
|
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.
|
|
460
460
|
*/ getPropertyByClass(cls, name) {
|
|
461
461
|
return this.getPropertiesByClass(cls)?.find((value)=>value.name === name) ?? null;
|
|
462
462
|
}
|
|
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.
|
|
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.
|
|
472
472
|
*/ getPropertyByName(name) {
|
|
473
473
|
return this._propMap[name] ?? null;
|
|
474
474
|
}
|
|
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.
|
|
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.
|
|
484
484
|
*/ getPropertyName(prop) {
|
|
485
485
|
return this._propNameMap.get(prop) ?? null;
|
|
486
486
|
}
|
|
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.
|
|
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.
|
|
495
495
|
*/ registerClass(cls) {
|
|
496
496
|
if (!this._classMap.has(cls.ctor)) {
|
|
497
497
|
this._classMap.set(cls.ctor, cls);
|
|
498
498
|
this.registerProps(cls);
|
|
499
499
|
}
|
|
500
500
|
}
|
|
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.
|
|
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.
|
|
510
510
|
*/ getAssetId(asset) {
|
|
511
511
|
return this._allocated.get(asset) ?? null;
|
|
512
512
|
}
|
|
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
|
-
*
|
|
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
|
+
*
|
|
519
519
|
*/ setAssetId(asset, id) {
|
|
520
520
|
if (asset) {
|
|
521
521
|
if (id) {
|
|
@@ -525,16 +525,16 @@ const defaultValues = {
|
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
527
|
}
|
|
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.
|
|
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
538
|
*/ async fetchBinary(id) {
|
|
539
539
|
const data = await this._assetManager.fetchBinaryData(id);
|
|
540
540
|
if (data) {
|
|
@@ -542,18 +542,18 @@ const defaultValues = {
|
|
|
542
542
|
}
|
|
543
543
|
return data;
|
|
544
544
|
}
|
|
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.
|
|
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.
|
|
557
557
|
*/ async serializeObject(obj, json, asyncTasks) {
|
|
558
558
|
if (obj === null || obj === undefined) {
|
|
559
559
|
return obj;
|
|
@@ -579,14 +579,14 @@ const defaultValues = {
|
|
|
579
579
|
}
|
|
580
580
|
return json;
|
|
581
581
|
}
|
|
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.
|
|
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.
|
|
590
590
|
*/ async serializeObjectProps(obj, json, asyncTasks, info) {
|
|
591
591
|
if (!info) {
|
|
592
592
|
const cls = this.getClasses();
|
|
@@ -603,17 +603,17 @@ const defaultValues = {
|
|
|
603
603
|
}
|
|
604
604
|
return json;
|
|
605
605
|
}
|
|
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.
|
|
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.
|
|
617
617
|
*/ async deserializeObject(ctx, json) {
|
|
618
618
|
const cls = this.getClasses();
|
|
619
619
|
const className = json['ClassName'];
|
|
@@ -646,12 +646,12 @@ const defaultValues = {
|
|
|
646
646
|
}
|
|
647
647
|
return obj;
|
|
648
648
|
}
|
|
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.
|
|
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.
|
|
655
655
|
*/ async deserializeObjectProps(obj, json, info) {
|
|
656
656
|
if (!info) {
|
|
657
657
|
const cls = this.getClasses();
|
|
@@ -666,14 +666,14 @@ const defaultValues = {
|
|
|
666
666
|
info = this.getClassByConstructor(info.parent);
|
|
667
667
|
}
|
|
668
668
|
}
|
|
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.
|
|
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.
|
|
677
677
|
*/ async fetchModel(path, scene, options) {
|
|
678
678
|
const id = this.VFS.normalizePath(path);
|
|
679
679
|
const model = await this._assetManager.fetchModel(scene, id, options);
|
|
@@ -683,29 +683,29 @@ const defaultValues = {
|
|
|
683
683
|
}
|
|
684
684
|
return model;
|
|
685
685
|
}
|
|
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.
|
|
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.
|
|
699
699
|
*/ async loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture) {
|
|
700
700
|
return this._assetManager.loadTextureFromBuffer(arrayBuffer, mimeType, srgb, samplerOptions, texture);
|
|
701
701
|
}
|
|
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.
|
|
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
709
|
*/ async fetchTexture(id, options) {
|
|
710
710
|
const texture = await this._assetManager.fetchTexture(id, options);
|
|
711
711
|
if (texture) {
|
|
@@ -713,12 +713,12 @@ const defaultValues = {
|
|
|
713
713
|
}
|
|
714
714
|
return texture;
|
|
715
715
|
}
|
|
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.
|
|
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
722
|
*/ async fetchMaterial(id, options) {
|
|
723
723
|
const material = await this._assetManager.fetchMaterial(id, options);
|
|
724
724
|
if (material) {
|
|
@@ -726,31 +726,31 @@ const defaultValues = {
|
|
|
726
726
|
}
|
|
727
727
|
return material;
|
|
728
728
|
}
|
|
729
|
-
/**
|
|
730
|
-
* Reload specific blue print materials
|
|
731
|
-
*
|
|
732
|
-
* @param filter - Determine whether a blue print material should reload.
|
|
733
|
-
*
|
|
729
|
+
/**
|
|
730
|
+
* Reload specific blue print materials
|
|
731
|
+
*
|
|
732
|
+
* @param filter - Determine whether a blue print material should reload.
|
|
733
|
+
*
|
|
734
734
|
*/ async reloadBluePrintMaterials(filter) {
|
|
735
735
|
await this._assetManager.reloadBluePrintMaterials(filter);
|
|
736
736
|
}
|
|
737
|
-
/**
|
|
738
|
-
* Mark specific blue print as changed
|
|
739
|
-
* @param path - BluePrint file path
|
|
737
|
+
/**
|
|
738
|
+
* Mark specific blue print as changed
|
|
739
|
+
* @param path - BluePrint file path
|
|
740
740
|
*/ invalidateBluePrint(path) {
|
|
741
741
|
this._assetManager.invalidateBluePrint(path);
|
|
742
742
|
}
|
|
743
|
-
/**
|
|
744
|
-
* Register a model loader by MIME type.
|
|
743
|
+
/**
|
|
744
|
+
* Register a model loader by MIME type.
|
|
745
745
|
*/ setModelLoader(mimeType, loader) {
|
|
746
746
|
this._assetManager.setModelLoader(mimeType, loader);
|
|
747
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.
|
|
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
754
|
*/ async fetchPrimitive(id, options) {
|
|
755
755
|
const primitive = await this._assetManager.fetchPrimitive(id, options);
|
|
756
756
|
if (primitive) {
|
|
@@ -758,8 +758,8 @@ const defaultValues = {
|
|
|
758
758
|
}
|
|
759
759
|
return primitive;
|
|
760
760
|
}
|
|
761
|
-
/**
|
|
762
|
-
* Load a font asset by path and track the allocation for reverse lookup.
|
|
761
|
+
/**
|
|
762
|
+
* Load a font asset by path and track the allocation for reverse lookup.
|
|
763
763
|
*/ async fetchFontAsset(path, options) {
|
|
764
764
|
const id = this.VFS.normalizePath(path);
|
|
765
765
|
const fontAsset = await this._assetManager.fetchFontAsset(id, options);
|
|
@@ -768,21 +768,21 @@ const defaultValues = {
|
|
|
768
768
|
}
|
|
769
769
|
return fontAsset;
|
|
770
770
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Returns the cached font asset if it is already loaded.
|
|
771
|
+
/**
|
|
772
|
+
* Returns the cached font asset if it is already loaded.
|
|
773
773
|
*/ getFontAsset(path) {
|
|
774
774
|
return this._assetManager.getFontAsset(this.VFS.normalizePath(path));
|
|
775
775
|
}
|
|
776
|
-
/**
|
|
777
|
-
* Releases a cached font asset.
|
|
776
|
+
/**
|
|
777
|
+
* Releases a cached font asset.
|
|
778
778
|
*/ releaseFontAsset(asset) {
|
|
779
779
|
const path = typeof asset === 'string' ? asset : this.getAssetId(asset);
|
|
780
780
|
return path ? this._assetManager.releaseFontAsset(this.VFS.normalizePath(path)) : false;
|
|
781
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.
|
|
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.
|
|
786
786
|
*/ async loadPrefabContent(path) {
|
|
787
787
|
try {
|
|
788
788
|
const content = await this._vfs.readFile(path, {
|
|
@@ -795,11 +795,11 @@ const defaultValues = {
|
|
|
795
795
|
return null;
|
|
796
796
|
}
|
|
797
797
|
}
|
|
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.
|
|
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.
|
|
803
803
|
*/ async instantiatePrefab(parent, path) {
|
|
804
804
|
try {
|
|
805
805
|
const json = await this.loadPrefabContent(path);
|
|
@@ -818,16 +818,16 @@ const defaultValues = {
|
|
|
818
818
|
return null;
|
|
819
819
|
}
|
|
820
820
|
}
|
|
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`.
|
|
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`.
|
|
831
831
|
*/ async loadScene(filename) {
|
|
832
832
|
const content = await this._vfs.readFile(filename, {
|
|
833
833
|
encoding: 'utf8'
|
|
@@ -835,15 +835,15 @@ const defaultValues = {
|
|
|
835
835
|
const json = JSON.parse(content);
|
|
836
836
|
return await this.deserializeObject(null, json);
|
|
837
837
|
}
|
|
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.
|
|
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.
|
|
847
847
|
*/ async saveScene(scene, filename) {
|
|
848
848
|
const asyncTasks = [];
|
|
849
849
|
const content = await this.serializeObject(scene, null, asyncTasks);
|
|
@@ -975,11 +975,11 @@ const defaultValues = {
|
|
|
975
975
|
async loadBluePrint(path) {
|
|
976
976
|
return this._assetManager.loadBluePrint(path);
|
|
977
977
|
}
|
|
978
|
-
/**
|
|
979
|
-
* Clear cached allocations and asset-manager caches.
|
|
980
|
-
*
|
|
981
|
-
* @remarks
|
|
982
|
-
* 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.
|
|
983
983
|
*/ clearCache() {
|
|
984
984
|
this._allocated = new WeakMap();
|
|
985
985
|
this._assetManager.clearCache();
|
|
@@ -998,18 +998,18 @@ const defaultValues = {
|
|
|
998
998
|
}
|
|
999
999
|
return null;
|
|
1000
1000
|
}
|
|
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.
|
|
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.
|
|
1013
1013
|
*/ findAnimationTarget(node, track) {
|
|
1014
1014
|
const target = track.target ?? '';
|
|
1015
1015
|
const value = {
|