@zappar/zappar-cv 0.4.0-beta.4 → 2.0.0-beta.0
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/CHANGELOG.md +91 -34
- package/README.md +2 -2
- package/lib/additional.d.ts +2 -1
- package/lib/additional.js +1 -2
- package/lib/camera-source-map.d.ts +10 -0
- package/lib/camera-source-map.js +32 -0
- package/lib/camera-source.d.ts +2 -5
- package/lib/camera-source.js +18 -32
- package/lib/cameramodel.js +18 -23
- package/lib/compatibility.js +2 -4
- package/lib/deserializer.js +1 -5
- package/lib/direct.js +12 -16
- package/lib/drawcamera.js +27 -31
- package/lib/drawface.js +5 -9
- package/lib/drawfaceproject.js +5 -9
- package/lib/drawplane.js +6 -11
- package/lib/event.js +5 -13
- package/lib/facelandmark.d.ts +1 -2
- package/lib/facelandmark.js +11 -18
- package/lib/facelandmarkdata.js +1 -4
- package/lib/facelandmarkinterface.js +1 -2
- package/lib/facemesh.js +10 -17
- package/lib/gen/zappar-client.js +11 -25
- package/lib/gen/zappar-cwrap.js +38 -33
- package/lib/gen/zappar-native.d.ts +11 -1
- package/lib/gen/zappar-native.js +20 -11
- package/lib/gen/zappar-server.js +6 -14
- package/lib/gen/zappar.d.ts +12 -0
- package/lib/gen/zappar.js +5 -11
- package/lib/gfx.d.ts +1 -0
- package/lib/gfx.js +1 -0
- package/lib/gl-state-manager.d.ts +9 -0
- package/lib/gl-state-manager.js +31 -0
- package/lib/html-element-source.d.ts +3 -20
- package/lib/html-element-source.js +39 -287
- package/lib/image-process-gl.d.ts +37 -0
- package/lib/image-process-gl.js +306 -0
- package/lib/imagebitmap-camera-source.d.ts +36 -0
- package/lib/imagebitmap-camera-source.js +273 -0
- package/lib/imagetracker.d.ts +28 -0
- package/lib/imagetracker.js +115 -0
- package/lib/index-standalone.d.ts +3 -0
- package/lib/index-standalone.js +5 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -27
- package/lib/landmarkdatagenerate.js +25 -30
- package/lib/loglevel.js +9 -16
- package/lib/messages.js +4 -8
- package/lib/mstp-camera-source.d.ts +29 -0
- package/lib/mstp-camera-source.js +226 -0
- package/lib/native.d.ts +2 -1
- package/lib/native.js +229 -130
- package/lib/options.d.ts +3 -0
- package/lib/options.js +1 -0
- package/lib/permission.js +13 -27
- package/lib/pipeline.d.ts +14 -5
- package/lib/pipeline.js +125 -61
- package/lib/profile.d.ts +2 -0
- package/lib/profile.js +59 -53
- package/lib/riff-reader.d.ts +18 -0
- package/lib/riff-reader.js +52 -0
- package/lib/sequencerecorder.d.ts +1 -0
- package/lib/sequencerecorder.js +17 -11
- package/lib/sequencesource.d.ts +7 -1
- package/lib/sequencesource.js +102 -64
- package/lib/serializer.js +1 -5
- package/lib/shader.js +2 -7
- package/lib/source.d.ts +6 -4
- package/lib/source.js +1 -5
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -4
- package/lib/worker-client.d.ts +1 -1
- package/lib/worker-client.js +9 -26
- package/lib/worker-imagebitmap.d.ts +5 -0
- package/lib/worker-imagebitmap.js +59 -0
- package/lib/worker-server.d.ts +0 -5
- package/lib/worker-server.js +133 -41
- package/lib/worker.js +6 -10
- package/lib/workerinterface.d.ts +47 -1
- package/lib/workerinterface.js +1 -2
- package/lib/zcv.js +117 -135
- package/lib/zcv.wasm +0 -0
- package/package.json +33 -32
- package/umd/169.zappar-cv.js +1 -0
- package/umd/{482727c0e7dd40d73f5aae47f238ad61.zbin → 482727c0e7dd40d73f5a.zbin} +0 -0
- package/umd/6a8309f88f836a752c68.wasm +0 -0
- package/umd/752.zappar-cv.js +1 -0
- package/umd/{b4f46e148a3b3b5aef90717d8d60e3fc.zbin → b4f46e148a3b3b5aef90.zbin} +0 -0
- package/umd/{f7b62a3a53b5c9b3222ba8dc53cb8b11.zbin → f7b62a3a53b5c9b3222b.zbin} +0 -0
- package/umd/zappar-cv.js +1 -9
- package/umd/zappar-cv.worker.js +1 -1
- package/lib/bundleworker-mainthread.d.ts +0 -2
- package/lib/bundleworker-mainthread.js +0 -36
- package/lib/bundleworker-worker.d.ts +0 -6
- package/lib/bundleworker-worker.js +0 -34
- package/lib/zcv-slam.js +0 -16
- package/lib/zcv-slam.wasm +0 -0
- package/umd/1ec038c18c27f4adf35917a8175401f0.wasm +0 -0
- package/umd/9c0b0dcf514b48c05541.bundleworker.js +0 -1
- package/umd/d115e485cffe500afc4f7c1272ea8f62.wasm +0 -0
package/lib/native.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,31 +7,34 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
10
|
+
import { zappar_client } from "./gen/zappar-client";
|
|
11
|
+
import { drawPlane } from "./drawplane";
|
|
12
|
+
import { cameraRotationForScreenOrientation, projectionMatrix } from "./cameramodel";
|
|
13
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
14
|
+
import { launchWorker, messageManager } from "./worker-client";
|
|
15
|
+
import { permissionRequestUI, permissionGrantedAll, permissionGrantedCamera, permissionGrantedMotion, permissionDeniedAny, permissionDeniedCamera, permissionDeniedMotion, permissionRequestMotion, permissionRequestCamera, permissionRequestAll, permissionDeniedUI } from "./permission";
|
|
16
|
+
import { createFaceMesh, destroyFaceMesh, getFaceMesh } from "./facemesh";
|
|
17
|
+
import { Pipeline, applyScreenCounterRotation } from "./pipeline";
|
|
18
|
+
import { CameraSource } from "./camera-source";
|
|
19
|
+
import { HTMLElementSource } from "./html-element-source";
|
|
20
|
+
import { createFaceLandmark, destroyFaceLandmark, getFaceLandmark } from "./facelandmark";
|
|
21
|
+
import compatibility from './compatibility';
|
|
22
|
+
import { setLogLevel, zcwarn, zcout } from "./loglevel";
|
|
23
|
+
import { SequenceSource } from "./sequencesource";
|
|
24
|
+
import { createCameraSource, getCameraSource } from "./camera-source-map";
|
|
25
|
+
import { gfx } from "./gfx";
|
|
26
|
+
import { ImageTracker } from "./imagetracker";
|
|
28
27
|
let client;
|
|
29
|
-
function initialize() {
|
|
28
|
+
export function initialize(opts) {
|
|
30
29
|
if (client)
|
|
31
30
|
return client;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
let loaded = false;
|
|
32
|
+
launchWorker(opts === null || opts === void 0 ? void 0 : opts.worker).then(() => {
|
|
33
|
+
zcout("Fully loaded");
|
|
34
|
+
loaded = true;
|
|
35
|
+
});
|
|
36
|
+
let c = new zappar_client(ab => {
|
|
37
|
+
messageManager.postOutgoingMessage({
|
|
36
38
|
t: "zappar",
|
|
37
39
|
d: ab
|
|
38
40
|
}, [ab]);
|
|
@@ -42,19 +44,30 @@ function initialize() {
|
|
|
42
44
|
if (pathParts.length > 1 && pathParts[1].length > 0)
|
|
43
45
|
c.impl.analytics_project_id_set(".wiz" + pathParts[1]);
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
var _a, _b;
|
|
47
|
+
messageManager.onIncomingMessage.bind(msg => {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
49
|
switch (msg.t) {
|
|
48
50
|
case "zappar":
|
|
49
|
-
(_a =
|
|
51
|
+
(_a = Pipeline.get(msg.p)) === null || _a === void 0 ? void 0 : _a.pendingMessages.push(msg.d);
|
|
50
52
|
break;
|
|
51
53
|
case "buf":
|
|
52
54
|
c.serializer.bufferReturn(msg.d);
|
|
53
55
|
break;
|
|
54
|
-
case "cameraFrameRecycleS2C":
|
|
56
|
+
case "cameraFrameRecycleS2C": {
|
|
57
|
+
let msgt = msg;
|
|
58
|
+
(_c = (_b = Pipeline.get(msgt.p)) === null || _b === void 0 ? void 0 : _b.cameraTokenReturn) === null || _c === void 0 ? void 0 : _c.call(_b, msg);
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case "videoFrameS2C": {
|
|
55
62
|
let msgt = msg;
|
|
56
|
-
(
|
|
63
|
+
(_e = (_d = Pipeline.get(msgt.p)) === null || _d === void 0 ? void 0 : _d.videoFrameFromWorker) === null || _e === void 0 ? void 0 : _e.call(_d, msgt);
|
|
57
64
|
break;
|
|
65
|
+
}
|
|
66
|
+
case "imageBitmapS2C": {
|
|
67
|
+
let msgt = msg;
|
|
68
|
+
(_g = (_f = Pipeline.get(msgt.p)) === null || _f === void 0 ? void 0 : _f.imageBitmapFromWorker) === null || _g === void 0 ? void 0 : _g.call(_f, msgt);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
58
71
|
case "licerr": {
|
|
59
72
|
let div = document.createElement("div");
|
|
60
73
|
div.innerHTML = "Visit <a href='https://docs.zap.works/universal-ar/licensing/' style='color: white;'>our licensing page</a> to find out about hosting on your own domain.";
|
|
@@ -80,42 +93,64 @@ function initialize() {
|
|
|
80
93
|
}, 1000);
|
|
81
94
|
document.body.append(div);
|
|
82
95
|
}
|
|
96
|
+
case "gfx": {
|
|
97
|
+
let div = document.createElement("div");
|
|
98
|
+
div.innerHTML = gfx;
|
|
99
|
+
div.style.position = "absolute";
|
|
100
|
+
div.style.bottom = "20px";
|
|
101
|
+
div.style.width = "250px";
|
|
102
|
+
div.style.left = "50%";
|
|
103
|
+
div.style.marginLeft = "-125px";
|
|
104
|
+
div.style.zIndex = Number.MAX_SAFE_INTEGER.toString();
|
|
105
|
+
div.style.opacity = "0";
|
|
106
|
+
div.style.transition = "opacity 0.5s";
|
|
107
|
+
document.body.append(div);
|
|
108
|
+
setTimeout(function () {
|
|
109
|
+
div.style.opacity = "1";
|
|
110
|
+
}, 500);
|
|
111
|
+
setTimeout(function () {
|
|
112
|
+
div.style.opacity = "0";
|
|
113
|
+
}, 3000);
|
|
114
|
+
setTimeout(function () {
|
|
115
|
+
div.remove();
|
|
116
|
+
}, 4000);
|
|
117
|
+
}
|
|
83
118
|
}
|
|
84
119
|
});
|
|
85
|
-
client = Object.assign(Object.assign({}, c.impl), { camera_default_device_id: userFacing => userFacing ?
|
|
120
|
+
client = Object.assign(Object.assign({}, c.impl), { loaded: () => loaded, camera_default_device_id: userFacing => userFacing ? CameraSource.USER_DEFAULT_DEVICE_ID : CameraSource.DEFAULT_DEVICE_ID, camera_source_create: (p, deviceId) => createCameraSource(p, deviceId), camera_source_destroy: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.destroy(); }, camera_source_pause: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.pause(); }, camera_source_start: cam => { var _a; return (_a = getCameraSource(cam)) === null || _a === void 0 ? void 0 : _a.start(); }, pipeline_create: () => Pipeline.create(c.impl, messageManager), pipeline_frame_update: (p) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.frameUpdate(c); }, pipeline_camera_frame_draw_gl: (pipeline, screenWidth, screenHeight, mirror) => {
|
|
86
121
|
var _a;
|
|
87
|
-
(_a =
|
|
122
|
+
(_a = Pipeline.get(pipeline)) === null || _a === void 0 ? void 0 : _a.cameraFrameDrawGL(screenWidth, screenHeight, mirror);
|
|
88
123
|
}, draw_plane: (gl, projectionMatrix, cameraMatrix, targetMatrix, texture) => {
|
|
89
|
-
|
|
124
|
+
drawPlane(gl, projectionMatrix, cameraMatrix, targetMatrix, texture);
|
|
90
125
|
}, pipeline_draw_face: (p, projectionMatrix, cameraMatrix, targetMatrix, o) => {
|
|
91
126
|
var _a;
|
|
92
|
-
let obj =
|
|
127
|
+
let obj = getFaceMesh(o);
|
|
93
128
|
if (!obj) {
|
|
94
|
-
|
|
129
|
+
zcwarn("attempting to call draw_face on a destroyed zappar_face_mesh_t");
|
|
95
130
|
return new Uint16Array();
|
|
96
131
|
}
|
|
97
|
-
(_a =
|
|
132
|
+
(_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.drawFace(projectionMatrix, cameraMatrix, targetMatrix, obj);
|
|
98
133
|
}, pipeline_draw_face_project: (p, matrix, vertices, uvMatrix, uvs, indices, texture) => {
|
|
99
134
|
var _a;
|
|
100
|
-
(_a =
|
|
101
|
-
}, projection_matrix_from_camera_model:
|
|
102
|
-
let res =
|
|
135
|
+
(_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.drawFaceProject(matrix, vertices, uvMatrix, uvs, indices, texture);
|
|
136
|
+
}, projection_matrix_from_camera_model: projectionMatrix, projection_matrix_from_camera_model_ext: projectionMatrix, pipeline_process_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.processGL(); }, pipeline_gl_context_set: (p, gl, texturePool) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextSet(gl, texturePool); }, pipeline_gl_context_lost: (p) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.glContextLost(); }, pipeline_camera_frame_upload_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.uploadGL(); }, pipeline_camera_frame_texture_gl: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTexture(); }, pipeline_camera_frame_texture_matrix: (p, sw, sh, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameTextureMatrix(sw, sh, mirror)) || mat4.create(); }, pipeline_camera_frame_user_facing: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraFrameUserFacing()) || false; }, pipeline_camera_pose_default: () => mat4.create(), pipeline_camera_pose_with_attitude: (p, mirror) => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.cameraPoseWithAttitude(mirror)) || mat4.create(); }, pipeline_camera_pose_with_origin: (p, o) => { let res = mat4.create(); mat4.invert(res, o); return res; }, pipeline_sequence_record_clear: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordClear(); }, pipeline_sequence_record_start: (p, expectedFrames) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStart(expectedFrames); }, pipeline_sequence_record_stop: p => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordStop(); }, pipeline_sequence_record_device_attitude_matrices_set: (p, v) => { var _a; return (_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordDeviceAttitudeMatrices(v); }, pipeline_sequence_record_data: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData()) || new Uint8Array(0); }, pipeline_sequence_record_data_size: p => { var _a; return ((_a = Pipeline.get(p)) === null || _a === void 0 ? void 0 : _a.sequenceRecordData().byteLength) || 0; }, instant_world_tracker_anchor_pose_camera_relative: (o, mirror) => {
|
|
137
|
+
let res = applyScreenCounterRotation(undefined, c.impl.instant_world_tracker_anchor_pose_raw(o));
|
|
103
138
|
if (mirror) {
|
|
104
|
-
let scale =
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
139
|
+
let scale = mat4.create();
|
|
140
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
141
|
+
mat4.multiply(res, scale, res);
|
|
142
|
+
mat4.multiply(res, res, scale);
|
|
108
143
|
}
|
|
109
144
|
return res;
|
|
110
145
|
}, instant_world_tracker_anchor_pose: (o, cameraPose, mirror) => {
|
|
111
|
-
let res =
|
|
146
|
+
let res = applyScreenCounterRotation(undefined, c.impl.instant_world_tracker_anchor_pose_raw(o));
|
|
112
147
|
if (mirror) {
|
|
113
|
-
let scale =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
148
|
+
let scale = mat4.create();
|
|
149
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
150
|
+
mat4.multiply(res, scale, res);
|
|
151
|
+
mat4.multiply(res, res, scale);
|
|
117
152
|
}
|
|
118
|
-
|
|
153
|
+
mat4.multiply(res, cameraPose, res);
|
|
119
154
|
return res;
|
|
120
155
|
}, instant_world_tracker_anchor_pose_set_from_camera_offset: (o, x, y, z, orientation) => {
|
|
121
156
|
// TODO - add an _ext function if we need to support mirrored cameras with an extra param
|
|
@@ -124,197 +159,261 @@ function initialize() {
|
|
|
124
159
|
// }
|
|
125
160
|
// TODO - can we access the appropriate pipeline here to call pipeline_camera_frame_user_facing(p)?
|
|
126
161
|
let userFacing = false;
|
|
127
|
-
let rotation =
|
|
128
|
-
let rotationMat =
|
|
129
|
-
|
|
130
|
-
let rawVec =
|
|
131
|
-
|
|
162
|
+
let rotation = cameraRotationForScreenOrientation(userFacing) * Math.PI / 180.0;
|
|
163
|
+
let rotationMat = mat4.create();
|
|
164
|
+
mat4.fromRotation(rotationMat, -rotation, [0, 0, 1]);
|
|
165
|
+
let rawVec = vec3.create();
|
|
166
|
+
vec3.transformMat4(rawVec, [x, y, z], rotationMat);
|
|
132
167
|
c.impl.instant_world_tracker_anchor_pose_set_from_camera_offset_raw(o, rawVec[0], rawVec[1], rawVec[2], orientation);
|
|
168
|
+
}, image_tracker_create: pipeline => ImageTracker.create(pipeline, c.impl), image_tracker_destroy: t => { var _a; return (_a = ImageTracker.get(t)) === null || _a === void 0 ? void 0 : _a.destroy(); }, image_tracker_target_count: t => {
|
|
169
|
+
let obj = ImageTracker.get(t);
|
|
170
|
+
if (!obj) {
|
|
171
|
+
zcwarn("attempting to call image_tracker_target_count on a destroyed zappar_image_tracker_t");
|
|
172
|
+
return 0;
|
|
173
|
+
}
|
|
174
|
+
return obj.targetCount();
|
|
175
|
+
}, image_tracker_target_load_from_memory: (t, data) => {
|
|
176
|
+
let obj = ImageTracker.get(t);
|
|
177
|
+
if (!obj) {
|
|
178
|
+
zcwarn("attempting to call image_tracker_target_load_from_memory on a destroyed zappar_image_tracker_t");
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
obj.loadFromMemory(data);
|
|
182
|
+
}, image_tracker_target_preview_compressed: (t, i) => {
|
|
183
|
+
var _a;
|
|
184
|
+
let obj = ImageTracker.get(t);
|
|
185
|
+
if (!obj) {
|
|
186
|
+
zcwarn("attempting to call image_tracker_target_preview_compressed on a destroyed zappar_image_tracker_t");
|
|
187
|
+
return new Uint8Array(0);
|
|
188
|
+
}
|
|
189
|
+
return ((_a = obj.getTargetInfo(i).preview) === null || _a === void 0 ? void 0 : _a.compressed) || new Uint8Array(0);
|
|
190
|
+
}, image_tracker_target_preview_compressed_mimetype: (t, i) => {
|
|
191
|
+
var _a;
|
|
192
|
+
let obj = ImageTracker.get(t);
|
|
193
|
+
if (!obj) {
|
|
194
|
+
zcwarn("attempting to call image_tracker_target_preview_compressed_mimetype on a destroyed zappar_image_tracker_t");
|
|
195
|
+
return "";
|
|
196
|
+
}
|
|
197
|
+
return ((_a = obj.getTargetInfo(i).preview) === null || _a === void 0 ? void 0 : _a.mimeType) || "";
|
|
198
|
+
}, image_tracker_target_preview_compressed_size: (t, i) => {
|
|
199
|
+
var _a, _b;
|
|
200
|
+
let obj = ImageTracker.get(t);
|
|
201
|
+
if (!obj) {
|
|
202
|
+
zcwarn("attempting to call image_tracker_target_preview_compressed_size on a destroyed zappar_image_tracker_t");
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
return ((_b = (_a = obj.getTargetInfo(i).preview) === null || _a === void 0 ? void 0 : _a.compressed) === null || _b === void 0 ? void 0 : _b.byteLength) || 0;
|
|
206
|
+
}, image_tracker_target_physical_scale_factor: (t, i) => {
|
|
207
|
+
let obj = ImageTracker.get(t);
|
|
208
|
+
if (!obj) {
|
|
209
|
+
zcwarn("attempting to call image_tracker_target_physical_scale_factor on a destroyed zappar_image_tracker_t");
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
return obj.getTargetInfo(i).physicalScaleFactor;
|
|
213
|
+
}, image_tracker_target_radius_top: (t, i) => {
|
|
214
|
+
let obj = ImageTracker.get(t);
|
|
215
|
+
if (!obj) {
|
|
216
|
+
zcwarn("attempting to call image_tracker_target_radius_top on a destroyed zappar_image_tracker_t");
|
|
217
|
+
return 0;
|
|
218
|
+
}
|
|
219
|
+
return obj.getTargetInfo(i).topRadius;
|
|
220
|
+
}, image_tracker_target_radius_bottom: (t, i) => {
|
|
221
|
+
let obj = ImageTracker.get(t);
|
|
222
|
+
if (!obj) {
|
|
223
|
+
zcwarn("attempting to call image_tracker_target_radius_bottom on a destroyed zappar_image_tracker_t");
|
|
224
|
+
return 0;
|
|
225
|
+
}
|
|
226
|
+
return obj.getTargetInfo(i).bottomRadius;
|
|
227
|
+
}, image_tracker_target_side_length: (t, i) => {
|
|
228
|
+
let obj = ImageTracker.get(t);
|
|
229
|
+
if (!obj) {
|
|
230
|
+
zcwarn("attempting to call image_tracker_target_side_length on a destroyed zappar_image_tracker_t");
|
|
231
|
+
return 0;
|
|
232
|
+
}
|
|
233
|
+
return obj.getTargetInfo(i).sideLength;
|
|
234
|
+
}, image_tracker_target_image: (t, i) => {
|
|
235
|
+
let obj = ImageTracker.get(t);
|
|
236
|
+
if (!obj) {
|
|
237
|
+
zcwarn("attempting to call image_tracker_target_image on a destroyed zappar_image_tracker_t");
|
|
238
|
+
return new Image();
|
|
239
|
+
}
|
|
240
|
+
return obj.getDecodedPreview(i);
|
|
133
241
|
}, image_tracker_anchor_pose_camera_relative: (o, indx, mirror) => {
|
|
134
|
-
let res =
|
|
242
|
+
let res = applyScreenCounterRotation(undefined, c.impl.image_tracker_anchor_pose_raw(o, indx));
|
|
135
243
|
if (mirror) {
|
|
136
|
-
let scale =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
244
|
+
let scale = mat4.create();
|
|
245
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
246
|
+
mat4.multiply(res, scale, res);
|
|
247
|
+
mat4.multiply(res, res, scale);
|
|
140
248
|
}
|
|
141
249
|
return res;
|
|
142
250
|
}, image_tracker_anchor_pose: (o, indx, cameraPose, mirror) => {
|
|
143
|
-
let res =
|
|
251
|
+
let res = applyScreenCounterRotation(undefined, c.impl.image_tracker_anchor_pose_raw(o, indx));
|
|
144
252
|
if (mirror) {
|
|
145
|
-
let scale =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
253
|
+
let scale = mat4.create();
|
|
254
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
255
|
+
mat4.multiply(res, scale, res);
|
|
256
|
+
mat4.multiply(res, res, scale);
|
|
149
257
|
}
|
|
150
|
-
|
|
258
|
+
mat4.multiply(res, cameraPose, res);
|
|
151
259
|
return res;
|
|
152
260
|
}, face_tracker_anchor_pose_camera_relative: (o, indx, mirror) => {
|
|
153
|
-
let res =
|
|
261
|
+
let res = applyScreenCounterRotation(undefined, c.impl.face_tracker_anchor_pose_raw(o, indx));
|
|
154
262
|
if (mirror) {
|
|
155
|
-
let scale =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
263
|
+
let scale = mat4.create();
|
|
264
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
265
|
+
mat4.multiply(res, scale, res);
|
|
266
|
+
mat4.multiply(res, res, scale);
|
|
159
267
|
}
|
|
160
268
|
return res;
|
|
161
269
|
}, face_tracker_anchor_pose: (o, indx, cameraPose, mirror) => {
|
|
162
|
-
let res =
|
|
270
|
+
let res = applyScreenCounterRotation(undefined, c.impl.face_tracker_anchor_pose_raw(o, indx));
|
|
163
271
|
if (mirror) {
|
|
164
|
-
let scale =
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
272
|
+
let scale = mat4.create();
|
|
273
|
+
mat4.fromScaling(scale, [-1, 1, 1]);
|
|
274
|
+
mat4.multiply(res, scale, res);
|
|
275
|
+
mat4.multiply(res, res, scale);
|
|
168
276
|
}
|
|
169
|
-
|
|
277
|
+
mat4.multiply(res, cameraPose, res);
|
|
170
278
|
return res;
|
|
171
279
|
}, face_tracker_model_load_default: (o) => __awaiter(this, void 0, void 0, function* () {
|
|
172
280
|
yield loadDefaultFaceModel(o);
|
|
173
281
|
}), face_mesh_create: () => {
|
|
174
|
-
return
|
|
282
|
+
return createFaceMesh();
|
|
175
283
|
}, face_mesh_destroy: (m) => {
|
|
176
|
-
|
|
284
|
+
destroyFaceMesh(m);
|
|
177
285
|
}, face_mesh_indices: (m) => {
|
|
178
|
-
let obj =
|
|
286
|
+
let obj = getFaceMesh(m);
|
|
179
287
|
if (!obj) {
|
|
180
|
-
|
|
288
|
+
zcwarn("attempting to call face_mesh_indices on a destroyed zappar_face_mesh_t");
|
|
181
289
|
return new Uint16Array();
|
|
182
290
|
}
|
|
183
291
|
return obj.getIndices();
|
|
184
292
|
}, face_mesh_indices_size: (m) => {
|
|
185
|
-
let obj =
|
|
293
|
+
let obj = getFaceMesh(m);
|
|
186
294
|
if (!obj) {
|
|
187
|
-
|
|
295
|
+
zcwarn("attempting to call face_mesh_indices_size on a destroyed zappar_face_mesh_t");
|
|
188
296
|
return 0;
|
|
189
297
|
}
|
|
190
298
|
return obj.getIndices().length;
|
|
191
299
|
}, face_mesh_uvs: (m) => {
|
|
192
|
-
let obj =
|
|
300
|
+
let obj = getFaceMesh(m);
|
|
193
301
|
if (!obj) {
|
|
194
|
-
|
|
302
|
+
zcwarn("attempting to call face_mesh_uvs on a destroyed zappar_face_mesh_t");
|
|
195
303
|
return new Float32Array();
|
|
196
304
|
}
|
|
197
305
|
return obj.getUVs();
|
|
198
306
|
}, face_mesh_uvs_size: (m) => {
|
|
199
|
-
let obj =
|
|
307
|
+
let obj = getFaceMesh(m);
|
|
200
308
|
if (!obj) {
|
|
201
|
-
|
|
309
|
+
zcwarn("attempting to call face_mesh_uvs_size on a destroyed zappar_face_mesh_t");
|
|
202
310
|
return 0;
|
|
203
311
|
}
|
|
204
312
|
return obj.getUVs().length;
|
|
205
313
|
}, face_mesh_vertices: (m) => {
|
|
206
|
-
let obj =
|
|
314
|
+
let obj = getFaceMesh(m);
|
|
207
315
|
if (!obj) {
|
|
208
|
-
|
|
316
|
+
zcwarn("attempting to call face_mesh_vertices on a destroyed zappar_face_mesh_t");
|
|
209
317
|
return new Float32Array();
|
|
210
318
|
}
|
|
211
319
|
return obj.getVertices();
|
|
212
320
|
}, face_mesh_vertices_size: (m) => {
|
|
213
|
-
let obj =
|
|
321
|
+
let obj = getFaceMesh(m);
|
|
214
322
|
if (!obj) {
|
|
215
|
-
|
|
323
|
+
zcwarn("attempting to call face_mesh_vertices_size on a destroyed zappar_face_mesh_t");
|
|
216
324
|
return 0;
|
|
217
325
|
}
|
|
218
326
|
return obj.getVertices().length;
|
|
219
327
|
}, face_mesh_normals: (m) => {
|
|
220
|
-
let obj =
|
|
328
|
+
let obj = getFaceMesh(m);
|
|
221
329
|
if (!obj) {
|
|
222
|
-
|
|
330
|
+
zcwarn("attempting to call face_mesh_normals on a destroyed zappar_face_mesh_t");
|
|
223
331
|
return new Float32Array();
|
|
224
332
|
}
|
|
225
333
|
return obj.getNormals();
|
|
226
334
|
}, face_mesh_normals_size: (m) => {
|
|
227
|
-
let obj =
|
|
335
|
+
let obj = getFaceMesh(m);
|
|
228
336
|
if (!obj) {
|
|
229
|
-
|
|
337
|
+
zcwarn("attempting to call face_mesh_normals_size on a destroyed zappar_face_mesh_t");
|
|
230
338
|
return 0;
|
|
231
339
|
}
|
|
232
340
|
return obj.getNormals().length;
|
|
233
341
|
}, face_mesh_load_from_memory: (m, ab, fillMouth, fillEyeL, fillEyeR, fillNeck) => {
|
|
234
|
-
let obj =
|
|
342
|
+
let obj = getFaceMesh(m);
|
|
235
343
|
if (!obj) {
|
|
236
|
-
|
|
344
|
+
zcwarn("attempting to call face_mesh_load_from_memory on a destroyed zappar_face_mesh_t");
|
|
237
345
|
return;
|
|
238
346
|
}
|
|
239
347
|
obj.loadFromMemory(ab, fillMouth, fillEyeL, fillEyeR, fillNeck);
|
|
240
348
|
}, face_mesh_update: (m, identity, expression, mirrored) => {
|
|
241
|
-
let obj =
|
|
349
|
+
let obj = getFaceMesh(m);
|
|
242
350
|
if (!obj) {
|
|
243
|
-
|
|
351
|
+
zcwarn("attempting to call face_mesh_update on a destroyed zappar_face_mesh_t");
|
|
244
352
|
return;
|
|
245
353
|
}
|
|
246
354
|
obj.update(identity, expression, mirrored);
|
|
247
355
|
}, face_mesh_load_default: (m) => __awaiter(this, void 0, void 0, function* () {
|
|
248
|
-
let obj =
|
|
356
|
+
let obj = getFaceMesh(m);
|
|
249
357
|
if (!obj) {
|
|
250
|
-
|
|
358
|
+
zcwarn("attempting to call face_mesh_load_default on a destroyed zappar_face_mesh_t");
|
|
251
359
|
return;
|
|
252
360
|
}
|
|
253
|
-
let url =
|
|
254
|
-
|
|
255
|
-
url = url.default;
|
|
256
|
-
let req = yield fetch(url);
|
|
361
|
+
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
362
|
+
let req = yield fetch(url.toString());
|
|
257
363
|
obj.loadFromMemory(yield req.arrayBuffer(), false, false, false, false);
|
|
258
364
|
}), face_mesh_load_default_face: (m, fillMouth, fillEyeL, fillEyeR) => __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
let obj =
|
|
365
|
+
let obj = getFaceMesh(m);
|
|
260
366
|
if (!obj) {
|
|
261
|
-
|
|
367
|
+
zcwarn("attempting to call face_mesh_load_default_face on a destroyed zappar_face_mesh_t");
|
|
262
368
|
return;
|
|
263
369
|
}
|
|
264
|
-
let url =
|
|
265
|
-
|
|
266
|
-
url = url.default;
|
|
267
|
-
let req = yield fetch(url);
|
|
370
|
+
let url = new URL("./face_mesh_face_model.zbin", import.meta.url);
|
|
371
|
+
let req = yield fetch(url.toString());
|
|
268
372
|
obj.loadFromMemory(yield req.arrayBuffer(), fillMouth, fillEyeL, fillEyeR, false);
|
|
269
373
|
}), face_mesh_load_default_full_head_simplified: (m, fillMouth, fillEyeL, fillEyeR, fillNeck) => __awaiter(this, void 0, void 0, function* () {
|
|
270
|
-
let obj =
|
|
374
|
+
let obj = getFaceMesh(m);
|
|
271
375
|
if (!obj) {
|
|
272
|
-
|
|
376
|
+
zcwarn("attempting to call face_mesh_load_default_full_head_simplified on a destroyed zappar_face_mesh_t");
|
|
273
377
|
return;
|
|
274
378
|
}
|
|
275
|
-
let url =
|
|
276
|
-
|
|
277
|
-
url = url.default;
|
|
278
|
-
let req = yield fetch(url);
|
|
379
|
+
let url = new URL("./face_mesh_full_head_simplified_model.zbin", import.meta.url);
|
|
380
|
+
let req = yield fetch(url.toString());
|
|
279
381
|
obj.loadFromMemory(yield req.arrayBuffer(), fillMouth, fillEyeL, fillEyeR, fillNeck);
|
|
280
382
|
}), face_mesh_loaded_version: (m) => {
|
|
281
|
-
let obj =
|
|
383
|
+
let obj = getFaceMesh(m);
|
|
282
384
|
if (!obj) {
|
|
283
|
-
|
|
385
|
+
zcwarn("attempting to call face_mesh_load_default on a destroyed zappar_face_mesh_t");
|
|
284
386
|
return -1;
|
|
285
387
|
}
|
|
286
388
|
return obj.getModelVersion();
|
|
287
389
|
}, face_landmark_create: (n) => {
|
|
288
|
-
return
|
|
390
|
+
return createFaceLandmark(n);
|
|
289
391
|
}, face_landmark_destroy: (m) => {
|
|
290
|
-
|
|
392
|
+
destroyFaceLandmark(m);
|
|
291
393
|
}, face_landmark_update: (m, identity, expression, mirrored) => {
|
|
292
|
-
let obj =
|
|
394
|
+
let obj = getFaceLandmark(m);
|
|
293
395
|
if (!obj) {
|
|
294
|
-
|
|
396
|
+
zcwarn("attempting to call face_landmark_update on a destroyed zappar_face_landmark_t");
|
|
295
397
|
return;
|
|
296
398
|
}
|
|
297
399
|
obj.update(identity, expression, mirrored);
|
|
298
400
|
}, face_landmark_anchor_pose: (m) => {
|
|
299
|
-
let obj =
|
|
401
|
+
let obj = getFaceLandmark(m);
|
|
300
402
|
if (!obj) {
|
|
301
|
-
|
|
302
|
-
return
|
|
403
|
+
zcwarn("attempting to call face_landmark_anchor_pose on a destroyed zappar_face_landmark_t");
|
|
404
|
+
return mat4.create();
|
|
303
405
|
}
|
|
304
406
|
return obj.anchor_pose;
|
|
305
|
-
}, html_element_source_create: (pipeline, elm) =>
|
|
306
|
-
|
|
407
|
+
}, 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_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, log_level_set: l => {
|
|
408
|
+
setLogLevel(l);
|
|
307
409
|
c.impl.log_level_set(l);
|
|
308
410
|
} });
|
|
309
411
|
return client;
|
|
310
412
|
}
|
|
311
|
-
exports.initialize = initialize;
|
|
312
413
|
function loadDefaultFaceModel(o) {
|
|
313
414
|
return __awaiter(this, void 0, void 0, function* () {
|
|
314
|
-
let url =
|
|
315
|
-
|
|
316
|
-
url = url.default;
|
|
317
|
-
let data = yield fetch(url);
|
|
415
|
+
let url = new URL("./face_tracking_model.zbin", import.meta.url);
|
|
416
|
+
let data = yield fetch(url.toString());
|
|
318
417
|
let ab = yield data.arrayBuffer();
|
|
319
418
|
client === null || client === void 0 ? void 0 : client.face_tracker_model_load_from_memory(o, ab);
|
|
320
419
|
});
|
package/lib/options.d.ts
ADDED
package/lib/options.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|