Hello,
I don't know if this is something that could be merged into github but we had some projects (and therefore customers) that
were highly loaded with objects, thus a bit slow in rendering.
The camera inertia was then to long lasting to control the camera if you know what I mean.
This is what I've changed to handle this:
// Inertia
var engineDelta = Math.min(this.getEngine().deltaTime,100), inertiaFactor = Math.min(1,16.66666 / engineDelta);
if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
this.alpha += (this.beta <= 0 ? -this.inertialAlphaOffset : this.inertialAlphaOffset) / inertiaFactor;
this.beta += this.inertialBetaOffset / inertiaFactor;
this.radius -= this.inertialRadiusOffset / inertiaFactor;
this.inertialAlphaOffset *= this.inertia * inertiaFactor;
this.inertialBetaOffset *= this.inertia * inertiaFactor;
this.inertialRadiusOffset *= this.inertia * inertiaFactor;
if (Math.abs(this.inertialAlphaOffset) < BABYLON.Engine.Epsilon)
this.inertialAlphaOffset = 0;
if (Math.abs(this.inertialBetaOffset) < BABYLON.Engine.Epsilon)
this.inertialBetaOffset = 0;
if (Math.abs(this.inertialRadiusOffset) < BABYLON.Engine.Epsilon)
this.inertialRadiusOffset = 0;
}
// Panning inertia
if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
if (!this._localDirection) {
this._localDirection = BABYLON.Vector3.Zero();
this._transformedDirection = BABYLON.Vector3.Zero();
}
this.inertialPanningX *= this.inertia * inertiaFactor;
this.inertialPanningY *= this.inertia * inertiaFactor;
if (Math.abs(this.inertialPanningX) < BABYLON.Engine.Epsilon)
this.inertialPanningX = 0;
if (Math.abs(this.inertialPanningY) < BABYLON.Engine.Epsilon)
this.inertialPanningY = 0;
this._localDirection.copyFromFloats(this.inertialPanningX / inertiaFactor, this.inertialPanningY / inertiaFactor, 0);
this._viewMatrix.invertToRef(this._cameraTransformMatrix);
BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
this.target.addInPlace(this._transformedDirection);
}
It rotates by the given inertia amount depending on the time that proceeded during the renderings.
The
var engineDelta = Math.min(this.getEngine().deltaTime,100)
is to avoid big camera jumps on frames that last longer than 100ms. In our project the render loop doesn't run continuesly.
If someone likes to test this and/or push it into babylon I would be glad to have contributed a small thing :-)
If not it's also completely okay as it's only needed in our project(s)! ;-)
Best regards
Kevin