@predy-js/render-interface 0.3.0-beta.15 → 0.3.0-beta.151

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/statistic.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * Name: @predy-js/render-interface
3
3
  * Description: undefined
4
4
  * Author: undefined
5
- * Version: v0.3.0-beta.15
5
+ * Version: v0.3.0-beta.151
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -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';
@@ -21,6 +21,8 @@ export interface PredyRequestResponse {
21
21
  time: number;
22
22
  }
23
23
  export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
24
+ export declare const DataCompressMethodZlib = 1;
25
+ type DataCompressMethod = typeof DataCompressMethodZlib;
24
26
  export interface PredyNativeInternal {
25
27
  webpDisabled?: boolean;
26
28
  createImageBitmap(data: TypedArray | string, //图片文件的数据
@@ -53,6 +55,25 @@ export interface PredyNativeInternal {
53
55
  * @param callback
54
56
  */
55
57
  evaluateScriptURL(url: string, callback: (err: Error, result: any) => void): void;
58
+ /**
59
+ * 将float32Array转换为half float,写入Uint16Array中,
60
+ * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
61
+ * 提供range参数后,算法求出source的最大最小值,然后将float16重新映射到range中
62
+ * 如果source和target的长度不匹配,返回false
63
+ */
64
+ float32ToFloat16(source: Float32Array, target: Uint16Array, range?: vec2): boolean;
65
+ /**
66
+ * 将half float转换为float32,通过Float32Array返回,
67
+ * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
68
+ * 如果没有提供,float16会被直接转化为float32
69
+ * 如果source和target的长度不匹配,返回false
70
+ */
71
+ float16ToFloat32(source: Uint16Array, target: Float32Array, range?: vec2): boolean;
72
+ /**
73
+ * 解压数据
74
+ * @param data
75
+ */
76
+ inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined;
56
77
  }
57
78
  type renderSDFImageCallback = (img: SDFImage) => void;
58
79
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.3.0-beta.15",
3
+ "version": "0.3.0-beta.151",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
@@ -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;
@@ -1,8 +1,9 @@
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';
6
+
6
7
  export interface PredyRequestOptions {
7
8
  url: string,
8
9
  //用于测试缓存,生产中不要使用
@@ -29,6 +30,10 @@ export interface PredyRequestResponse {
29
30
 
30
31
  export type PredyRequestCallback = (err: string | undefined, res: PredyRequestResponse) => void;
31
32
 
33
+ export const DataCompressMethodZlib = 1;
34
+
35
+ type DataCompressMethod = typeof DataCompressMethodZlib;
36
+
32
37
  export interface PredyNativeInternal {
33
38
  webpDisabled?: boolean,
34
39
 
@@ -67,6 +72,28 @@ export interface PredyNativeInternal {
67
72
  * @param callback
68
73
  */
69
74
  evaluateScriptURL (url: string, callback: (err: Error, result: any) => void): void,
75
+
76
+ /**
77
+ * 将float32Array转换为half float,写入Uint16Array中,
78
+ * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
79
+ * 提供range参数后,算法求出source的最大最小值,然后将float16重新映射到range中
80
+ * 如果source和target的长度不匹配,返回false
81
+ */
82
+ float32ToFloat16(source: Float32Array, target: Uint16Array, range?: vec2): boolean,
83
+
84
+ /**
85
+ * 将half float转换为float32,通过Float32Array返回,
86
+ * 如果提供了range参数,代表float16会被重新map到range中,以此提高精度范围
87
+ * 如果没有提供,float16会被直接转化为float32
88
+ * 如果source和target的长度不匹配,返回false
89
+ */
90
+ float16ToFloat32(source: Uint16Array, target: Float32Array, range?: vec2): boolean,
91
+
92
+ /**
93
+ * 解压数据
94
+ * @param data
95
+ */
96
+ inflateData(data: Uint8Array, method: DataCompressMethod): Uint8Array | undefined,
70
97
  }
71
98
 
72
99
  type renderSDFImageCallback = (img: SDFImage) => void;