尝试用三个j推动函数内的顶点

时间:2014-06-22 19:18:52

标签: javascript three.js

我正在尝试创建一个模板函数,根据通过函数传递的参数将多个等边三角形推到场景中。这是我正在使用的当前方法:

        function createEquiTri(x, y, sideLength){
            var geometry = new THREE.Geometry();

            geometry.verticies.push( new THREE.Vector3(x,(Math.sqrt(3)/2*sideLength)-(sideLength/2),0));
            geometry.verticies.push( new THREE.Vector3(x-(sideLength/2),y-(sideLength/2),0));
            geometry.verticies.push( new THREE.Vector3(x+(sideLength/2),y-(sideLength/2),0));

            geometry.faces.push( new THREE.Face3( 0, 1, 2 ));

            var redMat = new THREE.MeshBasicMaterial({color: 0xff0000});
            var triangle = new THREE.Mesh(geometry, redMat);
            scene.add(triangle) 
        }

        createEquiTri(0,0,20);

然而,在控制台中,我收到一个错误,我只能将范围说成:"未捕获的TypeError:无法读取属性' push'未定义"。但是我不知道为什么它会因为几何变量在同一个函数中而未定义。

0 个答案:

没有答案