Skip to content

Commit

Permalink
Treat frustum changes as camera changes in Scene#render
Browse files Browse the repository at this point in the history
Before this change, the user could update the frustum but not the camera
by resizing the viewer. The Scene would continue to render even when
requestRenderMode was enabled because it recognized the frustum had
changed, but would not update the cached camera to mark the change as
handled. This commit changes cameraEqual (in Scene.js) to take into
account the camera frustum.

Fixes #6812
  • Loading branch information
Luke San Antonio Bialecki committed Jul 19, 2018
1 parent c7a1b0c commit 3fa9b0e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,8 @@ define([
Cartesian3.equalsEpsilon(camera0.direction, camera1.direction, epsilon) &&
Cartesian3.equalsEpsilon(camera0.up, camera1.up, epsilon) &&
Cartesian3.equalsEpsilon(camera0.right, camera1.right, epsilon) &&
Matrix4.equalsEpsilon(camera0.transform, camera1.transform, epsilon);
Matrix4.equalsEpsilon(camera0.transform, camera1.transform, epsilon) &&
camera0.frustum.equalsEpsilon(camera1.frustum, epsilon);
}

function updateDerivedCommands(scene, command) {
Expand Down Expand Up @@ -3172,13 +3173,17 @@ define([

function checkForCameraUpdates(scene) {
var camera = scene._camera;
if (!cameraEqual(camera, scene._cameraClone, CesiumMath.EPSILON15)) {
var cameraClone = scene._cameraClone;

scene._frustumChanged = !camera.frustum.equals(cameraClone.frustum);

if (!cameraEqual(camera, cameraClone, CesiumMath.EPSILON15)) {
if (!scene._cameraStartFired) {
camera.moveStart.raiseEvent();
scene._cameraStartFired = true;
}
scene._cameraMovedTime = getTimestamp();
Camera.clone(camera, scene._cameraClone);
Camera.clone(camera, cameraClone);

return true;
}
Expand Down Expand Up @@ -3310,10 +3315,8 @@ define([
tryAndCatchError(this, time, update);
this._postUpdate.raiseEvent(this, time);

this._frustumChanged = !this._camera.frustum.equals(this._cameraClone.frustum);

var cameraChanged = checkForCameraUpdates(this);
var shouldRender = !this.requestRenderMode || this._renderRequested || cameraChanged || this._frustumChanged || this._logDepthBufferDirty || (this.mode === SceneMode.MORPHING);
var shouldRender = !this.requestRenderMode || this._renderRequested || cameraChanged || this._logDepthBufferDirty || (this.mode === SceneMode.MORPHING);
if (!shouldRender && defined(this.maximumRenderTimeChange) && defined(this._lastRenderTime)) {
var difference = Math.abs(JulianDate.secondsDifference(this._lastRenderTime, time));
shouldRender = shouldRender || difference > this.maximumRenderTimeChange;
Expand Down

0 comments on commit 3fa9b0e

Please sign in to comment.