# Three-bvh-csg with web worker

**URL:** <https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610>\
**Category:** Questions\
**Tags:** web-worker, bvh, three-bvh, csg, materials, geometry\
**Created:** [December 24, 2024, 2:35pm UTC](https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610 "2024-12-24T14:35:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cien267](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/cien267/32/52450_2.png) [@Cien267](https://discourse.threejs.org/u/Cien267)\
**Post date:** [December 24, 2024, 2:35pm UTC](https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610/1 "2024-12-24T14:35:03Z")

</div>

Hello everyone,  
I am using `three-bvh-csg` library, but due to the complexity of the objects, the subtraction operation takes a very long time. While it is processing, my website becomes unresponsive, and I can’t even display a loading indicator.

I tried using a Web Worker, but the Mesh is too large to be sent via `postMessage`.

Are there any ways to optimize or improve this process?

---

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [December 24, 2024, 3:10pm UTC](https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610/2 "2024-12-24T15:10:49Z")

</div>

Define “too large” 👀 ? What does the mesh represent? Can it be split into smaller contextual fragments?

(As for the loader - you can show it before the page becomes unresponsive, just make sure to load the model after the loader is already visible. Not that it’d improve the user experience much - frozen website has quite a big chance of crashing the browser or triggering a moral asking the user to force quit the page.)

---

<div class="post-metadata">

**Author:** ![PavelBoytchev](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pavelboytchev/32/38639_2.png) [@PavelBoytchev](https://discourse.threejs.org/u/PavelBoytchev)\
**Post date:** [December 24, 2024, 3:32pm UTC](https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610/3 "2024-12-24T15:32:36Z")

</div>

> [@Cien267](#):
>
> I can’t even display a loading indicator

I’ve heard that CSS load indicators run in a separate thread, so they are not blocked when JS is blocking the UI.

---

<div class="post-metadata">

**Author:** ![manthrax](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/manthrax/32/2596_2.png) [@manthrax](https://discourse.threejs.org/u/manthrax)\
**Post date:** [December 24, 2024, 8:31pm UTC](https://discourse.threejs.org/t/three-bvh-csg-with-web-worker/75610/4 "2024-12-24T20:31:03Z")

</div>

Are you using transferable objects to get the model out of the worker? i.e. returning the buffers themselves directly (zero copy) to the main thread, and setting them back into a new empty geometries attributes?

> **[Transferable objects - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Transferable_objects)**
>
> Transferable objects are objects that own resources that can be transferred from one context to another, ensuring that the resources are only available in one context at a time.
> Following a transfer, the original object is no longer usable; it no...
