@predy-js/render-interface 0.1.66-beta.1 → 0.1.66-beta.11
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/statistic.js +1 -1
- package/dist/types/Texture.d.ts +22 -30
- package/dist/types/native/AndGLContext.d.ts +4 -0
- package/dist/types/native/ImageBitmapInternal.d.ts +9 -6
- package/dist/types/native/TextureInternal.d.ts +5 -6
- package/package.json +1 -1
- package/types/Texture.ts +26 -6
- package/types/native/AndGLContext.ts +6 -0
- package/types/native/ImageBitmapInternal.ts +10 -7
- package/types/native/TextureInternal.ts +5 -6
package/dist/statistic.js
CHANGED
package/dist/types/Texture.d.ts
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
import type { IGPURenderer, IGPUResource } from './IGPURenderer';
|
2
2
|
import type { Immutable, TypedArray } from './type';
|
3
3
|
import type { GPURenderer } from './Renderer';
|
4
|
+
/**
|
5
|
+
* 图片解码的格式,默认为 WebGL2RenderingContext['RGBA8']
|
6
|
+
* 如果图片解码格式和texture的不一致,在非Web环境下,会产生报错,无法上传数据
|
7
|
+
* 一般情况由系统根据图片文件解析出图片的像素格式
|
8
|
+
*/
|
9
|
+
export type ImageBitmapPixelFormat = WebGL2RenderingContext['RGBA8'] | WebGL2RenderingContext['RGBA16F'] | WebGL2RenderingContext['RGBA32F'];
|
4
10
|
export declare enum TextureSourceType {
|
5
11
|
none = 0,
|
6
12
|
data = 1,
|
@@ -57,6 +63,11 @@ export interface TextureFactorySource2DMipmapsFrom {
|
|
57
63
|
}
|
58
64
|
export type TextureFactorySourceFrom = TextureFactorySource2DBinaryMipmapsFrom | TextureFactorySourceCubeBinaryMipmapsFrom | TextureFactorySource2DFrom | TextureFactorySourceCubeFrom | TextureFactorySourceCubeMipmapsFrom | TextureFactorySource2DMipmapsFrom | TextureFactorySourceFromCompressed;
|
59
65
|
export interface TextureFactory {
|
66
|
+
/**
|
67
|
+
* 通过TextureConfigOptions可以决定图片解码时使用的格式
|
68
|
+
* @param options
|
69
|
+
* @param config texture的属性
|
70
|
+
*/
|
60
71
|
loadSourceAsync(options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>;
|
61
72
|
canOffloadTexture(texture: Texture): boolean;
|
62
73
|
reloadTextureAsync(texture: Texture): Promise<Texture>;
|
@@ -80,37 +91,18 @@ export declare class Texture implements IGPUResource {
|
|
80
91
|
assignRenderer(renderer: GPURenderer): Texture;
|
81
92
|
}
|
82
93
|
type ImageSource = ImageBitmap | HTMLImageElement | HTMLCanvasElement;
|
94
|
+
export interface ImageData {
|
95
|
+
data: TypedArray;
|
96
|
+
width: number;
|
97
|
+
height: number;
|
98
|
+
}
|
83
99
|
export type TextureSourceCubeData = [
|
84
|
-
TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource |
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
data: TypedArray;
|
91
|
-
width: number;
|
92
|
-
height: number;
|
93
|
-
},
|
94
|
-
TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | {
|
95
|
-
data: TypedArray;
|
96
|
-
width: number;
|
97
|
-
height: number;
|
98
|
-
},
|
99
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | {
|
100
|
-
data: TypedArray;
|
101
|
-
width: number;
|
102
|
-
height: number;
|
103
|
-
},
|
104
|
-
TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | {
|
105
|
-
data: TypedArray;
|
106
|
-
width: number;
|
107
|
-
height: number;
|
108
|
-
},
|
109
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | {
|
110
|
-
data: TypedArray;
|
111
|
-
width: number;
|
112
|
-
height: number;
|
113
|
-
}
|
100
|
+
TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | ImageData,
|
101
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | ImageData,
|
102
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | ImageData,
|
103
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | ImageData,
|
104
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | ImageData,
|
105
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | ImageData
|
114
106
|
];
|
115
107
|
export type TextureSourceOptions = Texture2DSourceOptions | TextureCubeSourceOptions;
|
116
108
|
export interface Texture2DSourceOptionsNone extends TextureOptionsBase {
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import type { MaterialInternal } from './MaterialInternal';
|
2
2
|
import type { vec2 } from '../type';
|
3
3
|
import type { TextureInternal } from './TextureInternal';
|
4
|
+
import type { RenderPassInternal } from './RenderPassInternal';
|
4
5
|
export interface TextureGpuInfo {
|
5
6
|
format: number;
|
6
7
|
type: number;
|
7
8
|
target: number;
|
8
9
|
mipmaps: vec2[];
|
10
|
+
handle: number;
|
9
11
|
}
|
10
12
|
export declare abstract class AndGLContext {
|
11
13
|
abstract isEnabled(param: GLenum): boolean;
|
@@ -33,4 +35,6 @@ export declare abstract class AndGLContext {
|
|
33
35
|
*/
|
34
36
|
abstract setupStates(mtl: MaterialInternal): void;
|
35
37
|
abstract getTextureGpuInfo(texture: TextureInternal): TextureGpuInfo;
|
38
|
+
abstract getTexParameter(target: GLenum, pname: GLenum): number;
|
39
|
+
abstract bindRenderPass(renderPass: RenderPassInternal): void;
|
36
40
|
}
|
@@ -1,18 +1,21 @@
|
|
1
|
+
import type { ImageBitmapPixelFormat } from '../Texture';
|
1
2
|
export interface ImageBitmapConstructor {
|
3
|
+
premultiplyAlpha?: boolean;
|
2
4
|
}
|
3
5
|
export declare abstract class ImageBitmapInternal {
|
4
6
|
/**
|
5
|
-
|
6
|
-
|
7
|
-
|
7
|
+
* 释放内存,释放后不可再用,
|
8
|
+
* 释放后 width,height,byteLength都为0
|
9
|
+
*/
|
8
10
|
abstract close(): void;
|
9
11
|
/**
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
* 将内存拷贝到指定的Uint8Array中
|
13
|
+
* @param target
|
14
|
+
*/
|
13
15
|
abstract copyTo(target: Uint8Array): void;
|
14
16
|
abstract readonly width: number;
|
15
17
|
abstract readonly height: number;
|
16
18
|
abstract readonly byteLength: number;
|
19
|
+
abstract readonly format: ImageBitmapPixelFormat;
|
17
20
|
}
|
18
21
|
export type ImageBitmapCallback = (error: Error | undefined, image: ImageBitmapInternal) => void;
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type { TextureFormatOptions, TextureConfigOptionsBase } from '../Texture';
|
1
|
+
import type { TextureFormatOptions, TextureConfigOptionsBase, ImageData } from '../Texture';
|
2
2
|
import type { ResourceInternal } from './ResourceInternal';
|
3
|
-
import type { TypedArray } from '../type';
|
4
3
|
import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
5
4
|
export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
|
6
5
|
target: WebGLRenderingContext['TEXTURE_CUBE_MAP'] | WebGLRenderingContext['TEXTURE_2D'];
|
@@ -10,7 +9,7 @@ export interface TextureInternalConstructOptions extends TextureInternalOptions
|
|
10
9
|
width: number;
|
11
10
|
height: number;
|
12
11
|
}
|
13
|
-
export type TextureInternalCubeImages<T extends ImageBitmapInternal |
|
12
|
+
export type TextureInternalCubeImages<T extends ImageBitmapInternal | ImageData = ImageBitmapInternal> = [
|
14
13
|
positiveX: T,
|
15
14
|
nagtiveX: T,
|
16
15
|
positiveY: T,
|
@@ -30,7 +29,7 @@ export declare abstract class TextureInternal implements ResourceInternal {
|
|
30
29
|
/**
|
31
30
|
* 上传cubeImage解码后的数据
|
32
31
|
*/
|
33
|
-
abstract updateCubeImagesData(images: TextureInternalCubeImages<
|
32
|
+
abstract updateCubeImagesData(images: TextureInternalCubeImages<ImageData>, mipmapLevel?: number): void;
|
34
33
|
/**
|
35
34
|
* 上传cubeImage
|
36
35
|
*/
|
@@ -38,11 +37,11 @@ export declare abstract class TextureInternal implements ResourceInternal {
|
|
38
37
|
/**
|
39
38
|
* 上传整张解码后图片数据,数据尺寸必须和Texture尺寸定义相同
|
40
39
|
*/
|
41
|
-
abstract update2DImageData(data:
|
40
|
+
abstract update2DImageData(data: ImageData, mipmapLevel?: number): void;
|
42
41
|
/**
|
43
42
|
* 上传压缩纹理数据
|
44
43
|
*/
|
45
|
-
abstract update2DCompressedImage(data:
|
44
|
+
abstract update2DCompressedImage(data: ImageData, mipmapLevel?: number): void;
|
46
45
|
/**
|
47
46
|
* imageBitmap的尺寸也必须和Texture相同
|
48
47
|
* @param image
|
package/package.json
CHANGED
package/types/Texture.ts
CHANGED
@@ -2,6 +2,15 @@ import type { IGPURenderer, IGPUResource } from './IGPURenderer';
|
|
2
2
|
import type { Immutable, TypedArray } from './type';
|
3
3
|
import type { GPURenderer } from './Renderer';
|
4
4
|
|
5
|
+
/**
|
6
|
+
* 图片解码的格式,默认为 WebGL2RenderingContext['RGBA8']
|
7
|
+
* 如果图片解码格式和texture的不一致,在非Web环境下,会产生报错,无法上传数据
|
8
|
+
* 一般情况由系统根据图片文件解析出图片的像素格式
|
9
|
+
*/
|
10
|
+
export type ImageBitmapPixelFormat = WebGL2RenderingContext['RGBA8'] |
|
11
|
+
WebGL2RenderingContext['RGBA16F'] |
|
12
|
+
WebGL2RenderingContext['RGBA32F'] ;
|
13
|
+
|
5
14
|
export enum TextureSourceType {
|
6
15
|
none,
|
7
16
|
data = 1,
|
@@ -75,6 +84,11 @@ export type TextureFactorySourceFrom =
|
|
75
84
|
| TextureFactorySourceFromCompressed;
|
76
85
|
|
77
86
|
export interface TextureFactory {
|
87
|
+
/**
|
88
|
+
* 通过TextureConfigOptions可以决定图片解码时使用的格式
|
89
|
+
* @param options
|
90
|
+
* @param config texture的属性
|
91
|
+
*/
|
78
92
|
loadSourceAsync (options: TextureFactorySourceFrom, config?: TextureConfigOptions): Promise<TextureOptions>,
|
79
93
|
|
80
94
|
canOffloadTexture (texture: Texture): boolean,
|
@@ -112,13 +126,19 @@ export declare class Texture implements IGPUResource {
|
|
112
126
|
|
113
127
|
type ImageSource = ImageBitmap | HTMLImageElement | HTMLCanvasElement;
|
114
128
|
|
129
|
+
export interface ImageData {
|
130
|
+
data: TypedArray,
|
131
|
+
width: number,
|
132
|
+
height: number,
|
133
|
+
}
|
134
|
+
|
115
135
|
export type TextureSourceCubeData = [
|
116
|
-
TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource |
|
117
|
-
TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource |
|
118
|
-
TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource |
|
119
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource |
|
120
|
-
TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource |
|
121
|
-
TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource |
|
136
|
+
TEXTURE_CUBE_MAP_POSITIVE_X: ImageSource | ImageData,
|
137
|
+
TEXTURE_CUBE_MAP_NEGATIVE_X: ImageSource | ImageData,
|
138
|
+
TEXTURE_CUBE_MAP_POSITIVE_Y: ImageSource | ImageData,
|
139
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Y: ImageSource | ImageData,
|
140
|
+
TEXTURE_CUBE_MAP_POSITIVE_Z: ImageSource | ImageData,
|
141
|
+
TEXTURE_CUBE_MAP_NEGATIVE_Z: ImageSource | ImageData
|
122
142
|
];
|
123
143
|
|
124
144
|
// 为减少内存消耗,除了video之外,其余的数据内容会在texture生成后被置为undefined
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import type { MaterialInternal } from './MaterialInternal';
|
2
2
|
import type { vec2 } from '../type';
|
3
3
|
import type { TextureInternal } from './TextureInternal';
|
4
|
+
import type { RenderPassInternal } from './RenderPassInternal';
|
4
5
|
|
5
6
|
export interface TextureGpuInfo {
|
6
7
|
format: number,
|
7
8
|
type: number,
|
8
9
|
target: number,
|
9
10
|
mipmaps: vec2[],
|
11
|
+
handle: number,
|
10
12
|
}
|
11
13
|
|
12
14
|
export abstract class AndGLContext {
|
@@ -42,4 +44,8 @@ export abstract class AndGLContext {
|
|
42
44
|
abstract setupStates (mtl: MaterialInternal): void;
|
43
45
|
|
44
46
|
abstract getTextureGpuInfo (texture: TextureInternal): TextureGpuInfo;
|
47
|
+
|
48
|
+
abstract getTexParameter (target: GLenum, pname: GLenum): number;
|
49
|
+
|
50
|
+
abstract bindRenderPass (renderPass: RenderPassInternal): void;
|
45
51
|
}
|
@@ -1,21 +1,24 @@
|
|
1
|
+
import type { ImageBitmapPixelFormat } from '../Texture';
|
2
|
+
|
1
3
|
export interface ImageBitmapConstructor {
|
4
|
+
premultiplyAlpha?: boolean,
|
2
5
|
}
|
3
6
|
|
4
7
|
export abstract class ImageBitmapInternal {
|
5
8
|
/**
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
* 释放内存,释放后不可再用,
|
10
|
+
* 释放后 width,height,byteLength都为0
|
11
|
+
*/
|
9
12
|
abstract close (): void;
|
10
|
-
|
11
13
|
/**
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
* 将内存拷贝到指定的Uint8Array中
|
15
|
+
* @param target
|
16
|
+
*/
|
15
17
|
abstract copyTo (target: Uint8Array): void;
|
16
18
|
abstract readonly width: number;
|
17
19
|
abstract readonly height: number;
|
18
20
|
abstract readonly byteLength: number;
|
21
|
+
abstract readonly format: ImageBitmapPixelFormat;
|
19
22
|
}
|
20
23
|
|
21
24
|
export type ImageBitmapCallback = (
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import type { TextureFormatOptions, TextureConfigOptionsBase } from '../Texture';
|
1
|
+
import type { TextureFormatOptions, TextureConfigOptionsBase, ImageData } from '../Texture';
|
2
2
|
import type { ResourceInternal } from './ResourceInternal';
|
3
|
-
import type { TypedArray } from '../type';
|
4
3
|
import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
5
4
|
|
6
5
|
export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
|
@@ -13,7 +12,7 @@ export interface TextureInternalConstructOptions extends TextureInternalOptions
|
|
13
12
|
height: number,
|
14
13
|
}
|
15
14
|
|
16
|
-
export type TextureInternalCubeImages<T extends ImageBitmapInternal |
|
15
|
+
export type TextureInternalCubeImages<T extends ImageBitmapInternal | ImageData = ImageBitmapInternal> = [
|
17
16
|
positiveX: T,
|
18
17
|
nagtiveX: T,
|
19
18
|
positiveY: T,
|
@@ -43,7 +42,7 @@ export abstract class TextureInternal implements ResourceInternal {
|
|
43
42
|
/**
|
44
43
|
* 上传cubeImage解码后的数据
|
45
44
|
*/
|
46
|
-
abstract updateCubeImagesData (images: TextureInternalCubeImages<
|
45
|
+
abstract updateCubeImagesData (images: TextureInternalCubeImages<ImageData>, mipmapLevel?: number): void;
|
47
46
|
|
48
47
|
/**
|
49
48
|
* 上传cubeImage
|
@@ -53,13 +52,13 @@ export abstract class TextureInternal implements ResourceInternal {
|
|
53
52
|
/**
|
54
53
|
* 上传整张解码后图片数据,数据尺寸必须和Texture尺寸定义相同
|
55
54
|
*/
|
56
|
-
abstract update2DImageData (data:
|
55
|
+
abstract update2DImageData (data: ImageData, mipmapLevel?: number): void;
|
57
56
|
|
58
57
|
/**
|
59
58
|
* 上传压缩纹理数据
|
60
59
|
*/
|
61
60
|
|
62
|
-
abstract update2DCompressedImage (data:
|
61
|
+
abstract update2DCompressedImage (data: ImageData, mipmapLevel?: number): void;
|
63
62
|
|
64
63
|
/**
|
65
64
|
* imageBitmap的尺寸也必须和Texture相同
|