-
-
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
BufferAttribute: Add generic vector "component" getter / setter #24515
Conversation
I would be glad if we could make for ( let i = 0, el = []; i < attr.count; i += 2 ) {
// VectorN → Array → BufferAttribute
attr.setItem( i, vector.toArray( el ) );
// BufferAttribute → Array → BufferAttribute
attr.setItem( i, attr2.getItem( i, el ) );
} Arguably the 1 Alternatively, 'element' → setElement/getElement? |
Please also change current usages of |
We could - in my code I'd probably keep the two loops in some cases though because I find it more readable. It makes more sense to me to think of the elements in the array as vectors and access individual components.
These can be fairly hot functions in tight loops so keeping the implementations as simple as possible for performance is important imo.
If we change to a setter that just sets the individual elements rather than taking an index / component then this name change makes sense. |
Let's wait on this and #24512 for r145 if that's ok? |
Any updated thoughts on this? |
I'm OK with merging this after it's rebased. 👍🏻 |
Me too! |
# Conflicts: # docs/api/en/core/BufferAttribute.html # docs/api/ko/core/BufferAttribute.html # docs/api/zh/core/BufferAttribute.html
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
Great! Just updated. Also updating the docs is becoming quite inconvenient and error prone now that there are 6 pages that need to be updated for new changes. I wonder if there's any way we could shift this so only the english docs are updated and other language maintainers can look at a diff of some kind. |
My thoughts: #24984 (comment) |
Related issue: #--
Description
When writing functions that process arbitrary buffer attributes it's common to need code that can handle a buffer attribute storing components of arbitrary size. However there's currently no function for reading x, y, z, or w based on component index. This leads to writing for loops with conditions to branch and use getX, getY, getZ, etc which is far more verbose.
Some examples of current workarounds are here, here, here, and here.
All these cases would be much cleaner and more understandable if I could just write
instead of something like
cc @donmccurdy