mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 09:07:19 +02:00
chair
This commit is contained in:
parent
6f06c0ca7f
commit
cf8d4aa993
3 changed files with 19 additions and 163 deletions
|
@ -4,7 +4,7 @@ var BOOKS_URL = "atp:/kineticObjects/books.json"
|
|||
var UPPER_BOOKSHELF_URL = "atp:/kineticObjects/upperBookShelf.json"
|
||||
var LOWER_BOOKSHELF_URL = "atp:/kineticObjects/lowerBookShelf.json"
|
||||
|
||||
var CHAIR_URL = 'atp:/JSON/chair.json';
|
||||
var CHAIR_URL = 'atp:/kineticObjects/chair.json';
|
||||
|
||||
var FRUIT_BOWL_URL = "atp:/kineticObjects/fruit.json"
|
||||
|
||||
|
|
|
@ -26,15 +26,24 @@
|
|||
},
|
||||
|
||||
modelEmitOn: function(glowDisc) {
|
||||
Entities.editEntity(glowDisc, {
|
||||
textures: 'Metal-brushed-light.jpg:"https://s3-us-west-1.amazonaws.com/hifi-content/alan/dev/Lights-Dressing-Room-3.fbx/Lights-Dressing-Room-3.fbm/Metal-brushed-light.jpg",\nTex.CeilingLight-Emit:"http://hifi-content.s3.amazonaws.com/alan/dev/Lights-Dressing-Room-3.fbx/Lights-Dressing-Room-3.fbm/CielingLight-On-Diffuse.jpg",\nTexCeilingLight.Diffuse:"https://s3-us-west-1.amazonaws.com/hifi-content/alan/dev/Lights-Dressing-Room-3.fbx/Lights-Dressing-Room-3.fbm/CielingLight-Base.jpg"'
|
||||
});
|
||||
|
||||
var data = {
|
||||
"Metal-brushed-light.jpg": "atp:/models/Lights-Living-Room-2.fbx/Lights-Living-Room-2.fbm/Metal-brushed-light.jpg",
|
||||
"Tex.CeilingLight.Emit": "atp:/models/Lights-Living-Room-2.fbx/Lights-Living-Room-2.fbm/CielingLight-On-Diffuse.jpg",
|
||||
"TexCeilingLight.Diffuse": "atp:/models/Lights-Living-Room-2.fbx/Lights-Living-Room-2.fbm/CielingLight-Base.jpg"
|
||||
};
|
||||
Entities.editEntity(glowDisc, JSON.stringify(data));
|
||||
},
|
||||
|
||||
modelEmitOff: function(glowDisc) {
|
||||
Entities.editEntity(glowDisc, {
|
||||
textures: 'Metal-brushed-light.jpg:"https://s3-us-west-1.amazonaws.com/hifi-content/alan/dev/Lights-Dressing-Room-3.fbx/Lights-Dressing-Room-3.fbm/Metal-brushed-light.jpg",\nTex.CeilingLight-Emit:"",\nTexCeilingLight.Diffuse:"https://s3-us-west-1.amazonaws.com/hifi-content/alan/dev/Lights-Dressing-Room-3.fbx/Lights-Dressing-Room-3.fbm/CielingLight-Base.jpg"'
|
||||
});
|
||||
|
||||
var data = {
|
||||
"Metal-brushed-light.jpg": "atp:/models/Lights-Living-Room-2.fbx/Lights-Living-Room-2.fbm/Metal-brushed-light.jpg",
|
||||
"Tex.CeilingLight.Emit": "",
|
||||
"TexCeilingLight.Diffuse": "atp:/models/Lights-Living-Room-2.fbx/Lights-Living-Room-2.fbm/CielingLight-Base.jpg"
|
||||
}
|
||||
|
||||
Entities.editEntity(glowDisc, JSON.stringify(data));
|
||||
},
|
||||
|
||||
masterLightOn: function(masterLight) {
|
||||
|
@ -100,7 +109,9 @@
|
|||
|
||||
toggleLights: function() {
|
||||
|
||||
_this._switch = getEntityCustomData('home-switch', _this.entityID, {state: 'off'});
|
||||
_this._switch = getEntityCustomData('home-switch', _this.entityID, {
|
||||
state: 'off'
|
||||
});
|
||||
|
||||
var glowLights = this.findGlowLights();
|
||||
var masterLights = this.findMasterLights();
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
(function() {
|
||||
var SEARCH_RADIUS = 10;
|
||||
var _this;
|
||||
|
||||
var utilitiesScript = Script.resolvePath('../utils.js');
|
||||
|
||||
Script.include(utilitiesScript);
|
||||
|
||||
Switch = function() {
|
||||
_this = this;
|
||||
this.switchSound = SoundCache.getSound("atp:/switches/lamp_switch_2.wav");
|
||||
};
|
||||
|
||||
Switch.prototype = {
|
||||
prefix: 'hifi-home-lab-desk-lamp',
|
||||
clickReleaseOnEntity: function(entityID, mouseEvent) {
|
||||
if (!mouseEvent.isLeftButton) {
|
||||
return;
|
||||
}
|
||||
this.toggleLights();
|
||||
},
|
||||
|
||||
startNearTrigger: function() {
|
||||
this.toggleLights();
|
||||
},
|
||||
|
||||
modelEmitOn: function(discModel) {
|
||||
Entities.editEntity(glowDisc, {
|
||||
textures: {
|
||||
"Tex.Lamp-Bulldog": "http://hifi-content.s3.amazonaws.com/alan/dev/Lamp-Bulldog-Base.fbx/Lamp-Bulldog-Base.fbm/dog_statue.jpg",
|
||||
"Texture.001": "http://hifi-content.s3.amazonaws.com/alan/dev/Lamp-Bulldog-Base.fbx/Lamp-Bulldog-Base.fbm/Emissive-Map.png"
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
modelEmitOff: function(discModel) {
|
||||
Entities.editEntity(glowDisc, {
|
||||
textures: {
|
||||
"Tex.Lamp-Bulldog": "http://hifi-content.s3.amazonaws.com/alan/dev/Lamp-Bulldog-Base.fbx/Lamp-Bulldog-Base.fbm/dog_statue.jpg",
|
||||
"Texture.001": ""
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
masterLightOn: function(masterLight) {
|
||||
Entities.editEntity(masterLight, {
|
||||
visible: true
|
||||
});
|
||||
},
|
||||
|
||||
masterLightOff: function() {
|
||||
Entities.editEntity(masterLight, {
|
||||
visible: false
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
findMasterLights: function() {
|
||||
var found = [];
|
||||
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
||||
results.forEach(function(result) {
|
||||
var properties = Entities.getEntityProperties(result);
|
||||
if (properties.name === _this.prefix + "spotlight") {
|
||||
found.push(result);
|
||||
}
|
||||
});
|
||||
return found;
|
||||
},
|
||||
|
||||
findEmitModels: function() {
|
||||
var found = [];
|
||||
var results = Entities.findEntities(this.position, SEARCH_RADIUS);
|
||||
results.forEach(function(result) {
|
||||
var properties = Entities.getEntityProperties(result);
|
||||
if (properties.name === _this.prefix + "model") {
|
||||
found.push(result);
|
||||
}
|
||||
});
|
||||
return found;
|
||||
},
|
||||
|
||||
toggleLights: function() {
|
||||
|
||||
this._switch = getEntityCustomData('home-switch', this.entityID, {
|
||||
state: 'off'
|
||||
});
|
||||
|
||||
var masterLights = this.findMasterLights();
|
||||
var emitModels = this.findEmitModels();
|
||||
|
||||
if (this._switch.state === 'off') {
|
||||
|
||||
masterLights.forEach(function(masterLight) {
|
||||
_this.masterLightOn(masterLight);
|
||||
});
|
||||
emitModels.forEach(function(emitModel) {
|
||||
_this.modelEmitOn(emitModel);
|
||||
});
|
||||
setEntityCustomData('home-switch', this.entityID, {
|
||||
state: 'on'
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
masterLights.forEach(function(masterLight) {
|
||||
_this.masterLightOff(masterLight);
|
||||
});
|
||||
emitModels.forEach(function(emitModel) {
|
||||
_this.modelEmitOff(emitModel);
|
||||
});
|
||||
setEntityCustomData('home-switch', this.entityID, {
|
||||
state: 'off'
|
||||
});
|
||||
}
|
||||
|
||||
this.flipSwitch();
|
||||
Audio.playSound(this.switchSound, {
|
||||
volume: 0.5,
|
||||
position: this.position
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
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, {
|
||||
wantsTrigger: true
|
||||
});
|
||||
|
||||
var properties = Entities.getEntityProperties(this.entityID);
|
||||
|
||||
//The light switch is static, so just cache its position once
|
||||
this.position = Entities.getEntityProperties(this.entityID, "position").position;
|
||||
}
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new Switch();
|
||||
});
|
Loading…
Reference in a new issue