disable internal worker; resync requests for next vid frame.
This commit is contained in:
Родитель
1334d0c412
Коммит
19d5ddfe8c
|
@ -179,9 +179,13 @@ class XRExampleBase {
|
|||
// if this session is getting video frames, lets set up a callback.
|
||||
// EVENTUALLY should look at properties on the session to see if user
|
||||
// approved it, but the app doesn't let us know this yet
|
||||
this.session.requestVideoFrames(worker)
|
||||
this.session.setVideoFrameHandler(worker)
|
||||
}
|
||||
|
||||
requestVideoFrame() {
|
||||
this.session.requestVideoFrame();
|
||||
}
|
||||
|
||||
/*
|
||||
Extending classes should override this to set up the scene during class construction
|
||||
*/
|
||||
|
|
|
@ -246,8 +246,9 @@
|
|||
self.messageText = txt;
|
||||
},0);
|
||||
updateCVFPS();
|
||||
|
||||
self.requestVideoFrame();
|
||||
}
|
||||
|
||||
this.worker.addEventListener('error', (e) => {
|
||||
console.log("worker error:" + e)
|
||||
})
|
||||
|
|
|
@ -70,7 +70,7 @@ export default class XRSession extends EventHandlerBase {
|
|||
})
|
||||
}
|
||||
|
||||
requestVideoFrames(callback) {
|
||||
setVideoFrameHandler(callback) {
|
||||
if (callback instanceof Worker) {
|
||||
var worker = callback;
|
||||
callback = (ev => {
|
||||
|
@ -86,6 +86,10 @@ export default class XRSession extends EventHandlerBase {
|
|||
this._display.addEventListener("videoFrame", callback)
|
||||
}
|
||||
|
||||
requestVideoFrame() {
|
||||
this._display._requestVideoFrame();
|
||||
}
|
||||
|
||||
_createPresentationFrame(){
|
||||
return new XRPresentationFrame(this)
|
||||
}
|
||||
|
|
|
@ -210,7 +210,9 @@ export default class FlatDisplay extends XRDisplay {
|
|||
} catch(e) {
|
||||
console.error('computer vision callback error', e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_requestVideoFrame() {
|
||||
// Do whatever is needed with the image buffers here, and then call
|
||||
// this._arKitWrapper.requestComputerVisionData() to request a new one
|
||||
this._arKitWrapper.requestComputerVisionData()
|
||||
|
|
|
@ -40,25 +40,25 @@ export default class ARKitWrapper extends EventHandlerBase {
|
|||
this._isInitialized = false
|
||||
this._rawARData = null
|
||||
|
||||
// worker to convert buffers
|
||||
var blobURL = this._buildWorkerBlob()
|
||||
this._worker = new Worker(blobURL);
|
||||
URL.revokeObjectURL(blobURL);
|
||||
// // worker to convert buffers
|
||||
// var blobURL = this._buildWorkerBlob()
|
||||
// this._worker = new Worker(blobURL);
|
||||
// URL.revokeObjectURL(blobURL);
|
||||
|
||||
var self = this;
|
||||
this._worker.onmessage = function (ev) {
|
||||
setTimeout(function () {
|
||||
self.dispatchEvent(
|
||||
new CustomEvent(
|
||||
ARKitWrapper.COMPUTER_VISION_DATA,
|
||||
{
|
||||
source: self,
|
||||
detail: ev.data
|
||||
}
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
// var self = this;
|
||||
// this._worker.onmessage = function (ev) {
|
||||
// setTimeout(function () {
|
||||
// self.dispatchEvent(
|
||||
// new CustomEvent(
|
||||
// ARKitWrapper.COMPUTER_VISION_DATA,
|
||||
// {
|
||||
// source: self,
|
||||
// detail: ev.data
|
||||
// }
|
||||
// )
|
||||
// )
|
||||
// })
|
||||
// }
|
||||
|
||||
this.lightIntensity = 1000;
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче