From 82789113a833a2ce9d24e77a17452bb2b6633871 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 5 Feb 2016 19:50:08 -0800 Subject: [PATCH] quiet print messages --- .../CellScience/Scripts/clickToRideAndLook.js | 64 +- .../CellScience/Scripts/moveRandomly.js | 4 +- .../CellScience/Scripts/navigationButton.js | 90 +- .../Scripts/playBackgroundAudio.js | 74 +- .../Scripts/showButtonToPlaySound.js | 190 ++-- .../CellScience/Scripts/showIdentification.js | 75 +- .../CellScience/Scripts/utils.js | 4 +- .../DomainContent/CellScience/Scripts/zoom.js | 93 +- .../CellScience/importCellScience.js | 846 +++++++++--------- 9 files changed, 792 insertions(+), 648 deletions(-) diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/clickToRideAndLook.js b/unpublishedScripts/DomainContent/CellScience/Scripts/clickToRideAndLook.js index 1ba0206edc..d6a9b79467 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/clickToRideAndLook.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/clickToRideAndLook.js @@ -18,21 +18,46 @@ var self = this; this.preload = function(entityId) { - this.entityId = entityId; - this.data = JSON.parse(Entities.getEntityProperties(this.entityId, "userData").userData); - this.buttonImageURL = baseURL + "GUI/GUI_jump_off.png"; - this.addExitButton(); - this.isRiding = false; - self.mouseIsConnected = false; - if (this.data && this.data.isDynein) { - this.rotation = 180; - } else { - this.rotation = 0; - } - + this.initialize(entityId); + self.initTimeout = null; } + this.initialize = function(entityId) { + //print(' should initialize' + entityId) + var properties = Entities.getEntityProperties(entityId); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + //print(' no user data yet, try again in one second') + self.initialize(entityId); + }, 1000) + + } else { + //print(' userdata before parse attempt' + properties.userData) + self.userData = null; + try { + self.userData = JSON.parse(properties.userData); + } catch (err) { + //print(' error parsing json'); + //print(' properties are:' + properties.userData); + return; + } + + self.data = self.userData; + self.buttonImageURL = baseURL + "GUI/GUI_jump_off.png"; + self.addExitButton(); + self.isRiding = false; + self.mouseIsConnected = false; + if (self.data && self.data.isDynein) { + self.rotation = 180; + } else { + self.rotation = 0; + } + } + } + + + this.addExitButton = function() { this.windowDimensions = Controller.getViewportDimensions(); this.buttonWidth = 75; @@ -53,14 +78,16 @@ } this.clickReleaseOnEntity = function(entityId, mouseEvent) { - // print('CLICKED ON MOTOR PROTEIN') + + //print('CLICKED ON MOTOR PROTEIN') + return; if (mouseEvent.isLeftButton && !self.isRiding) { - print("GET ON"); + //print("GET ON"); self.isRiding = true; if (!self.entityId) { self.entityId = entityId; } - self.entityLocation = Entities.getEntityProperties(this.entityId, "position").position; + self.entityLocation = Entities.getEntityProperties(self.entityId, "position").position; self.targetLocation = Vec3.sum(self.entityLocation, TARGET_OFFSET); Overlays.editOverlay(self.exitButton, { visible: true @@ -117,7 +144,7 @@ y: event.y }); if (event.isLeftButton && clickedOverlay === self.exitButton) { - print("GET OFF"); + //print("GET OFF"); Script.update.disconnect(this.update); self.reset(); } @@ -138,7 +165,10 @@ self.reset(); if (self.mouseIsConnected === true) { - Controller.mousePressEvent.disconnect(this.onMousePress); + Controller.mousePressEvent.disconnect(self.onMousePress); + } + if (self.initTimeout !== null) { + Script.clearTimeout(self.initTimeout); } } diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/moveRandomly.js b/unpublishedScripts/DomainContent/CellScience/Scripts/moveRandomly.js index 7a3f2cf8fd..7c880a44b6 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/moveRandomly.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/moveRandomly.js @@ -40,7 +40,7 @@ z: Math.random() - 0.5 }; - // print("POS magnitude is " + magnitudeV + " and direction is " + directionV.x); + //print("POS magnitude is " + magnitudeV + " and direction is " + directionV.x); Entities.editEntity(self.entityId, { velocity: Vec3.multiply(magnitudeV, Vec3.normalize(directionV)) @@ -60,7 +60,7 @@ y: Math.random() - 0.5, z: Math.random() - 0.5 }; - // print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x); + //print("ROT magnitude is " + magnitudeAV + " and direction is " + directionAV.x); Entities.editEntity(self.entityId, { angularVelocity: Vec3.multiply(magnitudeAV, Vec3.normalize(directionAV)) diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js b/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js index 31f6612296..2798b58807 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/navigationButton.js @@ -1,4 +1,3 @@ - // Copyright 2016 High Fidelity, Inc. // // @@ -8,7 +7,7 @@ (function() { - var version = 2; + var version = 10; var added = false; this.frame = 0; var utilsScript = Script.resolvePath('utils.js'); @@ -19,35 +18,61 @@ this.preload = function(entityId) { this.entityId = entityId; - var mySavedSettings = Settings.getValue(entityId); + this.initialize(entityId); + this.initTimeout = null; + } - if (mySavedSettings.buttons !== undefined) { - // print('NAV preload buttons'+ mySavedSettings.buttons) - mySavedSettings.buttons.forEach(function(b) { - // print('NAV deleting button'+ b) - Overlays.deleteOverlay(b); - }) - Settings.setValue(entityId,'') - } - - - self.getUserData(); - this.buttonImageURL = baseURL + "GUI/GUI_" + self.userData.name + ".png?" + version; - if (self.button === undefined) { - // print('NAV NO BUTTON ADDING ONE!!') - self.button = true; - self.addButton(); + this.initialize = function(entityId) { + // print(' should initialize' + entityId) + var properties = Entities.getEntityProperties(entityId); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + // print(' no user data yet, try again in one second') + self.initialize(entityId); + }, 1000) } else { - // print('NAV SELF ALREADY HAS A BUTTON!!') - } + // print(' userdata before parse attempt' + properties.userData) + self.userData = null; + try { + self.userData = JSON.parse(properties.userData); + } catch (err) { + // print(' error parsing json'); + // print(' properties are:' + properties.userData); + return; + } + + var mySavedSettings = Settings.getValue(entityId); + + if (mySavedSettings.buttons !== undefined) { + //print(' preload buttons' + mySavedSettings.buttons) + mySavedSettings.buttons.forEach(function(b) { + //print(' deleting button' + b) + Overlays.deleteOverlay(b); + }) + Settings.setValue(entityId, '') + } + + + self.buttonImageURL = baseURL + "GUI/GUI_" + self.userData.name + ".png?" + version; + //print('BUTTON IMAGE URL:' + self.buttonImageURL) + if (self.button === undefined) { + // print('NAV NO BUTTON ADDING ONE!!') + self.button = true; + self.addButton(); + + } else { + // print('NAV SELF ALREADY HAS A BUTTON!!') + } + + } } + + this.addButton = function() { - - self.getUserData(); this.windowDimensions = Controller.getViewportDimensions(); this.buttonWidth = 150; this.buttonHeight = 50; @@ -87,7 +112,7 @@ if (self.frame < 10) { self.frame++; } else { - // this.lookAt(this.userData.target); + // this.lookAt(this.userData.target); } } @@ -107,7 +132,7 @@ } this.lookAtTarget = function() { - self.getUserData(); + var direction = Vec3.normalize(Vec3.subtract(self.userData.entryPoint, self.userData.target)); var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, { x: 1, @@ -125,16 +150,6 @@ MyAvatar.headYaw = 0; } - - this.getUserData = function() { - this.properties = Entities.getEntityProperties(this.entityId); - if (self.properties.userData) { - this.userData = JSON.parse(this.properties.userData); - } else { - this.userData = {}; - } - } - var buttonDeleter; var deleterCount = 0; this.unload = function() { @@ -144,6 +159,11 @@ Controller.mousePressEvent.disconnect(this.onClick); // Script.update.disconnect(this.update); + + + if (this.initTimeout !== null) { + Script.clearTimeout(this.initTimeout); + } } Controller.mousePressEvent.connect(this.onClick); diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/playBackgroundAudio.js b/unpublishedScripts/DomainContent/CellScience/Scripts/playBackgroundAudio.js index ff1f772d4e..6edccc211c 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/playBackgroundAudio.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/playBackgroundAudio.js @@ -12,50 +12,72 @@ this.preload = function(entityId) { self.soundPlaying = false; self.entityId = entityId; - self.getUserData(); - self.soundURL = baseURL + "Audio/" + self.userData.name + ".wav?" + version; - print("creating WAV name location is " + baseURL + "Audio/" + self.userData.name + ".wav"); - - self.soundOptions = { - stereo: true, - loop: true, - localOnly: true, - volume: 0.035 - }; - - this.sound = SoundCache.getSound(self.soundURL); - + this.initTimeout = null; + this.initialize(entityId); } - this.getUserData = function() { - self.properties = Entities.getEntityProperties(self.entityId); - if (self.properties.userData) { - self.userData = JSON.parse(this.properties.userData); + this.initialize = function(entityID) { + //print(' should initialize' + entityID) + var properties = Entities.getEntityProperties(entityID); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + //print(' no user data yet, try again in one second') + self.initialize(entityID); + }, 1000) + } else { - self.userData = {}; + //print(' userdata before parse attempt' + properties.userData) + self.userData = null; + try { + self.userData = JSON.parse(properties.userData); + } catch (err) { + //print(' error parsing json'); + //print(' properties are:' + properties.userData); + return; + } + + + //print(' USERDATA NAME ' + self.userData.name) + self.soundURL = baseURL + "Audio/" + self.userData.name + ".wav?" + version; + //print(" creating WAV name location is " + baseURL + "Audio/" + self.userData.name + ".wav"); + //print(' self soundURL' + self.soundURL) + + self.soundOptions = { + stereo: true, + loop: true, + localOnly: true, + volume: 0.035 + }; + + self.sound = SoundCache.getSound(self.soundURL); } } this.enterEntity = function(entityID) { - print("entering audio zone"); + //print("entering audio zone"); if (self.sound.downloaded) { - print("playing background audio named " + self.userData.name + "which has been downloaded"); + //print("playing background audio named " + self.userData.name + "which has been downloaded"); this.soundPlaying = Audio.playSound(self.sound, self.soundOptions); } else { - print("sound is not downloaded"); + //print("sound is not downloaded"); } } - this.leaveEntity = function(entityID) { - print("leaving audio area " + self.userData.name); + //print("leaving audio area " + self.userData.name); if (self.soundPlaying !== false) { - print("not null"); - print("Stopped sound " + self.userData.name); + //print("not null"); + //print("Stopped sound " + self.userData.name); self.soundPlaying.stop(); } else { - print("Sound not playing"); + //print("Sound not playing"); + } + } + + this.unload = function() { + if (this.initTimeout !== null) { + Script.clearTimeout(this.initTimeout); } } diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/showButtonToPlaySound.js b/unpublishedScripts/DomainContent/CellScience/Scripts/showButtonToPlaySound.js index e505a532e3..d37655f09b 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/showButtonToPlaySound.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/showButtonToPlaySound.js @@ -6,97 +6,117 @@ // (function() { - var baseURL = "https://hifi-content.s3.amazonaws.com/hifi-content/DomainContent/CellScience/"; - var self = this; - this.buttonImageURL = baseURL + "GUI/play_audio.svg?2"; + var baseURL = "https://hifi-content.s3.amazonaws.com/hifi-content/DomainContent/CellScience/"; + var self = this; + this.buttonImageURL = baseURL + "GUI/play_audio.svg?2"; - - - this.preload = function(entityId) { - this.entityId = entityId; - self.addButton(); - this.buttonShowing = false; - self.getUserData(); - this.showDistance = self.userData.showDistance; - this.soundURL = baseURL + "Audio/" + self.userData.soundName + ".wav"; - print("distance = " + self.userData.showDistance + ", sound = " + this.soundURL); - this.soundOptions = { - stereo: true, - loop: false, - localOnly: true, - volume: 0.5 - }; - this.sound = SoundCache.getSound(this.soundURL); - } - - this.addButton = function() { - this.windowDimensions = Controller.getViewportDimensions(); - this.buttonWidth = 100; - this.buttonHeight = 100; - this.buttonPadding = 0; - - this.buttonPositionX = (self.windowDimensions.x - self.buttonPadding) / 2 - self.buttonWidth; - this.buttonPositionY = (self.windowDimensions.y - self.buttonHeight) - (self.buttonHeight + self.buttonPadding); - this.button = Overlays.addOverlay("image", { - x: self.buttonPositionX, - y: self.buttonPositionY, - width: self.buttonWidth, - height: self.buttonHeight, - imageURL: self.buttonImageURL, - visible: false, - alpha: 1.0 - }); - } - - this.getUserData = function() { - this.properties = Entities.getEntityProperties(this.entityId); - if (self.properties.userData) { - this.userData = JSON.parse(this.properties.userData); - } else { - this.userData = {}; + this.preload = function(entityId) { + this.entityId = entityId; + this.initialize(entityId) + this.initTimeout = null; } - } - this.update = function(deltaTime) { + this.initialize = function(entityId) { + print(' should initialize' + entityId) + var properties = Entities.getEntityProperties(entityId); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + print(' no user data yet, try again in one second') + self.initialize(entityId); + }, 1000) - self.distance = Vec3.distance(MyAvatar.position, Entities.getEntityProperties(self.entityId).position); - //print(self.distance); - if (!self.buttonShowing && self.distance < self.userData.showDistance) { - self.buttonShowing = true; - Overlays.editOverlay(self.button, { - visible: true - }); - } else if (self.buttonShowing && self.distance > self.userData.showDistance) { - self.buttonShowing = false; - Overlays.editOverlay(self.button, { - visible: false - }); - } - } - - this.onClick = function(event) { - var clickedOverlay = Overlays.getOverlayAtPoint({ - x: event.x, - y: event.y - }); - if (clickedOverlay === self.button) { - print("button was clicked"); - if (self.sound.downloaded) { - print("play sound"); - Audio.playSound(self.sound, self.soundOptions); } else { - print("not downloaded"); + print(' userdata before parse attempt' + properties.userData) + self.userData = null; + try { + self.userData = JSON.parse(properties.userData); + } catch (err) { + print(' error parsing json'); + print(' properties are:' + properties.userData); + return; + } + + + + self.addButton(); + self.buttonShowing = false; + self.showDistance = self.userData.showDistance; + self.soundURL = baseURL + "Audio/" + self.userData.soundName + ".wav"; + // print("distance = " + self.userData.showDistance + ", sound = " + self.soundURL); + self.soundOptions = { + stereo: true, + loop: false, + localOnly: true, + volume: 0.75 + }; + self.sound = SoundCache.getSound(this.soundURL); + + + } - } - } - this.unload = function() { - Overlays.deleteOverlay(self.button); - Controller.mousePressEvent.disconnect(this.onClick); - Script.update.disconnect(this.update); - } + this.addButton = function() { + this.windowDimensions = Controller.getViewportDimensions(); + this.buttonWidth = 100; + this.buttonHeight = 100; + this.buttonPadding = 0; - Controller.mousePressEvent.connect(this.onClick); - Script.update.connect(this.update); + this.buttonPositionX = (self.windowDimensions.x - self.buttonPadding) / 2 - self.buttonWidth; + this.buttonPositionY = (self.windowDimensions.y - self.buttonHeight) - (self.buttonHeight + self.buttonPadding); + this.button = Overlays.addOverlay("image", { + x: self.buttonPositionX, + y: self.buttonPositionY, + width: self.buttonWidth, + height: self.buttonHeight, + imageURL: self.buttonImageURL, + visible: false, + alpha: 1.0 + }); + } -}); \ No newline at end of file + this.update = function(deltaTime) { + + self.distance = Vec3.distance(MyAvatar.position, Entities.getEntityProperties(self.entityId).position); + //print(self.distance); + if (!self.buttonShowing && self.distance < self.userData.showDistance) { + self.buttonShowing = true; + Overlays.editOverlay(self.button, { + visible: true + }); + } else if (self.buttonShowing && self.distance > self.userData.showDistance) { + self.buttonShowing = false; + Overlays.editOverlay(self.button, { + visible: false + }); + } + } + + this.onClick = function(event) { + var clickedOverlay = Overlays.getOverlayAtPoint({ + x: event.x, + y: event.y + }); + if (clickedOverlay === self.button) { + print("button was clicked"); + if (self.sound.downloaded) { + print("play sound"); + Audio.playSound(self.sound, self.soundOptions); + } else { + print("not downloaded"); + } + } + } + + this.unload = function() { + Overlays.deleteOverlay(self.button); + Controller.mousePressEvent.disconnect(this.onClick); + Script.update.disconnect(this.update); + if (this.initTimeout !== null) { + Script.clearTimeout(this.initTimeout); + } + } + + Controller.mousePressEvent.connect(this.onClick); + Script.update.connect(this.update); + + }); \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/showIdentification.js b/unpublishedScripts/DomainContent/CellScience/Scripts/showIdentification.js index 2e37f3a51f..7c019865e9 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/showIdentification.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/showIdentification.js @@ -14,20 +14,47 @@ this.preload = function(entityId) { this.soundPlaying = null; this.entityId = entityId; - self.getUserData(); - this.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version; - this.showDistance = self.userData.showDistance; - this.soundURL = baseURL + "Audio/" + self.userData.name + ".wav"; - this.soundOptions = { - stereo: true, - loop: false, - localOnly: true, - volume: 0.035, - position: this.position - }; - this.sound = SoundCache.getSound(this.soundURL); - this.buttonImageURL = baseURL + "GUI/GUI_audio.png?" + version; - self.addButton(); + self.initTimeout = null; + this.initialize(entityId); + + + } + + this.initialize = function(entityId) { + print(' should initialize' + entityId) + var properties = Entities.getEntityProperties(entityId); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + //print(' no user data yet, try again in one second') + self.initialize(entityId); + }, 1000) + + } else { + //print(' userdata before parse attempt' + properties.userData) + self.userData = null; + try { + self.userData = JSON.parse(properties.userData); + } catch (err) { + //print(' error parsing json'); + //print(' properties are:' + properties.userData); + return; + } + + self.labelURL = baseURL + "GUI/labels_" + self.userData.name + ".png?" + version; + self.showDistance = self.userData.showDistance; + self.soundURL = baseURL + "Audio/" + self.userData.name + ".wav"; + self.soundOptions = { + stereo: true, + loop: false, + localOnly: true, + volume: 0.035, + position: properties.position + }; + self.sound = SoundCache.getSound(self.soundURL); + self.buttonImageURL = baseURL + "GUI/GUI_audio.png?" + version; + self.addButton(); + + } } this.addButton = function() { @@ -78,9 +105,8 @@ this.enterEntity = function(entityID) { - // self.getUserData(); - print("entering entity and showing" + self.labelURL); - //self.buttonShowing = true; + // print("entering entity and showing" + self.labelURL); + Overlays.editOverlay(self.button, { visible: true }); @@ -92,9 +118,8 @@ this.leaveEntity = function(entityID) { - // self.getUserData(); - // print("leaving entity " + self.userData.name); - //self.buttonShowing = false; + // print("leaving entity " + self.userData.name); + print(Overlays); Overlays.editOverlay(self.button, { visible: false @@ -110,16 +135,16 @@ y: event.y }); if (clickedOverlay == self.button) { - print("button was clicked"); + //print("button was clicked"); if (self.sound.downloaded) { - print("play sound"); + // print("play sound"); Overlays.editOverlay(self.button, { visible: false }); this.soundPlaying = Audio.playSound(self.sound, self.soundOptions); } else { - print("not downloaded"); + // print("not downloaded"); } } } @@ -129,7 +154,9 @@ if (this.soundPlaying !== null) { this.soundPlaying.stop(); } - + if (self.initTimeout !== null) { + Script.clearTimeout(self.initTimeout); + } Controller.mousePressEvent.disconnect(this.onClick); } diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/utils.js b/unpublishedScripts/DomainContent/CellScience/Scripts/utils.js index 10a0827e9d..8b1f5c4055 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/utils.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/utils.js @@ -20,8 +20,8 @@ getEntityUserData = function(id) { try { results = JSON.parse(properties.userData); } catch (err) { - print('error parsing json'); - print('properties are:'+ properties.userData); + // print('error parsing json'); + // print('properties are:'+ properties.userData); } } return results ? results : {}; diff --git a/unpublishedScripts/DomainContent/CellScience/Scripts/zoom.js b/unpublishedScripts/DomainContent/CellScience/Scripts/zoom.js index 101ce54a5e..8b720b7fec 100644 --- a/unpublishedScripts/DomainContent/CellScience/Scripts/zoom.js +++ b/unpublishedScripts/DomainContent/CellScience/Scripts/zoom.js @@ -14,64 +14,76 @@ this.entered = true; this.preload = function(entityID) { - this.entityId = entityID; + this.initialize(entityID); + this.initTimeout = null; + } + this.initialize = function(entityID) { + // print(' should initialize') var properties = Entities.getEntityProperties(entityID); - portalDestination = properties.userData; - animationURL = properties.modelURL; - this.soundOptions = { - stereo: true, - loop: false, - localOnly: false, - position: this.position, - volume: 0.035 - }; - - this.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav"); - //print('Script.clearTimeout PRELOADING A ZOOM ENTITY') - print(" portal destination is " + portalDestination); + if (properties.userData.length === 0 || properties.hasOwnProperty('userData') === false) { + self.initTimeout = Script.setTimeout(function() { + // print(' no user data yet, try again in one second') + self.initialize(entityID); + }, 1000) + } else { + // print(' has userData') + self.portalDestination = properties.userData; + animationURL = properties.modelURL; + self.soundOptions = { + stereo: true, + loop: false, + localOnly: false, + position: properties.position, + volume: 0.5 + }; + + self.teleportSound = SoundCache.getSound("https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/Audio/whoosh.wav"); + // print(" portal destination is " + self.portalDestination); + } } this.enterEntity = function(entityID) { - print('Script.clearTimeout ENTERED A BOUNDARY ENTITY, SHOULD ZOOM', entityID) + // print(' ENTERED A BOUNDARY ENTITY, SHOULD ZOOM', entityID) var data = JSON.parse(Entities.getEntityProperties(this.entityId).userData); - - + // print(' DATA IS::' + data) if (data != null) { - print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")"); + // print("Teleporting to (" + data.location.x + ", " + data.location.y + ", " + data.location.z + ")"); if (self.teleportSound.downloaded) { //print("play sound"); + MyAvatar.position = data.location; Audio.playSound(self.teleportSound, self.soundOptions); + } else { //print("not downloaded"); } - this.lookAt(data.target, data.location); - + // this.lookAt(data.target, data.location); } } - this.lookAt = function(targetPosition, avatarPosition) { - var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition)); + // this.lookAt = function(targetPosition, avatarPosition) { + // print('GOING TO') + // var direction = Vec3.normalize(Vec3.subtract(MyAvatar.position, targetPosition)); - var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, { - x: 1, - y: 0, - z: 0 - }); - var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, { - x: 0, - y: 1, - z: 0 - }); - - MyAvatar.goToLocation(avatarPosition, true, yaw); - MyAvatar.headYaw = 0; - } + // var pitch = Quat.angleAxis(Math.asin(-direction.y) * 180.0 / Math.PI, { + // x: 1, + // y: 0, + // z: 0 + // }); + // var yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * 180.0 / Math.PI, { + // x: 0, + // y: 1, + // z: 0 + // }); + // print('JBP ZOOM DEBUG YO') + // MyAvatar.goToLocation(avatarPosition, true, yaw); + // MyAvatar.headYaw = 0; + // } @@ -81,9 +93,18 @@ animationSettings: '{ "frameIndex": 1, "running": false }' }); this.entered = false; + if (this.initTimeout !== null) { + Script.clearTimeout(this.initTimeout); + } //playSound(); } + this.unload = function() { + if (this.initTimeout !== null) { + Script.clearTimeout(this.initTimeout); + } + } + this.hoverEnterEntity = function(entityID) { Entities.editEntity(entityID, { animationURL: animationURL, diff --git a/unpublishedScripts/DomainContent/CellScience/importCellScience.js b/unpublishedScripts/DomainContent/CellScience/importCellScience.js index 36b60bf939..ad18c2db3c 100644 --- a/unpublishedScripts/DomainContent/CellScience/importCellScience.js +++ b/unpublishedScripts/DomainContent/CellScience/importCellScience.js @@ -5,7 +5,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var version = 1005; +var version = 1015; var cellLayout; var baseLocation = "https://hifi-content.s3.amazonaws.com/DomainContent/CellScience/"; @@ -79,398 +79,137 @@ var locations = { }, 1000] }; -var scenes = [ - { - name: "Cells", - objects: "", - location: locations.cells[0], - entryPoint: locations.cells[1], - zone: { - dimensions: { - x: 4000, - y: 4000, - z: 4000 - }, - light: { - r: 255, - g: 200, - b: 200 - }, - intensity: 1.1, - ambient: 0.7, - sun: true, - skybox: "cells_skybox_cross" +var scenes = [{ + name: "Cells", + objects: "", + location: locations.cells[0], + entryPoint: locations.cells[1], + zone: { + dimensions: { + x: 4000, + y: 4000, + z: 4000 }, - instances: [{ - model: "Cell", + light: { + r: 255, + g: 200, + b: 200 + }, + intensity: 1.1, + ambient: 0.7, + sun: true, + skybox: "cells_skybox_cross" + }, + instances: [{ + model: "Cell", + dimensions: { + x: 550, + y: 620, + z: 550 + }, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 500, + number: 10, + userData: JSON.stringify({ + target: locations.cellLayout[1], + location: locations.cellLayout[0], + baseURL: baseLocation + }), + script: "zoom.js?" + version, + visible: true + }], + boundary: { + radius: locations.cells[2], + center: locations.cells[0], + location: locations.cellLayout[1], + target: locations.cellLayout[0] + } +}, { + name: "CellLayout", + objects: cellLayout, + location: locations.cellLayout[0], + entryPoint: locations.cellLayout[1], + zone: { + dimensions: { + x: 4000, + y: 4000, + z: 4000 + }, + light: { + r: 247, + g: 233, + b: 220 + }, + intensity: 2.3, + ambient: 0.7, + sun: true, + skybox: "cosmos_skybox_blurred" + }, + instances: [{ + model: "translation", dimensions: { - x: 550, - y: 620, - z: 550 + x: 10, + y: 16, + z: 10 }, offset: { x: 0, y: 0, z: 0 }, - radius: 500, - number: 10, + radius: 300, + number: 15, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + }, + target: locations.ribosome[1], + location: locations.ribosome[0], + baseURL: baseLocation + }), + script: "zoom.js?" + version, + visible: true + }, { + model: "vesicle", + dimensions: { + x: 60, + y: 60, + z: 60 + }, + randomSize: 10, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1000, + number: 45, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), script: "moveRandomly.js?" + version, visible: true - }], - boundary: { - radius: locations.cells[2], - center: locations.cells[0], - location: locations.cellLayout[1], - target: locations.cellLayout[0] - } - }, { - name: "CellLayout", - objects: cellLayout, - location: locations.cellLayout[0], - entryPoint: locations.cellLayout[1], - zone: { + }, { //golgi vesicles + model: "vesicle", dimensions: { - x: 4000, - y: 4000, - z: 4000 - }, - light: { - r: 247, - g: 233, - b: 220 - }, - intensity: 2.3, - ambient: 0.7, - sun: true, - skybox: "cosmos_skybox_blurred" - }, - instances: [{ - model: "translation", - dimensions: { - x: 10, - y: 16, - z: 10 - }, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 300, - number: 15, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - }, - target: locations.ribosome[1], - location: locations.ribosome[0], - baseURL: baseLocation - }), - script: "zoom.js?" + version, - visible: true - }, { - model: "vesicle", - dimensions: { - x: 60, - y: 60, - z: 60 - }, - randomSize: 10, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 1000, - number: 45, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "moveRandomly.js?" + version, - visible: true - }, { //golgi vesicles - model: "vesicle", - dimensions: { - x: 10, - y: 10, - z: 10 - }, - randomSize: 10, - offset: { - x: -319, - y: 66, - z: 976 - }, - radius: 140, - number: 20, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "", - visible: true - }, { //golgi vesicles - model: "vesicle", - dimensions: { - x: 15, - y: 15, - z: 15 - }, - randomSize: 10, - offset: { - x: -319, - y: 66, - z: 976 - }, - radius: 115, - number: 15, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "moveRandomly.js?" + version, - visible: true - }, { - model: "vesicle", - dimensions: { - x: 50, - y: 50, - z: 50 - }, - randomSize: 10, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 600, - number: 30, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "", - visible: true - }, { //outer vesicles - model: "vesicle", - dimensions: { - x: 60, - y: 60, - z: 60 - }, - randomSize: 10, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 1600, - number: 45, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "", - visible: true - }, { //outer vesicles - model: "vesicle", - dimensions: { - x: 40, - y: 40, - z: 40 - }, - randomSize: 10, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 1400, - number: 45, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "moveRandomly.js?" + version, - visible: true - }, { //outer vesicles - model: "vesicle", - dimensions: { - x: 80, - y: 80, - z: 80 - }, - randomSize: 10, - offset: { - x: 0, - y: 0, - z: 0 - }, - radius: 1800, - number: 45, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "moveRandomly.js?" + version, - visible: true - }, - // {//wigglies - // model:"wiggly", - // dimensions:{x:320,y:40,z:160}, - // randomSize: 10, - // offset:{x:0,y:0,z:0}, - // radius:1800, - // number:50, - // userData:"", - // script:"moveRandomly", - // visible:true - // }, - //// {//wigglies - // model:"wiggly", - // dimensions:{x:640,y:80,z:320}, - // randomSize: 10, - // offset:{x:0,y:0,z:0}, - // radius:2100, - // number:50, - // userData:"", - // script:"moveRandomly", - // visible:true - // }, - { - model: "hexokinase", - dimensions: { - x: 3, - y: 4, - z: 3 - }, - randomSize: 10, - offset: { - x: 236, - y: 8, - z: 771 - }, - radius: 80, - number: 15, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - }, - target: locations.hexokinase[1], - location: locations.hexokinase[0], - baseURL: baseLocation - }), - script: "zoom.js?" + version, - visible: true - }, { - model: "pfructo_kinase", - dimensions: { - x: 3, - y: 4, - z: 3 - }, - randomSize: 10, - offset: { - x: 236, - y: 8, - z: 771 - }, - radius: 60, - number: 15, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "", - visible: true - }, { - model: "glucose_isomerase", - dimensions: { - x: 3, - y: 4, - z: 3 - }, - randomSize: 10, - offset: { - x: 236, - y: 8, - z: 771 - }, - radius: 70, - number: 15, - userData: JSON.stringify({ - grabbableKey: { - grabbable: false - } - }), - script: "", - visible: true - } - // { - // model:"NPC", - // dimensions:{x:20,y:20,z:20}, - // randomSize: 10, - // offset:{x:208.593693,y:6.113100222,z:153.3202277}, - // radius:520, - // number:25, - // userData: "", - // script:"", - // visible:true - // } - - - ], - boundary: { - radius: locations.cellLayout[2], - center: locations.cellLayout[0], - location: locations.cells[1], - target: locations.cells[0] - } - }, { - name: "Ribosome", - objects: "", - location: locations.ribosome[0], - entryPoint: locations.ribosome[1], - zone: { - dimensions: { - x: 4000, - y: 4000, - z: 4000 - }, - light: { - r: 250, - g: 185, - b: 182 - }, - intensity: 0.6, - ambient: 2.9, - sun: true, - skybox: "ribosome_skybox" - }, - instances: [{ - model: "translation_highres", - dimensions: { - x: 500, - y: 500, - z: 200 + x: 10, + y: 10, + z: 10 }, + randomSize: 10, offset: { - x: 0, - y: 0, - z: 0 + x: -319, + y: 66, + z: 976 }, - radius: 1, - number: 1, + radius: 140, + number: 20, userData: JSON.stringify({ grabbableKey: { grabbable: false @@ -478,48 +217,201 @@ var scenes = [ }), script: "", visible: true - }], - boundary: { - radius: locations.ribosome[2], - center: locations.ribosome[0], - location: locations.translation[1], - target: locations.translation[0] - } - }, { - name: "Hexokinase", - objects: "", - location: locations.hexokinase[0], - entryPoint: locations.hexokinase[1], - zone: { + }, { //golgi vesicles + model: "vesicle", dimensions: { - x: 4000, - y: 4000, - z: 4000 + x: 15, + y: 15, + z: 15 }, - light: { - r: 255, - g: 255, - b: 255 + randomSize: 10, + offset: { + x: -319, + y: 66, + z: 976 }, - intensity: 0.6, - ambient: 0.6, - sun: true, - skybox: "hexokinase_skybox" - }, - instances: [{ - model: "hexokinase_highres", + radius: 115, + number: 15, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "moveRandomly.js?" + version, + visible: true + }, { + model: "vesicle", dimensions: { - x: 600, - y: 600, - z: 600 + x: 50, + y: 50, + z: 50 }, + randomSize: 10, offset: { x: 0, y: 0, z: 0 }, - radius: 1, - number: 1, + radius: 600, + number: 30, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "", + visible: true + }, { //outer vesicles + model: "vesicle", + dimensions: { + x: 60, + y: 60, + z: 60 + }, + randomSize: 10, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1600, + number: 45, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "", + visible: true + }, { //outer vesicles + model: "vesicle", + dimensions: { + x: 40, + y: 40, + z: 40 + }, + randomSize: 10, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1400, + number: 45, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "moveRandomly.js?" + version, + visible: true + }, { //outer vesicles + model: "vesicle", + dimensions: { + x: 80, + y: 80, + z: 80 + }, + randomSize: 10, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1800, + number: 45, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "moveRandomly.js?" + version, + visible: true + }, + // {//wigglies + // model:"wiggly", + // dimensions:{x:320,y:40,z:160}, + // randomSize: 10, + // offset:{x:0,y:0,z:0}, + // radius:1800, + // number:50, + // userData:"", + // script:"moveRandomly", + // visible:true + // }, + //// {//wigglies + // model:"wiggly", + // dimensions:{x:640,y:80,z:320}, + // randomSize: 10, + // offset:{x:0,y:0,z:0}, + // radius:2100, + // number:50, + // userData:"", + // script:"moveRandomly", + // visible:true + // }, + { + model: "hexokinase", + dimensions: { + x: 3, + y: 4, + z: 3 + }, + randomSize: 10, + offset: { + x: 236, + y: 8, + z: 771 + }, + radius: 80, + number: 15, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + }, + target: locations.hexokinase[1], + location: locations.hexokinase[0], + baseURL: baseLocation + }), + script: "zoom.js?" + version, + visible: true + }, { + model: "pfructo_kinase", + dimensions: { + x: 3, + y: 4, + z: 3 + }, + randomSize: 10, + offset: { + x: 236, + y: 8, + z: 771 + }, + radius: 60, + number: 15, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "", + visible: true + }, { + model: "glucose_isomerase", + dimensions: { + x: 3, + y: 4, + z: 3 + }, + randomSize: 10, + offset: { + x: 236, + y: 8, + z: 771 + }, + radius: 70, + number: 15, userData: JSON.stringify({ grabbableKey: { grabbable: false @@ -527,15 +419,126 @@ var scenes = [ }), script: "", visible: true - }], - boundary: { - radius: locations.hexokinase[2], - center: locations.hexokinase[0], - location: locations.mitochondria[1], - target: locations.mitochondria[0] } + // { + // model:"NPC", + // dimensions:{x:20,y:20,z:20}, + // randomSize: 10, + // offset:{x:208.593693,y:6.113100222,z:153.3202277}, + // radius:520, + // number:25, + // userData: "", + // script:"", + // visible:true + // } + + + ], + boundary: { + radius: locations.cellLayout[2], + center: locations.cellLayout[0], + location: locations.cells[1], + target: locations.cells[0] } -]; +}, { + name: "Ribosome", + objects: "", + location: locations.ribosome[0], + entryPoint: locations.ribosome[1], + zone: { + dimensions: { + x: 4000, + y: 4000, + z: 4000 + }, + light: { + r: 250, + g: 185, + b: 182 + }, + intensity: 0.6, + ambient: 2.9, + sun: true, + skybox: "ribosome_skybox" + }, + instances: [{ + model: "translation_highres", + dimensions: { + x: 500, + y: 500, + z: 200 + }, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1, + number: 1, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "", + visible: true + }], + boundary: { + radius: locations.ribosome[2], + center: locations.ribosome[0], + location: locations.translation[1], + target: locations.translation[0] + } +}, { + name: "Hexokinase", + objects: "", + location: locations.hexokinase[0], + entryPoint: locations.hexokinase[1], + zone: { + dimensions: { + x: 4000, + y: 4000, + z: 4000 + }, + light: { + r: 255, + g: 255, + b: 255 + }, + intensity: 0.6, + ambient: 0.6, + sun: true, + skybox: "hexokinase_skybox" + }, + instances: [{ + model: "hexokinase_highres", + dimensions: { + x: 600, + y: 600, + z: 600 + }, + offset: { + x: 0, + y: 0, + z: 0 + }, + radius: 1, + number: 1, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }), + script: "", + visible: true + }], + boundary: { + radius: locations.hexokinase[2], + center: locations.hexokinase[0], + location: locations.mitochondria[1], + target: locations.mitochondria[0] + } +}]; function ImportScene(scene) { @@ -637,6 +640,7 @@ function createLayoutLights() { }) } + function CreateNavigationButton(scene, number) { // print('NAV NAVIGATION CREATING NAV!!' +scene.name + " " + number) @@ -811,7 +815,7 @@ function CreateInstances(scene) { }, idBounds, 150); } - print('Script.clearTimeout SCRIPT AT CREATE ENTITY: ' + script) + //print('SCRIPT AT CREATE ENTITY: ' + script) CreateEntity(scene.instances[i].model, position, rotation, scene.instances[i].dimensions, url, script, scene.instances[i].userData, scene.instances[i].visible); } } @@ -890,7 +894,7 @@ function getPointOnSphereOfRadius(radius, number, totalNumber) { // print("inc " + inc + " off " + off + " y " + y + " r " + r + " phi " + phi); if (isNaN(r)) { - print("r is not a number"); + //print("r is not a number"); r = 1; } @@ -913,7 +917,7 @@ function CreateEntity(name, position, rotation, dimensions, url, script, userDat scriptLocation = baseLocation + "Scripts/" + script; } - print('Script.clearTimeout SCRIPT LOCATION IN CREATE ENTITY' + scriptLocation) + //print(' SCRIPT LOCATION IN CREATE ENTITY' + scriptLocation) Entities.addEntity({ type: "Model", name: name,