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);
问题是我需要像使用 a 一样对待这个网格,CubeGeometry
并使用位图(最终是视频)纹理对其进行纹理处理。当前的结果是立方体的正面被分成四个相等的部分,每个部分都是来自位图中的像素数据的单一颜色。在这种情况下,我只关心立方体的正面。