Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Nyx UI. #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions applications/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ var metadata = { "applications":
"jsfile": "blocks/Blocks.js",
"icon": "blocks/blocks-inactive.svg",
"caption": "BLOCKS"
},
{
"isActive": true,
"directory": "nyx-ui",
"name": "Nyx UI",
"description": "A UI overlay system to add functionality.",
"jsfile": "nyx-ui/nyx.js",
"icon": "nyx-ui/icon.png",
"caption": "NYX"
}
]
};
5 changes: 5 additions & 0 deletions applications/nyx-ui/css/chunk-vendors.60253407.css

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions applications/nyx-ui/examples/basicButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function () {
var NyxAlpha1 = Script.require('../nyx-helpers.js?ds3dsa545');

var _entityID;

function onEntityMenuActionTriggered(triggeredEntityID, command, data) {
if (data.name === 'Create Cube' && triggeredEntityID === _entityID) {
Entities.addEntity({
type: "Box",
position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -5 })),
rotation: MyAvatar.orientation,
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
lifetime: 300 // Delete after 5 minutes.
});
}
}

this.preload = function (entityID) {
_entityID = entityID;

NyxAlpha1.registerWithEntityMenu(entityID, [
{
type: 'button',
name: 'Create Cube'
}
]);

NyxAlpha1.entityMenuActionTriggered.connect(_entityID, onEntityMenuActionTriggered);
};

this.unload = function () {
NyxAlpha1.entityMenuActionTriggered.disconnect(_entityID, onEntityMenuActionTriggered);
};

});
34 changes: 34 additions & 0 deletions applications/nyx-ui/examples/dynamicTextEntity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(function () {
var NyxAlpha1 = Script.require('../nyx-helpers.js?12dsadsddsadsdfafdasdassaddseras3');

var _entityID;

function onEntityMenuActionTriggered(triggeredEntityID, command, data) {
if (data.name === 'TESTFIELD' && triggeredEntityID === _entityID) {
Entities.editEntity(_entityID, {
text: data.value
});
}
}

this.preload = function (entityID) {
_entityID = entityID;

var initialProps = Entities.getEntityProperties(_entityID, ['text']);

NyxAlpha1.registerWithEntityMenu(_entityID, [
{
type: 'textField',
name: 'TESTFIELD',
hint: 'just smile!',
initialValue: initialProps.text
}
]);
NyxAlpha1.entityMenuActionTriggered.connect(_entityID, onEntityMenuActionTriggered);
};

this.unload = function () {
NyxAlpha1.entityMenuActionTriggered.connect(_entityID, onEntityMenuActionTriggered);
};

});
113 changes: 113 additions & 0 deletions applications/nyx-ui/examples/realGunSpawner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
(function () {
var NyxAlpha1 = Script.require('../nyx-helpers.js');

var _entityID;
var gunID;

function generateQuatFromDegreesViaRadians(rotxdeg,rotydeg,rotzdeg) {
var rotxrad = (rotxdeg/180)*Math.PI;
var rotyrad = (rotydeg/180)*Math.PI;
var rotzrad = (rotzdeg/180)*Math.PI;
var newRotation = Quat.fromPitchYawRollRadians(rotxrad,rotyrad,rotzrad);
return newRotation;
}

function equipGun() {
var RIGHT_HAND_INDEX = MyAvatar.getJointIndex("RightHand");
var localRot = generateQuatFromDegreesViaRadians(71.87 , 92 , -16.92);
var gunURL = "https://bas-skyspace.ams3.digitaloceanspaces.com/MurderGame/gun.fbx?" + Date.now();

gunID = Entities.addEntity( {
type: "Model",
name: "MurderGameGun",
modelURL: gunURL,
parentID: MyAvatar.sessionUUID,
parentJointIndex: RIGHT_HAND_INDEX,
localPosition: { x: 0.0179, y: 0.1467, z: 0.0305 },
localRotation: localRot,
localDimensions: { x: 0.0323, y: 0.1487, z: 0.2328 },
color: { red: 200, green: 0, blue: 20 },
collisionless: true,
dynamic: false,
lifetime: -1,
userData: "{ \"grabbableKey\": { \"grabbable\": false, \"triggerable\": false}}"
},"avatar");

NyxAlpha1.registerWithEntityMenu(gunID, [
{
type: 'button',
name: 'Unequip'
}
]);
NyxAlpha1.entityMenuActionTriggered.connect(gunID, onEntityMenuActionTriggered);
}

function onEntityMenuActionTriggered(triggeredEntityID, command, data) {
if (data.name === 'Equip' && triggeredEntityID === _entityID) {
equipGun();
}

if (data.name === 'Unequip' && triggeredEntityID === gunID) {
Entities.deleteEntity(gunID);
NyxAlpha1.entityMenuActionTriggered.disconnect(gunID, onEntityMenuActionTriggered);
}

if (data.name === 'Color Picker' && triggeredEntityID === _entityID) {
Entities.editEntity(_entityID, {
color: {
red: data.colors.rgba.r,
green: data.colors.rgba.g,
blue: data.colors.rgba.b
},
alpha: data.colors.rgba.a
});
}

if (data.name === 'Alpha' && triggeredEntityID === _entityID) {
Entities.editEntity(_entityID, {
alpha: data.value
});
}
}

this.preload = function (entityID) {
_entityID = entityID;

var initialProps = Entities.getEntityProperties(_entityID, ['color', 'alpha']);

NyxAlpha1.registerWithEntityMenu(entityID, [
{
type: 'button',
name: 'Equip'
},
{
type: 'colorPicker',
name: 'Color Picker',
initialColor: {
r: initialProps.color.r,
g: initialProps.color.g,
b: initialProps.color.b,
a: initialProps.alpha
},
loadValue: Entities.getEntityProperties(entityID, ['color']).color
},
{
type: 'slider',
name: 'Alpha',
step: 0.1,
color: 'yellow',
initialValue: initialProps.alpha,
minValue: 0,
maxValue: 1,
loadValue: Entities.getEntityProperties(entityID, ['color']).color
}
]);

NyxAlpha1.entityMenuActionTriggered.connect(_entityID, onEntityMenuActionTriggered);
};

this.unload = function () {
NyxAlpha1.entityMenuActionTriggered.disconnect(_entityID, onEntityMenuActionTriggered);
};

});
Empty file.
Binary file added applications/nyx-ui/favicon.ico
Binary file not shown.
Binary file added applications/nyx-ui/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions applications/nyx-ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>nyx</title><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css"><link href="css/chunk-vendors.60253407.css" rel="preload" as="style"><link href="js/app.fb624560.js" rel="preload" as="script"><link href="js/chunk-vendors.0bf81b95.js" rel="preload" as="script"><link href="css/chunk-vendors.60253407.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but nyx doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.0bf81b95.js"></script><script src="js/app.fb624560.js"></script></body></html>
Loading