@zappar/zappar-cv 3.1.0-beta.3 → 3.2.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.
package/README.md CHANGED
@@ -18,8 +18,8 @@ npm i @zappar/zappar-cv
18
18
 
19
19
  You can use our CDN from within your HTML:
20
20
  ```
21
- <script src="https://libs.zappar.com/zappar-cv/3.1.0-beta.3/zappar-cv.js"></script>
21
+ <script src="https://libs.zappar.com/zappar-cv/3.2.0-beta.1/zappar-cv.js"></script>
22
22
  ```
23
23
 
24
24
  Or you can download and host our standalone JavaScript bundle:
25
- [https://libs.zappar.com/zappar-cv/3.1.0-beta.3/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.1.0-beta.3/zappar-cv.zip)
25
+ [https://libs.zappar.com/zappar-cv/3.2.0-beta.1/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.2.0-beta.1/zappar-cv.zip)
@@ -1,6 +1,16 @@
1
1
  import { camera_profile_t, zappar_camera_source_t, zappar_pipeline_t } from "./gen/zappar";
2
2
  import { CameraFrameInfo, Source } from "./source";
3
3
  import { zappar_custom_anchor_t } from "./gen/zappar-native";
4
+ export interface BridgeOptions {
5
+ worldTracking?: boolean;
6
+ horizontalPlaneDetection?: boolean;
7
+ verticalPlaneDetection?: boolean;
8
+ tracksData?: boolean;
9
+ projectionsData?: boolean;
10
+ meshAnchors?: boolean;
11
+ d3?: boolean;
12
+ d3MaxResolution?: boolean;
13
+ }
4
14
  export declare class BridgedCameraSource extends Source {
5
15
  private _impl;
6
16
  private _pipeline;
@@ -15,6 +25,7 @@ export declare class BridgedCameraSource extends Source {
15
25
  private _textureSizes;
16
26
  private _yuvConversion;
17
27
  private _decodeBuffers;
28
+ private _options;
18
29
  static IsSupported(): boolean;
19
30
  constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t, _deviceId: string);
20
31
  destroy(): void;
@@ -30,7 +41,8 @@ export declare class BridgedCameraSource extends Source {
30
41
  private _anchorPoseUint16;
31
42
  setCustomAnchorPose(anchor: zappar_custom_anchor_t, pose_version: number, pose: Float32Array): void;
32
43
  resetTracking(): void;
33
- optionsUpdated(options: number): void;
44
+ private _convertToBitmask;
45
+ optionsUpdated(options: BridgeOptions): void;
34
46
  private _lastTimestamp;
35
47
  private _deviceMotionListener;
36
48
  private _deviceOrientationListener;
@@ -21,6 +21,7 @@ import { AndroidBridgeMessageHandler } from "./android-bridge-message-handler";
21
21
  import { getSharedTracer } from "./tracing/sharedtracer";
22
22
  import { BridgedWorldTracker } from "./bridged-world-tracker";
23
23
  import { hasBridgeArrayBufferHeader, parseBridgeArrayBuffer } from "./bridged-message-parser";
24
+ import { BridgedD3Tracker } from "./bridged-d3-tracker";
24
25
  // Some no-op tracing helpers for concise code and good dead code removal in bundlers
25
26
  let tracer = null;
26
27
  let traceStart = (name) => { };
@@ -44,6 +45,7 @@ export class BridgedCameraSource extends Source {
44
45
  this._profile = camera_profile_t.DEFAULT;
45
46
  this._textureSizes = new Map();
46
47
  this._decodeBuffers = [];
48
+ this._options = {};
47
49
  this._frameInFlight = false;
48
50
  this._anchorPoseFloat32 = new Float32Array(16);
49
51
  this._anchorPoseUint16 = new Uint16Array(this._anchorPoseFloat32.buffer);
@@ -133,10 +135,11 @@ export class BridgedCameraSource extends Source {
133
135
  this._textureSizes.clear();
134
136
  this._isPaused = false;
135
137
  this._startDeviceMotion();
136
- let options = 0;
137
- if (p)
138
- options = BridgedWorldTracker.SharedInstance().getCombinedOptionsForPipeline(p);
139
- this._messageHandler.postMessage(`start${options}:${this._profile}`);
138
+ let options = {};
139
+ if (p) {
140
+ options = Object.assign(Object.assign({}, BridgedWorldTracker.SharedInstance().getCombinedOptionsForPipeline(p)), BridgedD3Tracker.SharedInstance().getCombinedOptionsForPipeline(p));
141
+ }
142
+ this._messageHandler.postMessage(`start${this._convertToBitmask(options)}:${this._profile}`);
140
143
  }
141
144
  getFrame(currentlyProcessing) {
142
145
  var _a, _b;
@@ -368,8 +371,28 @@ export class BridgedCameraSource extends Source {
368
371
  resetTracking() {
369
372
  this._messageHandler.postMessage('resetTracking');
370
373
  }
374
+ _convertToBitmask(options) {
375
+ let bitmask = 0;
376
+ if (options.worldTracking)
377
+ bitmask |= 1;
378
+ if (options.horizontalPlaneDetection)
379
+ bitmask |= 2;
380
+ if (options.verticalPlaneDetection)
381
+ bitmask |= 4;
382
+ if (options.tracksData)
383
+ bitmask |= 8;
384
+ if (options.projectionsData)
385
+ bitmask |= 16;
386
+ if (options.meshAnchors)
387
+ bitmask |= 32;
388
+ if (options.d3)
389
+ bitmask |= 64;
390
+ if (options.d3MaxResolution)
391
+ bitmask |= 128;
392
+ return bitmask;
393
+ }
371
394
  optionsUpdated(options) {
372
- this._messageHandler.postMessage(`setOptions${options}`);
395
+ this._messageHandler.postMessage(`setOptions${this._convertToBitmask(options)}`);
373
396
  }
374
397
  _startDeviceMotion() {
375
398
  window.addEventListener("devicemotion", this._deviceMotionListener);
@@ -0,0 +1,18 @@
1
+ import { BridgeOptions } from "./bridged-camera-source";
2
+ import { Pipeline } from "./pipeline";
3
+ import { Zappar } from ".";
4
+ export declare class BridgedD3Tracker {
5
+ static IsSupported(): boolean;
6
+ private static _sharedInstance;
7
+ static SharedInstance(): BridgedD3Tracker;
8
+ private _latestId;
9
+ private _d3StateById;
10
+ private _identityPose;
11
+ private _emptyArray;
12
+ private _getD3State;
13
+ private _getD3DataFromPipeline;
14
+ private _getD3Data;
15
+ private _notifyOptionsUpdated;
16
+ getCombinedOptionsForPipeline(p: Pipeline): BridgeOptions;
17
+ impl: Partial<Zappar>;
18
+ }
@@ -0,0 +1,195 @@
1
+ import { mat4 } from "gl-matrix";
2
+ import { BridgedCameraSource } from "./bridged-camera-source";
3
+ import { Pipeline } from "./pipeline";
4
+ export class BridgedD3Tracker {
5
+ constructor() {
6
+ this._latestId = 1;
7
+ this._d3StateById = new Map();
8
+ this._identityPose = new Float32Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
9
+ this._emptyArray = new Float32Array([]);
10
+ this.impl = {
11
+ d3_tracker_create: (pipeline) => {
12
+ const p = Pipeline.get(pipeline);
13
+ if (!p)
14
+ throw new Error("Invalid pipeline in d3_tracker_create");
15
+ let newId = (this._latestId++);
16
+ let s = {
17
+ pipeline: p,
18
+ enabled: true,
19
+ sizeById: Object.create(null),
20
+ maxResolution: false,
21
+ };
22
+ this._d3StateById.set(newId, s);
23
+ this._notifyOptionsUpdated(s.pipeline);
24
+ return newId;
25
+ },
26
+ d3_tracker_destroy: (o) => {
27
+ let s = this._getD3State(o);
28
+ this._d3StateById.delete(o);
29
+ },
30
+ d3_tracker_enabled: (o) => {
31
+ let s = this._getD3State(o);
32
+ return s.enabled;
33
+ },
34
+ d3_tracker_enabled_set: (o, enabled) => {
35
+ let s = this._getD3State(o);
36
+ s.enabled = enabled;
37
+ this._notifyOptionsUpdated(s.pipeline);
38
+ },
39
+ d3_tracker_process_max_resolution_set: (o, v) => {
40
+ let s = this._getD3State(o);
41
+ s.maxResolution = v;
42
+ this._notifyOptionsUpdated(s.pipeline);
43
+ },
44
+ d3_tracker_count: (o) => {
45
+ var _a, _b;
46
+ const data = this._getD3Data(o);
47
+ if (!Array.isArray(data === null || data === void 0 ? void 0 : data.detections))
48
+ return 0;
49
+ return (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
50
+ },
51
+ d3_tracker_id: (o, indx) => {
52
+ var _a, _b, _c;
53
+ const data = this._getD3Data(o);
54
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '';
55
+ },
56
+ d3_tracker_qr: (o, indx) => {
57
+ var _a, _b, _c;
58
+ const data = this._getD3Data(o);
59
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.qr) !== null && _c !== void 0 ? _c : '';
60
+ },
61
+ d3_tracker_pose_raw: (o, indx) => {
62
+ return this.impl.d3_tracker_pose0_raw(o, indx);
63
+ },
64
+ d3_tracker_pose0_raw: (o, indx) => {
65
+ var _a, _b, _c, _d, _e, _f;
66
+ const data = this._getD3Data(o);
67
+ let ret = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.worldPoses) === null || _c === void 0 ? void 0 : _c[0];
68
+ if (!ret)
69
+ return this._identityPose;
70
+ if (Array.isArray(ret))
71
+ ret = new Float32Array(ret);
72
+ let worldToCamera = data === null || data === void 0 ? void 0 : data.worldToCamera;
73
+ if (!worldToCamera)
74
+ this._identityPose;
75
+ if (Array.isArray(worldToCamera)) {
76
+ worldToCamera = new Float32Array(worldToCamera);
77
+ if (data)
78
+ data.worldToCamera = worldToCamera;
79
+ }
80
+ const computed = mat4.create();
81
+ mat4.multiply(computed, worldToCamera, ret);
82
+ const state = this._getD3State(o);
83
+ const id = (_e = (_d = data === null || data === void 0 ? void 0 : data.detections) === null || _d === void 0 ? void 0 : _d[indx]) === null || _e === void 0 ? void 0 : _e.id;
84
+ if (id && id.length > 0) {
85
+ const size = 0.5 * ((_f = state.sizeById[id]) !== null && _f !== void 0 ? _f : 2);
86
+ computed[12] *= size;
87
+ computed[13] *= size;
88
+ computed[14] *= size;
89
+ }
90
+ return computed;
91
+ },
92
+ d3_tracker_pose1_raw: (o, indx) => {
93
+ var _a, _b, _c, _d, _e, _f;
94
+ const data = this._getD3Data(o);
95
+ let ret = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.worldPoses) === null || _c === void 0 ? void 0 : _c[1];
96
+ if (!ret)
97
+ return this._identityPose;
98
+ if (Array.isArray(ret))
99
+ ret = new Float32Array(ret);
100
+ let worldToCamera = data === null || data === void 0 ? void 0 : data.worldToCamera;
101
+ if (!worldToCamera)
102
+ this._identityPose;
103
+ if (Array.isArray(worldToCamera)) {
104
+ worldToCamera = new Float32Array(worldToCamera);
105
+ if (data)
106
+ data.worldToCamera = worldToCamera;
107
+ }
108
+ const computed = mat4.create();
109
+ mat4.multiply(computed, worldToCamera, ret);
110
+ const state = this._getD3State(o);
111
+ const id = (_e = (_d = data === null || data === void 0 ? void 0 : data.detections) === null || _d === void 0 ? void 0 : _d[indx]) === null || _e === void 0 ? void 0 : _e.id;
112
+ if (id && id.length > 0) {
113
+ const size = 0.5 * ((_f = state.sizeById[id]) !== null && _f !== void 0 ? _f : 2);
114
+ computed[12] *= size;
115
+ computed[13] *= size;
116
+ computed[14] *= size;
117
+ }
118
+ return computed;
119
+ },
120
+ d3_tracker_landmarks_data: (o, indx) => {
121
+ var _a, _b;
122
+ const data = this._getD3Data(o);
123
+ let landmarks = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.landmarks;
124
+ if (!landmarks)
125
+ return this._emptyArray;
126
+ if (Array.isArray(landmarks)) {
127
+ landmarks = new Float32Array(landmarks);
128
+ data.detections[indx].landmarks = landmarks;
129
+ }
130
+ return landmarks;
131
+ },
132
+ d3_tracker_landmarks_data_size: (o, indx) => {
133
+ var _a, _b, _c, _d;
134
+ const data = this._getD3Data(o);
135
+ return (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.landmarks) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
136
+ },
137
+ d3_tracker_type: (o, indx) => {
138
+ var _a, _b, _c;
139
+ const data = this._getD3Data(o);
140
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 0;
141
+ },
142
+ d3_tracker_dense: (o, indx) => {
143
+ var _a, _b, _c;
144
+ const data = this._getD3Data(o);
145
+ return (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.detections) === null || _a === void 0 ? void 0 : _a[indx]) === null || _b === void 0 ? void 0 : _b.dense) !== null && _c !== void 0 ? _c : 0;
146
+ },
147
+ d3_tracker_size_for_id_set: (o, id, size) => {
148
+ const state = this._getD3State(o);
149
+ state.sizeById[id] = size;
150
+ },
151
+ };
152
+ }
153
+ static IsSupported() {
154
+ return BridgedCameraSource.IsSupported();
155
+ }
156
+ static SharedInstance() {
157
+ if (!this._sharedInstance) {
158
+ this._sharedInstance = new BridgedD3Tracker();
159
+ }
160
+ return this._sharedInstance;
161
+ }
162
+ _getD3State(o) {
163
+ let s = this._d3StateById.get(o);
164
+ if (!s)
165
+ throw new Error("This object has been destroyed");
166
+ return s;
167
+ }
168
+ _getD3DataFromPipeline(p) {
169
+ var _a, _b, _c;
170
+ 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.d3Data;
171
+ }
172
+ _getD3Data(o) {
173
+ let s = this._getD3State(o);
174
+ return this._getD3DataFromPipeline(s.pipeline);
175
+ }
176
+ _notifyOptionsUpdated(p) {
177
+ if (p.currentCameraSource instanceof BridgedCameraSource) {
178
+ p.currentCameraSource.optionsUpdated(this.getCombinedOptionsForPipeline(p));
179
+ }
180
+ }
181
+ getCombinedOptionsForPipeline(p) {
182
+ const options = {};
183
+ for (const state of this._d3StateById.values()) {
184
+ if (state.pipeline !== p)
185
+ continue;
186
+ if (!state.enabled)
187
+ continue;
188
+ options.d3 = true;
189
+ if (state.maxResolution)
190
+ options.d3MaxResolution = true;
191
+ }
192
+ return options;
193
+ }
194
+ }
195
+ BridgedD3Tracker._sharedInstance = null;
@@ -24,6 +24,19 @@ export interface CustomAnchorData {
24
24
  pose: Float32Array | number[];
25
25
  poseVersion: number;
26
26
  }
27
+ export interface D3Data {
28
+ worldToCamera: Float32Array | number[];
29
+ detections: D3Detection[];
30
+ }
31
+ export interface D3Detection {
32
+ id: string;
33
+ type: number;
34
+ qr?: string;
35
+ dense?: number;
36
+ worldPoses: (Float32Array | number[])[];
37
+ landmarks: Float32Array | number[];
38
+ scale: number;
39
+ }
27
40
  export interface MeshAnchorData {
28
41
  id: string;
29
42
  pose: Float32Array | number[];
@@ -61,4 +74,5 @@ export interface BridgedMessage {
61
74
  previewBinaryBufferOffset: number;
62
75
  previewBinaryBufferLength: number;
63
76
  wtData: WTData;
77
+ d3Data?: D3Data;
64
78
  }
@@ -1,4 +1,5 @@
1
1
  import { Zappar } from ".";
2
+ import { BridgeOptions } from "./bridged-camera-source";
2
3
  import { Pipeline } from "./pipeline";
3
4
  export declare class BridgedWorldTracker {
4
5
  static IsSupported(): boolean;
@@ -15,6 +16,6 @@ export declare class BridgedWorldTracker {
15
16
  private _getWtData;
16
17
  private _getFrameData;
17
18
  private _notifyOptionsUpdated;
18
- getCombinedOptionsForPipeline(p: Pipeline): number;
19
+ getCombinedOptionsForPipeline(p: Pipeline): BridgeOptions;
19
20
  impl: Partial<Zappar>;
20
21
  }
@@ -27,6 +27,7 @@ export class BridgedWorldTracker {
27
27
  mesh_anchors_enabled: false
28
28
  };
29
29
  this._wtStateById.set(newId, s);
30
+ this._notifyOptionsUpdated(s.pipeline);
30
31
  return newId;
31
32
  },
32
33
  world_tracker_destroy: (o) => {
@@ -402,23 +403,23 @@ export class BridgedWorldTracker {
402
403
  }
403
404
  }
404
405
  getCombinedOptionsForPipeline(p) {
405
- let options = 0;
406
+ const options = {};
406
407
  for (let state of this._wtStateById.values()) {
407
408
  if (state.pipeline != p)
408
409
  continue;
409
410
  if (!state.enabled)
410
411
  continue;
411
- options |= 1;
412
+ options.worldTracking = true;
412
413
  if (state.horizontal_plane_detection_enabled)
413
- options |= 2;
414
+ options.horizontalPlaneDetection = true;
414
415
  if (state.vertical_plane_detection_enabled)
415
- options |= 4;
416
+ options.verticalPlaneDetection = true;
416
417
  if (state.tracks_data_enabled)
417
- options |= 8;
418
+ options.tracksData = true;
418
419
  if (state.projections_data_enabled)
419
- options |= 16;
420
+ options.projectionsData = true;
420
421
  if (state.mesh_anchors_enabled)
421
- options |= 32;
422
+ options.meshAnchors = true;
422
423
  }
423
424
  return options;
424
425
  }
@@ -52,6 +52,9 @@ export declare type zappar_world_tracker_t = number & {
52
52
  export declare type zappar_custom_anchor_t = number & {
53
53
  _: 'zappar_custom_anchor_t';
54
54
  };
55
+ export declare type zappar_d3_tracker_t = number & {
56
+ _: 'zappar_d3_tracker_t';
57
+ };
55
58
  export interface zappar {
56
59
  log_level(): log_level_t;
57
60
  log_level_set(level: log_level_t): void;
@@ -172,4 +175,6 @@ export interface zappar {
172
175
  custom_anchor_pose_set_from_anchor_offset(o: zappar_custom_anchor_t, anchor_id: string, x: number, y: number, z: number, orientation: transform_orientation_t): void;
173
176
  custom_anchor_pose_set(o: zappar_custom_anchor_t, pose: Float32Array): void;
174
177
  custom_anchor_pose_set_with_parent(o: zappar_custom_anchor_t, pose: Float32Array, anchor_id: string): void;
178
+ d3_tracker_create(pipeline: zappar_pipeline_t): zappar_d3_tracker_t;
179
+ d3_tracker_destroy(o: zappar_d3_tracker_t): void;
175
180
  }
@@ -20,6 +20,7 @@ export declare class zappar_client {
20
20
  private _zapcode_tracker_state_by_instance;
21
21
  private _world_tracker_state_by_instance;
22
22
  private _custom_anchor_state_by_instance;
23
+ private _d3_tracker_state_by_instance;
23
24
  impl: zappar;
24
25
  processMessages(a: ArrayBuffer): void;
25
26
  }
@@ -23,6 +23,7 @@ export class zappar_client {
23
23
  this._zapcode_tracker_state_by_instance = new Map();
24
24
  this._world_tracker_state_by_instance = new Map();
25
25
  this._custom_anchor_state_by_instance = new Map();
26
+ this._d3_tracker_state_by_instance = new Map();
26
27
  this.impl = {
27
28
  log_level: () => {
28
29
  return this._globalState.log_level;
@@ -1047,6 +1048,35 @@ export class zappar_client {
1047
1048
  m.string(anchor_id);
1048
1049
  });
1049
1050
  },
1051
+ // #### d3_tracker ####
1052
+ d3_tracker_create: (pipeline) => {
1053
+ let newId = (this._latestId++);
1054
+ let s = {
1055
+ id: [],
1056
+ enabled: true,
1057
+ count: 0,
1058
+ qr: [],
1059
+ pose: [],
1060
+ type: [],
1061
+ dense: [],
1062
+ process_max_resolution: false,
1063
+ };
1064
+ this._d3_tracker_state_by_instance.set(newId, s);
1065
+ this.serializer.sendMessage(59, m => {
1066
+ m.type(newId);
1067
+ m.type(pipeline);
1068
+ });
1069
+ return newId;
1070
+ },
1071
+ d3_tracker_destroy: (o) => {
1072
+ let s = this._d3_tracker_state_by_instance.get(o);
1073
+ if (!s)
1074
+ throw new Error("This object has been destroyed");
1075
+ this._d3_tracker_state_by_instance.delete(o);
1076
+ this.serializer.sendMessage(60, m => {
1077
+ m.type(o);
1078
+ });
1079
+ },
1050
1080
  };
1051
1081
  }
1052
1082
  processMessages(a) {
@@ -362,6 +362,8 @@ export function getRuntimeObject(mod) {
362
362
  "number",
363
363
  "number", "string"
364
364
  ]);
365
+ let d3_tracker_create_wrapped = mod.cwrap("zappar_d3_tracker_create", "number", ["number"]);
366
+ let d3_tracker_destroy_wrapped = mod.cwrap("zappar_d3_tracker_destroy", null, ["number"]);
365
367
  let dataArrayArgLength = 32;
366
368
  let dataArrayArg = mod._malloc(dataArrayArgLength);
367
369
  let floatDataArrayArgLength = 16 * 4;
@@ -1059,5 +1061,12 @@ export function getRuntimeObject(mod) {
1059
1061
  let ret = custom_anchor_pose_set_with_parent_wrapped(o, arg_pose, arg_anchor_id);
1060
1062
  return ret;
1061
1063
  },
1064
+ d3_tracker_create: (pipeline) => {
1065
+ let arg_pipeline = pipeline;
1066
+ return d3_tracker_create_wrapped(arg_pipeline);
1067
+ },
1068
+ d3_tracker_destroy: () => {
1069
+ d3_tracker_destroy_wrapped();
1070
+ },
1062
1071
  };
1063
1072
  }
@@ -122,6 +122,9 @@ export declare type zappar_world_tracker_t = number & {
122
122
  export declare type zappar_custom_anchor_t = number & {
123
123
  _: 'zappar_custom_anchor_t';
124
124
  };
125
+ export declare type zappar_d3_tracker_t = number & {
126
+ _: 'zappar_d3_tracker_t';
127
+ };
125
128
  export interface zappar_cwrap {
126
129
  log_level(): log_level_t;
127
130
  log_level_set(level: log_level_t): void;
@@ -245,4 +248,6 @@ export interface zappar_cwrap {
245
248
  custom_anchor_pose_set_from_anchor_offset(o: zappar_custom_anchor_t, anchor_id: string, x: number, y: number, z: number, orientation: transform_orientation_t): void;
246
249
  custom_anchor_pose_set(o: zappar_custom_anchor_t, pose: Float32Array): void;
247
250
  custom_anchor_pose_set_with_parent(o: zappar_custom_anchor_t, pose: Float32Array, anchor_id: string): void;
251
+ d3_tracker_create(pipeline: zappar_pipeline_t): zappar_d3_tracker_t;
252
+ d3_tracker_destroy(o: zappar_d3_tracker_t): void;
248
253
  }
@@ -12,6 +12,7 @@ import { zappar_instant_world_tracker_t } from "./zappar-native";
12
12
  import { zappar_zapcode_tracker_t } from "./zappar-native";
13
13
  import { zappar_world_tracker_t } from "./zappar-native";
14
14
  import { zappar_custom_anchor_t } from "./zappar-native";
15
+ import { zappar_d3_tracker_t } from "./zappar-native";
15
16
  export declare class zappar_server {
16
17
  private _impl;
17
18
  private _sender;
@@ -42,6 +43,8 @@ export declare class zappar_server {
42
43
  _world_tracker_by_instance: Map<number, zappar_world_tracker_t>;
43
44
  _pipeline_id_by_custom_anchor_id: Map<number, number>;
44
45
  _custom_anchor_by_instance: Map<number, zappar_custom_anchor_t>;
46
+ _pipeline_id_by_d3_tracker_id: Map<number, number>;
47
+ _d3_tracker_by_instance: Map<number, zappar_d3_tracker_t>;
45
48
  processBuffer(b: ArrayBuffer): void;
46
49
  exploreState(): void;
47
50
  }
@@ -30,6 +30,8 @@ export class zappar_server {
30
30
  this._world_tracker_by_instance = new Map();
31
31
  this._pipeline_id_by_custom_anchor_id = new Map();
32
32
  this._custom_anchor_by_instance = new Map();
33
+ this._pipeline_id_by_d3_tracker_id = new Map();
34
+ this._d3_tracker_by_instance = new Map();
33
35
  }
34
36
  processBuffer(b) {
35
37
  this._deserializer.setData(b);
@@ -507,6 +509,24 @@ export class zappar_server {
507
509
  this._impl.custom_anchor_pose_set_with_parent(obj, msg.matrix4x4(), msg.string());
508
510
  break;
509
511
  }
512
+ case 59: {
513
+ let clientId = msg.type();
514
+ let arg_pipeline_id = msg.type();
515
+ let arg_pipeline = this._pipeline_by_instance.get(arg_pipeline_id);
516
+ let handle = this._impl.d3_tracker_create(arg_pipeline);
517
+ this._d3_tracker_by_instance.set(clientId, handle);
518
+ this._pipeline_id_by_d3_tracker_id.set(clientId, arg_pipeline_id);
519
+ break;
520
+ }
521
+ case 60: {
522
+ let clientId = msg.type();
523
+ let obj = this._d3_tracker_by_instance.get(clientId);
524
+ if (obj === undefined)
525
+ return;
526
+ this._impl.d3_tracker_destroy(obj);
527
+ this._d3_tracker_by_instance.delete(clientId);
528
+ break;
529
+ }
510
530
  }
511
531
  });
512
532
  }
@@ -854,5 +874,13 @@ export class zappar_server {
854
874
  msg.matrix4x4(this._impl.custom_anchor_pose_raw(v));
855
875
  });
856
876
  }
877
+ for (let [k, v] of this._d3_tracker_by_instance) {
878
+ let pipeline = this._pipeline_id_by_d3_tracker_id.get(k);
879
+ if (!pipeline)
880
+ continue;
881
+ let serializer = this.serializersByPipelineId.get(pipeline);
882
+ if (!serializer)
883
+ continue;
884
+ }
857
885
  }
858
886
  }
