@naanouff/w3dts-scenedd 0.0.0-stage → 0.1.22
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/README.md +100 -3
- package/dist/codecs/ComponentCodecRegistry.d.ts +20 -0
- package/dist/codecs/ComponentCodecRegistry.d.ts.map +1 -0
- package/dist/contracts/ISceneComponentCodec.d.ts +69 -0
- package/dist/contracts/ISceneComponentCodec.d.ts.map +1 -0
- package/dist/descriptors/EngineConfigDescriptor.d.ts +18 -0
- package/dist/descriptors/EngineConfigDescriptor.d.ts.map +1 -0
- package/dist/descriptors/EntityDescriptor.d.ts +270 -0
- package/dist/descriptors/EntityDescriptor.d.ts.map +1 -0
- package/dist/descriptors/EnvironmentDescriptor.d.ts +30 -0
- package/dist/descriptors/EnvironmentDescriptor.d.ts.map +1 -0
- package/dist/descriptors/PhysicsSetupDescriptor.d.ts +12 -0
- package/dist/descriptors/PhysicsSetupDescriptor.d.ts.map +1 -0
- package/dist/descriptors/ResourceManifest.d.ts +57 -0
- package/dist/descriptors/ResourceManifest.d.ts.map +1 -0
- package/dist/descriptors/SceneDescriptor.d.ts +52 -0
- package/dist/descriptors/SceneDescriptor.d.ts.map +1 -0
- package/dist/descriptors/ScriptDescriptor.d.ts +15 -0
- package/dist/descriptors/ScriptDescriptor.d.ts.map +1 -0
- package/dist/descriptors/TerrainDescriptor.d.ts +39 -0
- package/dist/descriptors/TerrainDescriptor.d.ts.map +1 -0
- package/dist/descriptors/index.d.ts +13 -0
- package/dist/descriptors/index.d.ts.map +1 -0
- package/dist/extensions/w3dtsUiExtension.d.ts +113 -0
- package/dist/extensions/w3dtsUiExtension.d.ts.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/serialization/SceneDeserializer.d.ts +7 -0
- package/dist/serialization/SceneDeserializer.d.ts.map +1 -0
- package/dist/serialization/SceneSerializer.d.ts +30 -0
- package/dist/serialization/SceneSerializer.d.ts.map +1 -0
- package/dist/serialization/binaryCodec.d.ts +7 -0
- package/dist/serialization/binaryCodec.d.ts.map +1 -0
- package/dist/serialization/cdnAssetUrls.d.ts +18 -0
- package/dist/serialization/cdnAssetUrls.d.ts.map +1 -0
- package/dist/serialization/constants.d.ts +17 -0
- package/dist/serialization/constants.d.ts.map +1 -0
- package/dist/serialization/extensionEnabled.d.ts +10 -0
- package/dist/serialization/extensionEnabled.d.ts.map +1 -0
- package/dist/serialization/fetchRemote.d.ts +12 -0
- package/dist/serialization/fetchRemote.d.ts.map +1 -0
- package/dist/serialization/loadManifestUrlTextures.d.ts +23 -0
- package/dist/serialization/loadManifestUrlTextures.d.ts.map +1 -0
- package/dist/serialization/materialDescriptorProperties.d.ts +32 -0
- package/dist/serialization/materialDescriptorProperties.d.ts.map +1 -0
- package/dist/serialization/materialTextureManifest.d.ts +23 -0
- package/dist/serialization/materialTextureManifest.d.ts.map +1 -0
- package/dist/serialization/meshEmbeddedCodec.d.ts +11 -0
- package/dist/serialization/meshEmbeddedCodec.d.ts.map +1 -0
- package/dist/serialization/migrateSceneDocument.d.ts +10 -0
- package/dist/serialization/migrateSceneDocument.d.ts.map +1 -0
- package/dist/serialization/sceneFileLoad.d.ts +10 -0
- package/dist/serialization/sceneFileLoad.d.ts.map +1 -0
- package/dist/serialization/scenePak.d.ts +49 -0
- package/dist/serialization/scenePak.d.ts.map +1 -0
- package/dist/serialization/scenepakMetadata.d.ts +19 -0
- package/dist/serialization/scenepakMetadata.d.ts.map +1 -0
- package/dist/serialization/serializeGraphManifest.d.ts +12 -0
- package/dist/serialization/serializeGraphManifest.d.ts.map +1 -0
- package/dist/serialization/standaloneFinalize.d.ts +34 -0
- package/dist/serialization/standaloneFinalize.d.ts.map +1 -0
- package/dist/serialization/types.d.ts +206 -0
- package/dist/serialization/types.d.ts.map +1 -0
- package/dist/validation/SceneValidator.d.ts +1394 -0
- package/dist/validation/SceneValidator.d.ts.map +1 -0
- package/dist/w3dts-scenedd.es.js +5514 -0
- package/dist/w3dts-scenedd.umd.js +1 -0
- package/package.json +55 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file scenePak.ts
|
|
3
|
+
* @description Binary `.scenepak` container: magic + version + optional WebP thumbnail + zlib JSON.
|
|
4
|
+
* Version 1 is header + zlib JSON. Version 2 prepends a raw WebP chunk so a thumbnail can be
|
|
5
|
+
* read without inflating the scene. Future buffer chunks: documentation/domains/scenedd/SCENEDD_EVOLUTION_PLAN.md.
|
|
6
|
+
*/
|
|
7
|
+
/** 8-byte magic: ASCII `W3DSCNPK`. */
|
|
8
|
+
export declare const SCENEPAK_MAGIC: Uint8Array<ArrayBuffer>;
|
|
9
|
+
/** Header layout: magic (8) + uint32 LE container version (4). */
|
|
10
|
+
export declare const SCENEPAK_HEADER_BYTE_LENGTH = 12;
|
|
11
|
+
/** Version 1 payload = zlib raw deflate stream of UTF-8 JSON. */
|
|
12
|
+
export declare const SCENEPAK_CONTAINER_VERSION = 1;
|
|
13
|
+
/**
|
|
14
|
+
* Version 2: header + uint32 LE thumbnail byte length + raw WebP + zlib JSON.
|
|
15
|
+
* Written only when a thumbnail is supplied. Version 1 files stay readable.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SCENEPAK_THUMB_CONTAINER_VERSION = 2;
|
|
18
|
+
/** Reject thumbnails larger than a 128×128 WebP (a few KB) with margin. */
|
|
19
|
+
export declare const SCENEPAK_THUMB_MAX_BYTES: number;
|
|
20
|
+
export interface EncodeScenePakOptions {
|
|
21
|
+
/** Raw WebP bytes (intended 128×128). Omitted or empty keeps a version 1 file. */
|
|
22
|
+
thumbnail?: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
/** True if `bytes` starts with {@link SCENEPAK_MAGIC} (for sniffing JSON vs `.scenepak`). */
|
|
25
|
+
export declare function isScenePakBytes(bytes: Uint8Array): boolean;
|
|
26
|
+
/** True when `bytes` looks like a WebP (RIFF container, WEBP form). */
|
|
27
|
+
export declare function isWebpBytes(bytes: Uint8Array): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Byte offset of the zlib JSON payload. Version 1 starts immediately after the header.
|
|
30
|
+
* Version 2 skips the thumbnail length field and the WebP bytes.
|
|
31
|
+
*/
|
|
32
|
+
export declare function scenePakJsonOffset(bytes: Uint8Array): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns a copy of the embedded WebP, or `null` when the file is version 1 or the chunk is empty.
|
|
35
|
+
* Does not inflate the JSON payload.
|
|
36
|
+
*/
|
|
37
|
+
export declare function readScenePakThumbnail(bytes: Uint8Array): Uint8Array | null;
|
|
38
|
+
/**
|
|
39
|
+
* Encodes a JSON-serializable value (typically a {@link SceneDescriptor}) into `.scenepak` bytes.
|
|
40
|
+
* Without `thumbnail`, writes container version 1. With a WebP, writes version 2 and places the
|
|
41
|
+
* image before the compressed JSON.
|
|
42
|
+
*/
|
|
43
|
+
export declare function encodeScenePakJson(value: unknown, options?: EncodeScenePakOptions): Uint8Array;
|
|
44
|
+
/**
|
|
45
|
+
* Decodes `.scenepak` bytes to a parsed JSON value. Skips an optional leading thumbnail.
|
|
46
|
+
* Caller should run `validateScene` / `migrateSceneDocument` as needed.
|
|
47
|
+
*/
|
|
48
|
+
export declare function decodeScenePakJson(bytes: Uint8Array): unknown;
|
|
49
|
+
//# sourceMappingURL=scenePak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenePak.d.ts","sourceRoot":"","sources":["../../src/serialization/scenePak.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,sCAAsC;AACtC,eAAO,MAAM,cAAc,yBAAmE,CAAC;AAE/F,kEAAkE;AAClE,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAE9C,iEAAiE;AACjE,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAElD,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,QAAY,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,SAAS,CAAC,EAAE,UAAU,CAAC;CACxB;AAED,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAM1D;AAED,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAYtD;AAsBD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAqB5D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CAW1E;AAaD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,UAAU,CAuB9F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAM7D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file scenepakMetadata.ts
|
|
3
|
+
* @description Read export metadata (version, dates) from scenepak / JSON scene bytes.
|
|
4
|
+
*/
|
|
5
|
+
export type ScenepakFileMetadata = {
|
|
6
|
+
scenepakVersion?: number;
|
|
7
|
+
exportedAt?: string;
|
|
8
|
+
createdAt?: string;
|
|
9
|
+
projectName?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Extracts export metadata without full scene validation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readScenepakFileMetadata(bytes: ArrayBuffer | Uint8Array): ScenepakFileMetadata | null;
|
|
15
|
+
/**
|
|
16
|
+
* Next monotonic version for a re-export (1 when no prior file or legacy file without version).
|
|
17
|
+
*/
|
|
18
|
+
export declare function nextScenepakVersion(previousBytes?: ArrayBuffer | Uint8Array | null): number;
|
|
19
|
+
//# sourceMappingURL=scenepakMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scenepakMetadata.d.ts","sourceRoot":"","sources":["../../src/serialization/scenepakMetadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAgBF;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,WAAW,GAAG,UAAU,GAC9B,oBAAoB,GAAG,IAAI,CAU7B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,CAK3F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file serializeGraphManifest.ts
|
|
3
|
+
* @description Graph cache key resolution shared by core and domain serializers.
|
|
4
|
+
*/
|
|
5
|
+
/** Prefer SceneDD catalog alias over the graph document id/name. */
|
|
6
|
+
export declare function pickPreferredGraphCacheKey(keys: string[], graph: {
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
} | null | undefined): string | undefined;
|
|
10
|
+
/** Prefer ResourceManager cache key (manifest / catalog id) over the graph document's own `id`. */
|
|
11
|
+
export declare function resolveCachedGraphManifestId(cache: ReadonlyMap<string, unknown>, graph: unknown, fallbackId: string): string;
|
|
12
|
+
//# sourceMappingURL=serializeGraphManifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializeGraphManifest.d.ts","sourceRoot":"","sources":["../../src/serialization/serializeGraphManifest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oEAAoE;AACpE,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EAAE,EACd,KAAK,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GACvD,MAAM,GAAG,SAAS,CAQpB;AAED,mGAAmG;AACnG,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,CAwBR"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SceneDescriptor } from '../descriptors';
|
|
2
|
+
export interface FinalizeStandaloneResourcesOptions {
|
|
3
|
+
/**
|
|
4
|
+
* When a manifest entry uses `w3dts-texture:…`, bytes are embedded only if this resolves them
|
|
5
|
+
* (e.g. readback). If omitted or returns undefined, {@link resolveW3dtsTextureSourceUrl} is tried next.
|
|
6
|
+
*/
|
|
7
|
+
resolveW3dtsTextureBytes?: (cacheKey: string) => Promise<Uint8Array | undefined>;
|
|
8
|
+
/**
|
|
9
|
+
* Fallback for `w3dts-texture:` entries: return an HTTP(S) or relative URL to re-fetch raw texture bytes
|
|
10
|
+
* (e.g. original HDR path keyed by manifest texture id).
|
|
11
|
+
*/
|
|
12
|
+
resolveW3dtsTextureSourceUrl?: (cacheKey: string) => string | undefined;
|
|
13
|
+
/** Override fetch (tests). Default `globalThis.fetch`. */
|
|
14
|
+
fetchFn?: typeof fetch;
|
|
15
|
+
logger?: {
|
|
16
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface InlineRemoteGraphsOptions {
|
|
20
|
+
fetchFn?: typeof fetch;
|
|
21
|
+
logger?: {
|
|
22
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetches each `engineConfig` graph entry that has `url` but no `inline`, assigns `inline` from JSON, removes `url`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function inlineRemoteEngineConfigGraphs(descriptor: SceneDescriptor, options?: InlineRemoteGraphsOptions): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Mutates `descriptor.resources.textures`: fetches HTTP(S) / same-origin paths and optional
|
|
31
|
+
* `w3dts-texture:` payloads, replacing entries with `embedded.dataBase64` and dropping `url`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function finalizeStandaloneResources(descriptor: SceneDescriptor, options?: FinalizeStandaloneResourcesOptions): Promise<void>;
|
|
34
|
+
//# sourceMappingURL=standaloneFinalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standaloneFinalize.d.ts","sourceRoot":"","sources":["../../src/serialization/standaloneFinalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,MAAM,WAAW,kCAAkC;IACjD;;;OAGG;IACH,wBAAwB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACjF;;;OAGG;IACH,4BAA4B,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACxE,0DAA0D;IAC1D,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;CAC/D;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;CAC/D;AA+CD;;GAEG;AACH,wBAAsB,8BAA8B,CAClD,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;GAGG;AACH,wBAAsB,2BAA2B,CAC/C,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC,GAC3C,OAAO,CAAC,IAAI,CAAC,CA0Ff"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { IModelLoaderService, ProjectLoadParams, World, ResourceManager } from '@naanouff/w3dts-core';
|
|
2
|
+
import { EnvironmentDescriptor, PhysicsSetupDescriptor, SceneDescriptor, ScriptDescriptor, TextureEntry } from '../descriptors';
|
|
3
|
+
import { ComponentCodecRegistry } from '../codecs/ComponentCodecRegistry';
|
|
4
|
+
export interface SceneExtensionSerializeContext {
|
|
5
|
+
world: World;
|
|
6
|
+
resourceManager: ResourceManager;
|
|
7
|
+
options?: SerializeOptions;
|
|
8
|
+
/**
|
|
9
|
+
* Live ECS entity → stable SceneDD entity id (BIGI-4).
|
|
10
|
+
* Present when serializing from a world so lightmapper (and similar) payloads can key by id.
|
|
11
|
+
*/
|
|
12
|
+
entityToId?: ReadonlyMap<import('@naanouff/w3dts-core').Entity, string>;
|
|
13
|
+
}
|
|
14
|
+
export interface SceneExtensionDeserializeContext {
|
|
15
|
+
params: ProjectLoadParams;
|
|
16
|
+
validated: SceneDescriptor;
|
|
17
|
+
logger?: {
|
|
18
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* SceneDD entity id → live ECS entity after core deserialize (BIGI-4).
|
|
22
|
+
*/
|
|
23
|
+
entityMap?: ReadonlyMap<string, import('@naanouff/w3dts-core').Entity>;
|
|
24
|
+
}
|
|
25
|
+
/** Domain-owned slice under `SceneDescriptor.extensions[id]`. */
|
|
26
|
+
export interface SceneExtensionHandler {
|
|
27
|
+
id: string;
|
|
28
|
+
serialize?: (ctx: SceneExtensionSerializeContext) => unknown;
|
|
29
|
+
deserialize?: (payload: unknown, ctx: SceneExtensionDeserializeContext) => void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export interface SceneAsyncSchedulingOptions {
|
|
32
|
+
/**
|
|
33
|
+
* When true, yields to the main thread between coarse deserialize phases and entity chunks.
|
|
34
|
+
* Default false to preserve existing timing and tests.
|
|
35
|
+
*/
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
/** Max entities per chunk before yielding (default 50). Ignored when `enabled` is false. */
|
|
38
|
+
entityChunkSize?: number;
|
|
39
|
+
}
|
|
40
|
+
export interface SerializeOptions {
|
|
41
|
+
/** Scene name for metadata. */
|
|
42
|
+
sceneName?: string;
|
|
43
|
+
/** Project name that produced this scene (for round-trip: load this project before loading the file). */
|
|
44
|
+
projectName?: string;
|
|
45
|
+
/** Custom engine version string. */
|
|
46
|
+
engineVersion?: string;
|
|
47
|
+
/** Version of each package used (e.g. { "@naanouff/w3dts-core": "1.0.0" }). Written to metadata.packageVersions. */
|
|
48
|
+
packageVersions?: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* Optional: provide instance buffer data for InstancedMeshComponent (sync).
|
|
51
|
+
* If not provided, instances are serialized as [].
|
|
52
|
+
*/
|
|
53
|
+
getInstanceData?: (entity: unknown, comp: {
|
|
54
|
+
instanceBuffer: unknown;
|
|
55
|
+
instanceCount: number;
|
|
56
|
+
}) => Float32Array | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Optional: provide instance buffer data asynchronously (e.g. GPU readback).
|
|
59
|
+
* When set, use serializeAsync() so instance data is filled before returning.
|
|
60
|
+
*/
|
|
61
|
+
getInstanceDataAsync?: (entity: unknown, comp: {
|
|
62
|
+
instanceBuffer: unknown;
|
|
63
|
+
instanceCount: number;
|
|
64
|
+
}) => Promise<Float32Array | undefined>;
|
|
65
|
+
/**
|
|
66
|
+
* If true, meshes with no load URL (procedural) are still listed in resources.meshes.
|
|
67
|
+
* Default false: for fully procedural projects, resources.meshes stays empty and meshIds
|
|
68
|
+
* are resolved at load time (e.g. from cache / getMeshByName).
|
|
69
|
+
*/
|
|
70
|
+
includeProceduralMeshesInResources?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* When true, non-primitive meshes are written with `resources.meshes[].embedded` (base64 geometry)
|
|
73
|
+
* instead of relying on GLB URLs; use with `serializeAsync` so HTTP(S) textures can be fetched
|
|
74
|
+
* and embedded by the standalone finalization step.
|
|
75
|
+
*/
|
|
76
|
+
standaloneResources?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* During standalone finalization, resolves GPU-only `w3dts-texture:` entries to raw bytes.
|
|
79
|
+
* Without this, those entries stay as cache URLs and the file may not load on a cold cache.
|
|
80
|
+
*/
|
|
81
|
+
resolveW3dtsTextureBytes?: (cacheKey: string) => Promise<Uint8Array | undefined>;
|
|
82
|
+
/**
|
|
83
|
+
* Optional HTTP(S) / relative URL to re-fetch bytes for a manifest texture cache key
|
|
84
|
+
* when embedding `w3dts-texture:` entries (used after {@link resolveW3dtsTextureBytes} if that returns nothing).
|
|
85
|
+
*/
|
|
86
|
+
resolveW3dtsTextureSourceUrl?: (cacheKey: string) => string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* When `standaloneResources` is true: fetch `engineConfig` graph JSON from `url` and set `inline` (default: true).
|
|
89
|
+
* Set to false to keep graph URLs in the exported file.
|
|
90
|
+
*/
|
|
91
|
+
standaloneInlineGraphs?: boolean;
|
|
92
|
+
/** Override `fetch` during standalone finalization (textures + remote graphs). */
|
|
93
|
+
standaloneFetchFn?: typeof fetch;
|
|
94
|
+
/**
|
|
95
|
+
* Optional: return script binding for an entity (scriptId = graph id).
|
|
96
|
+
* When provided, scriptBinding components are emitted and scriptGraphs are taken from getScriptGraphs().
|
|
97
|
+
*/
|
|
98
|
+
getScriptBinding?: (entity: import('@naanouff/w3dts-core').Entity) => {
|
|
99
|
+
scriptId: string;
|
|
100
|
+
properties?: Record<string, unknown>;
|
|
101
|
+
} | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Optional: return script graphs to store in engineConfig.scriptGraphs.
|
|
104
|
+
* Required for scriptBinding to be validated; typically same graphs as used by getScriptBinding.
|
|
105
|
+
*/
|
|
106
|
+
getScriptGraphs?: () => Array<{
|
|
107
|
+
id: string;
|
|
108
|
+
inline: unknown;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* Optional: snapshot the active Game render graph for scenepak autonomy (BOX-A6b).
|
|
112
|
+
* When set, takes precedence over the `render-graph` resource cache.
|
|
113
|
+
*/
|
|
114
|
+
getGameRenderGraphEntry?: () => {
|
|
115
|
+
id: string;
|
|
116
|
+
inline?: unknown;
|
|
117
|
+
url?: string;
|
|
118
|
+
} | undefined;
|
|
119
|
+
/** Optional logger for serialization debug logs (e.g. materials, scriptBinding). */
|
|
120
|
+
logger?: {
|
|
121
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
122
|
+
};
|
|
123
|
+
/** Optional: emit `descriptor.environment` (skybox / IBL). */
|
|
124
|
+
getEnvironmentDescriptor?: () => EnvironmentDescriptor | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Optional domain serializers; payloads are merged into `descriptor.extensions[id]` when non-undefined.
|
|
127
|
+
*/
|
|
128
|
+
sceneExtensions?: SceneExtensionHandler[];
|
|
129
|
+
/**
|
|
130
|
+
* When set, only handlers whose `id` is listed run (`serialize`).
|
|
131
|
+
* Omitted or `undefined`: no filtering (backward compatible).
|
|
132
|
+
*/
|
|
133
|
+
enabledSceneExtensionIds?: readonly string[] | ReadonlySet<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Live ECS scene-root entity. When set, that entity is not written into `entities`,
|
|
136
|
+
* and children of the root omit `parentId` (they re-parent under the live root on load).
|
|
137
|
+
*/
|
|
138
|
+
sceneRootEntity?: import('@naanouff/w3dts-core').Entity;
|
|
139
|
+
/** Domain component serializers (terrain, gproc, physics, …). Omitted types are skipped. */
|
|
140
|
+
componentCodecRegistry?: ComponentCodecRegistry;
|
|
141
|
+
}
|
|
142
|
+
export interface DeserializeOptions {
|
|
143
|
+
/** Required for loading mesh URLs from resources.meshes. */
|
|
144
|
+
modelLoader?: IModelLoaderService;
|
|
145
|
+
/**
|
|
146
|
+
* Optional GPU texture load for `resources.textures` with HTTP(S) or relative URLs.
|
|
147
|
+
* When unset, core `TextureLoader` is used (requires `engine.webGPUContext.device`).
|
|
148
|
+
*/
|
|
149
|
+
loadTextureEntry?: (device: GPUDevice, textureId: string, entry: TextureEntry) => Promise<unknown>;
|
|
150
|
+
/**
|
|
151
|
+
* Optional: apply script binding after entity creation.
|
|
152
|
+
* Called for each component with type 'scriptBinding'; register script graphs in engineConfig.scriptGraphs first.
|
|
153
|
+
* Optional `properties` map onto ScriptComponent.parameterOverrides.
|
|
154
|
+
*/
|
|
155
|
+
addScriptBinding?: (entity: import('@naanouff/w3dts-core').Entity, scriptId: string, properties?: Record<string, unknown>) => void;
|
|
156
|
+
/** Optional logger for deserialization debug logs (e.g. materials, scriptBinding). */
|
|
157
|
+
logger?: {
|
|
158
|
+
debug: (msg: string, ...args: unknown[]) => void;
|
|
159
|
+
};
|
|
160
|
+
/** Optional cooperative multitasking during load (see {@link SceneAsyncSchedulingOptions}). */
|
|
161
|
+
asyncScheduling?: SceneAsyncSchedulingOptions;
|
|
162
|
+
/**
|
|
163
|
+
* Invoked from deserialize when `asyncScheduling.enabled` is true (phase markers and entity chunk progress).
|
|
164
|
+
*/
|
|
165
|
+
onProgress?: (phase: string, completed?: number, total?: number) => void;
|
|
166
|
+
/** Optional domain deserializers; run after core graph after `validated.extensions[id]` is present. */
|
|
167
|
+
sceneExtensions?: SceneExtensionHandler[];
|
|
168
|
+
/**
|
|
169
|
+
* When set, only extensions whose id is listed are deserialized; payload keys in the file for other ids are ignored.
|
|
170
|
+
* Omitted or `undefined`: no filtering (all registered handlers may run).
|
|
171
|
+
*/
|
|
172
|
+
enabledSceneExtensionIds?: readonly string[] | ReadonlySet<string>;
|
|
173
|
+
/**
|
|
174
|
+
* After manifest textures are registered, apply `descriptor.environment` (IBL / skybox).
|
|
175
|
+
* Viewer defaults to LitAbstractProject when the active project supports it.
|
|
176
|
+
*/
|
|
177
|
+
applyEnvironmentFromDescriptor?: (environment: EnvironmentDescriptor, ctx: {
|
|
178
|
+
params: ProjectLoadParams;
|
|
179
|
+
resourceManager: ResourceManager;
|
|
180
|
+
}) => void | Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Load graph JSON when an `engineConfig` graph entry has `url` and no `inline`.
|
|
183
|
+
* If unset and `globalThis.fetch` exists, the default from `fetchRemote.ts` is used.
|
|
184
|
+
*/
|
|
185
|
+
fetchGraphJson?: (url: string) => Promise<unknown>;
|
|
186
|
+
/**
|
|
187
|
+
* Load script text when `scripts[].sourceUrl` is set and `source` is empty.
|
|
188
|
+
* If unset and `globalThis.fetch` exists, the default from `fetchRemote.ts` is used.
|
|
189
|
+
*/
|
|
190
|
+
fetchScriptSource?: (url: string) => Promise<string>;
|
|
191
|
+
/**
|
|
192
|
+
* When set, `scripts[]` is resolved (including `sourceUrl` → `source` when fetch is available)
|
|
193
|
+
* and passed here. Without this callback, `sourceUrl` entries are not fetched (avoids silent network I/O).
|
|
194
|
+
*/
|
|
195
|
+
onScriptsResolved?: (scripts: ScriptDescriptor[]) => void | Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Invoked after entities are created when `descriptor.physics` is set.
|
|
198
|
+
* Host applies gravity / timestep to its physics system (not done automatically by scenedd).
|
|
199
|
+
*/
|
|
200
|
+
applyPhysicsDescriptor?: (physics: PhysicsSetupDescriptor, ctx: {
|
|
201
|
+
params: ProjectLoadParams;
|
|
202
|
+
}) => void | Promise<void>;
|
|
203
|
+
/** Domain component deserializers. Unknown descriptor types without a codec are no-ops. */
|
|
204
|
+
componentCodecRegistry?: ComponentCodecRegistry;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/serialization/types.ts"],"names":[],"mapp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