使用THREE.Geometry时无法应用纹理

时间:2015-05-16 18:15:58

标签: javascript three.js

我正在创建一个包含3个顶点和1个面的简单2D三角形。

如果在材质中使用颜色,它可以正常工作,但当我使用纹理时,我得[.WebGLRenderingContext-0633E7D8]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 2 相同的材质适用于使用BoxGeometry创建的对象。

        var wallTexture = THREE.ImageUtils.loadTexture("http://i.imgur.com/RiC9b5J.jpg");

        var wallMaterial = new THREE.MeshLambertMaterial({map: wallTexture});

        var geometry = new THREE.Geometry();

        geometry.vertices.push(new THREE.Vector3(-100, 0, 0));
        geometry.vertices.push(new THREE.Vector3(100, 0, 0));
        geometry.vertices.push(new THREE.Vector3(0, -150, 0));

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

        var mesh = new THREE.Mesh(geometry, wallMaterial);

http://jsfiddle.net/6pt9wnk4/8/

0 个答案:

没有答案