@zappar/zappar-cv 3.0.1-beta.6 → 3.1.0-beta.1

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.
Files changed (43) hide show
  1. package/README.md +2 -2
  2. package/lib/android-bridge-message-handler.d.ts +11 -0
  3. package/lib/android-bridge-message-handler.js +167 -0
  4. package/lib/array-from-string.d.ts +2 -0
  5. package/lib/array-from-string.js +48 -0
  6. package/lib/bridged-camera-source.d.ts +39 -0
  7. package/lib/bridged-camera-source.js +383 -0
  8. package/lib/bridged-message-parser.d.ts +12 -0
  9. package/lib/bridged-message-parser.js +56 -0
  10. package/lib/bridged-message.d.ts +64 -0
  11. package/lib/bridged-message.js +1 -0
  12. package/lib/bridged-world-tracker.d.ts +20 -0
  13. package/lib/bridged-world-tracker.js +426 -0
  14. package/lib/camera-source-map.d.ts +2 -1
  15. package/lib/camera-source-map.js +4 -1
  16. package/lib/drawmesh.d.ts +14 -0
  17. package/lib/drawmesh.js +123 -0
  18. package/lib/drawquad.d.ts +2 -0
  19. package/lib/drawquad.js +99 -0
  20. package/lib/gen/zappar.d.ts +16 -0
  21. package/lib/html-element-source.js +1 -1
  22. package/lib/index-standalone.js +1 -1
  23. package/lib/native.js +59 -14
  24. package/lib/options.d.ts +1 -0
  25. package/lib/permission.js +6 -0
  26. package/lib/pipeline.js +2 -1
  27. package/lib/profile.js +2 -1
  28. package/lib/source.d.ts +1 -0
  29. package/lib/version.d.ts +1 -1
  30. package/lib/version.js +1 -1
  31. package/lib/worker-server.js +1 -1
  32. package/lib/yuv-conversion-gl.d.ts +44 -0
  33. package/lib/yuv-conversion-gl.js +416 -0
  34. package/lib/zappar-cv.js +1 -1
  35. package/lib/zappar-cv.wasm +0 -0
  36. package/package.json +6 -16
  37. package/umd/287.zappar-cv.js +1 -0
  38. package/umd/{d4dad9f6d6bd944162fa.wasm → 641e1456d6d56783d581.wasm} +0 -0
  39. package/umd/867.zappar-cv.js +1 -1
  40. package/umd/zappar-cv-ceres.worker.js +1 -0
  41. package/umd/zappar-cv.js +1 -1
  42. package/umd/zappar-cv.worker.js +1 -1
  43. package/umd/751.zappar-cv.js +0 -1
