@galacean/engine-loader 1.2.0-beta.6 → 1.3.0-alpha.1

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.
Files changed (45) hide show
  1. package/dist/main.js +492 -414
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +492 -414
  4. package/dist/module.js +493 -415
  5. package/dist/module.js.map +1 -1
  6. package/package.json +4 -4
  7. package/types/PrefabLoader.d.ts +5 -0
  8. package/types/gltf/GLTFParser.d.ts +9 -0
  9. package/types/gltf/GLTFPipeline.d.ts +23 -0
  10. package/types/gltf/GLTFResource.d.ts +1 -1
  11. package/types/gltf/GLTFSchema.d.ts +1 -1
  12. package/types/gltf/GLTFUtil.d.ts +53 -0
  13. package/types/gltf/Schema.d.ts +814 -0
  14. package/types/gltf/extensions/ExtensionParser.d.ts +8 -0
  15. package/types/gltf/extensions/Schema.d.ts +142 -0
  16. package/types/gltf/parser/AnimationParser.d.ts +7 -0
  17. package/types/gltf/parser/BufferParser.d.ts +7 -0
  18. package/types/gltf/parser/EntityParser.d.ts +9 -0
  19. package/types/gltf/parser/MaterialParser.d.ts +8 -0
  20. package/types/gltf/parser/MeshParser.d.ts +13 -0
  21. package/types/gltf/parser/Parser.d.ts +21 -0
  22. package/types/gltf/parser/ParserContext.d.ts +46 -0
  23. package/types/gltf/parser/SceneParser.d.ts +11 -0
  24. package/types/gltf/parser/SkinParser.d.ts +6 -0
  25. package/types/gltf/parser/TextureParser.d.ts +8 -0
  26. package/types/gltf/parser/Validator.d.ts +5 -0
  27. package/types/index.d.ts +3 -0
  28. package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +13 -0
  29. package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +33 -0
  30. package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +17 -0
  31. package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +34 -0
  32. package/types/ktx2/TranscodeResult.d.ts +10 -0
  33. package/types/ktx2/constants.d.ts +7 -0
  34. package/types/ktx2/zstddec.d.ts +62 -0
  35. package/types/prefab/PrefabParser.d.ts +11 -0
  36. package/types/prefab/PrefabResource.d.ts +25 -0
  37. package/types/resource-deserialize/index.d.ts +0 -1
  38. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +12 -10
  39. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +13 -12
  40. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +2 -2
  41. package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +70 -0
  42. package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -0
  43. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +7 -4
  44. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +1 -1
  45. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +4 -3
