【发布时间】:2019-01-23 00:47:23
【问题描述】:
我想让我的圆柱体(代码中的π介子)逐个移动到我创建的板上的对象上。 我有这个代码:
a : 开始
index : 对象
attachEvent(_this, index,a) {
if(index>=a){
_this.domEvents.addEventListener(_this.cases[index], 'click',
function(event) {
for ( var i = a; i <= index; i++) {
_this.stepByStep(_this,i)
}
}, false)
}else{
_this.domEvents.addEventListener(_this.cases[index], 'click',
function(event) {
//nothing now
}, false)
}
}
stepByStep(_this,i)
{
_this.tween = new TWEEN.Tween(this.pions.position)
.to({
x: _this.cases[i].position.x,
y: _this.cases[i].position.y,
z: 5},1000)
.start();
}
当我运行我的代码时,我不知道为什么,但是 pions 直接进入了对象。
【问题讨论】:
-
您提供的代码没有任何解释。你能创建一个实时代码示例吗? (这里是代码 sn-ps,jsfiddle,codepen)
标签: javascript three.js tween