THREE.Shape上的ThreeJS位图纹理挤出

时间:2012-05-29 08:15:49

标签: javascript webgl three.js

我使用THREE.Shape对象成功绘制了一个带圆角的立方体:

var shape = new THREE.Shape();
x = width/2;
y = height/2;
shape.moveTo(x - radius, y);

//*** Top right
x = -width/2;
y = height/2;
shape.lineTo(x + radius, y);
if (tr) shape.quadraticCurveTo(x, y, x, y - radius);
else shape.lineTo(x, y);

//*** Bottom right
x = -width/2;
y = -height/2;
shape.lineTo(x, y + radius);
if (br) shape.quadraticCurveTo(x, y, x + radius, y);
else shape.lineTo(x, y);

//*** Bottom left
x = width/2;
y = -height/2;
shape.lineTo(x - radius, y);
if (bl) shape.quadraticCurveTo(x, y, x, y + radius);
else shape.lineTo(x, y);

//*** Top left
x = width/2;
y = height/2;
shape.lineTo(x, y - radius);
if (tl) shape.quadraticCurveTo(x, y, x - radius, y);
else shape.lineTo(x, y);

var extrude = this.shape.extrude({amount: extr || 0, bevelEnabled: false});
this.mesh = new THREE.Mesh(extrude, mat);

问题在于我需要像处理CubeGeometry那样处理这个网格,并用位图(最终是视频)纹理对其进行纹理处理。当前结果是立方体的正面被分成四个相等的段,每个段都是来自位图的像素数据。在这种情况下,我只关心立方体的正面。

1 个答案:

答案 0 :(得分:1)

似乎(现在)你需要自己编写UV坐标。

您需要计算几何体的边界框。使用该数据,您应该能够为每一侧生成0到1个UV。