Add JSON file loading support.

This commit is contained in:
Kasen IO 2020-04-09 03:39:33 -04:00
parent 3ebdc59071
commit 4b7f92f1d1
2 changed files with 34 additions and 2 deletions

View file

@ -163,7 +163,7 @@ function sendNearbyUsers() {
function useItem(item) {
//TODO: Add animation support for avatars, add JSON loading...?
//TODO: Add animation support for avatars...?
// Convert the item.type before checking it...
item.type = item.type.toUpperCase();
@ -191,6 +191,21 @@ function useItem(item) {
location.handleLookupString(item.url, true); // https://apidocs.vircadia.dev/location.html#.handleLookupString
}
if (item.type == "JSON") {
// https://apidocs.vircadia.dev/Clipboard.html#.importEntities
var jsonToLoad = item.url;
if (jsonToLoad) {
if (Clipboard.importEntities(jsonToLoad)) {
Clipboard.pasteEntities(
Vec3.sum(
MyAvatar.position,
Vec3.multiplyQbyV(MyAvatar.orientation, { x: 0, y: 0, z: -3 })
)
);
}
}
}
if (item.type == "UNKNOWN") {
// We don't know how to handle this yet.
Window.alert("Unknown item type, unable to use.");

View file

@ -25,7 +25,7 @@ getIcon<!--
<v-spacer></v-spacer>
<v-btn color="primary" fab @click="sortInventory('top')">
<v-btn medium color="primary" fab @click="sortInventory('top')">
<v-icon>
mdi-ab-testing
</v-icon>
@ -868,6 +868,12 @@ export default {
"type": "script",
"name": "TEST",
"url": "https://gooadfdagle.com/vr.js",
"uuid": "542rfwat4t5fsddf4354353",
},
{
"type": "json",
"name": "TESTJSON",
"url": "https://gooadfdagle.com/vr.json",
"uuid": "542rfwat4t54354353",
},
{
@ -918,6 +924,10 @@ export default {
"icon": "mdi-earth",
"color": "#0097A7", // cyan darken-2
},
"json": {
"icon": "mdi-inbox-multiple",
"color": "#37474F", // blue-grey darken-3
},
"unknown": {
"icon": "mdi-help",
"color": "grey",
@ -1074,6 +1084,10 @@ export default {
case ".fst":
detectedItemType = "avatar";
break;
// JSON Cases
case ".json":
detectedItemType = "json";
break;
}
if (detectedItemType == null) {
@ -1099,6 +1113,9 @@ export default {
case "serverless":
detectedItemType = "serverless";
break;
case "json":
detectedItemType = "json";
break;
}
if (detectedItemType == null) {