@predy-js/render-interface 0.1.73-beta.2 → 0.1.74
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 +15 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -10
- package/dist/index.mjs.map +1 -1
- package/dist/src/render/MarsTextureFactory.d.ts +1 -1
- package/dist/src/webgl/GLProgram.d.ts +1 -1
- package/dist/statistic.js +1 -1
- package/dist/types/RenderPass.d.ts +1 -0
- package/dist/types/ShaderLibrary.d.ts +0 -18
- package/dist/types/native/PredyNativeInternal.d.ts +30 -1
- package/package.json +1 -1
- package/types/RenderPass.ts +1 -1
- package/types/ShaderLibrary.ts +0 -20
- package/types/native/PredyNativeInternal.ts +31 -2
@@ -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<(ImageBitmap | HTMLImageElement)[]>;
|
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>;
|
@@ -36,7 +36,7 @@ export declare class GLProgram {
|
|
36
36
|
constructor(renderer: GLGPURenderer, program: WebGLProgram, shared: boolean, id: string);
|
37
37
|
init(renderer: GLGPURenderer, program: WebGLProgram): void;
|
38
38
|
bind(): void;
|
39
|
-
getSemanticValue(state: RenderState, semanticName: string): import("../../types").GPUBuffer |
|
39
|
+
getSemanticValue(state: RenderState, semanticName: string): UniformValue | import("../../types").GPUBuffer | null | undefined;
|
40
40
|
setupUniforms(state: RenderState): void;
|
41
41
|
setGLUniformValue(name: string, value: any, info: ProgramUniformInfo, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
42
42
|
setupAttributes(geometry: GLGeometry): GLVertexArrayObject;
|
package/dist/statistic.js
CHANGED
@@ -1,27 +1,10 @@
|
|
1
|
-
import type { AttributeBase, GeometryBufferLayout } from './Geometry';
|
2
1
|
export type Shader = ShaderWithSource | ShaderUseCacheId;
|
3
2
|
export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
|
4
|
-
interface MetalVertexAttribute extends Omit<AttributeBase, 'instanceDivisor'> {
|
5
|
-
location: number;
|
6
|
-
stride: number;
|
7
|
-
offset: number;
|
8
|
-
dataSource: string;
|
9
|
-
}
|
10
3
|
export interface MetalShaderSpec {
|
11
4
|
mtlBinary?: ArrayBuffer | string;
|
12
5
|
mtlSource?: string;
|
13
6
|
mtlVertex?: string;
|
14
7
|
mtlFragment?: string;
|
15
|
-
/**
|
16
|
-
* 用于提前计算pipeline,如果没有传递,则需要在mesh被assignRenderer的时候才会计算pipeline
|
17
|
-
* 当mesh被添加到renderPass的时候,会根据renderPass和mesh的vertexLayout寻找对应的pipeline
|
18
|
-
* 如果没有找到,则需要创建,创建后会被缓存
|
19
|
-
* 为了避免渲染卡顿,最好在编译shader的时候就进行pipeline缓存
|
20
|
-
*/
|
21
|
-
mtlVertexLayout?: {
|
22
|
-
bufferLayouts: GeometryBufferLayout[];
|
23
|
-
attributes: MetalVertexAttribute[];
|
24
|
-
};
|
25
8
|
}
|
26
9
|
export interface ShaderSourceBase extends MetalShaderSpec {
|
27
10
|
fragment: string;
|
@@ -98,4 +81,3 @@ export declare class ShaderLibraryEmpty implements ShaderLibrary {
|
|
98
81
|
compileShader(shaderCacheId: string): ShaderCompileResult;
|
99
82
|
destroy(): void;
|
100
83
|
}
|
101
|
-
export {};
|
@@ -1,6 +1,7 @@
|
|
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
|
+
import type { StringTemplate } from '@predy-js/specification';
|
4
5
|
export interface PredyRequestOptions {
|
5
6
|
url: string;
|
6
7
|
disableCache?: boolean;
|
@@ -23,4 +24,32 @@ export declare abstract class PredyNativeInternal {
|
|
23
24
|
options: ImageBitmapConstructor, callback: ImageBitmapCallback): void;
|
24
25
|
abstract getDefaultGPUCapability(): GPUCapability;
|
25
26
|
abstract requestWithCache(options: PredyRequestOptions, callback: PredyRequestCallback): void;
|
27
|
+
/**
|
28
|
+
* 将图片绘制到画布上,同时替换文案,绘制的顺序如下
|
29
|
+
* 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
|
30
|
+
* 将source绘制到画布上,绘制的尺寸为template.sourceSize
|
31
|
+
* 将content绘制到画布上,使用variables替换文案
|
32
|
+
* @param source
|
33
|
+
* @param template
|
34
|
+
* @param variables
|
35
|
+
*/
|
36
|
+
abstract renderImageTemplate(source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
|
37
|
+
}
|
38
|
+
export interface PredyResizeTemplate {
|
39
|
+
/**
|
40
|
+
* 要替换的文案
|
41
|
+
*/
|
42
|
+
content: StringTemplate;
|
43
|
+
/**
|
44
|
+
* 画布尺寸
|
45
|
+
*/
|
46
|
+
size: vec2;
|
47
|
+
/**
|
48
|
+
* 画布绘制的offset 默认[0,0]
|
49
|
+
*/
|
50
|
+
offset: vec2;
|
51
|
+
/**
|
52
|
+
* source image绘制到画布的尺寸
|
53
|
+
*/
|
54
|
+
sourceSize: vec2;
|
26
55
|
}
|
package/package.json
CHANGED
package/types/RenderPass.ts
CHANGED
package/types/ShaderLibrary.ts
CHANGED
@@ -1,30 +1,10 @@
|
|
1
|
-
import type { AttributeBase, GeometryBufferLayout } from './Geometry';
|
2
|
-
|
3
1
|
export type Shader = ShaderWithSource | ShaderUseCacheId;
|
4
2
|
export type ShaderWithSource = InstancedShaderWithSource | SharedShaderWithSource;
|
5
|
-
|
6
|
-
interface MetalVertexAttribute extends Omit<AttributeBase, 'instanceDivisor'> {
|
7
|
-
location: number,
|
8
|
-
stride: number,
|
9
|
-
offset: number,
|
10
|
-
dataSource: string,
|
11
|
-
}
|
12
3
|
export interface MetalShaderSpec {
|
13
4
|
mtlBinary?: ArrayBuffer | string,
|
14
5
|
mtlSource?: string,
|
15
6
|
mtlVertex?: string,
|
16
7
|
mtlFragment?: string,
|
17
|
-
//todo lilong
|
18
|
-
/**
|
19
|
-
* 用于提前计算pipeline,如果没有传递,则需要在mesh被assignRenderer的时候才会计算pipeline
|
20
|
-
* 当mesh被添加到renderPass的时候,会根据renderPass和mesh的vertexLayout寻找对应的pipeline
|
21
|
-
* 如果没有找到,则需要创建,创建后会被缓存
|
22
|
-
* 为了避免渲染卡顿,最好在编译shader的时候就进行pipeline缓存
|
23
|
-
*/
|
24
|
-
mtlVertexLayout?: {
|
25
|
-
bufferLayouts: GeometryBufferLayout[],
|
26
|
-
attributes: MetalVertexAttribute[],
|
27
|
-
},
|
28
8
|
}
|
29
9
|
|
30
10
|
export interface ShaderSourceBase extends MetalShaderSpec {
|
@@ -1,7 +1,7 @@
|
|
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 { StringTemplate } from '@predy-js/specification';
|
5
5
|
export interface PredyRequestOptions {
|
6
6
|
url: string,
|
7
7
|
//用于测试缓存,生产中不要使用
|
@@ -32,4 +32,33 @@ export declare abstract class PredyNativeInternal {
|
|
32
32
|
abstract getDefaultGPUCapability (): GPUCapability;
|
33
33
|
|
34
34
|
abstract requestWithCache (options: PredyRequestOptions, callback: PredyRequestCallback): void;
|
35
|
+
|
36
|
+
/**
|
37
|
+
* 将图片绘制到画布上,同时替换文案,绘制的顺序如下
|
38
|
+
* 创建 template.size尺寸的画布, 接下来的绘制均应用 template.offset
|
39
|
+
* 将source绘制到画布上,绘制的尺寸为template.sourceSize
|
40
|
+
* 将content绘制到画布上,使用variables替换文案
|
41
|
+
* @param source
|
42
|
+
* @param template
|
43
|
+
* @param variables
|
44
|
+
*/
|
45
|
+
abstract renderImageTemplate (source: ImageBitmap, template: PredyResizeTemplate, variables: Record<string, string | number>): ImageBitmap;
|
46
|
+
}
|
47
|
+
export interface PredyResizeTemplate {
|
48
|
+
/**
|
49
|
+
* 要替换的文案
|
50
|
+
*/
|
51
|
+
content: StringTemplate,
|
52
|
+
/**
|
53
|
+
* 画布尺寸
|
54
|
+
*/
|
55
|
+
size: vec2,
|
56
|
+
/**
|
57
|
+
* 画布绘制的offset 默认[0,0]
|
58
|
+
*/
|
59
|
+
offset: vec2,
|
60
|
+
/**
|
61
|
+
* source image绘制到画布的尺寸
|
62
|
+
*/
|
63
|
+
sourceSize: vec2,
|
35
64
|
}
|