File: WorkerPool.md | Updated: 11/15/2025
A simple pool for managing Web Workers.
WorkerPool is an addon, and must be imported explicitly, see Installation#Addons.
import { WorkerPool } from 'three/addons/utils/WorkerPool.js';
Constructs a new Worker pool.
pool | The size of the pool. Default is 4.
---|---
The size of the pool.
Default is 4.
A message queue.
A factory function for creating workers.
The current worker status.
An array of Workers.
An array with resolve functions for messages.
Terminates all Workers of this pool. Call this method whenever this Worker pool is no longer used in your app.
Post a message to an idle Worker. If no Worker is available, the message is pushed into a message queue for later processing.
msg | The message.
---|---
transfer | An array with array buffers for data transfer.
Returns: A Promise that resolves when the message has been processed.
Sets a function that is responsible for creating Workers.
workerCreator | The worker creator function.
---|---
Sets the Worker limit
pool | The size of the pool.
---|---