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

Places app: Portal Spawner and Copy URL #1296

Merged
merged 5 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Binary file added scripts/system/places/icons/portalFX.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 59 additions & 8 deletions scripts/system/places/places.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// places.css
//
// Created by Alezia Kurdis, January 1st, 2022.
// Copyright 2022 Overte e.V.
// Copyright 2022-2025 Overte e.V.
//
// css for the ui of the Places application.
//
Expand Down Expand Up @@ -750,19 +750,20 @@ font.domain-nbrUser_small {
color: #cccccc;
padding: 10px;
text-align: justify;
text-justify: inter-word;
text-justify: inter-word;
}

#placeDetail-visitBtn {
background: #0000ff;
background-image: linear-gradient(to bottom, #0000ff, #000020);
border: 0px;
border-radius: 10px;
font-weight: 800;
border-radius: 6px;
font-weight: 700;
color: #ffffff;
font-size: 20px;
padding: 3px 22px 3px 22px;
font-size: 14px;
padding: 2px 22px 2px 22px;
text-decoration: none;
width: 90%;
}

#placeDetail-visitBtn:hover {
Expand All @@ -774,7 +775,57 @@ font.domain-nbrUser_small {
#placeDetail-visitBtn-container {
width: 100%;
text-align: left;
margin-bottom: 40px;
margin-bottom: 8px;
}

#placeDetail-rezPortalBtn {
background: #0000ff;
background-image: linear-gradient(to bottom, #0000ff, #000020);
border: 0px;
border-radius: 6px;
font-weight: 700;
color: #ffffff;
font-size: 14px;
padding: 2px 22px 2px 22px;
text-decoration: none;
width: 90%;
}

#placeDetail-rezPortalBtn:hover {
background: #057eff;
background-image: linear-gradient(to bottom, #057eff, #00090f);
text-decoration: none;
}

#placeDetail-rezPortalBtn-container {
width: 100%;
text-align: left;
margin-bottom: 8px;
}

#placeDetail-copyPlaceURLBtn {
background: #0000ff;
background-image: linear-gradient(to bottom, #0000ff, #000020);
border: 0px;
border-radius: 6px;
font-weight: 700;
color: #ffffff;
font-size: 14px;
padding: 2px 22px 2px 22px;
text-decoration: none;
width: 90%;
}

#placeDetail-copyPlaceURLBtn:hover {
background: #057eff;
background-image: linear-gradient(to bottom, #057eff, #00090f);
text-decoration: none;
}

#placeDetail-copyPlaceURLBtn-container {
width: 100%;
text-align: left;
margin-bottom: 8px;
}

#placeDetail-placedata {
Expand Down Expand Up @@ -804,7 +855,7 @@ font.domain-nbrUser_small {

#placeDetail-users {
font-size: 30px;
font-weight: 600;
font-weight: 600;
}

#placeDetail-capacity {
Expand Down
28 changes: 27 additions & 1 deletion scripts/system/places/places.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// places.html
//
// Created by Alezia Kurdis, January 1st, 2022.
// Copyright 2022 Overte e.V.
// Copyright 2022-2025 Overte e.V.
//
// html for the ui of the Places application.
//
Expand Down Expand Up @@ -118,6 +118,8 @@
<td id="" width='29%'>

<div id="placeDetail-visitBtn-container"></div>
<div id="placeDetail-rezPortalBtn-container"></div>
<div id="placeDetail-copyPlaceURLBtn-container"></div>
<div id="placeDetail-maturity"></div>
<div id="placeDetail-placedata">
DOMAIN:
Expand Down Expand Up @@ -502,6 +504,28 @@

}

function rezPortal(name, address, placeID) {
var portalOrder = {
"channel": channel,
"action": "REQUEST_PORTAL",
"name": name,
"address": address,
"placeID": placeID
};
EventBridge.emitWebEvent(JSON.stringify(portalOrder));

}

function copyPlaceURL(address) {
var portalOrder = {
"channel": channel,
"action": "COPY_URL",
"address": address
};
EventBridge.emitWebEvent(JSON.stringify(portalOrder));

}

