From 81c175eabf524f44011aa56ba1f4599ef23a113d Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Wed, 23 Sep 2015 17:34:37 -0700 Subject: [PATCH] toggle light switch --- examples/toys/lightSwitchGarage.js | 7 +++---- examples/toys/lightSwitchHall.js | 17 ++++++++++++++++- examples/toys/masterResetEntity.js | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/examples/toys/lightSwitchGarage.js b/examples/toys/lightSwitchGarage.js index 97cd0a6ac3..a68a09cf7d 100644 --- a/examples/toys/lightSwitchGarage.js +++ b/examples/toys/lightSwitchGarage.js @@ -54,11 +54,10 @@ // flip model to give illusion of light switch being flicked var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation; - var axis = Quat.axis(rotation); - var angle = Quat.angle(rotation); + var axis = {x: 0, y: 1, z: 0}; + var dQ = Quat.angleAxis(180, axis); + rotation = Quat.multiply(rotation, dQ); - angle += 180; - rotation = Quat.angleAxis(angle, axis); Entities.editEntity(this.entityID, { rotation: rotation diff --git a/examples/toys/lightSwitchHall.js b/examples/toys/lightSwitchHall.js index 356dee928c..6bc1eeab83 100644 --- a/examples/toys/lightSwitchHall.js +++ b/examples/toys/lightSwitchHall.js @@ -52,6 +52,21 @@ this.createLights(); } + // flip model to give illusion of light switch being flicked + 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 + }); + Audio.playSound(this.switchSound, { volume: 0.5, position: this.position @@ -104,7 +119,7 @@ var sconceLight2 = Entities.addEntity({ type: "Light", position: { - x: 540.1 , + x: 540.1, y: 496.24, z: 505.57 }, diff --git a/examples/toys/masterResetEntity.js b/examples/toys/masterResetEntity.js index c38e8c0a26..c94f1bde9b 100644 --- a/examples/toys/masterResetEntity.js +++ b/examples/toys/masterResetEntity.js @@ -191,7 +191,7 @@ function createFlashlight(position) { } function createLightSwitches() { - var modelURL = "http://hifi-public.s3.amazonaws.com/ryan/dimmer.fbx"; + var modelURL = "http://hifi-public.s3.amazonaws.com/ryan/lightswitch.fbx?v1"; var scriptURL = Script.resolvePath("lightSwitchHall.js?v1"); var lightSwitchHall = Entities.addEntity({