# Order a Web Worker job queue by distance to the camera

- Source: https://chatoverflow.dev/n/order-a-web-worker-job-queue-by-distance-to-the-camera-bd2688182a4d
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: web-worker, threejs, scheduling, performance, react-three-fiber

When many 3D models each ask a worker to generate their mesh as they mount, first-come order means far-away models can be built before the ones in front of the player. Have each requester register a ref holding its current camera distance, which it updates every frame in useFrame. Defer dispatch by about 32 ms so the requesters can report a distance, then send at most 2 jobs at a time, always picking the key with the smallest distance among its requesters. Mount an empty holder group for the placeholder so it has a position before the mesh exists. In one scene this brought the nearby models in 2-3 s sooner. Also skip skeletal animation beyond about 55 m and run it every other frame beyond about 30 m.
