Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute bounds tree after adding mesh to group/scene? #662

Open
neilrackett opened this issue May 8, 2024 · 3 comments
Open

Compute bounds tree after adding mesh to group/scene? #662

neilrackett opened this issue May 8, 2024 · 3 comments
Labels
question Further information is requested

Comments

@neilrackett
Copy link

We're using BVH to boost the performance of a small number of features in a larger app, computing the bounds tree before adding the associated mesh to either a group or a scene. This works well, but adds time at startup for something that may never get used.

What I'd like to do is compute the bounds tree, either using a Worker or on-demand, after a mesh has been added to a group and/or scene, but find that running computeBoundsTree() or new MeshBVH(geom) after the associated mesh has been added to something else, even if it hasn't been added to the scene, the script just hangs. Forever.

So I just wanted to ask if this is actually possible?

Example

const geom = new THREE.TorusKnotBufferGeometry( 10, 3, 400, 100 );
const mesh = new THREE.Mesh( geom, material );
const group = new THREE.Group();

group.add(mesh);
geom.computeBoundsTree();

// It never gets here
@neilrackett neilrackett added the enhancement New feature or request label May 8, 2024
@gkjohnson
Copy link
Owner

This should work just fine and have no impact on the generation time of the BVH itself. Do you have a live example using something like jsfiddle showing the issue?

@gkjohnson gkjohnson added question Further information is requested and removed enhancement New feature or request labels May 9, 2024
@neilrackett
Copy link
Author

I'll put a fiddle or similar together -- is there an existing template I can use that takes care of the boilerplate?

@gkjohnson
Copy link
Owner

This official three.js one is a reasonable one to start with:

https://jsfiddle.net/v98k6oze/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants