mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
Fix models not scaling correctly when loading due to timeout.
This commit is contained in:
parent
585fb1939f
commit
3910448367
1 changed files with 7 additions and 3 deletions
|
@ -603,15 +603,19 @@ var toolBar = (function () {
|
||||||
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
Script.setTimeout(dimensionsCheckFunction, DIMENSIONS_CHECK_INTERVAL);
|
||||||
}
|
}
|
||||||
// Make sure the model 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. We need to give ample time to load the entity.
|
||||||
var MAX_LOADED_CHECKS = 10;
|
var MAX_LOADED_CHECKS = 100; // 100 * 100ms = 10 seconds.
|
||||||
var LOADED_CHECK_INTERVAL = 100;
|
var LOADED_CHECK_INTERVAL = 100;
|
||||||
var isLoadedCheckCount = 0;
|
var isLoadedCheckCount = 0;
|
||||||
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;
|
||||||
|
|
||||||
|
if (isLoadedCheckCount === MAX_LOADED_CHECKS) {
|
||||||
|
console.log("Model entity failed to load in time: " + (MAX_LOADED_CHECKS * LOADED_CHECK_INTERVAL) + " ... setting dimensions to: " + JSON.stringify(naturalDimensions))
|
||||||
|
}
|
||||||
|
|
||||||
Entities.editEntity(entityID, {
|
Entities.editEntity(entityID, {
|
||||||
visible: true,
|
visible: true,
|
||||||
dimensions: naturalDimensions
|
dimensions: naturalDimensions
|
||||||
|
|
Loading…
Reference in a new issue