Added "animate" binding, fixes #70

This commit is contained in:
Devine Lu Linvega
2019-07-22 14:50:05 +09:00
parent 00dc10894e
commit 7e99df545e
10 changed files with 46 additions and 54 deletions

View File

@@ -24,8 +24,6 @@ function Ronin () {
this.interpreter = new Lisp(this.library, this.includes)
this.osc = new Osc(this)
// Parameters
this.always = false
this.bindings = {}
this.install = function (host = document.body) {
@@ -48,6 +46,14 @@ function Ronin () {
this.commander.start()
this.surface.start()
this.osc.start()
this.loop()
}
this.loop = () => {
if (this.bindings['animate'] && typeof this.bindings['animate'] === 'function') {
this.bindings['animate']()
}
requestAnimationFrame(() => this.loop())
}
this.reset = function () {
@@ -62,12 +68,6 @@ function Ronin () {
}
this.animate = (b = true) => {
if (this.always === b) { return }
this.always = b
this.commander.loop()
}
this.bind = (event, fn) => {
this.bindings[event] = fn
}