@galacean/engine-loader 0.9.21 → 0.9.22

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-loader",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -15,10 +15,10 @@
15
15
  "types/**/*"
16
16
  ],
17
17
  "dependencies": {
18
- "@galacean/engine-core": "0.9.21",
19
- "@galacean/engine-draco": "0.9.21",
20
- "@galacean/engine-math": "0.9.21",
21
- "@galacean/engine-rhi-webgl": "0.9.21"
18
+ "@galacean/engine-core": "0.9.22",
19
+ "@galacean/engine-draco": "0.9.22",
20
+ "@galacean/engine-math": "0.9.22",
21
+ "@galacean/engine-rhi-webgl": "0.9.22"
22
22
  },
23
23
  "scripts": {
24
24
  "b:types": "tsc"
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Module for glTF 2.0 Interface
3
3
  */
4
- import type { MeshTopology, TextureFilterMode, TextureWrapMode as EngineTextureWrapMode } from "@galacean/engine-core";
4
+ import { MeshTopology } from "@galacean/engine-core";
5
5
  /**
6
6
  * The datatype of the components in the attribute
7
7
  */
@@ -814,9 +814,3 @@ export interface IGLTF extends IProperty {
814
814
  }
815
815
  /** glTF extensible owner schema. */
816
816
  export type GLTFExtensionOwnerSchema = IMeshPrimitive | IMaterial | ITextureInfo | INode;
817
- export interface ISamplerInfo {
818
- filterMode?: TextureFilterMode;
819
- wrapModeU?: EngineTextureWrapMode;
820
- wrapModeV?: EngineTextureWrapMode;
821
- mipmap?: boolean;
822
- }
@@ -1,6 +1,6 @@
1
- import { IndexFormat, Texture2D, TypedArray, VertexElementFormat } from "@galacean/engine-core";
1
+ import { IndexFormat, TypedArray, VertexElementFormat } from "@galacean/engine-core";
2
2
  import { Color, Vector2, Vector3, Vector4 } from "@galacean/engine-math";
3
- import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF, ISampler, ISamplerInfo } from "./GLTFSchema";
3
+ import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF } from "./GLTFSchema";
4
4
  import { BufferInfo, GLTFParserContext } from "./parser/GLTFParserContext";
5
5
  /**
6
6
  * @internal
@@ -44,6 +44,5 @@ export declare class GLTFUtils {
44
44
  glTF: IGLTF;
45
45
  buffers: ArrayBuffer[];
46
46
  };
47
- static parseSampler(texture: Texture2D, samplerInfo: ISamplerInfo): void;
48
- static getSamplerInfo(sampler: ISampler): ISamplerInfo;
47
+ private static _formatRelativePath;
49
48
  }
@@ -11,6 +11,12 @@ export declare abstract class GLTFExtensionParser {
11
11
  * The extension mode.
12
12
  */
13
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>;
14
20
  /**
15
21
  * Create and parse the resource.
16
22
  * @remarks This method overrides the default resource creation.
@@ -1,3 +1,4 @@
1
+ export { GLTFPipeline } from "./GLTFPipeline";
1
2
  export { GLTFResource } from "./GLTFResource";
2
3
  export { GLTFUtils } from "./GLTFUtils";
3
4
  export * from "./parser";
@@ -1,4 +1,4 @@
1
- import { AnimationClip } from "@galacean/engine-core";
1
+ import { AnimationClip, AssetPromise } from "@galacean/engine-core";
2
2
  import { IAnimation } from "../GLTFSchema";
3
3
  import { GLTFParser } from "./GLTFParser";
4
4
  import { GLTFParserContext } from "./GLTFParserContext";
@@ -6,7 +6,7 @@ export declare class GLTFAnimationParser extends GLTFParser {
6
6
  /**
7
7
  * @internal
8
8
  */
9
- static _parseStandardProperty(context: GLTFParserContext, animationClip: AnimationClip, animationInfo: IAnimation): Promise<AnimationClip>;
9
+ static _parseStandardProperty(context: GLTFParserContext, animationClip: AnimationClip, animationInfo: IAnimation): Promise<void>;
10
10
  private static _addCurve;
