纹理和RingGeometry / CylinderGeometry

时间:2013-09-17 10:30:47

标签: three.js textures

更新: 我制作了jsfiddle例子 - jsfiddle.net/NEXny/1/

[ignore this - just including a code block so stackoverflow will

让我发布上面的JSFiddle链接。是的,认真的。]

我在将纹理应用于RingGeometry和CylinderGeometry时遇到了麻烦,希望这张图片可以解释我的问题。

texture

可以通过这种方式之一应用纹理吗? 目前我的结果非常出乎意料......

1 个答案:

答案 0 :(得分:3)

您必须根据自己的喜好修改几何顶点UV。

相反,为什么不使用CircleGeometry作为气缸端盖。也就是说,自己构建端帽?

// cylinder
geometry = new THREE.CylinderGeometry( 192, 192, 40, 64, 1, true ); // open-ended
geometry1 = new THREE.CircleGeometry(192, 64);

// end-cap material
material1 = new THREE.MeshBasicMaterial({ 
    map: textures.circle,
    overdraw: 0.5 // for canvas renderer only
});

// cylinder material
material = new THREE.MeshBasicMaterial({ 
    map: textures.line,
    overdraw: 0.5 // for canvas renderer only
});

object = new THREE.Object3D();
scene.add(object);

// end-caps
var mesh1 = new THREE.Mesh(geometry1, material1);
mesh1.rotation.x = - Math.PI / 2;
mesh1.position.y = 20
object.add(mesh1);

var mesh2 = new THREE.Mesh(geometry1, material1);
mesh2.rotation.x = Math.PI / 2;
mesh2.position.y = -20
object.add(mesh2);

// cylinder
var mesh = new THREE.Mesh(geometry, material);
object.add(mesh);

小提琴:http://jsfiddle.net/NEXny/2/

three.js r.61