|
@@ -36140,7 +36140,7 @@ var BABYLON;
|
|
|
var endFrame = frameRate * (duration / 1000);
|
|
|
transition.setKeys([{
|
|
|
frame: 0,
|
|
|
- value: host[property]
|
|
|
+ value: host[property].clone ? host[property].clone() : host[property]
|
|
|
},
|
|
|
{
|
|
|
frame: endFrame,
|
|
@@ -48190,14 +48190,15 @@ var BABYLON;
|
|
|
if (this._filesToLoad && this._filesToLoad.length > 0) {
|
|
|
var files_1 = [];
|
|
|
var folders = [];
|
|
|
+ var items = event.dataTransfer ? event.dataTransfer.items : null;
|
|
|
for (var i = 0; i < this._filesToLoad.length; i++) {
|
|
|
var fileToLoad = this._filesToLoad[i];
|
|
|
var name_1 = fileToLoad.name.toLowerCase();
|
|
|
var type = fileToLoad.type;
|
|
|
var entry = void 0;
|
|
|
fileToLoad.correctName = name_1;
|
|
|
- if (event.dataTransfer && event.dataTransfer.items) {
|
|
|
- var item = event.dataTransfer.items[i];
|
|
|
+ if (items) {
|
|
|
+ var item = items[i];
|
|
|
if (item.getAsEntry) {
|
|
|
entry = item.getAsEntry();
|
|
|
}
|
|
@@ -69695,8 +69696,7 @@ var BABYLON;
|
|
|
var FramingBehavior = (function () {
|
|
|
function FramingBehavior() {
|
|
|
this._mode = FramingBehavior.IgnoreBoundsSizeMode;
|
|
|
- this._relativeRadius = 1.0;
|
|
|
- this._elevation = 0.3;
|
|
|
+ this._radiusScale = 1.0;
|
|
|
this._positionY = 0;
|
|
|
this._defaultElevation = 0.3;
|
|
|
this._elevationReturnTime = 1500;
|
|
@@ -69734,47 +69734,31 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
- Object.defineProperty(FramingBehavior.prototype, "relativeRadius", {
|
|
|
+ Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
|
|
|
/**
|
|
|
- * Gets the radius of the camera relative to the target's bounding box.
|
|
|
+ * Gets the scale applied to the radius
|
|
|
*/
|
|
|
get: function () {
|
|
|
- return this._relativeRadius;
|
|
|
+ return this._radiusScale;
|
|
|
},
|
|
|
/**
|
|
|
- * Sets the radius of the camera relative to the target's bounding box.
|
|
|
+ * Sets the scale applied to the radius (1 by default)
|
|
|
*/
|
|
|
set: function (radius) {
|
|
|
- this._relativeRadius = radius;
|
|
|
- },
|
|
|
- enumerable: true,
|
|
|
- configurable: true
|
|
|
- });
|
|
|
- Object.defineProperty(FramingBehavior.prototype, "elevation", {
|
|
|
- /**
|
|
|
- * Gets the elevation of the camera from the target, in radians.
|
|
|
- */
|
|
|
- get: function () {
|
|
|
- return this._elevation;
|
|
|
- },
|
|
|
- /**
|
|
|
- * Sets the elevation of the camera from the target, in radians.
|
|
|
- */
|
|
|
- set: function (elevation) {
|
|
|
- this._elevation = elevation;
|
|
|
+ this._radiusScale = radius;
|
|
|
},
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
Object.defineProperty(FramingBehavior.prototype, "positionY", {
|
|
|
/**
|
|
|
- * Gets the Y offset of the primary model from the camera's focus.
|
|
|
+ * Gets the Y offset of the primary mesh from the camera's focus.
|
|
|
*/
|
|
|
get: function () {
|
|
|
return this._positionY;
|
|
|
},
|
|
|
/**
|
|
|
- * Sets the Y offset of the primary model from the camera's focus.
|
|
|
+ * Sets the Y offset of the primary mesh from the camera's focus.
|
|
|
*/
|
|
|
set: function (positionY) {
|
|
|
this._positionY = positionY;
|
|
@@ -69836,13 +69820,13 @@ var BABYLON;
|
|
|
});
|
|
|
Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
|
|
|
/**
|
|
|
- * Gets the flag that indicates if user zooming should stop model animation.
|
|
|
+ * Gets the flag that indicates if user zooming should stop animation.
|
|
|
*/
|
|
|
get: function () {
|
|
|
return this._zoomStopsAnimation;
|
|
|
},
|
|
|
/**
|
|
|
- * Sets the flag that indicates if user zooming should stop model animation.
|
|
|
+ * Sets the flag that indicates if user zooming should stop animation.
|
|
|
*/
|
|
|
set: function (flag) {
|
|
|
this._zoomStopsAnimation = flag;
|
|
@@ -69852,13 +69836,13 @@ var BABYLON;
|
|
|
});
|
|
|
Object.defineProperty(FramingBehavior.prototype, "framingTime", {
|
|
|
/**
|
|
|
- * Gets the transition time when framing the model, in milliseconds
|
|
|
+ * Gets the transition time when framing the mesh, in milliseconds
|
|
|
*/
|
|
|
get: function () {
|
|
|
return this._framingTime;
|
|
|
},
|
|
|
/**
|
|
|
- * Sets the transition time when framing the model, in milliseconds
|
|
|
+ * Sets the transition time when framing the mesh, in milliseconds
|
|
|
*/
|
|
|
set: function (time) {
|
|
|
this._framingTime = time;
|
|
@@ -69909,8 +69893,8 @@ var BABYLON;
|
|
|
* @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
|
|
|
*/
|
|
|
FramingBehavior.prototype.zoomOnMesh = function (mesh, radius, applyToLowerLimit, framingPositionY, focusOnOriginXZ) {
|
|
|
- if (applyToLowerLimit === void 0) { applyToLowerLimit = false; }
|
|
|
- if (focusOnOriginXZ === void 0) { focusOnOriginXZ = true; }
|
|
|
+ if (applyToLowerLimit === void 0) { applyToLowerLimit = true; }
|
|
|
+ if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
|
|
|
if (framingPositionY == null) {
|
|
|
framingPositionY = this._positionY;
|
|
|
}
|
|
@@ -69923,12 +69907,11 @@ var BABYLON;
|
|
|
else {
|
|
|
zoomTarget = center.clone();
|
|
|
}
|
|
|
- // if (!this._vectorTransition) {
|
|
|
- // this._vectorTransition = Animation.CreateAnimation("target", Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
|
|
|
- // }
|
|
|
- // this._animatables.push(Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(),
|
|
|
- // 60, this._vectorTransition, this._framingTime));
|
|
|
- this._attachedCamera.setTarget(zoomTarget);
|
|
|
+ if (!this._vectorTransition) {
|
|
|
+ this._vectorTransition = BABYLON.Animation.CreateAnimation("target", BABYLON.Animation.ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
|
|
|
+ }
|
|
|
+ this._betaIsAnimating = true;
|
|
|
+ this._animatables.push(BABYLON.Animation.TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime));
|
|
|
// sets the radius and lower radius bounds
|
|
|
if (radius == null) {
|
|
|
// Small delta ensures camera is not always at lower zoom limit.
|
|
@@ -69943,14 +69926,14 @@ var BABYLON;
|
|
|
}
|
|
|
}
|
|
|
if (applyToLowerLimit) {
|
|
|
- this._attachedCamera.lowerRadiusLimit = radius;
|
|
|
+ this._attachedCamera.lowerRadiusLimit = mesh.getBoundingInfo().boundingSphere.radiusWorld;
|
|
|
+ ;
|
|
|
}
|
|
|
// transition to new radius
|
|
|
- // if (!this._radiusTransition) {
|
|
|
- // this._radiusTransition = Animation.CreateAnimation("radius", Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
|
|
|
- // }
|
|
|
- // this._animatables.push(Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(),
|
|
|
- // 60, this._radiusTransition, this._framingTime));
|
|
|
+ if (!this._radiusTransition) {
|
|
|
+ this._radiusTransition = BABYLON.Animation.CreateAnimation("radius", BABYLON.Animation.ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
|
|
|
+ }
|
|
|
+ this._animatables.push(BABYLON.Animation.TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime));
|
|
|
};
|
|
|
/**
|
|
|
* Calculates the lowest radius for the camera based on the bounding box of the mesh.
|
|
@@ -69966,8 +69949,7 @@ var BABYLON;
|
|
|
// (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
|
|
|
var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
|
|
|
// Horizon distance
|
|
|
- var sphereRadius = mesh.getBoundingInfo().boundingSphere.radiusWorld;
|
|
|
- var radius = radiusWithoutFraming * this._relativeRadius;
|
|
|
+ var radius = radiusWithoutFraming * this._radiusScale;
|
|
|
var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
|
|
|
var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
|
|
|
var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
|
|
@@ -70046,8 +70028,10 @@ var BABYLON;
|
|
|
FramingBehavior.prototype.stopAllAnimations = function () {
|
|
|
this._attachedCamera.animations = [];
|
|
|
while (this._animatables.length) {
|
|
|
- this._animatables[0].onAnimationEnd = null;
|
|
|
- this._animatables[0].stop();
|
|
|
+ if (this._animatables[0]) {
|
|
|
+ this._animatables[0].onAnimationEnd = null;
|
|
|
+ this._animatables[0].stop();
|
|
|
+ }
|
|
|
this._animatables.shift();
|
|
|
}
|
|
|
};
|
|
@@ -70070,11 +70054,11 @@ var BABYLON;
|
|
|
FramingBehavior.EasingMode = BABYLON.EasingFunction.EASINGMODE_EASEINOUT;
|
|
|
// Statics
|
|
|
/**
|
|
|
- * The camera can move all the way towards the model.
|
|
|
+ * The camera can move all the way towards the mesh.
|
|
|
*/
|
|
|
FramingBehavior.IgnoreBoundsSizeMode = 0;
|
|
|
/**
|
|
|
- * The camera is not allowed to zoom closer to the model than the point at which the adjusted bounding sphere touches the frustum sides
|
|
|
+ * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
|
|
|
*/
|
|
|
FramingBehavior.FitFrustumSidesMode = 1;
|
|
|
return FramingBehavior;
|
|
@@ -70103,6 +70087,7 @@ var BABYLON;
|
|
|
* Length of the distance animated by the transition when upper radius is reached
|
|
|
*/
|
|
|
this.upperRadiusTransitionRange = -2;
|
|
|
+ this._autoTransitionRange = false;
|
|
|
// Animations
|
|
|
this._radiusIsAnimating = false;
|
|
|
this._radiusBounceTransition = null;
|
|
@@ -70115,6 +70100,42 @@ var BABYLON;
|
|
|
enumerable: true,
|
|
|
configurable: true
|
|
|
});
|
|
|
+ Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
|
|
|
+ /**
|
|
|
+ * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
|
|
|
+ */
|
|
|
+ get: function () {
|
|
|
+ return this._autoTransitionRange;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
|
|
|
+ * Transition ranges will be set to 5% of the bounding box diagonal in world space
|
|
|
+ */
|
|
|
+ set: function (value) {
|
|
|
+ var _this = this;
|
|
|
+ if (this._autoTransitionRange === value) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._autoTransitionRange = value;
|
|
|
+ var camera = this._attachedCamera;
|
|
|
+ if (value) {
|
|
|
+ this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
|
|
|
+ if (!mesh) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mesh.computeWorldMatrix(true);
|
|
|
+ var diagonal = mesh.getBoundingInfo().diagonalLength;
|
|
|
+ _this.lowerRadiusTransitionRange = diagonal * 0.05;
|
|
|
+ _this.upperRadiusTransitionRange = diagonal * 0.05;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else if (this._onMeshTargetChangedObserver) {
|
|
|
+ camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ enumerable: true,
|
|
|
+ configurable: true
|
|
|
+ });
|
|
|
BouncingBehavior.prototype.attach = function (camera) {
|
|
|
var _this = this;
|
|
|
this._attachedCamera = camera;
|
|
@@ -70131,6 +70152,9 @@ var BABYLON;
|
|
|
};
|
|
|
BouncingBehavior.prototype.detach = function (camera) {
|
|
|
camera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
|
|
|
+ if (this._onMeshTargetChangedObserver) {
|
|
|
+ camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
|
|
|
+ }
|
|
|
};
|
|
|
/**
|
|
|
* Checks if the camera radius is at the specified limit. Takes into account animation locks.
|