getVertexPosition method
Returns the local-space position of the vertex at the given index, taking into account the current animation state of both morph targets and skinning.
index
- The vertex index.
target
- The target object that is used to store the method's result.
return Vector3 The vertex position in local space.
Implementation
Vector3 getVertexPosition(int index, Vector3 target ) {
final geometry = this.geometry;
final position = geometry?.attributes['position'];
final morphPosition = geometry?.morphAttributes['position'];
final morphTargetsRelative = geometry?.morphTargetsRelative;
target.fromBuffer( position, index );
final morphInfluences = this.morphTargetInfluences;
if ( morphPosition != null && morphInfluences.isNotEmpty) {
_morphA.setValues( 0, 0, 0 );
for (int i = 0, il = morphPosition.length; i < il; i ++ ) {
final influence = morphInfluences[ i ];
final morphAttribute = morphPosition[ i ];
if ( influence == 0 ) continue;
_tempA.fromBuffer( morphAttribute, index );
if ( morphTargetsRelative != null) {
_morphA.addScaled( _tempA, influence );
} else {
_morphA.addScaled( _tempA.sub( target ), influence );
}
}
target.add( _morphA );
}
return target;
}