Display avatar images and change avatar upon selection

This commit is contained in:
David Rowe 2015-04-22 10:59:53 -07:00
parent 63d0efcdec
commit 2eb5059668

View file

@ -74,9 +74,9 @@ var panelPlaceOrder = [
14, 15, 16, 17, 18, 19, 20 14, 15, 16, 17, 18, 19, 20
]; ];
// place index is 0-based // Avatar index is 0-based
function placeIndexToPanelIndex(placeIndex) { function avatarIndexToPanelIndex(avatarIndex) {
return panelPlaceOrder.indexOf(placeIndex) + 1; return panelPlaceOrder.indexOf(avatarIndex) + 1;
} }
// Panel index is 1-based // Panel index is 1-based
@ -151,24 +151,24 @@ function drawLobby() {
} }
} }
var places = {}; var avatars = {};
function changeLobbyTextures() { function changeLobbyTextures() {
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open("GET", "https://metaverse.highfidelity.com/api/v1/places?limit=21", false); req.open("GET", "https://metaverse.highfidelity.com/api/v1/marketplace?category=head+%26+body&limit=21", false);
req.send(); req.send(); // Data returned is randomized.
places = JSON.parse(req.responseText).data.places; avatars = JSON.parse(req.responseText).data.items;
var NUM_PANELS = places.length; var NUM_PANELS = avatars.length;
var textureProp = { var textureProp = {
textures: {} textures: {}
}; };
for (var j = 0; j < NUM_PANELS; j++) { for (var j = 0; j < NUM_PANELS; j++) {
var panelIndex = placeIndexToPanelIndex(j); var panelIndex = avatarIndexToPanelIndex(j);
textureProp["textures"]["file" + panelIndex] = places[j].previews.lobby; textureProp["textures"]["file" + panelIndex] = avatars[j].preview_url;
}; };
Overlays.editOverlay(panelWall, textureProp); Overlays.editOverlay(panelWall, textureProp);
@ -263,7 +263,7 @@ function cleanupLobby() {
currentMuzakInjector = null; currentMuzakInjector = null;
} }
places = {}; avatars = {};
} }
@ -279,14 +279,15 @@ function actionStartEvent(event) {
var panelStringIndex = panelName.indexOf("Panel"); var panelStringIndex = panelName.indexOf("Panel");
if (panelStringIndex != -1) { if (panelStringIndex != -1) {
var panelIndex = parseInt(panelName.slice(5)); var panelIndex = parseInt(panelName.slice(5));
var placeIndex = panelIndexToPlaceIndex(panelIndex); var avatarIndex = panelIndexToPlaceIndex(panelIndex);
if (placeIndex < places.length) { if (avatarIndex < avatars.length) {
var actionPlace = places[placeIndex]; var actionPlace = avatars[avatarIndex];
print("Jumping to " + actionPlace.name + " at " + actionPlace.address print("Changing avatar to " + actionPlace.name
+ " after click on panel " + panelIndex + " with place index " + placeIndex); + " after click on panel " + panelIndex + " with avatar index " + avatarIndex);
MyAvatar.useFullAvatarURL(actionPlace.content_url);
Window.location = actionPlace.address;
maybeCleanupLobby(); maybeCleanupLobby();
} }
} }
@ -341,9 +342,9 @@ function handleLookAt(pickRay) {
var panelStringIndex = panelName.indexOf("Panel"); var panelStringIndex = panelName.indexOf("Panel");
if (panelStringIndex != -1) { if (panelStringIndex != -1) {
var panelIndex = parseInt(panelName.slice(5)); var panelIndex = parseInt(panelName.slice(5));
var placeIndex = panelIndexToPlaceIndex(panelIndex); var avatarIndex = panelIndexToPlaceIndex(panelIndex);
if (placeIndex < places.length) { if (avatarIndex < avatars.length) {
var actionPlace = places[placeIndex]; var actionPlace = avatars[avatarIndex];
if (actionPlace.description == "") { if (actionPlace.description == "") {
Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText }); Overlays.editOverlay(descriptionText, { text: actionPlace.name, visible: showText });