123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- this.initialize = function () {
- if (Object.getPrototypeOf(this).id.includes('scene.vwf')) {
- console.log("Initialize of Scene...", this.id);
- this.watchPerformance();
- //this.globalTransport.init();
- this.back.back1.mask = "filter1";
- this.back.back2.mask = "filter2";
- this.back.back3.mask = "filter3";
- //this.back.back1.rectangle.fill = "https://localhost:3007/defaults/assets/test/test.mp4";
- //this.back.back1.rectangle.playVideo();
- this.back.back1.rectangle.setVideoState(true, null, 0);
- this.back.back1.rectangle.syncVideoState();
- this.back.back3.rectangle.setVideoState(false, null, 0);
- // this.tuning.syncStart();
- this.toneTransport.setTransportState(false, null, 0);
- this.filter1.el2.step();
- //this.toneGUI.toneText.step();
- } else {
- console.log("Initialize proto Scene..", this.id);
- }
- }
- this.setStartTime = function () {
- this.tuning.startTime = this.toneTransport.position;
- }
- this.watchPerformance = function () {
- let fixedTime = Number.parseFloat(this.time).toFixed();
- //this.timeText.text = fixedTime.toString();
- let secondsN = fixedTime//Math.floor(this.time/2);
- let minutesN = Math.floor(secondsN / 60);
- let hoursN = Math.floor(minutesN / 60);
- let seconds = Number.parseFloat(secondsN % 60).toFixed();
- let minutes = minutesN % 60;
- let hours = hoursN % 12;
- this.timeText.text = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds);
- if (fixedTime == 45) {
- if (this.part2 !== "started") {
- this.part1 = "finished";
- this.back.back1.rectangle.fill = "black";
- if (this.toneTransport) {
- this.toneTransport.syncTransportState();
- this.toneTransport.toggleTransport();
- this.future(2).setStartTime();
- //this.tuning.future(2).syncStart(this.tuning.startTime);
- this.tuning.volume = -15;
- }
- this.part2 = "started";
- let tuningText = {
- "extends": "proxy/two/text.vwf",
- "properties": {
- "size": 150,
- "fill": "white",
- "text": "",
- "stroke": "normal",
- "linewidth": 4,
- "translation": [500, 300]
- }
- }
- this.children.create("tuningText", tuningText, function (child) { });
- }
- //84 - tuning
- }
- if (fixedTime == 99) {
- this.back.back2.logo_text.text = "";
- this.tuningText.text = 'what is this?'
- }
- if (fixedTime == 105) {
- this.tuningText.text = ''
- }
- if (fixedTime == 110) {
- this.tuningText.text = 'I don\'t know'
- }
- if (fixedTime == 115) {
- this.tuningText.text = ''
- }
- if (fixedTime == 126) {
- this.tuningText.text = ' toi toi toi'
- }
- if (fixedTime == 129) { //129
- if (this.part3 !== "started") {
- this.part2 = "finished";
- this.tuningText.text = ''
- if (this.toneTransport) {
- this.toneTransport.syncTransportState();
- this.toneTransport.toggleTransport();
- }
- this.back.back1.rectangle.fill = "black";
- this.back.back1.rectangle.playVideo();
- this.back.back1.visible = false;
- this.filter1.visible = false;
- this.filter2.visible = false;
- this.filter1.el1.drag = false;
- this.filter1.el2.drag = false;
- this.filter2.el2.drag = false;
- this.filter2.visible = false;
- //this.back.back3.rectangle.setVideoState(true, null, 0);
- //this.back.back3.rectangle.unmute();
- this.startPart3();
- this.part3 = "started"
- }
- }
- if (fixedTime == 202) { //205
- if (this.part4 !== "started") {
- this.part3 = "finished";
- this.back.back3.rectangle.playVideo();
- //this.back.back3.rectangle.fill = "black";
- this.back.back3.visible = false;
- this.body.visible = false;
- this.tuningText.text = "";
- this.tuningText.opacity = 0.3;
- this.tuningText.fill = "grey";
- this.startPart4();
- this.part4 = "started"
- }
- }
- this.future(1).watchPerformance();
- }
- this.resize = function () {
- }
- this.startPart4 = function () {
- let self = this;
- let applause2 = {
- "extends": "proxy/two/ellipse.vwf",
- "properties": {
- "width": 200,
- "height": 200,
- "fill": "/defaults/assets/concert/hands.png",
- x: 220,
- y: 630,
- "drag": true,
- linewidth: 0,
- stroke: "transparent",
- opacity: 0.7,
- scale: 0.4
- }
- }
- let applause3 = {
- "extends": "proxy/two/ellipse.vwf",
- "properties": {
- "width": 200,
- "height": 200,
- "fill": "/defaults/assets/concert/hands.png",
- x: 460,
- y: 560,
- "drag": true,
- linewidth: 0,
- stroke: "transparent",
- opacity: 0.7,
- scale: 0.7
- }
- }
- let applause4 = {
- "extends": "proxy/two/ellipse.vwf",
- "properties": {
- "width": 200,
- "height": 200,
- "fill": "/defaults/assets/concert/hands.png",
- x: 740,
- y: 600,
- "drag": true,
- linewidth: 0,
- stroke: "transparent",
- opacity: 0.7,
- scale: 1
- }
- }
- let clapping2 = {
- "extends": "proxy/tonejs/player.vwf",
- "properties": {
- "url": "/defaults/assets/concert/clapping2.mp3",
- "volume": -10
- }
- }
- let clapping3 = {
- "extends": "proxy/tonejs/player.vwf",
- "properties": {
- "url": "/defaults/assets/concert/clapping3.mp3",
- "volume": -10
- }
- }
- let clapping4 = {
- "extends": "proxy/tonejs/player.vwf",
- "properties": {
- "url": "/defaults/assets/concert/clapping4.mp3",
- "volume": -10
- }
- }
- this.children.create("clapping2", clapping2);
- this.children.create("clapping3", clapping3);
- this.children.create("clapping4", clapping4);
- this.children.create("applause2", applause2, function (child) {
- child.mousedownEvent = function () {
- this.parent.clapping2.start();
- }
- child.mouseupEvent = function () {
- this.parent.clapping2.stop();
- }
- });
- this.children.create("applause3", applause3, function (child) {
- child.mousedownEvent = function () {
- this.parent.clapping3.start();
- }
- child.mouseupEvent = function () {
- this.parent.clapping3.stop();
- }
- });
- this.children.create("applause4", applause4, function (child) {
- child.mousedownEvent = function () {
- this.parent.clapping4.start();
- }
- child.mouseupEvent = function () {
- this.parent.clapping4.stop();
- }
- });
- }
- this.startPart3 = function () {
- //
- if (this.body.children.length == 0)
- this.createBody();
- //this.back.back3.rectangle.setVideoState(true, null, 0);
- this.back.back3.rectangle.syncVideoState();
- //this.back.back3.rectangle.syncVideoState();
- //this.back.back3.rectangle.isPlaying = true;
- this.back.back3.opacity = 1;
- this.filter3.el1.opacity = 0.35;
- this.filter3.el2.opacity = 0.35;
- this.filter3.el1.drag = true;
- this.filter3.el2.drag = true;
- this.back.back3.rectangle.playVideo();
- //this.back.back3.rectangle.unmute();
- //this.body.playBodyMotion("https://localhost:3007/defaults/assets/concert/motion.json");
- }
- this.playBodyMotion = function () {
- let initPose = this.body.getJointsAtTime(0);
- initPose.forEach((e, i) => {
- this.body.children["joint" + i].x = e.x * 1000;
- this.body.children["joint" + i].y = e.y * 1000;
- })
- }
- this.createBody = function () {
- let self = this;
- // let body = {
- // "extends": "proxy/two/group.vwf",
- // "properties": {
- // "drag": false,
- // "x": 239,
- // "y": -57,
- // "motionData": "https://localhost:3007/defaults/assets/concert/motion.json"
- // },
- // "methods":{
- // "applyBodyMotion":{
- // "parameters":["data"]
- // },
- // "getJointAtTime":{},
- // "getJointsAtTime":{}
- // }
- // }
- let child = this.body;
- child.motionData = "/defaults/assets/concert/motion.json";
- //this.children.create("body", body, function( child ) {
- let hands = [18, 20, 22, 21, 19, 17, 15, 16];
- let face = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- let topArr = [16, 14, 12, 11, 13, 15, 24, 23];
- let botArr = [24, 23];
- //let faceArr = [10,8,6,4,1,3,7,9]
- Array.from({ length: 25 }, (x, i) => {
- let d = 20;
- let joint = {
- "extends": "proxy/two/ellipse.vwf",
- "properties": {
- "width": d,
- "height": d,
- "fill": "yellow"
- }
- }
- if (face.includes(i)) {
- joint.properties.width = 5;
- joint.properties.height = 5;
- joint.properties.fill = "grey";
- joint.properties.opacity = 0.2;
- }
- if (hands.includes(i)) {
- joint.properties.width = 10;
- joint.properties.height = 10;
- joint.properties.fill = "grey";
- joint.properties.opacity = 0.5;
- }
- if (topArr.includes(i)) {
- joint.properties.opacity = 0.2;
- }
- if (botArr.includes(i)) {
- joint.properties.opacity = 0;
- }
- child.children.create("joint" + i, joint);
- });
- //16-14-12-11-13-15 - topline
- //12-24-23-11 - bottomline
- //18,16,20 - rh // 16,22
- //17,15,19 - lh // 15,21
- let rh = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
- "fill": "transparent",
- "linewidth": 1,
- "curved": true
- }
- }
- let rh2 = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }],
- "fill": "transparent",
- "linewidth": 1,
- "curved": true
- }
- }
- let lh = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
- "fill": "transparent",
- "linewidth": 1,
- "curved": true
- }
- }
- let lh2 = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }],
- "fill": "transparent",
- "linewidth": 1,
- "curved": true
- }
- }
- let topline = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "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 }],
- "fill": "transparent",
- "linewidth": 3,
- "curved": true
- }
- }
- let bottomline = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "vertices": [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }], //
- "fill": "transparent",
- "linewidth": 3,
- "curved": true
- }
- }
- let faceline = {
- "extends": "proxy/two/curve.vwf",
- "properties": {
- "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 }, { x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }], //
- "fill": "transparent",
- "linewidth": 1.5,
- "curved": true
- }
- }
- child.children.create("topline", topline);
- child.children.create("bottomline", bottomline);
- child.children.create("rhand", rh);
- child.children.create("lhand", lh);
- child.children.create("rhand2", rh2);
- child.children.create("lhand2", lh2);
- child.children.create("faceline", faceline);
- child.applyBodyMotion = function (data) {
- console.log(data);
- }
- //child.setScale(-1,1);
- self.back.back3.rectangle.bodyTrack = true;
- self.back.back3.rectangle.bodyNode = "body";
- //self.future(2).playBodyMotion();
- //});
- }
- this.filter2.el2.mousedownEvent = function () {
- this.fill = this.getRandomColor();
- console.log('CLICK ', this.id);
- }
- this.filter3.el1.overstartEvent = function (avatarID) {
- let scene = this.getScene();
- if (scene.part3 == "started") {
- let nodeName = this.parent.maskedNode;
- if (nodeName) {
- let node = scene.findNode(nodeName).rectangle;
- this.viewTroughFilter(node.id, false);
- //node.visible = true;
- }
- }
- }
- this.filter3.el1.overendEvent = function (avatarID) {
- let scene = this.getScene();
- if (scene.part3 == "started") {
- let nodeName = this.parent.maskedNode;
- if (nodeName) {
- let node = scene.findNode(nodeName).rectangle;
- this.viewTroughFilter(node.id, true);
- //node.visible = false;
- }
- }
- }
- this.filter1.el2.do = function () {
- this.rotation = this.rotation + 0.001;
- }
- this.filter3.el2.overstartEvent = function (avatarID) {
- let scene = this.getScene();
- if (scene.part3 == "started") {
- let nodeName = this.parent.maskedNode;
- if (nodeName) {
- let node = scene.findNode(nodeName).rectangle;
- this.viewTroughFilter(node.id, false);
- //node.visible = true;
- }
- }
- }
- this.filter3.el2.overendEvent = function (avatarID) {
- let scene = this.getScene();
- if (scene.part3 == "started") {
- let nodeName = this.parent.maskedNode;
- if (nodeName) {
- let node = scene.findNode(nodeName).rectangle;
- this.viewTroughFilter(node.id, true);
- //node.visible = false;
- }
- }
- }
- this.filter1.el2.overstartEvent = function (avatarID) {
- // let nodeName = this.parent.maskedNode;
- // if (nodeName) {
- // let node = this.getScene().findNode(nodeName);
- // //this.viewTroughFilter(node.id, true);
- // //node.visible = true;
- // }
- }
- this.filter1.el2.overendEvent = function (avatarID) {
- // let nodeName = this.parent.maskedNode;
- // if (nodeName) {
- // let node = this.getScene().findNode(nodeName);
- // //this.viewTroughFilter(node.id, false);
- // //node.visible = false;
- // }
- }
|