Skip to content

Commit

Permalink
Merge branch 'master' into topojson
Browse files Browse the repository at this point in the history
  • Loading branch information
mramato committed Jun 28, 2013
2 parents 12754fc + e1f84ba commit a742386
Show file tree
Hide file tree
Showing 9 changed files with 7,141 additions and 53 deletions.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Beta Releases
* `ImageryProvider.loadImage` now requires that the calling imagery provider instance be passed as its first parameter.
* Removed `CesiumViewerWidget` and replaced it with a new `Viewer` widget with mixin architecture. This new widget does not depend on Dojo and is part of the combined Cesium.js file. It is intended to be a flexible base widget for easily building robust applications. See [#838](https://github.com/AnalyticalGraphicsInc/cesium/pull/838) for the full details.
* Removed the Dojo-based `checkForChromeFrame` function, and replaced it with a new standalone version that returns a promise to signal when the asynchronous check has completed.
* Fix resizing issues in `CesiumWidget` ([#608](https://github.com/AnalyticalGraphicsInc/cesium/issues/608), [#834](https://github.com/AnalyticalGraphicsInc/cesium/issues/834)).
* Added initial support for [GeoJSON](http://www.geojson.org/) see [#890](https://github.com/AnalyticalGraphicsInc/cesium/pull/890) for details.
* Added `Context.getAntialias`.
* Added rotation, aligned axis, width, and height properties to `Billboard`s.
Expand All @@ -29,7 +30,6 @@ Beta Releases
* Added the ability to unsubscribe to `Timeline` update event.
* Added a `screenSpaceEventHandler` property to `CesiumWidget`. Also added a `sceneMode` option to the constructor to set the initial scene mode.
* Added `useDefaultRenderLoop` property to `CesiumWidget` that allows the default render loop to be disabled so that a custom render loop can be used.
* Fix resizing issues in `CesiumWidget` ([#608](https://github.com/AnalyticalGraphicsInc/cesium/issues/608)) by having the default render loop force a resize event every 60 frames.
* Added `CesiumWidget.onRenderLoopError` which is an `Event` that is raised if an exception is generated inside of the default render loop.
* `ImageryProviderViewModel.creationCommand` can now return an array of ImageryProvider instances, which allows adding multiple layers when a single item is selected in the `BaseLayerPicker` widget.
* Changed static `clone` functions in all objects such that if the object being cloned is undefined, the function will return undefined instead of throwing an exception
Expand Down
22 changes: 22 additions & 0 deletions Source/Core/defined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*global define*/
define(function() {
"use strict";

/**
* Returns true if the object is defined, returns false otherwise.
*
* @exports defined
*
* @example
* if (defined(positions)) {
* doSomething();
* } else {
* doSomethingElse();
* }
*/
var defined = function(value) {
return typeof value !== 'undefined';
};

return defined;
});
49 changes: 24 additions & 25 deletions Source/Widgets/CesiumWidget/CesiumWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ define([
function render() {
try {
if (widget._useDefaultRenderLoop) {
var frameNumber = widget._scene.getFrameState().frameNumber;
if (widget._needResize || (frameNumber % 60) === 0) {
widget.resize();
}
widget.resize();
widget.render();
requestAnimationFrame(render);
} else {
Expand Down Expand Up @@ -182,6 +179,8 @@ define([
this._element = widgetNode;
this._container = container;
this._canvas = canvas;
this._canvasWidth = canvas.width;
this._canvasHeight = canvas.height;
this._cesiumLogo = cesiumLogo;
this._scene = scene;
this._centralBody = centralBody;
Expand All @@ -190,6 +189,7 @@ define([
this._screenSpaceEventHandler = new ScreenSpaceEventHandler(canvas);
this._useDefaultRenderLoop = undefined;
this._renderLoopRunning = false;
this._canRender = false;

if (options.sceneMode) {
if (options.sceneMode === SceneMode.SCENE2D) {
Expand All @@ -200,14 +200,6 @@ define([
}
}

var that = this;
//Subscribe for resize events and set the initial size.
this._needResize = true;
this._resizeCallback = function() {
that._needResize = true;
};
window.addEventListener('resize', this._resizeCallback, false);

this.useDefaultRenderLoop = defaultValue(options.useDefaultRenderLoop, true);
};

Expand Down Expand Up @@ -362,7 +354,6 @@ define([
* @memberof CesiumWidget
*/
CesiumWidget.prototype.destroy = function() {
window.removeEventListener('resize', this._resizeCallback, false);
this._container.removeChild(this._element);
destroyObject(this);
};
Expand All @@ -374,21 +365,27 @@ define([
* @memberof CesiumWidget
*/
CesiumWidget.prototype.resize = function() {
var width = this._canvas.clientWidth;
var height = this._canvas.clientHeight;
if (this._canvas.width === width && this._canvas.height === height) {
var canvas = this._canvas;
var width = canvas.clientWidth;
var height = canvas.clientHeight;
if (this._canvasWidth === width && this._canvasHeight === height) {
return;
}

this._canvas.width = width;
this._canvas.height = height;
canvas.width = this._canvasWidth = width;
canvas.height = this._canvasHeight = height;

var frustum = this._scene.getCamera().frustum;
if (typeof frustum.aspectRatio !== 'undefined') {
frustum.aspectRatio = width / height;
} else {
frustum.top = frustum.right * (height / width);
frustum.bottom = -frustum.top;
var canRender = width !== 0 && height !== 0;
this._canRender = canRender;

if (canRender) {
var frustum = this._scene.getCamera().frustum;
if (typeof frustum.aspectRatio !== 'undefined') {
frustum.aspectRatio = width / height;
} else {
frustum.top = frustum.right * (height / width);
frustum.bottom = -frustum.top;
}
}
};

Expand All @@ -400,7 +397,9 @@ define([
CesiumWidget.prototype.render = function() {
var currentTime = this._clock.tick();
this._scene.initializeFrame();
this._scene.render(currentTime);
if (this._canRender) {
this._scene.render(currentTime);
}
};

return CesiumWidget;
Expand Down
9 changes: 0 additions & 9 deletions Source/Widgets/Viewer/Viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
height: 100%;
}

.cesium-viewer-canvas {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.cesium-viewer-timelineContainer {
position: absolute;
bottom: 0;
Expand Down
19 changes: 3 additions & 16 deletions Source/Widgets/Viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ define([
function render() {
try {
if (viewer._useDefaultRenderLoop) {
var frameNumber = viewer._cesiumWidget._scene.getFrameState().frameNumber;
if (viewer._needResize || (frameNumber % 60) === 0) {
viewer.resize();
}
viewer.resize();
viewer.render();
requestAnimationFrame(render);
} else {
Expand Down Expand Up @@ -192,14 +189,6 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
useDefaultRenderLoop : false
});

//Subscribe for resize events and set the initial size.
var that = this;
this._needResize = true;
this._resizeCallback = function() {
that._needResize = true;
};
window.addEventListener('resize', this._resizeCallback, false);

//Data source display
var dataSourceDisplay = new DataSourceDisplay(cesiumWidget.scene);
this._dataSourceDisplay = dataSourceDisplay;
Expand Down Expand Up @@ -573,7 +562,8 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
* @memberof Viewer
*/
Viewer.prototype.resize = function() {
this._needResize = false;
var cesiumWidget = this._cesiumWidget;
cesiumWidget.resize();

var container = this._container;
var width = container.clientWidth;
Expand All @@ -582,9 +572,6 @@ Either specify options.imageryProvider instead or set options.baseLayerPicker to
return;
}

var cesiumWidget = this._cesiumWidget;
cesiumWidget.resize();

var baseLayerPickerDropDown = this._baseLayerPickerDropDown;
if (typeof baseLayerPickerDropDown !== 'undefined') {
var baseLayerPickerMaxHeight = height - 125;
Expand Down
19 changes: 19 additions & 0 deletions Specs/Core/definedSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*global defineSuite*/
defineSuite([
'Core/defined'
], function(
defined) {
"use strict";
/*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/

var obj = 42;
var obj2;

it('works for defined object', function() {
expect(defined(obj)).toEqual(true);
});

it('works for undefined object', function() {
expect(defined(obj2)).toEqual(false);
});
});
Loading

0 comments on commit a742386

Please sign in to comment.