123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- this.initialize = function () {
- //this.createTransportVis();
- }
- this.simpleVis = function () {
- return {
- "extends": "http://vwf.example.com/aframe/abox.vwf",
- "properties": {
- "height": 0.3,
- "width": 0.3,
- "depth": 0.3,
- "class": "clickable"
- },
- "children": {
- "material": {
- "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
- "type": "component",
- "properties": {
- "color": "red"
- }
- },
- "cursor-listener": {
- extends: "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
- type: "component"
- }
- }
- }
- }
- 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 {
-
- this.doGlobalBeat(time, duration, b);
- this.beat = this.beat + 1;
- }
-
- }
- this.doGlobalBeat = function (time, duration, beat) {
- let allChilds = this.find("//element(*,'http://vwf.example.com/aframe/aentity.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.clickEventMethod = function () {
- if (this.parent.animationPlaying) {
- this.parent.stop();
- } else {
- this.parent.play();
- }
- }
- });
- this.setupTransport();
- //this.play();
- }
|