1

我正在尝试使用three.js在四边形上映射纹理,但纹理坐标似乎有问题,因为我看到的只是图像的左上角像素(UV = {0, 0} 我猜)...

这是我定义几何的方式:

var geom = new THREE.Geometry();
geom.vertices.push(new THREE.Vertex(new THREE.Vector3(-100,  50, 0)));
geom.vertices.push(new THREE.Vertex(new THREE.Vector3(-100,  -50, 0)));
geom.vertices.push(new THREE.Vertex(new THREE.Vector3(0,  -50, 0)));
geom.vertices.push(new THREE.Vertex(new THREE.Vector3(0,  50, 0)));
geom.faces.push(new THREE.Face3(0, 1, 2));
geom.faces.push(new THREE.Face3(0, 2, 3));
geom.faceVertexUvs[0].push([new THREE.Vector2(0, 0),
                            new THREE.Vector2(10, 0),
                            new THREE.Vector2(10, 10)]);
geom.faceVertexUvs[0].push([new THREE.Vector2(0, 0),
                            new THREE.Vector2(10, 10),
                            new THREE.Vector2(0, 10)]);
//I also tried:
//geom.faceVertexUvs[0].push([new THREE.Vector2(0, 0),
//                            new THREE.Vector2(10, 0),
//                            new THREE.Vector2(10, 10),
//                            new THREE.Vector2(0, 0),
//                            new THREE.Vector2(10, 10),
//                            new THREE.Vector2(0, 10)]);
geom.computeCentroids();
geom.computeFaceNormals();

有人能发现我做错了什么吗?

谢谢

4

1 回答 1

1

发布问题 2 分钟后找到解决方案...我需要使用新的 THREE.UV 而不是 THREE.Vector2。我真的希望这个项目的文档能变得更厚一些……现在每件小事都需要数小时的反复试验(至少对我来说)!

于 2013-04-30T11:42:43.367 回答