94 lines
3.8 KiB
JavaScript
94 lines
3.8 KiB
JavaScript
var launchPadEntity = "";
|
|
var launchpadButtons = [];
|
|
var launchpadText = "";
|
|
|
|
var launchpadProperties = {
|
|
"name": "Launchpad",
|
|
"position": {x: 0, y: 0, z: -3 },
|
|
"dimensions": { x: 0.5, y: 0.5, z: 0.05 },
|
|
"type": "Box",
|
|
"color": { "red": 38, "green": 38, "blue": 38 },
|
|
};
|
|
|
|
var launchpadButtonProperties = {
|
|
"name": "Launchpad_button",
|
|
"position": {x: 0, y: 0.17, z: -3.03},
|
|
"dimensions": { x: 0.1, y: 0.1, z: 0.01 },
|
|
"type": "Box",
|
|
"script": Script.resolvePath("launchPadButton.js"),
|
|
};
|
|
|
|
var launchpadBackText = {
|
|
"name": "Launchpad_text",
|
|
"type": "Text",
|
|
"position": { x: -0.015599999, y: -0.07519999, z: -2.97250 },
|
|
"dimensions": { x: 0.284164686, y: 0.08196557, z: 0.00999999 },
|
|
"rotation": { x: -0.0000, y: 1.4926251, z: -0.00001 },
|
|
"text": "Control Pad",
|
|
"lineHeight": 0.054999999701976776,
|
|
"backgroundColor": { "red": 38, "green": 38, "blue": 38 },
|
|
"parentID": {},
|
|
};
|
|
|
|
function rezLaunchpad() {
|
|
launchPadEntity = Entities.addEntity(launchpadProperties);
|
|
launchpadButtonProperties.parentID = launchPadEntity;
|
|
|
|
Script.setTimeout(function() { // Implemented to stop buttons randomly flying around the place.
|
|
var getSpawnedPosition = { x: -0.17, y: 0.17, z: -3 };
|
|
var OFFSET = 0;
|
|
for (var i = 0; i < 4; i++) {
|
|
OFFSET = OFFSET+1;
|
|
launchpadButtonProperties.name = "Launchpad_button_1_" + i;
|
|
launchpadButtonProperties.position.x = getSpawnedPosition.x + (0.1 * i) + OFFSET/100;
|
|
// launchpadButtonProperties.position.z = getSpawnedPosition.z + (0.1 * i);
|
|
launchpadButtons.push(Entities.addEntity(launchpadButtonProperties));
|
|
}
|
|
OFFSET = 0;
|
|
for (var i = 0; i < 4; i++) {
|
|
OFFSET = OFFSET+1;
|
|
launchpadButtonProperties.name = "Launchpad_button_2_" + i;
|
|
launchpadButtonProperties.position.x = getSpawnedPosition.x + (0.1 * i) + OFFSET/100;
|
|
launchpadButtonProperties.position.y = getSpawnedPosition.y - 0.11;
|
|
launchpadButtons.push(Entities.addEntity(launchpadButtonProperties));
|
|
}
|
|
OFFSET = 0;
|
|
for (var i = 0; i < 4; i++) {
|
|
OFFSET = OFFSET+1;
|
|
launchpadButtonProperties.name = "Launchpad_button_3_" + i;
|
|
launchpadButtonProperties.position.x = getSpawnedPosition.x + (0.1 * i) + OFFSET/100;
|
|
launchpadButtonProperties.position.y = getSpawnedPosition.y - 0.22;
|
|
launchpadButtons.push(Entities.addEntity(launchpadButtonProperties));
|
|
}
|
|
OFFSET = 0;
|
|
for (var i = 0; i < 4; i++) {
|
|
OFFSET = OFFSET+1;
|
|
launchpadButtonProperties.name = "Launchpad_button_4_" + i;
|
|
launchpadButtonProperties.position.x = getSpawnedPosition.x + (0.1 * i) + OFFSET/100;
|
|
launchpadButtonProperties.position.y = getSpawnedPosition.y - 0.33;
|
|
launchpadButtons.push(Entities.addEntity(launchpadButtonProperties));
|
|
}
|
|
launchpadText = Entities.addEntity(launchpadBackText);
|
|
Entities.editEntity(launchpadText, {parentID: launchPadEntity});
|
|
|
|
Entities.editEntity(launchPadEntity, {position: Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(Camera.getOrientation()))) });
|
|
// Entities.editEntity(launchPadEntity, {rotation: Quat.getFront(Camera.getOrientation()) });
|
|
|
|
}, 500);
|
|
}
|
|
|
|
function cleanUpLaunchpad() {
|
|
for(var i = 0; i < launchpadButtons.length; i++) {
|
|
Entities.deleteEntity(launchpadButtons[i]);
|
|
}
|
|
if(launchPadEntity) {
|
|
Entities.deleteEntity(launchPadEntity);
|
|
}
|
|
if(launchpadText) {
|
|
Entities.deleteEntity(launchpadText);
|
|
}
|
|
}
|
|
|
|
rezLaunchpad();
|
|
|
|
Script.scriptEnding.connect(cleanUpLaunchpad);
|