11
- parse(context: GLTFParserContext, index: number): Promise<AnimationClip>;
11
+ parse(context: GLTFParserContext): AssetPromise<AnimationClip[]> | void;
12
12
  }
@@ -1,6 +1,7 @@
1
+ import { AssetPromise } from "@galacean/engine-core";
1
2
  import { GLTFParser } from "./GLTFParser";
2
3
  import { GLTFParserContext } from "./GLTFParserContext";
3
4
  export declare class GLTFBufferParser extends GLTFParser {
4
- parse(context: GLTFParserContext, index: number): Promise<ArrayBuffer>;
5
- private _parseSingleBuffer;
5
+ parse(context: GLTFParserContext): AssetPromise<void>;
6
+ private _isGLB;
6
7
  }
@@ -1,6 +1,9 @@
1
- import { Entity } from "@galacean/engine-core";
2
1
  import { GLTFParser } from "./GLTFParser";
3
2
  import { GLTFParserContext } from "./GLTFParserContext";
4
3
  export declare class GLTFEntityParser extends GLTFParser {
5
- parse(context: GLTFParserContext, index: number): Entity;
4
+ /** @internal */
5
+ static _defaultName: String;
6
+ parse(context: GLTFParserContext): void;
7
+ private _buildEntityTree;
8
+ private _createSceneRoots;
6
9
  }
@@ -1,11 +1,8 @@
1
- import { BlinnPhongMaterial, Engine, Material, PBRMaterial, PBRSpecularMaterial, UnlitMaterial } from "@galacean/engine-core";
1
+ import { AssetPromise, Material, PBRMaterial, PBRSpecularMaterial, UnlitMaterial } from "@galacean/engine-core";
2
2
  import { IMaterial, ITextureInfo } from "../GLTFSchema";
3
3
  import { GLTFParser } from "./GLTFParser";
4
4
  import { GLTFParserContext } from "./GLTFParserContext";
