[three] | 光源扫描 波动墙效果

前言

最近在学习threejs   顺便整理学习心得出一些三维特效

效果

光源扫描

波动墙 

实现

 1. 创建一个点光源,动态修改顶点坐标


    // 创建一个点光源
    this._pointlight = new THREE.PointLight('red')
    this._pointlight.intensity = 20;
    this._pointlight.decay = 1;
    this._pointlight.distance = 2;
    this._pointlight.position.copy(position)
    this._scene.add(this._pointlight)

    

在animation 每一帧渲染修改顶点坐标

let py = 0 
// animation
if (this._pointlight) {
      if (py < 0.1) {
          py += 0.00005

          this._pointlight.position.y = this._pointlight.position.y + py
      } else if (py > 3) {

           this._pointlight.position.y = this._pointlight.position.y;
             py = 0
       }
 }

2. 创建圆柱几何,贴上渐变的纹理材质

 const geometry = new THREE.CylinderGeometry(option.R, option.R, option.H, option.A);
 const cylinder = new THREE.Mesh(geometry, [
    new THREE.MeshBasicMaterial({ map: this._textureLoader.load(option.img), side: THREE.DoubleSide, transparent: true }),
    new THREE.MeshBasicMaterial({ transparent: true, opacity: 0, side: THREE.DoubleSide }),
    new THREE.MeshBasicMaterial({ transparent: true, opacity: 0, side: THREE.DoubleSide })
        ])
cylinder.position.copy(position)

this._scene.add(cylinder)

在animation 每一帧渲染修改圆柱的scale属性设置大小

 let s = 0,p = 0

// animation
if(s > 5){s = 0, p = 1};
if (this._scanList) this._scanList.forEach(e => { e.scale.set(1 + s, 1, 1 + s); e.material[0].opacity = p })

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值