@predy-js/render-interface 0.3.4-beta.13 → 0.3.4-beta.15
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 +102 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -124
- package/dist/index.mjs.map +1 -1
- package/dist/src/module.d.ts +0 -1
- package/dist/src/render/EventSystem.d.ts +2 -1
- package/dist/src/render/event/UniversalRecognizer.d.ts +3 -5
- package/dist/statistic.js +1 -1
- package/dist/types/EventSystem.d.ts +5 -9
- package/dist/types/native/GPUBufferInternal.d.ts +1 -0
- package/dist/types/native/PredyNativeInternal.d.ts +2 -0
- package/dist/types/native/index.d.ts +1 -0
- package/dist/types/native/motion.d.ts +20 -0
- package/package.json +1 -1
- package/types/EventSystem.ts +6 -10
- package/types/native/DataBlockInternal.ts +3 -0
- package/types/native/GPUBufferInternal.ts +1 -0
- package/types/native/PredyNativeInternal.ts +4 -0
- package/types/native/index.ts +1 -0
- package/types/native/motion.ts +26 -0
package/dist/src/module.d.ts
CHANGED
@@ -17,5 +17,4 @@ export { MarsSharedGeometry as SharedGeometry } from './render/MarsSharedGeometr
|
|
17
17
|
export { getDefaultGPUCapability } from './render/MarsGPUCapability';
|
18
18
|
export { getDefaultTextureFactory, setDefaultTextureFactory, MarsTextureFactory } from './render/MarsTextureFactory';
|
19
19
|
export { PredyEventSystem as EventSystem } from './render/EventSystem';
|
20
|
-
export { UniversalRecognizer as PredyUniversalRecognizer } from './render/event/UniversalRecognizer';
|
21
20
|
export declare const ModuleMsg = "RI Package: @predy-js/render-interface";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { PredyTouchEventArg, PredyRecognizer } from 'types';
|
1
|
+
import type { PredyTouchEventArg, PredyRecognizer, UniversalRecognizerOptions } from 'types';
|
2
2
|
import { type EventSystem } from 'types';
|
3
3
|
import { EventSystemEnv } from 'types';
|
4
4
|
import type { Canvas } from 'types/Canvas';
|
@@ -13,6 +13,7 @@ export declare class PredyEventSystem implements EventSystem {
|
|
13
13
|
set enabled(value: boolean);
|
14
14
|
private createPlatformHandler;
|
15
15
|
setRecognizer(recognizer: PredyRecognizer): void;
|
16
|
+
setUniversalRecognizer(options: UniversalRecognizerOptions): void;
|
16
17
|
handleBaseEvent(event: PredyTouchEventArg): void;
|
17
18
|
dispatch(type: string, event: PredyTouchEventArg): void;
|
18
19
|
addEventListener(type: string, handler: (e: PredyTouchEventArg) => void): () => void;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { UniversalRecognizerOptions } from 'types';
|
2
|
-
import { RecognizerState
|
3
|
-
export declare class UniversalRecognizer implements
|
1
|
+
import type { PredyRecognizer, UniversalRecognizerOptions, PredyTouchEventArg } from 'types';
|
2
|
+
import { RecognizerState } from 'types';
|
3
|
+
export declare class UniversalRecognizer implements PredyRecognizer {
|
4
4
|
readonly options: UniversalRecognizerOptions;
|
5
5
|
private _state;
|
6
6
|
private trackedTouches;
|
@@ -19,13 +19,11 @@ export declare class UniversalRecognizer implements PredyUniversalRecognizer {
|
|
19
19
|
/**
|
20
20
|
* 手势识别核心算法
|
21
21
|
*/
|
22
|
-
private validateGesture;
|
23
22
|
private validateTouchCount;
|
24
23
|
private validateDuration;
|
25
24
|
private validateDistance;
|
26
25
|
private validateDirection;
|
27
26
|
private validateThreshold;
|
28
|
-
private validateFinalConditions;
|
29
27
|
private calculateOverallDelta;
|
30
28
|
/**
|
31
29
|
* 计算聚合缩放比例(基于各触点到中心点的距离变化)
|
package/dist/statistic.js
CHANGED
@@ -62,15 +62,6 @@ export interface PredyRecognizer {
|
|
62
62
|
detect(event: PredyTouchEventArg): string | undefined;
|
63
63
|
reset(): void;
|
64
64
|
}
|
65
|
-
/**
|
66
|
-
* 通用手势识别器
|
67
|
-
*/
|
68
|
-
export declare class PredyUniversalRecognizer implements PredyRecognizer {
|
69
|
-
constructor(options: UniversalRecognizerOptions);
|
70
|
-
_callback?: ((type: string, event: PredyTouchEventArg) => void) | undefined;
|
71
|
-
detect(event: PredyTouchEventArg): string | undefined;
|
72
|
-
reset(): void;
|
73
|
-
}
|
74
65
|
/**
|
75
66
|
* 事件系统
|
76
67
|
*/
|
@@ -80,8 +71,13 @@ export declare class EventSystem {
|
|
80
71
|
constructor(target: HTMLCanvasElement | Canvas, env: EventSystemEnv);
|
81
72
|
/**
|
82
73
|
* 设置自定义手势识别器
|
74
|
+
* 如不设置则只能监听基础的 touch 事件
|
83
75
|
*/
|
84
76
|
setRecognizer: (recognizer: PredyRecognizer) => void;
|
77
|
+
/**
|
78
|
+
* 设置 Predy 提供的通用手势识别器
|
79
|
+
*/
|
80
|
+
setUniversalRecognizer: (options: UniversalRecognizerOptions) => void;
|
85
81
|
/**
|
86
82
|
* 处理基础手势,只能在平台接口中调用
|
87
83
|
*/
|
@@ -6,6 +6,7 @@ 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;
|
@@ -94,6 +95,7 @@ export interface PredyNativeInternal {
|
|
94
95
|
* @param codec
|
95
96
|
*/
|
96
97
|
supportVideoCodec(codec: PredyVideoCodec): boolean;
|
98
|
+
createOrientationManager(): MotionOrientationManager;
|
97
99
|
}
|
98
100
|
type renderSDFImageCallback = (img: SDFImage) => void;
|
99
101
|
export {};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { vec4 } from '../type';
|
2
|
+
export interface OrientationData {
|
3
|
+
timestamp: number;
|
4
|
+
orientation: {
|
5
|
+
alpha: number;
|
6
|
+
beta: number;
|
7
|
+
gamma: number;
|
8
|
+
quat: vec4;
|
9
|
+
};
|
10
|
+
}
|
11
|
+
export interface MotionStartOptions {
|
12
|
+
fps?: number;
|
13
|
+
}
|
14
|
+
type MotionStartCallback = (success: boolean, msg: string) => void;
|
15
|
+
export declare abstract class MotionOrientationManager {
|
16
|
+
motionCallback?: (motion: OrientationData) => void;
|
17
|
+
abstract start(options: MotionStartOptions, callback?: MotionStartCallback): void;
|
18
|
+
abstract destroy(): void;
|
19
|
+
}
|
20
|
+
export {};
|
package/package.json
CHANGED
package/types/EventSystem.ts
CHANGED
@@ -84,16 +84,6 @@ export interface PredyRecognizer {
|
|
84
84
|
reset(): void,
|
85
85
|
}
|
86
86
|
|
87
|
-
/**
|
88
|
-
* 通用手势识别器
|
89
|
-
*/
|
90
|
-
export declare class PredyUniversalRecognizer implements PredyRecognizer {
|
91
|
-
constructor (options: UniversalRecognizerOptions);
|
92
|
-
_callback?: ((type: string, event: PredyTouchEventArg) => void) | undefined;
|
93
|
-
detect (event: PredyTouchEventArg): string | undefined;
|
94
|
-
reset (): void;
|
95
|
-
}
|
96
|
-
|
97
87
|
/**
|
98
88
|
* 事件系统
|
99
89
|
*/
|
@@ -104,9 +94,15 @@ export declare class EventSystem {
|
|
104
94
|
|
105
95
|
/**
|
106
96
|
* 设置自定义手势识别器
|
97
|
+
* 如不设置则只能监听基础的 touch 事件
|
107
98
|
*/
|
108
99
|
setRecognizer: (recognizer: PredyRecognizer) => void;
|
109
100
|
|
101
|
+
/**
|
102
|
+
* 设置 Predy 提供的通用手势识别器
|
103
|
+
*/
|
104
|
+
setUniversalRecognizer: (options: UniversalRecognizerOptions) => void;
|
105
|
+
|
110
106
|
/**
|
111
107
|
* 处理基础手势,只能在平台接口中调用
|
112
108
|
*/
|
@@ -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
|
/**
|
@@ -6,6 +6,7 @@ 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,
|
@@ -110,6 +111,9 @@ export interface PredyNativeInternal {
|
|
110
111
|
* @param codec
|
111
112
|
*/
|
112
113
|
supportVideoCodec(codec: PredyVideoCodec): boolean,
|
114
|
+
|
115
|
+
createOrientationManager(): MotionOrientationManager,
|
116
|
+
|
113
117
|
}
|
114
118
|
|
115
119
|
type renderSDFImageCallback = (img: SDFImage) => void;
|
package/types/native/index.ts
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
import type { vec4 } from '../type';
|
2
|
+
|
3
|
+
export interface OrientationData {
|
4
|
+
timestamp: number,
|
5
|
+
orientation: {
|
6
|
+
alpha: number,
|
7
|
+
beta: number,
|
8
|
+
gamma: number,
|
9
|
+
quat: vec4,
|
10
|
+
},
|
11
|
+
}
|
12
|
+
|
13
|
+
export interface MotionStartOptions {
|
14
|
+
fps?: number,
|
15
|
+
}
|
16
|
+
|
17
|
+
type MotionStartCallback = (success: boolean, msg: string) => void;
|
18
|
+
|
19
|
+
export abstract class MotionOrientationManager {
|
20
|
+
// 设置数据监听的回调
|
21
|
+
motionCallback?: (motion: OrientationData) => void;
|
22
|
+
// start 之后开始监听事件
|
23
|
+
abstract start (options: MotionStartOptions, callback?: MotionStartCallback): void;
|
24
|
+
// 停止并销毁
|
25
|
+
abstract destroy (): void;
|
26
|
+
}
|