@galacean/engine-loader 0.9.20 → 0.9.21
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 +186 -443
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +186 -443
- package/dist/module.js +114 -383
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/types/ProjectLoader.d.ts +1 -0
- package/types/gltf/GLTFSchema.d.ts +7 -1
- package/types/gltf/GLTFUtils.d.ts +4 -3
- package/types/gltf/extensions/GLTFExtensionParser.d.ts +0 -6
- package/types/gltf/index.d.ts +0 -1
- package/types/gltf/parser/GLTFAnimationParser.d.ts +3 -3
- package/types/gltf/parser/GLTFBufferParser.d.ts +2 -3
- package/types/gltf/parser/GLTFEntityParser.d.ts +2 -5
- package/types/gltf/parser/GLTFMaterialParser.d.ts +5 -2
- package/types/gltf/parser/GLTFMeshParser.d.ts +2 -2
- package/types/gltf/parser/GLTFParser.d.ts +3 -9
- package/types/gltf/parser/GLTFParserContext.d.ts +29 -28
- package/types/gltf/parser/GLTFSceneParser.d.ts +5 -4
- package/types/gltf/parser/GLTFSchemaParser.d.ts +7 -0
- package/types/gltf/parser/GLTFSkinParser.d.ts +3 -3
- package/types/gltf/parser/GLTFTextureParser.d.ts +9 -6
- package/types/gltf/parser/GLTFValidator.d.ts +1 -2
- package/types/gltf/parser/index.d.ts +2 -1
- 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 +6 -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/resources/schema/ProjectSchema.d.ts +9 -0
- package/types/resource-deserialize/resources/schema/index.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galacean/engine-loader",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.21",
|
|
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.
|
|
19
|
-
"@galacean/engine-draco": "0.9.
|
|
20
|
-
"@galacean/engine-
|
|
21
|
-
"@galacean/engine-
|
|
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"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"b:types": "tsc"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Module for glTF 2.0 Interface
|
|
3
3
|
*/
|
|
4
|
-
import { MeshTopology } from "@galacean/engine-core";
|
|
4
|
+
import type { MeshTopology, TextureFilterMode, TextureWrapMode as EngineTextureWrapMode } from "@galacean/engine-core";
|
|
5
5
|
/**
|
|
6
6
|
* The datatype of the components in the attribute
|
|
7
7
|
*/
|
|
@@ -814,3 +814,9 @@ 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, TypedArray, VertexElementFormat } from "@galacean/engine-core";
|
|
1
|
+
import { IndexFormat, Texture2D, TypedArray, VertexElementFormat } from "@galacean/engine-core";
|
|
2
2
|
import { Color, Vector2, Vector3, Vector4 } from "@galacean/engine-math";
|
|
3
|
-
import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF } from "./GLTFSchema";
|
|
3
|
+
import { AccessorComponentType, AccessorType, IAccessor, IBufferView, IGLTF, ISampler, ISamplerInfo } from "./GLTFSchema";
|
|
4
4
|
import { BufferInfo, GLTFParserContext } from "./parser/GLTFParserContext";
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
@@ -44,5 +44,6 @@ export declare class GLTFUtils {
|
|
|
44
44
|
glTF: IGLTF;
|
|
45
45
|
buffers: ArrayBuffer[];
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
static parseSampler(texture: Texture2D, samplerInfo: ISamplerInfo): void;
|
|
48
|
+
static getSamplerInfo(sampler: ISampler): ISamplerInfo;
|
|
48
49
|
}
|
|
@@ -11,12 +11,6 @@ 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>;
|
|
20
14
|
/**
|
|
21
15
|
* Create and parse the resource.
|
|
22
16
|
* @remarks This method overrides the default resource creation.
|
package/types/gltf/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnimationClip
|
|
1
|
+
import { AnimationClip } 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<
|
|
9
|
+
static _parseStandardProperty(context: GLTFParserContext, animationClip: AnimationClip, animationInfo: IAnimation): Promise<AnimationClip>;
|
|
10
10
|
private static _addCurve;
|
|
11
|
-
parse(context: GLTFParserContext):
|
|
11
|
+
parse(context: GLTFParserContext, index: number): Promise<AnimationClip>;
|
|
12
12
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { AssetPromise } from "@galacean/engine-core";
|
|
2
1
|
import { GLTFParser } from "./GLTFParser";
|
|
3
2
|
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
3
|
export declare class GLTFBufferParser extends GLTFParser {
|
|
5
|
-
parse(context: GLTFParserContext):
|
|
6
|
-
private
|
|
4
|
+
parse(context: GLTFParserContext, index: number): Promise<ArrayBuffer>;
|
|
5
|
+
private _parseSingleBuffer;
|
|
7
6
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { Entity } from "@galacean/engine-core";
|
|
1
2
|
import { GLTFParser } from "./GLTFParser";
|
|
2
3
|
import { GLTFParserContext } from "./GLTFParserContext";
|
|
3
4
|
export declare class GLTFEntityParser extends GLTFParser {
|
|
4
|
-
|
|
5
|
-
static _defaultName: String;
|
|
6
|
-
parse(context: GLTFParserContext): void;
|
|
7
|
-
private _buildEntityTree;
|
|
8
|
-
private _createSceneRoots;
|
|
5
|
+
parse(context: GLTFParserContext, index: number): Entity;
|
|
9
6
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BlinnPhongMaterial, Engine, 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;
|
|
6
9
|
/**
|
|
7
10
|
* @internal
|
|
8
11
|
*/
|
|
@@ -11,5 +14,5 @@ export declare class GLTFMaterialParser extends GLTFParser {
|
|
|
11
14
|
* @internal
|
|
12
15
|
*/
|
|
13
16
|
static _parseStandardProperty(context: GLTFParserContext, material: UnlitMaterial | PBRMaterial | PBRSpecularMaterial, materialInfo: IMaterial): void;
|
|
14
|
-
parse(context: GLTFParserContext):
|
|
17
|
+
parse(context: GLTFParserContext, index: number): Promise<Material>;
|
|
15
18
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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):
|
|
18
|
+
parse(context: GLTFParserContext, index: number): Promise<ModelMesh[]>;
|
|
19
19
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GLTFExtensionMode, GLTFExtensionParser } from "../extensions/GLTFExtensionParser";
|
|
1
|
+
import { EngineObject } from "@galacean/engine-core";
|
|
3
2
|
import type { GLTFExtensionOwnerSchema } from "../GLTFSchema";
|
|
3
|
+
import { GLTFExtensionMode, GLTFExtensionParser } from "../extensions/GLTFExtensionParser";
|
|
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>;
|
|
16
10
|
/**
|
|
17
11
|
* Execute all parses of extension to create resource.
|
|
18
12
|
* @param extensions - Related extensions field
|
|
@@ -54,7 +48,7 @@ export declare abstract class GLTFParser {
|
|
|
54
48
|
static _addExtensionParser(extensionName: string, extensionParser: GLTFExtensionParser): void;
|
|
55
49
|
private static _createAndParse;
|
|
56
50
|
private static _additiveParse;
|
|
57
|
-
abstract parse(context: GLTFParserContext):
|
|
51
|
+
abstract parse(context: GLTFParserContext, index?: number): any;
|
|
58
52
|
}
|
|
59
53
|
/**
|
|
60
54
|
* Declare ExtensionParser's decorator.
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer, Entity, ResourceManager, 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";
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
7
8
|
*/
|
|
8
9
|
export declare class GLTFParserContext {
|
|
9
|
-
glTF: IGLTF;
|
|
10
10
|
glTFResource: GLTFResource;
|
|
11
|
+
resourceManager: ResourceManager;
|
|
11
12
|
keepMeshData: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
private static readonly _parsers;
|
|
14
|
+
static addParser(parserType: GLTFParserType, parser: GLTFParser): void;
|
|
15
|
+
glTF: IGLTF;
|
|
14
16
|
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
17
|
contentRestorer: GLTFContentRestorer;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* @internal
|
|
@@ -41,13 +39,16 @@ export declare class BufferInfo {
|
|
|
41
39
|
restoreInfo: BufferDataRestoreInfo;
|
|
42
40
|
constructor(data: TypedArray, interleaved: boolean, stride: number);
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
|
53
53
|
}
|
|
54
|
+
export declare function registerGLTFParser(pipeline: GLTFParserType): (Parser: new () => GLTFParser) => void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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
|
-
|
|
6
|
-
private
|
|
7
|
-
parse(context: GLTFParserContext): AssetPromise<Entity> | void;
|
|
5
|
+
parse(context: GLTFParserContext, index: number): Promise<Entity>;
|
|
6
|
+
private _parseEntityComponent;
|
|
8
7
|
private _createCamera;
|
|
9
8
|
private _createRenderer;
|
|
10
9
|
private _createAnimator;
|
|
10
|
+
private _computeLocalBounds;
|
|
11
|
+
private _computeApproximateBindMatrix;
|
|
11
12
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GLTFParserContext } from ".";
|
|
1
|
+
import { Skin } from "@galacean/engine-core";
|
|
3
2
|
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
4
|
export declare class GLTFSkinParser extends GLTFParser {
|
|
5
|
-
parse(context: GLTFParserContext):
|
|
5
|
+
parse(context: GLTFParserContext, index: number): Promise<Skin>;
|
|
6
6
|
private _findSkeletonRootBone;
|
|
7
7
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GLTFParserContext } from ".";
|
|
1
|
+
import { Texture, TextureWrapMode } from "@galacean/engine-core";
|
|
3
2
|
import { GLTFParser } from "./GLTFParser";
|
|
3
|
+
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
4
|
export declare class GLTFTextureParser extends GLTFParser {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
/** @internal */
|
|
6
|
+
static _wrapMap: {
|
|
7
|
+
33071: TextureWrapMode;
|
|
8
|
+
33648: TextureWrapMode;
|
|
9
|
+
10497: TextureWrapMode;
|
|
10
|
+
};
|
|
11
|
+
parse(context: GLTFParserContext, index: number): Promise<Texture>;
|
|
9
12
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AssetPromise } from "@galacean/engine-core";
|
|
2
1
|
import { GLTFParser } from "./GLTFParser";
|
|
3
2
|
import { GLTFParserContext } from "./GLTFParserContext";
|
|
4
3
|
export declare class GLTFValidator extends GLTFParser {
|
|
5
|
-
parse(context: GLTFParserContext):
|
|
4
|
+
parse(context: GLTFParserContext): Promise<void>;
|
|
6
5
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { GLTFSchemaParser } from "./GLTFSchemaParser";
|
|
1
2
|
export { GLTFAnimationParser } from "./GLTFAnimationParser";
|
|
2
3
|
export { GLTFBufferParser } from "./GLTFBufferParser";
|
|
3
4
|
export { GLTFEntityParser } from "./GLTFEntityParser";
|
|
@@ -8,4 +9,4 @@ export { GLTFSceneParser } from "./GLTFSceneParser";
|
|
|
8
9
|
export { GLTFSkinParser } from "./GLTFSkinParser";
|
|
9
10
|
export { GLTFTextureParser } from "./GLTFTextureParser";
|
|
10
11
|
export { GLTFValidator } from "./GLTFValidator";
|
|
11
|
-
export { GLTFParserContext } from "./GLTFParserContext";
|
|
12
|
+
export { GLTFParserContext, GLTFParserType, registerGLTFParser } from "./GLTFParserContext";
|
|
@@ -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 {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare enum SupercompressionScheme {
|
|
2
|
+
None = 0,
|
|
3
|
+
BasisLZ = 1,
|
|
4
|
+
Zstd = 2,
|
|
5
|
+
ZLib = 3
|
|
6
|
+
}
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare class KTX2Container {
|
|
9
|
+
vkFormat: number;
|
|
10
|
+
typeSize: number;
|
|
11
|
+
pixelWidth: number;
|
|
12
|
+
pixelHeight: number;
|
|
13
|
+
pixelDepth: number;
|
|
14
|
+
layerCount: number;
|
|
15
|
+
faceCount: number;
|
|
16
|
+
supercompressionScheme: SupercompressionScheme;
|
|
17
|
+
levels: KTX2Level[];
|
|
18
|
+
dataFormatDescriptor: KTX2DataFormatDescriptorBasicFormat;
|
|
19
|
+
keyValue: {
|
|
20
|
+
[key: string]: string | Uint8Array;
|
|
21
|
+
};
|
|
22
|
+
globalData: KTX2GlobalDataBasisLZ | null;
|
|
23
|
+
constructor(buffer: Uint8Array);
|
|
24
|
+
get isSRGB(): boolean;
|
|
25
|
+
get isUASTC(): boolean;
|
|
26
|
+
private parse;
|
|
27
|
+
}
|
|
28
|
+
interface KTX2Level {
|
|
29
|
+
levelData: Uint8Array;
|
|
30
|
+
uncompressedByteLength: number;
|
|
31
|
+
}
|
|
32
|
+
interface KTX2DataFormatDescriptorBasicFormat {
|
|
33
|
+
vendorId: number;
|
|
34
|
+
descriptorType: number;
|
|
35
|
+
versionNumber: number;
|
|
36
|
+
/** @deprecated Inferred. */
|
|
37
|
+
descriptorBlockSize: number;
|
|
38
|
+
colorModel: number;
|
|
39
|
+
colorPrimaries: number;
|
|
40
|
+
transferFunction: number;
|
|
41
|
+
flags: number;
|
|
42
|
+
texelBlockDimension: [number, number, number, number];
|
|
43
|
+
bytesPlane: [number, number, number, number, number, number, number, number];
|
|
44
|
+
samples: KTX2BasicFormatSample[];
|
|
45
|
+
}
|
|
46
|
+
interface KTX2BasicFormatSample {
|
|
47
|
+
bitOffset: number;
|
|
48
|
+
bitLength: number;
|
|
49
|
+
/** @deprecated Renamed to 'channelType'. */
|
|
50
|
+
channelID?: number;
|
|
51
|
+
channelType: number;
|
|
52
|
+
samplePosition: number[];
|
|
53
|
+
sampleLower: number;
|
|
54
|
+
sampleUpper: number;
|
|
55
|
+
}
|
|
56
|
+
interface KTX2GlobalDataBasisLZ {
|
|
57
|
+
endpointCount: number;
|
|
58
|
+
selectorCount: number;
|
|
59
|
+
imageDescs: KTX2GlobalDataBasisLZImageDesc[];
|
|
60
|
+
endpointsData: Uint8Array;
|
|
61
|
+
selectorsData: Uint8Array;
|
|
62
|
+
tablesData: Uint8Array;
|
|
63
|
+
extendedData: Uint8Array;
|
|
64
|
+
}
|
|
65
|
+
interface KTX2GlobalDataBasisLZImageDesc {
|
|
66
|
+
imageFlags: number;
|
|
67
|
+
rgbSliceByteOffset: number;
|
|
68
|
+
rgbSliceByteLength: number;
|
|
69
|
+
alphaSliceByteOffset: number;
|
|
70
|
+
alphaSliceByteLength: number;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AssetPromise, Engine, EngineConfiguration, LoadItem, Loader, ResourceManager, Texture2D, TextureCube } from "@galacean/engine-core";
|
|
2
|
+
import { KTX2TargetFormat } from "./KTX2TargetFormat";
|
|
3
|
+
import { TranscodeResult } from "./transcoder/AbstractTranscoder";
|
|
4
|
+
export declare class KTX2Loader extends Loader<Texture2D | TextureCube> {
|
|
5
|
+
private static _isBinomialInit;
|
|
6
|
+
private static _binomialLLCTranscoder;
|
|
7
|
+
private static _khronosTranscoder;
|
|
8
|
+
private static _supportedMap;
|
|
9
|
+
/**
|
|
10
|
+
* Destroy ktx2 transcoder worker.
|
|
11
|
+
*/
|
|
12
|
+
static destroy(): void;
|
|
13
|
+
/** @internal */
|
|
14
|
+
static _parseBuffer(buffer: Uint8Array, engine: Engine, params?: KTX2Params): Promise<{
|
|
15
|
+
engine: Engine;
|
|
16
|
+
result: TranscodeResult;
|
|
17
|
+
targetFormat: KTX2TargetFormat;
|
|
18
|
+
params: Uint8Array;
|
|
19
|
+
}>;
|
|
20
|
+
/** @internal */
|
|
21
|
+
static _createTextureByBuffer(engine: Engine, transcodeResult: TranscodeResult, targetFormat: KTX2TargetFormat, params?: Uint8Array): Texture2D | TextureCube;
|
|
22
|
+
private static _decideTargetFormat;
|
|
23
|
+
private static _detectSupportedFormat;
|
|
24
|
+
private static _getBinomialLLCTranscoder;
|
|
25
|
+
private static _getKhronosTranscoder;
|
|
26
|
+
private static _getEngineTextureFormat;
|
|
27
|
+
initialize(engine: Engine, configuration: EngineConfiguration): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
load(item: LoadItem & {
|
|
32
|
+
params?: KTX2Params;
|
|
33
|
+
}, resourceManager: ResourceManager): AssetPromise<Texture2D | TextureCube>;
|
|
34
|
+
private _isKhronosSupported;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* KTX2 loader params interface.
|
|
38
|
+
*/
|
|
39
|
+
export interface KTX2Params {
|
|
40
|
+
/** Priority transcoding format queue, default is ASTC/ETC/DXT/PVRTC/RGBA8. */
|
|
41
|
+
priorityFormats: KTX2TargetFormat[];
|
|
42
|
+
}
|
|
43
|
+
declare module "@galacean/engine-core" {
|
|
44
|
+
interface EngineConfiguration {
|
|
45
|
+
/** KTX2 loader options. */
|
|
46
|
+
ktx2Loader?: {
|
|
47
|
+
/** Worker count for transcoder, default is 4. */
|
|
48
|
+
workerCount?: number;
|
|
49
|
+
/** Pre-initialization according to the priority transcoding format queue, default is ASTC/ETC/DXT/PVRTC/RGBA8. */
|
|
50
|
+
priorityFormats?: KTX2TargetFormat[] | KTX2TargetFormat[][];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KTX2 transcode target format.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum KTX2TargetFormat {
|
|
5
|
+
/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */
|
|
6
|
+
ASTC = 0,
|
|
7
|
+
/** RGB(A) compressed format, 128 bits per 4x4 pixel block. */
|
|
8
|
+
BC7 = 1,
|
|
9
|
+
/** RGB(A) compressed format, 4 bits per pixel if no alpha channel, 8 bits per pixel if has alpha channel. */
|
|
10
|
+
BC1_BC3 = 2,
|
|
11
|
+
/** RGB(A) compressed format, 4 bits per pixel. */
|
|
12
|
+
PVRTC = 3,
|
|
13
|
+
/** RGB(A) compressed format, 4 bits per pixel if no alpha channel, 8 bits per pixel if has alpha channel. */
|
|
14
|
+
ETC = 4,
|
|
15
|
+
/** R format, 8 bits per pixel. */
|
|
16
|
+
R8 = 5,
|
|
17
|
+
/** RG format, 16 bits per pixel. */
|
|
18
|
+
R8G8 = 6,
|
|
19
|
+
/** RGBA format, 32 bits per pixel. */
|
|
20
|
+
R8G8B8A8 = 7
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @internal
|
|
3
|
+
* WorkerPool, T is is post message type, U is return type.
|
|
4
|
+
*/
|
|
5
|
+
export declare class WorkerPool<T = any, U = any> {
|
|
6
|
+
readonly limitedCount: number;
|
|
7
|
+
private readonly _workerCreator;
|
|
8
|
+
private _taskQueue;
|
|
9
|
+
private _workerStatus;
|
|
10
|
+
private _workerItems;
|
|
11
|
+
/**
|
|
12
|
+
* Constructor of WorkerPool.
|
|
13
|
+
* @param limitedCount - worker limit count
|
|
14
|
+
* @param _workerCreator - creator of worker
|
|
15
|
+
*/
|
|
16
|
+
constructor(limitedCount: number, _workerCreator: () => Worker | Promise<Worker>);
|
|
17
|
+
prepareWorker(): Promise<Worker[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Post message to worker.
|
|
20
|
+
* @param message - Message which posted to worker
|
|
21
|
+
* @returns Return a promise of message
|
|
22
|
+
*/
|
|
23
|
+
postMessage(message: T): Promise<U>;
|
|
24
|
+
/**
|
|
25
|
+
* Destroy the worker pool.
|
|
26
|
+
*/
|
|
27
|
+
destroy(): void;
|
|
28
|
+
private _initWorker;
|
|
29
|
+
private _getIdleWorkerId;
|
|
30
|
+
private _onMessage;
|
|
31
|
+
private _nextTask;
|
|
32
|
+
}
|