@predy-js/render-interface 0.3.0-beta.12 → 0.3.0-beta.120
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 +13 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -8
- package/dist/index.mjs.map +1 -1
- package/dist/src/render/MarsMaterialDataBlock.d.ts +3 -3
- package/dist/src/render/MarsTextureFactory.d.ts +1 -1
- package/dist/src/webgl/GLProgram.d.ts +2 -3
- package/dist/statistic.js +1 -1
- package/dist/types/Material.d.ts +4 -3
- package/dist/types/native/DataBlockInternal.d.ts +15 -0
- package/package.json +1 -1
- package/types/Material.ts +4 -3
- package/types/native/DataBlockInternal.ts +17 -0
@@ -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
|
}
|
@@ -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;
|
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
|
@@ -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
|
}
|
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数据
|
@@ -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;
|