@@ -54,6 +54,9 @@ export declare type zappar_world_tracker_t = number & {
54
54
  export declare type zappar_custom_anchor_t = number & {
55
55
  _: 'zappar_custom_anchor_t';
56
56
  };
57
+ export declare type zappar_d3_tracker_t = number & {
58
+ _: 'zappar_d3_tracker_t';
59
+ };
57
60
  export interface zappar {
58
61
  loaded(): boolean;
59
62
  camera_default_device_id(userFacing: boolean): string;
@@ -281,4 +284,26 @@ export interface zappar {
281
284
  custom_anchor_pose_set_from_anchor_offset(o: zappar_custom_anchor_t, anchor_id: string, x: number, y: number, z: number, orientation: transform_orientation_t): void;
282
285
  custom_anchor_pose_set(o: zappar_custom_anchor_t, pose: Float32Array): void;
283
286
  custom_anchor_pose_set_with_parent(o: zappar_custom_anchor_t, pose: Float32Array, anchor_id: string): void;
287
+ d3_tracker_create(pipeline: zappar_pipeline_t): zappar_d3_tracker_t;
288
+ d3_tracker_destroy(o: zappar_d3_tracker_t): void;
289
+ d3_tracker_id(o: zappar_d3_tracker_t, indx: number): string;
290
+ d3_tracker_enabled(o: zappar_d3_tracker_t): boolean;
291
+ d3_tracker_enabled_set(o: zappar_d3_tracker_t, enabled: boolean): void;
292
+ d3_tracker_process_max_resolution_set(o: zappar_d3_tracker_t, v: boolean): void;
293
+ d3_tracker_count(o: zappar_d3_tracker_t): number;
294
+ d3_tracker_qr(o: zappar_d3_tracker_t, indx: number): string;
295
+ d3_tracker_pose_raw(o: zappar_d3_tracker_t, indx: number): Float32Array;
296
+ d3_tracker_pose_camera_relative(o: zappar_d3_tracker_t, indx: number, mirror: boolean): Float32Array;
297
+ d3_tracker_pose(o: zappar_d3_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
298
+ d3_tracker_pose0_raw(o: zappar_d3_tracker_t, indx: number): Float32Array;
299
+ d3_tracker_pose0_camera_relative(o: zappar_d3_tracker_t, indx: number, mirror: boolean): Float32Array;
300
+ d3_tracker_pose0(o: zappar_d3_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
301
+ d3_tracker_pose1_raw(o: zappar_d3_tracker_t, indx: number): Float32Array;
302
+ d3_tracker_pose1_camera_relative(o: zappar_d3_tracker_t, indx: number, mirror: boolean): Float32Array;
303
+ d3_tracker_pose1(o: zappar_d3_tracker_t, indx: number, camera_pose: Float32Array, mirror: boolean): Float32Array;
304
+ d3_tracker_landmarks_data(o: zappar_d3_tracker_t, indx: number): Float32Array;
305
+ d3_tracker_landmarks_data_size(o: zappar_d3_tracker_t, indx: number): number;
306
+ d3_tracker_type(o: zappar_d3_tracker_t, indx: number): number;
307
+ d3_tracker_dense(o: zappar_d3_tracker_t, indx: number): number;
308
+ d3_tracker_size_for_id_set(o: zappar_d3_tracker_t, id: string, size: number): void;
284
309
  }