@galacean/engine-loader 0.0.0-experimental-renderSort.3 → 0.0.0-experimental-shaderlab.2
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 +2 -2
- package/dist/main.js +1310 -706
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1309 -706
- package/dist/module.js +1298 -695
- package/dist/module.js.map +1 -1
- package/package.json +4 -5
- package/types/GLTFContentRestorer.d.ts +7 -6
- package/types/GLTFLoader.d.ts +7 -1
- package/types/PrimitiveMeshLoader.d.ts +1 -0
- package/types/ShaderChunkLoader.d.ts +1 -0
- package/types/ShaderLoader.d.ts +1 -0
- package/types/gltf/GLTFResource.d.ts +50 -16
- package/types/gltf/GLTFSchema.d.ts +1 -1
- package/types/gltf/GLTFUtils.d.ts +6 -10
- package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +1 -1
- package/types/gltf/extensions/GLTFExtensionSchema.d.ts +18 -10
- package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
- package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
- package/types/gltf/extensions/index.d.ts +2 -1
- package/types/gltf/index.d.ts +2 -1
- package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
- package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
- package/types/gltf/parser/GLTFMeshParser.d.ts +7 -6
- package/types/gltf/parser/GLTFParser.d.ts +1 -1
- package/types/gltf/parser/GLTFParserContext.d.ts +20 -6
- package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
- package/types/gltf/parser/index.d.ts +2 -1
- package/types/index.d.ts +5 -1
- package/types/ktx2/KTX2Loader.d.ts +4 -3
- 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/PrefabDesign.d.ts +70 -0
- package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +14 -0
- package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
- package/types/resource-deserialize/resources/prefab/ReflectionParser.d.ts +14 -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 +27 -1
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +2 -1
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-loader",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-shaderlab.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
"types/**/*"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@galacean/engine-core": "0.0.0-experimental-
|
|
19
|
-
"@galacean/engine-math": "0.0.0-experimental-
|
|
20
|
-
"@galacean/engine-
|
|
21
|
-
"@galacean/engine-rhi-webgl": "0.0.0-experimental-renderSort.3"
|
|
18
|
+
"@galacean/engine-core": "0.0.0-experimental-shaderlab.2",
|
|
19
|
+
"@galacean/engine-math": "0.0.0-experimental-shaderlab.2",
|
|
20
|
+
"@galacean/engine-rhi-webgl": "0.0.0-experimental-shaderlab.2"
|
|
22
21
|
},
|
|
23
22
|
"scripts": {
|
|
24
23
|
"b:types": "tsc"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AssetPromise, BlendShape, Buffer, ContentRestorer, ModelMesh, Texture2D
|
|
1
|
+
import { AssetPromise, BlendShape, Buffer, ContentRestorer, ModelMesh, Texture2D } from "@galacean/engine-core";
|
|
2
2
|
import { RequestConfig } from "@galacean/engine-core/types/asset/request";
|
|
3
3
|
import { Vector2 } from "@galacean/engine-math";
|
|
4
4
|
import { GLTFResource } from "./gltf/GLTFResource";
|
|
5
|
-
import type { IBufferView } from "./gltf/GLTFSchema";
|
|
5
|
+
import type { AccessorComponentType, IBufferView } from "./gltf/GLTFSchema";
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
@@ -65,10 +65,10 @@ export declare class BufferDataRestoreInfo {
|
|
|
65
65
|
*/
|
|
66
66
|
export declare class RestoreDataAccessor {
|
|
67
67
|
bufferIndex: number;
|
|
68
|
-
TypedArray:
|
|
68
|
+
TypedArray: Uint8ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor;
|
|
69
69
|
byteOffset: number;
|
|
70
70
|
length: number;
|
|
71
|
-
constructor(bufferIndex: number, TypedArray:
|
|
71
|
+
constructor(bufferIndex: number, TypedArray: Uint8ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor, byteOffset: number, length: number);
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
74
|
* @internal
|
|
@@ -85,8 +85,9 @@ export declare class BlendShapeRestoreInfo {
|
|
|
85
85
|
*/
|
|
86
86
|
export declare class BlendShapeDataRestoreInfo {
|
|
87
87
|
buffer: BufferDataRestoreInfo;
|
|
88
|
-
stride: number;
|
|
89
88
|
byteOffset: number;
|
|
90
89
|
count: number;
|
|
91
|
-
|
|
90
|
+
normalized: boolean;
|
|
91
|
+
componentType: AccessorComponentType;
|
|
92
|
+
constructor(buffer: BufferDataRestoreInfo, byteOffset: number, count: number, normalized: boolean, componentType: AccessorComponentType);
|
|
92
93
|
}
|
package/types/GLTFLoader.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { AssetPromise, Loader, LoadItem, ResourceManager } from "@galacean/engine-core";
|
|
1
|
+
import { AssetPromise, Engine, EngineConfiguration, Loader, LoadItem, ResourceManager } from "@galacean/engine-core";
|
|
2
2
|
import { GLTFResource } from "./gltf/GLTFResource";
|
|
3
3
|
export declare class GLTFLoader extends Loader<GLTFResource> {
|
|
4
|
+
/**
|
|
5
|
+
* Release glTF loader memory(includes meshopt workers).
|
|
6
|
+
* @remarks If use loader after releasing, we should release again.
|
|
7
|
+
*/
|
|
8
|
+
static release(): void;
|
|
9
|
+
initialize(_: Engine, configuration: EngineConfiguration): Promise<void>;
|
|
4
10
|
load(item: LoadItem, resourceManager: ResourceManager): AssetPromise<GLTFResource>;
|
|
5
11
|
}
|
|
6
12
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,28 +4,62 @@ import { AnimationClip, Camera, Engine, Entity, Light, Material, ModelMesh, Refe
|
|
|
4
4
|
*/
|
|
5
5
|
export declare class GLTFResource extends ReferResource {
|
|
6
6
|
/** glTF file url. */
|
|
7
|
-
url: string;
|
|
7
|
+
readonly url: string;
|
|
8
8
|
/** Texture2D after TextureParser. */
|
|
9
|
-
textures?: Texture2D[];
|
|
9
|
+
readonly textures?: Texture2D[];
|
|
10
10
|
/** Material after MaterialParser. */
|
|
11
|
-
materials?: Material[];
|
|
11
|
+
readonly materials?: Material[];
|
|
12
12
|
/** ModelMesh after MeshParser. */
|
|
13
|
-
meshes?: ModelMesh[][];
|
|
13
|
+
readonly meshes?: ModelMesh[][];
|
|
14
14
|
/** Skin after SkinParser. */
|
|
15
|
-
skins?: Skin[];
|
|
15
|
+
readonly skins?: Skin[];
|
|
16
16
|
/** AnimationClip after AnimationParser. */
|
|
17
|
-
animations?: AnimationClip[];
|
|
18
|
-
/**
|
|
17
|
+
readonly animations?: AnimationClip[];
|
|
18
|
+
/** @internal */
|
|
19
|
+
_defaultSceneRoot: Entity;
|
|
20
|
+
/** @internal */
|
|
21
|
+
_sceneRoots: Entity[];
|
|
22
|
+
/** @internal */
|
|
23
|
+
_extensionsData: Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Extensions data.
|
|
26
|
+
*/
|
|
27
|
+
get extensionsData(): Record<string, any>;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
constructor(engine: Engine, url: string);
|
|
32
|
+
/**
|
|
33
|
+
* Instantiate scene root entity.
|
|
34
|
+
* @param sceneIndex - Scene index
|
|
35
|
+
* @returns Root entity
|
|
36
|
+
*/
|
|
37
|
+
instantiateSceneRoot(sceneIndex?: number): Entity;
|
|
38
|
+
protected _onDestroy(): void;
|
|
39
|
+
private _disassociationSuperResource;
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated
|
|
42
|
+
* Entity after EntityParser.
|
|
43
|
+
*/
|
|
19
44
|
entities: Entity[];
|
|
20
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated
|
|
47
|
+
* Camera after SceneParser.
|
|
48
|
+
*/
|
|
21
49
|
cameras?: Camera[];
|
|
22
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* @deprecated
|
|
52
|
+
* Export lights in extension KHR_lights_punctual.
|
|
53
|
+
*/
|
|
23
54
|
lights?: Light[];
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
57
|
+
* RootEntities after SceneParser.
|
|
58
|
+
*/
|
|
59
|
+
get sceneRoots(): Entity[];
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Please use `instantiateSceneRoot` instead.
|
|
62
|
+
* RootEntity after SceneParser.
|
|
63
|
+
*/
|
|
64
|
+
get defaultSceneRoot(): Entity;
|
|
31
65
|
}
|
|
@@ -20,17 +20,12 @@ export declare class GLTFUtils {
|
|
|
20
20
|
static getComponentType(componentType: AccessorComponentType): Float32ArrayConstructor | Uint32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor;
|
|
21
21
|
static getNormalizedComponentScale(componentType: AccessorComponentType): number;
|
|
22
22
|
static getAccessorBuffer(context: GLTFParserContext, bufferViews: IBufferView[], accessor: IAccessor): Promise<BufferInfo>;
|
|
23
|
-
static bufferToVector3Array(
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated
|
|
26
|
-
* Get accessor data.
|
|
27
|
-
*/
|
|
28
|
-
static getAccessorData(glTF: IGLTF, accessor: IAccessor, buffers: ArrayBuffer[]): TypedArray;
|
|
23
|
+
static bufferToVector3Array(buffer: TypedArray, byteOffset: number, count: number, normalized: boolean, componentType: AccessorComponentType): Vector3[];
|
|
29
24
|
static getBufferViewData(bufferView: IBufferView, buffers: ArrayBuffer[]): ArrayBuffer;
|
|
30
25
|
/**
|
|
31
26
|
* Get accessor data.
|
|
32
27
|
*/
|
|
33
|
-
static processingSparseData(
|
|
28
|
+
static processingSparseData(context: GLTFParserContext, accessor: IAccessor, bufferInfo: BufferInfo): Promise<void>;
|
|
34
29
|
static getIndexFormat(type: AccessorComponentType): IndexFormat;
|
|
35
30
|
static getElementFormat(type: AccessorComponentType, size: number, normalized?: boolean): VertexElementFormat;
|
|
36
31
|
/**
|
|
@@ -40,9 +35,10 @@ export declare class GLTFUtils {
|
|
|
40
35
|
/**
|
|
41
36
|
* Parse the glb format.
|
|
42
37
|
*/
|
|
43
|
-
static parseGLB(context: GLTFParserContext,
|
|
44
|
-
glTF
|
|
45
|
-
buffers
|
|
38
|
+
static parseGLB(context: GLTFParserContext, originBuffer: ArrayBuffer): {
|
|
39
|
+
glTF?: IGLTF;
|
|
40
|
+
buffers?: ArrayBuffer[];
|
|
41
|
+
originBuffer?: ArrayBuffer;
|
|
46
42
|
};
|
|
47
43
|
static parseSampler(texture: Texture2D, samplerInfo: ISamplerInfo): void;
|
|
48
44
|
static getSamplerInfo(sampler: ISampler): ISamplerInfo;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module "@galacean/engine-core" {
|
|
2
|
+
interface EngineConfiguration {
|
|
3
|
+
/** glTF loader options. */
|
|
4
|
+
glTF?: {
|
|
5
|
+
/** Meshopt options. If set this option and workCount is great than 0, workers will be created. */
|
|
6
|
+
meshOpt?: {
|
|
7
|
+
/** Worker count for transcoder, default is 4. */
|
|
8
|
+
workerCount: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -19,7 +19,7 @@ export declare abstract class GLTFExtensionParser {
|
|
|
19
19
|
* @param extensionOwnerSchema - The extension owner schema
|
|
20
20
|
* @returns The resource or promise
|
|
21
21
|
*/
|
|
22
|
-
createAndParse(context: GLTFParserContext, extensionSchema: GLTFExtensionSchema, extensionOwnerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | Promise<EngineObject>;
|
|
22
|
+
createAndParse(context: GLTFParserContext, extensionSchema: GLTFExtensionSchema, extensionOwnerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | Promise<EngineObject | Uint8Array>;
|
|
23
23
|
/**
|
|
24
24
|
* Additive parse to the resource.
|
|
25
25
|
* @param context - The parser context
|
|
@@ -18,15 +18,6 @@ export interface IKHRLightsPunctual_Light {
|
|
|
18
18
|
export interface IKHRLightsPunctual {
|
|
19
19
|
lights: IKHRLightsPunctual_Light[];
|
|
20
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
21
|
/**
|
|
31
22
|
* Interfaces from the KHR_materials_clearcoat extension
|
|
32
23
|
*/
|
|
@@ -105,6 +96,14 @@ export interface IKHRMaterialVariants_Variant {
|
|
|
105
96
|
extensions?: any;
|
|
106
97
|
extras?: any;
|
|
107
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Interfaces from the KHR_materials_clearcoat extension
|
|
101
|
+
*/
|
|
102
|
+
export interface IKHRMaterialsAnisotropy {
|
|
103
|
+
anisotropyStrength: number;
|
|
104
|
+
anisotropyRotation: number;
|
|
105
|
+
anisotropyTexture: ITextureInfo;
|
|
106
|
+
}
|
|
108
107
|
export interface IKHRMaterialVariants_Variants {
|
|
109
108
|
variants: Array<IKHRMaterialVariants_Variant>;
|
|
110
109
|
}
|
|
@@ -134,6 +133,15 @@ export interface IKHRXmp {
|
|
|
134
133
|
export interface IKHRXmp_Node {
|
|
135
134
|
packet: number;
|
|
136
135
|
}
|
|
136
|
+
export interface IEXTMeshoptCompressionSchema {
|
|
137
|
+
buffer: number;
|
|
138
|
+
byteOffset?: number;
|
|
139
|
+
byteLength: number;
|
|
140
|
+
byteStride: number;
|
|
141
|
+
mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
|
|
142
|
+
count: number;
|
|
143
|
+
filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
|
|
144
|
+
}
|
|
137
145
|
export interface IGalaceanMaterialRemap {
|
|
138
146
|
refId: string;
|
|
139
147
|
key?: string;
|
|
@@ -146,4 +154,4 @@ export interface IGalaceanAnimation {
|
|
|
146
154
|
parameter: any;
|
|
147
155
|
}[];
|
|
148
156
|
}
|
|
149
|
-
export type GLTFExtensionSchema = IKHRLightsPunctual_Light |
|
|
157
|
+
export type GLTFExtensionSchema = IKHRLightsPunctual_Light | IKHRMaterialsClearcoat | IKHRMaterialsIor | IKHRMaterialsUnlit | IKHRMaterialsPbrSpecularGlossiness | IKHRMaterialsSheen | IKHRMaterialsSpecular | IKHRMaterialsTransmission | IKHRMaterialsTranslucency | IKHRMaterialVariants_Mapping | IKHRMaterialVariants_Variants | IKHRMaterialsAnisotropy | IKHRTextureBasisU | IKHRTextureTransform | IKHRXmp | IKHRXmp_Node | IGalaceanAnimation | Object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./KHR_draco_mesh_compression";
|
|
2
1
|
import "./KHR_lights_punctual";
|
|
3
2
|
import "./KHR_materials_clearcoat";
|
|
4
3
|
import "./KHR_materials_ior";
|
|
@@ -14,5 +13,7 @@ import "./KHR_texture_transform";
|
|
|
14
13
|
import "./KHR_materials_ior";
|
|
15
14
|
import "./GALACEAN_materials_remap";
|
|
16
15
|
import "./GALACEAN_animation_event";
|
|
16
|
+
import "./EXT_meshopt_compression";
|
|
17
|
+
import "./KHR_materials_anisotropy";
|
|
17
18
|
export { GLTFExtensionParser, GLTFExtensionMode } from "./GLTFExtensionParser";
|
|
18
19
|
export * from "./GLTFExtensionSchema";
|
package/types/gltf/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { GLTFResource } from "./GLTFResource";
|
|
|
2
2
|
export { GLTFUtils } from "./GLTFUtils";
|
|
3
3
|
export * from "./parser";
|
|
4
4
|
export * from "./extensions/index";
|
|
5
|
-
export
|
|
5
|
+
export { AccessorType } from "./GLTFSchema";
|
|
6
|
+
export type { IMaterial, IMeshPrimitive, ITextureInfo, INode, GLTFExtensionOwnerSchema, IGLTF, IMesh } from "./GLTFSchema";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IGLTF } from "../GLTFSchema";
|
|
2
|
+
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
|
+
export declare class GLTFJSONParser extends GLTFParser {
|
|
5
|
+
parse(context: GLTFParserContext): Promise<IGLTF>;
|
|
6
|
+
private _isGLB;
|
|
7
|
+
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { ModelMesh
|
|
1
|
+
import { ModelMesh } from "@galacean/engine-core";
|
|
2
2
|
import { ModelMeshRestoreInfo } from "../../GLTFContentRestorer";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IGLTF, IMesh, IMeshPrimitive } from "../GLTFSchema";
|
|
4
4
|
import { GLTFParser } from "./GLTFParser";
|
|
5
|
-
import {
|
|
5
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
6
6
|
export declare class GLTFMeshParser extends GLTFParser {
|
|
7
7
|
private static _tempVector3;
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
static _parseMeshFromGLTFPrimitive(context: GLTFParserContext, mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, gltfMesh: IMesh, gltfPrimitive: IMeshPrimitive, gltf: IGLTF,
|
|
11
|
+
static _parseMeshFromGLTFPrimitive(context: GLTFParserContext, mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, gltfMesh: IMesh, gltfPrimitive: IMeshPrimitive, gltf: IGLTF, keepMeshData: boolean): Promise<ModelMesh>;
|
|
12
|
+
private static _getBlendShapeData;
|
|
12
13
|
/**
|
|
13
14
|
* @internal
|
|
14
15
|
*/
|
|
15
|
-
static _createBlendShape(mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, glTFMesh: IMesh,
|
|
16
|
+
static _createBlendShape(context: GLTFParserContext, mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, glTFMesh: IMesh, gltfPrimitive: IMeshPrimitive, glTFTargets: {
|
|
16
17
|
[name: string]: number;
|
|
17
|
-
}[]
|
|
18
|
+
}[]): Promise<void>;
|
|
18
19
|
parse(context: GLTFParserContext, index: number): Promise<ModelMesh[]>;
|
|
19
20
|
}
|
|
@@ -17,7 +17,7 @@ export declare abstract class GLTFParser {
|
|
|
17
17
|
*/
|
|
18
18
|
static executeExtensionsCreateAndParse(extensions: {
|
|
19
19
|
[key: string]: any;
|
|
20
|
-
}, context: GLTFParserContext, ownerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | void | Promise<EngineObject | void>;
|
|
20
|
+
}, context: GLTFParserContext, ownerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | void | Promise<EngineObject | Uint8Array | void>;
|
|
21
21
|
/**
|
|
22
22
|
* Execute all parses of extension to parse resource.
|
|
23
23
|
* @param extensions - Related extensions field
|
|
@@ -18,6 +18,11 @@ export declare class GLTFParserContext {
|
|
|
18
18
|
contentRestorer: GLTFContentRestorer;
|
|
19
19
|
buffers?: ArrayBuffer[];
|
|
20
20
|
private _resourceCache;
|
|
21
|
+
private _progress;
|
|
22
|
+
/** @internal */
|
|
23
|
+
_setTaskCompleteProgress: (loaded: number, total: number) => void;
|
|
24
|
+
/** @internal */
|
|
25
|
+
_setTaskDetailProgress: (url: string, loaded: number, total: number) => void;
|
|
21
26
|
constructor(glTFResource: GLTFResource, resourceManager: ResourceManager, params: GLTFParams);
|
|
22
27
|
get<T>(type: GLTFParserType.Entity, index: number): Entity;
|
|
23
28
|
get<T>(type: GLTFParserType.Entity): Entity[];
|
|
@@ -26,6 +31,14 @@ export declare class GLTFParserContext {
|
|
|
26
31
|
get<T>(type: GLTFParserType, index: number): Promise<T>;
|
|
27
32
|
get<T>(type: GLTFParserType): Promise<T[]>;
|
|
28
33
|
parse(): Promise<GLTFResource>;
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
_onTaskDetail: (url: string, loaded: number, total: number) => void;
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
_addTaskCompletePromise(taskPromise: Promise<any>): void;
|
|
29
42
|
private _createAnimator;
|
|
30
43
|
private _handleSubAsset;
|
|
31
44
|
}
|
|
@@ -46,11 +59,12 @@ export declare enum GLTFParserType {
|
|
|
46
59
|
Validator = 1,
|
|
47
60
|
Scene = 2,
|
|
48
61
|
Buffer = 3,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
BufferView = 4,
|
|
63
|
+
Texture = 5,
|
|
64
|
+
Material = 6,
|
|
65
|
+
Mesh = 7,
|
|
66
|
+
Entity = 8,
|
|
67
|
+
Skin = 9,
|
|
68
|
+
Animation = 10
|
|
55
69
|
}
|
|
56
70
|
export declare function registerGLTFParser(pipeline: GLTFParserType): (Parser: new () => GLTFParser) => void;
|
|
@@ -9,4 +9,5 @@ export { GLTFSceneParser } from "./GLTFSceneParser";
|
|
|
9
9
|
export { GLTFSkinParser } from "./GLTFSkinParser";
|
|
10
10
|
export { GLTFTextureParser } from "./GLTFTextureParser";
|
|
11
11
|
export { GLTFValidator } from "./GLTFValidator";
|
|
12
|
-
export { GLTFParserContext, GLTFParserType, registerGLTFParser } from "./GLTFParserContext";
|
|
12
|
+
export { GLTFParserContext, GLTFParserType, registerGLTFParser, BufferInfo } from "./GLTFParserContext";
|
|
13
|
+
export { GLTFBufferViewParser } from "./GLTFBufferViewParser";
|
package/types/index.d.ts
CHANGED
|
@@ -10,13 +10,17 @@ import "./KTXCubeLoader";
|
|
|
10
10
|
import "./KTXLoader";
|
|
11
11
|
import "./MaterialLoader";
|
|
12
12
|
import "./MeshLoader";
|
|
13
|
+
import "./PrimitiveMeshLoader";
|
|
14
|
+
import "./ProjectLoader";
|
|
13
15
|
import "./SourceFontLoader";
|
|
14
16
|
import "./SpriteAtlasLoader";
|
|
15
17
|
import "./SpriteLoader";
|
|
16
18
|
import "./Texture2DLoader";
|
|
17
19
|
import "./TextureCubeLoader";
|
|
18
|
-
import "./ProjectLoader";
|
|
19
20
|
import "./ktx2/KTX2Loader";
|
|
21
|
+
import "./ShaderLoader";
|
|
22
|
+
import "./ShaderChunkLoader";
|
|
23
|
+
export { GLTFLoader } from "./GLTFLoader";
|
|
20
24
|
export type { GLTFParams } from "./GLTFLoader";
|
|
21
25
|
export * from "./SceneLoader";
|
|
22
26
|
export type { Texture2DParams } from "./Texture2DLoader";
|
|
@@ -8,9 +8,10 @@ export declare class KTX2Loader extends Loader<Texture2D | TextureCube> {
|
|
|
8
8
|
private static _priorityFormats;
|
|
9
9
|
private static _supportedMap;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Release ktx2 transcoder worker.
|
|
12
|
+
* @remarks If use loader after releasing, we should release again.
|
|
12
13
|
*/
|
|
13
|
-
static
|
|
14
|
+
static release(): void;
|
|
14
15
|
/** @internal */
|
|
15
16
|
static _parseBuffer(buffer: Uint8Array, engine: Engine, params?: KTX2Params): Promise<{
|
|
16
17
|
engine: Engine;
|
|
@@ -50,7 +51,7 @@ export declare enum KTX2Transcoder {
|
|
|
50
51
|
}
|
|
51
52
|
declare module "@galacean/engine-core" {
|
|
52
53
|
interface EngineConfiguration {
|
|
53
|
-
/** KTX2 loader options. */
|
|
54
|
+
/** KTX2 loader options. If set this option and workCount is great than 0, workers will be created. */
|
|
54
55
|
ktx2Loader?: {
|
|
55
56
|
/** Worker count for transcoder, default is 4. */
|
|
56
57
|
workerCount?: number;
|
|
@@ -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>;
|