mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
Merge pull request #3529 from huffman/19903
CR for Job #19903 - When you bring in an FBX apply the default scale to the model
This commit is contained in:
commit
3283c861b1
1 changed files with 26 additions and 1 deletions
|
@ -1215,19 +1215,44 @@ var toolBar = (function () {
|
||||||
Overlays.editOverlay(loadFileMenuItem, { visible: active });
|
Overlays.editOverlay(loadFileMenuItem, { visible: active });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var RESIZE_INTERVAL = 50;
|
||||||
|
var RESIZE_TIMEOUT = 20000;
|
||||||
|
var RESIZE_MAX_CHECKS = RESIZE_TIMEOUT / RESIZE_INTERVAL;
|
||||||
function addModel(url) {
|
function addModel(url) {
|
||||||
var position;
|
var position;
|
||||||
|
|
||||||
position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
position = Vec3.sum(MyAvatar.position, Vec3.multiply(Quat.getFront(MyAvatar.orientation), SPAWN_DISTANCE));
|
||||||
|
|
||||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||||
Entities.addEntity({
|
var entityId = Entities.addEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
position: position,
|
position: position,
|
||||||
dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION },
|
dimensions: { x: DEFAULT_DIMENSION, y: DEFAULT_DIMENSION, z: DEFAULT_DIMENSION },
|
||||||
modelURL: url
|
modelURL: url
|
||||||
});
|
});
|
||||||
print("Model added: " + url);
|
print("Model added: " + url);
|
||||||
|
|
||||||
|
var checkCount = 0;
|
||||||
|
function resize() {
|
||||||
|
var entityProperties = Entities.getEntityProperties(entityId);
|
||||||
|
var naturalDimensions = entityProperties.naturalDimensions;
|
||||||
|
|
||||||
|
checkCount++;
|
||||||
|
|
||||||
|
if (naturalDimensions.x == 0 && naturalDimensions.y == 0 && naturalDimensions.z == 0) {
|
||||||
|
if (checkCount < RESIZE_MAX_CHECKS) {
|
||||||
|
Script.setTimeout(resize, RESIZE_INTERVAL);
|
||||||
|
} else {
|
||||||
|
print("Resize failed: timed out waiting for model (" + url + ") to load");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
entityProperties.dimensions = naturalDimensions;
|
||||||
|
Entities.editEntity(entityId, entityProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.setTimeout(resize, RESIZE_INTERVAL);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
print("Can't add model: Model would be out of bounds.");
|
print("Can't add model: Model would be out of bounds.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue