ThreeJS Vue TweenJs 3D冒泡抽奖签到

 for (var i = 0; i < this.table.length; i++) {
      // 创建圆形头像
      var circleHead = new THREE.CircleGeometry(40, 62);
      var mesh = new THREE.Mesh(circleHead);

      mesh.position.x = Math.random() * 4000 - 2000;
      mesh.position.y = Math.random() * 4000 - 5500;
      mesh.position.z = Math.random() * 4000 - 2000;
      mesh.visible = false; 
      mesh.name = 'Avatar';
      that.objects.push(mesh);
      let url = this.getRandomAvatar();
      const texture = new THREE.TextureLoader().load(url);
      var material = new THREE.MeshBasicMaterial({
        map: texture,
        transparent:true,
        opacity:1
      });
      material.side = THREE.DoubleSide; //单面贴就删除
      that.objects[i].material = material;
      that.objects[i].visible = true; 
  
      var _object2 = new THREE.Object3D();
      _object2.position.z = -30000;
      this.targets.table.push(_object2);
    }



  function play() {
        for (var i = 0; i < that.objects.length; i++) {
          let item = that.objects[i]; 
          item.originalPosition = JSON.parse(JSON.stringify(item.position))
          start(item);
        }
        function start(item) {  
          that
            .createTween(item.position,item)
            .to(
              { 
                x: item.position.x + 100,
                y: -200,
              },
              Math.abs(item.position.y) * 5,
            )
            .onComplete((obj) => { 
                let time =  600 * 5
                that
                .createTween(item.position,item)
                .to(
                {  
                    y: 400,
                },
                 time,
                ) 
                .onComplete((obj) => { 
                    that.removeTween(item) 
                    setTimeout(() => {
                        item.position.x = item.originalPosition.x
                        item.position.y = item.originalPosition.y
                        item.position.z = item.originalPosition.z
                        item.material.opacity = 1
                        item.children[0].materia = 1 
                        start(item)
                    }, 500);
                })
                .start(); 
                that
                .createTween(item.material,item)
                .to(
                {  
                    opacity: 0,
                },
                 time,
                ) 
                .start(); 
                that
                .createTween(item.children[0].material,item)
                .to(
                {  
                    opacity: 0,
                },
                 time,
                ) 
                .start();
            })
            .start();
        }
      }

      function stop() {
        that.lotteryPlayState = 'stop';
      }
      play()
      return {
        play: play,
        stop: stop,
        playing: false,
      };

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

斥方遒(Oliver)

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

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

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

打赏作者

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

抵扣说明:

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

余额充值