Skip to content

Commit

Permalink
Adjust frustum when morphing and when the camera is above a certain h…
Browse files Browse the repository at this point in the history
…eight.
  • Loading branch information
bagnell committed Mar 13, 2017
1 parent b0f06c5 commit e13bc3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -985,11 +985,15 @@ define([
var pickGlobeScratchRay = new Ray();
var scratchRayIntersection = new Cartesian3();

Camera.prototype._adjustOrthographicFrustum = function() {
Camera.prototype._adjustOrthographicFrustum = function(zooming) {
if (!(this.frustum instanceof OrthographicFrustum)) {
return;
}

if (!zooming && this._positionCartographic.height < 150000.0) {
return;
}

if (!Matrix4.equals(Matrix4.IDENTITY, this.transform)) {
this.frustum.width = Cartesian3.magnitude(this.position);
return;
Expand All @@ -1012,7 +1016,7 @@ define([
}

if (!defined(globe) || (!defined(rayIntersection))) {
var distance = this.positionCartographic.height;
var distance = Math.max(this.positionCartographic.height, 0.0);
this.frustum.width = distance;
}
};
Expand Down Expand Up @@ -1041,7 +1045,7 @@ define([

camera._setTransform(currentTransform);

camera._adjustOrthographicFrustum();
camera._adjustOrthographicFrustum(true);
}

function setViewCV(camera, position,hpr, convert) {
Expand All @@ -1067,7 +1071,7 @@ define([

camera._setTransform(currentTransform);

camera._adjustOrthographicFrustum();
camera._adjustOrthographicFrustum(true);
}

function setView2D(camera, position, hpr, convert) {
Expand Down Expand Up @@ -1475,7 +1479,7 @@ define([
if (this._mode === SceneMode.SCENE2D) {
clampMove2D(this, cameraPosition);
}
this._adjustOrthographicFrustum();
this._adjustOrthographicFrustum(true);
};

/**
Expand Down Expand Up @@ -1691,6 +1695,8 @@ define([
Matrix3.multiplyByVector(rotation, this.up, this.up);
Cartesian3.cross(this.direction, this.up, this.right);
Cartesian3.cross(this.right, this.direction, this.up);

this._adjustOrthographicFrustum(false);
};

/**
Expand Down Expand Up @@ -2039,7 +2045,7 @@ define([
Cartesian3.cross(this.right, this.direction, this.up);
Cartesian3.normalize(this.up, this.up);

this._adjustOrthographicFrustum();
this._adjustOrthographicFrustum(true);
};

var viewRectangle3DCartographic1 = new Cartographic();
Expand Down
2 changes: 2 additions & 0 deletions Source/Scene/SceneTransitioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ define([
columbusViewMorph(startUp, endUp, value.time, camera.up);
Cartesian3.cross(camera.direction, camera.up, camera.right);
Cartesian3.normalize(camera.right, camera.right);
camera._adjustOrthographicFrustum(true);
}

function updateHeight(camera, height) {
Expand Down Expand Up @@ -795,6 +796,7 @@ define([
columbusViewMorph(startUp, endUp, value.time, camera.up);
Cartesian3.cross(camera.direction, camera.up, camera.right);
Cartesian3.normalize(camera.right, camera.right);
camera._adjustOrthographicFrustum(true);
}
var tween = scene.tweens.add({
duration : duration,
Expand Down

0 comments on commit e13bc3d

Please sign in to comment.