mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 00:43:49 +02:00
living room lights
This commit is contained in:
parent
009326b085
commit
c1725dda58
1 changed files with 13 additions and 15 deletions
|
@ -7,7 +7,7 @@
|
||||||
var DIFFUSE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelity_diffusebaked.png";
|
var DIFFUSE_TEXTURE_URL = "http://hifi-content.s3.amazonaws.com/highfidelity_diffusebaked.png";
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
var utilitiesScript = Script.resolvePath('../../../../libraries/utils.js');
|
var utilitiesScript = Script.resolvePath('../utils.js');
|
||||||
Script.include(utilitiesScript);
|
Script.include(utilitiesScript);
|
||||||
Switch = function() {
|
Switch = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
Switch.prototype = {
|
Switch.prototype = {
|
||||||
prefix: 'hifi-home-living-room-disc-light',
|
prefix: 'hifi-home-living-room-disc-',
|
||||||
clickReleaseOnEntity: function(entityID, mouseEvent) {
|
clickReleaseOnEntity: function(entityID, mouseEvent) {
|
||||||
if (!mouseEvent.isLeftButton) {
|
if (!mouseEvent.isLeftButton) {
|
||||||
return;
|
return;
|
||||||
|
@ -27,13 +27,13 @@
|
||||||
this.toggleLights();
|
this.toggleLights();
|
||||||
},
|
},
|
||||||
|
|
||||||
modelEmitOn: function(discModel) {
|
modelEmitOn: function(glowDisc) {
|
||||||
Entities.editEntity(glowDisc, {
|
Entities.editEntity(glowDisc, {
|
||||||
textures: 'emissive:' + EMISSIVE_TEXTURE_URL ',\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"'
|
textures: 'emissive:' + EMISSIVE_TEXTURE_URL + ',\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"'
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
modelEmitOff: function(discModel) {
|
modelEmitOff: function(glowDisc) {
|
||||||
Entities.editEntity(glowDisc, {
|
Entities.editEntity(glowDisc, {
|
||||||
textures: 'emissive:"",\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"'
|
textures: 'emissive:"",\ndiffuse:"' + DIFFUSE_TEXTURE_URL + '"'
|
||||||
})
|
})
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
masterLightOff: function() {
|
masterLightOff: function(masterLight) {
|
||||||
Entities.editEntity(masterLight, {
|
Entities.editEntity(masterLight, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
||||||
results.forEach(function(result) {
|
results.forEach(function(result) {
|
||||||
var properties = Entities.getEntityProperties(result);
|
var properties = Entities.getEntityProperties(result);
|
||||||
if (properties.name === _this.prefix + "glow") {
|
if (properties.name === _this.prefix + "light-glow") {
|
||||||
found.push(result);
|
found.push(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
||||||
results.forEach(function(result) {
|
results.forEach(function(result) {
|
||||||
var properties = Entities.getEntityProperties(result);
|
var properties = Entities.getEntityProperties(result);
|
||||||
if (properties.name === _this.prefix + "master") {
|
if (properties.name === _this.prefix + "light-master") {
|
||||||
found.push(result);
|
found.push(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
||||||
results.forEach(function(result) {
|
results.forEach(function(result) {
|
||||||
var properties = Entities.getEntityProperties(result);
|
var properties = Entities.getEntityProperties(result);
|
||||||
if (properties.name === _this.prefix + "model") {
|
if (properties.name === _this.prefix + "light-model") {
|
||||||
found.push(result);
|
found.push(result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -101,15 +101,13 @@
|
||||||
|
|
||||||
toggleLights: function() {
|
toggleLights: function() {
|
||||||
|
|
||||||
this.switch = getEntityCustomData('home-switch', this.entityID, {
|
_this._switch = getEntityCustomData('home-switch', _this.entityID, {state: 'off'});
|
||||||
state: 'off'
|
|
||||||
});
|
|
||||||
|
|
||||||
var glowLights = this.findGlowLights();
|
var glowLights = this.findGlowLights();
|
||||||
var masterLights = this.findMasterLights();
|
var masterLights = this.findMasterLights();
|
||||||
var emitModels = this.findEmitModels();
|
var emitModels = this.findEmitModels();
|
||||||
|
|
||||||
if (this.switch.state === 'off') {
|
if (this._switch.state === 'off') {
|
||||||
glowLights.forEach(function(glowLight) {
|
glowLights.forEach(function(glowLight) {
|
||||||
_this.glowLightOn(glowLight);
|
_this.glowLightOn(glowLight);
|
||||||
});
|
});
|
||||||
|
@ -119,7 +117,7 @@
|
||||||
emitModels.forEach(function(emitModel) {
|
emitModels.forEach(function(emitModel) {
|
||||||
_this.modelEmitOn(emitModel);
|
_this.modelEmitOn(emitModel);
|
||||||
});
|
});
|
||||||
setEntityCustomData('home-switch', this.entityID, {
|
setEntityCustomData('home-switch', _this.entityID, {
|
||||||
state: 'on'
|
state: 'on'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue