From bc29bcf0d2ce6fc706d952b58f5c41c13669f0fc Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Thu, 19 May 2016 11:18:30 -0700 Subject: [PATCH] light switch swap --- .../Home/switches/livingRoomDiscLights.js | 26 +++++--------- .../Home/switches/livingRoomFan.js | 35 +++++++------------ 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js b/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js index eef64fd3f8..6fb2ea538a 100644 --- a/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js +++ b/unpublishedScripts/DomainContent/Home/switches/livingRoomDiscLights.js @@ -10,7 +10,8 @@ // (function() { - + var ON_MODEL_URL = "atp:/switches/lightswitch_on.fbx"; + var OFF_MODEL_URL = "atp:/switches/lightswitch_off.fbx"; var SEARCH_RADIUS = 100; var _this; @@ -142,6 +143,9 @@ setEntityCustomData('home-switch', _this.entityID, { state: 'on' }); + Entities.editEntity(this.entityID, { + modelURL: ON_MODEL_URL + }); } else { glowLights.forEach(function(glowLight) { @@ -156,9 +160,12 @@ setEntityCustomData('home-switch', this.entityID, { state: 'off' }); + + Entities.editEntity(this.entityID, { + modelURL: OFF_MODEL_URL + }); } - this.flipSwitch(); Audio.playSound(this.switchSound, { volume: 0.5, position: this.position @@ -166,21 +173,6 @@ }, - 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, { diff --git a/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js b/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js index 6005503cf3..c1f0c0f112 100644 --- a/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js +++ b/unpublishedScripts/DomainContent/Home/switches/livingRoomFan.js @@ -11,7 +11,7 @@ (function() { - var FAN_SOUND_ENTITY_NAME ="home_sfx_ceiling_fan" + var FAN_SOUND_ENTITY_NAME = "home_sfx_ceiling_fan" var SEARCH_RADIUS = 100; var _this; var utilitiesScript = Script.resolvePath('../utils.js'); @@ -74,16 +74,16 @@ if (!_this.fanSoundEntity) { return; } - print('HOME FAN OFF 2') + print('HOME FAN OFF 2') var soundUserData = getEntityCustomData("soundKey", _this.fanSoundEntity); if (!soundUserData) { print("NO SOUND USER DATA! RETURNING."); return; } - print('HOME FAN OFF 3') + print('HOME FAN OFF 3') soundUserData.volume = 0.0; setEntityCustomData("soundKey", _this.fanSoundEntity, soundUserData); - print('HOME FAN OFF 4') + print('HOME FAN OFF 4') }, findFan: function() { @@ -105,7 +105,7 @@ var fan = null; print('HOME LOOKING FOR A FAN') - print('HOME TOTAL ENTITIES:: ' +entities.length) + print('HOME TOTAL ENTITIES:: ' + entities.length) entities.forEach(function(entity) { var props = Entities.getEntityProperties(entity); if (props.name === FAN_SOUND_ENTITY_NAME) { @@ -132,7 +132,9 @@ setEntityCustomData('home-switch', this.entityID, { state: 'on' }); - + Entities.editEntity(this.entityID, { + modelURL: ON_MODEL_URL + }) } else { this.fanRotationOff(); this.fanSoundOff(); @@ -140,9 +142,13 @@ setEntityCustomData('home-switch', this.entityID, { state: 'off' }); + + Entities.editEntity(this.entityID, { + modelURL: OFF_MODEL_URL + }) } - this.flipSwitch(); + Audio.playSound(this.switchSound, { volume: 0.5, position: this.position @@ -150,21 +156,6 @@ }, - 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, {