mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 17:19:06 +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() {
|
(function() {
|
||||||
|
var ON_MODEL_URL = "atp:/switches/lightswitch_on.fbx";
|
||||||
|
var OFF_MODEL_URL = "atp:/switches/lightswitch_off.fbx";
|
||||||
var SEARCH_RADIUS = 100;
|
var SEARCH_RADIUS = 100;
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
|
@ -142,6 +143,9 @@
|
||||||
setEntityCustomData('home-switch', _this.entityID, {
|
setEntityCustomData('home-switch', _this.entityID, {
|
||||||
state: 'on'
|
state: 'on'
|
||||||
});
|
});
|
||||||
|
Entities.editEntity(this.entityID, {
|
||||||
|
modelURL: ON_MODEL_URL
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glowLights.forEach(function(glowLight) {
|
glowLights.forEach(function(glowLight) {
|
||||||
|
@ -156,9 +160,12 @@
|
||||||
setEntityCustomData('home-switch', this.entityID, {
|
setEntityCustomData('home-switch', this.entityID, {
|
||||||
state: 'off'
|
state: 'off'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Entities.editEntity(this.entityID, {
|
||||||
|
modelURL: OFF_MODEL_URL
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flipSwitch();
|
|
||||||
Audio.playSound(this.switchSound, {
|
Audio.playSound(this.switchSound, {
|
||||||
volume: 0.5,
|
volume: 0.5,
|
||||||
position: this.position
|
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) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
setEntityCustomData('grabbableKey', this.entityID, {
|
setEntityCustomData('grabbableKey', this.entityID, {
|
||||||
|
|
|
@ -132,7 +132,9 @@
|
||||||
setEntityCustomData('home-switch', this.entityID, {
|
setEntityCustomData('home-switch', this.entityID, {
|
||||||
state: 'on'
|
state: 'on'
|
||||||
});
|
});
|
||||||
|
Entities.editEntity(this.entityID, {
|
||||||
|
modelURL: ON_MODEL_URL
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
this.fanRotationOff();
|
this.fanRotationOff();
|
||||||
this.fanSoundOff();
|
this.fanSoundOff();
|
||||||
|
@ -140,9 +142,13 @@
|
||||||
setEntityCustomData('home-switch', this.entityID, {
|
setEntityCustomData('home-switch', this.entityID, {
|
||||||
state: 'off'
|
state: 'off'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Entities.editEntity(this.entityID, {
|
||||||
|
modelURL: OFF_MODEL_URL
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flipSwitch();
|
|
||||||
Audio.playSound(this.switchSound, {
|
Audio.playSound(this.switchSound, {
|
||||||
volume: 0.5,
|
volume: 0.5,
|
||||||
position: this.position
|
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) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
setEntityCustomData('grabbableKey', this.entityID, {
|
setEntityCustomData('grabbableKey', this.entityID, {
|
||||||
|
|
Loading…
Reference in a new issue