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,
};