I am using Three.js Raycaster method in my web based car race game. But due to the heavy computations it is consuming a lot of CPU Cycles hence leading to a drop in fps. I am thinking of exporting the RayCaster method of Three.js on WebWorker. Can anyone guide me how to accomplish it , or is it possible at all ?
Asked
Active
Viewed 1,658 times
1 Answers
4
There was a question about offloading merge geometry method to a web worker, this should help you get your head around the problem.
While the merge geometry method is not ideal for a web worker, other things like physics and perhaps your ray cast method are.
Merging geometries using a WebWorker?
The key being that whatever work you do in the web worker will have to be sent to the main thread as an array of floats.
So you will need to pack your data up and unpack it on the other end.
This works well for physics engines when they are responding with x,y,z coordinates and the entire system is simulated in the web worker and positions are passed back to the main thread for rendering.

Community
- 1
- 1

mattdlockyer
- 6,984
- 4
- 40
- 44