@@ -0,0 +1,8 @@
1
+ import { EngineObject } from "@galacean/engine-core";
2
+ import { ParserContext } from "../parser/ParserContext";
3
+ import { ExtensionSchema } from "./Schema";
4
+ export declare abstract class ExtensionParser {
5
+ initialize(): void;
6
+ parseEngineResource(schema: ExtensionSchema, parseResource: EngineObject, context: ParserContext, ...extra: any[]): void | Promise<void>;
7
+ createEngineResource(schema: ExtensionSchema, context: ParserContext, ...extra: any[]): EngineObject | Promise<EngineObject>;
8
+ }
@@ -0,0 +1,142 @@
1
+ import { IMaterialNormalTextureInfo, ITextureInfo } from "../Schema";
2
+ /**
3
+ * Interfaces from the KHR_lights_punctual extension
4
+ */
5
+ export interface IKHRLightsPunctual_LightNode {
6
+ light: number;
7
+ }
8
+ export interface IKHRLightsPunctual_Light {
9
+ type: "directional" | "point" | "spot";
10
+ color?: number[];
11
+ intensity?: number;
12
+ range?: number;
13
+ spot?: {
14
+ innerConeAngle?: number;
15
+ outerConeAngle?: number;
16
+ };
17
+ }
18
+ export interface IKHRLightsPunctual {
19
+ lights: IKHRLightsPunctual_Light[];
20
+ }
21
+ /**
22
+ * Interfaces from the KHR_draco_mesh_compression extension
23
+ */
24
+ export interface IKHRDracoMeshCompression {
25
+ bufferView: number;
26
+ attributes: {
27
+ [name: string]: number;
28
+ };
29
+ }
30
+ /**
31
+ * Interfaces from the KHR_materials_clearcoat extension
32
+ */
33
+ export interface IKHRMaterialsClearcoat {
34
+ clearcoatFactor: number;
35
+ clearcoatTexture: ITextureInfo;
36
+ clearcoatRoughnessFactor: number;
37
+ clearcoatRoughnessTexture: ITextureInfo;
38
+ clearcoatNormalTexture: IMaterialNormalTextureInfo;
39
+ }
40
+ /**
41
+ * Interfaces from the KHR_materials_ior extension
42
+ */
43
+ export interface IKHRMaterialsIor {
44
+ ior: number;
45
+ }
46
+ /**
47
+ * Interfaces from the KHR_materials_unlit extension
48
+ */
49
+ export interface IKHRMaterialsUnlit {
50
+ }
51
+ /**
52
+ * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
53
+ */
54
+ export interface IKHRMaterialsPbrSpecularGlossiness {
55
+ diffuseFactor: number[];
56
+ diffuseTexture: ITextureInfo;
57
+ specularFactor: number[];
58
+ glossinessFactor: number;
59
+ specularGlossinessTexture: ITextureInfo;
60
+ }
61
+ /**
62
+ * Interfaces from the KHR_materials_sheen extension
63
+ */
64
+ export interface IKHRMaterialsSheen {
65
+ sheenColorFactor?: number[];
66
+ sheenColorTexture?: ITextureInfo;
67
+ sheenRoughnessFactor?: number;
68
+ sheenRoughnessTexture?: ITextureInfo;
69
+ }
70
+ /**
71
+ * Interfaces from the KHR_materials_specular extension
72
+ */
73
+ export interface IKHRMaterialsSpecular {
74
+ specularFactor: number;
75
+ specularColorFactor: number[];
76
+ specularTexture: ITextureInfo;
77
+ }
78
+ /**
79
+ * Interfaces from the KHR_materials_transmission extension
80
+ */
81
+ export interface IKHRMaterialsTransmission {
82
+ transmissionFactor?: number;
83
+ transmissionTexture?: ITextureInfo;
84
+ }
85
+ /**
86
+ * Interfaces from the KHR_materials_translucency extension
87
+ */
88
+ export interface IKHRMaterialsTranslucency {
89
+ translucencyFactor?: number;
90
+ translucencyTexture?: ITextureInfo;
91
+ }
92
+ /**
93
+ * Interfaces from the KHR_materials_variants extension
94
+ */
95
+ export interface IKHRMaterialVariants_Mapping {
96
+ mappings: Array<{
97
+ variants: number[];
98
+ material: number;
99
+ }>;
100
+ extensions?: any;
101
+ extras?: any;
102
+ }
103
+ export interface IKHRMaterialVariants_Variant {
104
+ name: string;
105
+ extensions?: any;
106
+ extras?: any;
107
+ }
108
+ export interface IKHRMaterialVariants_Variants {
109
+ variants: Array<IKHRMaterialVariants_Variant>;
110
+ }
111
+ /**
112
+ * Interfaces from the KHR_texture_basisu extension
113
+ */
114
+ export interface IKHRTextureBasisU {
115
+ source: number;
116
+ }
117
+ /**
118
+ * Interfaces from the KHR_texture_transform extension
119
+ */
120
+ export interface IKHRTextureTransform {
121
+ offset?: number[];
122
+ rotation?: number;
123
+ scale?: number[];
124
+ texCoord?: number;
125
+ }
126
+ /**
127
+ * Interfaces from the KHR_xmp extension
128
+ */
129
+ export interface IKHRXmp {
130
+ packets: Array<{
131
+ [key: string]: unknown;
132
+ }>;
133
+ }
134
+ export interface IKHRXmp_Node {
135
+ packet: number;
136
+ }
137
+ export interface IGalaceanMaterialRemap {
138
+ refId: string;
139
+ key?: string;
140
+ isClone?: boolean;
141
+ }
142
+ export type ExtensionSchema = IKHRLightsPunctual_Light | IKHRDracoMeshCompression | IKHRMaterialsClearcoat | IKHRMaterialsIor | IKHRMaterialsUnlit | IKHRMaterialsPbrSpecularGlossiness | IKHRMaterialsSheen | IKHRMaterialsSpecular | IKHRMaterialsTransmission | IKHRMaterialsTranslucency | IKHRMaterialVariants_Mapping | IKHRMaterialVariants_Variants | IKHRTextureBasisU | IKHRTextureTransform | IKHRXmp | IKHRXmp_Node;
@@ -0,0 +1,7 @@
1
+ import { AnimationClip, AssetPromise } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class AnimationParser extends Parser {
5
+ parse(context: ParserContext): AssetPromise<AnimationClip[]>;
6
+ private _addCurve;
7
+ }
@@ -0,0 +1,7 @@
1
+ import { AssetPromise } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class BufferParser extends Parser {
5
+ parse(context: ParserContext): AssetPromise<void>;
6
+ private _isGLB;
7
+ }
@@ -0,0 +1,9 @@
1
+ import { Parser } from "./Parser";
2
+ import { ParserContext } from "./ParserContext";
3
+ export declare class EntityParser extends Parser {
4
+ /** @internal */
5
+ static _defaultName: String;
6
+ parse(context: ParserContext): void;
7
+ private _buildEntityTree;
8
+ private _createSceneRoots;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { AssetPromise, Material } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class MaterialParser extends Parser {
5
+ /** @internal */
6
+ static _parseTextureTransform(material: Material, extensions: any, context: ParserContext): void;
7
+ parse(context: ParserContext): AssetPromise<Material[]>;
8
+ }
@@ -0,0 +1,13 @@
1
+ import { AssetPromise, ModelMesh } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class MeshParser extends Parser {
5
+ private static _tempVector3;
6
+ parse(context: ParserContext): AssetPromise<ModelMesh[][]>;
7
+ private _parseMeshFromGLTFPrimitive;
8
+ private _createBlendShape;
9
+ /**
10
+ * @deprecated
11
+ */
12
+ private _parseMeshFromGLTFPrimitiveDraco;
13
+ }
@@ -0,0 +1,21 @@
1
+ import { AnimationClip, AssetPromise, EngineObject, Material, Mesh } from "@galacean/engine-core";
2
+ import { ExtensionParser } from "../extensions/ExtensionParser";
3
+ import { ExtensionSchema } from "../extensions/Schema";
4
+ import { ParserContext } from "./ParserContext";
5
+ export declare abstract class Parser {
6
+ private static _extensionParsers;
7
+ static parseEngineResource(extensionName: string, extensionSchema: ExtensionSchema, parseResource: EngineObject, context: ParserContext, ...extra: any[]): void;
8
+ static createEngineResource<T extends EngineObject>(extensionName: string, extensionSchema: ExtensionSchema, context: ParserContext, ...extra: any[]): T | Promise<T>;
9
+ static hasExtensionParser(extensionName: string): boolean;
10
+ static initialize(extensionName: string): void;
11
+ /**
12
+ * @internal
13
+ */
14
+ static _addExtensionParser(extensionName: string, extensionParser: ExtensionParser): void;
15
+ abstract parse(context: ParserContext): AssetPromise<any> | void | Material | AnimationClip | Mesh;
16
+ }
17
+ /**
18
+ * Declare ExtensionParser's decorator.
19
+ * @param extensionName - Extension name
20
+ */
21
+ export declare function registerExtension(extensionName: string): (parser: new () => ExtensionParser) => void;
@@ -0,0 +1,46 @@
1
+ import { AnimationClip, AssetPromise, Buffer, Entity, Material, ModelMesh, Texture2D, TypedArray } from "@galacean/engine-core";
2
+ import { GLTFResource } from "../GLTFResource";
3
+ import { IGLTF } from "../Schema";
4
+ /**
5
+ * @internal
6
+ */
7
+ export declare class ParserContext {
8
+ gltf: IGLTF;
9
+ buffers: ArrayBuffer[];
10
+ glTFResource: GLTFResource;
11
+ keepMeshData: boolean;
12
+ hasSkinned: boolean;
13
+ /** chain asset promise */
14
+ chainPromises: AssetPromise<any>[];
15
+ accessorBufferCache: Record<string, BufferInfo>;
16
+ texturesPromiseInfo: PromiseInfo<Texture2D[]>;
17
+ materialsPromiseInfo: PromiseInfo<Material[]>;
18
+ meshesPromiseInfo: PromiseInfo<ModelMesh[][]>;
19
+ animationClipsPromiseInfo: PromiseInfo<AnimationClip[]>;
20
+ defaultSceneRootPromiseInfo: PromiseInfo<Entity>;
21
+ masterPromiseInfo: PromiseInfo<GLTFResource>;
22
+ promiseMap: Record<string, AssetPromise<any>>;
23
+ constructor(url: string);
24
+ private _initPromiseInfo;
25
+ }
26
+ /**
27
+ * @internal
28
+ */
29
+ export declare class BufferInfo {
30
+ data: TypedArray;
31
+ interleaved: boolean;
32
+ stride: number;
33
+ vertexBuffer: Buffer;
34
+ vertexBindingInfos: Record<number, number>;
35
+ constructor(data: TypedArray, interleaved: boolean, stride: number);
36
+ }
37
+ /**
38
+ * @internal
39
+ */
40
+ export declare class PromiseInfo<T> {
41
+ promise: AssetPromise<T>;
42
+ resolve: (value?: T | PromiseLike<T>) => void;
43
+ reject: (reason?: any) => void;
44
+ setProgress: (progress: number) => void;
45
+ onCancel: (callback: () => void) => void;
46
+ }
@@ -0,0 +1,11 @@
1
+ import { AssetPromise, Entity } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class SceneParser extends Parser {
5
+ private static _defaultMaterial;
6
+ private static _getDefaultMaterial;
7
+ parse(context: ParserContext): AssetPromise<Entity>;
8
+ private _createCamera;
9
+ private _createRenderer;
10
+ private _createAnimator;
11
+ }
@@ -0,0 +1,6 @@
1
+ import { Parser } from "./Parser";
2
+ import { ParserContext } from "./ParserContext";
3
+ export declare class SkinParser extends Parser {
4
+ parse(context: ParserContext): void;
5
+ private _findSkeletonRootBone;
6
+ }
@@ -0,0 +1,8 @@
1
+ import { AssetPromise, Texture2D } from "@galacean/engine-core";
2
+ import { Parser } from "./Parser";
3
+ import { ParserContext } from "./ParserContext";
4
+ export declare class TextureParser extends Parser {
5
+ private static _wrapMap;
6
+ parse(context: ParserContext): AssetPromise<Texture2D[]>;
7
+ private _parseSampler;
8
+ }
@@ -0,0 +1,5 @@
1
+ import { Parser } from "./Parser";
2
+ import { ParserContext } from "./ParserContext";
3
+ export declare class Validator extends Parser {
4
+ parse(context: ParserContext): void;
5
+ }
package/types/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import "./BufferLoader";
4
4
  import "./EnvLoader";
5
5
  import "./FontLoader";
6
6
  import "./GLTFLoader";
7
+ import "./PrefabLoader";
7
8
  import "./HDRLoader";
8
9
  import "./JSONLoader";
9
10
  import "./KTXCubeLoader";
@@ -27,3 +28,5 @@ export * from "./gltf";
27
28
  export { KTX2Loader, KTX2Transcoder } from "./ktx2/KTX2Loader";
28
29
  export { KTX2TargetFormat } from "./ktx2/KTX2TargetFormat";
29
30
  export * from "./resource-deserialize";
31
+ export * from "./prefab/PrefabResource";
32
+ export { PrefabLoader } from "./PrefabLoader";
@@ -0,0 +1,13 @@
1
+ import { KTX2TargetFormat } from "../KTX2TargetFormat";
2
+ import { TranscodeResult } from "../TranscodeResult";
3
+ /** @internal */
4
+ export declare class BinomialLLCTranscoder {
5
+ readonly workerLimit: number;
6
+ static MessageId: number;
7
+ private _transcodeWorkerPool;
8
+ private _initPromise;
9
+ constructor(workerLimit: number);
10
+ init(): Promise<any>;
11
+ transcode(buffer: ArrayBuffer, format: KTX2TargetFormat): Promise<TranscodeResult>;
12
+ destroy(): void;
13
+ }
@@ -0,0 +1,33 @@
1
+ type MessageType = "init" | "transcode";
2
+ export interface IBaseMessage {
3
+ type: MessageType;
4
+ }
5
+ export interface IInitMessage extends IBaseMessage {
6
+ type: "init";
7
+ transcoderWasm: ArrayBuffer;
8
+ }
9
+ export interface ITranscodeMessage extends IBaseMessage {
10
+ type: "transcode";
11
+ format: number;
12
+ buffer: ArrayBuffer;
13
+ }
14
+ export type IMessage = IInitMessage | ITranscodeMessage;
15
+ export type TranscodeResult = {
16
+ width: number;
17
+ height: number;
18
+ hasAlpha: boolean;
19
+ format: number;
20
+ faces: Array<{
21
+ data: Uint8Array;
22
+ width: number;
23
+ height: number;
24
+ }>[];
25
+ faceCount: number;
26
+ };
27
+ export type TranscodeResponse = {
28
+ id: number;
29
+ type: "transcoded";
30
+ } & TranscodeResult;
31
+ /** @internal */
32
+ export declare function TranscodeWorkerCode(): void;
33
+ export {};
@@ -0,0 +1,17 @@
1
+ import { KTX2Container } from "../KTX2Container";
2
+ import { KTX2TargetFormat } from "../KTX2TargetFormat";
3
+ import { TranscodeResult } from "./TranscoderWorkerCode";
4
+ /** @internal */
5
+ export declare class KhronosTranscoder {
6
+ readonly workerLimit: number;
7
+ readonly type: KTX2TargetFormat;
8
+ static transcoderMap: {
9
+ 0: string;
10
+ };
11
+ private _transcodeWorkerPool;
12
+ private _initPromise;
13
+ constructor(workerLimit: number, type: KTX2TargetFormat);
14
+ init(): Promise<any>;
15
+ transcode(ktx2Container: KTX2Container): Promise<TranscodeResult>;
16
+ destroy(): void;
17
+ }
@@ -0,0 +1,34 @@
1
+ export interface EncodedData {
2
+ buffer: Uint8Array;
3
+ levelWidth: number;
4
+ levelHeight: number;
5
+ uncompressedByteLength: number;
6
+ }
7
+ type MessageType = "init" | "transcode";
8
+ export interface IBaseMessage {
9
+ type: MessageType;
10
+ }
11
+ export interface IInitMessage extends IBaseMessage {
12
+ type: "init";
13
+ transcoderWasm: ArrayBuffer;
14
+ }
15
+ export interface ITranscodeMessage extends IBaseMessage {
16
+ type: "transcode";
17
+ format: number;
18
+ needZstd: boolean;
19
+ data: EncodedData[][];
20
+ }
21
+ export type IMessage = IInitMessage | ITranscodeMessage;
22
+ export type TranscodeResult = {
23
+ data: Array<{
24
+ data: Uint8Array;
25
+ width: number;
26
+ height: number;
27
+ }>;
28
+ };
29
+ export type TranscodeResponse = {
30
+ id: number;
31
+ type: "transcoded";
32
+ } & TranscodeResult;
33
+ export declare function TranscodeWorkerCode(): void;
34
+ export {};
@@ -0,0 +1,10 @@
1
+ export interface TranscodeResult {
2
+ width: number;
3
+ height: number;
4
+ hasAlpha: boolean;
5
+ mipmaps: Array<{
6
+ data: Uint8Array;
7
+ width: number;
8
+ height: number;
9
+ }>;
10
+ }
@@ -0,0 +1,7 @@
1
+ export declare enum SupercompressionScheme {
2
+ None = 0,
3
+ BasisLZ = 1,
4
+ Zstd = 2,
5
+ ZLib = 3
6
+ }
7
+ export declare const KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * From https://github.com/donmccurdy/zstddec by Don McCurdy
3
+ */
4
+ interface DecoderExports {
5
+ memory: Uint8Array;
6
+ ZSTD_findDecompressedSize: (compressedPtr: number, compressedSize: number) => number;
7
+ ZSTD_decompress: (uncompressedPtr: number, uncompressedSize: number, compressedPtr: number, compressedSize: number) => number;
8
+ malloc: (ptr: number) => number;
9
+ free: (ptr: number) => void;
10
+ }
11
+ /**
12
+ * ZSTD (Zstandard) decoder.
13
+ */
14
+ export declare class ZSTDDecoder {
15
+ static heap: Uint8Array;
16
+ static IMPORT_OBJECT: {
17
+ env: {
18
+ emscripten_notify_memory_growth: () => void;
19
+ };
20
+ };
21
+ static instance: {
22
+ exports: DecoderExports;
23
+ };
24
+ static WasmModuleURL: string;
25
+ _initPromise: Promise<any>;
26
+ init(): Promise<void>;
27
+ _init(result: WebAssembly.WebAssemblyInstantiatedSource): void;
28
+ decode(array: Uint8Array, uncompressedSize?: number): Uint8Array;
29
+ }
30
+ export {};
31
+ /**
32
+ * BSD License
33
+ *
34
+ * For Zstandard software
35
+ *
36
+ * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. All rights reserved.
37
+ *
38
+ * Redistribution and use in source and binary forms, with or without modification,
39
+ * are permitted provided that the following conditions are met:
40
+ *
41
+ * * Redistributions of source code must retain the above copyright notice, this
42
+ * list of conditions and the following disclaimer.
43
+ *
44
+ * * Redistributions in binary form must reproduce the above copyright notice,
45
+ * this list of conditions and the following disclaimer in the documentation
46
+ * and/or other materials provided with the distribution.
47
+ *
48
+ * * Neither the name Facebook nor the names of its contributors may be used to
49
+ * endorse or promote products derived from this software without specific
50
+ * prior written permission.
51
+ *
52
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
53
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
54
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
56
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
59
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
+ */
@@ -0,0 +1,11 @@
1
+ import { Engine, Entity } from "@galacean/engine-core";
2
+ import { HierarchyParser } from "../resource-deserialize/resources/parser/HierarchyParser";
3
+ import { PrefabResource } from "./PrefabResource";
4
+ import { IHierarchyFile, ParserContext } from "../resource-deserialize";
5
+ export declare class PrefabParser extends HierarchyParser<PrefabResource, ParserContext<IHierarchyFile, Entity>> {
6
+ readonly prefabResource: PrefabResource;
7
+ static parse(engine: Engine, url: string, data: IHierarchyFile): Promise<PrefabResource>;
8
+ constructor(data: IHierarchyFile, context: ParserContext<IHierarchyFile, Entity>, prefabResource: PrefabResource);
9
+ protected _handleRootEntity(id: string): void;
10
+ protected _clearAndResolve(): PrefabResource;
11
+ }
@@ -0,0 +1,25 @@
1
+ import { Engine, Entity, ReferResource } from "@galacean/engine-core";
2
+ /**
3
+ * The Prefab resource.
4
+ */
5
+ export declare class PrefabResource extends ReferResource {
6
+ readonly url: string;
7
+ /** @internal */
8
+ _root: Entity;
9
+ private _dependenceAssets;
10
+ /**
11
+ * @internal
12
+ * @param url - The url of the prefab
13
+ */
14
+ constructor(engine: Engine, url: string);
15
+ /**
16
+ * Instantiate prefab.
17
+ * @returns prefab's root entity
18
+ */
19
+ instantiate(): Entity;
20
+ /**
21
+ * @internal
22
+ */
23
+ _addDependenceAsset(resource: ReferResource): void;
24
+ protected _onDestroy(): void;
25
+ }
@@ -2,7 +2,6 @@ import { Engine } from "@galacean/engine-core";
2
2
  export { MeshDecoder } from "./resources/mesh/MeshDecoder";
3
3
  export { Texture2DDecoder } from "./resources/texture2D/TextureDecoder";
4
4
  export { ReflectionParser } from "./resources/parser/ReflectionParser";
5
- export { PrefabParser } from "./resources/prefab/PrefabParser";
6
5
  export * from "./resources/animationClip/AnimationClipDecoder";
7
6
  export type { IModelMesh } from "./resources/mesh/IModelMesh";
8
7
  /**
@@ -1,9 +1,11 @@
1
- import { Entity, Engine, Scene } from "@galacean/engine-core";
2
- import type { IPrefabFile } from "../schema";
1
+ import { Engine, Scene } from "@galacean/engine-core";
2
+ import type { IHierarchyFile } from "../schema";
3
3
  import { ReflectionParser } from "./ReflectionParser";
4
4
  import { ParserContext } from "./ParserContext";
5
+ import { PrefabResource } from "../../../prefab/PrefabResource";
5
6
  /** @Internal */
6
- export default abstract class HierarchyParser<T extends Scene | Entity, V extends ParserContext<IPrefabFile, T>> {
7
+ export declare abstract class HierarchyParser<T extends Scene | PrefabResource, V extends ParserContext<IHierarchyFile, T>> {
8
+ readonly data: IHierarchyFile;
7
9
  readonly context: V;
8
10
  /**
9
11
  * The promise of parsed object.
@@ -13,24 +15,24 @@ export default abstract class HierarchyParser<T extends Scene | Entity, V extend
13
15
  protected _reject: (reason: any) => void;
14
16
  protected _engine: Engine;
15
17
  protected _reflectionParser: ReflectionParser;
16
- private prefabContextMap;
17
- private prefabPromiseMap;
18
- constructor(context: V);
18
+ private _prefabContextMap;
19
+ private _prefabPromiseMap;
20
+ constructor(data: IHierarchyFile, context: V);
19
21
  /** start parse the scene or prefab or others */
20
22
  start(): void;
21
- protected abstract handleRootEntity(id: string): void;
23
+ protected abstract _handleRootEntity(id: string): void;
24
+ protected abstract _clearAndResolve(): Scene | PrefabResource;
22
25
  private _parseEntities;
23
26
  private _parseComponents;
24
27
  private _parsePrefabModification;
25
28
  private _parsePrefabRemovedEntities;
26
29
  private _parsePrefabRemovedComponents;
27
- private _clearAndResolve;
28
30
  private _organizeEntities;
29
31
  private _getEntityByConfig;
30
32
  private _parseEntity;
31
- private _parseGLTF;
33
+ private _parsePrefab;
32
34
  private _parseStrippedEntity;
33
35
  private _parseChildren;
34
36
  private _applyEntityData;
35
- private _traverseAddEntityToMap;
37
+ private _generateInstanceContext;
36
38
  }
@@ -1,29 +1,30 @@
1
- import { Component, EngineObject, Entity, ResourceManager } from "@galacean/engine-core";
2
- import type { IEntity } from "../schema";
1
+ import { Component, Engine, EngineObject, Entity, ReferResource, ResourceManager, Scene } from "@galacean/engine-core";
2
+ import type { IEntity, IHierarchyFile } from "../schema";
3
+ export declare enum ParserType {
4
+ Prefab = 0,
5
+ Scene = 1
6
+ }
3
7
  /**
4
8
  * Parser context
5
9
  * @export
6
- * @abstract
7
10
  * @class ParserContext
8
11
  * @template T
9
12
  * @template I
10
13
  */
11
- export declare class ParserContext<T extends Object, I extends EngineObject> {
12
- readonly originalData: T;
13
- readonly engine: any;
14
- target?: I;
14
+ export declare class ParserContext<T extends IHierarchyFile, I extends EngineObject> {
15
+ readonly engine: Engine;
16
+ readonly type: ParserType;
17
+ readonly resource: ReferResource | Scene;
15
18
  entityMap: Map<string, Entity>;
16
- components: Map<string, Component>;
17
- assets: Map<string, any>;
18
19
  entityConfigMap: Map<string, IEntity>;
20
+ components: Map<string, Component>;
19
21
  rootIds: string[];
20
22
  strippedIds: string[];
21
23
  readonly resourceManager: ResourceManager;
22
- constructor(originalData: T, engine: any, target?: I);
24
+ constructor(engine: Engine, type: ParserType, resource: ReferResource | Scene);
23
25
  /**
24
26
  * Destroy the context.
25
- * @abstract
26
27
  * @memberof ParserContext
27
28
  */
28
- destroy(): void;
29
+ clear(): void;
29
30
  }
@@ -1,11 +1,11 @@
1
1
  import { EngineObject, Entity } from "@galacean/engine-core";
2
- import type { IBasicType, IClassObject, IEntity, IPrefabFile } from "../schema";
2
+ import type { IBasicType, IClassObject, IEntity, IHierarchyFile } from "../schema";
3
3
  import { ParserContext } from "./ParserContext";
4
4
  export declare class ReflectionParser {
5
5
  private readonly _context;
6
6
  static customParseComponentHandles: Map<string, Function>;
7
7
  static registerCustomParseComponent(componentType: string, handle: Function): void;
8
- constructor(_context: ParserContext<IPrefabFile, EngineObject>);
8
+ constructor(_context: ParserContext<IHierarchyFile, EngineObject>);
9
9
  parseEntity(entityConfig: IEntity): Promise<Entity>;
10
10
  parseClassObject(item: IClassObject): Promise<any>;
11
11
  parsePropsAndMethods(instance: any, item: Omit<IClassObject, "class">): Promise<any>;