mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +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, {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var FAN_SOUND_ENTITY_NAME ="home_sfx_ceiling_fan"
|
var FAN_SOUND_ENTITY_NAME = "home_sfx_ceiling_fan"
|
||||||
var SEARCH_RADIUS = 100;
|
var SEARCH_RADIUS = 100;
|
||||||
var _this;
|
var _this;
|
||||||
var utilitiesScript = Script.resolvePath('../utils.js');
|
var utilitiesScript = Script.resolvePath('../utils.js');
|
||||||
|
@ -74,16 +74,16 @@
|
||||||
if (!_this.fanSoundEntity) {
|
if (!_this.fanSoundEntity) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('HOME FAN OFF 2')
|
print('HOME FAN OFF 2')
|
||||||
var soundUserData = getEntityCustomData("soundKey", _this.fanSoundEntity);
|
var soundUserData = getEntityCustomData("soundKey", _this.fanSoundEntity);
|
||||||
if (!soundUserData) {
|
if (!soundUserData) {
|
||||||
print("NO SOUND USER DATA! RETURNING.");
|
print("NO SOUND USER DATA! RETURNING.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('HOME FAN OFF 3')
|
print('HOME FAN OFF 3')
|
||||||
soundUserData.volume = 0.0;
|
soundUserData.volume = 0.0;
|
||||||
setEntityCustomData("soundKey", _this.fanSoundEntity, soundUserData);
|
setEntityCustomData("soundKey", _this.fanSoundEntity, soundUserData);
|
||||||
print('HOME FAN OFF 4')
|
print('HOME FAN OFF 4')
|
||||||
},
|
},
|
||||||
|
|
||||||
findFan: function() {
|
findFan: function() {
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
|
|
||||||
var fan = null;
|
var fan = null;
|
||||||
print('HOME LOOKING FOR A FAN')
|
print('HOME LOOKING FOR A FAN')
|
||||||
print('HOME TOTAL ENTITIES:: ' +entities.length)
|
print('HOME TOTAL ENTITIES:: ' + entities.length)
|
||||||
entities.forEach(function(entity) {
|
entities.forEach(function(entity) {
|
||||||
var props = Entities.getEntityProperties(entity);
|
var props = Entities.getEntityProperties(entity);
|
||||||
if (props.name === FAN_SOUND_ENTITY_NAME) {
|
if (props.name === FAN_SOUND_ENTITY_NAME) {
|
||||||
|
@ -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