mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:29:32 +02:00
Flipped lights so up is lights on and vica versa
This commit is contained in:
parent
f334651a57
commit
1e1cfb6aae
2 changed files with 44 additions and 25 deletions
|
@ -52,16 +52,7 @@
|
||||||
this.createLights();
|
this.createLights();
|
||||||
}
|
}
|
||||||
|
|
||||||
// flip model to give illusion of light switch being flicked
|
this.flipLights();
|
||||||
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,
|
||||||
|
@ -86,7 +77,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
createLights: function() {
|
createLights: function() {
|
||||||
|
|
||||||
|
|
||||||
var sconceLight3 = Entities.addEntity({
|
var sconceLight3 = Entities.addEntity({
|
||||||
type: "Light",
|
type: "Light",
|
||||||
|
@ -176,6 +167,25 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
flipLights: function() {
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// preload() will be called when the entity has become visible (or known) to the interface
|
// preload() will be called when the entity has become visible (or known) to the interface
|
||||||
// it gives us a chance to set our local JavaScript object up. In this case it means:
|
// it gives us a chance to set our local JavaScript object up. In this case it means:
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
|
@ -191,6 +201,7 @@
|
||||||
//If light is off, then we create two new lights- at the position of the sconces
|
//If light is off, then we create two new lights- at the position of the sconces
|
||||||
if (lightState.on === false) {
|
if (lightState.on === false) {
|
||||||
this.createLights();
|
this.createLights();
|
||||||
|
this.flipLights();
|
||||||
}
|
}
|
||||||
//If lights are on, do nothing!
|
//If lights are on, do nothing!
|
||||||
},
|
},
|
||||||
|
|
|
@ -53,19 +53,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
this.flipLights();
|
||||||
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,
|
||||||
|
@ -148,9 +136,27 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
flipLights: function() {
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
// preload() will be called when the entity has become visible (or known) to the interface
|
// preload() will be called when the entity has become visible (or known) to the interface
|
||||||
// it gives us a chance to set our local JavaScript object up. In this case it means:
|
// it gives us a chance to set our local JavaScript object up. In this case it means:
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
|
||||||
//The light switch is static, so just cache its position once
|
//The light switch is static, so just cache its position once
|
||||||
|
@ -163,6 +169,8 @@
|
||||||
//If light is off, then we create two new lights- at the position of the sconces
|
//If light is off, then we create two new lights- at the position of the sconces
|
||||||
if (lightState.on === false) {
|
if (lightState.on === false) {
|
||||||
this.createLights();
|
this.createLights();
|
||||||
|
this.flipLights();
|
||||||
|
|
||||||
}
|
}
|
||||||
//If lights are on, do nothing!
|
//If lights are on, do nothing!
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue