graflow 1.0
This commit is contained in:
@@ -168,27 +168,31 @@ class HelperBot{
|
||||
const delay = Math.max(Math.abs(dx), Math.abs(dy), Math.abs(dz)) * moveDelay
|
||||
const ax = (dy>0.5) ? -10 : ((dy<-0.5) ? 10 : 0 )
|
||||
const ay = (dx>0.5) ? 10 : ((dx<-0.5) ? -10 : 0 )
|
||||
|
||||
console.log( this.mecha.position.x, this.mecha.position.y)
|
||||
console.log(dx,dy,ax,ay)
|
||||
//TODO : fix jerks when rotation tweens overlap
|
||||
// console.log( this.mecha.position.x, this.mecha.position.y)
|
||||
// console.log(dx,dy,ax,ay)
|
||||
|
||||
const rotationDelay = Math.min(delay/4, 500)
|
||||
this.rotateBot({x: ax, y: ay, z: 0}, rotationDelay)
|
||||
const rotationDelay = delay/4;
|
||||
if(rotationDelay>400) this.rotateBot({x: ax, y: ay, z: 0}, rotationDelay)
|
||||
|
||||
let chkpt1 = true, chkpt2 = true, chkpt3 = true
|
||||
this.animate = false; console.log('stopped!')
|
||||
const startTime = Date.now()
|
||||
this.translateBot(position, delay, null, () => {
|
||||
this.translateBot(position, delay, () => {
|
||||
this.animate = true ; console.log('started!')
|
||||
},
|
||||
() => {
|
||||
const t = (Date.now()-startTime)/delay
|
||||
if(chkpt1 && (t >= 0.2)){ //Time to stop accelerating
|
||||
this.rotateBot({x: 0, y: 0, z: 0}, rotationDelay)
|
||||
if(rotationDelay>400) this.rotateBot({x: 0, y: 0, z: 0}, rotationDelay)
|
||||
chkpt1 = false
|
||||
}
|
||||
if(chkpt2 && (t >= 0.7)){ //Time to brake
|
||||
this.rotateBot({x: -ax, y: -ay, z: 0}, rotationDelay)
|
||||
if(rotationDelay>400) this.rotateBot({x: -ax, y: -ay, z: 0}, rotationDelay)
|
||||
chkpt2 = false
|
||||
}
|
||||
if(chkpt3 && (t >= 0.9)){ //Time to restore
|
||||
this.rotateBot({x: 0, y: 0, z: 0}, rotationDelay)
|
||||
if(rotationDelay>400) this.rotateBot({x: 0, y: 0, z: 0}, rotationDelay)
|
||||
chkpt3 = false
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user