concert.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. this.initialize = function () {
  2. if (Object.getPrototypeOf(this).id.includes('scene.vwf')) {
  3. console.log("Initialize of Scene...", this.id);
  4. this.watchPerformance();
  5. //this.globalTransport.init();
  6. this.back.back1.mask = "filter1";
  7. this.back.back2.mask = "filter2";
  8. this.back.back3.mask = "filter3";
  9. //this.back.back1.rectangle.fill = "https://localhost:3007/defaults/assets/test/test.mp4";
  10. //this.back.back1.rectangle.playVideo();
  11. this.back.back1.rectangle.setVideoState(true, null, 0);
  12. this.back.back1.rectangle.syncVideoState();
  13. this.back.back3.rectangle.setVideoState(false, null, 0);
  14. // this.tuning.syncStart();
  15. this.toneTransport.setTransportState(false, null, 0);
  16. this.filter1.el2.step();
  17. //this.toneGUI.toneText.step();
  18. } else {
  19. console.log("Initialize proto Scene..", this.id);
  20. }
  21. }
  22. this.setStartTime = function () {
  23. this.tuning.startTime = this.toneTransport.position;
  24. }
  25. this.watchPerformance = function () {
  26. let fixedTime = Number.parseFloat(this.time).toFixed();
  27. //this.timeText.text = fixedTime.toString();
  28. let secondsN = fixedTime//Math.floor(this.time/2);
  29. let minutesN = Math.floor(secondsN / 60);
  30. let hoursN = Math.floor(minutesN / 60);
  31. let seconds = Number.parseFloat(secondsN % 60).toFixed();
  32. let minutes = minutesN % 60;
  33. let hours = hoursN % 12;
  34. this.timeText.text = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
  35. if (fixedTime == 45) {
  36. if (this.part2 !== "started") {
  37. this.part1 = "finished";
  38. this.back.back1.rectangle.fill = "black";
  39. if (this.toneTransport) {
  40. this.toneTransport.syncTransportState();
  41. this.toneTransport.toggleTransport();
  42. this.future(2).setStartTime();
  43. //this.tuning.future(2).syncStart(this.tuning.startTime);
  44. this.tuning.volume = -15;
  45. }
  46. this.part2 = "started";
  47. let tuningText = {
  48. "extends": "proxy/two/text.vwf",
  49. "properties": {
  50. "size": 150,
  51. "fill": "white",
  52. "text": "",
  53. "stroke": "normal",
  54. "linewidth": 4,
  55. "translation": [500, 300]
  56. }
  57. }
  58. this.children.create("tuningText", tuningText, function (child) { });
  59. }
  60. //84 - tuning
  61. }
  62. if (fixedTime == 99) {
  63. this.back.back2.logo_text.text = "";
  64. this.tuningText.text = 'what is this?'
  65. }
  66. if (fixedTime == 105) {
  67. this.tuningText.text = ''
  68. }
  69. if (fixedTime == 110) {
  70. this.tuningText.text = 'I don\'t know'
  71. }
  72. if (fixedTime == 115) {
  73. this.tuningText.text = ''
  74. }
  75. if (fixedTime == 126) {
  76. this.tuningText.text = ' toi toi toi'
  77. }
  78. if (fixedTime == 129) { //129
  79. if (this.part3 !== "started") {
  80. this.part2 = "finished";
  81. this.tuningText.text = ''
  82. if (this.toneTransport) {
  83. this.toneTransport.syncTransportState();
  84. this.toneTransport.toggleTransport();
  85. }
  86. this.back.back1.rectangle.fill = "black";
  87. this.back.back1.rectangle.playVideo();
  88. this.back.back1.visible = false;
  89. this.filter1.visible = false;
  90. this.filter2.visible = false;
  91. this.filter1.el1.drag = false;
  92. this.filter1.el2.drag = false;
  93. this.filter2.el2.drag = false;
  94. this.filter2.visible = false;
  95. //this.back.back3.rectangle.setVideoState(true, null, 0);
  96. //this.back.back3.rectangle.unmute();
  97. this.startPart3();
  98. this.part3 = "started"
  99. }
  100. }
  101. if (fixedTime == 202) { //205
  102. if (this.part4 !== "started") {
  103. this.part3 = "finished";
  104. this.back.back3.rectangle.playVideo();
  105. //this.back.back3.rectangle.fill = "black";
  106. this.back.back3.visible = false;
  107. this.body.visible = false;
  108. this.tuningText.text = "";
  109. this.tuningText.opacity = 0.3;
  110. this.tuningText.fill = "grey";
  111. this.startPart4();
  112. this.part4 = "started"
  113. }
  114. }
  115. this.future(1).watchPerformance();
  116. }
  117. this.resize = function () {
  118. }
  119. this.startPart4 = function () {
  120. let self = this;
  121. let applause2 = {
  122. "extends": "proxy/two/ellipse.vwf",
  123. "properties": {
  124. "width": 200,
  125. "height": 200,
  126. "fill": "/defaults/assets/concert/hands.png",
  127. x: 220,
  128. y: 630,
  129. "drag": true,
  130. linewidth: 0,
  131. stroke: "transparent",
  132. opacity: 0.7,
  133. scale: 0.4
  134. }
  135. }
  136. let applause3 = {
  137. "extends": "proxy/two/ellipse.vwf",
  138. "properties": {
  139. "width": 200,
  140. "height": 200,
  141. "fill": "/defaults/assets/concert/hands.png",
  142. x: 460,
  143. y: 560,
  144. "drag": true,
  145. linewidth: 0,
  146. stroke: "transparent",
  147. opacity: 0.7,
  148. scale: 0.7
  149. }
  150. }
  151. let applause4 = {
  152. "extends": "proxy/two/ellipse.vwf",
  153. "properties": {
  154. "width": 200,
  155. "height": 200,
  156. "fill": "/defaults/assets/concert/hands.png",
  157. x: 740,
  158. y: 600,
  159. "drag": true,
  160. linewidth: 0,
  161. stroke: "transparent",
  162. opacity: 0.7,
  163. scale: 1
  164. }
  165. }
  166. let clapping2 = {
  167. "extends": "proxy/tonejs/player.vwf",
  168. "properties": {
  169. "url": "/defaults/assets/concert/clapping2.mp3",
  170. "volume": -10
  171. }
  172. }
  173. let clapping3 = {
  174. "extends": "proxy/tonejs/player.vwf",
  175. "properties": {
  176. "url": "/defaults/assets/concert/clapping3.mp3",
  177. "volume": -10
  178. }
  179. }
  180. let clapping4 = {
  181. "extends": "proxy/tonejs/player.vwf",
  182. "properties": {
  183. "url": "/defaults/assets/concert/clapping4.mp3",
  184. "volume": -10
  185. }
  186. }
  187. this.children.create("clapping2", clapping2);
  188. this.children.create("clapping3", clapping3);
  189. this.children.create("clapping4", clapping4);
  190. this.children.create("applause2", applause2, function (child) {
  191. child.mousedownEvent = function () {
  192. this.parent.clapping2.start();
  193. }
  194. child.mouseupEvent = function () {
  195. this.parent.clapping2.stop();
  196. }
  197. });
  198. this.children.create("applause3", applause3, function (child) {
  199. child.mousedownEvent = function () {
  200. this.parent.clapping3.start();
  201. }
  202. child.mouseupEvent = function () {
  203. this.parent.clapping3.stop();
  204. }
  205. });
  206. this.children.create("applause4", applause4, function (child) {
  207. child.mousedownEvent = function () {
  208. this.parent.clapping4.start();
  209. }
  210. child.mouseupEvent = function () {
  211. this.parent.clapping4.stop();
  212. }
  213. });
  214. }
  215. this.startPart3 = function () {
  216. //
  217. if (this.body.children.length == 0)
  218. this.createBody();
  219. //this.back.back3.rectangle.setVideoState(true, null, 0);
  220. this.back.back3.rectangle.syncVideoState();
  221. //this.back.back3.rectangle.syncVideoState();
  222. //this.back.back3.rectangle.isPlaying = true;
  223. this.back.back3.opacity = 1;
  224. this.filter3.el1.opacity = 0.35;
  225. this.filter3.el2.opacity = 0.35;
  226. this.filter3.el1.drag = true;
  227. this.filter3.el2.drag = true;
  228. this.back.back3.rectangle.playVideo();
  229. //this.back.back3.rectangle.unmute();
  230. //this.body.playBodyMotion("https://localhost:3007/defaults/assets/concert/motion.json");
  231. }
  232. this.playBodyMotion = function () {
  233. let initPose = this.body.getJointsAtTime(0);
  234. initPose.forEach((e, i) => {
  235. this.body.children["joint" + i].x = e.x * 1000;
  236. this.body.children["joint" + i].y = e.y * 1000;
  237. })
  238. }
  239. this.createBody = function () {
  240. let self = this;
  241. // let body = {
  242. // "extends": "proxy/two/group.vwf",
  243. // "properties": {
  244. // "drag": false,
  245. // "x": 239,
  246. // "y": -57,
  247. // "motionData": "https://localhost:3007/defaults/assets/concert/motion.json"
  248. // },
  249. // "methods":{
  250. // "applyBodyMotion":{
  251. // "parameters":["data"]
  252. // },
  253. // "getJointAtTime":{},
  254. // "getJointsAtTime":{}
  255. // }
  256. // }
  257. let child = this.body;
  258. child.motionData = "/defaults/assets/concert/motion.json";
  259. //this.children.create("body", body, function( child ) {
  260. let hands = [18, 20, 22, 21, 19, 17, 15, 16];
  261. let face = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  262. let topArr = [16, 14, 12, 11, 13, 15, 24, 23];
  263. let botArr = [24, 23];
  264. //let faceArr = [10,8,6,4,1,3,7,9]
  265. Array.from({ length: 25 }, (x, i) => {
  266. let d = 20;
  267. let joint = {
  268. "extends": "proxy/two/ellipse.vwf",
  269. "properties": {
  270. "width": d,
  271. "height": d,
  272. "fill": "yellow"
  273. }
  274. }
  275. if (face.includes(i)) {
  276. joint.properties.width = 5;
  277. joint.properties.height = 5;
  278. joint.properties.fill = "grey";
  279. joint.properties.opacity = 0.2;
  280. }
  281. if (hands.includes(i)) {
  282. joint.properties.width = 10;
  283. joint.properties.height = 10;
  284. joint.properties.fill = "grey";
  285. joint.properties.opacity = 0.5;
  286. }
  287. if (topArr.includes(i)) {
  288. joint.properties.opacity = 0.2;
  289. }
  290. if (botArr.includes(i)) {
  291. joint.properties.opacity = 0;
  292. }
  293. child.children.create("joint" + i, joint);
  294. });
  295. //16-14-12-11-13-15 - topline
  296. //12-24-23-11 - bottomline
  297. //18,16,20 - rh // 16,22
  298. //17,15,19 - lh // 15,21
  299. let rh = {
  300. "extends": "proxy/two/curve.vwf",
  301. "properties": {
  302. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
  303. "fill": "transparent",
  304. "linewidth": 1,
  305. "curved": true
  306. }
  307. }
  308. let rh2 = {
  309. "extends": "proxy/two/curve.vwf",
  310. "properties": {
  311. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }],
  312. "fill": "transparent",
  313. "linewidth": 1,
  314. "curved": true
  315. }
  316. }
  317. let lh = {
  318. "extends": "proxy/two/curve.vwf",
  319. "properties": {
  320. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
  321. "fill": "transparent",
  322. "linewidth": 1,
  323. "curved": true
  324. }
  325. }
  326. let lh2 = {
  327. "extends": "proxy/two/curve.vwf",
  328. "properties": {
  329. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }],
  330. "fill": "transparent",
  331. "linewidth": 1,
  332. "curved": true
  333. }
  334. }
  335. let topline = {
  336. "extends": "proxy/two/curve.vwf",
  337. "properties": {
  338. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
  339. "fill": "transparent",
  340. "linewidth": 3,
  341. "curved": true
  342. }
  343. }
  344. let bottomline = {
  345. "extends": "proxy/two/curve.vwf",
  346. "properties": {
  347. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }], //
  348. "fill": "transparent",
  349. "linewidth": 3,
  350. "curved": true
  351. }
  352. }
  353. let faceline = {
  354. "extends": "proxy/two/curve.vwf",
  355. "properties": {
  356. "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 },
  357. { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }], //
  358. "fill": "transparent",
  359. "linewidth": 1.5,
  360. "curved": true
  361. }
  362. }
  363. child.children.create("topline", topline);
  364. child.children.create("bottomline", bottomline);
  365. child.children.create("rhand", rh);
  366. child.children.create("lhand", lh);
  367. child.children.create("rhand2", rh2);
  368. child.children.create("lhand2", lh2);
  369. child.children.create("faceline", faceline);
  370. child.applyBodyMotion = function (data) {
  371. console.log(data);
  372. }
  373. //child.setScale(-1,1);
  374. self.back.back3.rectangle.bodyTrack = true;
  375. self.back.back3.rectangle.bodyNode = "body";
  376. //self.future(2).playBodyMotion();
  377. //});
  378. }
  379. this.filter2.el2.mousedownEvent = function () {
  380. this.fill = this.getRandomColor();
  381. console.log('CLICK ', this.id);
  382. }
  383. this.filter3.el1.overstartEvent = function (avatarID) {
  384. let scene = this.getScene();
  385. if (scene.part3 == "started") {
  386. let nodeName = this.parent.maskedNode;
  387. if (nodeName) {
  388. let node = scene.findNode(nodeName).rectangle;
  389. this.viewTroughFilter(node.id, false);
  390. //node.visible = true;
  391. }
  392. }
  393. }
  394. this.filter3.el1.overendEvent = function (avatarID) {
  395. let scene = this.getScene();
  396. if (scene.part3 == "started") {
  397. let nodeName = this.parent.maskedNode;
  398. if (nodeName) {
  399. let node = scene.findNode(nodeName).rectangle;
  400. this.viewTroughFilter(node.id, true);
  401. //node.visible = false;
  402. }
  403. }
  404. }
  405. this.filter1.el2.do = function () {
  406. this.rotation = this.rotation + 0.001;
  407. }
  408. this.filter3.el2.overstartEvent = function (avatarID) {
  409. let scene = this.getScene();
  410. if (scene.part3 == "started") {
  411. let nodeName = this.parent.maskedNode;
  412. if (nodeName) {
  413. let node = scene.findNode(nodeName).rectangle;
  414. this.viewTroughFilter(node.id, false);
  415. //node.visible = true;
  416. }
  417. }
  418. }
  419. this.filter3.el2.overendEvent = function (avatarID) {
  420. let scene = this.getScene();
  421. if (scene.part3 == "started") {
  422. let nodeName = this.parent.maskedNode;
  423. if (nodeName) {
  424. let node = scene.findNode(nodeName).rectangle;
  425. this.viewTroughFilter(node.id, true);
  426. //node.visible = false;
  427. }
  428. }
  429. }
  430. this.filter1.el2.overstartEvent = function (avatarID) {
  431. // let nodeName = this.parent.maskedNode;
  432. // if (nodeName) {
  433. // let node = this.getScene().findNode(nodeName);
  434. // //this.viewTroughFilter(node.id, true);
  435. // //node.visible = true;
  436. // }
  437. }
  438. this.filter1.el2.overendEvent = function (avatarID) {
  439. // let nodeName = this.parent.maskedNode;
  440. // if (nodeName) {
  441. // let node = this.getScene().findNode(nodeName);
  442. // //this.viewTroughFilter(node.id, false);
  443. // //node.visible = false;
  444. // }
  445. }