Skip to content

Commit a99bc64

Browse files
committed
CesiumWidget and Viewer requestRender specs
1 parent 72cacdb commit a99bc64

File tree

6 files changed

+56
-10
lines changed

6 files changed

+56
-10
lines changed

Source/Scene/PerformanceDisplay.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ define([
8989
* Update the display. This function should only be called once per frame, because
9090
* each call records a frame in the internal buffer and redraws the display.
9191
*
92-
* @param {Boolean} [renderedThisFrame] If provided, the FPS count will only update and display if true.
92+
* @param {Boolean} [renderedThisFrame=true] If provided, the FPS count will only update and display if true.
9393
*/
9494
PerformanceDisplay.prototype.update = function(renderedThisFrame) {
9595
var time = getTimestamp();

Source/Scene/Scene.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,7 @@ define([
218218
* @param {Number} [options.terrainExaggeration=1.0] A scalar used to exaggerate the terrain. Note that terrain exaggeration will not modify any other primitive as they are positioned relative to the ellipsoid.
219219
* @param {Boolean} [options.shadows=false] Determines if shadows are cast by the sun.
220220
* @param {MapMode2D} [options.mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
221-
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as
222-
* determined by changes within the scene. Enabling improves performance of the application, but requires using
223-
* {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases
224-
* after making changes to the scene in other parts of the API.
221+
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API.
225222
* @param {Number} [options.maximumRenderTimeChange=0.5] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested.
226223
*
227224
* @see CesiumWidget
@@ -2925,8 +2922,6 @@ define([
29252922
context.endFrame();
29262923
}
29272924

2928-
var scratchTime = new JulianDate();
2929-
29302925
/**
29312926
* @private
29322927
*/
@@ -2949,7 +2944,7 @@ define([
29492944

29502945
try {
29512946
if (shouldRender) {
2952-
this._lastRenderTime = JulianDate.clone(time, scratchTime);
2947+
this._lastRenderTime = JulianDate.clone(time, this._lastRenderTime);
29532948
this._renderRequested = false;
29542949

29552950
render(this, time);

Source/Widgets/CesiumWidget/CesiumWidget.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ define([
164164
* @param {Boolean} [options.shadows=false] Determines if shadows are cast by the sun.
165165
* @param {ShadowMode} [options.terrainShadows=ShadowMode.RECEIVE_ONLY] Determines if the terrain casts or receives shadows from the sun.
166166
* @param {MapMode2D} [options.mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
167-
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application.
167+
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API.
168168
* @param {Number} [options.maximumRenderTimeChange=0.5] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested.
169169
*
170170
* @exception {DeveloperError} Element with id "container" does not exist in the document.

Source/Widgets/Viewer/Viewer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ define([
288288
* @param {ShadowMode} [options.terrainShadows=ShadowMode.RECEIVE_ONLY] Determines if the terrain casts or receives shadows from the sun.
289289
* @param {MapMode2D} [options.mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
290290
* @param {Boolean} [options.projectionPicker=false] If set to true, the ProjectionPicker widget will be created.
291-
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application.
291+
* @param {Boolean} [options.requestRenderMode=false] If true, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using {@link Scene#requestRender} to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API.
292292
* @param {Number} [options.maximumRenderTimeChange=0.5] If requestRenderMode is true, this value defines the maximum change in simulation time allowed before a render is requested.
293293
*
294294
* @exception {DeveloperError} Element with id "container" does not exist in the document.

Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js

+35
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,22 @@ defineSuite([
236236
expect(widget.scene.orderIndependentTranslucency).toBe(false);
237237
});
238238

239+
it('can enable requestRenderMode', function() {
240+
widget = createCesiumWidget(container, {
241+
requestRenderMode : true
242+
});
243+
244+
expect(widget.scene.requestRenderMode).toBe(true);
245+
});
246+
247+
it('can set maximumRenderTimeChange', function() {
248+
widget = createCesiumWidget(container, {
249+
maximumRenderTimeChange : Number.POSITIVE_INFINITY
250+
});
251+
252+
expect(widget.scene.maximumRenderTimeChange).toBe(Number.POSITIVE_INFINITY);
253+
});
254+
239255
it('throws if no container provided', function() {
240256
expect(function() {
241257
return createCesiumWidget(undefined);
@@ -262,6 +278,25 @@ defineSuite([
262278
}).toThrowDeveloperError();
263279
});
264280

281+
it('resizing triggers a render in requestRender mode', function() {
282+
widget = createCesiumWidget(container, {
283+
requestRenderMode : true,
284+
maximumRenderTimeChange : Number.POSITIVE_INFINITY
285+
});
286+
287+
var scene = widget._scene;
288+
spyOn(scene, 'requestRender');
289+
290+
widget.resize();
291+
292+
expect(scene.requestRender).not.toHaveBeenCalled();
293+
294+
widget._forceResize = true;
295+
widget.resize();
296+
297+
expect(scene.requestRender).toHaveBeenCalled();
298+
});
299+
265300
it('throws if no container id does not exist', function() {
266301
expect(function() {
267302
return createCesiumWidget('doesnotexist');

Specs/Widgets/Viewer/ViewerSpec.js

+16
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,22 @@ defineSuite([
806806
});
807807
});
808808

809+
it('can enable requestRender mode', function() {
810+
viewer = createViewer(container, {
811+
requestRenderMode : true
812+
});
813+
814+
expect(viewer.scene.requestRenderMode).toBe(true);
815+
});
816+
817+
it('can set maximumRenderTimeChange', function() {
818+
viewer = createViewer(container, {
819+
maximumRenderTimeChange : Number.POSITIVE_INFINITY
820+
});
821+
822+
expect(viewer.scene.maximumRenderTimeChange).toBe(Number.POSITIVE_INFINITY);
823+
});
824+
809825
it('can get and set trackedEntity', function() {
810826
viewer = createViewer(container);
811827

0 commit comments

Comments
 (0)