Skip to content

Commit

Permalink
Merge branch 'master' into ie-2d
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed May 9, 2016
2 parents c9e08f6 + 0dbb960 commit f290ca5
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="Source/ThirdParty/|Source/Workers/cesiumWorkerBootstrapper.js|ThirdParty/|Tools/build.js" kind="src" path=""/>
<classpathentry excluding="Source/ThirdParty/|Source/Workers/cesiumWorkerBootstrapper.js|ThirdParty/|gulpfile.js" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary/StandardBrowser/html5"/>
<classpathentry kind="output" path=""/>
Expand Down
11 changes: 10 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Change Log
==========

### 1.22 - 2016-06-01

* Breaking changes
*
* Deprecated
*
* Improved KML NetworkLink compatibility by supporting the `Url` tag. [#3895](https://github.com/AnalyticalGraphicsInc/cesium/pull/3895).
* Fixed exaggerated terrain tiles disappearing. [#3676](https://github.com/AnalyticalGraphicsInc/cesium/issues/3676)
* Fixed infinite horizontal 2D scrolling in IE/Edge. [#3893](https://github.com/AnalyticalGraphicsInc/cesium/issues/3893)

### 1.21 - 2016-05-02

* Breaking changes
Expand All @@ -14,7 +24,6 @@ Change Log
* Fixed issue causing the fog to go dark and the atmosphere to flicker when the camera clips the globe. [#3178](https://github.com/AnalyticalGraphicsInc/cesium/issues/3178)
* Fixed a bug that caused an exception and rendering to stop when using `ArcGisMapServerImageryProvider` to connect to a MapServer specifying the Web Mercator projection and a fullExtent bigger than the valid extent of the projection. [#3854](https://github.com/AnalyticalGraphicsInc/cesium/pull/3854)
* Fixed issue causing an exception when switching scene modes with an active KML network link. [#3865](https://github.com/AnalyticalGraphicsInc/cesium/issues/3865)
* Fixed infinite horizontal 2D scrolling in IE/Edge. [#3893](https://github.com/AnalyticalGraphicsInc/cesium/issues/3893)

### 1.20 - 2016-04-01

Expand Down
42 changes: 0 additions & 42 deletions Source/Core/EllipsoidalOccluder.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,48 +238,6 @@ define([
return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
};

/**
* Computes a point that can be used for horizon culling from a list of positions. If the point is below
* the horizon, all of the positions are guaranteed to be below the horizon as well. The returned point
* is expressed in the ellipsoid-scaled space and is suitable for use with
* {@link EllipsoidalOccluder#isScaledSpacePointVisible}.
*
* @param {Cartesian3} directionToPoint The direction that the computed point will lie along.
* A reasonable direction to use is the direction from the center of the ellipsoid to
* the center of the bounding sphere computed from the positions. The direction need not
* be normalized.
* @param {Cartesian3[]} points The vertices from which to compute the horizon culling point. The positions
* must be expressed in a reference frame centered at the ellipsoid and aligned with the
* ellipsoid's axes.
* @param {Cartesian3} [result] The instance on which to store the result instead of allocating a new instance.
* @returns {Cartesian3} The computed horizon culling point, expressed in the ellipsoid-scaled space.
*/
EllipsoidalOccluder.prototype.computeHorizonCullingPointFromPoints = function(directionToPoint, points, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(directionToPoint)) {
throw new DeveloperError('directionToPoint is required');
}
if (!defined(points)) {
throw new DeveloperError('points is required');
}
//>>includeEnd('debug');

if (!defined(result)) {
result = new Cartesian3();
}

var ellipsoid = this._ellipsoid;
var scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(ellipsoid, directionToPoint);
var resultMagnitude = 0.0;

for (var i = 0, len = points.length; i < len; ++i) {
var candidateMagnitude = computeMagnitude(ellipsoid, points[i], scaledSpaceDirectionToPoint);
resultMagnitude = Math.max(resultMagnitude, candidateMagnitude);
}

return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result);
};

var subsampleScratch = [];

/**
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/HeightmapTessellator.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ define([
var center = options.relativetoCenter;
if (defined(center)) {
var occluder = new EllipsoidalOccluder(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromPoints(center, positions);
occludeePointInScaledSpace = occluder.computeHorizonCullingPoint(center, positions);
}

var aaBox = new AxisAlignedBoundingBox(minimum, maximum, relativeToCenter);
Expand Down
89 changes: 74 additions & 15 deletions Source/Core/PolygonGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ define([
'./BoundingSphere',
'./Cartesian2',
'./Cartesian3',
'./Cartographic',
'./ComponentDatatype',
'./defaultValue',
'./defined',
Expand All @@ -28,6 +29,7 @@ define([
BoundingSphere,
Cartesian2,
Cartesian3,
Cartographic,
ComponentDatatype,
defaultValue,
defined,
Expand Down Expand Up @@ -85,13 +87,30 @@ define([
return result;
}

var scratchCarto1 = new Cartographic();
var scratchCarto2 = new Cartographic();
function adjustPosHeightsForNormal(position, p1, p2, ellipsoid) {
var carto1 = ellipsoid.cartesianToCartographic(position, scratchCarto1);
var height = carto1.height;
var p1Carto = ellipsoid.cartesianToCartographic(p1, scratchCarto2);
p1Carto.height = height;
ellipsoid.cartographicToCartesian(p1Carto, p1);

var p2Carto = ellipsoid.cartesianToCartographic(p2, scratchCarto2);
p2Carto.height = height - 100;
ellipsoid.cartographicToCartesian(p2Carto, p2);
}

var scratchBoundingRectangle = new BoundingRectangle();
var scratchPosition = new Cartesian3();
var scratchNormal = new Cartesian3();
var scratchTangent = new Cartesian3();
var scratchBinormal = new Cartesian3();
var p1Scratch = new Cartesian3();
var p2Scratch = new Cartesian3();
var scratchPerPosNormal = new Cartesian3();
var scratchPerPosTangent = new Cartesian3();
var scratchPerPosBinormal = new Cartesian3();

var appendTextureCoordinatesOrigin = new Cartesian2();
var appendTextureCoordinatesCartesian2 = new Cartesian2();
Expand All @@ -109,8 +128,10 @@ define([
var tangentPlane = options.tangentPlane;
var ellipsoid = options.ellipsoid;
var stRotation = options.stRotation;
var top = options.top || options.wall;
var bottom = options.bottom || options.wall;
var wall = options.wall;
var top = options.top || wall;
var bottom = options.bottom || wall;
var perPositionHeight = options.perPositionHeight;

var origin = appendTextureCoordinatesOrigin;
origin.x = boundingRectangle.x;
Expand All @@ -120,7 +141,14 @@ define([
var length = flatPositions.length;

var textureCoordinates = vertexFormat.st ? new Float32Array(2 * (length / 3)) : undefined;
var normals = vertexFormat.normal ? new Float32Array(length) : undefined;
var normals;
if (vertexFormat.normal) {
if (perPositionHeight && top && !wall) {
normals = geometry.attributes.normal.values;
} else {
normals = new Float32Array(length);
}
}
var tangents = vertexFormat.tangent ? new Float32Array(length) : undefined;
var binormals = vertexFormat.binormal ? new Float32Array(length) : undefined;

Expand Down Expand Up @@ -172,12 +200,15 @@ define([
var attrIndex1 = attrIndex + 1;
var attrIndex2 = attrIndex + 2;

if (options.wall) {
if (wall) {
if (i + 3 < length) {
var p1 = Cartesian3.fromArray(flatPositions, i + 3, p1Scratch);

if (recomputeNormal) {
var p2 = Cartesian3.fromArray(flatPositions, i + length, p2Scratch);
if (perPositionHeight) {
adjustPosHeightsForNormal(position, p1, p2, ellipsoid);
}
Cartesian3.subtract(p1, position, p1);
Cartesian3.subtract(p2, position, p2);
normal = Cartesian3.normalize(Cartesian3.cross(p2, p1, normal), normal);
Expand All @@ -198,6 +229,15 @@ define([
} else {
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
if (vertexFormat.tangent || vertexFormat.binormal) {
if (perPositionHeight) {
scratchPerPosNormal = Cartesian3.fromArray(normals, attrIndex, scratchPerPosNormal);
scratchPerPosTangent = Cartesian3.cross(Cartesian3.UNIT_Z, scratchPerPosNormal, scratchPerPosTangent);
scratchPerPosTangent = Cartesian3.normalize(Matrix3.multiplyByVector(textureMatrix, scratchPerPosTangent, scratchPerPosTangent), scratchPerPosTangent);
if (vertexFormat.binormal) {
scratchPerPosBinormal = Cartesian3.normalize(Cartesian3.cross(scratchPerPosNormal, scratchPerPosTangent, scratchPerPosBinormal), scratchPerPosBinormal);
}
}

tangent = Cartesian3.cross(Cartesian3.UNIT_Z, normal, tangent);
tangent = Cartesian3.normalize(Matrix3.multiplyByVector(textureMatrix, tangent, tangent), tangent);
if (vertexFormat.binormal) {
Expand All @@ -216,7 +256,8 @@ define([
normals[attrIndex1 + bottomOffset] = -normal.y;
normals[attrIndex2 + bottomOffset] = -normal.z;
}
if (top) {

if ((top && !perPositionHeight) || wall) {
normals[attrIndex] = normal.x;
normals[attrIndex1] = normal.y;
normals[attrIndex2] = normal.z;
Expand All @@ -235,9 +276,15 @@ define([
}

if(top) {
tangents[attrIndex] = tangent.x;
tangents[attrIndex1] = tangent.y;
tangents[attrIndex2] = tangent.z;
if (perPositionHeight) {
tangents[attrIndex] = scratchPerPosTangent.x;
tangents[attrIndex1] = scratchPerPosTangent.y;
tangents[attrIndex2] = scratchPerPosTangent.z;
} else {
tangents[attrIndex] = tangent.x;
tangents[attrIndex1] = tangent.y;
tangents[attrIndex2] = tangent.z;
}
}
}

Expand All @@ -248,9 +295,15 @@ define([
binormals[attrIndex2 + bottomOffset] = binormal.z;
}
if (top) {
binormals[attrIndex] = binormal.x;
binormals[attrIndex1] = binormal.y;
binormals[attrIndex2] = binormal.z;
if (perPositionHeight) {
binormals[attrIndex] = scratchPerPosBinormal.x;
binormals[attrIndex1] = scratchPerPosBinormal.y;
binormals[attrIndex2] = scratchPerPosBinormal.z;
} else {
binormals[attrIndex] = binormal.x;
binormals[attrIndex1] = binormal.y;
binormals[attrIndex2] = binormal.z;
}
}
}
attrIndex += 3;
Expand Down Expand Up @@ -294,14 +347,14 @@ define([

var createGeometryFromPositionsExtrudedPositions = [];

function createGeometryFromPositionsExtruded(ellipsoid, positions, granularity, hierarchy, perPositionHeight, closeTop, closeBottom) {
function createGeometryFromPositionsExtruded(ellipsoid, positions, granularity, hierarchy, perPositionHeight, closeTop, closeBottom, vertexFormat) {
var geos = {
walls : []
};
var i;

if (closeTop || closeBottom) {
var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, positions, granularity, perPositionHeight);
var topGeo = PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, positions, granularity, perPositionHeight, vertexFormat);

var edgePoints = topGeo.attributes.position.values;
var indices = topGeo.indices;
Expand Down Expand Up @@ -330,6 +383,11 @@ define([
}

topGeo.attributes.position.values = topBottomPositions;
if (perPositionHeight) {
var normals = topGeo.attributes.normal.values;
topGeo.attributes.normal.values = new Float32Array(topBottomPositions.length);
topGeo.attributes.normal.values.set(normals);
}
topGeo.indices = newIndices;
} else if (closeBottom) {
numPositions = edgePoints.length / 3;
Expand Down Expand Up @@ -735,6 +793,7 @@ define([
var geometries = [];

var options = {
perPositionHeight: perPositionHeight,
vertexFormat: vertexFormat,
geometry: undefined,
tangentPlane: tangentPlane,
Expand All @@ -749,7 +808,7 @@ define([
options.top = closeTop;
options.bottom = closeBottom;
for (i = 0; i < polygons.length; i++) {
geometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom);
geometry = createGeometryFromPositionsExtruded(ellipsoid, polygons[i], granularity, hierarchy[i], perPositionHeight, closeTop, closeBottom, vertexFormat);
if (closeTop && closeBottom) {
topAndBottom = geometry.topAndBottom;
options.geometry = PolygonGeometryLibrary.scaleToGeodeticHeightExtruded(topAndBottom.geometry, height, extrudedHeight, ellipsoid, perPositionHeight);
Expand Down Expand Up @@ -780,7 +839,7 @@ define([
} else {
for (i = 0; i < polygons.length; i++) {
geometry = new GeometryInstance({
geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight)
geometry : PolygonGeometryLibrary.createGeometryFromPositions(ellipsoid, polygons[i], granularity, perPositionHeight, vertexFormat)
});
geometry.geometry.attributes.position.values = PolygonPipeline.scaleToGeodeticHeight(geometry.geometry.attributes.position.values, height, ellipsoid, !perPositionHeight);
options.geometry = geometry.geometry;
Expand Down
13 changes: 10 additions & 3 deletions Source/Core/PolygonGeometryLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define([
'./Geometry',
'./GeometryAttribute',
'./GeometryAttributes',
'./GeometryPipeline',
'./IndexDatatype',
'./Math',
'./PolygonPipeline',
Expand All @@ -27,6 +28,7 @@ define([
Geometry,
GeometryAttribute,
GeometryAttributes,
GeometryPipeline,
IndexDatatype,
CesiumMath,
PolygonPipeline,
Expand Down Expand Up @@ -269,7 +271,7 @@ define([

var createGeometryFromPositionsPositions = [];

PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, positions, granularity, perPositionHeight) {
PolygonGeometryLibrary.createGeometryFromPositions = function(ellipsoid, positions, granularity, perPositionHeight, vertexFormat) {
var tangentPlane = EllipsoidTangentPlane.fromPoints(positions, ellipsoid);
var positions2D = tangentPlane.projectPointsOntoPlane(positions, createGeometryFromPositionsPositions);

Expand All @@ -295,8 +297,7 @@ define([
flattenedPositions[index++] = p.y;
flattenedPositions[index++] = p.z;
}

return new Geometry({
var geometry = new Geometry({
attributes : {
position : new GeometryAttribute({
componentDatatype : ComponentDatatype.DOUBLE,
Expand All @@ -307,6 +308,12 @@ define([
indices : indices,
primitiveType : PrimitiveType.TRIANGLES
});

if (vertexFormat.normal) {
return GeometryPipeline.computeNormal(geometry);
}

return geometry;
}

return PolygonPipeline.computeSubdivision(ellipsoid, positions, indices, granularity);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/QuantizedMeshTerrainData.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ define([
var maximumHeight = result.maximumHeight;
var boundingSphere = defaultValue(result.boundingSphere, that._boundingSphere);
var obb = defaultValue(result.orientedBoundingBox, that._orientedBoundingBox);
var occlusionPoint = defaultValue(result.occludeePointInScaledSpace, that._horizonOcclusionPoint);
var occlusionPoint = that._horizonOcclusionPoint;
var stride = result.vertexStride;
var terrainEncoding = TerrainEncoding.clone(result.encoding);

Expand Down
6 changes: 5 additions & 1 deletion Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ define([
}
id = uri + '#' + tokens[1];
}

styleEntity = styleCollection.getById(id);
if (!defined(styleEntity)) {
styleEntity = styleCollection.getById('#' + id);
Expand Down Expand Up @@ -1827,6 +1827,10 @@ define([
var networkEntity = r.entity;

var link = queryFirstNode(node, 'Link', namespaces.kml);

if(!defined(link)){
link = queryFirstNode(node, 'Url', namespaces.kml);
}
if (defined(link)) {
var href = queryStringValue(link, 'href', namespaces.kml);
if (defined(href)) {
Expand Down
Loading

0 comments on commit f290ca5

Please sign in to comment.