mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
Merge pull request #406 from kasenvr/fix/entity-size-on-create
Bugfix: Create app now uses proper dimensions on create
This commit is contained in:
commit
079c0c022e
1 changed files with 30 additions and 28 deletions
|
@ -579,33 +579,30 @@ var toolBar = (function () {
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
|
|
||||||
var dimensionsCheckCallback = function(){
|
var dimensionsCheckCallback = function(){
|
||||||
var POST_ADJUST_ENTITY_TYPES = ["Model"];
|
// Adjust position of entity per bounding box after it has been created and auto-resized.
|
||||||
if (POST_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) {
|
var initialDimensions = Entities.getEntityProperties(entityID, ["dimensions"]).dimensions;
|
||||||
// Adjust position of entity per bounding box after it has been created and auto-resized.
|
var DIMENSIONS_CHECK_INTERVAL = 200;
|
||||||
var initialDimensions = Entities.getEntityProperties(entityID, ["dimensions"]).dimensions;
|
var MAX_DIMENSIONS_CHECKS = 10;
|
||||||
var DIMENSIONS_CHECK_INTERVAL = 200;
|
var dimensionsCheckCount = 0;
|
||||||
var MAX_DIMENSIONS_CHECKS = 10;
|
var dimensionsCheckFunction = function () {
|
||||||
var dimensionsCheckCount = 0;
|
dimensionsCheckCount++;
|
||||||
var dimensionsCheckFunction = function () {
|
var properties = Entities.getEntityProperties(entityID, ["dimensions", "registrationPoint", "rotation"]);
|
||||||
dimensionsCheckCount++;
|
if (!Vec3.equal(properties.dimensions, initialDimensions)) {
|
||||||
var properties = Entities.getEntityProperties(entityID, ["dimensions", "registrationPoint", "rotation"]);
|
position = adjustPositionPerBoundingBox(position, direction, properties.registrationPoint,
|
||||||
if (!Vec3.equal(properties.dimensions, initialDimensions)) {
|
properties.dimensions, properties.rotation);
|
||||||
position = adjustPositionPerBoundingBox(position, direction, properties.registrationPoint,
|
position = grid.snapToSurface(grid.snapToGrid(position, false, properties.dimensions),
|
||||||
properties.dimensions, properties.rotation);
|
properties.dimensions);
|
||||||
position = grid.snapToSurface(grid.snapToGrid(position, false, properties.dimensions),
|
Entities.editEntity(entityID, {
|
||||||
properties.dimensions);
|
position: position
|
||||||
Entities.editEntity(entityID, {
|
});
|
||||||
position: position
|
selectionManager._update(false, this);
|
||||||
});
|
} else if (dimensionsCheckCount < MAX_DIMENSIONS_CHECKS) {
|
||||||
selectionManager._update(false, this);
|
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
||||||
} else if (dimensionsCheckCount < MAX_DIMENSIONS_CHECKS) {
|
}
|
||||||
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
};
|
||||||
}
|
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
||||||
};
|
|
||||||
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Make sure the entity is loaded before we try to figure out
|
// Make sure the model entity is loaded before we try to figure out
|
||||||
// its dimensions.
|
// its dimensions.
|
||||||
var MAX_LOADED_CHECKS = 10;
|
var MAX_LOADED_CHECKS = 10;
|
||||||
var LOADED_CHECK_INTERVAL = 100;
|
var LOADED_CHECK_INTERVAL = 100;
|
||||||
|
@ -613,7 +610,8 @@ var toolBar = (function () {
|
||||||
var entityIsLoadedCheck = function() {
|
var entityIsLoadedCheck = function() {
|
||||||
isLoadedCheckCount++;
|
isLoadedCheckCount++;
|
||||||
if (isLoadedCheckCount === MAX_LOADED_CHECKS || Entities.isLoaded(entityID)) {
|
if (isLoadedCheckCount === MAX_LOADED_CHECKS || Entities.isLoaded(entityID)) {
|
||||||
var naturalDimensions = Entities.getEntityProperties(entityID, "naturalDimensions").naturalDimensions
|
var naturalDimensions = Entities.getEntityProperties(entityID, "naturalDimensions").naturalDimensions;
|
||||||
|
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
visible: true,
|
visible: true,
|
||||||
dimensions: naturalDimensions
|
dimensions: naturalDimensions
|
||||||
|
@ -623,7 +621,11 @@ var toolBar = (function () {
|
||||||
}
|
}
|
||||||
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
|
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
|
|
||||||
|
var POST_ADJUST_ENTITY_TYPES = ["Model"];
|
||||||
|
if (POST_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) {
|
||||||
|
Script.setTimeout(entityIsLoadedCheck, LOADED_CHECK_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
SelectionManager.addEntity(entityID, false, this);
|
SelectionManager.addEntity(entityID, false, this);
|
||||||
SelectionManager.saveProperties();
|
SelectionManager.saveProperties();
|
||||||
|
|
Loading…
Reference in a new issue