@galacean/engine-loader 1.2.0-alpha.1 → 1.2.0-alpha.10

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.
Files changed (29) hide show
  1. package/dist/main.js +483 -219
  2. package/dist/main.js.map +1 -1
  3. package/dist/miniprogram.js +483 -219
  4. package/dist/module.js +484 -220
  5. package/dist/module.js.map +1 -1
  6. package/package.json +4 -4
  7. package/types/PrimitiveMeshLoader.d.ts +1 -0
  8. package/types/gltf/GLTFUtils.d.ts +4 -3
  9. package/types/gltf/parser/GLTFJSONParser.d.ts +7 -0
  10. package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
  11. package/types/index.d.ts +3 -2
  12. package/types/resource-deserialize/index.d.ts +2 -1
  13. package/types/resource-deserialize/resources/animationClip/AnimationClipDecoder.d.ts +0 -1
  14. package/types/resource-deserialize/resources/parser/HierarchyParser.d.ts +36 -0
  15. package/types/resource-deserialize/resources/parser/ParserContext.d.ts +29 -0
  16. package/types/resource-deserialize/resources/parser/ReflectionParser.d.ts +4 -4
  17. package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +13 -4
  18. package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
  19. package/types/resource-deserialize/resources/scene/SceneParser.d.ts +3 -17
  20. package/types/resource-deserialize/resources/scene/SceneParserContext.d.ts +6 -12
  21. package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +24 -1
  22. package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +1 -0
  23. package/types/ktx2/BinomialLLCTranscoder/BinomialLLCTranscoder.d.ts +0 -13
  24. package/types/ktx2/BinomialLLCTranscoder/TranscodeWorkerCode.d.ts +0 -33
  25. package/types/ktx2/KhronosTranscoder/KhronosTranscoder.d.ts +0 -17
  26. package/types/ktx2/KhronosTranscoder/TranscoderWorkerCode.d.ts +0 -34
  27. package/types/ktx2/TranscodeResult.d.ts +0 -10
  28. package/types/ktx2/constants.d.ts +0 -7
  29. package/types/ktx2/zstddec.d.ts +0 -62
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galacean/engine-loader",
3
- "version": "1.2.0-alpha.1",
3
+ "version": "1.2.0-alpha.10",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org"
@@ -15,9 +15,9 @@
15
15
  "types/**/*"
16
16
  ],
17
17
  "dependencies": {
18
- "@galacean/engine-core": "1.2.0-alpha.1",
19
- "@galacean/engine-math": "1.2.0-alpha.1",
20
- "@galacean/engine-rhi-webgl": "1.2.0-alpha.1"
18
+ "@galacean/engine-core": "1.2.0-alpha.10",
19
+ "@galacean/engine-rhi-webgl": "1.2.0-alpha.10",
20
+ "@galacean/engine-math": "1.2.0-alpha.10"
21
21
  },
