@zappar/zappar-cv 4.0.0-beta.1 → 4.1.0-beta.2
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 +2 -2
- package/lib/additional.d.ts +1 -0
- package/lib/file-locator.d.ts +13 -0
- package/lib/file-locator.js +17 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/landmarkdatagenerate.js +3 -2
- package/lib/native.js +6 -5
- package/lib/profile.js +2 -2
- package/lib/src/additional.d.ts +1 -0
- package/lib/src/file-locator.d.ts +13 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/version.d.ts +1 -1
- package/lib/src/webxr-camera-source.d.ts +2 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/webxr-camera-source.d.ts +2 -0
- package/lib/webxr-camera-source.js +13 -8
- package/lib/worker-client.js +30 -11
- package/lib/zappar-cv.wasm +0 -0
- package/package.json +1 -1
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/4.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/4.1.0-beta.2/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/4.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/4.1.0-beta.2/zappar-cv.zip](https://libs.zappar.com/zappar-cv/4.1.0-beta.2/zappar-cv.zip)
|
package/lib/additional.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export interface Additional {
|
|
|
47
47
|
cookies_permitted: (p: boolean) => void;
|
|
48
48
|
world_tracker_points_data_matrix(wt: zappar_world_tracker_t, screenWidth: number, screenHeight: number, mirror: boolean): Float32Array;
|
|
49
49
|
in_app_clip: () => boolean;
|
|
50
|
+
webxr_camera_source_dom_overlay_element_set: (element: Element | null) => void;
|
|
50
51
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Returns the URL to load an asset from, or a falsy value to use the default. */
|
|
2
|
+
export declare type FileLocator = (filename: string, defaultUrl: string) => string | void | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Overrides where the library loads its runtime assets from. Call before
|
|
5
|
+
* `initialize()`; pass nothing to clear.
|
|
6
|
+
*
|
|
7
|
+
* The locator runs once per asset, where `filename` is one of:
|
|
8
|
+
* `zappar-cv.wasm`, `face_tracking_model.zbin`, `face_mesh_face_model.zbin`,
|
|
9
|
+
* `face_mesh_full_head_simplified_model.zbin`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setFileLocator(locator?: FileLocator): void;
|
|
12
|
+
/** Resolves an asset URL, routing it through the locator if one is set. */
|
|
13
|
+
export declare function resolveFileUrl(filename: string, defaultUrl: URL | string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
let fileLocator;
|
|
2
|
+
/**
|
|
3
|
+
* Overrides where the library loads its runtime assets from. Call before
|
|
4
|
+
* `initialize()`; pass nothing to clear.
|
|
5
|
+
*
|
|
6
|
+
* The locator runs once per asset, where `filename` is one of:
|
|
7
|
+
* `zappar-cv.wasm`, `face_tracking_model.zbin`, `face_mesh_face_model.zbin`,
|
|
8
|
+
* `face_mesh_full_head_simplified_model.zbin`.
|
|
9
|
+
*/
|
|
10
|
+
export function setFileLocator(locator) {
|
|
11
|
+
fileLocator = locator;
|
|
12
|
+
}
|
|
13
|
+
/** Resolves an asset URL, routing it through the locator if one is set. */
|
|
14
|
+
export function resolveFileUrl(filename, defaultUrl) {
|
|
15
|
+
const url = defaultUrl.toString();
|
|
16
|
+
return (fileLocator === null || fileLocator === void 0 ? void 0 : fileLocator(filename, url)) || url;
|
|
17
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import { Options } from "./options.js";
|
|
|
4
4
|
export declare type Zappar = zappar & Additional;
|
|
5
5
|
export declare function initialize(opts?: Options): Zappar;
|
|
6
6
|
export { CameraFrameData } from './camera-frame-data.js';
|
|
7
|
+
export { setFileLocator, FileLocator } from "./file-locator.js";
|
|
7
8
|
export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, zappar_zapcode_tracker_t, zappar_custom_anchor_t, zappar_d3_tracker_t, barcode_format_t, world_scale_mode_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t, image_target_type_t, world_tracker_quality_t, camera_profile_t, transform_orientation_t, plane_orientation_t, anchor_status_t, } from "./gen/zappar.js";
|
package/lib/index.js
CHANGED
|
@@ -4,4 +4,5 @@ export function initialize(opts) {
|
|
|
4
4
|
console.log(`Zappar CV v${VERSION}`);
|
|
5
5
|
return nativeInitialize(opts);
|
|
6
6
|
}
|
|
7
|
+
export { setFileLocator } from "./file-locator.js";
|
|
7
8
|
export { barcode_format_t, world_scale_mode_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, image_target_type_t, world_tracker_quality_t, camera_profile_t, transform_orientation_t, plane_orientation_t, anchor_status_t, } from "./gen/zappar.js";
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { FaceMesh } from "./facemesh.js";
|
|
11
11
|
import { face_landmark_name_t } from "./gen/zappar.js";
|
|
12
|
+
import { resolveFileUrl } from "./file-locator.js";
|
|
12
13
|
let vertexIndexByName = new Map([
|
|
13
14
|
[face_landmark_name_t.EAR_LEFT, 888],
|
|
14
15
|
[face_landmark_name_t.EAR_RIGHT, 467],
|
|
@@ -27,7 +28,7 @@ let vertexIndexByName = new Map([
|
|
|
27
28
|
export function generateDataJSON() {
|
|
28
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
30
|
let mesh = new FaceMesh();
|
|
30
|
-
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
31
|
+
let url = resolveFileUrl("face_mesh_face_model.zbin", new URL("./face_mesh_face_model.zbin", import.meta.url));
|
|
31
32
|
let req = yield fetch(url.toString());
|
|
32
33
|
mesh.loadFromMemory(yield req.arrayBuffer(), false, false, false, false);
|
|
33
34
|
let names = new Set([face_landmark_name_t.EYE_LEFT, face_landmark_name_t.EYE_RIGHT, face_landmark_name_t.EAR_LEFT, face_landmark_name_t.EAR_RIGHT, face_landmark_name_t.NOSE_BRIDGE, face_landmark_name_t.NOSE_TIP, face_landmark_name_t.NOSE_BASE, face_landmark_name_t.LIP_TOP, face_landmark_name_t.LIP_BOTTOM, face_landmark_name_t.MOUTH_CENTER, face_landmark_name_t.CHIN, face_landmark_name_t.EYEBROW_LEFT, face_landmark_name_t.EYEBROW_RIGHT]);
|
|
@@ -58,7 +59,7 @@ function arrayAsCPPLiteral(a) {
|
|
|
58
59
|
export function generateDataCPP() {
|
|
59
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
61
|
let mesh = new FaceMesh();
|
|
61
|
-
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
62
|
+
let url = resolveFileUrl("face_mesh_face_model.zbin", new URL("./face_mesh_face_model.zbin", import.meta.url));
|
|
62
63
|
let req = yield fetch(url.toString());
|
|
63
64
|
mesh.loadFromMemory(yield req.arrayBuffer(), false, false, false, false);
|
|
64
65
|
let names = [face_landmark_name_t.EYE_LEFT, face_landmark_name_t.EYE_RIGHT, face_landmark_name_t.EAR_LEFT, face_landmark_name_t.EAR_RIGHT, face_landmark_name_t.NOSE_BRIDGE, face_landmark_name_t.NOSE_TIP, face_landmark_name_t.NOSE_BASE, face_landmark_name_t.LIP_TOP, face_landmark_name_t.LIP_BOTTOM, face_landmark_name_t.MOUTH_CENTER, face_landmark_name_t.CHIN, face_landmark_name_t.EYEBROW_LEFT, face_landmark_name_t.EYEBROW_RIGHT];
|
package/lib/native.js
CHANGED
|
@@ -35,6 +35,7 @@ import { BridgedCameraSource } from "./bridged-camera-source.js";
|
|
|
35
35
|
import { WebXRCameraSource } from "./webxr-camera-source.js";
|
|
36
36
|
import { WebXRWorldTracker } from "./webxr-world-tracker.js";
|
|
37
37
|
import { profile } from "./profile.js";
|
|
38
|
+
import { resolveFileUrl } from "./file-locator.js";
|
|
38
39
|
let client;
|
|
39
40
|
const pipelineByWorldTracker = new Map();
|
|
40
41
|
const d3TrackerSizeById = new Map();
|
|
@@ -861,7 +862,7 @@ export function initialize(opts) {
|
|
|
861
862
|
zcwarn("attempting to call face_mesh_load_default on a destroyed zappar_face_mesh_t");
|
|
862
863
|
return;
|
|
863
864
|
}
|
|
864
|
-
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
865
|
+
let url = resolveFileUrl("face_mesh_face_model.zbin", new URL("./face_mesh_face_model.zbin", import.meta.url));
|
|
865
866
|
let req = yield fetch(url.toString());
|
|
866
867
|
obj.loadFromMemory(yield req.arrayBuffer(), false, false, false, false);
|
|
867
868
|
}), face_mesh_load_default_face: (m, fillMouth, fillEyeL, fillEyeR) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -870,7 +871,7 @@ export function initialize(opts) {
|
|
|
870
871
|
zcwarn("attempting to call face_mesh_load_default_face on a destroyed zappar_face_mesh_t");
|
|
871
872
|
return;
|
|
872
873
|
}
|
|
873
|
-
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
874
|
+
let url = resolveFileUrl("face_mesh_face_model.zbin", new URL("./face_mesh_face_model.zbin", import.meta.url));
|
|
874
875
|
let req = yield fetch(url.toString());
|
|
875
876
|
obj.loadFromMemory(yield req.arrayBuffer(), fillMouth, fillEyeL, fillEyeR, false);
|
|
876
877
|
}), face_mesh_load_default_full_head_simplified: (m, fillMouth, fillEyeL, fillEyeR, fillNeck) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -879,7 +880,7 @@ export function initialize(opts) {
|
|
|
879
880
|
zcwarn("attempting to call face_mesh_load_default_full_head_simplified on a destroyed zappar_face_mesh_t");
|
|
880
881
|
return;
|
|
881
882
|
}
|
|
882
|
-
let url = new URL("./face_mesh_full_head_simplified_model.zbin", import.meta.url);
|
|
883
|
+
let url = resolveFileUrl("face_mesh_full_head_simplified_model.zbin", new URL("./face_mesh_full_head_simplified_model.zbin", import.meta.url));
|
|
883
884
|
let req = yield fetch(url.toString());
|
|
884
885
|
obj.loadFromMemory(yield req.arrayBuffer(), fillMouth, fillEyeL, fillEyeR, fillNeck);
|
|
885
886
|
}), face_mesh_loaded_version: (m) => {
|
|
@@ -996,7 +997,7 @@ export function initialize(opts) {
|
|
|
996
997
|
}
|
|
997
998
|
mat4.multiply(res, cameraPose, res);
|
|
998
999
|
return res;
|
|
999
|
-
}, html_element_source_create: (pipeline, elm) => HTMLElementSource.createVideoElementSource(pipeline, elm), html_element_source_start: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.start(); }, html_element_source_pause: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, html_element_source_destroy: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, sequence_source_create: p => SequenceSource.create(p), sequence_source_load_from_memory: (o, data) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.loadFromMemory(data); }, sequence_source_pause: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, sequence_source_start: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.start(); }, sequence_source_max_playback_fps_set: (o, fps) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.maxPlaybackFpsSet(fps); }, sequence_source_time_set: (o, t) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.setTime(t); }, sequence_source_destroy: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, permission_granted_all: permissionGrantedAll, permission_granted_camera: permissionGrantedCamera, permission_granted_motion: permissionGrantedMotion, permission_denied_any: permissionDeniedAny, permission_denied_camera: permissionDeniedCamera, permission_denied_motion: permissionDeniedMotion, permission_request_motion: permissionRequestMotion, permission_request_camera: permissionRequestCamera, permission_request_all: permissionRequestAll, permission_request_ui: permissionRequestUI, permission_request_ui_promise: permissionRequestUI, permission_denied_ui: permissionDeniedUI, browser_incompatible: compatibility.incompatible, browser_incompatible_ui: compatibility.incompatible_ui, in_app_clip: () => BridgedCameraSource.IsSupported(), log_level_set: l => {
|
|
1000
|
+
}, html_element_source_create: (pipeline, elm) => HTMLElementSource.createVideoElementSource(pipeline, elm), html_element_source_start: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.start(); }, html_element_source_pause: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, html_element_source_destroy: o => { var _a; return (_a = HTMLElementSource.getVideoElementSource(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, sequence_source_create: p => SequenceSource.create(p), sequence_source_load_from_memory: (o, data) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.loadFromMemory(data); }, sequence_source_pause: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.pause(); }, sequence_source_start: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.start(); }, sequence_source_max_playback_fps_set: (o, fps) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.maxPlaybackFpsSet(fps); }, sequence_source_time_set: (o, t) => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.setTime(t); }, sequence_source_destroy: o => { var _a; return (_a = SequenceSource.get(o)) === null || _a === void 0 ? void 0 : _a.destroy(); }, permission_granted_all: permissionGrantedAll, permission_granted_camera: permissionGrantedCamera, permission_granted_motion: permissionGrantedMotion, permission_denied_any: permissionDeniedAny, permission_denied_camera: permissionDeniedCamera, permission_denied_motion: permissionDeniedMotion, permission_request_motion: permissionRequestMotion, permission_request_camera: permissionRequestCamera, permission_request_all: permissionRequestAll, permission_request_ui: permissionRequestUI, permission_request_ui_promise: permissionRequestUI, permission_denied_ui: permissionDeniedUI, browser_incompatible: compatibility.incompatible, browser_incompatible_ui: compatibility.incompatible_ui, in_app_clip: () => BridgedCameraSource.IsSupported(), webxr_camera_source_dom_overlay_element_set: elm => WebXRCameraSource.setDomOverlayElement(elm), log_level_set: l => {
|
|
1000
1001
|
setLogLevel(l);
|
|
1001
1002
|
c.impl.log_level_set(l);
|
|
1002
1003
|
}, cookies_permitted: p => {
|
|
@@ -1014,7 +1015,7 @@ export function initialize(opts) {
|
|
|
1014
1015
|
}
|
|
1015
1016
|
function loadDefaultFaceModel(o) {
|
|
1016
1017
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1017
|
-
let url = new URL("./face_tracking_model.zbin", import.meta.url);
|
|
1018
|
+
let url = resolveFileUrl("face_tracking_model.zbin", new URL("./face_tracking_model.zbin", import.meta.url));
|
|
1018
1019
|
let data = yield fetch(url.toString());
|
|
1019
1020
|
let ab = yield data.arrayBuffer();
|
|
1020
1021
|
client === null || client === void 0 ? void 0 : client.face_tracker_model_load_from_memory(o, ab);
|
package/lib/profile.js
CHANGED
|
@@ -11,8 +11,8 @@ export let profile = {
|
|
|
11
11
|
showGyroPermissionsWarningIfNecessary: false,
|
|
12
12
|
showSafariPermissionsResetIfNecessary: false,
|
|
13
13
|
requestHighFrameRate: false,
|
|
14
|
-
videoWidth:
|
|
15
|
-
videoHeight:
|
|
14
|
+
videoWidth: 640,
|
|
15
|
+
videoHeight: 480,
|
|
16
16
|
videoElementInDOM: false,
|
|
17
17
|
preferMediaStreamTrackProcessorCamera: false,
|
|
18
18
|
preferImageBitmapCamera: false,
|
package/lib/src/additional.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export interface Additional {
|
|
|
47
47
|
cookies_permitted: (p: boolean) => void;
|
|
48
48
|
world_tracker_points_data_matrix(wt: zappar_world_tracker_t, screenWidth: number, screenHeight: number, mirror: boolean): Float32Array;
|
|
49
49
|
in_app_clip: () => boolean;
|
|
50
|
+
webxr_camera_source_dom_overlay_element_set: (element: Element | null) => void;
|
|
50
51
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Returns the URL to load an asset from, or a falsy value to use the default. */
|
|
2
|
+
export declare type FileLocator = (filename: string, defaultUrl: string) => string | void | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Overrides where the library loads its runtime assets from. Call before
|
|
5
|
+
* `initialize()`; pass nothing to clear.
|
|
6
|
+
*
|
|
7
|
+
* The locator runs once per asset, where `filename` is one of:
|
|
8
|
+
* `zappar-cv.wasm`, `face_tracking_model.zbin`, `face_mesh_face_model.zbin`,
|
|
9
|
+
* `face_mesh_full_head_simplified_model.zbin`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setFileLocator(locator?: FileLocator): void;
|
|
12
|
+
/** Resolves an asset URL, routing it through the locator if one is set. */
|
|
13
|
+
export declare function resolveFileUrl(filename: string, defaultUrl: URL | string): string;
|
package/lib/src/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ import { Options } from "./options.js";
|
|
|
4
4
|
export declare type Zappar = zappar & Additional;
|
|
5
5
|
export declare function initialize(opts?: Options): Zappar;
|
|
6
6
|
export { CameraFrameData } from './camera-frame-data.js';
|
|
7
|
+
export { setFileLocator, FileLocator } from "./file-locator.js";
|
|
7
8
|
export { zappar_image_tracker_t, zappar_instant_world_tracker_t, zappar_world_tracker_t, zappar_barcode_finder_t, zappar_face_tracker_t, zappar_face_landmark_t, zappar_zapcode_tracker_t, zappar_custom_anchor_t, zappar_d3_tracker_t, barcode_format_t, world_scale_mode_t, face_landmark_name_t, instant_world_tracker_transform_orientation_t, log_level_t, zappar_face_mesh_t, zappar_pipeline_t, zappar_camera_source_t, zappar_sequence_source_t, image_target_type_t, world_tracker_quality_t, camera_profile_t, transform_orientation_t, plane_orientation_t, anchor_status_t, } from "./gen/zappar.js";
|
package/lib/src/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.1.0-beta.2";
|
|
@@ -58,6 +58,8 @@ export declare class WebXRCameraSource extends Source {
|
|
|
58
58
|
private _customAnchors;
|
|
59
59
|
private _groundH;
|
|
60
60
|
static IsSupported(): boolean;
|
|
61
|
+
private static _domOverlayElement;
|
|
62
|
+
static setDomOverlayElement(element: Element | null): void;
|
|
61
63
|
constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t);
|
|
62
64
|
destroy(): void;
|
|
63
65
|
setProfile(p: camera_profile_t): void;
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.
|
|
1
|
+
export declare const VERSION = "4.1.0-beta.2";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "4.
|
|
1
|
+
export const VERSION = "4.1.0-beta.2";
|
|
@@ -58,6 +58,8 @@ export declare class WebXRCameraSource extends Source {
|
|
|
58
58
|
private _customAnchors;
|
|
59
59
|
private _groundH;
|
|
60
60
|
static IsSupported(): boolean;
|
|
61
|
+
private static _domOverlayElement;
|
|
62
|
+
static setDomOverlayElement(element: Element | null): void;
|
|
61
63
|
constructor(_impl: zappar_camera_source_t, _pipeline: zappar_pipeline_t);
|
|
62
64
|
destroy(): void;
|
|
63
65
|
setProfile(p: camera_profile_t): void;
|
|
@@ -53,8 +53,8 @@ export class WebXRCameraSource extends Source {
|
|
|
53
53
|
this._rawCameraWidth = 320;
|
|
54
54
|
this._rawCameraHeight = 240;
|
|
55
55
|
this._profile = camera_profile_t.DEFAULT;
|
|
56
|
-
this._preferredWidth = profile.videoWidth;
|
|
57
|
-
this._preferredHeight = profile.videoHeight;
|
|
56
|
+
this._preferredWidth = Math.max(profile.videoWidth, 1280);
|
|
57
|
+
this._preferredHeight = Math.max(profile.videoHeight, 720);
|
|
58
58
|
this._permissionRequestShown = false;
|
|
59
59
|
this._planeHitTestSource = null;
|
|
60
60
|
this._customAnchorSetRequests = new Map();
|
|
@@ -352,6 +352,9 @@ export class WebXRCameraSource extends Source {
|
|
|
352
352
|
return false;
|
|
353
353
|
return true;
|
|
354
354
|
}
|
|
355
|
+
static setDomOverlayElement(element) {
|
|
356
|
+
WebXRCameraSource._domOverlayElement = element;
|
|
357
|
+
}
|
|
355
358
|
destroy() {
|
|
356
359
|
this.pause();
|
|
357
360
|
deleteCameraSource(this._impl);
|
|
@@ -360,8 +363,8 @@ export class WebXRCameraSource extends Source {
|
|
|
360
363
|
this._profile = p;
|
|
361
364
|
}
|
|
362
365
|
setPreferredResolution(w, h) {
|
|
363
|
-
this._preferredWidth = w;
|
|
364
|
-
this._preferredHeight = h;
|
|
366
|
+
this._preferredWidth = Math.max(w, 1280);
|
|
367
|
+
this._preferredHeight = Math.max(h, 720);
|
|
365
368
|
}
|
|
366
369
|
_stop() {
|
|
367
370
|
if (!this._xrSession)
|
|
@@ -456,7 +459,7 @@ export class WebXRCameraSource extends Source {
|
|
|
456
459
|
return;
|
|
457
460
|
}
|
|
458
461
|
_syncCamera() {
|
|
459
|
-
var _a, _b, _c;
|
|
462
|
+
var _a, _b, _c, _d;
|
|
460
463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
461
464
|
if (this._isPaused) {
|
|
462
465
|
if (this._xrSession)
|
|
@@ -478,7 +481,8 @@ export class WebXRCameraSource extends Source {
|
|
|
478
481
|
}
|
|
479
482
|
if (navigator.xr) {
|
|
480
483
|
try {
|
|
481
|
-
const
|
|
484
|
+
const overlayElement = (_b = WebXRCameraSource._domOverlayElement) !== null && _b !== void 0 ? _b : document.documentElement;
|
|
485
|
+
const session = yield navigator.xr.requestSession('immersive-ar', { requiredFeatures: ['dom-overlay', 'camera-access', 'hit-test', 'anchors'], domOverlay: { root: overlayElement } });
|
|
482
486
|
const refSpace = yield session.requestReferenceSpace('local');
|
|
483
487
|
this._xrViewerSpace = yield session.requestReferenceSpace('viewer');
|
|
484
488
|
this._xrWebGLLayer = new XRWebGLLayer(session, this._offscreenContext);
|
|
@@ -491,11 +495,11 @@ export class WebXRCameraSource extends Source {
|
|
|
491
495
|
this._xrGlBinding = new XRWebGLBinding(session, this._offscreenContext);
|
|
492
496
|
// Create a reference space that is a ray pointing down [0, -0.3] in normalized device coordinates
|
|
493
497
|
const offsetRay = new XRRay(new DOMPointReadOnly(0, 0, 0), { x: 0, y: -0.3, z: -1, w: 0 });
|
|
494
|
-
(
|
|
498
|
+
(_d = (_c = session.requestHitTestSource) === null || _c === void 0 ? void 0 : _c.call(session, {
|
|
495
499
|
space: this._xrViewerSpace,
|
|
496
500
|
offsetRay: offsetRay,
|
|
497
501
|
entityTypes: ['plane']
|
|
498
|
-
})) === null ||
|
|
502
|
+
})) === null || _d === void 0 ? void 0 : _d.then((hitTestSource) => {
|
|
499
503
|
this._planeHitTestSource = hitTestSource;
|
|
500
504
|
});
|
|
501
505
|
}
|
|
@@ -593,3 +597,4 @@ export class WebXRCameraSource extends Source {
|
|
|
593
597
|
return false;
|
|
594
598
|
}
|
|
595
599
|
}
|
|
600
|
+
WebXRCameraSource._domOverlayElement = null;
|
package/lib/worker-client.js
CHANGED
|
@@ -9,22 +9,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
var _a;
|
|
11
11
|
import { MsgManager } from "./messages.js";
|
|
12
|
+
import { resolveFileUrl } from "./file-locator.js";
|
|
12
13
|
export let messageManager = new MsgManager();
|
|
13
14
|
const params = new URLSearchParams(window.location.search);
|
|
14
15
|
const shouldRecordData = parseInt((_a = params.get('_zrecorddata')) !== null && _a !== void 0 ? _a : '0');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
function wasmUrl() {
|
|
17
|
+
return resolveFileUrl("zappar-cv.wasm", new URL("./zappar-cv.wasm", import.meta.url));
|
|
18
|
+
}
|
|
19
|
+
function compileWasm(url) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
if (typeof WebAssembly.compileStreaming === "function") {
|
|
22
|
+
try {
|
|
23
|
+
return yield WebAssembly.compileStreaming(fetch(url));
|
|
24
|
+
}
|
|
25
|
+
catch (_a) {
|
|
26
|
+
// Fall back to a buffered compile if the server sends a non-wasm MIME type.
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const response = yield fetch(url);
|
|
30
|
+
return WebAssembly.compile(yield response.arrayBuffer());
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let wasmModulePromise;
|
|
34
|
+
function getWasmModule() {
|
|
35
|
+
if (!wasmModulePromise)
|
|
36
|
+
wasmModulePromise = compileWasm(wasmUrl());
|
|
37
|
+
return wasmModulePromise;
|
|
38
|
+
}
|
|
20
39
|
export function launchWorker(worker) {
|
|
21
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
41
|
if (!worker)
|
|
23
42
|
worker = new Worker(new URL("./worker", import.meta.url), { type: 'module' });
|
|
24
43
|
worker.postMessage({
|
|
25
44
|
t: "wasm",
|
|
26
|
-
url:
|
|
27
|
-
module: yield
|
|
45
|
+
url: wasmUrl(),
|
|
46
|
+
module: yield getWasmModule(),
|
|
28
47
|
shouldRecordData
|
|
29
48
|
});
|
|
30
49
|
yield waitForLoad(worker);
|
|
@@ -48,8 +67,8 @@ export function launchCeresWorkers(port0, port1, worker0, worker1) {
|
|
|
48
67
|
worker0 = new Worker(new URL("./ceres-worker", import.meta.url), { type: 'module' });
|
|
49
68
|
worker0.postMessage({
|
|
50
69
|
t: "wasm",
|
|
51
|
-
url:
|
|
52
|
-
module: yield
|
|
70
|
+
url: wasmUrl(),
|
|
71
|
+
module: yield getWasmModule(),
|
|
53
72
|
port: port0,
|
|
54
73
|
instance: 0,
|
|
55
74
|
}, [port0]);
|
|
@@ -59,8 +78,8 @@ export function launchCeresWorkers(port0, port1, worker0, worker1) {
|
|
|
59
78
|
worker1 = new Worker(new URL("./ceres-worker", import.meta.url), { type: 'module' });
|
|
60
79
|
worker1.postMessage({
|
|
61
80
|
t: "wasm",
|
|
62
|
-
url:
|
|
63
|
-
module: yield
|
|
81
|
+
url: wasmUrl(),
|
|
82
|
+
module: yield getWasmModule(),
|
|
64
83
|
port: port1,
|
|
65
84
|
instance: 1,
|
|
66
85
|
}, [port1]);
|
package/lib/zappar-cv.wasm
CHANGED
|
Binary file
|