-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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: Fix the behavior of ".set" function #24511
Conversation
Hmmm good catch here, thanks. I think we will either decide what the type of the input array is supposed to be, or else to handle a few edge cases. Consider a normalized Uint8Array BufferAttribute.
I'd also point out that Given that the input array to the BufferAttribute was presumably a Uint8Array containing integers, I wonder if we should just assume any array inputs to these methods will not require further conversion? Or I suppose we could compare the type of the array vs. the internal array. 😕 |
I think it will get confusing if we handle anything like this. I think its okay to assume that the explicit values being passed into the function are the ones the user is trying to use - ie treat every array as a regular, non typed array as this PR does.
I'm okay with adding "offset" to "copyArray". But I do think that if "set" remains it needs to normalize / denormalize values since the naming aligns with the other setter / getter functions |
Could you say more about why you expect that? By another convention (THREE.Color, THREE.VectorX) our const array = new Uint8Array( [ 0, 64, 0, ... ] );
const attribute = new BufferAttribute( array.slice(), 3, true );
attribute.getY( 0 ); // 0.25
attibute.set( array.slice() );
attribute.getY( 0 ); // 0.0 If we are going to drop support for u8, i8, u16, i16, u32, and i32 arrays in this method, I think we would need to include some warnings or errors rather than doing this silently. |
Hm you're right. I suppose there's just an inconsistency now from either perspective. The other But either way this isn't what I intended to address in this PR. I'm happy to change it to whatever is preferred. I don't feel strongly enough about the behavior here to spend too much time discussing it. |
I would prefer to merge this PR so the regression is fixed. Let's discuss a change in behavior elsewhere. |
Merging to include this PR in |
I think it would be best if |
Followup: #24526 |
Related issue: #22874
Description
The
BufferAttribute.set
function takes an array not a scalar value.cc @donmccurdy