5
5
  export declare class GLTFMaterialParser extends GLTFParser {
6
- /** @internal */
7
- static _getDefaultMaterial(engine: Engine): BlinnPhongMaterial;
8
- private static _defaultMaterial;
9
6
  /**
10
7
  * @internal
11
8
  */
@@ -14,5 +11,5 @@ export declare class GLTFMaterialParser extends GLTFParser {
14
11
  * @internal
15
12
  */
16
13
  static _parseStandardProperty(context: GLTFParserContext, material: UnlitMaterial | PBRMaterial | PBRSpecularMaterial, materialInfo: IMaterial): void;
17
- parse(context: GLTFParserContext, index: number): Promise<Material>;
14
+ parse(context: GLTFParserContext): AssetPromise<Material[]>;
18
15
  }
@@ -1,4 +1,4 @@
1
- import { ModelMesh, TypedArray } from "@galacean/engine-core";
1
+ import { AssetPromise, ModelMesh, TypedArray } from "@galacean/engine-core";
2
2
  import { ModelMeshRestoreInfo } from "../../GLTFContentRestorer";
3
3
  import type { IAccessor, IGLTF, IMesh, IMeshPrimitive } from "../GLTFSchema";
4
4
  import { GLTFParser } from "./GLTFParser";
@@ -15,5 +15,5 @@ export declare class GLTFMeshParser extends GLTFParser {
15
15
  static _createBlendShape(mesh: ModelMesh, meshRestoreInfo: ModelMeshRestoreInfo, glTFMesh: IMesh, accessors: IAccessor[], glTFTargets: {
16
16
  [name: string]: number;
17
17
  }[], getBlendShapeData: (semantic: string, shapeIndex: number) => Promise<BufferInfo>): Promise<void[]>;
18
- parse(context: GLTFParserContext, index: number): Promise<ModelMesh[]>;
18
+ parse(context: GLTFParserContext): AssetPromise<ModelMesh[][]> | void;
19
19
  }
@@ -1,12 +1,18 @@
1
- import { EngineObject } from "@galacean/engine-core";
2
- import type { GLTFExtensionOwnerSchema } from "../GLTFSchema";
1
+ import { AnimationClip, AssetPromise, EngineObject, Material, Mesh } from "@galacean/engine-core";
3
2
  import { GLTFExtensionMode, GLTFExtensionParser } from "../extensions/GLTFExtensionParser";
3
+ import type { GLTFExtensionOwnerSchema } from "../GLTFSchema";
4
4
  import { GLTFParserContext } from "./GLTFParserContext";
5
5
  /**
6
6
  * Base class of glTF parser.
7
7
  */
8
8
  export declare abstract class GLTFParser {
9
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>;
10
16
  /**
11
17
  * Execute all parses of extension to create resource.
12
18
  * @param extensions - Related extensions field
@@ -48,7 +54,7 @@ export declare abstract class GLTFParser {
48
54
  static _addExtensionParser(extensionName: string, extensionParser: GLTFExtensionParser): void;
49
55
  private static _createAndParse;
50
56
  private static _additiveParse;
51
- abstract parse(context: GLTFParserContext, index?: number): any;
57
+ abstract parse(context: GLTFParserContext): AssetPromise<any> | void | Material | AnimationClip | Mesh;
52
58
  }
53
59
  /**
54
60
  * Declare ExtensionParser's decorator.
@@ -1,31 +1,33 @@
1
- import { Buffer, Entity, ResourceManager, TypedArray } from "@galacean/engine-core";
1
+ import { AnimationClip, AssetPromise, Buffer, Entity, Material, ModelMesh, Texture2D, TypedArray } from "@galacean/engine-core";
2
2
  import { BufferDataRestoreInfo, GLTFContentRestorer } from "../../GLTFContentRestorer";
3
3
  import { GLTFResource } from "../GLTFResource";
4
4
  import type { IGLTF } from "../GLTFSchema";
5
- import { GLTFParser } from "./GLTFParser";
6
5
  /**
7
6
  * @internal
8
7
  */
9
8
  export declare class GLTFParserContext {
9
+ glTF: IGLTF;
10
10
  glTFResource: GLTFResource;
11
- resourceManager: ResourceManager;
12
11
  keepMeshData: boolean;
13
- private static readonly _parsers;
14
- static addParser(parserType: GLTFParserType, parser: GLTFParser): void;
15
- glTF: IGLTF;
12
+ hasSkinned: boolean;
13
+ chainPromises: AssetPromise<any>[];
16
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>>;
17
22
  contentRestorer: GLTFContentRestorer;
18
- buffers?: ArrayBuffer[];
19
- private _resourceCache;
20
- constructor(glTFResource: GLTFResource, resourceManager: ResourceManager, keepMeshData: boolean);
21
- get<T>(type: GLTFParserType.Entity, index: number): Entity;
22
- get<T>(type: GLTFParserType.Entity): Entity[];
23
- get<T>(type: GLTFParserType.Schema): Promise<T>;
24
- get<T>(type: GLTFParserType.Validator): Promise<T>;
25
- get<T>(type: GLTFParserType, index: number): Promise<T>;
26
- get<T>(type: GLTFParserType): Promise<T[]>;
27
- parse(): Promise<GLTFResource>;
28
- private _handleSubAsset;
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;
29
31
  }
30
32
  /**
31
33
  * @internal
@@ -39,16 +41,13 @@ export declare class BufferInfo {
39
41
  restoreInfo: BufferDataRestoreInfo;
40
42
  constructor(data: TypedArray, interleaved: boolean, stride: number);
41
43
  }
42
- export declare enum GLTFParserType {
43
- Schema = 0,
44
- Validator = 1,
45
- Scene = 2,
46
- Buffer = 3,
47
- Texture = 4,
48
- Material = 5,
49
- Mesh = 6,
50
- Entity = 7,
51
- Skin = 8,
52
- Animation = 9
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
53
  }
54
- export declare function registerGLTFParser(pipeline: GLTFParserType): (Parser: new () => GLTFParser) => void;
@@ -1,12 +1,11 @@
1
- import { Entity } from "@galacean/engine-core";
1
+ import { AssetPromise, Entity } from "@galacean/engine-core";
2
2
  import { GLTFParser } from "./GLTFParser";
3
3
  import { GLTFParserContext } from "./GLTFParserContext";
4
4
  export declare class GLTFSceneParser extends GLTFParser {
5
- parse(context: GLTFParserContext, index: number): Promise<Entity>;
6
- private _parseEntityComponent;
5
+ private static _defaultMaterial;
6
+ private static _getDefaultMaterial;
7
+ parse(context: GLTFParserContext): AssetPromise<Entity> | void;
7
8
  private _createCamera;
8
9
  private _createRenderer;
9
10
  private _createAnimator;
10
- private _computeLocalBounds;
11
- private _computeApproximateBindMatrix;
12
11
  }
@@ -1,7 +1,7 @@
1
- import { Skin } from "@galacean/engine-core";
1
+ import { AssetPromise } from "@galacean/engine-core";
2
+ import { GLTFParserContext } from ".";
2
3
  import { GLTFParser } from "./GLTFParser";
3
- import { GLTFParserContext } from "./GLTFParserContext";
4
4
  export declare class GLTFSkinParser extends GLTFParser {
5
- parse(context: GLTFParserContext, index: number): Promise<Skin>;
5
+ parse(context: GLTFParserContext): AssetPromise<void>;
6
6
  private _findSkeletonRootBone;
7
7
  }
@@ -1,12 +1,9 @@
1
- import { Texture, TextureWrapMode } from "@galacean/engine-core";
1
+ import { AssetPromise, Texture2D } from "@galacean/engine-core";
2
+ import { GLTFParserContext } from ".";
2
3
  import { GLTFParser } from "./GLTFParser";
3
- import { GLTFParserContext } from "./GLTFParserContext";
4
4
  export declare class GLTFTextureParser extends GLTFParser {
5
- /** @internal */
6
- static _wrapMap: {
7
- 33071: TextureWrapMode;
8
- 33648: TextureWrapMode;
9
- 10497: TextureWrapMode;
10
- };
11
- parse(context: GLTFParserContext, index: number): Promise<Texture>;
5
+ private static _wrapMap;
6
+ parse(context: GLTFParserContext): AssetPromise<Texture2D[]> | void;
7
+ private _getSamplerInfo;
8
+ private _parseSampler;
12
9
  }
@@ -1,5 +1,6 @@
1
+ import { AssetPromise } from "@galacean/engine-core";
1
2
  import { GLTFParser } from "./GLTFParser";
2
3
  import { GLTFParserContext } from "./GLTFParserContext";
3
4
  export declare class GLTFValidator extends GLTFParser {
4
- parse(context: GLTFParserContext): Promise<void>;
5
+ parse(context: GLTFParserContext): AssetPromise<void>;
5
6
  }
@@ -1,4 +1,3 @@
1
- export { GLTFSchemaParser } from "./GLTFSchemaParser";
2
1
  export { GLTFAnimationParser } from "./GLTFAnimationParser";
3
2
  export { GLTFBufferParser } from "./GLTFBufferParser";
4
3
  export { GLTFEntityParser } from "./GLTFEntityParser";
@@ -9,4 +8,4 @@ export { GLTFSceneParser } from "./GLTFSceneParser";
9
8
  export { GLTFSkinParser } from "./GLTFSkinParser";
10
9
  export { GLTFTextureParser } from "./GLTFTextureParser";
11
10
  export { GLTFValidator } from "./GLTFValidator";
12
- export { GLTFParserContext, GLTFParserType, registerGLTFParser } from "./GLTFParserContext";
11
+ export { GLTFParserContext } from "./GLTFParserContext";
@@ -1,4 +1,3 @@
1
1
  export * from "./BasicSchema";
2
2
  export * from "./MaterialSchema";
3
- export * from "./ProjectSchema";
4
3
  export * from "./SceneSchema";