我用画布创建了纹理,但我有一点小问题。我不能像在图像中那样旋转我的纹理。我该怎么做呢?
setTexture = (name, font = 20) => {
const canvas = window.document.createElement("canvas");
canvas.width = 256;
canvas.height = 128;
const ctx = canvas.getContext("2d");
ctx.fillStyle = "white";
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.font = `${font}pt Arial`;
ctx.fillStyle = "black";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText(
name || "unnamed",
canvas.width / 2,
canvas.height / 2
);
const texture = new THREE.Texture(canvas);
texture.wrapS = THREE.RepeatWrapping;
texture.repeat.x = -1;
texture.needsUpdate = true;
return texture;
};

发布于 2019-11-28 03:23:48
如果要旋转纹理,可以更新几何体中的UV,也可以使用texture.rotation修改器。
const texture = new THREE.Texture(canvas);
texture.rotation = Math.PI; // 180 deg in radians如果旋转未围绕所需的点旋转,则可以将texture.center设置为[0.0, 1.0]范围内的另一个值。
const texture = new THREE.Texture(canvas);
texture.center = new THREE.Vector2(0.5, 0.7);
texture.rotation = Math.PI;https://stackoverflow.com/questions/59072119
复制相似问题