mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
Nearby user loading functionality enabled.
This commit is contained in:
parent
c0df50de3c
commit
f1ff399225
2 changed files with 42 additions and 15 deletions
|
@ -117,7 +117,7 @@
|
|||
</v-list-item-action>
|
||||
</v-list-item>
|
||||
<v-list-item
|
||||
@click="shareDialog.show = true; shareDialog.data.url = item.url;"
|
||||
@click="shareDialog.show = true; shareDialog.data.url = item.url; sendAppMessage('web-to-script-request-nearby-users', '')"
|
||||
>
|
||||
<v-list-item-title>Share</v-list-item-title>
|
||||
<v-list-item-action>
|
||||
|
@ -473,7 +473,7 @@ EventBridge.scriptEventReceived.connect(function(receivedCommand) {
|
|||
if (receivedCommand.app == "inventory") {
|
||||
// We route the data based on the command given.
|
||||
if (receivedCommand.command == 'script-to-web-inventory') {
|
||||
alert("INVENTORY RECEIVED ON APP:" + JSON.stringify(receivedCommand.data));
|
||||
// alert("INVENTORY RECEIVED ON APP:" + JSON.stringify(receivedCommand.data));
|
||||
vue_this.receiveInventory(receivedCommand.data);
|
||||
}
|
||||
|
||||
|
@ -482,8 +482,10 @@ EventBridge.scriptEventReceived.connect(function(receivedCommand) {
|
|||
}
|
||||
|
||||
if (receivedCommand.command == 'script-to-web-nearby-users') {
|
||||
alert("RECEIVING NEARBY USERS:" + JSON.stringify(receivedCommand.data));
|
||||
// alert("RECEIVING NEARBY USERS:" + JSON.stringify(receivedCommand.data));
|
||||
vue_this.receiveNearbyUsers(receivedCommand.data);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -734,7 +736,11 @@ new Vue({
|
|||
return this.iconType[itemType].color;
|
||||
},
|
||||
receiveNearbyUsers: function(receivedUsers) {
|
||||
this.nearbyUsers = receivedUsers;
|
||||
if (!receivedUsers) {
|
||||
this.nearbyUsers = [];
|
||||
} else {
|
||||
this.nearbyUsers = receivedUsers;
|
||||
}
|
||||
},
|
||||
sendAppMessage: function(command, data) {
|
||||
var JSONtoSend = {
|
||||
|
|
|
@ -39,6 +39,10 @@ function onWebAppEventReceived(event) {
|
|||
shareItem(eventJSON.data);
|
||||
}
|
||||
|
||||
if (eventJSON.command == "web-to-script-request-nearby-users") {
|
||||
sendNearbyUsers();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,18 +58,18 @@ function sendToWeb(command, data) {
|
|||
tablet.emitScriptEvent(JSON.stringify(dataToSend));
|
||||
}
|
||||
|
||||
// var inventoryMessagesChannel = "com.vircadia.inventory";
|
||||
var inventoryMessagesChannel = "com.vircadia.inventory";
|
||||
|
||||
// function onMessageReceived(channel, message, sender, localOnly) {
|
||||
// if (channel == inventoryMessagesChannel) {
|
||||
// var messageJSON = JSON.parse(message);
|
||||
// }
|
||||
// print("Message received:");
|
||||
// print("- channel: " + channel);
|
||||
// print("- message: " + message);
|
||||
// print("- sender: " + sender);
|
||||
// print("- localOnly: " + localOnly);
|
||||
// }
|
||||
function onMessageReceived(channel, message, sender, localOnly) {
|
||||
if (channel == inventoryMessagesChannel) {
|
||||
var messageJSON = JSON.parse(message);
|
||||
}
|
||||
print("Message received:");
|
||||
print("- channel: " + channel);
|
||||
print("- message: " + message);
|
||||
print("- sender: " + sender);
|
||||
print("- localOnly: " + localOnly);
|
||||
}
|
||||
|
||||
// END APP EVENT AND MESSAGING ROUTING
|
||||
|
||||
|
@ -98,6 +102,23 @@ function shareItem(data) {
|
|||
|
||||
}
|
||||
|
||||
function sendNearbyUsers() {
|
||||
var nearbyUsers = AvatarList.getAvatarsInRange(Vec3.ZERO, 25); // Find all users within 25m.
|
||||
var nearbyUsersToSend = [];
|
||||
|
||||
nearbyUsers.forEach(function(user, i) {
|
||||
var objectToWrite;
|
||||
var aviName = AvatarList.getAvatar(user).displayName;
|
||||
|
||||
if (aviName != MyAvatar.displayName) {
|
||||
objectToWrite = { "name": aviName, "uuid": user };
|
||||
nearbyUsersToSend.push = objectToWrite;
|
||||
}
|
||||
});
|
||||
|
||||
sendToWeb("script-to-web-nearby-users", nearbyUsersToSend);
|
||||
}
|
||||
|
||||
function useItem(item) {
|
||||
|
||||
//TODO: Add animation support for avatars, add JSON loading...?
|
||||
|
|
Loading…
Reference in a new issue