@@ -0,0 +1,56 @@
1
+ const decoder = new TextDecoder();
2
+ const binaryReplyHeader = new Uint8Array([0x5A, 0x50, 0x52, 0x4D]); // "ZPRM"
3
+ const binaryReplyHeader_u16 = new Uint16Array(binaryReplyHeader.buffer);
4
+ export const BridgeArrayBufferHeader_u32 = (new Uint32Array(binaryReplyHeader.buffer))[0];
5
+ export function hasBridgeArrayBufferHeader(str) {
6
+ if (str.length < 16)
7
+ return false;
8
+ if (str.charCodeAt(0) !== binaryReplyHeader_u16[0])
9
+ return false;
10
+ if (str.charCodeAt(1) !== binaryReplyHeader_u16[1])
11
+ return false;
12
+ return true;
13
+ }
14
+ // Temporary typed arrays to do reply ID extraction without generating any garbage
15
+ const binaryReplyMessageId = new Uint32Array(1);
16
+ const binaryReplyMessageId_u16 = new Uint16Array(binaryReplyMessageId.buffer);
17
+ export function replyIdFromBridgeArrayBuffer(str) {
18
+ if (str.length < 16)
19
+ return 0xFFFFFFFF;
20
+ binaryReplyMessageId_u16[0] = str.charCodeAt(2);
21
+ binaryReplyMessageId_u16[1] = str.charCodeAt(3);
22
+ return binaryReplyMessageId[0];
23
+ }
24
+ export function parseBridgeArrayBuffer(ab) {
25
+ if (ab.byteLength < 32)
26
+ return;
27
+ let offset = 0;
28
+ const buffer32 = new Uint32Array(ab);
29
+ if (buffer32[0] !== BridgeArrayBufferHeader_u32)
30
+ return;
31
+ offset += 4;
32
+ const replyID = buffer32[offset >> 2];
33
+ offset += 4;
34
+ const jsonLength = buffer32[offset >> 2];
35
+ offset += 4;
36
+ const jsonData = new Uint8Array(ab, offset, jsonLength);
37
+ const json = JSON.parse(decoder.decode(jsonData));
38
+ offset += jsonLength;
39
+ offset = ((offset + 15) >> 4) << 4; // Padding to 16 byte alignment
40
+ const binaryBufferLength = buffer32[offset >> 2];
41
+ offset += 4;
42
+ offset += 12; // Padding
43
+ return {
44
+ replyID,
45
+ json,
46
+ uint8ArrayForBinaryBufferOffset: (o, length) => {
47
+ return new Uint8Array(ab, offset + o, length);
48
+ },
49
+ floatArrayForBinaryBufferOffset: (o, length) => {
50
+ return new Float32Array(ab, offset + o, length / 4);
51
+ },
52
+ uint32ArrayForBinaryBufferOffset: (o, length) => {
53
+ return new Uint32Array(ab, offset + o, length / 4);
54
+ }
55
+ };
56
+ }
@@ -0,0 +1,64 @@
1
+ import { anchor_status_t, world_tracker_quality_t } from './gen/zappar-native';
2
+ import { UvLayout } from './yuv-conversion-gl';
3
+ export interface WTData {
4
+ world_anchor_status: anchor_status_t;
5
+ world_anchor_pose: Float32Array | number[];
6
+ ground_anchor_status: anchor_status_t;
7
+ ground_anchor_pose: Float32Array | number[];
8
+ plane_anchors: PlaneAnchorData[];
9
+ custom_anchors: CustomAnchorData[];
10
+ mesh_anchors: MeshAnchorData[];
11
+ quality: world_tracker_quality_t;
12
+ }
13
+ export interface PlaneAnchorData {
14
+ id: string;
15
+ horizontal: boolean;
16
+ status: anchor_status_t;
17
+ pose: Float32Array | number[];
18
+ boundary: Float32Array | number[];
19
+ boundaryVersion: number;
20
+ }
21
+ export interface CustomAnchorData {
22
+ id: number;
23
+ status: anchor_status_t;
24
+ pose: Float32Array | number[];
25
+ poseVersion: number;
26
+ }
27
+ export interface MeshAnchorData {
28
+ id: string;
29
+ pose: Float32Array | number[];
30
+ status: anchor_status_t;
31
+ vertices: {
32
+ binaryOffset: number;
33
+ binaryLength: number;
34
+ offset: number;
35
+ stride: number;
36
+ count: number;
37
+ format: number;
38
+ componentsPerVector: number;
39
+ };
40
+ indices: {
41
+ binaryOffset: number;
42
+ binaryLength: number;
43
+ bytesPerIndex: number;
44
+ indexCountPerPrimitive: number;
45
+ count: number;
46
+ primitiveType: number;
47
+ };
48
+ }
49
+ export interface BridgedMessage {
50
+ frameNo: number;
51
+ cameraModel: Float32Array | [number, number, number, number, number, number];
52
+ dataWidth: number;
53
+ dataHeight: number;
54
+ dataBinaryBufferOffset: number;
55
+ dataBinaryBufferLength: number;
56
+ yWidth: number;
57
+ yHeight: number;
58
+ uvWidth: number;
59
+ uvHeight: number;
60
+ uvLayout?: UvLayout;
61
+ previewBinaryBufferOffset: number;
62
+ previewBinaryBufferLength: number;
63
+ wtData: WTData;
64
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { Zappar } from ".";
2
+ import { Pipeline } from "./pipeline";
3
+ export declare class BridgedWorldTracker {
4
+ static IsSupported(): boolean;
5
+ private static _sharedInstance;
6
+ static SharedInstance(): BridgedWorldTracker;
7
+ private _latestId;
8
+ private _wtStateById;
9
+ private _anchorStateById;
10
+ private _identityPose;
11
+ private _emptyArray;
12
+ private _getWtState;
13
+ private _getAnchorState;
14
+ private _getWtDataFromPipeline;
15
+ private _getWtData;
16
+ private _getFrameData;
17
+ private _notifyOptionsUpdated;
18
+ getCombinedOptionsForPipeline(p: Pipeline): number;
19
+ impl: Partial<Zappar>;
20
+ }
@@ -0,0 +1,426 @@
1
+ import { BridgedCameraSource } from "./bridged-camera-source";
2
+ import { anchor_status_t, plane_orientation_t } from "./gen/zappar";
3
+ import { Pipeline } from "./pipeline";
4
+ const _emptyUint8Array = new Uint8Array(0);
5
+ export class BridgedWorldTracker {
6
+ constructor() {
7
+ this._latestId = 1;
8
+ this._wtStateById = new Map();
9
+ this._anchorStateById = new Map();
10
+ this._identityPose = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
11
+ this._emptyArray = new Float32Array([]);
12
+ this.impl = {
13
+ world_tracker_create: (pipeline) => {
14
+ let p = Pipeline.get(pipeline);
15
+ if (!p)
16
+ throw new Error("Invalid pipeline in world_tracker_create");
17
+ let newId = (this._latestId++);
18
+ let s = {
19
+ pipeline: p,
20
+ enabled: true,
21
+ horizontal_plane_detection_enabled: true,
22
+ vertical_plane_detection_enabled: false,
23
+ world_anchor_id: 'world',
24
+ ground_anchor_id: 'ground',
25
+ tracks_data_enabled: false,
26
+ projections_data_enabled: false,
27
+ mesh_anchors_enabled: false
28
+ };
29
+ this._wtStateById.set(newId, s);
30
+ return newId;
31
+ },
32
+ world_tracker_destroy: (o) => {
33
+ let s = this._getWtState(o);
34
+ this._wtStateById.delete(o);
35
+ },
36
+ world_tracker_enabled: (o) => {
37
+ let s = this._getWtState(o);
38
+ return s.enabled;
39
+ },
40
+ world_tracker_enabled_set: (o, enabled) => {
41
+ let s = this._getWtState(o);
42
+ s.enabled = enabled;
43
+ this._notifyOptionsUpdated(s.pipeline);
44
+ },
45
+ world_tracker_quality: (o) => {
46
+ let wtData = this._getWtData(o);
47
+ if (!wtData)
48
+ return 0;
49
+ return wtData.quality;
50
+ },
51
+ world_tracker_horizontal_plane_detection_enabled: (o) => {
52
+ let s = this._getWtState(o);
53
+ return s.horizontal_plane_detection_enabled;
54
+ },
55
+ world_tracker_horizontal_plane_detection_enabled_set: (o, enabled) => {
56
+ let s = this._getWtState(o);
57
+ s.horizontal_plane_detection_enabled = enabled;
58
+ this._notifyOptionsUpdated(s.pipeline);
59
+ },
60
+ world_tracker_vertical_plane_detection_enabled: (o) => {
61
+ let s = this._getWtState(o);
62
+ return s.vertical_plane_detection_enabled;
63
+ },
64
+ world_tracker_vertical_plane_detection_enabled_set: (o, enabled) => {
65
+ let s = this._getWtState(o);
66
+ s.vertical_plane_detection_enabled = enabled;
67
+ this._notifyOptionsUpdated(s.pipeline);
68
+ },
69
+ world_tracker_plane_anchor_count: (o) => {
70
+ let wtData = this._getWtData(o);
71
+ let plane_anchors = wtData === null || wtData === void 0 ? void 0 : wtData.plane_anchors;
72
+ if (!plane_anchors)
73
+ return 0;
74
+ return plane_anchors.length;
75
+ },
76
+ world_tracker_plane_anchor_id: (o, indx) => {
77
+ var _a, _b, _c;
78
+ let wtData = this._getWtData(o);
79
+ return (_c = (_b = (_a = wtData === null || wtData === void 0 ? void 0 : wtData.plane_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "";
80
+ },
81
+ world_tracker_plane_anchor_pose_raw: (o, indx) => {
82
+ var _a, _b;
83
+ let wtData = this._getWtData(o);
84
+ let pose = (_b = (_a = wtData === null || wtData === void 0 ? void 0 : wtData.plane_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.pose;
85
+ if (pose === undefined)
86
+ return this._identityPose;
87
+ if (Array.isArray(pose)) {
88
+ pose = new Float32Array(pose);
89
+ wtData.plane_anchors[indx].pose = pose;
90
+ }
91
+ return pose;
92
+ },
93
+ world_tracker_plane_anchor_status: (o, indx) => {
94
+ var _a, _b, _c, _d;
95
+ return (_d = (_c = (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.plane_anchors) === null || _b === void 0 ? void 0 : _b[indx]) === null || _c === void 0 ? void 0 : _c.status) !== null && _d !== void 0 ? _d : anchor_status_t.ANCHOR_STATUS_STOPPED;
96
+ },
97
+ world_tracker_plane_anchor_polygon_data_size: (o, indx) => {
98
+ var _a, _b, _c, _d, _e;
99
+ return (_e = (_d = (_c = (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.plane_anchors) === null || _b === void 0 ? void 0 : _b[indx]) === null || _c === void 0 ? void 0 : _c.boundary) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
100
+ },
101
+ world_tracker_plane_anchor_polygon_data: (o, indx) => {
102
+ var _a, _b, _c;
103
+ let boundary = (_c = (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.plane_anchors) === null || _b === void 0 ? void 0 : _b[indx]) === null || _c === void 0 ? void 0 : _c.boundary;
104
+ if (!boundary)
105
+ return this._emptyArray;
106
+ if (Array.isArray(boundary)) {
107
+ boundary = new Float32Array(boundary);
108
+ this._getWtData(o).plane_anchors[indx].boundary = boundary;
109
+ }
110
+ return boundary;
111
+ },
112
+ world_tracker_plane_anchor_polygon_version: (o, indx) => {
113
+ var _a, _b, _c, _d;
114
+ return (_d = (_c = (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.plane_anchors) === null || _b === void 0 ? void 0 : _b[indx]) === null || _c === void 0 ? void 0 : _c.boundaryVersion) !== null && _d !== void 0 ? _d : 0;
115
+ },
116
+ world_tracker_plane_anchor_orientation: (o, indx) => {
117
+ var _a, _b, _c, _d;
118
+ return ((_d = (_c = (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.plane_anchors) === null || _b === void 0 ? void 0 : _b[indx]) === null || _c === void 0 ? void 0 : _c.horizontal) !== null && _d !== void 0 ? _d : true) ? plane_orientation_t.PLANE_ORIENTATION_HORIZONTAL : plane_orientation_t.PLANE_ORIENTATION_VERTICAL;
119
+ },
120
+ world_tracker_world_anchor_status: (o) => {
121
+ var _a, _b;
122
+ return (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.world_anchor_status) !== null && _b !== void 0 ? _b : anchor_status_t.ANCHOR_STATUS_INITIALIZING;
123
+ },
124
+ world_tracker_world_anchor_id: (o) => {
125
+ let s = this._getWtState(o);
126
+ return s.world_anchor_id;
127
+ },
128
+ world_tracker_world_anchor_pose_raw: (o) => {
129
+ let wtData = this._getWtData(o);
130
+ let pose = wtData === null || wtData === void 0 ? void 0 : wtData.world_anchor_pose;
131
+ if (pose === undefined)
132
+ return this._identityPose;
133
+ if (Array.isArray(pose)) {
134
+ pose = new Float32Array(pose);
135
+ wtData.world_anchor_pose = pose;
136
+ }
137
+ return pose;
138
+ },
139
+ world_tracker_ground_anchor_status: (o) => {
140
+ var _a, _b;
141
+ return (_b = (_a = this._getWtData(o)) === null || _a === void 0 ? void 0 : _a.ground_anchor_status) !== null && _b !== void 0 ? _b : anchor_status_t.ANCHOR_STATUS_INITIALIZING;
142
+ },
143
+ world_tracker_ground_anchor_id: (o) => {
144
+ let s = this._getWtState(o);
145
+ return s.ground_anchor_id;
146
+ },
147
+ world_tracker_ground_anchor_pose_raw: (o) => {
148
+ let wtData = this._getWtData(o);
149
+ let pose = wtData === null || wtData === void 0 ? void 0 : wtData.ground_anchor_pose;
150
+ if (pose === undefined)
151
+ return this._identityPose;
152
+ if (Array.isArray(pose)) {
153
+ pose = new Float32Array(pose);
154
+ wtData.ground_anchor_pose = pose;
155
+ }
156
+ return pose;
157
+ },
158
+ world_tracker_reset: (o) => {
159
+ // Reset local pose_version state
160
+ for (const entry of this._anchorStateById.values()) {
161
+ if (entry.wt === o)
162
+ entry.pose_version = 0;
163
+ }
164
+ let s = this._getWtState(o);
165
+ let source = s.pipeline.currentCameraSource;
166
+ if (source instanceof BridgedCameraSource) {
167
+ source.resetTracking();
168
+ }
169
+ },
170
+ world_tracker_tracks_data_enabled: (o) => {
171
+ let s = this._getWtState(o);
172
+ return s.tracks_data_enabled;
173
+ },
174
+ world_tracker_tracks_data_enabled_set: (o, tracks_data_enabled) => {
175
+ let s = this._getWtState(o);
176
+ s.tracks_data_enabled = tracks_data_enabled;
177
+ this._notifyOptionsUpdated(s.pipeline);
178
+ },
179
+ world_tracker_tracks_data_size: (o) => {
180
+ // Stub
181
+ let s = this._getWtState(o);
182
+ return 0;
183
+ },
184
+ world_tracker_tracks_data: (o) => {
185
+ // Stub
186
+ let s = this._getWtState(o);
187
+ return this._emptyArray;
188
+ },
189
+ world_tracker_tracks_type_data_size: (o) => {
190
+ // Stub
191
+ let s = this._getWtState(o);
192
+ return 0;
193
+ },
194
+ world_tracker_tracks_type_data: (o) => {
195
+ // Stub
196
+ return _emptyUint8Array;
197
+ },
198
+ world_tracker_projections_data_enabled: (o) => {
199
+ let s = this._getWtState(o);
200
+ return s.projections_data_enabled;
201
+ },
202
+ world_tracker_projections_data_enabled_set: (o, projections_data_enabled) => {
203
+ let s = this._getWtState(o);
204
+ s.projections_data_enabled = projections_data_enabled;
205
+ this._notifyOptionsUpdated(s.pipeline);
206
+ },
207
+ world_tracker_projections_data_size: (o) => {
208
+ // Stub
209
+ let s = this._getWtState(o);
210
+ return 0;
211
+ },
212
+ world_tracker_projections_data: (o) => {
213
+ // Stub
214
+ let s = this._getWtState(o);
215
+ return this._emptyArray;
216
+ },
217
+ // #### custom_anchor ####
218
+ custom_anchor_create: (pipeline, worldtracker, id) => {
219
+ let newId = (this._latestId++);
220
+ let wtState = this._getWtState(worldtracker);
221
+ let s = {
222
+ pipeline: wtState.pipeline,
223
+ wt: worldtracker,
224
+ pose_version: 0,
225
+ anchor_id: id,
226
+ };
227
+ this._anchorStateById.set(newId, s);
228
+ return newId;
229
+ },
230
+ custom_anchor_destroy: (o) => {
231
+ let s = this._getAnchorState(o);
232
+ this._anchorStateById.delete(o);
233
+ },
234
+ custom_anchor_status: (o) => {
235
+ var _a, _b;
236
+ let s = this._getAnchorState(o);
237
+ let wtData = this._getWtDataFromPipeline(s.pipeline);
238
+ const anchorData = ((_a = wtData === null || wtData === void 0 ? void 0 : wtData.custom_anchors) !== null && _a !== void 0 ? _a : []).find(entry => entry.id === o);
239
+ return (_b = anchorData === null || anchorData === void 0 ? void 0 : anchorData.status) !== null && _b !== void 0 ? _b : anchor_status_t.ANCHOR_STATUS_INITIALIZING;
240
+ },
241
+ custom_anchor_pose_version: (o) => {
242
+ var _a, _b;
243
+ let s = this._getAnchorState(o);
244
+ let wtData = this._getWtDataFromPipeline(s.pipeline);
245
+ const anchorData = ((_a = wtData === null || wtData === void 0 ? void 0 : wtData.custom_anchors) !== null && _a !== void 0 ? _a : []).find(entry => entry.id === o);
246
+ return (_b = anchorData === null || anchorData === void 0 ? void 0 : anchorData.poseVersion) !== null && _b !== void 0 ? _b : -1;
247
+ },
248
+ custom_anchor_pose_raw: (o) => {
249
+ var _a;
250
+ let s = this._getAnchorState(o);
251
+ let wtData = this._getWtDataFromPipeline(s.pipeline);
252
+ const anchorData = ((_a = wtData === null || wtData === void 0 ? void 0 : wtData.custom_anchors) !== null && _a !== void 0 ? _a : []).find(entry => entry.id === o);
253
+ if (!anchorData)
254
+ return this._identityPose;
255
+ let pose = anchorData === null || anchorData === void 0 ? void 0 : anchorData.pose;
256
+ if (pose === undefined)
257
+ return this._identityPose;
258
+ if (Array.isArray(pose)) {
259
+ pose = new Float32Array(pose);
260
+ anchorData.pose = pose;
261
+ }
262
+ return pose;
263
+ },
264
+ custom_anchor_pose_set: (o, pose) => {
265
+ var _a, _b;
266
+ let s = this._getAnchorState(o);
267
+ s.pose_version++;
268
+ let source = (_b = (_a = s.pipeline) === null || _a === void 0 ? void 0 : _a.getCurrentCameraInfo()) === null || _b === void 0 ? void 0 : _b.cameraSource;
269
+ if (source instanceof BridgedCameraSource) {
270
+ source.setCustomAnchorPose(o, s.pose_version, pose);
271
+ }
272
+ },
273
+ custom_anchor_pose_set_with_parent: (o, pose, anchor_id) => {
274
+ var _a, _b;
275
+ (_b = (_a = this.impl).custom_anchor_pose_set) === null || _b === void 0 ? void 0 : _b.call(_a, o, pose);
276
+ },
277
+ world_tracker_mesh_anchor_count: o => {
278
+ var _a, _b;
279
+ const data = this._getWtData(o);
280
+ return (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
281
+ },
282
+ world_tracker_mesh_anchor_id: (o, indx) => {
283
+ var _a, _b, _c;
284
+ const data = this._getWtData(o);
285
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "";
286
+ },
287
+ world_tracker_mesh_anchor_indices: (o, indx) => {
288
+ var _a, _b;
289
+ const data = this._getWtData(o);
290
+ const { binaryLength, binaryOffset } = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.indices;
291
+ if (binaryLength === undefined || binaryOffset === undefined)
292
+ return new Uint32Array();
293
+ const frameData = this._getFrameData(o);
294
+ if (!frameData)
295
+ return new Uint32Array();
296
+ return frameData.uint32ArrayForBinaryBufferOffset(binaryOffset, binaryLength);
297
+ },
298
+ world_tracker_mesh_anchor_indices_count: (o, indx) => {
299
+ var _a, _b, _c;
300
+ const data = this._getWtData(o);
301
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.indices.count) !== null && _c !== void 0 ? _c : 0;
302
+ },
303
+ world_tracker_mesh_anchor_indices_size: (o, indx) => {
304
+ var _a, _b, _c;
305
+ return (_c = (_b = (_a = this.impl).world_tracker_mesh_anchor_indices) === null || _b === void 0 ? void 0 : _b.call(_a, o, indx).byteLength) !== null && _c !== void 0 ? _c : 0;
306
+ },
307
+ world_tracker_mesh_anchor_vertices: (o, indx) => {
308
+ var _a, _b;
309
+ const data = this._getWtData(o);
310
+ const { binaryLength, binaryOffset } = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.vertices;
311
+ if (binaryLength === undefined || binaryOffset === undefined)
312
+ return new Float32Array();
313
+ const frameData = this._getFrameData(o);
314
+ if (!frameData)
315
+ return new Float32Array();
316
+ return frameData.floatArrayForBinaryBufferOffset(binaryOffset, binaryLength);
317
+ },
318
+ world_tracker_mesh_anchor_vertices_count: (o, indx) => {
319
+ var _a, _b, _c;
320
+ const data = this._getWtData(o);
321
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.vertices.count) !== null && _c !== void 0 ? _c : 0;
322
+ },
323
+ world_tracker_mesh_anchor_vertices_size: (o, indx) => {
324
+ var _a, _b, _c;
325
+ return (_c = (_b = (_a = this.impl).world_tracker_mesh_anchor_vertices) === null || _b === void 0 ? void 0 : _b.call(_a, o, indx).byteLength) !== null && _c !== void 0 ? _c : 0;
326
+ },
327
+ world_tracker_mesh_anchor_vertices_offset: (o, indx) => {
328
+ var _a, _b, _c;
329
+ const data = this._getWtData(o);
330
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.vertices.offset) !== null && _c !== void 0 ? _c : 0;
331
+ },
332
+ world_tracker_mesh_anchor_vertices_stride: (o, indx) => {
333
+ var _a, _b, _c;
334
+ const data = this._getWtData(o);
335
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.vertices.stride) !== null && _c !== void 0 ? _c : 0;
336
+ },
337
+ world_tracker_mesh_anchor_pose_raw: (o, indx) => {
338
+ var _a, _b;
339
+ let wtData = this._getWtData(o);
340
+ let pose = (_b = (_a = wtData === null || wtData === void 0 ? void 0 : wtData.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.pose;
341
+ if (pose === undefined)
342
+ return this._identityPose;
343
+ if (Array.isArray(pose)) {
344
+ pose = new Float32Array(pose);
345
+ wtData.mesh_anchors[indx].pose = pose;
346
+ }
347
+ return pose;
348
+ },
349
+ world_tracker_mesh_anchor_status: (o, indx) => {
350
+ var _a, _b, _c;
351
+ const data = this._getWtData(o);
352
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.mesh_anchors) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.status) !== null && _c !== void 0 ? _c : anchor_status_t.ANCHOR_STATUS_STOPPED;
353
+ },
354
+ world_tracker_mesh_anchors_enabled: (o) => {
355
+ let s = this._getWtState(o);
356
+ return s.mesh_anchors_enabled;
357
+ },
358
+ world_tracker_mesh_anchors_enabled_set: (o, enabled) => {
359
+ let s = this._getWtState(o);
360
+ s.mesh_anchors_enabled = enabled;
361
+ this._notifyOptionsUpdated(s.pipeline);
362
+ },
363
+ };
364
+ }
365
+ static IsSupported() {
366
+ return BridgedCameraSource.IsSupported();
367
+ }
368
+ static SharedInstance() {
369
+ if (!this._sharedInstance) {
370
+ this._sharedInstance = new BridgedWorldTracker();
371
+ }
372
+ return this._sharedInstance;
373
+ }
374
+ _getWtState(o) {
375
+ let s = this._wtStateById.get(o);
376
+ if (!s)
377
+ throw new Error("This object has been destroyed");
378
+ return s;
379
+ }
380
+ _getAnchorState(o) {
381
+ let s = this._anchorStateById.get(o);
382
+ if (!s)
383
+ throw new Error("This object has been destroyed");
384
+ return s;
385
+ }
386
+ _getWtDataFromPipeline(p) {
387
+ var _a, _b, _c;
388
+ return (_c = (_b = (_a = p === null || p === void 0 ? void 0 : p.getCurrentCameraInfo()) === null || _a === void 0 ? void 0 : _a.cameraSourceData) === null || _b === void 0 ? void 0 : _b.frameInfo) === null || _c === void 0 ? void 0 : _c.wtData;
389
+ }
390
+ _getWtData(o) {
391
+ let s = this._getWtState(o);
392
+ return this._getWtDataFromPipeline(s.pipeline);
393
+ }
394
+ _getFrameData(o) {
395
+ var _a, _b, _c;
396
+ let s = this._getWtState(o);
397
+ return (_c = (_b = (_a = s === null || s === void 0 ? void 0 : s.pipeline) === null || _a === void 0 ? void 0 : _a.getCurrentCameraInfo()) === null || _b === void 0 ? void 0 : _b.cameraSourceData) === null || _c === void 0 ? void 0 : _c.frameData;
398
+ }
399
+ _notifyOptionsUpdated(p) {
400
+ if (p.currentCameraSource instanceof BridgedCameraSource) {
401
+ p.currentCameraSource.optionsUpdated(this.getCombinedOptionsForPipeline(p));
402
+ }
403
+ }
404
+ getCombinedOptionsForPipeline(p) {
405
+ let options = 0;
406
+ for (let state of this._wtStateById.values()) {
407
+ if (state.pipeline != p)
408
+ continue;
409
+ if (!state.enabled)
410
+ continue;
411
+ options |= 1;
412
+ if (state.horizontal_plane_detection_enabled)
413
+ options |= 2;
414
+ if (state.vertical_plane_detection_enabled)
415
+ options |= 4;
416
+ if (state.tracks_data_enabled)
417
+ options |= 8;
418
+ if (state.projections_data_enabled)
419
+ options |= 16;
420
+ if (state.mesh_anchors_enabled)
421
+ options |= 32;
422
+ }
423
+ return options;
424
+ }
425
+ }
426
+ BridgedWorldTracker._sharedInstance = null;
@@ -1,8 +1,9 @@
1
+ import { BridgedCameraSource } from "./bridged-camera-source";
1
2
  import { CameraSource } from "./camera-source";
2
3
  import { zappar_camera_source_t, zappar_pipeline_t } from "./gen/zappar";
3
4
  import { ImageBitmapCameraSource } from "./imagebitmap-camera-source";
4
5
  import { MSTPCameraSource } from "./mstp-camera-source";
5
- export declare type CameraSourceType = CameraSource | MSTPCameraSource | ImageBitmapCameraSource;
6
+ export declare type CameraSourceType = CameraSource | MSTPCameraSource | ImageBitmapCameraSource | BridgedCameraSource;
6
7
  export declare function getNextCameraSourceId(): zappar_camera_source_t;
7
8
  export declare function setCameraSourceId(id: zappar_camera_source_t, c: CameraSourceType): void;
8
9
  export declare function getCameraSource(id: zappar_camera_source_t): CameraSourceType | undefined;
@@ -1,3 +1,4 @@
1
+ import { BridgedCameraSource } from "./bridged-camera-source";
1
2
  import { CameraSource } from "./camera-source";
2
3
  import { ImageBitmapCameraSource } from "./imagebitmap-camera-source";
3
4
  import { zcout } from "./loglevel";
@@ -19,7 +20,9 @@ export function deleteCameraSource(id) {
19
20
  }
20
21
  export function createCameraSource(p, deviceId) {
21
22
  let ret = getNextCameraSourceId();
22
- if (profile.preferMediaStreamTrackProcessorCamera &&
23
+ if (BridgedCameraSource.IsSupported() && deviceId === CameraSource.DEFAULT_DEVICE_ID)
24
+ setCameraSourceId(ret, new BridgedCameraSource(ret, p, deviceId));
25
+ else if (profile.preferMediaStreamTrackProcessorCamera &&
23
26
  'MediaStreamTrackProcessor' in window &&
24
27
  'MediaStreamTrackGenerator' in window)
25
28
  setCameraSourceId(ret, new MSTPCameraSource(ret, p, deviceId));
@@ -0,0 +1,14 @@
1
+ export declare class MeshDraw {
2
+ private _gl;
3
+ private _vbo;
4
+ private _uvbo;
5
+ private _ibo;
6
+ private _lastIndices;
7
+ private _shader;
8
+ constructor(_gl: WebGLRenderingContext);
9
+ dispose(): void;
10
+ private _generateIBO;
11
+ private _generateVBO;
12
+ draw(projectionMatrix: Float32Array, cameraMatrix: Float32Array, targetMatrix: Float32Array, vertices: Float32Array, indices: Uint32Array, vertexOffset: number, vertexStride: number, indicesCount: number): void;
13
+ private _getShader;
14
+ }