Merge pull request #16502 from MiladNazeri/dev-2718/models-brought-in-at-incorrect-dimensions

dev-2718/models-brought-in-at-incorrect-dimensions
This commit is contained in:
Zach Fox 2019-11-15 15:54:08 -08:00 committed by GitHub
commit 3b9a8b426f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -569,14 +569,13 @@ var toolBar = (function () {
}
}
entityID = Entities.addEntity(properties);
SelectionManager.addEntity(entityID, false, this);
SelectionManager.saveProperties();
pushCommandForSelections([{
entityID: entityID,
properties: properties
}], [], true);
if (type === "Model") {
properties.visible = false;
}
entityID = Entities.addEntity(properties);
var dimensionsCheckCallback = function(){
var POST_ADJUST_ENTITY_TYPES = ["Model"];
if (POST_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) {
// Adjust position of entity per bounding box after it has been created and auto-resized.
@ -602,6 +601,34 @@ var toolBar = (function () {
};
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
}
}
// Make sure the entity is loaded before we try to figure out
// its dimensions.
var MAX_LOADED_CHECKS = 10;
var LOADED_CHECK_INTERVAL = 100;
var isLoadedCheckCount = 0;
var entityIsLoadedCheck = function() {
isLoadedCheckCount++;
if (isLoadedCheckCount === MAX_LOADED_CHECKS || Entities.isLoaded(entityID)) {
var naturalDimensions = Entities.getEntityProperties(entityID, "naturalDimensions").naturalDimensions
Entities.editEntity(entityID, {
visible: true,
dimensions: naturalDimensions
})
dimensionsCheckCallback();
return;
}
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
}
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
SelectionManager.addEntity(entityID, false, this);
SelectionManager.saveProperties();
pushCommandForSelections([{
entityID: entityID,
properties: properties
}], [], true);
} else {
Window.notifyEditError("Can't create " + properties.type + ": " +
properties.type + " would be out of bounds.");