function goHome() {
var message = {
"channel": channel,
Expand Down Expand Up @@ -766,6 +790,8 @@
placeUrl = "hifi://" + placeDetail.address;
}
document.getElementById("placeDetail-visitBtn-container").innerHTML = "<button id='placeDetail-visitBtn' onclick='teleport(" + '"' + placeDetail.id + '"' + ", " + '"' + placeUrl + '"' + "); return false;'>Visit</button>";
document.getElementById("placeDetail-rezPortalBtn-container").innerHTML = "<button id='placeDetail-rezPortalBtn' onclick='rezPortal(" + '"' + placeDetail.name + '"' + ", " + '"' + placeUrl + '"' + ", " + '"' + placeDetail.id + '"' + "); return false;'>Portal</button>";
document.getElementById("placeDetail-copyPlaceURLBtn-container").innerHTML = "<button id='placeDetail-copyPlaceURLBtn' onclick='copyPlaceURL(" + '"' + placeUrl + '"' + "); return false;'>Copy URL</button>";
document.getElementById("placeDetail-maturity").innerHTML = placeDetail.maturity.toUpperCase();
document.getElementById("placeDetail-maturity").className = placeDetail.maturity + "FilterOn placeMaturity";
document.getElementById("placeDetail-domain").innerHTML = placeDetail.domain.toUpperCase();
Expand Down
87 changes: 84 additions & 3 deletions scripts/system/places/places.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// places.js
//
// Created by Alezia Kurdis, January 1st, 2022.
// Copyright 2022-2023 Overte e.V.
// Copyright 2022-2025 Overte e.V.
//
// Generate an explore app based on the differents source of placename data.
//
Expand Down Expand Up @@ -36,6 +36,12 @@
var APP_ICON_ACTIVE = ROOT + "icons/appicon_a.png";
var appStatus = false;
var channel = "com.overte.places";

var portalChannelName = "com.overte.places.portalRezzer";
var MAX_DISTANCE_TO_CONSIDER_PORTAL = 100.0; //in meters
var PORTAL_DURATION_MILLISEC = 45000; //45 sec
var rezzerPortalCount = 0;
var MAX_REZZED_PORTAL = 15;

var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");

Expand Down Expand Up @@ -92,6 +98,24 @@
Window.location = messageObj.address;
}

} else if (messageObj.action === "REQUEST_PORTAL" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
var portalPosition = Vec3.sum(MyAvatar.feetPosition, Vec3.multiplyQbyV(MyAvatar.orientation, {"x": 0.0, "y": 0.0, "z": -2.0}));
var requestToSend = {
"action": "REZ_PORTAL",
"position": portalPosition,
"url": messageObj.address,
"name": messageObj.name,
"placeID": messageObj.placeID
};
Messages.sendMessage(portalChannelName, JSON.stringify(requestToSend), false);

} else if (messageObj.action === "COPY_URL" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
Window.copyToClipboard(messageObj.address);
Window.displayAnnouncement("Place URL copied.");
} else if (messageObj.action === "GO_HOME" && (n - timestamp) > INTERCALL_DELAY) {
d = new Date();
timestamp = d.getTime();
Expand Down Expand Up @@ -284,8 +308,8 @@
region = "local";
order = "A";
fetch = true;
pinned = false;
currentFound = true;
pinned = false;
currentFound = true;
} else {
region = "federation";
order = "F";
Expand Down Expand Up @@ -555,16 +579,73 @@
}
//####### END of seed random library ################

function onMessageReceived(paramChannel, paramMessage, paramSender, paramLocalOnly) {
if (paramChannel === portalChannelName) {
var instruction = JSON.parse(paramMessage);
if (instruction.action === "REZ_PORTAL") {
generatePortal(instruction.position, instruction.url, instruction.name, instruction.placeID);
}
}
}

function generatePortal(position, url, name, placeID) {
if (rezzerPortalCount <= MAX_REZZED_PORTAL) {
var TOLERANCE_FACTOR = 1.1;
if (Vec3.distance(MyAvatar.position, position) < MAX_DISTANCE_TO_CONSIDER_PORTAL) {
var height = MyAvatar.userHeight * MyAvatar.scale * TOLERANCE_FACTOR;

var portalPosition = Vec3.sum(position, {"x": 0.0, "y": height/2, "z": 0.0});
var dimensions = {"x": height * 0.618, "y": height, "z": height * 0.618};
var userdata = {
"url": url,
"name": name,
"placeID": placeID
};

var portalID = Entities.addEntity({
"position": portalPosition,
"dimensions": dimensions,
"type": "Shape",
"shape": "Sphere",
"name": "Portal to " + name,
"canCastShadow": false,
"collisionless": true,
"userData": JSON.stringify(userdata),
"script": ROOT + "portal.js",
"visible": "false",
"grab": {
"grabbable": false
}
}, "local");
rezzerPortalCount = rezzerPortalCount + 1;

Script.setTimeout(function () {
Entities.deleteEntity(portalID);
rezzerPortalCount = rezzerPortalCount - 1;
if (rezzerPortalCount < 0) {
rezzerPortalCount = 0;
}
}, PORTAL_DURATION_MILLISEC);
}
}
}

function cleanup() {

if (appStatus) {
tablet.gotoHomeScreen();
tablet.webEventReceived.disconnect(onAppWebEventReceived);
}

Messages.messageReceived.disconnect(onMessageReceived);
Messages.unsubscribe(portalChannelName);

tablet.screenChanged.disconnect(onScreenChanged);
tablet.removeButton(button);
}

Messages.subscribe(portalChannelName);
Messages.messageReceived.connect(onMessageReceived);

Script.scriptEnding.connect(cleanup);
}());
Loading