cancelling tweens
This commit is contained in:
+7
-3
@@ -11,6 +11,7 @@ export class Threetobus{
|
||||
|
||||
this.cameras = {}
|
||||
this.renderers = []
|
||||
this.tweensRegistry = {}
|
||||
}
|
||||
|
||||
get EventsMapping() { return this._stagedEventsMapping }
|
||||
@@ -185,7 +186,7 @@ export class Threetobus{
|
||||
}
|
||||
|
||||
|
||||
buildFromJSON(id, desc){
|
||||
agentFromJSON(id, desc){
|
||||
let obj
|
||||
if(desc.type === 'Mesh') {
|
||||
const geom = new THREE[desc.geometry.type](...(desc.geometry.args || []))
|
||||
@@ -206,10 +207,11 @@ export class Threetobus{
|
||||
if(desc.children) {
|
||||
desc.children.forEach(childDesc => {
|
||||
const childId = (childDesc.idSuffix) ? `${id}_${childDesc.idSuffix}` : ''
|
||||
obj.add(this.buildFromJSON(childId, childDesc))
|
||||
obj.add(this.agentFromJSON(childId, childDesc))
|
||||
})
|
||||
}
|
||||
obj.name = id
|
||||
this.tweensRegistry[id] = { 'move': null }
|
||||
return obj
|
||||
}
|
||||
|
||||
@@ -237,12 +239,14 @@ export class Threetobus{
|
||||
newZ = isNaN(newZ) ? options.object.position.z : newZ
|
||||
newZ += (parseFloat(options.dz) || 0)
|
||||
|
||||
new TWEEN.Tween(options.object.position)
|
||||
if(this.tweensRegistry[options.object.name]['move']) this.tweensRegistry[options.object.name]['move'].end()
|
||||
this.tweensRegistry[options.object.name]['move'] = new TWEEN.Tween(options.object.position)
|
||||
.to({ x: newX,
|
||||
y: newY,
|
||||
z: newZ,
|
||||
}, options.delay)
|
||||
.easing(TWEEN.Easing[options.easing][options.easingMode])
|
||||
.onComplete(() => this.tweensRegistry[options.object.name]['move']=null)
|
||||
.start()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user