gkjohnson / three-mesh-bvh

A BVH implementation to speed up raycasting and enable spatial queries against three.js meshes.
https://gkjohnson.github.io/three-mesh-bvh/example/bundle/raycast.html
MIT License
2.56k stars 268 forks source link

Add example of generation via webworker #139

Closed gkjohnson closed 4 years ago

gkjohnson commented 4 years ago

Add an example demonstrating how to create a BVH via webworker -- maybe even provide a utility out of the box.

import { asyncGenerateMeshBVH } from 'three-mesh-bvh';

asyncGenerateMeshBVH( geometry, { copyBuffers: false } )
    .then( ( { geometry, bvh } ) => {

        // geometry is available to be used again
        geometry.boundsTree = bvh;

    } );
Ely-S commented 4 years ago

:+1: