@zappar/zappar-cv 3.8.0 → 3.8.4

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.8.0/zappar-cv.js"></script>
21
+ <script src="https://libs.zappar.com/zappar-cv/3.8.4/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.8.0/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.8.0/zappar-cv.zip)
25
+ [https://libs.zappar.com/zappar-cv/3.8.4/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.8.4/zappar-cv.zip)
package/lib/pipeline.js CHANGED
@@ -349,6 +349,7 @@ export class Pipeline {
349
349
  data.frame = msg.frame;
350
350
  data.userFacing = msg.userFacing;
351
351
  data.uvTransform = msg.uvTransform;
352
+ data.data = msg.data;
352
353
  if (this._cameraFrameDataRGBEnabled)
353
354
  data.rgbFrame = msg.frame;
354
355
  this.tokensInFlight--;
@@ -531,7 +532,8 @@ export class Pipeline {
531
532
  userFacing,
532
533
  cameraModel,
533
534
  cameraToDevice,
534
- cp
535
+ cp,
536
+ requestData: this._cameraFrameDataEnabled,
535
537
  };
536
538
  this._mgr.postOutgoingMessage(msg, [img]);
537
539
  }
@@ -1 +1 @@
1
- export declare const VERSION = "3.8.0";
1
+ export declare const VERSION = "3.8.4";
@@ -52,6 +52,7 @@ export declare class WebXRCameraSource extends Source {
52
52
  private _planeHitTestSource;
53
53
  private _customAnchorSetRequests;
54
54
  private _customAnchors;
55
+ private _groundH;
55
56
  static IsSupported(): boolean;
56
57
  constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t);
57
58
  destroy(): void;
@@ -61,12 +61,14 @@ export interface ImageBitmapC2S {
61
61
  cameraModel: Float32Array;
62
62
  cameraToDevice: Float32Array;
63
63
  cp: camera_profile_t;
64
+ requestData?: boolean;
64
65
  }
65
66
  export interface ImageBitmapS2C {
66
67
  t: "imageBitmapS2C";
67
68
  p: zappar_pipeline_t;
68
69
  dataWidth: number;
69
70
  dataHeight: number;
71
+ data?: ArrayBuffer;
70
72
  uvTransform: Float32Array;
71
73
  userFacing: boolean;
72
74
  frame: ImageBitmap;
package/lib/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "3.8.0";
1
+ export declare const VERSION = "3.8.4";
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "3.8.0";
1
+ export const VERSION = "3.8.4";
@@ -52,6 +52,7 @@ export declare class WebXRCameraSource extends Source {
52
52
  private _planeHitTestSource;
53
53
  private _customAnchorSetRequests;
54
54
  private _customAnchors;
55
+ private _groundH;
55
56
  static IsSupported(): boolean;
56
57
  constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t);
57
58
  destroy(): void;
@@ -26,6 +26,7 @@ for (let i = 0; i < 32; i++) {
26
26
  const _quat = quat.create();
27
27
  const _trans = vec3.create();
28
28
  const _up = vec3.fromValues(0, 1, 0);
29
+ const _ground = mat4.create();
29
30
  export class WebXRCameraSource extends Source {
30
31
  constructor(_impl, _pipeline) {
31
32
  super();
@@ -55,7 +56,7 @@ export class WebXRCameraSource extends Source {
55
56
  this._customAnchorSetRequests = new Map();
56
57
  this._customAnchors = new Map();
57
58
  this._onXRFrame = (time, frame) => {
58
- var _a, _b, _c, _d, _e;
59
+ var _a, _b, _c, _d, _e, _f;
59
60
  if (this._isPaused)
60
61
  return;
61
62
  (_a = this._xrSession) === null || _a === void 0 ? void 0 : _a.requestAnimationFrame(this._onXRFrame);
@@ -203,6 +204,16 @@ export class WebXRCameraSource extends Source {
203
204
  continue; // skip vertical planes if not requested
204
205
  }
205
206
  if (poseInCamera) {
207
+ // Update ground height to the lowest detected plane
208
+ if (localPose) {
209
+ const planeY = worldPose.transform.matrix[13];
210
+ const viewerHeight = localPose.transform.matrix[13] - planeY;
211
+ if (viewerHeight > 0.8 && viewerHeight < 1.8) {
212
+ if (this._groundH === undefined || planeY < this._groundH) {
213
+ this._groundH = planeY;
214
+ }
215
+ }
216
+ }
206
217
  plane_anchors.push({
207
218
  id: "plane-" + plane_anchors.length,
208
219
  horizontal: true,
@@ -236,11 +247,15 @@ export class WebXRCameraSource extends Source {
236
247
  }
237
248
  else {
238
249
  const world_pose = rotateMatrix(localPose.transform.inverse.matrix, rot);
250
+ let ground_pose = mat4.create();
251
+ mat4.fromTranslation(_ground, [0, (_f = this._groundH) !== null && _f !== void 0 ? _f : -1.5, 0]);
252
+ mat4.multiply(ground_pose, localPose.transform.inverse.matrix, _ground);
253
+ ground_pose = rotateMatrix(ground_pose, rot);
239
254
  this._latestWtData = {
240
255
  world_anchor_status: anchor_status_t.ANCHOR_STATUS_TRACKING,
241
256
  world_anchor_pose: world_pose,
242
- ground_anchor_pose: mat4.create(),
243
- ground_anchor_status: anchor_status_t.ANCHOR_STATUS_INITIALIZING,
257
+ ground_anchor_pose: ground_pose,
258
+ ground_anchor_status: this._groundH === undefined ? anchor_status_t.ANCHOR_STATUS_INITIALIZING : anchor_status_t.ANCHOR_STATUS_TRACKING,
244
259
  plane_anchors,
245
260
  custom_anchors,
246
261
  quality: world_tracker_quality_t.WORLD_TRACKER_QUALITY_GOOD,
@@ -255,6 +270,7 @@ export class WebXRCameraSource extends Source {
255
270
  this._customAnchorSetRequests.clear();
256
271
  this._customAnchors.clear();
257
272
  this._planeHitTestSource = null;
273
+ this._groundH = undefined;
258
274
  if (this._isPaused)
259
275
  return;
260
276
  if (this._permissionRequestShown)
@@ -58,7 +58,8 @@ export function handleImageBitmap(m, r, server, mgr) {
58
58
  frame: m.i,
59
59
  userFacing: info.userFacing,
60
60
  uvTransform: info.uvTransform || mat4.create(),
61
- tokenId: m.tokenId, p: m.p
61
+ tokenId: m.tokenId, p: m.p,
62
+ data: m.requestData ? info.data : undefined
62
63
  };
63
64
  mgr.postOutgoingMessage(msg, [m.i]);
64
65
  let pipeline = server._pipeline_by_instance.get(m.p);
@@ -61,12 +61,14 @@ export interface ImageBitmapC2S {
61
61
  cameraModel: Float32Array;
62
62
  cameraToDevice: Float32Array;
63
63
  cp: camera_profile_t;
64
+ requestData?: boolean;
64
65
  }
65
66
  export interface ImageBitmapS2C {
66
67
  t: "imageBitmapS2C";
67
68
  p: zappar_pipeline_t;
68
69
  dataWidth: number;
69
70
  dataHeight: number;
71
+ data?: ArrayBuffer;
70
72
  uvTransform: Float32Array;
71
73
  userFacing: boolean;
72
74
  frame: ImageBitmap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zappar/zappar-cv",
3
- "version": "3.8.0",
3
+ "version": "3.8.4",
4
4
  "description": "Zappar's core computer vision library, supporting image, face and world tracking.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",