From 39da67de9a5d6cb8ca0fdc58a017c87b2531e986 Mon Sep 17 00:00:00 2001 From: Luke San Antonio Bialecki Date: Thu, 19 Jul 2018 16:06:15 -0400 Subject: [PATCH] Treat frustum changes as camera changes in Scene#render 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 --- Source/Scene/Scene.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 5572b52d3447..034e49870814 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -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) { @@ -3171,13 +3172,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; } @@ -3309,10 +3314,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;