@galacean/engine-loader 1.0.0 → 1.0.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.
- package/dist/main.js +1764 -1208
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +1784 -1228
- package/dist/module.js +1751 -1210
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/AnimationClipLoader.d.ts +1 -0
- package/types/GLTFContentRestorer.d.ts +92 -0
- package/types/GLTFLoader.d.ts +3 -0
- package/types/ProjectLoader.d.ts +1 -0
- package/types/Texture2DContentRestorer.d.ts +11 -0
- package/types/TextureCubeContentRestorer.d.ts +11 -0
- package/types/gltf/GLTFPipeline.d.ts +23 -0
- package/types/gltf/GLTFResource.d.ts +7 -15
- package/types/gltf/GLTFSchema.d.ts +816 -0
- package/types/gltf/GLTFUtil.d.ts +4 -4
- package/types/gltf/GLTFUtils.d.ts +48 -0
- package/types/gltf/extensions/GALACEAN_animation_event.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_materials_ior.d.ts +1 -0
- package/types/gltf/extensions/KHR_materials_variants.d.ts +6 -1
- package/types/gltf/extensions/index.d.ts +5 -1
- package/types/gltf/index.d.ts +6 -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 +53 -0
- package/types/gltf/parser/GLTFSceneParser.d.ts +11 -0
- package/types/gltf/parser/GLTFSchemaParser.d.ts +7 -0
- package/types/gltf/parser/GLTFSkinParser.d.ts +7 -0
- package/types/gltf/parser/GLTFTextureParser.d.ts +9 -0
- package/types/gltf/parser/GLTFValidator.d.ts +6 -0
- package/types/gltf/parser/index.d.ts +11 -0
- package/types/index.d.ts +2 -2
- package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +13 -0
- package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +33 -0
- package/types/ktx2/KTX2Container.d.ts +72 -0
- package/types/ktx2/KTX2Loader.d.ts +53 -0
- package/types/ktx2/KTX2TargetFormat.d.ts +21 -0
- package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +17 -0
- package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +34 -0
- package/types/ktx2/TranscodeResult.d.ts +10 -0
- package/types/ktx2/WorkerPool.d.ts +32 -0
- package/types/ktx2/constants.d.ts +7 -0
- package/types/ktx2/transcoder/AbstractTranscoder.d.ts +55 -0
- package/types/ktx2/transcoder/BinomialLLCTranscoder.d.ts +8 -0
- package/types/ktx2/transcoder/BinomialLLCWorkerCode.d.ts +2 -0
- package/types/ktx2/transcoder/KhronosTranscoder.d.ts +13 -0
- package/types/ktx2/transcoder/KhronosWorkerCode.d.ts +1 -0
- package/types/ktx2/zstddec.d.ts +62 -0
- package/types/resource-deserialize/index.d.ts +3 -3
- package/types/resource-deserialize/resources/mesh/MeshDecoder.d.ts +1 -1
- package/types/resource-deserialize/resources/parser/PrefabParser.d.ts +5 -0
- package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +14 -0
- package/types/resource-deserialize/resources/scene/SceneParser.d.ts +1 -1
- package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +61 -0
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +91 -0
- package/types/resource-deserialize/resources/schema/ProjectSchema.d.ts +9 -0
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +41 -0
- package/types/resource-deserialize/resources/schema/index.d.ts +3 -0
package/types/gltf/GLTFUtil.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IndexFormat, TypedArray, VertexElementFormat } from "@galacean/engine-core";
|
|
2
2
|
import { Color, Vector2, Vector3, Vector4 } from "@galacean/engine-math";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF } from "./GLTFSchema";
|
|
4
|
+
import { BufferInfo, GLTFParserContext } from "./parser/GLTFParserContext";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -21,9 +21,9 @@ export declare class GLTFUtil {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get the TypedArray corresponding to the component type.
|
|
23
23
|
*/
|
|
24
|
-
static getComponentType(componentType: AccessorComponentType):
|
|
24
|
+
static getComponentType(componentType: AccessorComponentType): Int8ArrayConstructor | Uint8ArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor;
|
|
25
25
|
static getNormalizedComponentScale(componentType: AccessorComponentType): number;
|
|
26
|
-
static getAccessorBuffer(context:
|
|
26
|
+
static getAccessorBuffer(context: GLTFParserContext, gltf: IGLTF, accessor: IAccessor): BufferInfo;
|
|
27
27
|
/**
|
|
28
28
|
* @deprecated
|
|
29
29
|
* Get accessor data.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { IndexFormat, TypedArray, VertexElementFormat } from "@galacean/engine-core";
|
|
2
|
+
import { Color, Vector2, Vector3, Vector4 } from "@galacean/engine-math";
|
|
3
|
+
import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF } from "./GLTFSchema";
|
|
4
|
+
import { BufferInfo, GLTFParserContext } from "./parser/GLTFParserContext";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class GLTFUtils {
|
|
9
|
+
static floatBufferToVector2Array(buffer: Float32Array): Vector2[];
|
|
10
|
+
static floatBufferToVector3Array(buffer: Float32Array): Vector3[];
|
|
11
|
+
static floatBufferToVector4Array(buffer: Float32Array): Vector4[];
|
|
12
|
+
static floatBufferToColorArray(buffer: Float32Array, isColor3: boolean): Color[];
|
|
13
|
+
/**
|
|
14
|
+
* Get the number of bytes occupied by accessor type.
|
|
15
|
+
*/
|
|
16
|
+
static getAccessorTypeSize(accessorType: AccessorType): number;
|
|
17
|
+
/**
|
|
18
|
+
* Get the TypedArray corresponding to the component type.
|
|
19
|
+
*/
|
|
20
|
+
static getComponentType(componentType: AccessorComponentType): Float32ArrayConstructor | Uint32ArrayConstructor | Uint8ArrayConstructor | Uint16ArrayConstructor | Int8ArrayConstructor | Int16ArrayConstructor;
|
|
21
|
+
static getNormalizedComponentScale(componentType: AccessorComponentType): number;
|
|
22
|
+
static getAccessorBuffer(context: GLTFParserContext, bufferViews: IBufferView[], accessor: IAccessor): Promise<BufferInfo>;
|
|
23
|
+
static bufferToVector3Array(data: TypedArray, byteStride: number, accessorByteOffset: number, count: number): Vector3[];
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated
|
|
26
|
+
* Get accessor data.
|
|
27
|
+
*/
|
|
28
|
+
static getAccessorData(glTF: IGLTF, accessor: IAccessor, buffers: ArrayBuffer[]): TypedArray;
|
|
29
|
+
static getBufferViewData(bufferView: IBufferView, buffers: ArrayBuffer[]): ArrayBuffer;
|
|
30
|
+
/**
|
|
31
|
+
* Get accessor data.
|
|
32
|
+
*/
|
|
33
|
+
static processingSparseData(bufferViews: IBufferView[], accessor: IAccessor, buffers: ArrayBuffer[], bufferInfo: BufferInfo): void;
|
|
34
|
+
static getIndexFormat(type: AccessorComponentType): IndexFormat;
|
|
35
|
+
static getElementFormat(type: AccessorComponentType, size: number, normalized?: boolean): VertexElementFormat;
|
|
36
|
+
/**
|
|
37
|
+
* Load image buffer
|
|
38
|
+
*/
|
|
39
|
+
static loadImageBuffer(imageBuffer: ArrayBuffer, type: string): Promise<HTMLImageElement>;
|
|
40
|
+
/**
|
|
41
|
+
* Parse the glb format.
|
|
42
|
+
*/
|
|
43
|
+
static parseGLB(context: GLTFParserContext, glb: ArrayBuffer): {
|
|
44
|
+
glTF: IGLTF;
|
|
45
|
+
buffers: ArrayBuffer[];
|
|
46
|
+
};
|
|
47
|
+
private static _formatRelativePath;
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { EngineObject } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFExtensionOwnerSchema } from "../GLTFSchema";
|
|
3
|
+
import { GLTFParserContext } from "../parser/GLTFParserContext";
|
|
4
|
+
import { GLTFExtensionSchema } from "./GLTFExtensionSchema";
|
|
5
|
+
/**
|
|
6
|
+
* Base class of glTF extension parser.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class GLTFExtensionParser {
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* The extension mode.
|
|
12
|
+
*/
|
|
13
|
+
_mode: GLTFExtensionMode;
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the parser.
|
|
16
|
+
* @remarks Some plugins require initialization.
|
|
17
|
+
* @returns The void or promise
|
|
18
|
+
*/
|
|
19
|
+
initialize(): void | Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Create and parse the resource.
|
|
22
|
+
* @remarks This method overrides the default resource creation.
|
|
23
|
+
* @param context - The parser context
|
|
24
|
+
* @param extensionSchema - The extension schema
|
|
25
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
26
|
+
* @returns The resource or promise
|
|
27
|
+
*/
|
|
28
|
+
createAndParse(context: GLTFParserContext, extensionSchema: GLTFExtensionSchema, extensionOwnerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | Promise<EngineObject>;
|
|
29
|
+
/**
|
|
30
|
+
* Additive parse to the resource.
|
|
31
|
+
* @param context - The parser context
|
|
32
|
+
* @param parseResource - The parsed resource
|
|
33
|
+
* @param extensionSchema - The extension schema
|
|
34
|
+
* @param extensionOwnerSchema - The extension owner schema
|
|
35
|
+
* @returns The void or promise
|
|
36
|
+
*/
|
|
37
|
+
additiveParse(context: GLTFParserContext, parseResource: EngineObject, extensionSchema: GLTFExtensionSchema, extensionOwnerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): void | Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* glTF Extension mode.
|
|
41
|
+
*/
|
|
42
|
+
export declare enum GLTFExtensionMode {
|
|
43
|
+
/**
|
|
44
|
+
* Cerate instance and parse mode.
|
|
45
|
+
* @remarks
|
|
46
|
+
* If the glTF property has multiple extensions of `CreateAndParse` mode, only execute the last one.
|
|
47
|
+
* If this method is registered, the default pipeline processing will be ignored.
|
|
48
|
+
*/
|
|
49
|
+
CreateAndParse = 0,
|
|
50
|
+
/** Additive parse mode. */
|
|
51
|
+
AdditiveParse = 1
|
|
52
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { IMaterialNormalTextureInfo, ITextureInfo } from "../GLTFSchema";
|
|
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 interface IGalaceanAnimation {
|
|
143
|
+
events: {
|
|
144
|
+
time: number;
|
|
145
|
+
functionName: string;
|
|
146
|
+
parameter: any;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
export type GLTFExtensionSchema = IKHRLightsPunctual_Light | IKHRDracoMeshCompression | IKHRMaterialsClearcoat | IKHRMaterialsIor | IKHRMaterialsUnlit | IKHRMaterialsPbrSpecularGlossiness | IKHRMaterialsSheen | IKHRMaterialsSpecular | IKHRMaterialsTransmission | IKHRMaterialsTranslucency | IKHRMaterialVariants_Mapping | IKHRMaterialVariants_Variants | IKHRTextureBasisU | IKHRTextureTransform | IKHRXmp | IKHRXmp_Node | IGalaceanAnimation | Object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,9 +6,13 @@ import "./KHR_materials_pbrSpecularGlossiness";
|
|
|
6
6
|
import "./KHR_materials_sheen";
|
|
7
7
|
import "./KHR_materials_transmission";
|
|
8
8
|
import "./KHR_materials_unlit";
|
|
9
|
-
|
|
9
|
+
export type { IGLTFExtensionVariants } from "./KHR_materials_variants";
|
|
10
10
|
import "./KHR_materials_volume";
|
|
11
11
|
import "./KHR_mesh_quantization";
|
|
12
12
|
import "./KHR_texture_basisu";
|
|
13
13
|
import "./KHR_texture_transform";
|
|
14
|
+
import "./KHR_materials_ior";
|
|
14
15
|
import "./GALACEAN_materials_remap";
|
|
16
|
+
import "./GALACEAN_animation_event";
|
|
17
|
+
export { GLTFExtensionParser, GLTFExtensionMode } from "./GLTFExtensionParser";
|
|
18
|
+
export * from "./GLTFExtensionSchema";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { GLTFPipeline } from "./GLTFPipeline";
|
|
2
|
+
export { GLTFResource } from "./GLTFResource";
|
|
3
|
+
export { GLTFUtils } from "./GLTFUtils";
|
|
4
|
+
export * from "./parser";
|
|
5
|
+
export * from "./extensions/index";
|
|
6
|
+
export type { IMaterial, IMeshPrimitive, ITextureInfo, INode, GLTFExtensionOwnerSchema } from "./GLTFSchema";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnimationClip, AssetPromise } from "@galacean/engine-core";
|
|
2
|
+
import { IAnimation } from "../GLTFSchema";
|
|
3
|
+
import { GLTFParser } from "./GLTFParser";
|
|
4
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
5
|
+
export declare class GLTFAnimationParser extends GLTFParser {
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
static _parseStandardProperty(context: GLTFParserContext, animationClip: AnimationClip, animationInfo: IAnimation): Promise<void>;
|
|
10
|
+
private static _addCurve;
|
|
11
|
+
parse(context: GLTFParserContext): AssetPromise<AnimationClip[]> | void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssetPromise } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
|
+
export declare class GLTFBufferParser extends GLTFParser {
|
|
5
|
+
parse(context: GLTFParserContext): AssetPromise<void>;
|
|
6
|
+
private _isGLB;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GLTFParser } from "./GLTFParser";
|
|
2
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
3
|
+
export declare class GLTFEntityParser extends GLTFParser {
|
|
4
|
+
/** @internal */
|
|
5
|
+
static _defaultName: String;
|
|
6
|
+
parse(context: GLTFParserContext): void;
|
|
7
|
+
private _buildEntityTree;
|
|
8
|
+
private _createSceneRoots;
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AssetPromise, Material, PBRMaterial, PBRSpecularMaterial, UnlitMaterial } from "@galacean/engine-core";
|
|
2
|
+
import { IMaterial, ITextureInfo } from "../GLTFSchema";
|
|
3
|
+
import { GLTFParser } from "./GLTFParser";
|
|
4
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
5
|
+
export declare class GLTFMaterialParser extends GLTFParser {
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
static _checkOtherTextureTransform(texture: ITextureInfo, textureName: string): void;
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
static _parseStandardProperty(context: GLTFParserContext, material: UnlitMaterial | PBRMaterial | PBRSpecularMaterial, materialInfo: IMaterial): void;
|
|
14
|
+
parse(context: GLTFParserContext): AssetPromise<Material[]>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AssetPromise, ModelMesh, TypedArray } from "@galacean/engine-core";
|
|
2
|
+
import { ModelMeshRestoreInfo } from "../../GLTFContentRestorer";
|
|
3
|
+
import type { IAccessor, IGLTF, IMesh, IMeshPrimitive } from "../GLTFSchema";
|
|
4
|
+
import { GLTFParser } from "./GLTFParser";
|
|
5
|
+
import { BufferInfo, GLTFParserContext } from "./GLTFParserContext";
|
|
6
|
+
export declare class GLTFMeshParser extends GLTFParser {
|
|
7
|
+
private static _tempVector3;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
static _parseMeshFromGLTFPrimitive(context: GLTFParserContext, mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, gltfMesh: IMesh, gltfPrimitive: IMeshPrimitive, gltf: IGLTF, getVertexBufferData: (semantic: string) => TypedArray, getBlendShapeData: (semantic: string, shapeIndex: number) => Promise<BufferInfo>, getIndexBufferData: () => Promise<TypedArray>, keepMeshData: boolean): Promise<ModelMesh>;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
static _createBlendShape(mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, glTFMesh: IMesh, accessors: IAccessor[], glTFTargets: {
|
|
16
|
+
[name: string]: number;
|
|
17
|
+
}[], getBlendShapeData: (semantic: string, shapeIndex: number) => Promise<BufferInfo>): Promise<void[]>;
|
|
18
|
+
parse(context: GLTFParserContext): AssetPromise<ModelMesh[][]> | void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AnimationClip, AssetPromise, EngineObject, Material, Mesh } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFExtensionMode, GLTFExtensionParser } from "../extensions/GLTFExtensionParser";
|
|
3
|
+
import type { GLTFExtensionOwnerSchema } from "../GLTFSchema";
|
|
4
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
5
|
+
/**
|
|
6
|
+
* Base class of glTF parser.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class GLTFParser {
|
|
9
|
+
private static readonly _extensionParsers;
|
|
10
|
+
/**
|
|
11
|
+
* Execute all parses of extension to initialize plugin.
|
|
12
|
+
* @remarks Some plugins require initialization.
|
|
13
|
+
* @returns The void or promise
|
|
14
|
+
*/
|
|
15
|
+
static executeExtensionsInitialize(extensionName: string): void | Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Execute all parses of extension to create resource.
|
|
18
|
+
* @param extensions - Related extensions field
|
|
19
|
+
* @param context - The parser context
|
|
20
|
+
* @param ownerSchema - The extension owner schema
|
|
21
|
+
* @param extra - Extra params
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
static executeExtensionsCreateAndParse(extensions: {
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}, context: GLTFParserContext, ownerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): EngineObject | void | Promise<EngineObject | void>;
|
|
27
|
+
/**
|
|
28
|
+
* Execute all parses of extension to parse resource.
|
|
29
|
+
* @param extensions - Related extensions field
|
|
30
|
+
* @param context - The parser context
|
|
31
|
+
* @param parseResource - The parsed resource
|
|
32
|
+
* @param ownerSchema - The extension owner schema
|
|
33
|
+
* @param extra - Extra params
|
|
34
|
+
*/
|
|
35
|
+
static executeExtensionsAdditiveAndParse(extensions: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}, context: GLTFParserContext, parseResource: EngineObject, ownerSchema: GLTFExtensionOwnerSchema, ...extra: any[]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the plugin is registered.
|
|
40
|
+
* @param extensionName - Extension name
|
|
41
|
+
* @returns Boolean
|
|
42
|
+
*/
|
|
43
|
+
static hasExtensionParser(extensionName: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the last plugin by glTF extension mode.
|
|
46
|
+
* @param extensionName - Extension name
|
|
47
|
+
* @param mode - GLTF extension mode
|
|
48
|
+
* @returns GLTF extension parser
|
|
49
|
+
*/
|
|
50
|
+
static getExtensionParser(extensionName: string, mode: GLTFExtensionMode): GLTFExtensionParser | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
static _addExtensionParser(extensionName: string, extensionParser: GLTFExtensionParser): void;
|
|
55
|
+
private static _createAndParse;
|
|
56
|
+
private static _additiveParse;
|
|
57
|
+
abstract parse(context: GLTFParserContext): AssetPromise<any> | void | Material | AnimationClip | Mesh;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Declare ExtensionParser's decorator.
|
|
61
|
+
* @param extensionName - Extension name
|
|
62
|
+
*/
|
|
63
|
+
export declare function registerGLTFExtension(extensionName: string, mode: GLTFExtensionMode): (parser: new () => GLTFExtensionParser) => void;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AnimationClip, AssetPromise, Buffer, Entity, Material, ModelMesh, Texture2D, TypedArray } from "@galacean/engine-core";
|
|
2
|
+
import { BufferDataRestoreInfo, GLTFContentRestorer } from "../../GLTFContentRestorer";
|
|
3
|
+
import { GLTFResource } from "../GLTFResource";
|
|
4
|
+
import type { IGLTF } from "../GLTFSchema";
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class GLTFParserContext {
|
|
9
|
+
glTF: IGLTF;
|
|
10
|
+
glTFResource: GLTFResource;
|
|
11
|
+
keepMeshData: boolean;
|
|
12
|
+
hasSkinned: boolean;
|
|
13
|
+
chainPromises: AssetPromise<any>[];
|
|
14
|
+
accessorBufferCache: Record<string, BufferInfo>;
|
|
15
|
+
texturesPromiseInfo: PromiseInfo<Texture2D[]>;
|
|
16
|
+
materialsPromiseInfo: PromiseInfo<Material[]>;
|
|
17
|
+
meshesPromiseInfo: PromiseInfo<ModelMesh[][]>;
|
|
18
|
+
animationClipsPromiseInfo: PromiseInfo<AnimationClip[]>;
|
|
19
|
+
defaultSceneRootPromiseInfo: PromiseInfo<Entity>;
|
|
20
|
+
masterPromiseInfo: PromiseInfo<GLTFResource>;
|
|
21
|
+
promiseMap: Record<string, AssetPromise<any>>;
|
|
22
|
+
contentRestorer: GLTFContentRestorer;
|
|
23
|
+
/** @internal */
|
|
24
|
+
_buffers: ArrayBuffer[] | Promise<ArrayBuffer[]>;
|
|
25
|
+
constructor(url: string);
|
|
26
|
+
/**
|
|
27
|
+
* Get all the buffer data.
|
|
28
|
+
*/
|
|
29
|
+
getBuffers(): Promise<ArrayBuffer[]>;
|
|
30
|
+
private _initPromiseInfo;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare class BufferInfo {
|
|
36
|
+
data: TypedArray;
|
|
37
|
+
interleaved: boolean;
|
|
38
|
+
stride: number;
|
|
39
|
+
vertexBuffer: Buffer;
|
|
40
|
+
vertexBindingInfos: Record<number, number>;
|
|
41
|
+
restoreInfo: BufferDataRestoreInfo;
|
|
42
|
+
constructor(data: TypedArray, interleaved: boolean, stride: number);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
export declare class PromiseInfo<T> {
|
|
48
|
+
promise: AssetPromise<T>;
|
|
49
|
+
resolve: (value?: T | PromiseLike<T>) => void;
|
|
50
|
+
reject: (reason?: any) => void;
|
|
51
|
+
setProgress: (progress: number) => void;
|
|
52
|
+
onCancel: (callback: () => void) => void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AssetPromise, Entity } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
|
+
export declare class GLTFSceneParser extends GLTFParser {
|
|
5
|
+
private static _defaultMaterial;
|
|
6
|
+
private static _getDefaultMaterial;
|
|
7
|
+
parse(context: GLTFParserContext): AssetPromise<Entity> | void;
|
|
8
|
+
private _createCamera;
|
|
9
|
+
private _createRenderer;
|
|
10
|
+
private _createAnimator;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IGLTF } from "../GLTFSchema";
|
|
2
|
+
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
|
+
export declare class GLTFSchemaParser extends GLTFParser {
|
|
5
|
+
parse(context: GLTFParserContext): Promise<IGLTF>;
|
|
6
|
+
private _isGLB;
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AssetPromise } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFParserContext } from ".";
|
|
3
|
+
import { GLTFParser } from "./GLTFParser";
|
|
4
|
+
export declare class GLTFSkinParser extends GLTFParser {
|
|
5
|
+
parse(context: GLTFParserContext): AssetPromise<void>;
|
|
6
|
+
private _findSkeletonRootBone;
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AssetPromise, Texture2D } from "@galacean/engine-core";
|
|
2
|
+
import { GLTFParserContext } from ".";
|
|
3
|
+
import { GLTFParser } from "./GLTFParser";
|
|
4
|
+
export declare class GLTFTextureParser extends GLTFParser {
|
|
5
|
+
private static _wrapMap;
|
|
6
|
+
parse(context: GLTFParserContext): AssetPromise<Texture2D[]> | void;
|
|
7
|
+
private _getSamplerInfo;
|
|
8
|
+
private _parseSampler;
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AssetPromise } from "@galacean/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,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
CHANGED
|
@@ -2,7 +2,6 @@ import "./AnimatorControllerLoader";
|
|
|
2
2
|
import "./BufferLoader";
|
|
3
3
|
import "./EnvLoader";
|
|
4
4
|
import "./FontLoader";
|
|
5
|
-
import "./gltf/extensions/index";
|
|
6
5
|
import "./GLTFLoader";
|
|
7
6
|
import "./HDRLoader";
|
|
8
7
|
import "./JSONLoader";
|
|
@@ -15,9 +14,10 @@ import "./SpriteAtlasLoader";
|
|
|
15
14
|
import "./SpriteLoader";
|
|
16
15
|
import "./Texture2DLoader";
|
|
17
16
|
import "./TextureCubeLoader";
|
|
17
|
+
import "./AnimationClipLoader";
|
|
18
18
|
export { parseSingleKTX } from "./compressed-texture";
|
|
19
|
-
export { GLTFResource } from "./gltf/GLTFResource";
|
|
20
19
|
export type { GLTFParams } from "./GLTFLoader";
|
|
21
20
|
export * from "./resource-deserialize";
|
|
22
21
|
export * from "./SceneLoader";
|
|
23
22
|
export type { Texture2DParams } from "./Texture2DLoader";
|
|
23
|
+
export * from "./gltf";
|
|
@@ -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 {};
|