Merge pull request #498 from overte-org/fix/create_app_perf

Fixed Create App performance when moving objects
This commit is contained in:
ksuprynowicz 2023-06-30 23:21:01 +02:00 committed by GitHub
commit 6b8f460423
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 14 deletions

View file

@ -156,7 +156,7 @@
selectionManager.addEventListener(function () {
selectionDisplay.updateHandles();
entityIconOverlayManager.updatePositions();
entityIconOverlayManager.updatePositions(selectionManager.selections);
entityShapeVisualizer.setEntities(selectionManager.selections);
});

View file

@ -109,6 +109,10 @@ var EntityListTool = function(shouldUseEditTabletApp, selectionManager) {
// ignore events that we emitted from the entity list itself
return;
}
// Otherwise this will emit tens of events every second when objects are moved.
if (!isSelectionUpdate) {
return;
}
var selectedIDs = [];
for (var i = 0; i < that.selectionManager.selections.length; i++) {

View file

@ -1082,8 +1082,8 @@ SelectionDisplay = (function() {
text: "",
textColor: { red: 0, green: 0, blue: 0 },
backgroundColor: { red: 255, green: 255, blue: 255 },
textAlpha: 0.7,
backgroundAlpha: 0.7,
textAlpha: 1.0,
backgroundAlpha: 1.0,
visible: false,
billboardMode: "full",
renderLayer: "front",

View file

@ -16,20 +16,33 @@ EntityIconOverlayManager = function(entityTypes, getOverlayPropertiesFunc) {
// Map from EntityItemID to EntityItemID object
var entityIDs = {};
function updateEntity(entityID) {
var properties = Entities.getEntityProperties(entityID);
var overlayProperties = {
position: properties.position
};
if (getOverlayPropertiesFunc) {
var customProperties = getOverlayPropertiesFunc(entityID, properties);
for (var key in customProperties) {
overlayProperties[key] = customProperties[key];
}
}
Entities.editEntity(entityOverlays[entityID], overlayProperties);
}
this.updatePositions = function(ids) {
for (var id in entityIDs) {
var entityID = entityIDs[id];
var properties = Entities.getEntityProperties(entityID);
var overlayProperties = {
position: properties.position
};
if (getOverlayPropertiesFunc) {
var customProperties = getOverlayPropertiesFunc(entityID, properties);
for (var key in customProperties) {
overlayProperties[key] = customProperties[key];
if (ids) {
for (var index in ids) {
var id = ids[index];
if (entityIDs[id]) {
updateEntity(entityIDs[id]);
}
}
Entities.editEntity(entityOverlays[entityID], overlayProperties);
} else {
for (var id in entityIDs) {
var entityID = entityIDs[id];
updateEntity(entityID);
}
}
};