Skip to content

Commit

Permalink
Merge pull request #1296 from AleziaKurdis/placeApp_rezTP
Browse files Browse the repository at this point in the history
Places app: Portal Spawner and Copy URL
  • Loading branch information
ksuprynowicz authored Feb 10, 2025
2 parents 7a59a27 + f1cecad commit ccdac96
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 17 deletions.
6 changes: 3 additions & 3 deletions libraries/entities/src/EntityTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// EntityTypes.h
// libraries/entities/src
//
// Created by Brad Hefta-Gaub on 12/4/13.
// Created by Brad Hefta-Gaub on December 4th, 2013.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// Copyright 2023-2025 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand Down Expand Up @@ -91,7 +91,7 @@ class EntityTypes {
* <tr><td><code>"Material"</code></td><td>Modifies the existing materials on entities and avatars.</td>
* <td>{@link Entities.EntityProperties-Material|EntityProperties-Material}</td></tr>
* <tr><td><code>"Sound"</code></td><td>Plays a sound.</td>
* <td>{@link Entities.EntityProperties-Material|EntityProperties-Sound}</td></tr>
* <td>{@link Entities.EntityProperties-Sound|EntityProperties-Sound}</td></tr>
* </tbody>
* </table>
* @typedef {string} Entities.EntityType
Expand Down
5 changes: 3 additions & 2 deletions libraries/shared/src/PickFilter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by Sam Gondelman on 12/7/18.
// Created by Sam Gondelman on December 7th, 2018.
// Copyright 2018 High Fidelity, Inc.
// Copyright 2025 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand All @@ -26,7 +27,7 @@ class PickFilter {
* <tr><td>PICK_DOMAIN_ENTITIES</td><td><code>1</code></td><td>Include domain entities when intersecting.</td></tr>
* <tr><td>PICK_AVATAR_ENTITIES</td><td><code>2</code></td><td>Include avatar entities when intersecting.</td></tr>
* <tr><td>PICK_LOCAL_ENTITIES</td><td><code>4</code></td><td>Include local entities when intersecting.</td></tr>
* <tr><td>PICK_AVATATRS</td><td><code>8</code></td><td>Include avatars when intersecting.</td></tr>
* <tr><td>PICK_AVATARS</td><td><code>8</code></td><td>Include avatars when intersecting.</td></tr>
* <tr><td>PICK_HUD</td><td><code>16</code></td><td>Include the HUD surface when intersecting in HMD mode.</td></tr>
* <tr><td>PICK_INCLUDE_VISIBLE</td><td><code>32</code></td><td>Include visible objects when intersecting.</td></tr>
* <tr><td>PICK_INCLUDE_INVISIBLE</td><td><code>64</code></td><td>Include invisible objects when intersecting.</td></tr>
Expand Down
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

0 comments on commit ccdac96

Please sign in to comment.