|
@@ -64,7 +64,7 @@ class SimplifyModifier {
|
|
|
|
|
|
const v = new Vector3().fromBufferAttribute( positionAttribute, i );
|
|
|
|
|
|
- const vertex = new Vertex( v, i );
|
|
|
+ const vertex = new Vertex( v );
|
|
|
vertices.push( vertex );
|
|
|
|
|
|
}
|
|
@@ -141,6 +141,8 @@ class SimplifyModifier {
|
|
|
|
|
|
const vertex = vertices[ i ].position;
|
|
|
position.push( vertex.x, vertex.y, vertex.z );
|
|
|
+ // cache final index to GREATLY speed up faces reconstruction
|
|
|
+ vertices[ i ].id = i;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -149,12 +151,7 @@ class SimplifyModifier {
|
|
|
for ( let i = 0; i < faces.length; i ++ ) {
|
|
|
|
|
|
const face = faces[ i ];
|
|
|
-
|
|
|
- const a = vertices.indexOf( face.v1 );
|
|
|
- const b = vertices.indexOf( face.v2 );
|
|
|
- const c = vertices.indexOf( face.v3 );
|
|
|
-
|
|
|
- index.push( a, b, c );
|
|
|
+ index.push( face.v1.id, face.v2.id, face.v3.id );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -500,11 +497,11 @@ class Triangle {
|
|
|
|
|
|
class Vertex {
|
|
|
|
|
|
- constructor( v, id ) {
|
|
|
+ constructor( v ) {
|
|
|
|
|
|
this.position = v;
|
|
|
-
|
|
|
- this.id = id; // old index id
|
|
|
+
|
|
|
+ this.id = -1; // external use position in vertices list (for e.g. face generation)
|
|
|
|
|
|
this.faces = []; // faces vertex is connected
|
|
|
this.neighbors = []; // neighbouring vertices aka "adjacentVertices"
|