mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
simple baton
This commit is contained in:
parent
ad5a111b85
commit
608821b50b
2 changed files with 95 additions and 0 deletions
|
@ -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!!");
|
||||
}
|
||||
|
||||
});
|
|
@ -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);
|
Loading…
Reference in a new issue