-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
SceneUtils: Add reduceVertices(). #22742
Conversation
Oh so it's like the Array.prototype.reduce() function but for vertices. Maybe it's easier for users if the signature is the same as Array.reduce(), meaning first argument is the function and second argument the initial value? |
Sort of, but the difference is that it does not have to reduce to a |
For the time being I would suggest to add the method to SceneUtils. |
Sorry for the delay, I've addressed the comments now. I was reminded of this while fixing this function in MV for skinned meshes: google/model-viewer#3272 I was hoping to fix three's bounding box computation, but since it's inside of BufferGeometry it can't access the bones. This function can be a work-around in the meanwhile, but it seems like there should be a more core way of handling this. |
Okay, updated from |
Actually, @donmccurdy would you mind taking a look at this? It seems to work quite well generally, but it still seems to fail your example: google/model-viewer#2450 (comment) |
Interesting, so think I found the final remaining problem. The issue with the old CesiumMan model was that is used |
It does seem like we're going to need something like #22874 sooner or later, either directly on THREE.BufferAttribute or in a utility function. |
Agreed; is there any problem with #22874? I'd like to merge that first so I can clean this up and test it. |
Just bumping this thread now that #22874 has been merged. :) |
Okay, I think this one's ready now. Supposedly I should run |
You shouldn't, all building is done by mrdoob in separate commits. |
Thank you! |
Note: In functional languages such function is usually called |
I wrote this some time ago to support model-viewer's automatic camera framing (which is tight without allowing the object to leave the frame for any orbit parameters with constant zoom). I always thought it might be a useful generic method for three.js, so I figured I'd contribute it and see if anyone agrees it might be useful to others.