@web-ar-studio/webar-engine-sdk 1.0.11 → 1.0.13

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.d.ts CHANGED
@@ -13,11 +13,18 @@ declare const EVENT_LOST = "lost";
13
13
  declare const EVENT_POSE = "pose";
14
14
  declare const EVENT_PROCESS = "process";
15
15
  declare const EVENT_XR_SESSION = "xrsession";
16
+ declare const EVENT_XR_SELECT = "xrselect";
17
+ declare const EVENT_XR_ROTATE_START = "xrrotatestart";
18
+ declare const EVENT_XR_ROTATE = "xrrotate";
19
+ declare const EVENT_XR_PINCH_START = "xrpinchstart";
20
+ declare const EVENT_XR_PINCH = "xrpinch";
21
+ declare const EVENT_XR_PAN_START = "xrpanstart";
22
+ declare const EVENT_XR_PAN_MOVE = "xrpanmove";
23
+ declare const EVENT_XR_VIEWER_POSE = "xrviewerpose";
16
24
  declare const EVENT_RESIZE = "resize";
17
25
  declare const EVENT_DEVICE_ORIENTATION = "deviceorientation";
18
26
  declare const EVENT_SCREEN_ORIENTATION = "change";
19
27
  declare const EVENT_VISIBILITY = "visibilitychange";
20
- declare const EVENT_SELECT = "select";
21
28
  declare const EVENT_FRAME = "frame";
22
29
  declare const DATA_ERROR = "DataError";
23
30
  declare const EVENT_ERROR = "EventError";
@@ -79,7 +86,7 @@ type TConfigData = {
79
86
  anchor?: never;
80
87
  } | {
81
88
  mode: typeof PROJECT_MODE_SLAM_WEBXR;
82
- uiContainer: Element;
89
+ uiContainer?: Element;
83
90
  fov?: never;
84
91
  near?: never;
85
92
  far?: never;
@@ -106,7 +113,7 @@ type TConfigData = {
106
113
  anchor: TAnchorType;
107
114
  });
108
115
 
109
- type TEventWASType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_SELECT | typeof EVENT_FRAME;
116
+ type TEventWASType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_XR_SELECT | typeof EVENT_XR_ROTATE_START | typeof EVENT_XR_ROTATE | typeof EVENT_XR_PINCH_START | typeof EVENT_XR_PINCH | typeof EVENT_XR_PAN_START | typeof EVENT_XR_PAN_MOVE | typeof EVENT_XR_VIEWER_POSE | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
110
117
 
