2

I'm successfully drawing a cube with rounded corners by using the THREE.Shape object:

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);

The issue is that I need to treat this mesh as you would with a CubeGeometry and texture it with a bitmap (and eventually video) texture. The current result is the front face of the cube is split into four equal segments, each a single color from what does appear to be pixel data from the bitmap. In this instance, I am only concerned with the front face of the cube.

1 Answer 1

1

Seems like (by now) you'll need to write the UV coordinates yourself.

You need to compute the bounding box of your geometry. With that data you should be able to generate 0 to 1 UVs for each side.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, forgot to update this. This is what I ended up doing.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.