Reputation: 1086
I want to dynamically add new faces to a mesh. I keep getting this console warning:
THREE.BufferAttribute.copyVector3sArray(): vector is undefined
This is the simplest example that still causes it. It works - this example correctly produces a single triangle that's a clone of the geometry's first face - but I can't get rid of the warning.
var vertices = this.body.geometry.vertices;
var faces = this.body.geometry.faces;
var face = faces[0];
var a = face.a;
var b = face.b;
var c = face.c;
var va = vertices[a].clone();
var vb = vertices[b].clone();
var vc = vertices[c].clone();
vertices = [];
vertices.push(va);
vertices.push(vb);
vertices.push(vc);
this.body.geometry.vertices = vertices;
this.body.geometry.faces = faces;
It looks a lot like this question, except that I'm not accidentally assigning a vector to a vertex's index, so I can't use that solution.
Upvotes: 0
Views: 457
Reputation: 1086
It appears the undefined vector was a vertex normal. Running
this.body.geometry.computeFlatVertexNormals();
solved the problem. (Alternatively, the normals could be calculated by running computeFaceNormals()
or computeVertexNormals()
.)
Upvotes: 1