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