web-worker

BreezeJs with dedicated web worker

半世苍凉 提交于 2020-01-01 17:43:10
问题 I am trying to initialize a Breeze manager inside a 'Web Worker'. RequireJs, knockout, q, breeze are being imported inside the worker. After a call to: EntityQuery.from('name').using(manager).execute() , the following error appears: Uncaught Error: Q is undefined. Are you missing Q.js? See https://github.com/kriskowal/q . A live preview is uploaded here http://plnkr.co/edit/meXjKa?p=preview (plunk supports downloading for easier debug). EDIT -- relevant code Worker.js importScripts('knockout

BreezeJs with dedicated web worker

ⅰ亾dé卋堺 提交于 2020-01-01 17:43:06
问题 I am trying to initialize a Breeze manager inside a 'Web Worker'. RequireJs, knockout, q, breeze are being imported inside the worker. After a call to: EntityQuery.from('name').using(manager).execute() , the following error appears: Uncaught Error: Q is undefined. Are you missing Q.js? See https://github.com/kriskowal/q . A live preview is uploaded here http://plnkr.co/edit/meXjKa?p=preview (plunk supports downloading for easier debug). EDIT -- relevant code Worker.js importScripts('knockout

web-workers in Rails projects

梦想与她 提交于 2020-01-01 11:51:53
问题 I try to use web workers to be able to run several javascript codes at the same time. To start the worker I put the following into my javascript code section: var worker = new Worker("my_task.js"); worker.onmessage = function(e) { console.log('Worker said: ', e.data); }; worker.postMessage("test"); my_task.js is the same folder as the file that holds the code above. This is how my_task.js looks like: self.addEventListener('message', function(e) { self.postMessage(e.data); }, false); But there

web-workers in Rails projects

风格不统一 提交于 2020-01-01 11:51:15
问题 I try to use web workers to be able to run several javascript codes at the same time. To start the worker I put the following into my javascript code section: var worker = new Worker("my_task.js"); worker.onmessage = function(e) { console.log('Worker said: ', e.data); }; worker.postMessage("test"); my_task.js is the same folder as the file that holds the code above. This is how my_task.js looks like: self.addEventListener('message', function(e) { self.postMessage(e.data); }, false); But there

Spawning a Shared Worker in a Dedicated Worker

孤者浪人 提交于 2019-12-31 03:21:07
问题 I'm playing around with WebWorkers. Somehow I had the idea to let the different instances of a page know when another one is closed. Therefore I wrote a Shared Worker and it works fine. But now I want a Dedicated Worker to act as an interface to the Shared Worker. So that expensive actions in the UI won't affect the continous communication with the Shared Worker. But I get the error, SharedWorker was not defined. An idea would be to use MessageChannel, but I want it to run at least in Firefox

How to efficiently convert THREE.Geometry to ArrayBuffer, File or Blob?

五迷三道 提交于 2019-12-29 06:30:12
问题 I'd like to move a piece of my code in which i build a THREE.Geometry object to a HTML5 Web Worker. Since i don't want to serialize it to a string (for obvious performance purposes), i'd like to convert it to a Transferable Object like ArrayBuffer, File or Blob so i can pass it "by reference". Do you know a efficient way to convert a THREE.Geometry to one of those objects ? 回答1: The most efficient way is to use the existing geometry buffers such as: geometryGroup.__vertexArray geometryGroup._

What can I use with Web Workers?

青春壹個敷衍的年華 提交于 2019-12-29 05:45:10
问题 I have a few questions about web workers Does the worker have access to storage? E.g. indexedDB/webSQL and local storage of the file the worker was initiated from? How can i include a file in a worker? I have a functions.js which has alot of quick app related functions and it really wont make sense to copy paste the file's contents in a worker only to have two different places up update my functions. Can I have a DOM inside a worker? like load an audio file in a temp audio tag to read its

HTML5 navigator.geolocation in Web Workers

怎甘沉沦 提交于 2019-12-29 01:35:14
问题 I am trying to move my code for navigator.geolocation in a web worker. I tried it with Chrome and Safari but getting 'undefined' on var isGPSSupported = navigator.geolocation; Frustrated... they said in specification that 'navigator' object should be supported in web workers... My code is below: index.js var gpsWorker = new Worker("app/gpsworker.js"); gpsWorker.onmessage = function (e) { alert(e.data); }; gpsWorker.postMessage("Start GPS!"); gpsWorker.onerror = function (e) { alert("Error in

Using transferable objects from a Web Worker

ⅰ亾dé卋堺 提交于 2019-12-28 09:15:28
问题 I currently have this code to create a Web Worker: w = new Worker("webwork.js"); w.onmessage = function(event) { alert(event.data); } And then the webwork.js code for the Web Worker: self.onmessage = function(event) { //var ss=r; //Causes error because of undefined var ss=""; for(var currProp in event) { ss+=("event."+currProp+"="+event[currProp]+"\n"); } postMessage(ss); } Now I want to transfer a 128-Megabyte ArrayBuffer with this code: var r = new ArrayBuffer(1048576*128); w.postMessage(0,

Using transferable objects from a Web Worker

ε祈祈猫儿з 提交于 2019-12-28 09:15:12
问题 I currently have this code to create a Web Worker: w = new Worker("webwork.js"); w.onmessage = function(event) { alert(event.data); } And then the webwork.js code for the Web Worker: self.onmessage = function(event) { //var ss=r; //Causes error because of undefined var ss=""; for(var currProp in event) { ss+=("event."+currProp+"="+event[currProp]+"\n"); } postMessage(ss); } Now I want to transfer a 128-Megabyte ArrayBuffer with this code: var r = new ArrayBuffer(1048576*128); w.postMessage(0,