stroke method
void
stroke(
- Vector3 position1,
- Vector3 position2,
- Matrix4 matrix1,
- Matrix4 matrix2,
Implementation
void stroke(Vector3 position1,Vector3 position2,Matrix4 matrix1,Matrix4 matrix2 ) {
if ( position1.distanceToSquared( position2 ) == 0 ) return;
int count = geometry.drawRange['count']!;
final points = getPoints( size );
for (int i = 0, il = points.length; i < il; i ++ ) {
final vertex1 = points[ i ];
final vertex2 = points[ ( i + 1 ) % il ];
// positions
vector1.setFrom( vertex1 ).applyMatrix4( matrix2 ).add( position2 );
vector2.setFrom( vertex2 ).applyMatrix4( matrix2 ).add( position2 );
vector3.setFrom( vertex2 ).applyMatrix4( matrix1 ).add( position1 );
vector4.setFrom( vertex1 ).applyMatrix4( matrix1 ).add( position1 );
vector1.copyIntoNativeArray( positions.array, ( count + 0 ) * 3 );
vector2.copyIntoNativeArray( positions.array, ( count + 1 ) * 3 );
vector4.copyIntoNativeArray( positions.array, ( count + 2 ) * 3 );
vector2.copyIntoNativeArray( positions.array, ( count + 3 ) * 3 );
vector3.copyIntoNativeArray( positions.array, ( count + 4 ) * 3 );
vector4.copyIntoNativeArray( positions.array, ( count + 5 ) * 3 );
// normals
vector1.setFrom( vertex1 ).applyMatrix4( matrix2 ).normalize();
vector2.setFrom( vertex2 ).applyMatrix4( matrix2 ).normalize();
vector3.setFrom( vertex2 ).applyMatrix4( matrix1 ).normalize();
vector4.setFrom( vertex1 ).applyMatrix4( matrix1 ).normalize();
vector1.copyIntoNativeArray( normals.array, ( count + 0 ) * 3 );
vector2.copyIntoNativeArray( normals.array, ( count + 1 ) * 3 );
vector4.copyIntoNativeArray( normals.array, ( count + 2 ) * 3 );
vector2.copyIntoNativeArray( normals.array, ( count + 3 ) * 3 );
vector3.copyIntoNativeArray( normals.array, ( count + 4 ) * 3 );
vector4.copyIntoNativeArray( normals.array, ( count + 5 ) * 3 );
// colors
color.copyIntoArray( colors.array, ( count + 0 ) * 3 );
color.copyIntoArray( colors.array, ( count + 1 ) * 3 );
color.copyIntoArray( colors.array, ( count + 2 ) * 3 );
color.copyIntoArray( colors.array, ( count + 3 ) * 3 );
color.copyIntoArray( colors.array, ( count + 4 ) * 3 );
color.copyIntoArray( colors.array, ( count + 5 ) * 3 );
count += 6;
}
geometry.drawRange['count'] = count;
}