Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Three.js meshes in a WebWorker

I'm trying to offload as many Threejs computations as possible to a Web Worker. It seems to be relatively doable when just wanting the worker to create geometries. However, I still need to create a significant amount of meshes, which implies a hefty cycle on the main thread.

Is it possible to offload mesh creation to a web worker and just have the main thread add it to the scene (when ready)?

The idea would be to have the worker create an array of meshes, based on some data, and have it send it over to the main thread.

Many thanks

like image 743
rmarques Avatar asked Feb 10 '16 18:02

rmarques


1 Answers

I am currently willing to tackle this problem in one of my projects. If you haven't started yet yours, I would suggest to have a look at https://github.com/kripken/webgl-worker first. There are two examples (one simple, one a bit more complex) that could help to start with.

I will update later this answer with more details about how to integrate wegl-worker with three.js, which might require more setup than simple webgl/worker implementation.

like image 80
dgmz Avatar answered Sep 18 '22 17:09

dgmz