@zappar/zappar-cv 3.0.0-alpha.4 → 3.0.0-alpha.5
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/mstp-camera-source.d.ts +1 -0
- package/lib/mstp-camera-source.js +16 -0
- package/lib/native.js +8 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/worker-server.js +14 -5
- package/lib/workerinterface.d.ts +5 -0
- package/package.json +1 -1
- package/umd/56.zappar-cv.js +1 -1
- package/umd/zappar-cv.js +1 -1
- package/umd/zappar-cv.worker.js +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/3.0.0-alpha.
|
|
21
|
+
<script src="https://libs.zappar.com/zappar-cv/3.0.0-alpha.5/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.0.0-alpha.
|
|
25
|
+
[https://libs.zappar.com/zappar-cv/3.0.0-alpha.5/zappar-cv.zip](https://libs.zappar.com/zappar-cv/3.0.0-alpha.5/zappar-cv.zip)
|
|
@@ -164,6 +164,11 @@ export class MSTPCameraSource extends Source {
|
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
|
+
streamEnded() {
|
|
168
|
+
console.log('MSTP stream ended');
|
|
169
|
+
this._stop();
|
|
170
|
+
this._syncCamera();
|
|
171
|
+
}
|
|
167
172
|
_syncCamera() {
|
|
168
173
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
174
|
if (this._currentStream && this._isPaused) {
|
|
@@ -187,6 +192,11 @@ export class MSTPCameraSource extends Source {
|
|
|
187
192
|
let processor = new MediaStreamTrackProcessor({
|
|
188
193
|
track: videoTracks[0]
|
|
189
194
|
});
|
|
195
|
+
const str = this._currentStream;
|
|
196
|
+
yield delay(1000);
|
|
197
|
+
if (str !== this._currentStream) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
190
200
|
let p = Pipeline.get(this._pipeline);
|
|
191
201
|
if (p)
|
|
192
202
|
p.sendCameraStreamToWorker(this._impl, processor.readable, this._isUserFacing);
|
|
@@ -239,3 +249,9 @@ export class MSTPCameraSource extends Source {
|
|
|
239
249
|
}
|
|
240
250
|
MSTPCameraSource.USER_DEFAULT_DEVICE_ID = "Simulated User Default Device ID: a908df7f-5661-4d20-b227-a1c15d2fdb4b";
|
|
241
251
|
MSTPCameraSource.DEFAULT_DEVICE_ID = "Simulated Default Device ID: a908df7f-5661-4d20-b227-a1c15d2fdb4b";
|
|
252
|
+
function delay(ms) {
|
|
253
|
+
return new Promise(resolve => {
|
|
254
|
+
setTimeout(resolve, ms);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
;
|
package/lib/native.js
CHANGED
|
@@ -25,6 +25,7 @@ import { SequenceSource } from "./sequencesource";
|
|
|
25
25
|
import { createCameraSource, getCameraSource } from "./camera-source-map";
|
|
26
26
|
import { gfx } from "./gfx";
|
|
27
27
|
import { ImageTracker } from "./imagetracker";
|
|
28
|
+
import { MSTPCameraSource } from "./mstp-camera-source";
|
|
28
29
|
let client;
|
|
29
30
|
export function initialize(opts) {
|
|
30
31
|
if (client)
|
|
@@ -71,6 +72,13 @@ export function initialize(opts) {
|
|
|
71
72
|
(_g = (_f = Pipeline.get(msgt.p)) === null || _f === void 0 ? void 0 : _f.imageBitmapFromWorker) === null || _g === void 0 ? void 0 : _g.call(_f, msgt);
|
|
72
73
|
break;
|
|
73
74
|
}
|
|
75
|
+
case "streamEndedS2C": {
|
|
76
|
+
let msgt = msg;
|
|
77
|
+
const src = getCameraSource(msgt.source);
|
|
78
|
+
if (src instanceof MSTPCameraSource)
|
|
79
|
+
src.streamEnded();
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
74
82
|
case "licerr": {
|
|
75
83
|
let div = document.createElement("div");
|
|
76
84
|
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.";
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "3.0.0-alpha.
|
|
1
|
+
export declare const VERSION = "3.0.0-alpha.5";
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "3.0.0-alpha.
|
|
1
|
+
export const VERSION = "3.0.0-alpha.5";
|
package/lib/worker-server.js
CHANGED
|
@@ -68,7 +68,13 @@ export function launchWorkerServer(wasmUrl) {
|
|
|
68
68
|
}
|
|
69
69
|
case "streamC2S": {
|
|
70
70
|
let msgt = msg;
|
|
71
|
-
consumeStream(mod, r, msgt.s, msgt.p, msgt.userFacing, server, msgt.source)
|
|
71
|
+
consumeStream(mod, r, msgt.s, msgt.p, msgt.userFacing, server, msgt.source).then(() => {
|
|
72
|
+
let m = { t: "streamEndedS2C", p: msgt.p, source: msgt.source };
|
|
73
|
+
console.log('Stream ended, requesting new stream');
|
|
74
|
+
messageManager.postOutgoingMessage(m, []);
|
|
75
|
+
}).catch(err => {
|
|
76
|
+
console.log('Stream ended with error', err);
|
|
77
|
+
});
|
|
72
78
|
break;
|
|
73
79
|
}
|
|
74
80
|
case "cameraToScreenC2S": {
|
|
@@ -140,12 +146,13 @@ function consumeStream(mod, r, stream, p, userFacing, server, source) {
|
|
|
140
146
|
}
|
|
141
147
|
try {
|
|
142
148
|
yield consumeReader(mod, r, reader, p, userFacing, server, source);
|
|
149
|
+
return;
|
|
143
150
|
}
|
|
144
151
|
catch (err) {
|
|
145
|
-
console.log("Consuming reader error", err);
|
|
152
|
+
console.log("Consuming reader error 2", err);
|
|
146
153
|
}
|
|
147
|
-
reader.releaseLock();
|
|
148
154
|
yield delay(1000);
|
|
155
|
+
return;
|
|
149
156
|
}
|
|
150
157
|
});
|
|
151
158
|
}
|
|
@@ -156,7 +163,7 @@ function getFrameOrTimeout(reader) {
|
|
|
156
163
|
return new Promise((resolve, reject) => {
|
|
157
164
|
const token = setTimeout(() => {
|
|
158
165
|
console.log('Frame timeout');
|
|
159
|
-
reject();
|
|
166
|
+
reject('Frame timeout');
|
|
160
167
|
}, 2000);
|
|
161
168
|
reader.read().then(result => {
|
|
162
169
|
clearTimeout(token);
|
|
@@ -167,11 +174,13 @@ function getFrameOrTimeout(reader) {
|
|
|
167
174
|
const cameraToDeviceTransform = mat4.create();
|
|
168
175
|
const cameraModel = new Float32Array([300, 300, 160, 120, 0, 0]);
|
|
169
176
|
function consumeReader(mod, r, reader, p, userFacing, server, source) {
|
|
177
|
+
var _a;
|
|
170
178
|
return __awaiter(this, void 0, void 0, function* () {
|
|
171
179
|
while (true) {
|
|
172
180
|
let result = yield getFrameOrTimeout(reader);
|
|
173
181
|
if (result.done) {
|
|
174
|
-
console.log("Stream done");
|
|
182
|
+
console.log("Stream done", userFacing);
|
|
183
|
+
(_a = result.value) === null || _a === void 0 ? void 0 : _a.close();
|
|
175
184
|
return;
|
|
176
185
|
}
|
|
177
186
|
let frame = result.value;
|
package/lib/workerinterface.d.ts
CHANGED
|
@@ -63,6 +63,11 @@ export interface ImageBitmapS2C {
|
|
|
63
63
|
frame: ImageBitmap;
|
|
64
64
|
tokenId: number;
|
|
65
65
|
}
|
|
66
|
+
export interface StreamEndedS2C {
|
|
67
|
+
t: "streamEndedS2C";
|
|
68
|
+
p: zappar_pipeline_t;
|
|
69
|
+
source: zappar_camera_source_t;
|
|
70
|
+
}
|
|
66
71
|
export interface SensorDataC2S {
|
|
67
72
|
t: "sensorDataC2S";
|
|
68
73
|
sensor: "accel" | "accel_wo_gravity_int" | "accel_w_gravity_int" | "rotation_rate_int" | "attitude_int" | "rotation_rate" | "attitude";
|
package/package.json
CHANGED