123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- this.initialize = function () {
- //this.createTransportVis();
- }
- this.simpleVis = function () {
- return {
- "extends": "proxy/two/rectangle.vwf",
- "properties": {
- "height": 25,
- "width": 25,
- "fill": "#ddd"
- }
- }
- }
- this.stop = function () {
- this.animationStop();
- this.playing = false;
- }
- this.play = function () {
- this.beat = 0;
- this.animationPlay(0, this.animationDuration);
- this.playing = true;
- }
- this.setupTransport = function () {
- this.beat = 0;
- this.animationLoop = true;
- this.animationDuration = 1;
- this.animationRate = 1;
- this.animationTPS = 30;
- //this.animationPlay(0,1);
- }
- this.animationUpdate = function (time, duration) {
- //let sceneID = this.find("/")[0].id
- let rate = this.animationTPS / this.animationRate; // 60/1 by default
- var b = this.beat;
- //console.log('b: ' + this.beat + ' t: ' + time + ' ta: ' + this.time);
-
- if (time == this.animationDuration) { //time == 1 &&
- this.beat = 0;
- //this.doGlobalBeat(time, duration, b);
- } else {
-
- if(this.beat !== rate) {
- this.doGlobalBeat(time, duration, b)
- }
- this.beat = this.beat + 1;
- }
-
- }
- this.resetVisual = function(){
- this.vis.fill = "#ddd";
- }
- this.changeVisual = function(){
- this.vis.fill = "green";
- //this.future(0.5).resetVisual();
- }
- this.doGlobalBeat = function (time, duration, beat) {
- this.changeVisual();
- let allChilds = this.find("//element(*,'proxy/two/node.vwf')"); //this.children
- allChilds.forEach(el => {
- if (el.globalBeat) {
- let obj = {
- name: this.name,
- time: time,
- duration: duration,
- beat: beat
- }
- el.onGlobalBeat(obj);
- }
- })
- }
- this.init = function () {
- this.children.create("vis", this.simpleVis(), function (child) {
- child.mousedownEvent = function () {
- if (this.parent.animationPlaying) {
- this.parent.stop();
- this.parent.resetVisual();
- } else {
- this.parent.play();
- this.parent.changeVisual();
- }
- }
- });
- this.setupTransport();
- //this.play();
- }
|