From 0aab01d774f7a76972ca4c35a577afc635753a7d Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 18 Mar 2016 12:37:28 -0700 Subject: [PATCH 1/2] remove switches to prep for next merge --- .../Home/pingPongGun/pingPongGun.js | 6 + .../Home/switches/dressingRoomDiscLights.js | 180 ------------------ .../Home/switches/livingRoomDiscLights.js | 180 ------------------ .../Home/switches/livingRoomFan.js | 136 ------------- 4 files changed, 6 insertions(+), 496 deletions(-) delete mode 100644 unpublishedScripts/DomainContent/Home/switches/dressingRoomDiscLights.js delete mode 100644 unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js delete mode 100644 unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js diff --git a/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js index 9e0f5eb47f..c769f53768 100644 --- a/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js +++ b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js @@ -33,6 +33,12 @@ z: 0 }; + var PING_PONG_GUN_GRAVITY = { + x: 0, + y: -5, + z: 0 + }; + var BALL_DIMENSIONS = { x: 0.04, y: 0.04, diff --git a/unpublishedScripts/DomainContent/Home/switches/dressingRoomDiscLights.js b/unpublishedScripts/DomainContent/Home/switches/dressingRoomDiscLights.js deleted file mode 100644 index 4719b9ee5a..0000000000 --- a/unpublishedScripts/DomainContent/Home/switches/dressingRoomDiscLights.js +++ /dev/null @@ -1,180 +0,0 @@ -(function() { - - var SEARCH_RADIUS = 100; - - var EMISSIVE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelitysign_white_emissive.png"; - - var DIFFUSE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelity_diffusebaked.png"; - - var _this; - var utilitiesScript = Script.resolvePath('../../../../libraries/utils.js'); - Script.include(utilitiesScript); - Switch = function() { - _this = this; - this.switchSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/lamp_switch_2.wav"); - }; - - Switch.prototype = { - prefix: 'hifi-home-dressing-room-disc-light', - clickReleaseOnEntity: function(entityID, mouseEvent) { - if (!mouseEvent.isLeftButton) { - return; - } - this.toggleLights(); - }, - - startNearTrigger: function() { - this.toggleLights(); - }, - - modelEmitOn: function(discModel) { - Entities.editEntity(glowDisc, { - textures: 'emissive:' + EMISSIVE_TEXTURE_URL ',\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"' - }) - }, - - modelEmitOff: function(discModel) { - Entities.editEntity(glowDisc, { - textures: 'emissive:"",\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"' - }) - }, - - masterLightOn: function(masterLight) { - Entities.editEntity(masterLight, { - visible: true - }); - }, - - masterLightOff: function() { - Entities.editEntity(masterLight, { - visible: false - }); - }, - - glowLightOn: function(glowLight) { - Entities.editEntity(glowLight, { - visible: true - }); - }, - - glowLightOff: function(glowLight) { - Entities.editEntity(glowLight, { - visible: false - }); - }, - - findGlowLights: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "light-glow") { - found.push(result); - } - }); - return found; - }, - - findMasterLights: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "light-master") { - found.push(result); - } - }); - return found; - }, - - findEmitModels: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "light-model") { - found.push(result); - } - }); - return found; - }, - - toggleLights: function() { - - this.switch = getEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - - var glowLights = this.findGlowLights(); - var masterLights = this.findMasterLights(); - var emitModels = this.findEmitModels(); - - if (this.switch.state === 'off') { - glowLights.forEach(function(glowLight) { - _this.glowLightOn(glowLight); - }); - masterLights.forEach(function(masterLight) { - _this.masterLightOn(masterLight); - }); - emitModels.forEach(function(emitModel) { - _this.modelEmitOn(emitModel); - }); - setEntityCustomData('home-switch', this.entityID, { - state: 'on' - }); - - } else { - glowLights.forEach(function(glowLight) { - _this.glowLightOff(glowLight); - }); - masterLights.forEach(function(masterLight) { - _this.masterLightOff(masterLight); - }); - emitModels.forEach(function(emitModel) { - _this.modelEmitOff(emitModel); - }); - setEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - } - - this.flipSwitch(); - Audio.playSound(this.switchSound, { - volume: 0.5, - position: this.position - }); - - }, - - flipSwitch: function() { - var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation; - var axis = { - x: 0, - y: 1, - z: 0 - }; - var dQ = Quat.angleAxis(180, axis); - rotation = Quat.multiply(rotation, dQ); - - Entities.editEntity(this.entityID, { - rotation: rotation - }); - }, - - preload: function(entityID) { - this.entityID = entityID; - setEntityCustomData('grabbableKey', this.entityID, { - wantsTrigger: true - }); - - var properties = Entities.getEntityProperties(this.entityID); - - - //The light switch is static, so just cache its position once - this.position = Entities.getEntityProperties(this.entityID, "position").position; - } - }; - - // entity scripts always need to return a newly constructed object of our type - return new Switch(); -}); \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js b/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js deleted file mode 100644 index c342e9d16a..0000000000 --- a/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js +++ /dev/null @@ -1,180 +0,0 @@ -(function() { - - var SEARCH_RADIUS = 100; - - var EMISSIVE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelitysign_white_emissive.png"; - - var DIFFUSE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelity_diffusebaked.png"; - - var _this; - var utilitiesScript = Script.resolvePath('../../../../libraries/utils.js'); - Script.include(utilitiesScript); - Switch = function() { - _this = this; - this.switchSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/lamp_switch_2.wav"); - }; - - Switch.prototype = { - prefix: 'hifi-home-living-room-disc-light', - clickReleaseOnEntity: function(entityID, mouseEvent) { - if (!mouseEvent.isLeftButton) { - return; - } - this.toggleLights(); - }, - - startNearTrigger: function() { - this.toggleLights(); - }, - - modelEmitOn: function(discModel) { - Entities.editEntity(glowDisc, { - textures: 'emissive:' + EMISSIVE_TEXTURE_URL ',\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"' - }) - }, - - modelEmitOff: function(discModel) { - Entities.editEntity(glowDisc, { - textures: 'emissive:"",\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"' - }) - }, - - masterLightOn: function(masterLight) { - Entities.editEntity(masterLight, { - visible: true - }); - }, - - masterLightOff: function() { - Entities.editEntity(masterLight, { - visible: false - }); - }, - - glowLightOn: function(glowLight) { - Entities.editEntity(glowLight, { - visible: true - }); - }, - - glowLightOff: function(glowLight) { - Entities.editEntity(glowLight, { - visible: false - }); - }, - - findGlowLights: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "glow") { - found.push(result); - } - }); - return found; - }, - - findMasterLights: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "master") { - found.push(result); - } - }); - return found; - }, - - findEmitModels: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix + "model") { - found.push(result); - } - }); - return found; - }, - - toggleLights: function() { - - this.switch = getEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - - var glowLights = this.findGlowLights(); - var masterLights = this.findMasterLights(); - var emitModels = this.findEmitModels(); - - if (this.switch.state === 'off') { - glowLights.forEach(function(glowLight) { - _this.glowLightOn(glowLight); - }); - masterLights.forEach(function(masterLight) { - _this.masterLightOn(masterLight); - }); - emitModels.forEach(function(emitModel) { - _this.modelEmitOn(emitModel); - }); - setEntityCustomData('home-switch', this.entityID, { - state: 'on' - }); - - } else { - glowLights.forEach(function(glowLight) { - _this.glowLightOff(glowLight); - }); - masterLights.forEach(function(masterLight) { - _this.masterLightOff(masterLight); - }); - emitModels.forEach(function(emitModel) { - _this.modelEmitOff(emitModel); - }); - setEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - } - - this.flipSwitch(); - Audio.playSound(this.switchSound, { - volume: 0.5, - position: this.position - }); - - }, - - flipSwitch: function() { - var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation; - var axis = { - x: 0, - y: 1, - z: 0 - }; - var dQ = Quat.angleAxis(180, axis); - rotation = Quat.multiply(rotation, dQ); - - Entities.editEntity(this.entityID, { - rotation: rotation - }); - }, - - preload: function(entityID) { - this.entityID = entityID; - setEntityCustomData('grabbableKey', this.entityID, { - wantsTrigger: true - }); - - var properties = Entities.getEntityProperties(this.entityID); - - - //The light switch is static, so just cache its position once - this.position = Entities.getEntityProperties(this.entityID, "position").position; - } - }; - - // entity scripts always need to return a newly constructed object of our type - return new Switch(); -}); \ No newline at end of file diff --git a/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js b/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js deleted file mode 100644 index 6498807e47..0000000000 --- a/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js +++ /dev/null @@ -1,136 +0,0 @@ -(function() { - var SEARCH_RADIUS = 100; - var _this; - var utilitiesScript = Script.resolvePath('../../../../libraries/utils.js'); - Script.include(utilitiesScript); - Switch = function() { - _this = this; - this.switchSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/lamp_switch_2.wav"); - }; - - Switch.prototype = { - prefix: 'hifi-home-living-room-fan', - clickReleaseOnEntity: function(entityID, mouseEvent) { - if (!mouseEvent.isLeftButton) { - return; - } - this.toggle(); - }, - - startNearTrigger: function() { - this.toggle(); - }, - - fanRotationOn: function() { - Entities.editEntity(this.fan, { - damping: 0, - angularVelocity: { - x: 0, - y: 0.25, - z: 0 - } - }) - }, - - fanRotationOff: function() { - Entities.editEntity(this.fan, { - damping: 1.0, - // angularVelocity:{ - // x:0, - // y:0, - // z:0 - // } - }) - }, - - fanSoundOn: function() { - - }, - - fanSoundOff: function() { - - }, - - ventSoundOn: function() { - - }, - - ventSoundOff: function() { - - }, - - findFan: function() { - var found = []; - var results = Entities.findEntities(this.position, SEARCH_RADIUS); - results.forEach(function(result) { - var properties = Entities.getEntityProperties(result); - if (properties.name === _this.prefix) { - found.push(result); - } - }); - return found; - }, - - toggle: function() { - this.fan = this.findFan(); - this.switch = getEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - - if (this.switch.state === 'off') { - this.fanRotationOn(); - this.fanSoundOn(); - this.ventSoundOn(); - setEntityCustomData('home-switch', this.entityID, { - state: 'on' - }); - - } else { - this.fanRotationOff(); - this.fanSoundOff(); - this.ventSoundOff(); - - setEntityCustomData('home-switch', this.entityID, { - state: 'off' - }); - } - - this.flipSwitch(); - Audio.playSound(this.switchSound, { - volume: 0.5, - position: this.position - }); - - }, - - flipSwitch: function() { - var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation; - var axis = { - x: 0, - y: 1, - z: 0 - }; - var dQ = Quat.angleAxis(180, axis); - rotation = Quat.multiply(rotation, dQ); - - Entities.editEntity(this.entityID, { - rotation: rotation - }); - }, - - preload: function(entityID) { - this.entityID = entityID; - setEntityCustomData('grabbableKey', this.entityID, { - wantsTrigger: true - }); - - var properties = Entities.getEntityProperties(this.entityID); - - //The light switch is static, so just cache its position once - this.position = Entities.getEntityProperties(this.entityID, "position").position; - } - }; - - // entity scripts always need to return a newly constructed object of our type - return new Switch(); -}); \ No newline at end of file From acba6817f2d82326afdc5c4c58fc9b5a3209325f Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 18 Mar 2016 14:52:34 -0700 Subject: [PATCH 2/2] hmm --- .../DomainContent/Home/fishTank/tank.js | 23 ++++++++++++++----- .../DomainContent/Home/fishTank/wrapper.js | 17 +++++++------- .../Home/pingPongGun/pingPongGun.js | 1 + .../DomainContent/Home/reset.js | 20 ++++++++-------- 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/unpublishedScripts/DomainContent/Home/fishTank/tank.js b/unpublishedScripts/DomainContent/Home/fishTank/tank.js index 577a1f192e..e21f992ffa 100644 --- a/unpublishedScripts/DomainContent/Home/fishTank/tank.js +++ b/unpublishedScripts/DomainContent/Home/fishTank/tank.js @@ -46,13 +46,16 @@ var UPPER_CORNER_FORWARD_OFFSET = -TANK_DIMENSIONS.x; var UPPER_CORNER_LATERAL_OFFSET = TANK_DIMENSIONS.z / 8; - + var upperCorner, lowerCorner; function FishTank() { _this = this; } function startUpdate() { + upperCorner = getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET); + lowerCorner = getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET); + //when the baton is claimed; // print('trying to claim the object' + _entityID) iOwn = true; @@ -137,6 +140,7 @@ preload: function(entityID) { // print("preload"); + this.entityID = entityID; _entityID = entityID; this.initialize(entityID); @@ -409,7 +413,6 @@ } - if (_this.userData['hifi-home-fishtank'].fishLoaded === false) { //no fish in the user data _this.tankLocked = true; @@ -418,9 +421,7 @@ var data = { fishLoaded: true, bubbleSystem: _this.userData['hifi-home-fishtank'].bubbleSystem, - bubbleSound: _this.userData['hifi-home-fishtank'].bubbleSound, innerContainer: _this.userData['hifi-home-fishtank'].innerContainer, - } setEntityCustomData(FISHTANK_USERDATA_KEY, _this.entityID, data); _this.userData['hifi-home-fishtank'].fishLoaded = true; @@ -497,6 +498,7 @@ z: 0 }; + var othersCounted = 0; for (var j = 0; j < fish.length; j++) { if (i != j) { @@ -604,8 +606,17 @@ var center = _this.currentProperties.position; - upperCorner = getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET); - lowerCorner = getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET); + var lowerCorner = { + x: center.x - (_this.currentProperties.dimensions.z / 2), + y: center.y, + z: center.z - (_this.currentProperties.dimensions.z / 2) + }; + var upperCorner = { + x: center.x + (_this.currentProperties.dimensions.z / 2), + y: center.y + _this.currentProperties.dimensions.y, + z: center.z + (_this.currentProperties.dimensions.z / 2) + }; + var fish = []; diff --git a/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js b/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js index a25367443f..9f0b42d95a 100644 --- a/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js +++ b/unpublishedScripts/DomainContent/Home/fishTank/wrapper.js @@ -124,12 +124,7 @@ FishTank = function(spawnPosition, spawnRotation) { color: DEBUG_COLOR, collisionless: true, script: TANK_SCRIPT, - visible: true, - userData: JSON.stringify({ - 'hifiHomeKey': { - 'reset': true - } - }), + visible: true } if (spawnRotation !== undefined) { @@ -427,18 +422,24 @@ FishTank = function(spawnPosition, spawnRotation) { createTankBase(); createTreasureChest(); - var customKey = 'hifi-home-fishtank'; + var customKey = 'hifi-home-fishtank'; var data = { fishLoaded: false, bubbleSystem: bubbleSystem, - // bubbleSound: bubbleSound, innerContainer: innerContainer, } + var resetKey = 'hifiHomeKey'; + var resetData = { + 'reset': true + }; + + Script.setTimeout(function() { setEntityCustomData(customKey, fishTank, data); + setEntityCustomData(resetKey, fishTank, resetData); }, 2000) diff --git a/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js index c769f53768..a1c409785d 100644 --- a/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js +++ b/unpublishedScripts/DomainContent/Home/pingPongGun/pingPongGun.js @@ -114,6 +114,7 @@ dynamic: true, rotation: gunProperties.rotation, position: this.getGunTipPosition(gunProperties), + gravity:PING_PONG_GUN_GRAVITY, velocity: forwardVec, lifetime: 10, userData: JSON.stringify({ diff --git a/unpublishedScripts/DomainContent/Home/reset.js b/unpublishedScripts/DomainContent/Home/reset.js index 5be2564e5d..8f1f831712 100644 --- a/unpublishedScripts/DomainContent/Home/reset.js +++ b/unpublishedScripts/DomainContent/Home/reset.js @@ -34,7 +34,7 @@ Script.include(kineticPath); Script.include(utilsPath); - // Script.include(fishTankPath); + Script.include(fishTankPath); Script.include(tiltMazePath); Script.include(whiteboardPath); Script.include(plantPath); @@ -113,15 +113,15 @@ createDynamicEntities: function() { - // var fishTank = new FishTank({ - // x: 1098.9254, - // y: 460.5814, - // z: -79.1103 - // }, { - // x: 0, - // y: 152, - // z: 0 - // }); + var fishTank = new FishTank({ + x: 1098.9254, + y: 460.5814, + z: -79.1103 + }, { + x: 0, + y: 152, + z: 0 + }); var tiltMaze = new TiltMaze({ x: 1105.5768,