4
votes

How do I find vertices positions of a mesh after I used .fromGeometry(); code? I created a buffergeometry from a geomtery that I used for a mesh. Here is an example.

var geom = new THREE.BoxGeometry(1,1,1);
var buffgeom = new THREE.BufferGeometry();
buffgeom.fromGeometry(geom);
var mat = new THREE.MeshBasicMaterial({ color: 0x0000ff });
var cube = new THREE.Mesh(buffgeom, mat);

geometryvertices.vertices = buffgeom.vertices;

The geometryvertices.vertices = buffgeom.vertices; code doesn't work for buffgeom. How do I find vertices positions of buffgeom? Can somebody please help?

After that I want to push the vertices of a geometry into THREE.Vector3. This is how it worked with a geometry.

geom.vertices.push(Vector3);

And it doesn't work with a buffergeometry.

1

1 Answers

0
votes
var tempGeo = new THREE.Geometry().fromBufferGeometry(myMesh.geometry);
for (var i= 0; i< tempGeo.vertices.length; i++) {
  var pos = tempGeo.vertices[i].applyMatrix4(myMesh.matrix);
}