simple baton

This commit is contained in:
ericrius1 2016-03-22 17:06:49 -07:00
parent ad5a111b85
commit 608821b50b
2 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,64 @@
(function() {
Script.include("../../libraries/virtualBaton.js");
var _this = this;
this.startUpdate = function() {
Entities.editEntity(_this.batonDebugModel, {visible: true});
}
this.maybeClaim = function() {
if (_this.isBatonOwner === true) {
_this.soundIntervalConnected = false;
}
Entities.editEntity(_this.batonDebugModel, {visible: false});
baton.claim(_this.startUpdate, _this.maybeClaim);
}
this.preload = function(entityID) {
_this.entityID = entityID
_this.batonDebugModel = Entities.addEntity({
type: "Box",
color: {
red: 200,
green: 10,
blue: 200
},
position: Vec3.sum(MyAvatar.position, {
x: 0,
y: 1,
z: 0
}),
dimensions: {
x: 0.5,
y: 1,
z: 0
},
parentID: MyAvatar.sessionUUID,
visible: false
});
_this.colorsToCycle = [{
red: 200,
green: 0,
blue: 0
}, {
red: 0,
green: 200,
blue: 0
}, {
red: 0,
green: 0,
blue: 200
}];
baton = virtualBaton({
batonName: "batonSimpleEntityScript:" + _this.entityID
});
_this.isBatonOwner = false;
_this.maybeClaim();
print("EBL Preload!!");
}
});

View file

@ -0,0 +1,31 @@
var orientation = Camera.getOrientation();
orientation = Quat.safeEulerAngles(orientation);
orientation.x = 0;
orientation = Quat.fromVec3Degrees(orientation);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
// Math.random ensures no caching of script
var SCRIPT_URL = Script.resolvePath("batonSimpleEntityScript.js?v1" + Math.random());
var myEntity = Entities.addEntity({
type: "Box",
color: {
red: 200,
green: 10,
blue: 10
},
position: center,
dimensions: {
x: 0.1,
y: 0.1,
z: 0.1
},
script: SCRIPT_URL
});
function cleanup() {
Entities.deleteEntity(myEntity);
}
Script.scriptEnding.connect(cleanup);