I have a probably stupid problem. Im trying to iterate through the vertices of a plane.
Why wont this work. I get a “Uncaught TypeError: Cannot set property ‘x’ of undefined” error.
plane = new THREE.Mesh(new THREE.PlaneGeometry(100,100, 10, 10), planeMat);
//Set up heightmap for plane
var vertices = plane.geometry.vertices;
var l = vertices.length;
for ( var i = 0;i < l;i++){
vertices[i].position.x = Math.random()*50;
}
scene.add(plane);
Entire code that renders http://jsfiddle.net/sJESN/ uncomment commented line in above loop to get error.
Thanks for any help, I’ve been going crazy for 3 days with this!
Sorry for any noob mistakes.
The vertices array which is a part of all the geometry objects does not have a position member. The position variable is a member of Object3D and it is a THREE.Vector3. The array of vertices is actually itself an array of THREE.Vector3 so you simply need to change this line
to…