二、飞线或者路线的实现(TubeBufferGeometry:管道缓冲几何体)

        在做three大屏的时候我们经常会遇到绘制发光路线和指向的情况,那么就需要使用到管道(TubeBufferGeometry)这个API。先看看他能达到的几种效果。

一、效果图

        1平面效果

2飞线效果

二、那么我们直接看代码,一共有6步。

  1. 定义数据

  let linePoints = [

      new THREE.Vector3(0, 0, 0),

      new THREE.Vector3(5, 4, 0),

      new THREE.Vector3(10, 0, 0),

    ];

      2.创建曲线

this.lineCurve = new THREE.CatmullRomCurve3(linePoints);

        3.根据曲线生产管道集合体

this.geometry = new THREE.TubeBufferGeometry(

    this.lineCurve,

      100,

      1,

      2,

      false

    );

4设置飞线材质,创建纹理,贴图

const textloader = new THREE.TextureLoader();
    this.texture = textloader.load("./textures/z_11.png");
    this.texture.repeat.set(1, 2);
    this.texture.wrapS = THREE.RepeatWrapping;
    this.texture.wrapT = THREE.MirroredRepeatWrapping;

    this.material = new THREE.MeshBasicMaterial({
      // color: 0xfff000,
      map: this.texture,
      transparent: true,
    });

5.创建飞线物体

this.mesh = new THREE.Mesh(this.geometry, this.material);

6.创建飞线动画

6.创建飞线动画
gsap.to(this.texture.offset, {
      x: -1,
      duration: time,
      repeat: -1,
      ease: "none",
    });

以上就是创建一个飞线或者路线的实现步骤,当然一定要记得把生成的MESh物体加入到scene(场景)中,当然你也可以根据threejs的官网属性来了解每个参数是什么意思。

官网地址:http://cw.hubwiz.com/card/c/three.js-api/1/13/40/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

arguments_zd

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值