From 3fa9b0e89b55b0b737d1817dd3ee1fb1d94ed307 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 d003f7eaec33..3580672a054c 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) { @@ -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; } @@ -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;