Hi Team,
I’m trying to use Cesium.TaskProcessor.scheduleTask to use web worker that can use Cesium object.
I’m facing issue in getting the resolve value from promise object of Cesium.TaskProcessor.scheduleTask
Tried #1, #2 method below but both failed,
main.js
let worker = new Cesium.TaskProcessor('worker.js');
let resPromise = worker.scheduleTask({"foo":"bar"}, [this._viewer.scene]);
console.log("Cesium worker",worker)
console.log("resPromise",resPromise)
#1
Cesium.when(resPromise,e =>{
console.log("cesium task1", e)
});
#2
resPromise.then(e=>{
console.log("cesium task2", e)
})
worker.js
self.onmessage= function(ev) {
console.log("workerrrrrrrr, public",ev);
postMessage("hello from worker");
Please give me a working snippet if able.
REF
https://cesium.com/learn/cesiumjs/ref-doc/TaskProcessor.html?classFilter=task
var taskProcessor = new Cesium.TaskProcessor('myWorkerPath');
var promise = taskProcessor.scheduleTask({
someParameter : true,
another : 'hello'
});
if (!Cesium.defined(promise)) {
// too many active tasks - try again later
} else {
Cesium.when(promise, function(result) {
// use the result of the task
});
}
Thanks in advance,
Hiroshi