toTriangleSoup method

MeshGeometry toTriangleSoup()

Returns a geometry without containing indices. If the geometry is already non-indexed, the method performs no changes.

Implementation

MeshGeometry toTriangleSoup() {
	final indices = this.indices;

	if ( indices != null) {
		final vertices = this.vertices;
		final newVertices = Float32List( indices.length * 3 );

		for ( int i = 0, l = indices.length; i < l; i ++ ) {
			final a = indices[ i ];
			final stride = 3;

			newVertices[ i * stride ] = vertices[ a * stride ];
			newVertices[ ( i * stride ) + 1 ] = vertices[ ( a * stride ) + 1 ];
			newVertices[ ( i * stride ) + 2 ] = vertices[ ( a * stride ) + 2 ];
		}

		return MeshGeometry( newVertices );
	}
    else {
		return this;
	}
}