mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
Add and wire up "search in view" JavaScript API stub
This commit is contained in:
parent
a4b5f5395d
commit
28cfca993f
6 changed files with 53 additions and 13 deletions
|
@ -550,6 +550,14 @@ QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, f
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVector<QUuid> EntityScriptingInterface::findEntitiesInView(const glm::vec3& center, float radius) const {
|
||||||
|
QVector<QUuid> result;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
QVector<QUuid> EntityScriptingInterface::findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const {
|
||||||
QVector<QUuid> result;
|
QVector<QUuid> result;
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
|
|
|
@ -129,6 +129,10 @@ public slots:
|
||||||
|
|
||||||
/// finds models within the search sphere specified by the center point and radius
|
/// finds models within the search sphere specified by the center point and radius
|
||||||
/// this function will not find any models in script engine contexts which don't have access to models
|
/// this function will not find any models in script engine contexts which don't have access to models
|
||||||
|
Q_INVOKABLE QVector<QUuid> findEntitiesInView(const glm::vec3& center, float radius) const;
|
||||||
|
|
||||||
|
/// finds models within the box specified by the corner and dimensions
|
||||||
|
/// this function will not find any models in script engine contexts which don't have access to models
|
||||||
Q_INVOKABLE QVector<QUuid> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
Q_INVOKABLE QVector<QUuid> findEntitiesInBox(const glm::vec3& corner, const glm::vec3& dimensions) const;
|
||||||
|
|
||||||
/// If the scripting context has visible entities, this will determine a ray intersection, the results
|
/// If the scripting context has visible entities, this will determine a ray intersection, the results
|
||||||
|
|
|
@ -366,6 +366,10 @@ input[type=button]:disabled {
|
||||||
background: linear-gradient(#575757 20%, #252525 100%);
|
background: linear-gradient(#575757 20%, #252525 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input[type=button][pressed=pressed] {
|
||||||
|
color: #00b4ef;
|
||||||
|
}
|
||||||
|
|
||||||
input[type=checkbox] {
|
input[type=checkbox] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -861,11 +865,6 @@ textarea:enabled[scrolling="true"]::-webkit-resizer {
|
||||||
position: relative; /* New positioning context. */
|
position: relative; /* New positioning context. */
|
||||||
}
|
}
|
||||||
|
|
||||||
#entity-list .glyph {
|
|
||||||
font-family: HiFi-Glyphs;
|
|
||||||
font-size: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#search-area {
|
#search-area {
|
||||||
padding-right: 168px;
|
padding-right: 168px;
|
||||||
padding-bottom: 24px;
|
padding-bottom: 24px;
|
||||||
|
@ -875,7 +874,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer {
|
||||||
width: 98%;
|
width: 98%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#inView {
|
#in-view {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 126px;
|
right: 126px;
|
||||||
}
|
}
|
||||||
|
@ -904,8 +903,11 @@ textarea:enabled[scrolling="true"]::-webkit-resizer {
|
||||||
border-left: 2px solid #575757;
|
border-left: 2px solid #575757;
|
||||||
border-right: 2px solid #575757;
|
border-right: 2px solid #575757;
|
||||||
background-color: #1c1c1c;
|
background-color: #1c1c1c;
|
||||||
|
}
|
||||||
|
|
||||||
height: 100px;
|
#entity-table-scroll .glyph {
|
||||||
|
font-family: HiFi-Glyphs;
|
||||||
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#entity-table {
|
#entity-table {
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<div id="entity-list">
|
<div id="entity-list">
|
||||||
<div id="search-area">
|
<div id="search-area">
|
||||||
<span class="icon-input"><input type="text" class="search" id="filter" placeholder="Filter" /><span>Y</span></span>
|
<span class="icon-input"><input type="text" class="search" id="filter" placeholder="Filter" /><span>Y</span></span>
|
||||||
<input type="button" id="inView" class="glyph" value="" />
|
<input type="button" id="in-view" class="glyph" value="" />
|
||||||
<div id="radius-and-unit" class="number">
|
<div id="radius-and-unit" class="number">
|
||||||
<label for="radius">Search radius <span class="unit">m</span></label>
|
<label for="radius">Search radius <span class="unit">m</span></label>
|
||||||
<input type="number" id="radius" value="100" />
|
<input type="number" id="radius" value="100" />
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
<div id="no-entities">
|
<div id="no-entities">
|
||||||
No entities found within a <span id="no-entities-radius">100</span> meter radius. Try moving to a different location and refreshing.
|
No entities found <span id="no-entities-in-view">in view</span> within a <span id="no-entities-radius">100</span> meter radius. Try moving to a different location and refreshing.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,13 +36,15 @@ function loaded() {
|
||||||
elToggleVisible = document.getElementById("visible");
|
elToggleVisible = document.getElementById("visible");
|
||||||
elDelete = document.getElementById("delete");
|
elDelete = document.getElementById("delete");
|
||||||
elFilter = document.getElementById("filter");
|
elFilter = document.getElementById("filter");
|
||||||
elTeleport = document.getElementById("teleport");
|
elInView = document.getElementById("in-view")
|
||||||
elRadius = document.getElementById("radius");
|
elRadius = document.getElementById("radius");
|
||||||
|
elTeleport = document.getElementById("teleport");
|
||||||
elEntityTable = document.getElementById("entity-table");
|
elEntityTable = document.getElementById("entity-table");
|
||||||
elInfoToggle = document.getElementById("info-toggle");
|
elInfoToggle = document.getElementById("info-toggle");
|
||||||
elInfoToggleGlyph = elInfoToggle.firstChild;
|
elInfoToggleGlyph = elInfoToggle.firstChild;
|
||||||
elFooter = document.getElementById("footer-text");
|
elFooter = document.getElementById("footer-text");
|
||||||
elNoEntitiesMessage = document.getElementById("no-entities");
|
elNoEntitiesMessage = document.getElementById("no-entities");
|
||||||
|
elNoEntitiesInView = document.getElementById("no-entities-in-view");
|
||||||
elNoEntitiesRadius = document.getElementById("no-entities-radius");
|
elNoEntitiesRadius = document.getElementById("no-entities-radius");
|
||||||
elEntityTableScroll = document.getElementById("entity-table-scroll");
|
elEntityTableScroll = document.getElementById("entity-table-scroll");
|
||||||
|
|
||||||
|
@ -271,6 +273,22 @@ function loaded() {
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
var isFilterInView = false;
|
||||||
|
var FILTER_IN_VIEW_ATTRIBUTE = "pressed";
|
||||||
|
elNoEntitiesInView.style.display = "none";
|
||||||
|
elInView.onclick = function () {
|
||||||
|
isFilterInView = !isFilterInView;
|
||||||
|
if (isFilterInView) {
|
||||||
|
elInView.setAttribute(FILTER_IN_VIEW_ATTRIBUTE, FILTER_IN_VIEW_ATTRIBUTE);
|
||||||
|
elNoEntitiesInView.style.display = "inline";
|
||||||
|
} else {
|
||||||
|
elInView.removeAttribute(FILTER_IN_VIEW_ATTRIBUTE);
|
||||||
|
elNoEntitiesInView.style.display = "none";
|
||||||
|
}
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({ type: "filterInView", filterInView: isFilterInView }));
|
||||||
|
refreshEntities();
|
||||||
|
}
|
||||||
|
|
||||||
elRadius.onchange = function () {
|
elRadius.onchange = function () {
|
||||||
elRadius.value = Math.max(elRadius.value, 0);
|
elRadius.value = Math.max(elRadius.value, 0);
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'radius', radius: elRadius.value }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'radius', radius: elRadius.value }));
|
||||||
|
|
|
@ -9,7 +9,7 @@ EntityListTool = function(opts) {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var filterInView = false;
|
||||||
var searchRadius = 100;
|
var searchRadius = 100;
|
||||||
|
|
||||||
var visible = false;
|
var visible = false;
|
||||||
|
@ -54,7 +54,14 @@ EntityListTool = function(opts) {
|
||||||
|
|
||||||
that.sendUpdate = function() {
|
that.sendUpdate = function() {
|
||||||
var entities = [];
|
var entities = [];
|
||||||
var ids = Entities.findEntities(MyAvatar.position, searchRadius);
|
|
||||||
|
var ids;
|
||||||
|
if (filterInView) {
|
||||||
|
ids = Entities.findEntitiesInView(MyAvatar.position, searchRadius);
|
||||||
|
} else {
|
||||||
|
ids = Entities.findEntities(MyAvatar.position, searchRadius);
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < ids.length; i++) {
|
for (var i = 0; i < ids.length; i++) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var properties = Entities.getEntityProperties(id);
|
var properties = Entities.getEntityProperties(id);
|
||||||
|
@ -115,9 +122,10 @@ EntityListTool = function(opts) {
|
||||||
toggleSelectedEntitiesLocked();
|
toggleSelectedEntitiesLocked();
|
||||||
} else if (data.type == "toggleVisible") {
|
} else if (data.type == "toggleVisible") {
|
||||||
toggleSelectedEntitiesVisible();
|
toggleSelectedEntitiesVisible();
|
||||||
|
} else if (data.type === "filterInView") {
|
||||||
|
filterInView = data.filterInView === true;
|
||||||
} else if (data.type === "radius") {
|
} else if (data.type === "radius") {
|
||||||
searchRadius = data.radius;
|
searchRadius = data.radius;
|
||||||
that.sendUpdate();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue