为了账号安全,请及时绑定邮箱和手机立即绑定

ThreeJS 转向纹理

ThreeJS 转向纹理

慕容森 2022-01-13 15:40:14
我用画布创建了纹理,但我没有什么问题。我无法像图像中那样转动我的纹理。我怎样才能做到这一点?   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;  };
查看完整描述

1 回答

?
梦里花落0921

TA贡献1772条经验 获得超6个赞

如果要旋转纹理,可以更新几何体中的 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;


查看完整回答
反对 回复 2022-01-13
  • 1 回答
  • 0 关注
  • 418 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号