-
-
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
BufferAttribute getters #5729
Comments
What should it return? |
Perhaps an Array of length itemSize? Assuming we are working with positions (which is what the getters would be nice for), we could have
or
Vector3 could also gain a constructor that receives an Array of size 3 (if we really want to reduce verbosity) =P EDIT: Overall this would make it easier to combine Raycasting and BufferGeometry since intersectObjects returns an Array of objects each with an index. But that index is transformed, and because of that we have to multiply it by itemSize to access the respective value in a BufferGeometry. However, we can use it as is when calling setXYZ(...) |
I am not a big fan of using But perhaps we can do something much simpler... Something like this:
We can define the required new methods using the following pattern:
|
After reading your comment I went to read the source code and found that that snippet is very similar to the implementation approach of
My question now is: Why bother multiplying the index by itemSize if we're just gonna return 3 components? Is it expected to have a user use setXYZ and hypothetical getXYZ outside of a itemSize == 3 scenario? Retrospectively, the same situation happens with setXYZW. |
A user can create a BTW, we could add an optional
|
Fair enough. I like the optional parameter, though =) |
Looks good to me! 👍 |
Fixed by #5735. |
Hi guys,
Is there a way of getting the xyz coords stored in a BufferAttribute without having to do something like:
This is kinda verbose... =(
There's already setXYZ(...), and more, that work with itemSize. Equivalent getters would be awesome =)
The resulting code would be something like:
Thank you!
The text was updated successfully, but these errors were encountered: