@predy-js/render-interface 0.3.4-beta.8 → 0.3.4-beta.80

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.4-beta.8
5
+ * Version: v0.3.4-beta.80
6
6
  */
7
7
 
8
8
  // https://github.com/greggman/webgl-memory/blob/main/src/texture-utils.js
@@ -147,6 +147,7 @@ export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
147
147
  height: number;
148
148
  }>;
149
149
  target?: WebGLRenderingContext['TEXTURE_2D'];
150
+ generateMipmap?: boolean;
150
151
  }
151
152
  export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
152
153
  sourceType: TextureSourceType.compressed;
@@ -167,6 +168,7 @@ export interface TextureCubeSourceOptionsImageMipmaps extends TextureOptionsBase
167
168
  sourceType: TextureSourceType.mipmaps;
168
169
  mipmaps: Array<TextureSourceCubeData>;
169
170
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'];
171
+ generateMipmap?: boolean;
170
172
  }
171
173
  export type TextureCubeSourceURLMap = [
172
174
  TEXTURE_CUBE_MAP_POSITIVE_X: string,
@@ -4,6 +4,7 @@ import type { GPUBufferOptionsMemoryShared } from '../GPUBuffer';
4
4
  export interface GPUBufferInternalOptions {
5
5
  data?: TypedArray;
6
6
  options?: typeof GPUBufferOptionsMemoryShared;
7
+ target?: number;
7
8
  }
8
9
  /**
9
10
  * 内存写入GPU的具体时机由框架自行决定,只要保证在渲染前输入GPU即可
@@ -1,11 +1,12 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
2
  import type { TypedArray, vec2 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
- import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
4
+ import type { PredyResizeTemplate, SDFImageOptions, SDFImage, SDFString, FontBase } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
6
  import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
7
  import type { ResourcePlatform } from './ResourceInternal';
8
8
  import type { PredyVideoCodec, PredyTextEncoding, PredyResourceCacheStatus } from '../constants';
9
+ import type { MotionOrientationManager } from './motion';
9
10
  export interface PredyRequestOptions {
10
11
  url: string;
11
12
  disableCache?: boolean;
@@ -52,6 +53,13 @@ export interface PredyNativeInternal {
52
53
  * @param callback 如果传入callback就是异步绘制,否则会直接返回结果
53
54
  */
54
55
  generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined;
56
+ /**
57
+ * 同步获取一些文本的大小
58
+ * @param lines 文本
59
+ * @param fonts 字体
60
+ * 按照传入的顺序依次返回每个文本的大小。如传入[line1, line2, line3],返回[line1_width, line1_height, line2_width, line2_height, line3_width, line3_height]
61
+ */
62
+ getTextLineSize(lines: SDFString[], fonts: FontBase[]): Float32Array;
55
63
  /**
56
64
  * 下载并且执行脚本文件,此方法会缓存https的脚本内容
57
65
  * 对于http的请求(开发环境),每次都重新请求
@@ -94,6 +102,7 @@ export interface PredyNativeInternal {
94
102
  * @param codec
95
103
  */
96
104
  supportVideoCodec(codec: PredyVideoCodec): boolean;
105
+ createOrientationManager(): MotionOrientationManager;
97
106
  }
98
107
  type renderSDFImageCallback = (img: SDFImage) => void;
99
108
  export {};
@@ -14,3 +14,4 @@ export * from './AndGLContext';
14
14
  export * from './PredyNativeInternal';
15
15
  export * from './PredyNativeModule';
16
16
  export * from './VideoDecoder';
17
+ export * from './motion';
@@ -0,0 +1,15 @@
1
+ import type { vec3 } from '../type';
2
+ export interface OrientationData {
3
+ timestamp: number;
4
+ orientation: Float32Array | vec3;
5
+ }
6
+ export interface MotionStartOptions {
7
+ fps?: number;
8
+ }
9
+ type MotionStartCallback = (success: boolean, error?: string) => void;
10
+ export declare abstract class MotionOrientationManager {
11
+ motionCallback?: (motion: OrientationData) => void;
12
+ abstract start(options: MotionStartOptions, callback?: MotionStartCallback): void;
13
+ abstract destroy(): void;
14
+ }
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@predy-js/render-interface",
3
- "version": "0.3.4-beta.8",
3
+ "version": "0.3.4-beta.80",
4
4
  "license": "MIT",
5
5
  "module": "./dist/index.mjs",
6
6
  "main": "./dist/index.js",
package/types/Texture.ts CHANGED
@@ -183,6 +183,7 @@ export interface Texture2DSourceOptionsImageMipmaps extends TextureOptionsBase {
183
183
  sourceType: TextureSourceType.mipmaps,
184
184
  mipmaps: Array<ImageSource | { data: TypedArray, width: number, height: number }>,
185
185
  target?: WebGLRenderingContext['TEXTURE_2D'],
186
+ generateMipmap?: boolean,
186
187
  }
