Three.js: Proposal: Add new BufferAttribute methods

Created on 26 Nov 2019  路  7Comments  路  Source: mrdoob/three.js

Vector3 has these methods:

Vector3.applyMatrix3( matrix3 );
Vector3.applyNormalMatrix( matrix3 );
Vector3.applyMatrix4( matrix4 );
Vector3.transformDirection( matrix4 );

We need to be able to apply the same transforms to each element of a BufferAttribute.

I propose we add the following methods:

BufferAtribute.applyMatrix3( matrix3 );       // to replace Matrix3.applyToBufferAttribute()
BufferAtribute.applyNormalMatrix( matrix3 );  // new
BufferAtribute.applyMatrix4( matrix4 );       // to replace Matrix4.applyToBufferAttribute()
BufferAtribute.transformDirection( matrix4 ); // new

Related:

17997

18001 bug

18005 bug

Suggestions for alternate APIs welcome.

Enhancement

Most helpful comment

OK, I'll do it.

All 7 comments

transformDirection() > applyDirectionMatrix()?

transformDirection() > applyDirectionMatrix()

transformDirection() is applying a transform to the vector, but interpreting the vector not as a position vector, but as a direction vector. That method was introduces a long time ago and I think the name is OK.

I never liked the API

matrix.applyToBufferAttribute( attribute );

and this is an opportunity to replace it with an API that is, in my opinion, more natural.

Moving them to BufferAttribute sounds good to me. Was just trying to unify the last name.

Moving them to BufferAttribute sounds good to me.

馃憤

OK, I'll do it.

Closed in #18070.

Was this page helpful?
0 / 5 - 0 ratings