content/hifi-content/alexia/Apps/Template/VRFontTest.js
2022-02-13 20:57:54 +01:00

69 lines
No EOL
2.3 KiB
JavaScript

"use strict";
//
// template.js
//
(function() {
var APP_NAME = "VR FONT";
// Link to your app's HTML file
var APP_URL_BOLD = "http://hifi-content.s3.amazonaws.com/alexia/Apps/Template/VRFontTestBold.html";
var APP_URL_NORMAL = "http://hifi-content.s3.amazonaws.com/alexia/Apps/Template/VRFontTest.html";
// Path to the icon art for your app
var APP_ICON = "https://hifi-content.s3.amazonaws.com/faye/gemstoneMagicMaker/gemstoneAppIcon.svg";
// Get a reference to the tablet
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
// The following lines create a button on the tablet's menu screen
var button = tablet.addButton({
icon: APP_ICON,
text: APP_NAME
});
// When user click the app button, we'll display our app on the tablet screen
function onClicked() {
tablet.gotoWebScreen(APP_URL_NORMAL);
}
button.clicked.connect(onClicked);
// Helper function that gives us a position right in front of the user
function getPositionToCreateEntity() {
var direction = Quat.getFront(MyAvatar.orientation);
var distance = 0.5;
var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance));
position.y += 0.5;
return position;
}
// Handle the events we're recieving from the web UI
function onWebEventReceived(event) {
print("template.js received a web event:" + event);
// Converts the event to a JavasScript Object
if (typeof event === "string") {
event = JSON.parse(event);
}
if (event.type === "click") {
// Define the entity properties of for each of the gemstone, then add it to the scene
if (event.data === "Bold") {
tablet.gotoWebScreen(APP_URL_BOLD);
} else if (event.data === "Normal") {
tablet.gotoWebScreen(APP_URL_NORMAL);
}
}
}
tablet.webEventReceived.connect(onWebEventReceived);
// Provide a way to "uninstall" the app
// Here, we write a function called "cleanup" which gets executed when
// this script stops running. It'll remove the app button from the tablet.
function cleanup() {
tablet.removeButton(button);
}
Script.scriptEnding.connect(cleanup);
}());