@galacean/engine-loader 0.9.0-beta.80
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/LICENSE +21 -0
- package/README.md +1 -0
- package/dist/main.js +4410 -0
- package/dist/main.js.map +1 -0
- package/dist/miniprogram.js +4410 -0
- package/dist/module.js +4400 -0
- package/dist/module.js.map +1 -0
- package/package.json +26 -0
- package/types/AnimationClipLoader.d.ts +0 -0
- package/types/AnimatorControllerLoader.d.ts +1 -0
- package/types/BufferLoader.d.ts +1 -0
- package/types/EnvLoader.d.ts +1 -0
- package/types/FontLoader.d.ts +1 -0
- package/types/GLTFContentRestorer.d.ts +85 -0
- package/types/GLTFLoader.d.ts +12 -0
- package/types/HDRLoader.d.ts +1 -0
- package/types/JSONLoader.d.ts +1 -0
- package/types/KTXCubeLoader.d.ts +1 -0
- package/types/KTXLoader.d.ts +4 -0
- package/types/MaterialLoader.d.ts +1 -0
- package/types/MeshLoader.d.ts +1 -0
- package/types/SceneLoader.d.ts +1 -0
- package/types/SourceFontLoader.d.ts +1 -0
- package/types/SpriteAtlasLoader.d.ts +1 -0
- package/types/SpriteLoader.d.ts +1 -0
- package/types/TextLoader.d.ts +1 -0
- package/types/Texture2DContentRestorer.d.ts +14 -0
- package/types/Texture2DLoader.d.ts +10 -0
- package/types/TextureCubeContentRestorer.d.ts +14 -0
- package/types/TextureCubeLoader.d.ts +1 -0
- package/types/compressed-texture/KhronosTextureContainer.d.ts +20 -0
- package/types/compressed-texture/index.d.ts +3 -0
- package/types/compressed-texture/type.d.ts +87 -0
- package/types/gltf/GLTFParser.d.ts +9 -0
- package/types/gltf/GLTFPipeline.d.ts +23 -0
- package/types/gltf/GLTFResource.d.ts +39 -0
- package/types/gltf/GLTFSchema.d.ts +816 -0
- package/types/gltf/GLTFUtil.d.ts +53 -0
- package/types/gltf/Schema.d.ts +814 -0
- package/types/gltf/extensions/ExtensionParser.d.ts +8 -0
- package/types/gltf/extensions/GALACEAN_materials_remap.d.ts +1 -0
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +52 -0
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +149 -0
- package/types/gltf/extensions/KHR_draco_mesh_compression.d.ts +1 -0
- package/types/gltf/extensions/KHR_lights_punctual.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_clearcoat.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_ior.d.ts +0 -0
- package/types/gltf/extensions/KHR_materials_pbrSpecularGlossiness.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_sheen.d.ts +0 -0
- package/types/gltf/extensions/KHR_materials_transmission.d.ts +0 -0
- package/types/gltf/extensions/KHR_materials_unlit.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_variants.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_volume.d.ts +0 -0
- package/types/gltf/extensions/KHR_mesh_quantization.d.ts +1 -0
- package/types/gltf/extensions/KHR_texture_basisu.d.ts +0 -0
- package/types/gltf/extensions/KHR_texture_transform.d.ts +1 -0
- package/types/gltf/extensions/OASIS_animation_event.d.ts +1 -0
- package/types/gltf/extensions/OASIS_materials_remap.d.ts +1 -0
- package/types/gltf/extensions/Schema.d.ts +142 -0
- package/types/gltf/extensions/index.d.ts +14 -0
- package/types/gltf/index.d.ts +6 -0
- package/types/gltf/parser/AnimationParser.d.ts +7 -0
- package/types/gltf/parser/BufferParser.d.ts +7 -0
- package/types/gltf/parser/EntityParser.d.ts +9 -0
- package/types/gltf/parser/GLTFAnimationParser.d.ts +12 -0
- package/types/gltf/parser/GLTFBufferParser.d.ts +7 -0
- package/types/gltf/parser/GLTFEntityParser.d.ts +9 -0
- package/types/gltf/parser/GLTFMaterialParser.d.ts +15 -0
- package/types/gltf/parser/GLTFMeshParser.d.ts +19 -0
- package/types/gltf/parser/GLTFParser.d.ts +63 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +48 -0
- package/types/gltf/parser/GLTFSceneParser.d.ts +11 -0
- package/types/gltf/parser/GLTFSkinParser.d.ts +6 -0
- package/types/gltf/parser/GLTFTextureParser.d.ts +8 -0
- package/types/gltf/parser/GLTFValidator.d.ts +6 -0
- package/types/gltf/parser/MaterialParser.d.ts +8 -0
- package/types/gltf/parser/MeshParser.d.ts +13 -0
- package/types/gltf/parser/Parser.d.ts +21 -0
- package/types/gltf/parser/ParserContext.d.ts +46 -0
- package/types/gltf/parser/SceneParser.d.ts +11 -0
- package/types/gltf/parser/SkinParser.d.ts +6 -0
- package/types/gltf/parser/TextureParser.d.ts +8 -0
- package/types/gltf/parser/Validator.d.ts +5 -0
- package/types/gltf/parser/index.d.ts +11 -0
- package/types/index.d.ts +23 -0
- package/types/resource-deserialize/index.d.ts +18 -0
- package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +17 -0
- package/types/resource-deserialize/resources/animationClip/ComponentMap.d.ts +2 -0
- package/types/resource-deserialize/resources/mesh/MeshDecoder.d.ts +9 -0
- package/types/resource-deserialize/resources/mesh/type.d.ts +31 -0
- package/types/resource-deserialize/resources/prefab/PrefabDesign.d.ts +70 -0
- package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +5 -0
- package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -0
- package/types/resource-deserialize/resources/scene/EditorTextureLoader.d.ts +4 -0
- package/types/resource-deserialize/resources/scene/MeshLoader.d.ts +4 -0
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +28 -0
- package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +13 -0
- package/types/resource-deserialize/resources/texture2D/TextureDecoder.d.ts +5 -0
- package/types/resource-deserialize/utils/BufferReader.d.ts +32 -0
- package/types/resource-deserialize/utils/Decorator.d.ts +11 -0
- package/types/resource-deserialize/utils/FileHeader.d.ts +9 -0
- package/types/resource-deserialize/utils/Utils.d.ts +5 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AssetPromise } from "@oasis-engine/core";
|
|
2
|
+
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
|
+
export declare class GLTFValidator extends GLTFParser {
|
|
5
|
+
parse(context: GLTFParserContext): AssetPromise<void>;
|
|
6
|
+
}
|
|
@@ -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,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,11 @@
|
|
|
1
|
+
export { GLTFAnimationParser } from "./GLTFAnimationParser";
|
|
2
|
+
export { GLTFBufferParser } from "./GLTFBufferParser";
|
|
3
|
+
export { GLTFEntityParser } from "./GLTFEntityParser";
|
|
4
|
+
export { GLTFMaterialParser } from "./GLTFMaterialParser";
|
|
5
|
+
export { GLTFMeshParser } from "./GLTFMeshParser";
|
|
6
|
+
export { GLTFParser, registerGLTFExtension } from "./GLTFParser";
|
|
7
|
+
export { GLTFSceneParser } from "./GLTFSceneParser";
|
|
8
|
+
export { GLTFSkinParser } from "./GLTFSkinParser";
|
|
9
|
+
export { GLTFTextureParser } from "./GLTFTextureParser";
|
|
10
|
+
export { GLTFValidator } from "./GLTFValidator";
|
|
11
|
+
export { GLTFParserContext } from "./GLTFParserContext";
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./AnimatorControllerLoader";
|
|
2
|
+
import "./BufferLoader";
|
|
3
|
+
import "./EnvLoader";
|
|
4
|
+
import "./FontLoader";
|
|
5
|
+
import "./gltf/extensions/index";
|
|
6
|
+
import "./GLTFLoader";
|
|
7
|
+
import "./HDRLoader";
|
|
8
|
+
import "./JSONLoader";
|
|
9
|
+
import "./KTXCubeLoader";
|
|
10
|
+
import "./KTXLoader";
|
|
11
|
+
import "./MaterialLoader";
|
|
12
|
+
import "./MeshLoader";
|
|
13
|
+
import "./SourceFontLoader";
|
|
14
|
+
import "./SpriteAtlasLoader";
|
|
15
|
+
import "./SpriteLoader";
|
|
16
|
+
import "./Texture2DLoader";
|
|
17
|
+
import "./TextureCubeLoader";
|
|
18
|
+
export { parseSingleKTX } from "./compressed-texture";
|
|
19
|
+
export { GLTFResource } from "./gltf/GLTFResource";
|
|
20
|
+
export type { GLTFParams } from "./GLTFLoader";
|
|
21
|
+
export * from "./resource-deserialize";
|
|
22
|
+
export * from "./SceneLoader";
|
|
23
|
+
export type { Texture2DParams } from "./Texture2DLoader";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Engine } from "@galacean/engine-core";
|
|
2
|
+
export { MeshDecoder } from "./resources/mesh/MeshDecoder";
|
|
3
|
+
export { Texture2DDecoder } from "./resources/texture2D/TextureDecoder";
|
|
4
|
+
export { ReflectionParser } from "./resources/prefab/ReflectionParser";
|
|
5
|
+
export { PrefabParser } from "./resources/prefab/PrefabParser";
|
|
6
|
+
export * from "./resources/animationClip/AnimationClipDecoder";
|
|
7
|
+
export type { IModelMesh } from "./resources/mesh/IModelMesh";
|
|
8
|
+
/**
|
|
9
|
+
* Decode engine binary resource.
|
|
10
|
+
* @param arrayBuffer - array buffer of decode binary file
|
|
11
|
+
* @param engine - engine
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function decode<T>(arrayBuffer: ArrayBuffer, engine: Engine): Promise<T>;
|
|
15
|
+
export * from "./resources/prefab/PrefabDesign";
|
|
16
|
+
export * from "./resources/scene/SceneParser";
|
|
17
|
+
export * from "./resources/scene/MeshLoader";
|
|
18
|
+
export * from "./resources/scene/EditorTextureLoader";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnimationClip, Engine } from "@galacean/engine-core";
|
|
2
|
+
import type { BufferReader } from "../../utils/BufferReader";
|
|
3
|
+
export { ComponentMap } from "./ComponentMap";
|
|
4
|
+
export declare enum InterpolableValueType {
|
|
5
|
+
Float = 0,
|
|
6
|
+
FloatArray = 1,
|
|
7
|
+
Vector2 = 2,
|
|
8
|
+
Vector3 = 3,
|
|
9
|
+
Vector4 = 4,
|
|
10
|
+
Quaternion = 5,
|
|
11
|
+
Color = 6,
|
|
12
|
+
Array = 7,
|
|
13
|
+
Boolean = 8
|
|
14
|
+
}
|
|
15
|
+
export declare class AnimationClipDecoder {
|
|
16
|
+
static decode(engine: Engine, bufferReader: BufferReader): Promise<AnimationClip>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModelMesh } from "@galacean/engine-core";
|
|
2
|
+
import type { Engine } from "@galacean/engine-core";
|
|
3
|
+
import type { BufferReader } from "../../utils/BufferReader";
|
|
4
|
+
/**
|
|
5
|
+
* @todo refactor
|
|
6
|
+
*/
|
|
7
|
+
export declare class MeshDecoder {
|
|
8
|
+
static decode(engine: Engine, bufferReader: BufferReader): Promise<ModelMesh>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type uint8 = number;
|
|
2
|
+
type uint16 = number;
|
|
3
|
+
type uint32 = number;
|
|
4
|
+
export interface IMeshData {
|
|
5
|
+
objectId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
vertexElements: Array<{
|
|
8
|
+
semantic: string;
|
|
9
|
+
offset: uint32;
|
|
10
|
+
format: uint8;
|
|
11
|
+
bindingIndex: uint8;
|
|
12
|
+
instanceStepRate: uint8;
|
|
13
|
+
}>;
|
|
14
|
+
subMeshes: Array<{
|
|
15
|
+
start: uint32;
|
|
16
|
+
count: uint32;
|
|
17
|
+
topology: uint8;
|
|
18
|
+
}>;
|
|
19
|
+
vertexBuffer: {
|
|
20
|
+
bufferUsage: uint8;
|
|
21
|
+
buffer: ArrayBuffer;
|
|
22
|
+
stride: uint16;
|
|
23
|
+
};
|
|
24
|
+
hasIndexBuffer: boolean;
|
|
25
|
+
indexBuffer?: {
|
|
26
|
+
bufferUsage: uint8;
|
|
27
|
+
buffer: ArrayBuffer;
|
|
28
|
+
format: uint8;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { BackgroundMode } from "@galacean/engine-core";
|
|
2
|
+
import { IRefObject } from "@galacean/engine-core/types/asset/IRefObject";
|
|
3
|
+
import { IColor } from "../mesh/IModelMesh";
|
|
4
|
+
export interface IPrefabFile {
|
|
5
|
+
entities: Array<IEntity>;
|
|
6
|
+
}
|
|
7
|
+
export interface IScene extends IPrefabFile {
|
|
8
|
+
scene: {
|
|
9
|
+
background: {
|
|
10
|
+
mode: BackgroundMode;
|
|
11
|
+
color: IColor;
|
|
12
|
+
texture?: IRefObject;
|
|
13
|
+
sky?: IRefObject;
|
|
14
|
+
};
|
|
15
|
+
ambient: {
|
|
16
|
+
ambientLight: IRefObject;
|
|
17
|
+
diffuseSolidColor: IColor;
|
|
18
|
+
diffuseIntensity: number;
|
|
19
|
+
specularIntensity: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
files: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
type: string;
|
|
25
|
+
virtualPath: string;
|
|
26
|
+
path: string;
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
export interface IVector3 {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
z: number;
|
|
33
|
+
}
|
|
34
|
+
export interface IBasicEntity {
|
|
35
|
+
name?: string;
|
|
36
|
+
id?: string;
|
|
37
|
+
components?: Array<IComponent>;
|
|
38
|
+
isActive?: boolean;
|
|
39
|
+
position?: IVector3;
|
|
40
|
+
rotation?: IVector3;
|
|
41
|
+
scale?: IVector3;
|
|
42
|
+
children?: Array<string>;
|
|
43
|
+
parent?: string;
|
|
44
|
+
}
|
|
45
|
+
export type IEntity = IBasicEntity | IRefEntity;
|
|
46
|
+
export interface IRefEntity extends IBasicEntity {
|
|
47
|
+
assetRefId: string;
|
|
48
|
+
key?: string;
|
|
49
|
+
isClone?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export type IComponent = {
|
|
52
|
+
id: string;
|
|
53
|
+
refId?: string;
|
|
54
|
+
} & IClassObject;
|
|
55
|
+
export type IMethodParams = Array<IBasicType>;
|
|
56
|
+
export type IClassObject = {
|
|
57
|
+
class: string;
|
|
58
|
+
constructParams?: IMethodParams;
|
|
59
|
+
methods?: {
|
|
60
|
+
[methodName: string]: Array<IMethodParams>;
|
|
61
|
+
};
|
|
62
|
+
props?: {
|
|
63
|
+
[key: string]: IBasicType | IMethodParams;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export type IBasicType = string | number | boolean | null | undefined | IAssetRef | IClassObject | IMethodParams;
|
|
67
|
+
export type IAssetRef = {
|
|
68
|
+
key?: string;
|
|
69
|
+
refId: string;
|
|
70
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Engine, Entity } from "@galacean/engine-core";
|
|
2
|
+
import { IBasicType, IClassObject, IEntity } from "./PrefabDesign";
|
|
3
|
+
export declare class ReflectionParser {
|
|
4
|
+
static customParseComponentHandles: Map<string, Function>;
|
|
5
|
+
static registerCustomParseComponent(componentType: string, handle: Function): void;
|
|
6
|
+
static parseEntity(entityConfig: IEntity, engine: Engine): Promise<Entity>;
|
|
7
|
+
private static getEntityByConfig;
|
|
8
|
+
static parseClassObject(item: IClassObject, engine: Engine, resourceManager?: any): Promise<any>;
|
|
9
|
+
static parseBasicType(value: IBasicType, engine: Engine, resourceManager?: any): Promise<any>;
|
|
10
|
+
static parsePropsAndMethods(instance: any, item: Omit<IClassObject, "class">, engine: Engine, resourceManager?: any): Promise<any>;
|
|
11
|
+
static parseMethod(instance: any, methodName: string, methodParams: Array<IBasicType>, engine: Engine, resourceManager?: any): Promise<any>;
|
|
12
|
+
private static _isClass;
|
|
13
|
+
private static _isRef;
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Engine, Scene } from "@galacean/engine-core";
|
|
2
|
+
import { IScene } from "../prefab/PrefabDesign";
|
|
3
|
+
import { SceneParserContext } from "./SceneParserContext";
|
|
4
|
+
/** @Internal */
|
|
5
|
+
export declare class SceneParser {
|
|
6
|
+
readonly context: SceneParserContext;
|
|
7
|
+
/**
|
|
8
|
+
* Parse scene data.
|
|
9
|
+
* @param engine - the engine of the parser context
|
|
10
|
+
* @param sceneData - scene data which is exported by editor
|
|
11
|
+
* @returns a promise of scene
|
|
12
|
+
*/
|
|
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
|
+
constructor(context: SceneParserContext);
|
|
22
|
+
/** start parse the scene */
|
|
23
|
+
start(): void;
|
|
24
|
+
private _parseEntities;
|
|
25
|
+
private _organizeEntities;
|
|
26
|
+
private _parseComponents;
|
|
27
|
+
private _clearAndResolveScene;
|
|
28
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component, Entity, Scene } from "@galacean/engine-core";
|
|
2
|
+
import { IEntity, IScene } from "../prefab/PrefabDesign";
|
|
3
|
+
export declare class SceneParserContext {
|
|
4
|
+
readonly originalData: IScene;
|
|
5
|
+
readonly scene: Scene;
|
|
6
|
+
entityMap: Map<string, Entity>;
|
|
7
|
+
components: Map<string, Component>;
|
|
8
|
+
assets: Map<string, any>;
|
|
9
|
+
entityConfigMap: Map<string, IEntity>;
|
|
10
|
+
rootIds: string[];
|
|
11
|
+
constructor(originalData: IScene, scene: Scene);
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare class BufferReader {
|
|
2
|
+
buffer: ArrayBuffer;
|
|
3
|
+
private _dataView;
|
|
4
|
+
private _littleEndian;
|
|
5
|
+
private _offset;
|
|
6
|
+
static imageMapping: {
|
|
7
|
+
0: string;
|
|
8
|
+
1: string;
|
|
9
|
+
2: string;
|
|
10
|
+
3: string;
|
|
11
|
+
};
|
|
12
|
+
constructor(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number, littleEndian?: boolean);
|
|
13
|
+
get offset(): number;
|
|
14
|
+
nextUint8(): number;
|
|
15
|
+
nextUint16(): number;
|
|
16
|
+
nextUint32(): number;
|
|
17
|
+
nextInt32(): number;
|
|
18
|
+
nextInt32Array(len: number): Int32Array;
|
|
19
|
+
nextFloat32(): number;
|
|
20
|
+
nextFloat32Array(len: number): Float32Array;
|
|
21
|
+
nextUint32Array(len: number): Uint32Array;
|
|
22
|
+
nextUint8Array(len: number): Uint8Array;
|
|
23
|
+
nextUint64(): number;
|
|
24
|
+
nextStr(): string;
|
|
25
|
+
/**
|
|
26
|
+
* image data 放在最后
|
|
27
|
+
*/
|
|
28
|
+
nextImageData(count?: number): ArrayBuffer;
|
|
29
|
+
nextImagesData(count: number): ArrayBuffer[];
|
|
30
|
+
skip(bytes: number): this;
|
|
31
|
+
scan(maxByteLength: number, term?: number): Uint8Array;
|
|
32
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Engine } from "@galacean/engine-core";
|
|
2
|
+
import type { BufferReader } from "./BufferReader";
|
|
3
|
+
export declare const decoderMap: Record<string, {
|
|
4
|
+
decode: (engine: Engine, bufferReader: BufferReader) => Promise<any>;
|
|
5
|
+
}>;
|
|
6
|
+
/**
|
|
7
|
+
* Decoder decorator generator.
|
|
8
|
+
* @param type - resource file type.
|
|
9
|
+
* @returns Decoder decorator
|
|
10
|
+
*/
|
|
11
|
+
export declare function decoder(type: string): ClassDecorator;
|