gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
552 stars 45 forks source link

Can't be used with STL model #83

Closed below-1 closed 1 year ago

below-1 commented 1 year ago

STL model doesn't have UV mapping. When apply CSG operation to loaded STL object, It will throw an error.

gkjohnson commented 1 year ago

Hello! What error is thrown? It's important for each of the brushes to have the same vertex attributes but perhaps that can be communicated more effectively in the docs and errors.

below-1 commented 1 year ago

Sorry just answering now. After reading the source, it appears UV attributes must exists in operated geometry. So I decided to generate UV for my STL model.

gkjohnson commented 1 year ago

it appears UV attributes must exists in operated geometry

This isn't the case. It's just important that both geometries share the same attributes. Either adding UVs to the STL or removing them from the other geometry should work

brucedjones commented 1 year ago

Hm looks like uv's are assumed. I had an issue where one model has a uv attribute and another doesn't. I called deleteAttribute('uv') on the model that has is, but then ran in to an error because the evaluator does assume there is a uv attribute:

https://github.com/gkjohnson/three-bvh-csg/blob/7ec1b6f839bfb0eb95d43cadbf6d56f1eacee4f6/src/core/Evaluator.js#L129

@gkjohnson any thoughts on how to work around this?

brucedjones commented 1 year ago

I confirmed locally that simply removing the uv property there allows everything to work