飞机上的顶点没有位置?

Tob*_*bis 3 three.js

我有一个可能很愚蠢的问题.我试图迭代一个平面的顶点.为什么不这样做呢?我得到一个"未捕获的TypeError:无法设置属性'x'未定义"错误.

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);
Run Code Online (Sandbox Code Playgroud)

在上面的循环中呈现http://jsfiddle.net/sJESN/取消注释注释行的整个代码以获取错误.

感谢您的帮助,我已经疯狂了3天!对不起任何noob错误.

Cor*_*oss 8

作为所有几何对象的一部分的顶点数组没有位置成员.position变量是Object3D的成员,它是THREE.Vector3.顶点数组实际上是本身 THREE.Vector3的数组,所以你只需要改变这一行

vertices[i].position.x = Math.random() * 50;
Run Code Online (Sandbox Code Playgroud)

至...

vertices[i].x = Math.random() * 50;
Run Code Online (Sandbox Code Playgroud)