@predy-js/render-interface 0.1.61-beta.2 → 0.1.61-beta.20
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 +139 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +139 -59
- package/dist/index.mjs.map +1 -1
- package/dist/src/render/MarsMaterial.d.ts +2 -3
- package/dist/src/render/MarsMaterialDataBlock.d.ts +12 -3
- package/dist/src/render/MarsRenderer.d.ts +3 -0
- package/dist/src/webgl/GLProgram.d.ts +2 -0
- package/dist/statistic.js +1 -1
- package/dist/types/Material.d.ts +27 -24
- package/dist/types/RenderFrame.d.ts +3 -5
- package/dist/types/RenderPass.d.ts +2 -2
- package/dist/types/Renderer.d.ts +21 -12
- package/dist/types/ShaderLibrary.d.ts +4 -4
- package/dist/types/native/DataBlockInternal.d.ts +3 -0
- package/dist/types/native/ImageBitmapInternal.d.ts +0 -2
- package/dist/types/native/MaterialInternal.d.ts +0 -9
- package/dist/types/native/RenderFrameInternal.d.ts +3 -7
- package/dist/types/native/RendererInternal.d.ts +10 -0
- package/dist/types/native/TextureInternal.d.ts +1 -0
- package/package.json +1 -1
- package/types/Material.ts +37 -31
- package/types/RenderFrame.ts +3 -5
- package/types/RenderPass.ts +2 -2
- package/types/Renderer.ts +24 -13
- package/types/ShaderLibrary.ts +4 -4
- package/types/native/DataBlockInternal.ts +5 -0
- package/types/native/ImageBitmapInternal.ts +0 -2
- package/types/native/MaterialInternal.ts +0 -11
- package/types/native/RenderFrameInternal.ts +3 -7
- package/types/native/RendererInternal.ts +13 -0
- package/types/native/TextureInternal.ts +1 -0
package/types/Renderer.ts
CHANGED
@@ -23,13 +23,12 @@ export interface RendererExtensions {
|
|
23
23
|
copyTexture?: (source: Texture, tex: Texture) => void,
|
24
24
|
resetColorAttachments?: (rp: RenderPass, colorAttachments: Texture[]) => void,
|
25
25
|
}
|
26
|
-
|
27
26
|
export declare class GPURenderer implements IGPURenderer {
|
28
27
|
readonly height: number;
|
29
28
|
readonly width: number;
|
30
29
|
/**
|
31
|
-
|
32
|
-
|
30
|
+
* if webgl not support, gpu.level will be 0
|
31
|
+
*/
|
33
32
|
readonly shaderLibrary: ShaderLibrary;
|
34
33
|
readonly gpu: GPUCapability;
|
35
34
|
readonly canvas: Canvas;
|
@@ -44,19 +43,31 @@ export declare class GPURenderer implements IGPURenderer {
|
|
44
43
|
createBuffer (options: GPUBufferOptions): GPUBuffer;
|
45
44
|
|
46
45
|
/**
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
* 根据不同平台封装实现 requestAnimationFrame,
|
47
|
+
* FrameRequestCallback函数回调中进行渲染数据更新,
|
48
|
+
* OpenGL/WebGL在绘制开始之前(传递此帧数据)
|
49
|
+
* Metal在commandBuffer提交后(传递下一帧数据)
|
50
|
+
* @param cb
|
51
|
+
*/
|
52
|
+
requestAnimationFrame (cb: FrameRequestCallback): number;
|
53
|
+
|
54
|
+
//todo
|
55
|
+
cancelAnimationFrame (id: number): void;
|
56
|
+
|
57
|
+
/**
|
58
|
+
* only resize when width or height is different from now,
|
59
|
+
* when resized,all full-screen renderPasses attached to this renderer should be resized as well
|
60
|
+
* 只有当宽高不同的时候,才实际进行函数
|
61
|
+
* 当重新调整宽高后,这个renderer创建的renderPasses,如果没有被指定 viewport(全屏),那么需要resize 所有的renderPass
|
62
|
+
* @param width
|
63
|
+
* @param height
|
64
|
+
*/
|
54
65
|
resize (width: number, height: number): void;
|
55
66
|
|
56
67
|
/**
|
57
|
-
|
58
|
-
|
59
|
-
|
68
|
+
* destroy all resources created by this renderer
|
69
|
+
* @param haltGL if true, this method will call webgl lose context extension which leads webgl absolutely halt
|
70
|
+
*/
|
60
71
|
destroy (haltGL?: boolean): void;
|
61
72
|
|
62
73
|
}
|
package/types/ShaderLibrary.ts
CHANGED
@@ -2,7 +2,7 @@ export type Shader = ShaderWithSource | ShaderUseCacheId;
|
|
2
2
|
export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
|
3
3
|
|
4
4
|
export interface MetaShaderSpec {
|
5
|
-
mtlBinary?: ArrayBuffer,
|
5
|
+
mtlBinary?: ArrayBuffer | string,
|
6
6
|
mtlSource?: string,
|
7
7
|
|
8
8
|
mtlVertex?: string,
|
@@ -72,9 +72,9 @@ export interface ShaderLibrary {
|
|
72
72
|
getShaderResult(cacheId: string): ShaderCompileResult | undefined,
|
73
73
|
|
74
74
|
/**
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
* 添加shader
|
76
|
+
* @param shader
|
77
|
+
*/
|
78
78
|
addShader(shader: Shader): string,
|
79
79
|
|
80
80
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { ResourceInternal } from './ResourceInternal';
|
2
2
|
import type { TypedArray } from '../type';
|
3
|
+
import type { TextureInternal } from './TextureInternal';
|
3
4
|
|
4
5
|
export interface DataBlockInternalOptions {
|
5
6
|
name: string,
|
@@ -32,4 +33,8 @@ export abstract class DataBlockInternal implements ResourceInternal {
|
|
32
33
|
*/
|
33
34
|
abstract getUniformValue (name: string, value: TypedArray): boolean;
|
34
35
|
|
36
|
+
abstract setUniformTextures (uniformName: string, texture: TextureInternal[] | undefined): void;
|
37
|
+
|
38
|
+
abstract getUniformTextures (uniformName: string): TextureInternal[] | undefined;
|
39
|
+
|
35
40
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { ResourceInternal } from './ResourceInternal';
|
2
2
|
import type { MaterialRenderStates } from '../Material';
|
3
3
|
import type { DataBlockInternal } from './DataBlockInternal';
|
4
|
-
import type { TextureInternal } from './TextureInternal';
|
5
4
|
export interface MaterialInternalOptions {
|
6
5
|
states: MaterialRenderStates,
|
7
6
|
dataBlocks: DataBlockInternal[],
|
@@ -18,14 +17,4 @@ export abstract class MaterialInternal implements ResourceInternal {
|
|
18
17
|
protected constructor (options: MaterialInternalOptions) {
|
19
18
|
}
|
20
19
|
abstract destroy (): void;
|
21
|
-
|
22
|
-
/**
|
23
|
-
* 对于 uniform sampler2D uTex
|
24
|
-
* 和 uniform sampler2D uTextures[4] 都使用此函数
|
25
|
-
* @param name
|
26
|
-
* @param value
|
27
|
-
*/
|
28
|
-
abstract setUniformTextures (name: string, value: TextureInternal[]): void;
|
29
|
-
|
30
|
-
abstract getUniformTextures (name: string): TextureInternal[];
|
31
20
|
}
|
@@ -19,16 +19,12 @@ export abstract class RenderFrameInternal implements ResourceInternal {
|
|
19
19
|
protected constructor (options: RenderFrameInternalOptions) {
|
20
20
|
}
|
21
21
|
abstract destroy (): void;
|
22
|
-
/**
|
23
|
-
* warp层完成所有数据传输后,通知客户端,可以进行实际渲染,
|
24
|
-
* 实际渲染根据客户端时机进行,在调用end()之前,客户端会根据实际刷新进行绘制
|
25
|
-
*/
|
26
|
-
abstract begin (): void;
|
27
22
|
|
28
23
|
/**
|
29
|
-
*
|
24
|
+
* 代表此帧会在渲染队列的下一帧被渲染,调用此函数,也会调用renderer.invalid方法
|
25
|
+
* 由于渲染是异步的,此函数在Metal/Vulkan实现中,并不会直接绘制
|
30
26
|
*/
|
31
|
-
abstract
|
27
|
+
abstract render (): void;
|
32
28
|
|
33
29
|
abstract updateLoadAction (action: RenderPassLoadAction): void;
|
34
30
|
}
|
@@ -35,6 +35,11 @@ export abstract class RendererInternal implements ResourceInternal {
|
|
35
35
|
|
36
36
|
abstract destroy (): void;
|
37
37
|
|
38
|
+
/**
|
39
|
+
* 需要进行重新渲染
|
40
|
+
*/
|
41
|
+
abstract invalid (): void;
|
42
|
+
|
38
43
|
abstract createBuffer (options: GPUBufferInternalOptions): GPUBufferInternal;
|
39
44
|
|
40
45
|
abstract createGeometry (options: GeometryInternalOptions): GeometryInternal;
|
@@ -57,6 +62,14 @@ export abstract class RendererInternal implements ResourceInternal {
|
|
57
62
|
|
58
63
|
abstract cancelAnimationFrame (id: number): void;
|
59
64
|
|
65
|
+
/**
|
66
|
+
* 获取错误信息,目前支持最大获取5条,
|
67
|
+
* 每次调用此函数后,清空错误队列
|
68
|
+
*/
|
69
|
+
abstract getErrors (): string[];
|
70
|
+
|
71
|
+
abstract resize (width: number, height: number): void;
|
72
|
+
|
60
73
|
abstract createImageBitmap (
|
61
74
|
data: ArrayBuffer | string, //图片文件的数据
|
62
75
|
options: ImageBitmapConstructor,
|
@@ -5,6 +5,7 @@ import type { ImageBitmapInternal } from './ImageBitmapInternal';
|
|
5
5
|
|
6
6
|
export interface TextureInternalOptions extends TextureFormatOptions, Omit<TextureConfigOptionsBase, 'keepImageSource'> {
|
7
7
|
target: WebGLRenderingContext['TEXTURE_CUBE_MAP'] | WebGLRenderingContext['TEXTURE_2D'],
|
8
|
+
generateMipmap?: boolean,
|
8
9
|
}
|
9
10
|
|
10
11
|
export interface TextureInternalConstructOptions extends TextureInternalOptions {
|