187
188
 
188
189
  export interface Texture2DSourceOptionsCompressed extends TextureOptionsBase {
@@ -202,6 +203,7 @@ export interface TextureCubeSourceOptionsImageMipmaps extends TextureOptionsBase
202
203
  sourceType: TextureSourceType.mipmaps,
203
204
  mipmaps: Array<TextureSourceCubeData>,
204
205
  target: WebGLRenderingContext['TEXTURE_CUBE_MAP'],
206
+ generateMipmap?: boolean,
205
207
  }
206
208
 
207
209
  export type TextureCubeSourceURLMap = [
@@ -21,6 +21,9 @@ export abstract class DataBlockInternal implements ResourceInternal {
21
21
 
22
22
  protected constructor (options: DataBlockInternalOptions) {}
23
23
 
24
+ //todo
25
+ // setUniformValues (uniforms: Record<string, TypedArray>): void;
26
+
24
27
  abstract destroy (): void;
25
28
 
26
29
  /**
@@ -5,6 +5,7 @@ import type { GPUBufferOptionsMemoryShared } from '../GPUBuffer';
5
5
  export interface GPUBufferInternalOptions {
6
6
  data?: TypedArray,
7
7
  options?: typeof GPUBufferOptionsMemoryShared,
8
+ target?: number,
8
9
  }
9
10
 
10
11
  /**
@@ -1,11 +1,12 @@
1
1
  import type { ImageBitmapCallback, ImageBitmapConstructor } from './ImageBitmapInternal';
2
2
  import type { TypedArray, vec2 } from '../type';
3
3
  import type { GPUCapability } from '../GPUCapability';
4
- import type { PredyResizeTemplate, SDFImageOptions, SDFImage } from '@predy-js/specification';
4
+ import type { PredyResizeTemplate, SDFImageOptions, SDFImage, SDFString, FontBase } from '@predy-js/specification';
5
5
  import type { ImageBitmapInternal } from './ImageBitmapInternal';
6
6
  import type { PredyVideoDecoder, PredyVideoDecoderConstructor } from './VideoDecoder';
7
7
  import type { ResourcePlatform } from './ResourceInternal';
8
8
  import type { PredyVideoCodec, PredyTextEncoding, PredyResourceCacheStatus } from '../constants';
9
+ import type { MotionOrientationManager } from './motion';
9
10
 
10
11
  export interface PredyRequestOptions {
11
12
  url: string,
@@ -63,6 +64,15 @@ export interface PredyNativeInternal {
63
64
  * @param callback 如果传入callback就是异步绘制,否则会直接返回结果
64
65
  */
65
66
  generateSDFImage(options: SDFImageOptions, callback?: renderSDFImageCallback): SDFImage | undefined,
67
+
68
+ /**
69
+ * 同步获取一些文本的大小
70
+ * @param lines 文本
71
+ * @param fonts 字体
72
+ * 按照传入的顺序依次返回每个文本的大小。如传入[line1, line2, line3],返回[line1_width, line1_height, line2_width, line2_height, line3_width, line3_height]
73
+ */
74
+ getTextLineSize(lines: SDFString[], fonts: FontBase[]): Float32Array,
75
+
66
76
  /**
67
77
  * 下载并且执行脚本文件,此方法会缓存https的脚本内容
68
78
  * 对于http的请求(开发环境),每次都重新请求
@@ -110,6 +120,9 @@ export interface PredyNativeInternal {
110
120
  * @param codec
111
121
  */
112
122
  supportVideoCodec(codec: PredyVideoCodec): boolean,
123
+
124
+ createOrientationManager(): MotionOrientationManager,
125
+
113
126
  }
114
127
 
115
128
  type renderSDFImageCallback = (img: SDFImage) => void;
@@ -14,3 +14,4 @@ export * from './AndGLContext';
14
14
  export * from './PredyNativeInternal';
15
15
  export * from './PredyNativeModule';
16
16
  export * from './VideoDecoder';
17
+ export * from './motion';
@@ -0,0 +1,21 @@
1
+ import type { vec3 } from '../type';
2
+
3
+ export interface OrientationData {
4
+ timestamp: number,
5
+ orientation: Float32Array | vec3,
6
+ }
7
+
8
+ export interface MotionStartOptions {
9
+ fps?: number,
10
+ }
11
+
12
+ type MotionStartCallback = (success: boolean, error?: string) => void;
13
+
14
+ export abstract class MotionOrientationManager {
15
+ // 设置数据监听的回调
16
+ motionCallback?: (motion: OrientationData) => void;
17
+ // start 之后开始监听事件
18
+ abstract start (options: MotionStartOptions, callback?: MotionStartCallback): void;
19
+ // 停止并销毁
20
+ abstract destroy (): void;
21
+ }