47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
// batServer.js
|
|
|
|
(function(){
|
|
var _entityID = null;
|
|
this.preload = function(entityID){
|
|
_entityID = entityID;
|
|
}
|
|
this.remotelyCallable = ["changeParent", "swoopTheBats", "apparateBats"];
|
|
|
|
this.changeParent = function(id, parent){
|
|
var id = parent[0];
|
|
var properties = {
|
|
parentID: id
|
|
};
|
|
Entities.editEntity(_entityID, properties);
|
|
console.log("CHANGE PARENT", parent);
|
|
}
|
|
|
|
this.swoopTheBats = function(id, angularVelocity){
|
|
try{
|
|
var spin = JSON.parse(angularVelocity[0]);
|
|
}catch(e){
|
|
console.error(e);
|
|
}
|
|
var properties = {
|
|
localAngularVelocity: spin
|
|
};
|
|
Entities.editEntity(_entityID, properties);
|
|
console.log("SPIN CHANGE", angularVelocity);
|
|
}
|
|
|
|
this.apparateBats = function(id, isVisible){
|
|
//var isVisible = Entities.getEntityProperties(_entityID, ["visible"]);
|
|
var visibility = isVisible;
|
|
console.log("visible: ", JSON.stringify(visibility));
|
|
// if (isVisible.visible != true) visibility = true;
|
|
// else visibility = false;
|
|
var properties = {
|
|
visible: visibility
|
|
}
|
|
Entities.editEntity(_entityID, properties);
|
|
}
|
|
|
|
this.unload = function(entityID){
|
|
console.log("bat unloading");
|
|
}
|
|
})
|