toggle light switch

This commit is contained in:
ericrius1 2015-09-23 17:34:37 -07:00
parent 153a30de0d
commit 81c175eabf
3 changed files with 20 additions and 6 deletions

View file

@ -54,11 +54,10 @@
// flip model to give illusion of light switch being flicked // flip model to give illusion of light switch being flicked
var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation; var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation;
var axis = Quat.axis(rotation); var axis = {x: 0, y: 1, z: 0};
var angle = Quat.angle(rotation); var dQ = Quat.angleAxis(180, axis);
rotation = Quat.multiply(rotation, dQ);
angle += 180;
rotation = Quat.angleAxis(angle, axis);
Entities.editEntity(this.entityID, { Entities.editEntity(this.entityID, {
rotation: rotation rotation: rotation

View file

@ -52,6 +52,21 @@
this.createLights(); 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, { Audio.playSound(this.switchSound, {
volume: 0.5, volume: 0.5,
position: this.position position: this.position
@ -104,7 +119,7 @@
var sconceLight2 = Entities.addEntity({ var sconceLight2 = Entities.addEntity({
type: "Light", type: "Light",
position: { position: {
x: 540.1 , x: 540.1,
y: 496.24, y: 496.24,
z: 505.57 z: 505.57
}, },

View file

@ -191,7 +191,7 @@ function createFlashlight(position) {
} }
function createLightSwitches() { 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 scriptURL = Script.resolvePath("lightSwitchHall.js?v1");
var lightSwitchHall = Entities.addEntity({ var lightSwitchHall = Entities.addEntity({