@predy-js/render-interface 0.3.1 → 0.3.2
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/index.js +73 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -36
- package/dist/index.mjs.map +1 -1
- package/dist/src/render/MarsMaterialDataBlock.d.ts +3 -3
- package/dist/src/render/MarsRenderer.d.ts +1 -0
- package/dist/src/render/MarsTextureFactory.d.ts +1 -1
- package/dist/src/webgl/GLProgram.d.ts +2 -3
- package/dist/src/webgl/KhronosTextureContainer.d.ts +3 -3
- package/dist/src/webgl/constants.d.ts +1 -1
- package/dist/statistic.js +1 -1
- package/dist/types/Material.d.ts +4 -3
- package/dist/types/Renderer.d.ts +4 -0
- package/dist/types/Texture.d.ts +7 -5
- package/dist/types/native/DataBlockInternal.d.ts +15 -0
- package/dist/types/native/PredyNativeInternal.d.ts +55 -21
- package/dist/types/native/RendererInternal.d.ts +6 -1
- package/dist/types/native/TextureInternal.d.ts +6 -2
- package/package.json +1 -1
- package/types/Material.ts +4 -3
- package/types/Renderer.ts +4 -0
- package/types/Texture.ts +43 -41
- package/types/native/DataBlockInternal.ts +17 -0
- package/types/native/PredyNativeInternal.ts +69 -25
- package/types/native/RendererInternal.ts +6 -1
- package/types/native/TextureInternal.ts +6 -2
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { MaterialDataBlock, MaterialDataBlockDestroyOptions, MaterialDataBlockOptions, UniformSemantic, UniformValue, vec2, Texture } from '../../types';
|
1
|
+
import type { MaterialDataBlock, MaterialDataBlockDestroyOptions, MaterialDataBlockOptions, UniformSemantic, UniformValue, vec2, Texture, SemanticFunc } from '../../types';
|
2
2
|
import type { MarsRenderer } from './MarsRenderer';
|
3
3
|
import { MarsTexture } from './MarsTexture';
|
4
4
|
import type { UniformBlockSpec } from '../webgl/GLUniformUtils';
|
@@ -10,7 +10,7 @@ export declare class MarsMaterialDataBlock implements MaterialDataBlock {
|
|
10
10
|
readonly _uniformValueRanges: Record<string, vec2>;
|
11
11
|
readonly name: string;
|
12
12
|
readonly uniformSemantics: {
|
13
|
-
[key: string]: UniformSemantic;
|
13
|
+
[key: string]: UniformSemantic | SemanticFunc;
|
14
14
|
};
|
15
15
|
readonly renderer?: MarsRenderer;
|
16
16
|
readonly uboBufferMap: Record<string, UniformBlockBuffer>;
|
@@ -41,6 +41,6 @@ export declare class MarsMaterialDataBlock implements MaterialDataBlock {
|
|
41
41
|
setUniformValues(map: {
|
42
42
|
[p: string]: UniformValue;
|
43
43
|
}): void;
|
44
|
-
setUniformSemantic(name: string, semantic: string | undefined): void;
|
44
|
+
setUniformSemantic(name: string, semantic: string | SemanticFunc | undefined): void;
|
45
45
|
clone(name: string): MarsMaterialDataBlock;
|
46
46
|
}
|
@@ -18,6 +18,7 @@ export declare class MarsRenderer implements GPURenderer {
|
|
18
18
|
destroy(haltGL?: boolean): void;
|
19
19
|
resize(width: number, height: number): void;
|
20
20
|
cancelAnimationFrame(id: number): void;
|
21
|
+
resume(): void;
|
21
22
|
getErrors(): string[];
|
22
23
|
invalid(): void;
|
23
24
|
requestAnimationFrame(cb: FrameRequestCallback): number;
|
@@ -5,7 +5,7 @@ export declare class MarsTextureFactory implements TextureFactory {
|
|
5
5
|
[key: string]: Promise<Texture>;
|
6
6
|
};
|
7
7
|
constructor();
|
8
|
-
loadMipmapImagesAsync(pointers: vec2[], bin: ArrayBuffer): Promise<(
|
8
|
+
loadMipmapImagesAsync(pointers: vec2[], bin: ArrayBuffer): Promise<(HTMLImageElement | ImageBitmap)[]>;
|
9
9
|
loadImageAsync(url: string | HTMLImageElement | Blob): Promise<HTMLImageElement | ImageBitmap>;
|
10
10
|
requestBinaryAsync(url: string): Promise<ArrayBuffer>;
|
11
11
|
loadImageBinaryAsync(binary: ArrayBuffer | TypedArray | Blob, mime?: string): Promise<HTMLImageElement | ImageBitmap>;
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import type { GLGPURenderer } from './GLGPURenderer';
|
2
2
|
import type { GLGeometry } from './GLGeometry';
|
3
|
-
import type { RenderState } from '../../types/RenderFrame';
|
3
|
+
import type { RenderState, SemanticFunc } from '../../types/RenderFrame';
|
4
4
|
import type { GLVertexArrayObject } from './GLVertexArrayObject';
|
5
5
|
import type { UniformBlockSpec } from './GLUniformUtils';
|
6
|
-
import type { UniformValue } from '../../types';
|
7
6
|
export interface ProgramAttributeInfo {
|
8
7
|
readonly name: string;
|
9
8
|
readonly size: number;
|
@@ -36,7 +35,7 @@ export declare class GLProgram {
|
|
36
35
|
constructor(renderer: GLGPURenderer, program: WebGLProgram, shared: boolean, id: string);
|
37
36
|
init(renderer: GLGPURenderer, program: WebGLProgram): void;
|
38
37
|
bind(): void;
|
39
|
-
getSemanticValue(state: RenderState, semanticName: string): import("../../types").GPUBuffer |
|
38
|
+
getSemanticValue(state: RenderState, semanticName: string | SemanticFunc): number | Float32Array | Float64Array | Uint8Array | Uint32Array | Uint16Array | Int8Array | Int16Array | Int32Array | import("../../types").GPUBuffer | import("../../types").Texture | number[] | number[][] | import("../../types").UniformStruct | import("../../types").UniformStruct[] | SemanticFunc | import("../../types").Texture[] | null | undefined;
|
40
39
|
setupUniforms(state: RenderState): void;
|
41
40
|
setGLUniformValue(name: string, value: any, info: ProgramUniformInfo, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
42
41
|
setupAttributes(geometry: GLGeometry): GLVertexArrayObject;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { TextureOptions
|
1
|
+
import type { TextureOptions } from '../../types';
|
2
2
|
export declare class KhronosTextureContainer {
|
3
3
|
arrayBuffer: ArrayBuffer;
|
4
4
|
baseOffset: number;
|
@@ -15,9 +15,9 @@ export declare class KhronosTextureContainer {
|
|
15
15
|
numberOfFaces: number;
|
16
16
|
numberOfMipmapLevels: number;
|
17
17
|
bytesOfKeyValueData: number;
|
18
|
-
constructor(arrayBuffer: ArrayBuffer,
|
18
|
+
constructor(arrayBuffer: ArrayBuffer, baseOffset?: number);
|
19
19
|
mipmaps(loadMipmaps: boolean): Array<{
|
20
|
-
data:
|
20
|
+
data: Uint8Array;
|
21
21
|
width: number;
|
22
22
|
height: number;
|
23
23
|
}>;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { TypedArray, vec2 } from '../../types/type';
|
2
|
-
export declare
|
2
|
+
export declare const constants: WebGL2RenderingContext & WEBGL_compressed_texture_astc;
|
3
3
|
export declare function createTypedArrayByGLType(type: number, elementCount: number | ArrayBuffer): TypedArray;
|
4
4
|
export declare function getBytesPerElementByGLType(type: number): number;
|
5
5
|
export declare function getMatAttrLocPair(type: number): vec2;
|
package/dist/statistic.js
CHANGED
package/dist/types/Material.d.ts
CHANGED
@@ -4,6 +4,7 @@ import type { Immutable, TypedArray } from './type';
|
|
4
4
|
import type { GPURenderer } from './Renderer';
|
5
5
|
import type { DestroyOptions } from './constants';
|
6
6
|
import type { Texture } from './Texture';
|
7
|
+
import type { SemanticFunc } from './RenderFrame';
|
7
8
|
export type UniformSemantic = 'VIEW' | 'MODEL' | 'MODELVIEW' | 'PROJECTION' | 'VIEWPROJECTION' | 'MODELVIEWPROJECTION' | string;
|
8
9
|
export interface MaterialRenderStates {
|
9
10
|
sampleAlphaToCoverage?: boolean;
|
@@ -110,7 +111,7 @@ export interface MaterialDataBlockOptions {
|
|
110
111
|
uniformTextures?: Record<string, Texture | Texture[]>;
|
111
112
|
name?: string;
|
112
113
|
uniformSemantics?: {
|
113
|
-
[key: string]: UniformSemantic;
|
114
|
+
[key: string]: UniformSemantic | SemanticFunc;
|
114
115
|
};
|
115
116
|
}
|
116
117
|
export interface MaterialDataBlockDestroyOptions {
|
@@ -121,11 +122,11 @@ export declare class MaterialDataBlock implements IGPUResource {
|
|
121
122
|
readonly isDestroyed: boolean;
|
122
123
|
readonly name: string;
|
123
124
|
readonly uniformSemantics?: {
|
124
|
-
[key: string]: UniformSemantic;
|
125
|
+
[key: string]: UniformSemantic | SemanticFunc;
|
125
126
|
};
|
126
127
|
constructor(options: MaterialDataBlockOptions);
|
127
128
|
hasUniformValue(name: string): boolean;
|
128
|
-
setUniformSemantic(name: string, semantic: string | undefined): void;
|
129
|
+
setUniformSemantic(name: string, semantic: string | SemanticFunc | undefined): void;
|
129
130
|
/**
|
130
131
|
* 多次调用次函数只会更新JS层的数据,不会直接更新GPU数据
|
131
132
|
* 在下一次渲染前,会将JS层的数据更新到GPU
|
package/dist/types/Renderer.d.ts
CHANGED
package/dist/types/Texture.d.ts
CHANGED
@@ -25,6 +25,7 @@ export interface TextureFactorySource2DFrom {
|
|
25
25
|
export interface TextureFactorySourceFromCompressed {
|
26
26
|
type: TextureSourceType.compressed;
|
27
27
|
url: string;
|
28
|
+
c?: number;
|
28
29
|
}
|
29
30
|
export type TextureFactorySourceCubeFrom = {
|
30
31
|
type: TextureSourceType.image;
|
@@ -64,10 +65,10 @@ export interface TextureFactorySource2DMipmapsFrom {
|
|
64
65
|
export type TextureFactorySourceFrom = TextureFactorySource2DBinaryMipmapsFrom | TextureFactorySourceCubeBinaryMipmapsFrom | TextureFactorySource2DFrom | TextureFactorySourceCubeFrom | TextureFactorySourceCubeMipmapsFrom | TextureFactorySource2DMipmapsFrom | TextureFactorySourceFromCompressed;
|
65
66
|
export interface TextureFactory {
|
66
67
|
/**
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
* 通过TextureConfigOptions可以决定图片解码时使用的格式
|
69
|
+
* @param options
|
70
|
+
* @param config texture的属性
|
71
|
+
*/
|
71
72
|
loadSourceAsync(options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>;
|
72
73
|
canOffloadTexture(texture: Texture): boolean;
|
73
74
|
reloadTextureAsync(texture: Texture): Promise<Texture>;
|
@@ -150,7 +151,7 @@ export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
|
|
150
151
|
export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
|
151
152
|
sourceType: TextureSourceType.compressed;
|
152
153
|
mipmaps: Array<{
|
153
|
-
data:
|
154
|
+
data: Uint8Array;
|
154
155
|
width: number;
|
155
156
|
height: number;
|
156
157
|
}>;
|
@@ -188,6 +189,7 @@ export interface TextureConfigOptionsBase {
|
|
188
189
|
}
|
189
190
|
export interface TextureConfigOptions extends TextureConfigOptionsBase {
|
190
191
|
sourceFrom?: TextureFactorySourceFrom;
|
192
|
+
premultiplyAlpha?: boolean;
|
191
193
|
}
|
192
194
|
export interface TextureFormatOptions {
|
193
195
|
format?: GLenum;
|
@@ -4,6 +4,12 @@ import type { TextureInternal } from './TextureInternal';
|
|
4
4
|
export interface DataBlockInternalOptions {
|
5
5
|
name: string;
|
6
6
|
}
|
7
|
+
/**
|
8
|
+
* struct uniform的数据结构
|
9
|
+
*/
|
10
|
+
export interface NativeUniformStruct {
|
11
|
+
[key: string]: TypedArray;
|
12
|
+
}
|
7
13
|
export declare abstract class DataBlockInternal implements ResourceInternal {
|
8
14
|
readonly isDestroyed: boolean;
|
9
15
|
/**
|
@@ -27,6 +33,15 @@ export declare abstract class DataBlockInternal implements ResourceInternal {
|
|
27
33
|
* @param value
|
28
34
|
*/
|
29
35
|
abstract getUniformValue(name: string, value: TypedArray): boolean;
|
36
|
+
/**
|
37
|
+
* 设置uniform的结构体数据,对于数据进行深拷贝,修改原始数据,不会影响已经传入的数据,
|
38
|
+
* 如果要修改数据,必须重新调用setUniformStructValues
|
39
|
+
*/
|
40
|
+
abstract setUniformStructValues(name: string, values: NativeUniformStruct[]): boolean;
|
41
|
+
/**
|
42
|
+
* 获取uniform的结构体数据,获取的数据进行深拷贝,传入的数据将
|
43
|
+
*/
|
44
|
+
abstract getUniformStructValue(name: string, idx: number): Record<string, ArrayBuffer> | undefined;
|
30
45
|
abstract setUniformTextures(uniformName: string, texture: TextureInternal[] | undefined): void;
|
31
46
|
abstract getUniformTextures(uniformName: string): TextureInternal[] | undefined;
|
32
47
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
|
2
|
-
import type { TypedArray } from '../type';
|
2
|
+
import type { TypedArray, vec2 } from '../type';
|
3
3
|
import type { GPUCapability } from '../GPUCapability';
|
4
4
|
import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
|
5
5
|
import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
@@ -13,7 +13,9 @@ export interface PredyRequestOptions {
|
|
13
13
|
export declare enum PredyResourceCacheStatus {
|
14
14
|
noCache = 0,
|
15
15
|
cached = 1,
|
16
|
-
preloaded = 2
|
16
|
+
preloaded = 2,
|
17
|
+
hitCDN = 3,
|
18
|
+
missCDN = 4
|
17
19
|
}
|
18
20
|
export interface PredyRequestResponse {
|
19
21
|
data: ArrayBuffer | string;
|
@@ -21,6 +23,12 @@ export interface PredyRequestResponse {
|
|
21
23
|
time: number;
|
22
24
|
}
|
23
25
|
export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
|
26
|
+
export declare const DataCompressMethodZlib = 1;
|
27
|
+
type DataCompressMethod = typeof DataCompressMethodZlib;
|
28
|
+
export declare enum PredyTextEncoding {
|
29
|
+
utf8 = 0,
|
30
|
+
ascii = 1
|
31
|
+
}
|
24
32
|
export interface PredyNativeInternal {
|
25
33
|
webpDisabled?: boolean;
|
26
34
|
createImageBitmap(data: TypedArray | string, //图片文件的数据
|
@@ -28,31 +36,57 @@ export interface PredyNativeInternal {
|
|
28
36
|
getDefaultGPUCapability(): GPUCapability;
|
29
37
|
requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
|
30
38
|
/**
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
39
|
+
* decode text from data
|
40
|
+
* @param data
|
41
|
+
* @param encoding 默认utf8
|
42
|
+
*/
|
43
|
+
decodeText(data: Uint8Array, encoding?: PredyTextEncoding): string;
|
35
44
|
/**
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
* 将图片绘制到画布上,同时替换文案,绘制的顺序如下
|
46
|
+
* 创建template.size尺寸的画布, 接下来的绘制均应用 template.offset
|
47
|
+
* 将images绘制到画布上,images的尺寸由image.frame决定
|
48
|
+
* 将数据模板content绘制到画布上,使用variables替换文案
|
49
|
+
* @param template
|
50
|
+
*/
|
42
51
|
renderImageTemplate(template: PredyResizeTemplate): ImageBitmapInternal;
|
43
52
|
/**
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
53
|
+
* 异步绘制图片的模板
|
54
|
+
* @param options
|
55
|
+
* @param callback 如果传入callback就是异步绘制,否则会直接返回结果
|
56
|
+
*/
|
48
57
|
generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined;
|
49
58
|
/**
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
59
|
+
* 下载并且执行脚本文件,此方法会缓存https的脚本内容
|
60
|
+
* 对于http的请求(开发环境),每次都重新请求
|
61
|
+
* @param url
|
62
|
+
* @param callback
|
63
|
+
*/
|
55
64
|
evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void;
|
65
|
+
/**
|
66
|
+
* 将float32Array转换为half float,写入Uint16Array中,
|
67
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
68
|
+
* 提供range参数后,算法求出source的最大最小值,然后将float16重新映射到range中
|
69
|
+
* 如果source和target的长度不匹配,返回false
|
70
|
+
*/
|
71
|
+
float32ToFloat16(source: Float32Array, target: Uint16Array, range?: vec2): boolean;
|
72
|
+
/**
|
73
|
+
* 将half float转换为float32,通过Float32Array返回,
|
74
|
+
* 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
|
75
|
+
* 如果没有提供,float16会被直接转化为float32
|
76
|
+
* 如果source和target的长度不匹配,返回false
|
77
|
+
*/
|
78
|
+
float16ToFloat32(source: Uint16Array, target: Float32Array, range?: vec2): boolean;
|
79
|
+
/**
|
80
|
+
* 解压数据
|
81
|
+
* @param data
|
82
|
+
* @param method
|
83
|
+
*/
|
84
|
+
inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined;
|
85
|
+
/**
|
86
|
+
* 恢复当前的主JSContext,多个JSContext执行的时候会发生抢占,
|
87
|
+
* 调用此函数后,当前的JSContext会被恢复
|
88
|
+
*/
|
89
|
+
restoreJSContext(): boolean;
|
56
90
|
}
|
57
91
|
type renderSDFImageCallback = (img: SDFImage) => void;
|
58
92
|
export {};
|
@@ -11,6 +11,7 @@ import type { GPUCapability } from '../GPUCapability';
|
|
11
11
|
import type { TextureInternal, TextureInternalConstructOptions } from './TextureInternal';
|
12
12
|
import type { AndGLContext } from './AndGLContext';
|
13
13
|
import type { MetalInternal } from './MetalInternal';
|
14
|
+
import type { vec2 } from '../type';
|
14
15
|
/**
|
15
16
|
* renderer 内部创建的对象,用来统计信息,排查资源泄漏的问题
|
16
17
|
*/
|
@@ -83,5 +84,9 @@ export declare abstract class RendererInternal implements ResourceInternal {
|
|
83
84
|
* 每次调用此函数后,清空错误队列
|
84
85
|
*/
|
85
86
|
abstract getErrors(): string[];
|
86
|
-
|
87
|
+
/**
|
88
|
+
* resize predy view,并且相关的fbo和render pass都需要设为相应的尺寸
|
89
|
+
* @param size 如果不提供size,则使用当前predy view parent的尺寸
|
90
|
+
*/
|
91
|
+
abstract resize(size?: vec2): void;
|
87
92
|
}
|
@@ -39,9 +39,13 @@ export declare abstract class TextureInternal implements ResourceInternal {
|
|
39
39
|
*/
|
40
40
|
abstract update2DImageData(data: ImageData, mipmapLevel?: number): void;
|
41
41
|
/**
|
42
|
-
*
|
42
|
+
* 上传2D压缩纹理数据
|
43
43
|
*/
|
44
|
-
abstract
|
44
|
+
abstract update2DCompressedData(data: Uint8Array, mipmapLevel?: number): void;
|
45
|
+
/**
|
46
|
+
* 上传Cube压缩纹理数据
|
47
|
+
*/
|
48
|
+
abstract update2DCompressedCubeData(data: Uint8Array[], mipmapLevel?: number): void;
|
45
49
|
/**
|
46
50
|
* imageBitmap的尺寸也必须和Texture相同
|
47
51
|
* @param image
|
package/package.json
CHANGED
package/types/Material.ts
CHANGED
@@ -4,6 +4,7 @@ import type { Immutable, TypedArray } from './type';
|
|
4
4
|
import type { GPURenderer } from './Renderer';
|
5
5
|
import type { DestroyOptions } from './constants';
|
6
6
|
import type { Texture } from './Texture';
|
7
|
+
import type { SemanticFunc } from './RenderFrame';
|
7
8
|
|
8
9
|
export type UniformSemantic =
|
9
10
|
| 'VIEW'
|
@@ -142,7 +143,7 @@ export interface MaterialDataBlockOptions {
|
|
142
143
|
uniformValues?: { [key: string]: UniformValue },
|
143
144
|
uniformTextures?: Record<string, Texture | Texture[]>,
|
144
145
|
name?: string,
|
145
|
-
uniformSemantics?: { [key: string]: UniformSemantic },
|
146
|
+
uniformSemantics?: { [key: string]: UniformSemantic | SemanticFunc },
|
146
147
|
}
|
147
148
|
|
148
149
|
export interface MaterialDataBlockDestroyOptions {
|
@@ -157,13 +158,13 @@ export declare class MaterialDataBlock implements IGPUResource {
|
|
157
158
|
|
158
159
|
readonly name: string;
|
159
160
|
|
160
|
-
readonly uniformSemantics?: { [key: string]: UniformSemantic };
|
161
|
+
readonly uniformSemantics?: { [key: string]: UniformSemantic | SemanticFunc };
|
161
162
|
|
162
163
|
constructor (options: MaterialDataBlockOptions);
|
163
164
|
|
164
165
|
hasUniformValue (name: string): boolean;
|
165
166
|
|
166
|
-
setUniformSemantic (name: string, semantic: string | undefined): void;
|
167
|
+
setUniformSemantic (name: string, semantic: string | SemanticFunc | undefined): void;
|
167
168
|
|
168
169
|
/**
|
169
170
|
* 多次调用次函数只会更新JS层的数据,不会直接更新GPU数据
|
package/types/Renderer.ts
CHANGED
package/types/Texture.ts
CHANGED
@@ -9,7 +9,7 @@ import type { GPURenderer } from './Renderer';
|
|
9
9
|
*/
|
10
10
|
export type ImageBitmapPixelFormat = WebGL2RenderingContext['RGBA8'] |
|
11
11
|
WebGL2RenderingContext['RGBA16F'] |
|
12
|
-
WebGL2RenderingContext['RGBA32F']
|
12
|
+
WebGL2RenderingContext['RGBA32F'];
|
13
13
|
|
14
14
|
export enum TextureSourceType {
|
15
15
|
none,
|
@@ -31,6 +31,7 @@ export interface TextureFactorySource2DFrom {
|
|
31
31
|
export interface TextureFactorySourceFromCompressed {
|
32
32
|
type: TextureSourceType.compressed,
|
33
33
|
url: string,
|
34
|
+
c?: number,
|
34
35
|
}
|
35
36
|
|
36
37
|
export type TextureFactorySourceCubeFrom = {
|
@@ -46,12 +47,12 @@ export type TextureFactorySourceCubeBinaryMipmapsFrom = {
|
|
46
47
|
type: TextureSourceType.mipmaps,
|
47
48
|
bin: string,
|
48
49
|
mipmaps: Array<[
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
TEXTURE_CUBE_MAP_POSITIVE_X: DataRange,
|
51
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X: DataRange,
|
52
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y: DataRange,
|
53
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y: DataRange,
|
54
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z: DataRange,
|
55
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z: DataRange
|
55
56
|
]>,
|
56
57
|
};
|
57
58
|
|
@@ -75,27 +76,27 @@ export interface TextureFactorySource2DMipmapsFrom {
|
|
75
76
|
}
|
76
77
|
|
77
78
|
export type TextureFactorySourceFrom =
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
79
|
+
TextureFactorySource2DBinaryMipmapsFrom
|
80
|
+
| TextureFactorySourceCubeBinaryMipmapsFrom
|
81
|
+
| TextureFactorySource2DFrom
|
82
|
+
| TextureFactorySourceCubeFrom
|
83
|
+
| TextureFactorySourceCubeMipmapsFrom
|
84
|
+
| TextureFactorySource2DMipmapsFrom
|
85
|
+
| TextureFactorySourceFromCompressed;
|
85
86
|
|
86
87
|
export interface TextureFactory {
|
87
88
|
/**
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
loadSourceAsync
|
89
|
+
* 通过TextureConfigOptions可以决定图片解码时使用的格式
|
90
|
+
* @param options
|
91
|
+
* @param config texture的属性
|
92
|
+
*/
|
93
|
+
loadSourceAsync(options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>,
|
93
94
|
|
94
|
-
canOffloadTexture
|
95
|
+
canOffloadTexture(texture: Texture): boolean,
|
95
96
|
|
96
|
-
reloadTextureAsync
|
97
|
+
reloadTextureAsync(texture: Texture): Promise<Texture>,
|
97
98
|
|
98
|
-
loadCompressedTextureFromArrayBuffer
|
99
|
+
loadCompressedTextureFromArrayBuffer(arrayBuffer: ArrayBuffer, options?: TextureOptions): TextureOptions,
|
99
100
|
}
|
100
101
|
|
101
102
|
export declare class Texture implements IGPUResource {
|
@@ -133,12 +134,12 @@ export interface ImageData {
|
|
133
134
|
}
|
134
135
|
|
135
136
|
export type TextureSourceCubeData = [
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
137
|
+
TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | ImageData,
|
138
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | ImageData,
|
139
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | ImageData,
|
140
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | ImageData,
|
141
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | ImageData,
|
142
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | ImageData
|
142
143
|
];
|
143
144
|
|
144
145
|
// 为减少内存消耗,除了video之外,其余的数据内容会在texture生成后被置为undefined
|
@@ -186,7 +187,7 @@ export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
|
|
186
187
|
|
187
188
|
export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
|
188
189
|
sourceType: TextureSourceType.compressed,
|
189
|
-
mipmaps: Array<{ data:
|
190
|
+
mipmaps: Array<{ data: Uint8Array, width: number, height: number }>,
|
190
191
|
target?: WebGLRenderingContext['TEXTURE_2D'],
|
191
192
|
}
|
192
193
|
|
@@ -204,12 +205,12 @@ export interface TextureCubeSourceOptionsImageMipmaps extends TextureOptionsBase
|
|
204
205
|
}
|
205
206
|
|
206
207
|
export type TextureCubeSourceURLMap = [
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
208
|
+
TEXTURE_CUBE_MAP_POSITIVE_X: string,
|
209
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X: string,
|
210
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y: string,
|
211
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y: string,
|
212
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z: string,
|
213
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z: string
|
213
214
|
];
|
214
215
|
|
215
216
|
export interface TextureConfigOptionsBase {
|
@@ -227,6 +228,7 @@ export interface TextureConfigOptionsBase {
|
|
227
228
|
|
228
229
|
export interface TextureConfigOptions extends TextureConfigOptionsBase {
|
229
230
|
sourceFrom?: TextureFactorySourceFrom,
|
231
|
+
premultiplyAlpha?: boolean,
|
230
232
|
}
|
231
233
|
|
232
234
|
export interface TextureFormatOptions {
|
@@ -242,12 +244,12 @@ export interface TextureOptionsBase extends TextureConfigOptions, TextureFormatO
|
|
242
244
|
export type TextureCubeSourceOptions = TextureCubeSourceOptionsImage | TextureCubeSourceOptionsImageMipmaps;
|
243
245
|
|
244
246
|
export type Texture2DSourceOptions =
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
247
|
+
Texture2DSourceOptionsImage
|
248
|
+
| Texture2DSourceOptionsData
|
249
|
+
| Texture2DSourceOptionsVideo
|
250
|
+
| Texture2DSourceOptionsImageMipmaps
|
251
|
+
| Texture2DSourceOptionsCompressed
|
252
|
+
| Texture2DSourceOptionsFrameBuffer;
|
251
253
|
|
252
254
|
export type Texture2DOptions = Texture2DSourceOptions;
|
253
255
|
|
@@ -5,6 +5,12 @@ import type { TextureInternal } from './TextureInternal';
|
|
5
5
|
export interface DataBlockInternalOptions {
|
6
6
|
name: string,
|
7
7
|
}
|
8
|
+
|
9
|
+
/**
|
10
|
+
* struct uniform的数据结构
|
11
|
+
*/
|
12
|
+
export interface NativeUniformStruct { [key: string]: TypedArray }
|
13
|
+
|
8
14
|
export abstract class DataBlockInternal implements ResourceInternal {
|
9
15
|
readonly isDestroyed: boolean;
|
10
16
|
/**
|
@@ -33,6 +39,17 @@ export abstract class DataBlockInternal implements ResourceInternal {
|
|
33
39
|
*/
|
34
40
|
abstract getUniformValue (name: string, value: TypedArray): boolean;
|
35
41
|
|
42
|
+
/**
|
43
|
+
* 设置uniform的结构体数据,对于数据进行深拷贝,修改原始数据,不会影响已经传入的数据,
|
44
|
+
* 如果要修改数据,必须重新调用setUniformStructValues
|
45
|
+
*/
|
46
|
+
abstract setUniformStructValues (name: string, values: NativeUniformStruct[]): boolean;
|
47
|
+
|
48
|
+
/**
|
49
|
+
* 获取uniform的结构体数据,获取的数据进行深拷贝,传入的数据将
|
50
|
+
*/
|
51
|
+
abstract getUniformStructValue (name: string, idx: number): Record<string, ArrayBuffer> | undefined;
|
52
|
+
|
36
53
|
abstract setUniformTextures (uniformName: string, texture: TextureInternal[] | undefined): void;
|
37
54
|
|
38
55
|
abstract getUniformTextures (uniformName: string): TextureInternal[] | undefined;
|