@galacean/engine-loader 1.1.0-beta.8 → 1.1.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 +318 -222
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +318 -222
- package/dist/module.js +319 -223
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/GLTFLoader.d.ts +1 -0
- package/types/PrimitiveMeshLoader.d.ts +1 -0
- package/types/Texture2DLoader.d.ts +9 -1
- package/types/gltf/GLTFUtils.d.ts +4 -3
- package/types/gltf/extensions/EXT_meshopt_compression.d.ts +13 -0
- package/types/gltf/extensions/KHR_materials_anisotropy.d.ts +1 -0
- package/types/gltf/extensions/MeshoptDecoder.d.ts +8 -0
- package/types/gltf/parser/GLTFBufferViewParser.d.ts +5 -0
- package/types/gltf/parser/GLTFParserContext.d.ts +4 -2
- package/types/gltf/parser/GLTFSceneParser.d.ts +0 -1
- package/types/gltf/parser/GLTFSchemaParser.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/ktx2/KTX2Loader.d.ts +16 -5
- package/types/ktx2/transcoder/AbstractTranscoder.d.ts +1 -1
- package/types/ktx2/transcoder/BinomialLLCTranscoder.d.ts +1 -1
- package/types/ktx2/transcoder/BinomialLLCWorkerCode.d.ts +1 -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 +1 -1
- package/types/resource-deserialize/resources/prefab/PrefabParser.d.ts +13 -4
- package/types/resource-deserialize/resources/prefab/PrefabParserContext.d.ts +5 -0
- package/types/resource-deserialize/resources/schema/BasicSchema.d.ts +2 -0
- package/types/resource-deserialize/resources/schema/MaterialSchema.d.ts +1 -1
- package/types/resource-deserialize/resources/schema/SceneSchema.d.ts +3 -1
- package/types/resource-deserialize/utils/BufferReader.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-loader",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
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-
|
|
19
|
-
"@galacean/engine-
|
|
20
|
-
"@galacean/engine-
|
|
21
|
-
"@galacean/engine-rhi-webgl": "1.1.
|
|
18
|
+
"@galacean/engine-core": "1.1.1",
|
|
19
|
+
"@galacean/engine-draco": "1.1.1",
|
|
20
|
+
"@galacean/engine-math": "1.1.1",
|
|
21
|
+
"@galacean/engine-rhi-webgl": "1.1.1"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"b:types": "tsc"
|
package/types/GLTFLoader.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextureFormat } from "@galacean/engine-core";
|
|
1
|
+
import { TextureFilterMode, TextureFormat, TextureWrapMode } from "@galacean/engine-core";
|
|
2
2
|
/**
|
|
3
3
|
* Texture2D loader params interface.
|
|
4
4
|
*/
|
|
@@ -7,4 +7,12 @@ export interface Texture2DParams {
|
|
|
7
7
|
format: TextureFormat;
|
|
8
8
|
/** Whether to use multi-level texture, default is true. */
|
|
9
9
|
mipmap: boolean;
|
|
10
|
+
/** Wrapping mode for texture coordinate S. */
|
|
11
|
+
wrapModeU: TextureWrapMode;
|
|
12
|
+
/** Wrapping mode for texture coordinate T. */
|
|
13
|
+
wrapModeV: TextureWrapMode;
|
|
14
|
+
/** Filter mode for texture. */
|
|
15
|
+
filterMode: TextureFilterMode;
|
|
16
|
+
/** Anisotropic level for texture. */
|
|
17
|
+
anisoLevel: number;
|
|
10
18
|
}
|
|
@@ -40,9 +40,10 @@ export declare class GLTFUtils {
|
|
|
40
40
|
/**
|
|
41
41
|
* Parse the glb format.
|
|
42
42
|
*/
|
|
43
|
-
static parseGLB(context: GLTFParserContext,
|
|
44
|
-
glTF
|
|
45
|
-
buffers
|
|
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,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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer, Entity, ResourceManager, TypedArray } from "@galacean/engine-core";
|
|
2
2
|
import { BufferDataRestoreInfo, GLTFContentRestorer } from "../../GLTFContentRestorer";
|
|
3
|
+
import { GLTFParams } from "../../GLTFLoader";
|
|
3
4
|
import { GLTFResource } from "../GLTFResource";
|
|
4
5
|
import type { IGLTF } from "../GLTFSchema";
|
|
5
6
|
import { GLTFParser } from "./GLTFParser";
|
|
@@ -9,7 +10,7 @@ import { GLTFParser } from "./GLTFParser";
|
|
|
9
10
|
export declare class GLTFParserContext {
|
|
10
11
|
glTFResource: GLTFResource;
|
|
11
12
|
resourceManager: ResourceManager;
|
|
12
|
-
|
|
13
|
+
params: GLTFParams;
|
|
13
14
|
private static readonly _parsers;
|
|
14
15
|
static addParser(parserType: GLTFParserType, parser: GLTFParser): void;
|
|
15
16
|
glTF: IGLTF;
|
|
@@ -17,7 +18,7 @@ export declare class GLTFParserContext {
|
|
|
17
18
|
contentRestorer: GLTFContentRestorer;
|
|
18
19
|
buffers?: ArrayBuffer[];
|
|
19
20
|
private _resourceCache;
|
|
20
|
-
constructor(glTFResource: GLTFResource, resourceManager: ResourceManager,
|
|
21
|
+
constructor(glTFResource: GLTFResource, resourceManager: ResourceManager, params: GLTFParams);
|
|
21
22
|
get<T>(type: GLTFParserType.Entity, index: number): Entity;
|
|
22
23
|
get<T>(type: GLTFParserType.Entity): Entity[];
|
|
23
24
|
get<T>(type: GLTFParserType.Schema): Promise<T>;
|
|
@@ -25,6 +26,7 @@ export declare class GLTFParserContext {
|
|
|
25
26
|
get<T>(type: GLTFParserType, index: number): Promise<T>;
|
|
26
27
|
get<T>(type: GLTFParserType): Promise<T[]>;
|
|
27
28
|
parse(): Promise<GLTFResource>;
|
|
29
|
+
private _createAnimator;
|
|
28
30
|
private _handleSubAsset;
|
|
29
31
|
}
|
|
30
32
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -22,6 +22,6 @@ export * from "./SceneLoader";
|
|
|
22
22
|
export type { Texture2DParams } from "./Texture2DLoader";
|
|
23
23
|
export { parseSingleKTX } from "./compressed-texture";
|
|
24
24
|
export * from "./gltf";
|
|
25
|
-
export { KTX2Loader } from "./ktx2/KTX2Loader";
|
|
25
|
+
export { KTX2Loader, KTX2Transcoder } from "./ktx2/KTX2Loader";
|
|
26
26
|
export { KTX2TargetFormat } from "./ktx2/KTX2TargetFormat";
|
|
27
27
|
export * from "./resource-deserialize";
|
|
@@ -5,6 +5,7 @@ export declare class KTX2Loader extends Loader<Texture2D | TextureCube> {
|
|
|
5
5
|
private static _isBinomialInit;
|
|
6
6
|
private static _binomialLLCTranscoder;
|
|
7
7
|
private static _khronosTranscoder;
|
|
8
|
+
private static _priorityFormats;
|
|
8
9
|
private static _supportedMap;
|
|
9
10
|
/**
|
|
10
11
|
* Destroy ktx2 transcoder worker.
|
|
@@ -24,30 +25,40 @@ export declare class KTX2Loader extends Loader<Texture2D | TextureCube> {
|
|
|
24
25
|
private static _getBinomialLLCTranscoder;
|
|
25
26
|
private static _getKhronosTranscoder;
|
|
26
27
|
private static _getEngineTextureFormat;
|
|
27
|
-
initialize(
|
|
28
|
+
initialize(_: Engine, configuration: EngineConfiguration): Promise<void>;
|
|
28
29
|
/**
|
|
29
30
|
* @internal
|
|
30
31
|
*/
|
|
31
32
|
load(item: LoadItem & {
|
|
32
33
|
params?: KTX2Params;
|
|
33
34
|
}, resourceManager: ResourceManager): AssetPromise<Texture2D | TextureCube>;
|
|
34
|
-
private _isKhronosSupported;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* KTX2 loader params interface.
|
|
38
38
|
*/
|
|
39
39
|
export interface KTX2Params {
|
|
40
|
-
/** Priority transcoding format queue, default is ASTC/ETC/
|
|
40
|
+
/** Priority transcoding format queue which is preferred options, default is BC7/ASTC/BC3_BC1/ETC/PVRTC/R8G8B8A8. */
|
|
41
|
+
/** @deprecated */
|
|
41
42
|
priorityFormats: KTX2TargetFormat[];
|
|
42
43
|
}
|
|
44
|
+
/** Used for initialize KTX2 transcoder. */
|
|
45
|
+
export declare enum KTX2Transcoder {
|
|
46
|
+
/** BinomialLLC transcoder. */
|
|
47
|
+
BinomialLLC = 0,
|
|
48
|
+
/** Khronos transcoder. */
|
|
49
|
+
Khronos = 1
|
|
50
|
+
}
|
|
43
51
|
declare module "@galacean/engine-core" {
|
|
44
52
|
interface EngineConfiguration {
|
|
45
53
|
/** KTX2 loader options. */
|
|
46
54
|
ktx2Loader?: {
|
|
47
55
|
/** Worker count for transcoder, default is 4. */
|
|
48
56
|
workerCount?: number;
|
|
49
|
-
/**
|
|
50
|
-
|
|
57
|
+
/** Global transcoding format queue which will be used if not specified in per-instance param, default is BC7/ASTC/BC3_BC1/ETC/PVRTC/R8G8B8A8. */
|
|
58
|
+
/** @deprecated */
|
|
59
|
+
priorityFormats?: KTX2TargetFormat[];
|
|
60
|
+
/** Used for initialize KTX2 transcoder, default is BinomialLLC. */
|
|
61
|
+
transcoder?: KTX2Transcoder;
|
|
51
62
|
};
|
|
52
63
|
}
|
|
53
64
|
}
|
|
@@ -20,7 +20,7 @@ export interface InitMessage extends BaseMessage {
|
|
|
20
20
|
export interface BinomialTranscodeMessage extends BaseMessage {
|
|
21
21
|
type: "transcode";
|
|
22
22
|
format: number;
|
|
23
|
-
buffer:
|
|
23
|
+
buffer: Uint8Array;
|
|
24
24
|
}
|
|
25
25
|
export type IBinomialMessage = InitMessage | BinomialTranscodeMessage;
|
|
26
26
|
export type TranscodeResult = {
|
|
@@ -4,5 +4,5 @@ import { AbstractTranscoder, TranscodeResult } from "./AbstractTranscoder";
|
|
|
4
4
|
export declare class BinomialLLCTranscoder extends AbstractTranscoder {
|
|
5
5
|
constructor(workerLimitCount: number);
|
|
6
6
|
_initTranscodeWorkerPool(): Promise<any>;
|
|
7
|
-
transcode(buffer:
|
|
7
|
+
transcode(buffer: Uint8Array, format: KTX2TargetFormat): Promise<TranscodeResult>;
|
|
8
8
|
}
|
|
@@ -3,4 +3,4 @@ import { TranscodeResult } from "./AbstractTranscoder";
|
|
|
3
3
|
export declare function TranscodeWorkerCode(): void;
|
|
4
4
|
export declare const _init: () => (wasmBinary?: ArrayBuffer) => any;
|
|
5
5
|
export declare const init: (wasmBinary?: ArrayBuffer) => any;
|
|
6
|
-
export declare function transcode(buffer:
|
|
6
|
+
export declare function transcode(buffer: Uint8Array, targetFormat: any, KTX2File: any): TranscodeResult;
|
|
@@ -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
|
+
}
|
|
@@ -10,7 +10,7 @@ export declare class ReflectionParser {
|
|
|
10
10
|
parseClassObject(item: IClassObject): Promise<any>;
|
|
11
11
|
parsePropsAndMethods(instance: any, item: Omit<IClassObject, "class">): Promise<any>;
|
|
12
12
|
parseMethod(instance: any, methodName: string, methodParams: Array<IBasicType>): Promise<any>;
|
|
13
|
-
parseBasicType(value: IBasicType): Promise<any>;
|
|
13
|
+
parseBasicType(value: IBasicType, originValue?: any): Promise<any>;
|
|
14
14
|
private _getEntityByConfig;
|
|
15
15
|
private static _isClass;
|
|
16
16
|
private static _isAssetRef;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { Entity } from "@galacean/engine-core";
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
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
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Layer } from "@galacean/engine-core";
|
|
1
2
|
export interface IVector3 {
|
|
2
3
|
x: number;
|
|
3
4
|
y: number;
|
|
@@ -33,6 +34,7 @@ export interface IBasicEntity {
|
|
|
33
34
|
scale?: IVector3;
|
|
34
35
|
children?: Array<string>;
|
|
35
36
|
parent?: string;
|
|
37
|
+
layer?: Layer;
|
|
36
38
|
}
|
|
37
39
|
export type IEntity = IBasicEntity | IRefEntity;
|
|
38
40
|
export interface IRefEntity extends IBasicEntity {
|
|
@@ -79,7 +79,7 @@ export interface IMaterialSchema {
|
|
|
79
79
|
shader: string;
|
|
80
80
|
shaderData: {
|
|
81
81
|
[key: string]: {
|
|
82
|
-
type: "Vector2" | "Vector3" | "Vector4" | "Color" | "Float" | "Texture";
|
|
82
|
+
type: "Vector2" | "Vector3" | "Vector4" | "Color" | "Float" | "Texture" | "Boolean" | "Integer";
|
|
83
83
|
value: IVector3 | IVector2 | IColor | number | IAssetRef;
|
|
84
84
|
};
|
|
85
85
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackgroundMode, DiffuseMode, ShadowCascadesMode, ShadowResolution } from "@galacean/engine-core";
|
|
2
2
|
import type { IReferable } from "@galacean/engine-core/types/asset/IReferable";
|
|
3
|
-
import type { IColor, IPrefabFile } from "./BasicSchema";
|
|
3
|
+
import type { IColor, IPrefabFile, IVector3 } from "./BasicSchema";
|
|
4
4
|
export declare enum SpecularMode {
|
|
5
5
|
Sky = "Sky",
|
|
6
6
|
Custom = "Custom"
|
|
@@ -30,6 +30,8 @@ export interface IScene extends IPrefabFile {
|
|
|
30
30
|
shadowResolution: ShadowResolution;
|
|
31
31
|
shadowDistance: number;
|
|
32
32
|
shadowCascades: ShadowCascadesMode;
|
|
33
|
+
shadowTwoCascadeSplits: number;
|
|
34
|
+
shadowFourCascadeSplits: IVector3;
|
|
33
35
|
};
|
|
34
36
|
};
|
|
35
37
|
files: Array<{
|
|
@@ -2,7 +2,7 @@ export declare class BufferReader {
|
|
|
2
2
|
data: Uint8Array;
|
|
3
3
|
private _dataView;
|
|
4
4
|
private _littleEndian;
|
|
5
|
-
private
|
|
5
|
+
private _position;
|
|
6
6
|
private _baseOffset;
|
|
7
7
|
constructor(data: Uint8Array, byteOffset?: number, byteLength?: number, littleEndian?: boolean);
|
|
8
8
|
get position(): number;
|