mirror of
https://github.com/overte-org/overte.git
synced 2025-07-14 02:16:42 +02:00
light switch swap
This commit is contained in:
parent
d50681243c
commit
bc29bcf0d2
2 changed files with 22 additions and 39 deletions
|
@ -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, {
|
||||
|
|
|
@ -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, {
|
||||
|
|
Loading…
Reference in a new issue