111
118
  type TVector = {
112
119
  x: number;
@@ -145,21 +152,38 @@ type TEventPoseData = {
145
152
  landmarksData?: TVector[];
146
153
  };
147
154
 
155
+ type XREvent = {
156
+ rotation: number;
157
+ scale: number;
158
+ deltaX: number;
159
+ deltaY: number;
160
+ clientX: number;
161
+ clientY: number;
162
+ };
163
+
164
+ type TXRViewerPose = {
165
+ positionVector: TVector;
166
+ rotationQuaternion: TQuaternion;
167
+ scaleVector: TVector;
168
+ projectionMatrix: Float32Array;
169
+ };
170
+
148
171
  type TEventWASCallBack = {
149
172
  (detectedData: TEventDetectedData[]): void;
150
173
  (lostData: TEventLostData[]): void;
151
174
  (poseData: TEventPoseData[]): void;
152
175
  (isProcess: boolean): void;
153
176
  (isActive: boolean): void;
177
+ (event: XREvent): void;
178
+ (XRViewerPose: TXRViewerPose | undefined): void;
154
179
  (event: UIEvent): void;
155
180
  (event: DeviceOrientationEvent): void;
156
181
  (angle: number): void;
157
182
  (isVisible: boolean): void;
158
- (): void;
159
183
  (deltaTime: number): void;
160
184
  };
161
185
 
162
- type TEventType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_SELECT | typeof EVENT_FRAME;
186
+ type TEventType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_XR_SELECT | typeof EVENT_XR_ROTATE_START | typeof EVENT_XR_ROTATE | typeof EVENT_XR_PINCH_START | typeof EVENT_XR_PINCH | typeof EVENT_XR_PAN_START | typeof EVENT_XR_PAN_MOVE | typeof EVENT_XR_VIEWER_POSE | typeof EVENT_RESIZE | typeof EVENT_DEVICE_ORIENTATION | typeof EVENT_SCREEN_ORIENTATION | typeof EVENT_VISIBILITY | typeof EVENT_FRAME;
163
187
 
164
188
  type TViewportSizes = {
165
189
  width: number;
@@ -179,15 +203,13 @@ type TTriggerSize = {
179
203
  height: number;
180
204
  };
181
205
 
182
- type TEventEmitType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_SELECT;
206
+ type TEventEmitType = typeof EVENT_DETECTED | typeof EVENT_LOST | typeof EVENT_POSE | typeof EVENT_PROCESS | typeof EVENT_XR_SESSION | typeof EVENT_XR_SELECT | typeof EVENT_XR_ROTATE_START | typeof EVENT_XR_ROTATE | typeof EVENT_XR_PINCH_START | typeof EVENT_XR_PINCH | typeof EVENT_XR_PAN_START | typeof EVENT_XR_PAN_MOVE | typeof EVENT_XR_VIEWER_POSE;
183
207
 
184
- type TEventEmitData = TEventDetectedData[] | TEventLostData[] | TEventPoseData[] | boolean;
208
+ type TEventEmitData = TEventDetectedData[] | TEventLostData[] | TEventPoseData[] | TXRViewerPose | XREvent | boolean;
185
209
 
186
- type TXRViewerPose = {
187
- positionVector: TVector;
188
- rotationQuaternion: TQuaternion;
189
- scaleVector: TVector;
190
- projectionMatrix: Float32Array;
210
+ type TSizes = {
211
+ width: number;
212
+ height: number;
191
213
  };
192
214
 
193
215
  interface IWAS {
@@ -198,6 +220,7 @@ interface IWAS {
198
220
  setMediaStream(): Promise<void>;
199
221
  getTriggerSize(triggerId: number): TTriggerSize | null;
200
222
  getTriggerScale(triggerId: number): TVector | null;
223
+ getSizes(): TSizes;
201
224
  getViewportSizes(): TViewportSizes;
202
225
  getFaceMeshTriangulation(): Uint16Array;
203
226
  getFaceMeshTriangulationFillMouth(): Uint16Array;
@@ -208,9 +231,11 @@ interface IWAS {
208
231
  getIsSupportXRSession(): Promise<boolean>;
209
232
  getIsActiveXRSession(): boolean;
210
233
  endXRSession(): void;
211
- getXRViewerPose(): TXRViewerPose | null;
234
+ getXRFramebuffer(): WebGLFramebuffer | null;
235
+ getXRCameraImage(): WebGLTexture | null;
212
236
  emit(type: TEventEmitType, data?: TEventEmitData): void;
213
237
  getDeltaTime(): number;
238
+ getElapsedTime(): number;
214
239
  }
215
240
 
216
241
  declare class WAS implements IWAS {
@@ -256,11 +281,12 @@ declare class WAS implements IWAS {
256
281
  on(type: typeof EVENT_POSE, callBack: (poseData: TEventPoseData[]) => void): Promise<void>;
257
282
  on(type: typeof EVENT_PROCESS, callBack: (isProcess: boolean) => void): Promise<void>;
258
283
  on(type: typeof EVENT_XR_SESSION, callBack: (isActive: boolean) => void): Promise<void>;
284
+ on(type: typeof EVENT_XR_SELECT | typeof EVENT_XR_ROTATE_START | typeof EVENT_XR_ROTATE | typeof EVENT_XR_PINCH_START | typeof EVENT_XR_PINCH | typeof EVENT_XR_PAN_START | typeof EVENT_XR_PAN_MOVE, callBack: (event: XREvent) => void): Promise<void>;
285
+ on(type: typeof EVENT_XR_VIEWER_POSE, callBack: (XRViewerPose: TXRViewerPose | undefined) => void): Promise<void>;
259
286
  on(type: typeof EVENT_RESIZE, callBack: (event: UIEvent) => void): Promise<void>;
260
287
  on(type: typeof EVENT_DEVICE_ORIENTATION, callBack: (event: DeviceOrientationEvent) => void): Promise<void>;
261
288
  on(type: typeof EVENT_SCREEN_ORIENTATION, callBack: (angle: number) => void): Promise<void>;
262
289
  on(type: typeof EVENT_VISIBILITY, callBack: (isVisible: boolean) => void): Promise<void>;
263
- on(type: typeof EVENT_SELECT, callBack: () => void): Promise<void>;
264
290
  on(type: typeof EVENT_FRAME, callBack: (deltaTime: number) => void): Promise<void>;
265
291
  un(type: TEventType): Promise<void>;
266
292
  dispose(): Promise<void>;
@@ -287,6 +313,7 @@ declare class WAS implements IWAS {
287
313
  private drawVideo;
288
314
  getTriggerSize(triggerId: number): TTriggerSize | null;
289
315
  getTriggerScale(triggerId: number): TVector | null;
316
+ getSizes(): TSizes;
290
317
  getViewportSizes(): TViewportSizes;
291
318
  getFaceMeshTriangulation(): Uint16Array;
292
319
  getFaceMeshTriangulationFillMouth(): Uint16Array;
@@ -297,9 +324,11 @@ declare class WAS implements IWAS {
297
324
  getIsSupportXRSession(): Promise<boolean>;
298
325
  getIsActiveXRSession(): boolean;
299
326
  endXRSession(): void;
300
- getXRViewerPose(): TXRViewerPose | null;
327
+ getXRFramebuffer(): WebGLFramebuffer | null;
328
+ getXRCameraImage(): WebGLTexture | null;
301
329
  emit(type: TEventEmitType, data?: TEventEmitData): void;
302
330
  getDeltaTime(): number;
331
+ getElapsedTime(): number;
303
332
  }
304
333
 
305
- export { ANCHOR_TYPE_BOTTOM_LEFT, ANCHOR_TYPE_BOTTOM_LIP, ANCHOR_TYPE_BOTTOM_RIGHT, ANCHOR_TYPE_CENTER, ANCHOR_TYPE_CHIN, ANCHOR_TYPE_LEFT_EAR, ANCHOR_TYPE_LEFT_EYE, ANCHOR_TYPE_LEFT_EYEBROW, ANCHOR_TYPE_NOSE_BASE, ANCHOR_TYPE_NOSE_BRIDGE, ANCHOR_TYPE_NOSE_TIP, ANCHOR_TYPE_ORIGIN, ANCHOR_TYPE_RIGHT_EAR, ANCHOR_TYPE_RIGHT_EYE, ANCHOR_TYPE_RIGHT_EYEBROW, ANCHOR_TYPE_TOP_LEFT, ANCHOR_TYPE_TOP_RIGHT, DATA_ERROR, DEVICE_ERROR, EVENT_DETECTED, EVENT_DEVICE_ORIENTATION, EVENT_ERROR, EVENT_FRAME, EVENT_LOST, EVENT_POSE, EVENT_PROCESS, EVENT_RESIZE, EVENT_SCREEN_ORIENTATION, EVENT_SELECT, EVENT_VISIBILITY, EVENT_XR_SESSION, GL_ERROR, HTML_ERROR, PROJECT_MODE_FACE, PROJECT_MODE_IMAGE, PROJECT_MODE_MIX, PROJECT_MODE_QR, PROJECT_MODE_SLAM_3DOF, PROJECT_MODE_SLAM_WEBXR, type TEventDetectedData, type TEventLostData, type TEventPoseData, TRIGGER_MODE_FACE, TRIGGER_MODE_IMAGE, TRIGGER_MODE_QR, TRIGGER_MODE_SLAM_WEBXR, type TTriggerSize, type TViewportSizes, type TXRViewerPose, VIDEO_ERROR, WORKER_ERROR, XR_ERROR, WAS as default };
334
+ export { ANCHOR_TYPE_BOTTOM_LEFT, ANCHOR_TYPE_BOTTOM_LIP, ANCHOR_TYPE_BOTTOM_RIGHT, ANCHOR_TYPE_CENTER, ANCHOR_TYPE_CHIN, ANCHOR_TYPE_LEFT_EAR, ANCHOR_TYPE_LEFT_EYE, ANCHOR_TYPE_LEFT_EYEBROW, ANCHOR_TYPE_NOSE_BASE, ANCHOR_TYPE_NOSE_BRIDGE, ANCHOR_TYPE_NOSE_TIP, ANCHOR_TYPE_ORIGIN, ANCHOR_TYPE_RIGHT_EAR, ANCHOR_TYPE_RIGHT_EYE, ANCHOR_TYPE_RIGHT_EYEBROW, ANCHOR_TYPE_TOP_LEFT, ANCHOR_TYPE_TOP_RIGHT, DATA_ERROR, DEVICE_ERROR, EVENT_DETECTED, EVENT_DEVICE_ORIENTATION, EVENT_ERROR, EVENT_FRAME, EVENT_LOST, EVENT_POSE, EVENT_PROCESS, EVENT_RESIZE, EVENT_SCREEN_ORIENTATION, EVENT_VISIBILITY, EVENT_XR_PAN_MOVE, EVENT_XR_PAN_START, EVENT_XR_PINCH, EVENT_XR_PINCH_START, EVENT_XR_ROTATE, EVENT_XR_ROTATE_START, EVENT_XR_SELECT, EVENT_XR_SESSION, EVENT_XR_VIEWER_POSE, GL_ERROR, HTML_ERROR, PROJECT_MODE_FACE, PROJECT_MODE_IMAGE, PROJECT_MODE_MIX, PROJECT_MODE_QR, PROJECT_MODE_SLAM_3DOF, PROJECT_MODE_SLAM_WEBXR, type TEventDetectedData, type TEventLostData, type TEventPoseData, TRIGGER_MODE_FACE, TRIGGER_MODE_IMAGE, TRIGGER_MODE_QR, TRIGGER_MODE_SLAM_WEBXR, type TSizes, type TTriggerSize, type TViewportSizes, type TXRViewerPose, VIDEO_ERROR, WORKER_ERROR, type XREvent, XR_ERROR, WAS as default };