22
22
  "scripts": {
23
23
  "b:types": "tsc"
@@ -0,0 +1 @@
1
+ export {};
@@ -40,9 +40,10 @@ export declare class GLTFUtils {
40
40
  /**
41
41
  * Parse the glb format.
42
42
  */
43
- static parseGLB(context: GLTFParserContext, glb: ArrayBuffer): {
44
- glTF: IGLTF;
45
- buffers: ArrayBuffer[];
43
+ static parseGLB(context: GLTFParserContext, originBuffer: ArrayBuffer): {
44
+ glTF?: IGLTF;
45
+ buffers?: ArrayBuffer[];
46
+ originBuffer?: ArrayBuffer;
46
47
  };
47
48
  static parseSampler(texture: Texture2D, samplerInfo: ISamplerInfo): void;
48
49
  static getSamplerInfo(sampler: ISampler): ISamplerInfo;
@@ -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
+ }
@@ -3,5 +3,4 @@ import { GLTFParser } from "./GLTFParser";
3
3
  import { GLTFParserContext } from "./GLTFParserContext";
4
4
  export declare class GLTFSchemaParser extends GLTFParser {
5
5
  parse(context: GLTFParserContext): Promise<IGLTF>;
6
- private _isGLB;
7
6
  }
package/types/index.d.ts CHANGED
@@ -10,19 +10,20 @@ 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
+ export { GLTFLoader } from "./GLTFLoader";
20
22
  export type { GLTFParams } from "./GLTFLoader";
21
23
  export * from "./SceneLoader";
22
24
  export type { Texture2DParams } from "./Texture2DLoader";
23
25
  export { parseSingleKTX } from "./compressed-texture";
24
26
  export * from "./gltf";
25
- export { GLTFLoader } from "./GLTFLoader";
26
27
  export { KTX2Loader, KTX2Transcoder } from "./ktx2/KTX2Loader";
27
28
  export { KTX2TargetFormat } from "./ktx2/KTX2TargetFormat";
28
29
  export * from "./resource-deserialize";
@@ -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/parser/PrefabParser";
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";
@@ -1,6 +1,5 @@
1
1
  import { AnimationClip, Engine } from "@galacean/engine-core";
2
2
  import type { BufferReader } from "../../utils/BufferReader";
3
- export { ComponentMap } from "./ComponentMap";
4
3
  export declare enum InterpolableValueType {
5
4
  Float = 0,
6
5
  FloatArray = 1,
@@ -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 { SceneParserContext } from "../scene/SceneParserContext";
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: SceneParserContext);
8
+ constructor(_context: ParserContext<IPrefabFile, EngineObject>);
9
9
  parseEntity(entityConfig: IEntity): Promise<Entity>;
10
10
  parseClassObject(item: IClassObject): Promise<any>;
11
11
  parsePropsAndMethods(instance: any, item: Omit<IClassObject, "class">): Promise<any>;
@@ -1,5 +1,14 @@
1
- import { Entity } from "@galacean/engine-core";
2
- import type { IEntity } from "./PrefabDesign";
3
- export declare class PrefabParser {
4
- static parseChildren(entitiesConfig: Map<string, IEntity>, entities: Map<string, Entity>, parentId: string): void;
1
+ import { Entity, Engine } from "@galacean/engine-core";
2
+ import type { IPrefabFile } from "../schema";
3
+ import { PrefabParserContext } from "./PrefabParserContext";
4
+ import HierarchyParser from "../parser/HierarchyParser";
5
+ export declare class PrefabParser extends HierarchyParser<Entity, PrefabParserContext> {
6
+ /**
7
+ * Parse prefab data.
8
+ * @param engine - the engine of the parser context
9
+ * @param prefabData - prefab data which is exported by editor
10
+ * @returns a promise of prefab
11
+ */
12
+ static parse(engine: Engine, prefabData: IPrefabFile): PrefabParser;
13
+ protected handleRootEntity(id: string): void;
5
14
  }
@@ -0,0 +1,5 @@
1
+ import { Entity } from "@galacean/engine-core";
2
+ import { IPrefabFile } from "../schema";
3
+ import { ParserContext } from "../parser/ParserContext";
4
+ export declare class PrefabParserContext extends ParserContext<IPrefabFile, Entity> {
5
+ }
@@ -1,9 +1,9 @@
1
1
  import { Engine, Scene } from "@galacean/engine-core";
2
2
  import type { IScene } from "../schema";
3
3
  import { SceneParserContext } from "./SceneParserContext";
4
+ import HierarchyParser from "../parser/HierarchyParser";
4
5
  /** @Internal */
5
- export declare class SceneParser {
6
- readonly context: SceneParserContext;
6
+ export declare class SceneParser extends HierarchyParser<Scene, SceneParserContext> {
7
7
  /**
8
8
  * Parse scene data.
9
9
  * @param engine - the engine of the parser context
@@ -11,19 +11,5 @@ export declare class SceneParser {
11
11
  * @returns a promise of scene
12
12
  */
13
13
  static parse(engine: Engine, sceneData: IScene): Promise<Scene>;
14
- /**
15
- * The promise of parsed scene.
16
- */
17
- readonly promise: Promise<Scene>;
18
- private _resolve;
19
- private _reject;
20
- private _engine;
21
- private _reflectionParser;
22
- constructor(context: SceneParserContext);
23
- /** start parse the scene */
24
- start(): void;
25
- private _parseEntities;
26
- private _organizeEntities;
27
- private _parseComponents;
28
- private _clearAndResolveScene;
14
+ protected handleRootEntity(id: string): void;
29
15
  }
@@ -1,15 +1,9 @@
1
- import { Component, Engine, Entity, ResourceManager, Scene } from "@galacean/engine-core";
2
- import type { IEntity, IScene } from "../schema";
3
- export declare class SceneParserContext {
1
+ import { Scene } from "@galacean/engine-core";
2
+ import { IScene } from "../schema";
3
+ import { ParserContext } from "../parser/ParserContext";
4
+ export declare class SceneParserContext extends ParserContext<IScene, Scene> {
4
5
  readonly originalData: IScene;
6
+ readonly engine: any;
5
7
  readonly scene: Scene;
6
- entityMap: Map<string, Entity>;
7
- components: Map<string, Component>;
8
- assets: Map<string, any>;
9
- entityConfigMap: Map<string, IEntity>;
10
- rootIds: string[];
11
- readonly engine: Engine;
12
- readonly resourceManager: ResourceManager;
13
- constructor(originalData: IScene, scene: Scene);
14
- destroy(): void;
8
+ constructor(originalData: IScene, engine: any, scene: Scene);
15
9
  }
@@ -36,11 +36,34 @@ export interface IBasicEntity {
36
36
  parent?: string;
37
37
  layer?: Layer;
38
38
  }
39
- export type IEntity = IBasicEntity | IRefEntity;
39
+ export type IEntity = IBasicEntity | IRefEntity | IStrippedEntity;
40
40
  export interface IRefEntity extends IBasicEntity {
41
41
  assetRefId: string;
42
42
  key?: string;
43
43
  isClone?: boolean;
44
+ modifications: {
45
+ target: IPrefabModifyTarget;
46
+ methods?: {
47
+ [methodName: string]: Array<IMethodParams>;
48
+ };
49
+ props?: {
50
+ [key: string]: IBasicType | IMethodParams;
51
+ };
52
+ }[];
53
+ removedEntities: IPrefabModifyTarget[];
54
+ removedComponents: IPrefabModifyTarget[];
55
+ }
56
+ export interface IPrefabModifyTarget {
57
+ entityId?: string;
58
+ componentId?: string;
59
+ }
60
+ export interface IStrippedEntity extends IBasicEntity {
61
+ strippedId: string;
62
+ prefabInstanceId: string;
63
+ prefabSource: {
64
+ assetId: string;
65
+ entityId: string;
66
+ };
44
67
  }
45
68
  export type IComponent = {
46
69
  id: string;
@@ -32,6 +32,7 @@ export interface IScene extends IPrefabFile {
32
32
  shadowCascades: ShadowCascadesMode;
33
33
  shadowTwoCascadeSplits: number;
34
34
  shadowFourCascadeSplits: IVector3;
35
+ shadowFadeBorder: number;
35
36
  };
36
37
  };
37
38
  files: Array<{
@@ -1,13 +0,0 @@
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
- }
@@ -1,33 +0,0 @@
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 {};
@@ -1,17 +0,0 @@
1
- import { KTX2Container } from "../KTX2Container";
2
- import { KTX2TargetFormat } from "../KTX2TargetFormat";
3
- import { TranscodeResult } from "./TranscoderWorkerCode";
4
- /** @internal */
5
- export declare class KhronosTranscoder {
6
- readonly workerLimit: number;
7
- readonly type: KTX2TargetFormat;
8
- static transcoderMap: {
9
- 0: string;
10
- };
11
- private _transcodeWorkerPool;
12
- private _initPromise;
13
- constructor(workerLimit: number, type: KTX2TargetFormat);
14
- init(): Promise<any>;
15
- transcode(ktx2Container: KTX2Container): Promise<TranscodeResult>;
16
- destroy(): void;
17
- }
@@ -1,34 +0,0 @@
1
- export interface EncodedData {
2
- buffer: Uint8Array;
3
- levelWidth: number;
4
- levelHeight: number;
5
- uncompressedByteLength: number;
6
- }
7
- type MessageType = "init" | "transcode";
8
- export interface IBaseMessage {
9
- type: MessageType;
10
- }
11
- export interface IInitMessage extends IBaseMessage {
12
- type: "init";
13
- transcoderWasm: ArrayBuffer;
14
- }
15
- export interface ITranscodeMessage extends IBaseMessage {
16
- type: "transcode";
17
- format: number;
18
- needZstd: boolean;
19
- data: EncodedData[][];
20
- }
21
- export type IMessage = IInitMessage | ITranscodeMessage;
22
- export type TranscodeResult = {
23
- data: Array<{
24
- data: Uint8Array;
25
- width: number;
26
- height: number;
27
- }>;
28
- };
29
- export type TranscodeResponse = {
30
- id: number;
31
- type: "transcoded";
32
- } & TranscodeResult;
33
- export declare function TranscodeWorkerCode(): void;
34
- export {};
@@ -1,10 +0,0 @@
1
- export interface TranscodeResult {
2
- width: number;
3
- height: number;
4
- hasAlpha: boolean;
5
- mipmaps: Array<{
6
- data: Uint8Array;
7
- width: number;
8
- height: number;
9
- }>;
10
- }
@@ -1,7 +0,0 @@
1
- export declare enum SupercompressionScheme {
2
- None = 0,
3
- BasisLZ = 1,
4
- Zstd = 2,
5
- ZLib = 3
6
- }
7
- export declare const KHR_DF_SAMPLE_DATATYPE_SIGNED = 64;
@@ -1,62 +0,0 @@
1
- /**
2
- * From https://github.com/donmccurdy/zstddec by Don McCurdy
3
- */
4
- interface DecoderExports {
5
- memory: Uint8Array;
6
- ZSTD_findDecompressedSize: (compressedPtr: number, compressedSize: number) => number;
7
- ZSTD_decompress: (uncompressedPtr: number, uncompressedSize: number, compressedPtr: number, compressedSize: number) => number;
8
- malloc: (ptr: number) => number;
9
- free: (ptr: number) => void;
10
- }
11
- /**
12
- * ZSTD (Zstandard) decoder.
13
- */
14
- export declare class ZSTDDecoder {
15
- static heap: Uint8Array;
16
- static IMPORT_OBJECT: {
17
- env: {
18
- emscripten_notify_memory_growth: () => void;
19
- };
20
- };
21
- static instance: {
22
- exports: DecoderExports;
23
- };
24
- static WasmModuleURL: string;
25
- _initPromise: Promise<any>;
26
- init(): Promise<void>;
27
- _init(result: WebAssembly.WebAssemblyInstantiatedSource): void;
28
- decode(array: Uint8Array, uncompressedSize?: number): Uint8Array;
29
- }
30
- export {};
31
- /**
32
- * BSD License
33
- *
34
- * For Zstandard software
35
- *
36
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. All rights reserved.
37
- *
38
- * Redistribution and use in source and binary forms, with or without modification,
39
- * are permitted provided that the following conditions are met:
40
- *
41
- * * Redistributions of source code must retain the above copyright notice, this
42
- * list of conditions and the following disclaimer.
43
- *
44
- * * Redistributions in binary form must reproduce the above copyright notice,
45
- * this list of conditions and the following disclaimer in the documentation
46
- * and/or other materials provided with the distribution.
47
- *
48
- * * Neither the name Facebook nor the names of its contributors may be used to
49
- * endorse or promote products derived from this software without specific
50
- * prior written permission.
51
- *
52
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
53
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
54
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
55
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
56
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
57
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
58
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
59
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
61
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
- */