-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
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
BatchedMesh: add method to check if geometry can be added #27979
Comments
Of course you can currently use a try / catch block to test if adding the geometry is successful, but I understand it's not ideal.
In what way is this slow? I'm looking at the code and it doesn't look like it should take an unreasonable amount of time if it just returned success or not. |
Perhaps something else in the code was causing the performance issue - I can't say for sure right now, sorry for implying. What do you think about officially exposing the method or adding a public method for testing which returns information if (and if not) the object can be added: |
What would you plan to do with the "reason" string? An API structured such that you can do the following feels best: if ( mesh.canAddGeometry( geometry ) ) {
const id = mesh.addGeometry( geometry );
// ...
} |
The reason for this object return type was just so that it could also be called internally (and replace |
Got it - I think this can be achieved with an internal function while retaining a simple public facing function that can be used like above. |
Description
How should i detect if my BufferGeometry can be added to a BatchedMesh before calling addGeometry?
I know there's
_validateGeometry
- but this method seems not meant to be part of the public API. I'd need a way to detect if calling addGeometry is safe.Solution
Expose
_validateGeometry
- not sure if it should throw however - perhaps it could return an object or string containing a reason for why it can't be added (and then the addGeometry call could still throw)Alternatives
Calling(this is very slow) - but an official API method would be preferred_validateGeometry
Additional context
No response
The text was updated successfully, but these errors were encountered: