Matrix3/Matrix4: Refactored .applyToBuffer() #10355

Merged
merged 5 commits into from Dec 15, 2016

Projects

None yet

3 participants

@Mugen87
Contributor
Mugen87 commented Dec 14, 2016 edited

This PR renames .applyToBuffer() to . applyToBufferAttribute(). Besides, the methods now support InterleavedBufferAttribute.

docs/api/math/Matrix4.html
- Multiplies (applies) the upper 3x3 matrix of this matrix to every 3D vector in the [page:ArrayBuffer buffer].
+ Multiplies (applies) the upper 3x3 matrix of this matrix to every 3D vector in the [page:BufferAttribute attribute].
@WestLangley
WestLangley Dec 14, 2016 Collaborator

upper 3x3 ? Also, what is the use case for this method?

@Mugen87
Mugen87 Dec 14, 2016 Contributor

I've removed that part of the sentence. The following commit originally added the methods 1b6effb.

docs/api/math/Matrix4.html
- Default is the last element in the array.<br /><br />
+ [page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br />
+ [page:Number offset] - (optional) index in the attribute of the first vector. Default is 0.<br />
+ [page:Number count] - (optional) index in the attribute of the last vector. Default is the last element in the attribute.<br /><br />
@WestLangley
WestLangley Dec 14, 2016 Collaborator

count is a quantity, not an index.

docs/api/math/Matrix4.html
- [page:Number offset] - (optional) index in the array of the first vector's x component. Default is 0.<br />
- [page:Number length] - (optional) index in the array of the last vector's z component.
- Default is the last element in the array.<br /><br />
+ [page:BufferAttribute attribute] - An attribute of floats that represent 3D vectors.<br />
@WestLangley
WestLangley Dec 14, 2016 Collaborator

This method only makes sense with certain buffer attributes, right? -- even though it is generically-named.

@Mugen87
Mugen87 Dec 14, 2016 Contributor

I can't think of a better name than . applyToBufferAttribute(). Any suggestions?

@Mugen87
Contributor
Mugen87 commented Dec 14, 2016 edited

Um, looks like these methods are not used in the entire repo so far...

@WestLangley
Collaborator

Um, looks like these methods are not used in the entire repo so far...

Right. What is the use case? And why offset and count?

@Mugen87
Contributor
Mugen87 commented Dec 14, 2016 edited

And why offset and count?

I think the original author added these parameters (offset and length) to keep the interface and logic of applyToBuffer similar to applyToVector3Array.

@WestLangley
Collaborator

Let's see what others think...

@mrdoob
Owner
mrdoob commented Dec 14, 2016

Feel free to remove what's not needed 👍

@Mugen87
Contributor
Mugen87 commented Dec 14, 2016 edited

We need these methods if we want to make BufferGeometry .applyMatrix() compatible to InterleavedBufferAttribute, see here.

@Mugen87
Contributor
Mugen87 commented Dec 14, 2016

Why not start with this simplified approach? . applyToBufferAttribute() without offset and count. In this way the methods can be used in BufferGeometry .applyMatrix().

@WestLangley
Collaborator

Why not start with this simplified approach? . applyToBufferAttribute() without offset and count.

That seems reasonable to me. Can you remove applyToVector3Array()? There is only one example use case, which can be refactored or inlined if necessary.

@mrdoob mrdoob merged commit 61736b1 into mrdoob:dev Dec 15, 2016
@mrdoob
Owner
mrdoob commented Dec 15, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment