Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into style-tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed May 5, 2014
2 parents 691cf3b + 10fabfb commit 0acfb54
Show file tree
Hide file tree
Showing 19 changed files with 169 additions and 54 deletions.
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Change Log

Beta Releases
-------------

### b29 - 2014-06-02

* Improved terrain and imagery rendering performance when very close to the surface.

### b28 - 2014-05-01

* Breaking changes ([why so many?](https://groups.google.com/forum/#!topic/cesium-dev/CQ0wCHjJ9x4)):
Expand Down Expand Up @@ -52,7 +57,7 @@ Beta Releases
* `BaseLayerPickerViewModel.selectedItem` -> `BaseLayerPickerViewModel.selectedImagery`
* `BaseLayerPickerViewModel.imageryLayers`has been removed and replaced with `BaseLayerPickerViewModel.centralBody`
* Renamed `TimeIntervalCollection.clear` to `TimeIntervalColection.removeAll`
* `Context` is now private
* `Context` is now private.
* Removed `Scene.context`. Instead, use `Scene.drawingBufferWidth`, `Scene.drawingBufferHeight`, `Scene.maximumAliasedLineWidth`, and `Scene.createTextureAtlas`.
* `Billboard.computeScreenSpacePosition`, `Label.computeScreenSpacePosition`, `SceneTransforms.clipToWindowCoordinates` and `SceneTransforms.clipToDrawingBufferCoordinates` take a `Scene` parameter instead of a `Context`.
* `Camera` constructor takes `Scene` as parameter instead of `Context`
Expand All @@ -64,10 +69,10 @@ Beta Releases
* Added `DynamicRectangle` to support DataSource provided `RectangleGeometry`.
* Added `DynamicWall` to support DataSource provided `WallGeometry`.
* Improved texture upload performance and reduced memory usage when using `BingMapsImageryProvider` and other imagery providers that return false from `hasAlphaChannel`.
* Added the ability to offset the grid in the `GridMaterial`.
* `GeometryVisualizer` now creates geometry asynchronously to prevent locking up the browser.
* Add `Clock.canAnimate` to prevent time from advancing, even while the clock is animating.
* `Viewer` now prevents time from advancing if asynchronous geometry is being processed in order to avoid showing an incomplete picture. This can be disabled via the `Viewer.allowDataSourcesToSuspendAnimation` settings.
* Added `Model.minimumPixelSize` property so models remain visible when the viewer zooms out.
* Added ability to modify glTF material parameters using `Model.getMaterial`, `ModelMaterial`, and `ModelMesh.material`.
* Added `asynchronous` and `ready` properties to `Model`.
* Added `Cartesian4.fromColor` and `Color.fromCartesian4`.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Ayudh Das](https://github.com/ayudhDas)
* [You Lu](https://github.com/YouLu)
* [David Hite](https://github.com/dav3hit3)
* [Kevin Ring](https://github.com/kring)

Also see [our contributors page](http://cesiumjs.org/contributors.html) for more information.
3 changes: 2 additions & 1 deletion Source/DynamicScene/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ define(['../Core/Cartesian2',
processPacketData(Color, existingMaterial, 'color', materialData.color, undefined, sourceUri);
processPacketData(Number, existingMaterial, 'cellAlpha', materialData.cellAlpha, undefined, sourceUri);
existingMaterial.lineThickness = combineIntoCartesian2(existingMaterial.lineThickness, materialData.rowThickness, materialData.columnThickness);
existingMaterial.lineOffset = combineIntoCartesian2(existingMaterial.lineOffset, materialData.rowOffset, materialData.columnOffset);
existingMaterial.lineCount = combineIntoCartesian2(existingMaterial.lineCount, materialData.rowCount, materialData.columnCount);
} else if (defined(packetData.image)) {
if (!(existingMaterial instanceof ImageMaterialProperty)) {
Expand Down Expand Up @@ -879,7 +880,7 @@ define(['../Core/Cartesian2',
for (i = 0, len = tmp.length; i < len; i += 3) {
scratchCartographic.longitude = tmp[i];
scratchCartographic.latitude = tmp[i + 1];
scratchCartographic.height = tmp[i] + 2;
scratchCartographic.height = tmp[i + 2];
values.push(Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic));
}
vertexPositionsData.array = values;
Expand Down
18 changes: 15 additions & 3 deletions Source/DynamicScene/GridMaterialProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ define(['../Core/Cartesian2',
this._lineCountSubscription = undefined;
this._lineThickness = undefined;
this._lineThicknessSubscription = undefined;
this._lineOffset = undefined;
this._lineOffsetSubscription = undefined;

this.color = new ConstantProperty(Color.WHITE);
this.cellAlpha = new ConstantProperty(0.1);
this.lineCount = new ConstantProperty(new Cartesian2(8, 8));
this.lineThickness = new ConstantProperty(new Cartesian2(1.0, 1.0));
this.lineOffset = new ConstantProperty(new Cartesian2(0.0, 0.0));
};

defineProperties(GridMaterialProperty.prototype, {
Expand All @@ -52,7 +55,8 @@ define(['../Core/Cartesian2',
return Property.isConstant(this._color) &&
Property.isConstant(this._cellAlpha) &&
Property.isConstant(this._lineCount) &&
Property.isConstant(this._lineThickness);
Property.isConstant(this._lineThickness) &&
Property.isConstant(this._lineOffset);
}
},
/**
Expand Down Expand Up @@ -91,7 +95,13 @@ define(['../Core/Cartesian2',
* @type {Property}
* @default new ConstantProperty(new Cartesian2(1.0, 1.0))
*/
lineThickness : createDynamicPropertyDescriptor('lineThickness')
lineThickness : createDynamicPropertyDescriptor('lineThickness'),
/**
* Gets or sets the {@link Cartesian2} property which determines the offset of rows and columns in the grid.
* @type {Property}
* @default new ConstantProperty(new Cartesian2(0.0, 0.0))
*/
lineOffset : createDynamicPropertyDescriptor('lineOffset')
});

/**
Expand Down Expand Up @@ -121,6 +131,7 @@ define(['../Core/Cartesian2',
result.cellAlpha = defined(this._cellAlpha) ? this._cellAlpha.getValue(time) : undefined;
result.lineCount = defined(this._lineCount) ? this._lineCount.getValue(time, result.lineCount) : undefined;
result.lineThickness = defined(this._lineThickness) ? this._lineThickness.getValue(time, result.lineThickness) : undefined;
result.lineOffset = defined(this._lineOffset) ? this._lineOffset.getValue(time, result.lineOffset) : undefined;
return result;
};

Expand All @@ -138,7 +149,8 @@ define(['../Core/Cartesian2',
Property.equals(this._color, other._color) && //
Property.equals(this._cellAlpha, other._cellAlpha) && //
Property.equals(this._lineCount, other._lineCount) && //
Property.equals(this._lineThickness, other._lineThickness));
Property.equals(this._lineThickness, other._lineThickness) && //
Property.equals(this._lineOffset, other._lineOffset));
};

/**
Expand Down
24 changes: 16 additions & 8 deletions Source/Scene/GlobeSurface.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ define([
for (i = 0, len = levelZeroTiles.length; i < len; ++i) {
tile = levelZeroTiles[i];
surface._tileReplacementQueue.markTileRendered(tile);
if (tile.state !== TileState.READY) {
if (tile.state.value < TileState.READY.value) {
queueTileLoad(surface, tile);
}
if (tile.isRenderable && isTileVisible(surface, frameState, tile)) {
Expand Down Expand Up @@ -432,8 +432,8 @@ define([
}
}
} else {
++debug.tilesWaitingForChildren;
// SSE is not good enough but not all children are loaded, so render this tile anyway.
// SSE is not good enough but either all children are upsampled (so there's no point in refining) or they're not all loaded yet.
// So render the current tile.
addTileToRenderList(surface, tile);
}
}
Expand Down Expand Up @@ -616,20 +616,28 @@ define([

function queueChildrenLoadAndDetermineIfChildrenAreAllRenderable(surface, frameState, tile) {
var allRenderable = true;
var allUpsampledOnly = true;

var children = tile.children;
for (var i = 0, len = children.length; i < len; ++i) {
var child = children[i];

surface._tileReplacementQueue.markTileRendered(child);
if (child.state !== TileState.READY) {

allUpsampledOnly = allUpsampledOnly && child.state === TileState.UPSAMPLED_ONLY;
allRenderable = allRenderable && child.isRenderable;

if (child.state.value < TileState.READY.value) {
queueTileLoad(surface, child);
}
if (!child.isRenderable) {
allRenderable = false;
}
}

return allRenderable;
if (!allRenderable) {
++surface._debug.tilesWaitingForChildren;
}

// If all children are upsampled from this tile, we just render this tile instead of its children.
return allRenderable && !allUpsampledOnly;
}

function queueTileLoad(surface, tile) {
Expand Down
4 changes: 3 additions & 1 deletion Source/Scene/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ define([
* <li><code>cellAlpha</code>: Alpha value for the cells between grid lines. This will be combined with color.alpha.</li>
* <li><code>lineCount</code>: Object with x and y values specifying the number of columns and rows respectively.</li>
* <li><code>lineThickness</code>: Object with x and y values specifying the thickness of grid lines (in pixels where available).</li>
* <li><code>lineOffset</code>: Object with x and y values specifying the offset of grid lines (range is 0 to 1).</li>
* </ul>
* <li>Stripe</li>
* <ul>
Expand Down Expand Up @@ -1182,7 +1183,8 @@ define([
color : new Color(0.0, 1.0, 0.0, 1.0),
cellAlpha : 0.1,
lineCount : new Cartesian2(8.0, 8.0),
lineThickness : new Cartesian2(1.0, 1.0)
lineThickness : new Cartesian2(1.0, 1.0),
lineOffset : new Cartesian2(0.0, 0.0)
},
source : GridMaterial
},
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/ModelMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define([
* Use {@link Model#getMaterial} to create an instance.
* </p>
*
* @alias ModelMatrix
* @alias ModelMaterial
* @internalConstructor
*
* @see Model#getMaterial
Expand Down Expand Up @@ -127,4 +127,4 @@ define([
};

return ModelMaterial;
});
});
16 changes: 13 additions & 3 deletions Source/Scene/Tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,16 @@ define([
// But it's not done loading until our two state machines are terminated.
var isDoneLoading = !defined(this.loadedTerrain) && !defined(this.upsampledTerrain);

// If this tile's terrain and imagery are just upsampled from its parent, mark the tile as
// upsampled only. We won't refine a tile if its four children are upsampled only.
var isUpsampledOnly = defined(this.terrainData) && this.terrainData.wasCreatedByUpsampling();

// Transition imagery states
var tileImageryCollection = this.imagery;
for (var i = 0, len = tileImageryCollection.length; i < len; ++i) {
var tileImagery = tileImageryCollection[i];
if (!defined(tileImagery.loadingImagery)) {
isUpsampledOnly = false;
continue;
}

Expand All @@ -377,6 +382,8 @@ define([
--i;
len = tileImageryCollection.length;
continue;
} else {
isUpsampledOnly = false;
}
}

Expand All @@ -385,6 +392,9 @@ define([

// The imagery is renderable as soon as we have any renderable imagery for this region.
isRenderable = isRenderable && (thisTileDoneLoading || defined(tileImagery.readyImagery));

isUpsampledOnly = isUpsampledOnly && defined(tileImagery.loadingImagery) &&
(tileImagery.loadingImagery.state === ImageryState.FAILED || tileImagery.loadingImagery.state === ImageryState.INVALID);
}

// The tile becomes renderable when the terrain and all imagery data are loaded.
Expand All @@ -394,7 +404,7 @@ define([
}

if (isDoneLoading) {
this.state = TileState.READY;
this.state = isUpsampledOnly ? TileState.UPSAMPLED_ONLY : TileState.READY;
}
}
};
Expand Down Expand Up @@ -573,9 +583,9 @@ define([
// of its ancestors receives new (better) data and we want to re-upsample from the
// new data.

if (defined(tile.children)) {
if (defined(tile._children)) {
for (var childIndex = 0; childIndex < 4; ++childIndex) {
var childTile = tile.children[childIndex];
var childTile = tile._children[childIndex];
if (childTile.state !== TileState.START) {
if (defined(childTile.terrainData) && !childTile.terrainData.wasCreatedByUpsampling()) {
// Data for the child tile has already been loaded.
Expand Down
3 changes: 2 additions & 1 deletion Source/Scene/TileState.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ define(['../Core/Enumeration'], function(Enumeration) {
var TileState = {
START : new Enumeration(0, 'START'),
LOADING : new Enumeration(1, 'LOADING'),
READY : new Enumeration(2, 'READY')
READY : new Enumeration(2, 'READY'),
UPSAMPLED_ONLY : new Enumeration(3, 'UPSAMPLED_ONLY')
};

return TileState;
Expand Down
5 changes: 3 additions & 2 deletions Source/Shaders/Materials/GridMaterial.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ uniform vec4 color;
uniform float cellAlpha;
uniform vec2 lineCount;
uniform vec2 lineThickness;
uniform vec2 lineOffset;

czm_material czm_getMaterial(czm_materialInput materialInput)
{
czm_material material = czm_getDefaultMaterial(materialInput);

vec2 st = materialInput.st;

float scaledWidth = fract(lineCount.s * st.s);
float scaledWidth = fract(lineCount.s * st.s - lineOffset.s);
scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));
float scaledHeight = fract(lineCount.t * st.t);
float scaledHeight = fract(lineCount.t * st.t - lineOffset.t);
scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));

float value;
Expand Down
52 changes: 36 additions & 16 deletions Specs/DynamicScene/CzmlDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1162,32 +1162,50 @@ defineSuite([
expect(dynamicObject.orientation.getValue(Iso8601.MINIMUM_VALUE)).toEqual(new Quaternion(0.0, 0.0, 0.0, 1.0));
});

it('CZML VertexPositions works.', function() {
it('vertexPositions work with cartesians.', function() {
var expectedResult = [new Cartesian3(1.0, 2.0, 3.0), new Cartesian3(5.0, 6.0, 7.0)];

var packet = {
vertexPositions : {
cartesian : [1.0, 2.0, 3.0, 5.0, 6.0, 7.0]
cartesian : [expectedResult[0].x, expectedResult[0].y, expectedResult[0].z, expectedResult[1].x, expectedResult[1].y, expectedResult[1].z]
}
};

var dataSource = new CzmlDataSource();
dataSource.load(packet);
var dynamicObject = dataSource.dynamicObjects.getObjects()[0];
expect(dynamicObject.vertexPositions.getValue(Iso8601.MINIMUM_VALUE)).toEqual([new Cartesian3(1.0, 2.0, 3.0), new Cartesian3(5.0, 6.0, 7.0)]);
expect(dynamicObject.vertexPositions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult);
});

packet = {
vertexPositions : [{
interval : '2013-01-01T00:00:00Z/2013-01-01T01:00:00Z',
cartesian : [1.0, 2.0, 3.0]
}, {
interval : '2013-01-01T01:00:00Z/2013-01-01T02:00:00Z',
cartesian : [4.0, 5.0, 6.0]
}]
it('vertexPositions work with cartographicRadians.', function() {
var input = [new Cartographic(1.0, 2.0, 4.0), new Cartographic(5.0, 6.0, 7.0)];
var expectedResult = Ellipsoid.WGS84.cartographicArrayToCartesianArray(input);

var packet = {
vertexPositions : {
cartographicRadians : [input[0].longitude, input[0].latitude, input[0].height, input[1].longitude, input[1].latitude, input[1].height]
}
};
dataSource = new CzmlDataSource();

var dataSource = new CzmlDataSource();
dataSource.load(packet);
dynamicObject = dataSource.dynamicObjects.getObjects()[0];
expect(dynamicObject.vertexPositions.getValue(JulianDate.fromIso8601('2013-01-01T00:00:00Z'))).toEqual([new Cartesian3(1.0, 2.0, 3.0)]);
expect(dynamicObject.vertexPositions.getValue(JulianDate.fromIso8601('2013-01-01T01:00:00Z'))).toEqual([new Cartesian3(4.0, 5.0, 6.0)]);
var dynamicObject = dataSource.dynamicObjects.getObjects()[0];
expect(dynamicObject.vertexPositions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult);
});

it('vertexPositions work with cartographicDegrees.', function() {
var expectedResult = Ellipsoid.WGS84.cartographicArrayToCartesianArray([Cartographic.fromDegrees(1.0, 2.0, 3.0), Cartographic.fromDegrees(5.0, 6.0, 7.0)]);

var packet = {
vertexPositions : {
cartographicDegrees : [1.0, 2.0, 3.0, 5.0, 6.0, 7.0]
}
};

var dataSource = new CzmlDataSource();
dataSource.load(packet);
var dynamicObject = dataSource.dynamicObjects.getObjects()[0];
expect(dynamicObject.vertexPositions.getValue(Iso8601.MINIMUM_VALUE)).toEqual(expectedResult);
});

it('CZML ViewFrom works.', function() {
Expand Down Expand Up @@ -1868,8 +1886,10 @@ defineSuite([
cellAlpha : 0,
rowCount : 36,
rowThickness : 1,
rowOffset: 0.5,
columnCount : 9,
columnThickness : 1
columnThickness : 1,
columnOffset: 0.5
}
}]
}
Expand Down
Loading

0 comments on commit 0acfb54

Please sign in to comment.