2d.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. this.initialize = function () {
  2. if (Object.getPrototypeOf(this).id.includes('scene.vwf')) {
  3. console.log("Initialize of Scene...", this.id);
  4. this.globalTransport.init();
  5. this.back.back2.mask = "filter2";
  6. this.back.back1.mask = "filter1";
  7. //this.back.back1.rectangle.fill = "https://localhost:3007/defaults/assets/test/test.mp4";
  8. //this.back.back1.rectangle.playVideo();
  9. this.back.back1.rectangle.setVideoState(false, null, 0);
  10. this.synth.sync();
  11. this.future(1).setStartTime();
  12. this.tuning.syncStart();
  13. //this.synth.scheduleRepeat();
  14. this.synth.triggerAttackRelease(["A3"], "32n", "4n", 0.8);
  15. this.synth.triggerAttackRelease(["E3"], "32n", "8n", 0.8);
  16. this.toneTransport.setTransportState(false, null, 0);
  17. this.toneGUI.toneText.step();
  18. } else {
  19. console.log("Initialize proto Scene..", this.id);
  20. }
  21. }
  22. this.resize = function () {
  23. }
  24. this.setStartTime = function () {
  25. this.tuning.startTime = this.toneTransport.position;
  26. }
  27. this.toneGUI.toneText.do = function () {
  28. let scene = this.getScene();
  29. if (scene && scene.toneTransport) {
  30. this.text = scene.toneTransport.position;
  31. }
  32. }
  33. this.toneGUI.tonePlay.mousedownEvent = function () {
  34. let scene = this.getScene();
  35. if (scene.toneTransport) {
  36. //scene.tuning.startTime = scene.toneTransport.position;
  37. //scene.future(1).setStartTime();
  38. //scene.tuning.startTime = scene.toneTransport.position;
  39. scene.toneTransport.syncTransportState();
  40. scene.toneTransport.toggleTransport();
  41. }
  42. // let scene = this.getScene();
  43. // if(!scene.toneTransport.state || scene.toneTransport.state == "stopped"){
  44. // scene.toneTransport.start();
  45. // scene.toneTransport.state = "started";
  46. // console.log("START Transport")
  47. // } else if(scene.toneTransport.state == "started"){
  48. // scene.toneTransport.stop();
  49. // scene.toneTransport.state = "stopped";
  50. // console.log("STOP Transport")
  51. // } else if(scene.toneTransport.state == "paused"){
  52. // scene.toneTransport.state = "paused";
  53. // }
  54. }
  55. this.audio.mousedownEvent = function () {
  56. this.parent.back.back1.rectangle.unmute();
  57. }
  58. this.play.mousedownEvent = function () {
  59. //this.parent.back.back1.rectangle.setVideoState(true, 0, 0);
  60. //this.parent.back.back1.rectangle.setVideoState(this.isPlaying, this.startOffset, this.pausedTime);
  61. this.parent.back.back1.rectangle.syncVideoState();
  62. this.parent.back.back1.rectangle.playVideo();
  63. }
  64. this.ellipse.clickEvent = function () {
  65. this.fill = this.getRandomColor();
  66. console.log('CLICK ', this.id);
  67. }
  68. this.ellipse.mousedownEvent = function () {
  69. this.fill = this.getRandomColor();
  70. console.log('Mouse Down ', this.id);
  71. }
  72. this.ellipse.mouseupEvent = function () {
  73. this.fill = this.getRandomColor();
  74. console.log('Mouse Up ', this.id);
  75. }
  76. this.ellipse.overstartEvent = function (avatarID) {
  77. this.fill = "#e3dd24"
  78. }
  79. this.ellipse.overendEvent = function (avatarID) {
  80. this.fill = "white"
  81. }
  82. this.filter2.el2.overstartEvent = function (avatarID) {
  83. let nodeName = this.parent.maskedNode;
  84. if (nodeName) {
  85. let node = this.getScene().findNode(nodeName);
  86. this.viewTroughFilter(node.id, true);
  87. //node.visible = true;
  88. }
  89. }
  90. this.filter2.el2.overendEvent = function (avatarID) {
  91. let nodeName = this.parent.maskedNode;
  92. if (nodeName) {
  93. let node = this.getScene().findNode(nodeName);
  94. this.viewTroughFilter(node.id, false);
  95. //node.visible = false;
  96. }
  97. }
  98. this.filter1.el1.overstartEvent = function (avatarID) {
  99. let nodeName = this.parent.maskedNode;
  100. if (nodeName) {
  101. let node = this.getScene().findNode(nodeName);
  102. //this.viewTroughFilter(node.id, true);
  103. //node.visible = true;
  104. }
  105. }
  106. this.filter1.el1.overendEvent = function (avatarID) {
  107. let nodeName = this.parent.maskedNode;
  108. if (nodeName) {
  109. let node = this.getScene().findNode(nodeName);
  110. //this.viewTroughFilter(node.id, false);
  111. //node.visible = false;
  112. }
  113. }
  114. this.filter1.el2.overstartEvent = function (avatarID) {
  115. let nodeName = this.parent.maskedNode;
  116. if (nodeName) {
  117. let node = this.getScene().findNode(nodeName);
  118. //this.viewTroughFilter(node.id, true);
  119. //node.visible = true;
  120. }
  121. }
  122. this.filter1.el2.overendEvent = function (avatarID) {
  123. let nodeName = this.parent.maskedNode;
  124. if (nodeName) {
  125. let node = this.getScene().findNode(nodeName);
  126. //this.viewTroughFilter(node.id, false);
  127. //node.visible = false;
  128. }
  129. }