@galacean/engine-loader 1.2.0-alpha.3 → 1.2.0-alpha.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/main.js +373 -163
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +373 -163
- package/dist/module.js +374 -164
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/resource-deserialize/index.d.ts +2 -1
- package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
- package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
- package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
- package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +13 -4
- package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
- package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +24 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-loader",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"types/**/*"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@galacean/engine-
|
|
19
|
-
"@galacean/engine-
|
|
20
|
-
"@galacean/engine-
|
|
18
|
+
"@galacean/engine-math": "1.2.0-alpha.5",
|
|
19
|
+
"@galacean/engine-rhi-webgl": "1.2.0-alpha.5",
|
|
20
|
+
"@galacean/engine-core": "1.2.0-alpha.5"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"b:types": "tsc"
|
|
@@ -2,7 +2,7 @@ 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/
|
|
5
|
+
export { PrefabParser } from "./resources/prefab/PrefabParser";
|
|
6
6
|
export * from "./resources/animationClip/AnimationClipDecoder";
|
|
7
7
|
export type { IModelMesh } from "./resources/mesh/IModelMesh";
|
|
8
8
|
/**
|
|
@@ -16,3 +16,4 @@ export * from "./resources/schema";
|
|
|
16
16
|
export * from "./resources/scene/SceneParser";
|
|
17
17
|
export * from "./resources/scene/MeshLoader";
|
|
18
18
|
export * from "./resources/scene/EditorTextureLoader";
|
|
19
|
+
export * from "./resources/parser/ParserContext";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Entity, Engine, Scene } from "@galacean/engine-core";
|
|
2
|
+
import type { IPrefabFile } from "../schema";
|
|
3
|
+
import { ReflectionParser } from "./ReflectionParser";
|
|
4
|
+
import { ParserContext } from "./ParserContext";
|
|
5
|
+
/** @Internal */
|
|
6
|
+
export default abstract class HierarchyParser<T extends Scene | Entity, V extends ParserContext<IPrefabFile, T>> {
|
|
7
|
+
readonly context: V;
|
|
8
|
+
/**
|
|
9
|
+
* The promise of parsed object.
|
|
10
|
+
*/
|
|
11
|
+
readonly promise: Promise<T>;
|
|
12
|
+
protected _resolve: (item: T) => void;
|
|
13
|
+
protected _reject: (reason: any) => void;
|
|
14
|
+
protected _engine: Engine;
|
|
15
|
+
protected _reflectionParser: ReflectionParser;
|
|
16
|
+
private prefabContextMap;
|
|
17
|
+
private prefabPromiseMap;
|
|
18
|
+
constructor(context: V);
|
|
19
|
+
/** start parse the scene or prefab or others */
|
|
20
|
+
start(): void;
|
|
21
|
+
protected abstract handleRootEntity(id: string): void;
|
|
22
|
+
private _parseEntities;
|
|
23
|
+
private _parseComponents;
|
|
24
|
+
private _parsePrefabModification;
|
|
25
|
+
private _parsePrefabRemovedEntities;
|
|
26
|
+
private _parsePrefabRemovedComponents;
|
|
27
|
+
private _clearAndResolve;
|
|
28
|
+
private _organizeEntities;
|
|
29
|
+
private _getEntityByConfig;
|
|
30
|
+
private _parseEntity;
|
|
31
|
+
private _parseGLTF;
|
|
32
|
+
private _parseStrippedEntity;
|
|
33
|
+
private _parseChildren;
|
|
34
|
+
private _applyEntityData;
|
|
35
|
+
private _traverseAddEntityToMap;
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Component, EngineObject, Entity, ResourceManager } from "@galacean/engine-core";
|
|
2
|
+
import type { IEntity } from "../schema";
|
|
3
|
+
/**
|
|
4
|
+
* Parser context
|
|
5
|
+
* @export
|
|
6
|
+
* @abstract
|
|
7
|
+
* @class ParserContext
|
|
8
|
+
* @template T
|
|
9
|
+
* @template I
|
|
10
|
+
*/
|
|
11
|
+
export declare class ParserContext<T extends Object, I extends EngineObject> {
|
|
12
|
+
readonly originalData: T;
|
|
13
|
+
readonly engine: any;
|
|
14
|
+
target?: I;
|
|
15
|
+
entityMap: Map<string, Entity>;
|
|
16
|
+
components: Map<string, Component>;
|
|
17
|
+
assets: Map<string, any>;
|
|
18
|
+
entityConfigMap: Map<string, IEntity>;
|
|
19
|
+
rootIds: string[];
|
|
20
|
+
strippedIds: string[];
|
|
21
|
+
readonly resourceManager: ResourceManager;
|
|
22
|
+
constructor(originalData: T, engine: any, target?: I);
|
|
23
|
+
/**
|
|
24
|
+
* Destroy the context.
|
|
25
|
+
* @abstract
|
|
26
|
+
* @memberof ParserContext
|
|
27
|
+
*/
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Entity } from "@galacean/engine-core";
|
|
2
|
-
import type { IBasicType, IClassObject, IEntity } from "../schema";
|
|
3
|
-
import {
|
|
1
|
+
import { EngineObject, Entity } from "@galacean/engine-core";
|
|
2
|
+
import type { IBasicType, IClassObject, IEntity, IPrefabFile } from "../schema";
|
|
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:
|
|
8
|
+
constructor(_context: ParserContext<IPrefabFile, 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>;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { Entity } from "@galacean/engine-core";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Entity, Engine } from "@galacean/engine-core";
|
|
2
|
+
import type { IPrefabFile } from "../schema";
|
|
3
|
+
import { PrefabParserContext } from "./PrefabParserContext";
|
|
4
|
+
import HierarchyParser from "../parser/HierarchyParser";
|
|
5
|
+
export declare class PrefabParser extends HierarchyParser<Entity, PrefabParserContext> {
|
|
6
|
+
/**
|
|
7
|
+
* Parse prefab data.
|
|
8
|
+
* @param engine - the engine of the parser context
|
|
9
|
+
* @param prefabData - prefab data which is exported by editor
|
|
10
|
+
* @returns a promise of prefab
|
|
11
|
+
*/
|
|
12
|
+
static parse(engine: Engine, prefabData: IPrefabFile): PrefabParser;
|
|
13
|
+
protected handleRootEntity(id: string): void;
|
|
5
14
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Engine, Scene } from "@galacean/engine-core";
|
|
2
2
|
import type { IScene } from "../schema";
|
|
3
3
|
import { SceneParserContext } from "./SceneParserContext";
|
|
4
|
+
import HierarchyParser from "../parser/HierarchyParser";
|
|
4
5
|
/** @Internal */
|
|
5
|
-
export declare class SceneParser {
|
|
6
|
-
readonly context: SceneParserContext;
|
|
6
|
+
export declare class SceneParser extends HierarchyParser<Scene, SceneParserContext> {
|
|
7
7
|
/**
|
|
8
8
|
* Parse scene data.
|
|
9
9
|
* @param engine - the engine of the parser context
|
|
@@ -11,19 +11,5 @@ export declare class SceneParser {
|
|
|
11
11
|
* @returns a promise of scene
|
|
12
12
|
*/
|
|
13
13
|
static parse(engine: Engine, sceneData: IScene): Promise<Scene>;
|
|
14
|
-
|
|
15
|
-
* The promise of parsed scene.
|
|
16
|
-
*/
|
|
17
|
-
readonly promise: Promise<Scene>;
|
|
18
|
-
private _resolve;
|
|
19
|
-
private _reject;
|
|
20
|
-
private _engine;
|
|
21
|
-
private _reflectionParser;
|
|
22
|
-
constructor(context: SceneParserContext);
|
|
23
|
-
/** start parse the scene */
|
|
24
|
-
start(): void;
|
|
25
|
-
private _parseEntities;
|
|
26
|
-
private _organizeEntities;
|
|
27
|
-
private _parseComponents;
|
|
28
|
-
private _clearAndResolveScene;
|
|
14
|
+
protected handleRootEntity(id: string): void;
|
|
29
15
|
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import { Scene } from "@galacean/engine-core";
|
|
2
|
+
import { IScene } from "../schema";
|
|
3
|
+
import { ParserContext } from "../parser/ParserContext";
|
|
4
|
+
export declare class SceneParserContext extends ParserContext<IScene, Scene> {
|
|
4
5
|
readonly originalData: IScene;
|
|
6
|
+
readonly engine: any;
|
|
5
7
|
readonly scene: Scene;
|
|
6
|
-
|
|
7
|
-
components: Map<string, Component>;
|
|
8
|
-
assets: Map<string, any>;
|
|
9
|
-
entityConfigMap: Map<string, IEntity>;
|
|
10
|
-
rootIds: string[];
|
|
11
|
-
readonly engine: Engine;
|
|
12
|
-
readonly resourceManager: ResourceManager;
|
|
13
|
-
constructor(originalData: IScene, scene: Scene);
|
|
14
|
-
destroy(): void;
|
|
8
|
+
constructor(originalData: IScene, engine: any, scene: Scene);
|
|
15
9
|
}
|
|
@@ -36,11 +36,34 @@ export interface IBasicEntity {
|
|
|
36
36
|
parent?: string;
|
|
37
37
|
layer?: Layer;
|
|
38
38
|
}
|
|
39
|
-
export type IEntity = IBasicEntity | IRefEntity;
|
|
39
|
+
export type IEntity = IBasicEntity | IRefEntity | IStrippedEntity;
|
|
40
40
|
export interface IRefEntity extends IBasicEntity {
|
|
41
41
|
assetRefId: string;
|
|
42
42
|
key?: string;
|
|
43
43
|
isClone?: boolean;
|
|
44
|
+
modifications: {
|
|
45
|
+
target: IPrefabModifyTarget;
|
|
46
|
+
methods?: {
|
|
47
|
+
[methodName: string]: Array<IMethodParams>;
|
|
48
|
+
};
|
|
49
|
+
props?: {
|
|
50
|
+
[key: string]: IBasicType | IMethodParams;
|
|
51
|
+
};
|
|
52
|
+
}[];
|
|
53
|
+
removedEntities: IPrefabModifyTarget[];
|
|
54
|
+
removedComponents: IPrefabModifyTarget[];
|
|
55
|
+
}
|
|
56
|
+
export interface IPrefabModifyTarget {
|
|
57
|
+
entityId?: string;
|
|
58
|
+
componentId?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface IStrippedEntity extends IBasicEntity {
|
|
61
|
+
strippedId: string;
|
|
62
|
+
prefabInstanceId: string;
|
|
63
|
+
prefabSource: {
|
|
64
|
+
assetId: string;
|
|
65
|
+
entityId: string;
|
|
66
|
+
};
|
|
44
67
|
}
|
|
45
68
|
export type IComponent = {
|
|
46
69
|
id: string;
|