mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:08:54 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into createEntitiesGrabbable
This commit is contained in:
commit
5d1cc3696a
4 changed files with 402 additions and 394 deletions
|
@ -57,9 +57,9 @@ ListModel {
|
||||||
// Not normally set directly, but rather by giving a truthy argument to getFirstPage(true);
|
// Not normally set directly, but rather by giving a truthy argument to getFirstPage(true);
|
||||||
property bool delayedClear: false;
|
property bool delayedClear: false;
|
||||||
function resetModel() {
|
function resetModel() {
|
||||||
if (!delayedClear) { root.clear(); }
|
|
||||||
currentPageToRetrieve = 1;
|
currentPageToRetrieve = 1;
|
||||||
retrievedAtLeastOnePage = false;
|
retrievedAtLeastOnePage = false;
|
||||||
|
if (!delayedClear) { root.clear(); }
|
||||||
totalPages = 0;
|
totalPages = 0;
|
||||||
totalEntries = 0;
|
totalEntries = 0;
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,13 @@ ListModel {
|
||||||
function needsMoreHorizontalResults() {
|
function needsMoreHorizontalResults() {
|
||||||
return flickable
|
return flickable
|
||||||
&& currentPageToRetrieve > 0
|
&& currentPageToRetrieve > 0
|
||||||
|
&& retrievedAtLeastOnePage
|
||||||
&& flickable.contentWidth < flickable.width;
|
&& flickable.contentWidth < flickable.width;
|
||||||
}
|
}
|
||||||
function needsMoreVerticalResults() {
|
function needsMoreVerticalResults() {
|
||||||
return flickable
|
return flickable
|
||||||
&& currentPageToRetrieve > 0
|
&& currentPageToRetrieve > 0
|
||||||
|
&& retrievedAtLeastOnePage
|
||||||
&& flickable.contentHeight < flickable.height;
|
&& flickable.contentHeight < flickable.height;
|
||||||
}
|
}
|
||||||
function getNextPageIfNotEnoughHorizontalResults() {
|
function getNextPageIfNotEnoughHorizontalResults() {
|
||||||
|
|
|
@ -143,7 +143,7 @@ class MyAvatar : public Avatar {
|
||||||
* registration point of the 3D model.
|
* registration point of the 3D model.
|
||||||
*
|
*
|
||||||
* @property {Vec3} position
|
* @property {Vec3} position
|
||||||
* @property {number} scale
|
* @property {number} scale - Returns the clamped scale of the avatar.
|
||||||
* @property {number} density <em>Read-only.</em>
|
* @property {number} density <em>Read-only.</em>
|
||||||
* @property {Vec3} handPosition
|
* @property {Vec3} handPosition
|
||||||
* @property {number} bodyYaw - The rotation left or right about an axis running from the head to the feet of the avatar.
|
* @property {number} bodyYaw - The rotation left or right about an axis running from the head to the feet of the avatar.
|
||||||
|
@ -982,7 +982,7 @@ public:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function MyAvatar.getAvatarScale
|
* @function MyAvatar.getAvatarScale
|
||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
Q_INVOKABLE float getAvatarScale();
|
Q_INVOKABLE float getAvatarScale();
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ class AvatarData : public QObject, public SpatiallyNestable {
|
||||||
|
|
||||||
// The following properties have JSDoc in MyAvatar.h and ScriptableAvatar.h
|
// The following properties have JSDoc in MyAvatar.h and ScriptableAvatar.h
|
||||||
Q_PROPERTY(glm::vec3 position READ getWorldPosition WRITE setPositionViaScript)
|
Q_PROPERTY(glm::vec3 position READ getWorldPosition WRITE setPositionViaScript)
|
||||||
Q_PROPERTY(float scale READ getTargetScale WRITE setTargetScale)
|
Q_PROPERTY(float scale READ getDomainLimitedScale WRITE setTargetScale)
|
||||||
Q_PROPERTY(float density READ getDensity)
|
Q_PROPERTY(float density READ getDensity)
|
||||||
Q_PROPERTY(glm::vec3 handPosition READ getHandPosition WRITE setHandPosition)
|
Q_PROPERTY(glm::vec3 handPosition READ getHandPosition WRITE setHandPosition)
|
||||||
Q_PROPERTY(float bodyYaw READ getBodyYaw WRITE setBodyYaw)
|
Q_PROPERTY(float bodyYaw READ getBodyYaw WRITE setBodyYaw)
|
||||||
|
|
|
@ -28,436 +28,442 @@ debugPrint = function (message) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function loaded() {
|
function loaded() {
|
||||||
openEventBridge(function() {
|
openEventBridge(function() {
|
||||||
entityList = new List('entity-list', { valueNames: ['name', 'type', 'url', 'locked', 'visible'], page: MAX_ITEMS});
|
entityList = new List('entity-list', { valueNames: ['name', 'type', 'url', 'locked', 'visible'], page: MAX_ITEMS});
|
||||||
entityList.clear();
|
entityList.clear();
|
||||||
elEntityTable = document.getElementById("entity-table");
|
elEntityTable = document.getElementById("entity-table");
|
||||||
elEntityTableBody = document.getElementById("entity-table-body");
|
elEntityTableBody = document.getElementById("entity-table-body");
|
||||||
elRefresh = document.getElementById("refresh");
|
elRefresh = document.getElementById("refresh");
|
||||||
elToggleLocked = document.getElementById("locked");
|
elToggleLocked = document.getElementById("locked");
|
||||||
elToggleVisible = document.getElementById("visible");
|
elToggleVisible = document.getElementById("visible");
|
||||||
elDelete = document.getElementById("delete");
|
elDelete = document.getElementById("delete");
|
||||||
elFilter = document.getElementById("filter");
|
elFilter = document.getElementById("filter");
|
||||||
elInView = document.getElementById("in-view")
|
elInView = document.getElementById("in-view")
|
||||||
elRadius = document.getElementById("radius");
|
elRadius = document.getElementById("radius");
|
||||||
elExport = document.getElementById("export");
|
elExport = document.getElementById("export");
|
||||||
elPal = document.getElementById("pal");
|
elPal = document.getElementById("pal");
|
||||||
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");
|
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");
|
||||||
|
|
||||||
document.getElementById("entity-name").onclick = function() {
|
document.getElementById("entity-name").onclick = function() {
|
||||||
setSortColumn('name');
|
setSortColumn('name');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-type").onclick = function() {
|
document.getElementById("entity-type").onclick = function() {
|
||||||
setSortColumn('type');
|
setSortColumn('type');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-url").onclick = function() {
|
document.getElementById("entity-url").onclick = function() {
|
||||||
setSortColumn('url');
|
setSortColumn('url');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-locked").onclick = function () {
|
document.getElementById("entity-locked").onclick = function () {
|
||||||
setSortColumn('locked');
|
setSortColumn('locked');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-visible").onclick = function () {
|
document.getElementById("entity-visible").onclick = function () {
|
||||||
setSortColumn('visible');
|
setSortColumn('visible');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-verticesCount").onclick = function () {
|
document.getElementById("entity-verticesCount").onclick = function () {
|
||||||
setSortColumn('verticesCount');
|
setSortColumn('verticesCount');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-texturesCount").onclick = function () {
|
document.getElementById("entity-texturesCount").onclick = function () {
|
||||||
setSortColumn('texturesCount');
|
setSortColumn('texturesCount');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-texturesSize").onclick = function () {
|
document.getElementById("entity-texturesSize").onclick = function () {
|
||||||
setSortColumn('texturesSize');
|
setSortColumn('texturesSize');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-hasTransparent").onclick = function () {
|
document.getElementById("entity-hasTransparent").onclick = function () {
|
||||||
setSortColumn('hasTransparent');
|
setSortColumn('hasTransparent');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-isBaked").onclick = function () {
|
document.getElementById("entity-isBaked").onclick = function () {
|
||||||
setSortColumn('isBaked');
|
setSortColumn('isBaked');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-drawCalls").onclick = function () {
|
document.getElementById("entity-drawCalls").onclick = function () {
|
||||||
setSortColumn('drawCalls');
|
setSortColumn('drawCalls');
|
||||||
};
|
};
|
||||||
document.getElementById("entity-hasScript").onclick = function () {
|
document.getElementById("entity-hasScript").onclick = function () {
|
||||||
setSortColumn('hasScript');
|
setSortColumn('hasScript');
|
||||||
};
|
};
|
||||||
|
|
||||||
function onRowClicked(clickEvent) {
|
function onRowClicked(clickEvent) {
|
||||||
var id = this.dataset.entityId;
|
var id = this.dataset.entityId;
|
||||||
var selection = [this.dataset.entityId];
|
var selection = [this.dataset.entityId];
|
||||||
if (clickEvent.ctrlKey) {
|
if (clickEvent.ctrlKey) {
|
||||||
selection = selection.concat(selectedEntities);
|
var selectedIndex = selectedEntities.indexOf(id);
|
||||||
} else if (clickEvent.shiftKey && selectedEntities.length > 0) {
|
if (selectedIndex >= 0) {
|
||||||
var previousItemFound = -1;
|
selection = selectedEntities;
|
||||||
var clickedItemFound = -1;
|
selection.splice(selectedIndex, 1)
|
||||||
for (var entity in entityList.visibleItems) {
|
} else {
|
||||||
if (clickedItemFound === -1 && this.dataset.entityId == entityList.visibleItems[entity].values().id) {
|
selection = selection.concat(selectedEntities);
|
||||||
clickedItemFound = entity;
|
}
|
||||||
} else if(previousItemFound === -1 && selectedEntities[0] == entityList.visibleItems[entity].values().id) {
|
} else if (clickEvent.shiftKey && selectedEntities.length > 0) {
|
||||||
previousItemFound = entity;
|
var previousItemFound = -1;
|
||||||
}
|
var clickedItemFound = -1;
|
||||||
}
|
for (var entity in entityList.visibleItems) {
|
||||||
if (previousItemFound !== -1 && clickedItemFound !== -1) {
|
if (clickedItemFound === -1 && this.dataset.entityId == entityList.visibleItems[entity].values().id) {
|
||||||
var betweenItems = [];
|
clickedItemFound = entity;
|
||||||
var toItem = Math.max(previousItemFound, clickedItemFound);
|
} else if(previousItemFound === -1 && selectedEntities[0] == entityList.visibleItems[entity].values().id) {
|
||||||
// skip first and last item in this loop, we add them to selection after the loop
|
previousItemFound = entity;
|
||||||
for (var i = (Math.min(previousItemFound, clickedItemFound) + 1); i < toItem; i++) {
|
}
|
||||||
entityList.visibleItems[i].elm.className = 'selected';
|
}
|
||||||
betweenItems.push(entityList.visibleItems[i].values().id);
|
if (previousItemFound !== -1 && clickedItemFound !== -1) {
|
||||||
}
|
var betweenItems = [];
|
||||||
if (previousItemFound > clickedItemFound) {
|
var toItem = Math.max(previousItemFound, clickedItemFound);
|
||||||
// always make sure that we add the items in the right order
|
// skip first and last item in this loop, we add them to selection after the loop
|
||||||
betweenItems.reverse();
|
for (var i = (Math.min(previousItemFound, clickedItemFound) + 1); i < toItem; i++) {
|
||||||
}
|
entityList.visibleItems[i].elm.className = 'selected';
|
||||||
selection = selection.concat(betweenItems, selectedEntities);
|
betweenItems.push(entityList.visibleItems[i].values().id);
|
||||||
}
|
}
|
||||||
}
|
if (previousItemFound > clickedItemFound) {
|
||||||
|
// always make sure that we add the items in the right order
|
||||||
|
betweenItems.reverse();
|
||||||
|
}
|
||||||
|
selection = selection.concat(betweenItems, selectedEntities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
selectedEntities = selection;
|
selectedEntities = selection;
|
||||||
|
|
||||||
this.className = 'selected';
|
this.className = 'selected';
|
||||||
|
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "selectionUpdate",
|
type: "selectionUpdate",
|
||||||
focus: false,
|
focus: false,
|
||||||
entityIds: selection,
|
entityIds: selection,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
refreshFooter();
|
refreshFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onRowDoubleClicked() {
|
function onRowDoubleClicked() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "selectionUpdate",
|
type: "selectionUpdate",
|
||||||
focus: true,
|
focus: true,
|
||||||
entityIds: [this.dataset.entityId],
|
entityIds: [this.dataset.entityId],
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
const BYTES_PER_MEGABYTE = 1024 * 1024;
|
const BYTES_PER_MEGABYTE = 1024 * 1024;
|
||||||
|
|
||||||
function decimalMegabytes(number) {
|
function decimalMegabytes(number) {
|
||||||
return number ? (number / BYTES_PER_MEGABYTE).toFixed(1) : "";
|
return number ? (number / BYTES_PER_MEGABYTE).toFixed(1) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayIfNonZero(number) {
|
function displayIfNonZero(number) {
|
||||||
return number ? number : "";
|
return number ? number : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEntity(id, name, type, url, locked, visible, verticesCount, texturesCount, texturesSize, hasTransparent,
|
function addEntity(id, name, type, url, locked, visible, verticesCount, texturesCount, texturesSize, hasTransparent,
|
||||||
isBaked, drawCalls, hasScript) {
|
isBaked, drawCalls, hasScript) {
|
||||||
|
|
||||||
var urlParts = url.split('/');
|
var urlParts = url.split('/');
|
||||||
var filename = urlParts[urlParts.length - 1];
|
var filename = urlParts[urlParts.length - 1];
|
||||||
|
|
||||||
var IMAGE_MODEL_NAME = 'default-image-model.fbx';
|
var IMAGE_MODEL_NAME = 'default-image-model.fbx';
|
||||||
|
|
||||||
if (filename === IMAGE_MODEL_NAME) {
|
if (filename === IMAGE_MODEL_NAME) {
|
||||||
type = "Image";
|
type = "Image";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entities[id] === undefined) {
|
if (entities[id] === undefined) {
|
||||||
entityList.add([{
|
entityList.add([{
|
||||||
id: id, name: name, type: type, url: filename, locked: locked, visible: visible,
|
id: id, name: name, type: type, url: filename, locked: locked, visible: visible,
|
||||||
verticesCount: displayIfNonZero(verticesCount), texturesCount: displayIfNonZero(texturesCount),
|
verticesCount: displayIfNonZero(verticesCount), texturesCount: displayIfNonZero(texturesCount),
|
||||||
texturesSize: decimalMegabytes(texturesSize), hasTransparent: hasTransparent,
|
texturesSize: decimalMegabytes(texturesSize), hasTransparent: hasTransparent,
|
||||||
isBaked: isBaked, drawCalls: displayIfNonZero(drawCalls), hasScript: hasScript
|
isBaked: isBaked, drawCalls: displayIfNonZero(drawCalls), hasScript: hasScript
|
||||||
}],
|
}],
|
||||||
function (items) {
|
function (items) {
|
||||||
var currentElement = items[0].elm;
|
var currentElement = items[0].elm;
|
||||||
var id = items[0]._values.id;
|
var id = items[0]._values.id;
|
||||||
entities[id] = {
|
entities[id] = {
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
el: currentElement,
|
el: currentElement,
|
||||||
item: items[0]
|
item: items[0]
|
||||||
};
|
};
|
||||||
currentElement.setAttribute('id', 'entity_' + id);
|
currentElement.setAttribute('id', 'entity_' + id);
|
||||||
currentElement.setAttribute('title', url);
|
currentElement.setAttribute('title', url);
|
||||||
currentElement.dataset.entityId = id;
|
currentElement.dataset.entityId = id;
|
||||||
currentElement.onclick = onRowClicked;
|
currentElement.onclick = onRowClicked;
|
||||||
currentElement.ondblclick = onRowDoubleClicked;
|
currentElement.ondblclick = onRowDoubleClicked;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var item = entities[id].item;
|
var item = entities[id].item;
|
||||||
item.values({ name: name, url: filename, locked: locked, visible: visible });
|
item.values({ name: name, url: filename, locked: locked, visible: visible });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeEntities(deletedIDs) {
|
function removeEntities(deletedIDs) {
|
||||||
for (i = 0, length = deletedIDs.length; i < length; i++) {
|
for (i = 0, length = deletedIDs.length; i < length; i++) {
|
||||||
delete entities[deletedIDs[i]];
|
delete entities[deletedIDs[i]];
|
||||||
entityList.remove("id", deletedIDs[i]);
|
entityList.remove("id", deletedIDs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function scheduleRefreshEntityList() {
|
function scheduleRefreshEntityList() {
|
||||||
var REFRESH_DELAY = 50;
|
var REFRESH_DELAY = 50;
|
||||||
if (refreshEntityListTimer) {
|
if (refreshEntityListTimer) {
|
||||||
clearTimeout(refreshEntityListTimer);
|
clearTimeout(refreshEntityListTimer);
|
||||||
}
|
}
|
||||||
refreshEntityListTimer = setTimeout(refreshEntityListObject, REFRESH_DELAY);
|
refreshEntityListTimer = setTimeout(refreshEntityListObject, REFRESH_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearEntities() {
|
function clearEntities() {
|
||||||
entities = {};
|
entities = {};
|
||||||
entityList.clear();
|
entityList.clear();
|
||||||
refreshFooter();
|
refreshFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
var elSortOrder = {
|
var elSortOrder = {
|
||||||
name: document.querySelector('#entity-name .sort-order'),
|
name: document.querySelector('#entity-name .sort-order'),
|
||||||
type: document.querySelector('#entity-type .sort-order'),
|
type: document.querySelector('#entity-type .sort-order'),
|
||||||
url: document.querySelector('#entity-url .sort-order'),
|
url: document.querySelector('#entity-url .sort-order'),
|
||||||
locked: document.querySelector('#entity-locked .sort-order'),
|
locked: document.querySelector('#entity-locked .sort-order'),
|
||||||
visible: document.querySelector('#entity-visible .sort-order'),
|
visible: document.querySelector('#entity-visible .sort-order'),
|
||||||
verticesCount: document.querySelector('#entity-verticesCount .sort-order'),
|
verticesCount: document.querySelector('#entity-verticesCount .sort-order'),
|
||||||
texturesCount: document.querySelector('#entity-texturesCount .sort-order'),
|
texturesCount: document.querySelector('#entity-texturesCount .sort-order'),
|
||||||
texturesSize: document.querySelector('#entity-texturesSize .sort-order'),
|
texturesSize: document.querySelector('#entity-texturesSize .sort-order'),
|
||||||
hasTransparent: document.querySelector('#entity-hasTransparent .sort-order'),
|
hasTransparent: document.querySelector('#entity-hasTransparent .sort-order'),
|
||||||
isBaked: document.querySelector('#entity-isBaked .sort-order'),
|
isBaked: document.querySelector('#entity-isBaked .sort-order'),
|
||||||
drawCalls: document.querySelector('#entity-drawCalls .sort-order'),
|
drawCalls: document.querySelector('#entity-drawCalls .sort-order'),
|
||||||
hasScript: document.querySelector('#entity-hasScript .sort-order'),
|
hasScript: document.querySelector('#entity-hasScript .sort-order'),
|
||||||
}
|
}
|
||||||
function setSortColumn(column) {
|
function setSortColumn(column) {
|
||||||
if (currentSortColumn == column) {
|
if (currentSortColumn == column) {
|
||||||
currentSortOrder = currentSortOrder == "asc" ? "desc" : "asc";
|
currentSortOrder = currentSortOrder == "asc" ? "desc" : "asc";
|
||||||
} else {
|
} else {
|
||||||
elSortOrder[currentSortColumn].innerHTML = "";
|
elSortOrder[currentSortColumn].innerHTML = "";
|
||||||
currentSortColumn = column;
|
currentSortColumn = column;
|
||||||
currentSortOrder = "asc";
|
currentSortOrder = "asc";
|
||||||
}
|
}
|
||||||
elSortOrder[column].innerHTML = currentSortOrder == "asc" ? ASCENDING_STRING : DESCENDING_STRING;
|
elSortOrder[column].innerHTML = currentSortOrder == "asc" ? ASCENDING_STRING : DESCENDING_STRING;
|
||||||
entityList.sort(currentSortColumn, { order: currentSortOrder });
|
entityList.sort(currentSortColumn, { order: currentSortOrder });
|
||||||
}
|
}
|
||||||
setSortColumn('type');
|
setSortColumn('type');
|
||||||
|
|
||||||
function refreshEntities() {
|
function refreshEntities() {
|
||||||
clearEntities();
|
clearEntities();
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshFooter() {
|
function refreshFooter() {
|
||||||
if (selectedEntities.length > 1) {
|
if (selectedEntities.length > 1) {
|
||||||
elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected";
|
elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected";
|
||||||
} else if (selectedEntities.length === 1) {
|
} else if (selectedEntities.length === 1) {
|
||||||
elFooter.firstChild.nodeValue = "1 entity selected";
|
elFooter.firstChild.nodeValue = "1 entity selected";
|
||||||
} else if (entityList.visibleItems.length === 1) {
|
} else if (entityList.visibleItems.length === 1) {
|
||||||
elFooter.firstChild.nodeValue = "1 entity found";
|
elFooter.firstChild.nodeValue = "1 entity found";
|
||||||
} else {
|
} else {
|
||||||
elFooter.firstChild.nodeValue = entityList.visibleItems.length + " entities found";
|
elFooter.firstChild.nodeValue = entityList.visibleItems.length + " entities found";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshEntityListObject() {
|
function refreshEntityListObject() {
|
||||||
refreshEntityListTimer = null;
|
refreshEntityListTimer = null;
|
||||||
entityList.sort(currentSortColumn, { order: currentSortOrder });
|
entityList.sort(currentSortColumn, { order: currentSortOrder });
|
||||||
entityList.search(elFilter.value);
|
entityList.search(elFilter.value);
|
||||||
refreshFooter();
|
refreshFooter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSelectedEntities(selectedIDs) {
|
function updateSelectedEntities(selectedIDs) {
|
||||||
var notFound = false;
|
var notFound = false;
|
||||||
for (var id in entities) {
|
for (var id in entities) {
|
||||||
entities[id].el.className = '';
|
entities[id].el.className = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedEntities = [];
|
selectedEntities = [];
|
||||||
for (var i = 0; i < selectedIDs.length; i++) {
|
for (var i = 0; i < selectedIDs.length; i++) {
|
||||||
var id = selectedIDs[i];
|
var id = selectedIDs[i];
|
||||||
selectedEntities.push(id);
|
selectedEntities.push(id);
|
||||||
if (id in entities) {
|
if (id in entities) {
|
||||||
var entity = entities[id];
|
var entity = entities[id];
|
||||||
entity.el.className = 'selected';
|
entity.el.className = 'selected';
|
||||||
} else {
|
} else {
|
||||||
notFound = true;
|
notFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshFooter();
|
refreshFooter();
|
||||||
|
|
||||||
return notFound;
|
return notFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
elRefresh.onclick = function() {
|
elRefresh.onclick = function() {
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
}
|
}
|
||||||
elToggleLocked.onclick = function () {
|
elToggleLocked.onclick = function () {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleLocked' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleLocked' }));
|
||||||
}
|
}
|
||||||
elToggleVisible.onclick = function () {
|
elToggleVisible.onclick = function () {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleVisible' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'toggleVisible' }));
|
||||||
}
|
}
|
||||||
elExport.onclick = function() {
|
elExport.onclick = function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'export'}));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'export'}));
|
||||||
}
|
}
|
||||||
elPal.onclick = function () {
|
elPal.onclick = function () {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'pal' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'pal' }));
|
||||||
}
|
}
|
||||||
elDelete.onclick = function() {
|
elDelete.onclick = function() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("keydown", function (keyDownEvent) {
|
document.addEventListener("keydown", function (keyDownEvent) {
|
||||||
if (keyDownEvent.target.nodeName === "INPUT") {
|
if (keyDownEvent.target.nodeName === "INPUT") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var keyCode = keyDownEvent.keyCode;
|
var keyCode = keyDownEvent.keyCode;
|
||||||
if (keyCode === DELETE) {
|
if (keyCode === DELETE) {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' }));
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
}
|
}
|
||||||
if (keyDownEvent.keyCode === KEY_P && keyDownEvent.ctrlKey) {
|
if (keyDownEvent.keyCode === KEY_P && keyDownEvent.ctrlKey) {
|
||||||
if (keyDownEvent.shiftKey) {
|
if (keyDownEvent.shiftKey) {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' }));
|
||||||
} else {
|
} else {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
var isFilterInView = false;
|
var isFilterInView = false;
|
||||||
var FILTER_IN_VIEW_ATTRIBUTE = "pressed";
|
var FILTER_IN_VIEW_ATTRIBUTE = "pressed";
|
||||||
elNoEntitiesInView.style.display = "none";
|
elNoEntitiesInView.style.display = "none";
|
||||||
elInView.onclick = function () {
|
elInView.onclick = function () {
|
||||||
isFilterInView = !isFilterInView;
|
isFilterInView = !isFilterInView;
|
||||||
if (isFilterInView) {
|
if (isFilterInView) {
|
||||||
elInView.setAttribute(FILTER_IN_VIEW_ATTRIBUTE, FILTER_IN_VIEW_ATTRIBUTE);
|
elInView.setAttribute(FILTER_IN_VIEW_ATTRIBUTE, FILTER_IN_VIEW_ATTRIBUTE);
|
||||||
elNoEntitiesInView.style.display = "inline";
|
elNoEntitiesInView.style.display = "inline";
|
||||||
} else {
|
} else {
|
||||||
elInView.removeAttribute(FILTER_IN_VIEW_ATTRIBUTE);
|
elInView.removeAttribute(FILTER_IN_VIEW_ATTRIBUTE);
|
||||||
elNoEntitiesInView.style.display = "none";
|
elNoEntitiesInView.style.display = "none";
|
||||||
}
|
}
|
||||||
EventBridge.emitWebEvent(JSON.stringify({ type: "filterInView", filterInView: isFilterInView }));
|
EventBridge.emitWebEvent(JSON.stringify({ type: "filterInView", filterInView: isFilterInView }));
|
||||||
refreshEntities();
|
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 }));
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
elNoEntitiesRadius.firstChild.nodeValue = elRadius.value;
|
elNoEntitiesRadius.firstChild.nodeValue = elRadius.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.EventBridge !== undefined) {
|
if (window.EventBridge !== undefined) {
|
||||||
EventBridge.scriptEventReceived.connect(function(data) {
|
EventBridge.scriptEventReceived.connect(function(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
|
||||||
if (data.type === "clearEntityList") {
|
if (data.type === "clearEntityList") {
|
||||||
clearEntities();
|
clearEntities();
|
||||||
} else if (data.type == "selectionUpdate") {
|
} else if (data.type == "selectionUpdate") {
|
||||||
var notFound = updateSelectedEntities(data.selectedIDs);
|
var notFound = updateSelectedEntities(data.selectedIDs);
|
||||||
if (notFound) {
|
if (notFound) {
|
||||||
refreshEntities();
|
refreshEntities();
|
||||||
}
|
}
|
||||||
} else if (data.type === "update" && data.selectedIDs !== undefined) {
|
} else if (data.type === "update" && data.selectedIDs !== undefined) {
|
||||||
var newEntities = data.entities;
|
var newEntities = data.entities;
|
||||||
if (newEntities && newEntities.length == 0) {
|
if (newEntities && newEntities.length == 0) {
|
||||||
elNoEntitiesMessage.style.display = "block";
|
elNoEntitiesMessage.style.display = "block";
|
||||||
elFooter.firstChild.nodeValue = "0 entities found";
|
elFooter.firstChild.nodeValue = "0 entities found";
|
||||||
} else if (newEntities) {
|
} else if (newEntities) {
|
||||||
elNoEntitiesMessage.style.display = "none";
|
elNoEntitiesMessage.style.display = "none";
|
||||||
for (var i = 0; i < newEntities.length; i++) {
|
for (var i = 0; i < newEntities.length; i++) {
|
||||||
var id = newEntities[i].id;
|
var id = newEntities[i].id;
|
||||||
addEntity(id, newEntities[i].name, newEntities[i].type, newEntities[i].url,
|
addEntity(id, newEntities[i].name, newEntities[i].type, newEntities[i].url,
|
||||||
newEntities[i].locked ? LOCKED_GLYPH : null,
|
newEntities[i].locked ? LOCKED_GLYPH : null,
|
||||||
newEntities[i].visible ? VISIBLE_GLYPH : null,
|
newEntities[i].visible ? VISIBLE_GLYPH : null,
|
||||||
newEntities[i].verticesCount, newEntities[i].texturesCount, newEntities[i].texturesSize,
|
newEntities[i].verticesCount, newEntities[i].texturesCount, newEntities[i].texturesSize,
|
||||||
newEntities[i].hasTransparent ? TRANSPARENCY_GLYPH : null,
|
newEntities[i].hasTransparent ? TRANSPARENCY_GLYPH : null,
|
||||||
newEntities[i].isBaked ? BAKED_GLYPH : null,
|
newEntities[i].isBaked ? BAKED_GLYPH : null,
|
||||||
newEntities[i].drawCalls,
|
newEntities[i].drawCalls,
|
||||||
newEntities[i].hasScript ? SCRIPT_GLYPH : null);
|
newEntities[i].hasScript ? SCRIPT_GLYPH : null);
|
||||||
}
|
}
|
||||||
updateSelectedEntities(data.selectedIDs);
|
updateSelectedEntities(data.selectedIDs);
|
||||||
scheduleRefreshEntityList();
|
scheduleRefreshEntityList();
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
} else if (data.type === "removeEntities" && data.deletedIDs !== undefined && data.selectedIDs !== undefined) {
|
} else if (data.type === "removeEntities" && data.deletedIDs !== undefined && data.selectedIDs !== undefined) {
|
||||||
removeEntities(data.deletedIDs);
|
removeEntities(data.deletedIDs);
|
||||||
updateSelectedEntities(data.selectedIDs);
|
updateSelectedEntities(data.selectedIDs);
|
||||||
scheduleRefreshEntityList();
|
scheduleRefreshEntityList();
|
||||||
} else if (data.type === "deleted" && data.ids) {
|
} else if (data.type === "deleted" && data.ids) {
|
||||||
removeEntities(data.ids);
|
removeEntities(data.ids);
|
||||||
refreshFooter();
|
refreshFooter();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTimeout(refreshEntities, 1000);
|
setTimeout(refreshEntities, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
// Take up available window space
|
// Take up available window space
|
||||||
elEntityTableScroll.style.height = window.innerHeight - 207;
|
elEntityTableScroll.style.height = window.innerHeight - 207;
|
||||||
|
|
||||||
var SCROLLABAR_WIDTH = 21;
|
var SCROLLABAR_WIDTH = 21;
|
||||||
var tds = document.querySelectorAll("#entity-table-body tr:first-child td");
|
var tds = document.querySelectorAll("#entity-table-body tr:first-child td");
|
||||||
var ths = document.querySelectorAll("#entity-table thead th");
|
var ths = document.querySelectorAll("#entity-table thead th");
|
||||||
if (tds.length >= ths.length) {
|
if (tds.length >= ths.length) {
|
||||||
// Update the widths of the header cells to match the body
|
// Update the widths of the header cells to match the body
|
||||||
for (var i = 0; i < ths.length; i++) {
|
for (var i = 0; i < ths.length; i++) {
|
||||||
ths[i].width = tds[i].offsetWidth;
|
ths[i].width = tds[i].offsetWidth;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Reasonable widths if nothing is displayed
|
// Reasonable widths if nothing is displayed
|
||||||
var tableWidth = document.getElementById("entity-table").offsetWidth - SCROLLABAR_WIDTH;
|
var tableWidth = document.getElementById("entity-table").offsetWidth - SCROLLABAR_WIDTH;
|
||||||
if (showExtraInfo) {
|
if (showExtraInfo) {
|
||||||
ths[0].width = 0.10 * tableWidth;
|
ths[0].width = 0.10 * tableWidth;
|
||||||
ths[1].width = 0.20 * tableWidth;
|
ths[1].width = 0.20 * tableWidth;
|
||||||
ths[2].width = 0.20 * tableWidth;
|
ths[2].width = 0.20 * tableWidth;
|
||||||
ths[3].width = 0.04 * tableWidth;
|
ths[3].width = 0.04 * tableWidth;
|
||||||
ths[4].width = 0.04 * tableWidth;
|
ths[4].width = 0.04 * tableWidth;
|
||||||
ths[5].width = 0.08 * tableWidth;
|
ths[5].width = 0.08 * tableWidth;
|
||||||
ths[6].width = 0.08 * tableWidth;
|
ths[6].width = 0.08 * tableWidth;
|
||||||
ths[7].width = 0.10 * tableWidth;
|
ths[7].width = 0.10 * tableWidth;
|
||||||
ths[8].width = 0.04 * tableWidth;
|
ths[8].width = 0.04 * tableWidth;
|
||||||
ths[9].width = 0.08 * tableWidth;
|
ths[9].width = 0.08 * tableWidth;
|
||||||
ths[10].width = 0.04 * tableWidth + SCROLLABAR_WIDTH;
|
ths[10].width = 0.04 * tableWidth + SCROLLABAR_WIDTH;
|
||||||
} else {
|
} else {
|
||||||
ths[0].width = 0.16 * tableWidth;
|
ths[0].width = 0.16 * tableWidth;
|
||||||
ths[1].width = 0.34 * tableWidth;
|
ths[1].width = 0.34 * tableWidth;
|
||||||
ths[2].width = 0.34 * tableWidth;
|
ths[2].width = 0.34 * tableWidth;
|
||||||
ths[3].width = 0.08 * tableWidth;
|
ths[3].width = 0.08 * tableWidth;
|
||||||
ths[4].width = 0.08 * tableWidth;
|
ths[4].width = 0.08 * tableWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.onresize = resize;
|
window.onresize = resize;
|
||||||
elFilter.onchange = resize;
|
elFilter.onchange = resize;
|
||||||
elFilter.onblur = refreshFooter;
|
elFilter.onblur = refreshFooter;
|
||||||
|
|
||||||
|
|
||||||
var showExtraInfo = false;
|
var showExtraInfo = false;
|
||||||
var COLLAPSE_EXTRA_INFO = "E";
|
var COLLAPSE_EXTRA_INFO = "E";
|
||||||
var EXPAND_EXTRA_INFO = "D";
|
var EXPAND_EXTRA_INFO = "D";
|
||||||
|
|
||||||
function toggleInfo(event) {
|
function toggleInfo(event) {
|
||||||
showExtraInfo = !showExtraInfo;
|
showExtraInfo = !showExtraInfo;
|
||||||
if (showExtraInfo) {
|
if (showExtraInfo) {
|
||||||
elEntityTable.className = "showExtraInfo";
|
elEntityTable.className = "showExtraInfo";
|
||||||
elInfoToggleGlyph.innerHTML = COLLAPSE_EXTRA_INFO;
|
elInfoToggleGlyph.innerHTML = COLLAPSE_EXTRA_INFO;
|
||||||
} else {
|
} else {
|
||||||
elEntityTable.className = "";
|
elEntityTable.className = "";
|
||||||
elInfoToggleGlyph.innerHTML = EXPAND_EXTRA_INFO;
|
elInfoToggleGlyph.innerHTML = EXPAND_EXTRA_INFO;
|
||||||
}
|
}
|
||||||
resize();
|
resize();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
elInfoToggle.addEventListener("click", toggleInfo, true);
|
elInfoToggle.addEventListener("click", toggleInfo, true);
|
||||||
|
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
});
|
});
|
||||||
|
|
||||||
augmentSpinButtons();
|
augmentSpinButtons();
|
||||||
|
|
||||||
// Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked
|
// Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked
|
||||||
document.addEventListener("contextmenu", function (event) {
|
document.addEventListener("contextmenu", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue