diff --git a/.gitignore b/.gitignore index ebdbdcfb19c8..8c1ca44ffb4c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ Thumbs.db /Apps/CesiumViewer/Gallery/gallery-index.js /Apps/Sandcastle/jsHintOptions.js -/Apps/Sandcastle/.jshintrc /Apps/Sandcastle/gallery/gallery-index.js /Source/Cesium.js diff --git a/.jshintrc b/.jshintrc index 41bbea9cc9b4..9d360ee6532f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -3,26 +3,26 @@ "camelcase": false, "curly": true, "eqeqeq": true, - "es3": true, "forin": true, + "freeze": true, "immed": true, - "latedef": true, + "latedef": false, "newcap": true, "noarg": true, - "noempty": false, + "noempty": true, + "nonbsp": true, "nonew": true, "plusplus": false, "quotmark": false, - "regexp": false, "undef": true, - "unused": false, + "unused": "vars", "strict": true, - "trailing": true, "asi": false, "boss": false, "debug": false, "eqnull": false, "esnext": false, + "moz": false, "evil": false, "expr": false, "funcscope": false, @@ -32,15 +32,31 @@ "laxbreak": false, "laxcomma": false, "loopfunc": false, - "moz": false, "multistr": true, + "noyield": false, + "notypeof": false, "proto": false, - "regexdash": false, "scripturl": false, - "smarttabs": false, "shadow": false, "sub": false, "supernew": false, + "validthis": false, "browser": true, - "predef": [ "JSON" ] + "browserify": false, + "couch": false, + "devel": true, + "dojo": false, + "jasmine": true, + "jquery": false, + "mocha": true, + "mootools": false, + "node": false, + "nonstandard": false, + "prototypejs": false, + "qunit": false, + "rhino": false, + "shelljs": false, + "worker": false, + "wsh": false, + "yui": false } \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 2dfa93e1b8e5..27cf02d7e417 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "0.10" + - "0.12" sudo: false script: - npm run jsHint && npm run release diff --git a/Apps/.jshintrc b/Apps/.jshintrc new file mode 100644 index 000000000000..24762c7dc745 --- /dev/null +++ b/Apps/.jshintrc @@ -0,0 +1,4 @@ +{ + "extends": "../.jshintrc", + "jasmine": false +} diff --git a/Apps/Sandcastle/.jshintrc b/Apps/Sandcastle/.jshintrc new file mode 100644 index 000000000000..6941e70549df --- /dev/null +++ b/Apps/Sandcastle/.jshintrc @@ -0,0 +1,12 @@ +{ + "extends": "../.jshintrc", + "jasmine": false, + "unused": false, + "predef": [ + "JSON", + "require", + "console", + "Sandcastle", + "Cesium" + ] +} diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index eb3522f3c92e..0365a7b5b19f 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -1,4 +1,4 @@ -/*global require,Blob,CodeMirror,JSHINT*/ +/*global require,Blob,JSHINT*/ /*global gallery_demos*/// defined by gallery/gallery-index.js, created by build /*global sandcastleJsHintOptions*/// defined by jsHintOptions.js, created by build require({ diff --git a/Apps/Sandcastle/gallery/Cesium Inspector.html b/Apps/Sandcastle/gallery/Cesium Inspector.html index 8c0a58ed10ca..ad804d476a55 100644 --- a/Apps/Sandcastle/gallery/Cesium Inspector.html +++ b/Apps/Sandcastle/gallery/Cesium Inspector.html @@ -35,7 +35,6 @@ var scene = viewer.scene; var globe = scene.globe; globe.depthTestAgainstTerrain = true; -var ellipsoid = globe.ellipsoid; var cesiumTerrainProviderHeightmaps = new Cesium.CesiumTerrainProvider({ url : '//assets.agi.com/stk-terrain/world', diff --git a/Apps/Sandcastle/gallery/Picking.html b/Apps/Sandcastle/gallery/Picking.html index 8655d47583ec..6616cd00b9fe 100644 --- a/Apps/Sandcastle/gallery/Picking.html +++ b/Apps/Sandcastle/gallery/Picking.html @@ -36,7 +36,6 @@ var handler; Sandcastle.addDefaultToolbarButton('Show Cartographic Position on Mouse Over', function() { - var ellipsoid = scene.globe.ellipsoid; var entity = viewer.entities.add({ label : { show : false @@ -46,9 +45,9 @@ // Mouse over the globe to see the cartographic position handler = new Cesium.ScreenSpaceEventHandler(scene.canvas); handler.setInputAction(function(movement) { - var cartesian = viewer.camera.pickEllipsoid(movement.endPosition, ellipsoid); + var cartesian = viewer.camera.pickEllipsoid(movement.endPosition, scene.globe.ellipsoid); if (cartesian) { - var cartographic = ellipsoid.cartesianToCartographic(cartesian); + var cartographic = Cesium.Cartographic.fromCartesian(cartesian); var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2); var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2); @@ -145,8 +144,6 @@ }); Sandcastle.addToolbarButton('Pick position', function() { - var ellipsoid = scene.globe.ellipsoid; - var modelEntity = viewer.entities.add({ name : 'milktruck', position : Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706), @@ -174,7 +171,7 @@ var cartesian = viewer.scene.pickPosition(movement.endPosition); if (Cesium.defined(cartesian)) { - var cartographic = ellipsoid.cartesianToCartographic(cartesian); + var cartographic = Cesium.Cartographic.fromCartesian(cartesian); var longitudeString = Cesium.Math.toDegrees(cartographic.longitude).toFixed(2); var latitudeString = Cesium.Math.toDegrees(cartographic.latitude).toFixed(2); var heightString = cartographic.height.toFixed(2); diff --git a/Apps/Sandcastle/gallery/Terrain Exaggeration.html b/Apps/Sandcastle/gallery/Terrain Exaggeration.html new file mode 100644 index 000000000000..6ea88244b425 --- /dev/null +++ b/Apps/Sandcastle/gallery/Terrain Exaggeration.html @@ -0,0 +1,92 @@ + + + + + + + + + Cesium Demo + + + + + + +
+

Loading...

+
+
+
+ + + \ No newline at end of file diff --git a/Apps/Sandcastle/gallery/Terrain Exaggeration.jpg b/Apps/Sandcastle/gallery/Terrain Exaggeration.jpg new file mode 100644 index 000000000000..b553cda91907 Binary files /dev/null and b/Apps/Sandcastle/gallery/Terrain Exaggeration.jpg differ diff --git a/Apps/Sandcastle/gallery/Terrain.html b/Apps/Sandcastle/gallery/Terrain.html index 62c2722fb4f5..161191a44e6a 100644 --- a/Apps/Sandcastle/gallery/Terrain.html +++ b/Apps/Sandcastle/gallery/Terrain.html @@ -203,4 +203,4 @@ } - + \ No newline at end of file diff --git a/Apps/Sandcastle/gallery/Video.html b/Apps/Sandcastle/gallery/Video.html new file mode 100644 index 000000000000..1aff99ae3c68 --- /dev/null +++ b/Apps/Sandcastle/gallery/Video.html @@ -0,0 +1,129 @@ + + + + + + + + + Cesium Demo + + + + + + + +
+

Loading...

+
+ + + + + diff --git a/Apps/Sandcastle/gallery/Video.jpg b/Apps/Sandcastle/gallery/Video.jpg new file mode 100644 index 000000000000..dd2b3542beb6 Binary files /dev/null and b/Apps/Sandcastle/gallery/Video.jpg differ diff --git a/Specs/Sandcastle/QuadtreePrimitive.html b/Apps/Sandcastle/gallery/development/QuadtreePrimitive.html similarity index 92% rename from Specs/Sandcastle/QuadtreePrimitive.html rename to Apps/Sandcastle/gallery/development/QuadtreePrimitive.html index c8eee939ef64..c0be08bd69fa 100644 --- a/Specs/Sandcastle/QuadtreePrimitive.html +++ b/Apps/Sandcastle/gallery/development/QuadtreePrimitive.html @@ -1,9 +1,3 @@ - @@ -11,20 +5,20 @@ - + Cesium Demo - +

Loading...

diff --git a/CHANGES.md b/CHANGES.md index f8cbd94b685e..c4c6ae2d1a24 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,10 +13,21 @@ Change Log * Entity collections have a reference to their owner (usually a data source, but can be a `CompositeEntityCollection`). * `GeoJsonDataSource.load` now takes an optional `describeProperty` function for generating feature description properties. [#3140](https://github.com/AnalyticalGraphicsInc/cesium/pull/3140) * Fixed a bug which caused `Entity` polyline graphics to be incorrect when a scene's ellipsoid was not WGS84. [#3174](https://github.com/AnalyticalGraphicsInc/cesium/pull/3174) +* Fixed `JulianDate.fromIso8601 ` so that it correctly parses the `YYYY-MM-DDThh:mmTZD` format. * Added `ImageryProvider.readyPromise` and `TerrainProvider.readyPromise` and implemented it in all terrain and imagery providers. This is a promise which resolves when `ready` becomes true and rejected if there is an error during initialization. [#3175](https://github.com/AnalyticalGraphicsInc/cesium/pull/3175) * Added support for fog near the horizon, which improves performance by rendering less terrain tiles and reduces terrain tile requests. This is enabled by default. See `Scene.fog` for options. [#3154](https://github.com/AnalyticalGraphicsInc/cesium/pull/3154) * Added `Queue.peek` to return the item at the front of a Queue. * Added `Camera.distanceToBoundingSphere` function. +* Added utility function `getBaseUri`, which given a URI with or without query parameters, returns the base path of the URI. +* Added support for incrementally loading textures after a Model is ready. This allows the Model to be visible as soon as possible while its textures are loaded in the background. +* Added `Cartographic.fromCartesian` function. +* Added `Camera.getPixelSize` function to get the size of a pixel in meters based on the current view. +* Added terrain exaggeration. Enabled on viewer creation with the exaggeration scalar as the `terrainExaggeration` option. +* Added `ImageMaterialProperty.alpha` and a `alpha` uniform to `Image` `Material` types to control overall image opacity. It defaults to 1.0, fully opaque. +* `ImageMaterialProperty.image` now accepts an `HTMLVideoElement`. You can also assign a video element directly to an Entity `material` property. +* `Material` image uniforms now accept and `HTMLVideoElement` anywhere it could previously take a `Canvas` element. +* Added `VideoSynchronizer` helper object for keeping an `HTMLVideoElement` in sync with a scene's clock. +* Added 'Video' Sandcastle showcase to demonstrate video materials. * Fixed an issue with tile selection when below the surface of the ellipsoid. [#3170](https://github.com/AnalyticalGraphicsInc/cesium/issues/3170) ### 1.15 - 2015-11-02 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f63543bad9be..1a079714c39f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -27,6 +27,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Sean Lilley](https://github.com/lilleyse) * [Katherina Lim](https://github.com/klim705) * [Gabrielle Getz](https://github.com/ggetz) + * [Sarah Chow](https://github.com/slchow) + * [Brendan Flood](https://github.com/bflood-agi) * [NICTA](http://www.nicta.com.au/) * [Chris Cooper](https://github.com/chris-cooper) * [Kevin Ring](https://github.com/kring) diff --git a/Documentation/Images/CornerTypeBeveled.png b/Documentation/Images/CornerTypeBeveled.png new file mode 100644 index 000000000000..cd3e5ea452bf Binary files /dev/null and b/Documentation/Images/CornerTypeBeveled.png differ diff --git a/Documentation/Images/CornerTypeMitered.png b/Documentation/Images/CornerTypeMitered.png new file mode 100644 index 000000000000..9032f2b9f006 Binary files /dev/null and b/Documentation/Images/CornerTypeMitered.png differ diff --git a/Documentation/Images/CornerTypeRounded.png b/Documentation/Images/CornerTypeRounded.png new file mode 100644 index 000000000000..25a046dd2253 Binary files /dev/null and b/Documentation/Images/CornerTypeRounded.png differ diff --git a/LICENSE.md b/LICENSE.md index 879dfec721ef..b3c3dc8ce5d0 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -263,6 +263,18 @@ Copyright (c) 2008-2015 Pivotal Labs > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +Cesium Documentation +==================== + +The Cesium documentation files include the following third-party content. + +### Source Sans Pro (Font) + +SourceĀ® Sans Pro, Adobe's first open source typeface family, was designed by Paul D. Hunt. It is a sans serif typeface intended to work well in user interfaces. + +[SIL Open Font License, 1.1](http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) ([text](http://scripts.sil.org/cms/scripts/render_download.php?format=file&media_id=OFL_plaintext&filename=OFL.txt)) + + Example Applications ==================== @@ -356,6 +368,12 @@ https://www.mapbox.com/maki/ https://github.com/mapbox/maki +### Big Buck Bunny trailer + +Creative Commons Attribution 3.0 +(c) copyright 2008, Blender Foundation +www.bigbuckbunny.org + ### population909500.json ### https://github.com/dataarts/webgl-globe diff --git a/README.md b/README.md index bf1ca3c6568a..d3ae8e2fd7ec 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,11 @@ We appreciate attribution by including the Cesium logo and link in your app. ### Demos ###

+  +  +  +  +        diff --git a/Source/.jshintrc b/Source/.jshintrc new file mode 100644 index 000000000000..24762c7dc745 --- /dev/null +++ b/Source/.jshintrc @@ -0,0 +1,4 @@ +{ + "extends": "../.jshintrc", + "jasmine": false +} diff --git a/Source/Core/Cartographic.js b/Source/Core/Cartographic.js index 96588dcdd141..2c29e60ea9e9 100644 --- a/Source/Core/Cartographic.js +++ b/Source/Core/Cartographic.js @@ -1,16 +1,20 @@ /*global define*/ define([ + './Cartesian3', './defaultValue', './defined', './DeveloperError', './freezeObject', - './Math' + './Math', + './scaleToGeodeticSurface' ], function( + Cartesian3, defaultValue, defined, DeveloperError, freezeObject, - CesiumMath) { + CesiumMath, + scaleToGeodeticSurface) { "use strict"; /** @@ -105,6 +109,52 @@ define([ return Cartographic.fromRadians(longitude, latitude, height, result); }; + var cartesianToCartographicN = new Cartesian3(); + var cartesianToCartographicP = new Cartesian3(); + var cartesianToCartographicH = new Cartesian3(); + var wgs84OneOverRadii = new Cartesian3(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.3142451793); + var wgs84OneOverRadiiSquared = new Cartesian3(1.0 / (6378137.0 * 6378137.0), 1.0 / (6378137.0 * 6378137.0), 1.0 / (6356752.3142451793 * 6356752.3142451793)); + var wgs84CenterToleranceSquared = CesiumMath.EPSILON1; + + /** + * Creates a new Cartographic instance from a Cartesian position. The values in the + * resulting object will be in radians. + * + * @param {Cartesian3} cartesian The Cartesian position to convert to cartographic representation. + * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the position lies. + * @param {Cartographic} [result] The object onto which to store the result. + * @returns {Cartographic} The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid. + */ + Cartographic.fromCartesian = function(cartesian, ellipsoid, result) { + var oneOverRadii = defined(ellipsoid) ? ellipsoid.oneOverRadii : wgs84OneOverRadii; + var oneOverRadiiSquared = defined(ellipsoid) ? ellipsoid.oneOverRadiiSquared : wgs84OneOverRadiiSquared; + var centerToleranceSquared = defined(ellipsoid) ? ellipsoid._centerToleranceSquared : wgs84CenterToleranceSquared; + + //`cartesian is required.` is thrown from scaleToGeodeticSurface + var p = scaleToGeodeticSurface(cartesian, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, cartesianToCartographicP); + + if (!defined(p)) { + return undefined; + } + + var n = Cartesian3.multiplyComponents(cartesian, oneOverRadiiSquared, cartesianToCartographicN); + n = Cartesian3.normalize(n, n); + + var h = Cartesian3.subtract(cartesian, p, cartesianToCartographicH); + + var longitude = Math.atan2(n.y, n.x); + var latitude = Math.asin(n.z); + var height = CesiumMath.sign(Cartesian3.dot(h, cartesian)) * Cartesian3.magnitude(h); + + if (!defined(result)) { + return new Cartographic(longitude, latitude, height); + } + result.longitude = longitude; + result.latitude = latitude; + result.height = height; + return result; + }; + /** * Duplicates a Cartographic instance. * diff --git a/Source/Core/CornerType.js b/Source/Core/CornerType.js index 67613c671d70..542ae7e5ed20 100644 --- a/Source/Core/CornerType.js +++ b/Source/Core/CornerType.js @@ -8,29 +8,24 @@ define([ /** * Style options for corners. * + * @demo The {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Corridor.html&label=Geometries|Corridor Demo} + * demonstrates the three corner types, as used by {@link CorridorGraphics}. + * * @namespace * @alias CornerType */ var CornerType = { /** - *

-         *  _____
-         * (  ___
-         * | |
-         * 
+ * * - * Corner is circular. + * Corner has a smooth edge. * @type {Number} * @constant */ ROUNDED : 0, /** - *
-         *  ______
-         * |  ____
-         * | |
-         * 
+ * * * Corner point is the intersection of adjacent edges. * @type {Number} @@ -39,11 +34,7 @@ define([ MITERED : 1, /** - *
-         *  _____
-         * /  ___
-         * | |
-         * 
+ * * * Corner is clipped. * @type {Number} diff --git a/Source/Core/Ellipsoid.js b/Source/Core/Ellipsoid.js index b5257e4e9521..7071158b8979 100644 --- a/Source/Core/Ellipsoid.js +++ b/Source/Core/Ellipsoid.js @@ -7,7 +7,8 @@ define([ './defineProperties', './DeveloperError', './freezeObject', - './Math' + './Math', + './scaleToGeodeticSurface' ], function( Cartesian3, Cartographic, @@ -16,7 +17,8 @@ define([ defineProperties, DeveloperError, freezeObject, - CesiumMath) { + CesiumMath, + scaleToGeodeticSurface) { "use strict"; function initialize(ellipsoid, x, y, z) { @@ -501,9 +503,6 @@ define([ return result; }; - var scaleToGeodeticSurfaceIntersection = new Cartesian3(); - var scaleToGeodeticSurfaceGradient = new Cartesian3(); - /** * Scales the provided Cartesian position along the geodetic surface normal * so that it is on the surface of this ellipsoid. If the position is @@ -514,98 +513,7 @@ define([ * @returns {Cartesian3} The modified result parameter, a new Cartesian3 instance if none was provided, or undefined if the position is at the center. */ Ellipsoid.prototype.scaleToGeodeticSurface = function(cartesian, result) { - //>>includeStart('debug', pragmas.debug); - if (!defined(cartesian)) { - throw new DeveloperError('cartesian is required.'); - } - //>>includeEnd('debug'); - - var positionX = cartesian.x; - var positionY = cartesian.y; - var positionZ = cartesian.z; - - var oneOverRadii = this._oneOverRadii; - var oneOverRadiiX = oneOverRadii.x; - var oneOverRadiiY = oneOverRadii.y; - var oneOverRadiiZ = oneOverRadii.z; - - var x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX; - var y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY; - var z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ; - - // Compute the squared ellipsoid norm. - var squaredNorm = x2 + y2 + z2; - var ratio = Math.sqrt(1.0 / squaredNorm); - - // As an initial approximation, assume that the radial intersection is the projection point. - var intersection = Cartesian3.multiplyByScalar(cartesian, ratio, scaleToGeodeticSurfaceIntersection); - - //* If the position is near the center, the iteration will not converge. - if (squaredNorm < this._centerToleranceSquared) { - return !isFinite(ratio) ? undefined : Cartesian3.clone(intersection, result); - } - - var oneOverRadiiSquared = this._oneOverRadiiSquared; - var oneOverRadiiSquaredX = oneOverRadiiSquared.x; - var oneOverRadiiSquaredY = oneOverRadiiSquared.y; - var oneOverRadiiSquaredZ = oneOverRadiiSquared.z; - - // Use the gradient at the intersection point in place of the true unit normal. - // The difference in magnitude will be absorbed in the multiplier. - var gradient = scaleToGeodeticSurfaceGradient; - gradient.x = intersection.x * oneOverRadiiSquaredX * 2.0; - gradient.y = intersection.y * oneOverRadiiSquaredY * 2.0; - gradient.z = intersection.z * oneOverRadiiSquaredZ * 2.0; - - // Compute the initial guess at the normal vector multiplier, lambda. - var lambda = (1.0 - ratio) * Cartesian3.magnitude(cartesian) / (0.5 * Cartesian3.magnitude(gradient)); - var correction = 0.0; - - var func; - var denominator; - var xMultiplier; - var yMultiplier; - var zMultiplier; - var xMultiplier2; - var yMultiplier2; - var zMultiplier2; - var xMultiplier3; - var yMultiplier3; - var zMultiplier3; - - do { - lambda -= correction; - - xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX); - yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY); - zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ); - - xMultiplier2 = xMultiplier * xMultiplier; - yMultiplier2 = yMultiplier * yMultiplier; - zMultiplier2 = zMultiplier * zMultiplier; - - xMultiplier3 = xMultiplier2 * xMultiplier; - yMultiplier3 = yMultiplier2 * yMultiplier; - zMultiplier3 = zMultiplier2 * zMultiplier; - - func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0; - - // "denominator" here refers to the use of this expression in the velocity and acceleration - // computations in the sections to follow. - denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ; - - var derivative = -2.0 * denominator; - - correction = func / derivative; - } while (Math.abs(func) > CesiumMath.EPSILON12); - - if (!defined(result)) { - return new Cartesian3(positionX * xMultiplier, positionY * yMultiplier, positionZ * zMultiplier); - } - result.x = positionX * xMultiplier; - result.y = positionY * yMultiplier; - result.z = positionZ * zMultiplier; - return result; + return scaleToGeodeticSurface(cartesian, this._oneOverRadii, this._oneOverRadiiSquared, this._centerToleranceSquared, result); }; /** diff --git a/Source/Core/GeometryPipeline.js b/Source/Core/GeometryPipeline.js index bc055a91b454..ee49c5300b03 100644 --- a/Source/Core/GeometryPipeline.js +++ b/Source/Core/GeometryPipeline.js @@ -2079,7 +2079,6 @@ define([ var westGeometry = copyGeometryForSplit(geometry); var i; - var index; var length = indices.length; var westGeometryIndexMap = []; @@ -2181,7 +2180,6 @@ define([ var cartesian3Scratch6 = new Cartesian3(); var cartesian4Scratch0 = new Cartesian4(); - var cartesian4Scratch1 = new Cartesian4(); function splitLongitudePolyline(instance) { var geometry = instance.geometry; @@ -2190,7 +2188,6 @@ define([ var prevPositions = attributes.prevPosition.values; var nextPositions = attributes.nextPosition.values; var expandAndWidths = attributes.expandAndWidth.values; - var indices = geometry.indices; var texCoords = (defined(attributes.st)) ? attributes.st.values : undefined; var colors = (defined(attributes.color)) ? attributes.color.values : undefined; diff --git a/Source/Core/HeightmapTerrainData.js b/Source/Core/HeightmapTerrainData.js index c82da0e9ac5a..6a6aa7150d2a 100644 --- a/Source/Core/HeightmapTerrainData.js +++ b/Source/Core/HeightmapTerrainData.js @@ -153,11 +153,12 @@ define([ * @param {Number} x The X coordinate of the tile for which to create the terrain data. * @param {Number} y The Y coordinate of the tile for which to create the terrain data. * @param {Number} level The level of the tile for which to create the terrain data. + * @param {Number} [exaggeration=1.0] The scale used to exaggerate the terrain. * @returns {Promise.|undefined} A promise for the terrain mesh, or undefined if too many * asynchronous mesh creations are already in progress and the operation should * be retried later. */ - HeightmapTerrainData.prototype.createMesh = function(tilingScheme, x, y, level) { + HeightmapTerrainData.prototype.createMesh = function(tilingScheme, x, y, level, exaggeration) { //>>includeStart('debug', pragmas.debug); if (!defined(tilingScheme)) { throw new DeveloperError('tilingScheme is required.'); @@ -176,6 +177,7 @@ define([ var ellipsoid = tilingScheme.ellipsoid; var nativeRectangle = tilingScheme.tileXYToNativeRectangle(x, y, level); var rectangle = tilingScheme.tileXYToRectangle(x, y, level); + exaggeration = defaultValue(exaggeration, 1.0); // Compute the center of the tile for RTC rendering. var center = ellipsoid.cartographicToCartesian(Rectangle.center(rectangle)); @@ -195,7 +197,8 @@ define([ relativeToCenter : center, ellipsoid : ellipsoid, skirtHeight : Math.min(thisLevelMaxError * 4.0, 1000.0), - isGeographic : tilingScheme instanceof GeographicTilingScheme + isGeographic : tilingScheme instanceof GeographicTilingScheme, + exaggeration : exaggeration }); if (!defined(verticesPromise)) { diff --git a/Source/Core/HeightmapTessellator.js b/Source/Core/HeightmapTessellator.js index db1c326719e7..fa9458733880 100644 --- a/Source/Core/HeightmapTessellator.js +++ b/Source/Core/HeightmapTessellator.js @@ -60,6 +60,7 @@ define([ * @param {Rectangle} options.nativeRectangle An rectangle in the native coordinates of the heightmap's projection. For * a heightmap with a geographic projection, this is degrees. For the web mercator * projection, this is meters. + * @param {Number} [options.exaggeration=1.0] The scale used to exaggerate the terrain. * @param {Rectangle} [options.rectangle] The rectangle covered by the heightmap, in geodetic coordinates with north, south, east and * west properties in radians. Either rectangle or nativeRectangle must be provided. If both * are provided, they're assumed to be consistent. @@ -179,6 +180,7 @@ define([ } var relativeToCenter = defaultValue(options.relativeToCenter, Cartesian3.ZERO); + var exaggeration = defaultValue(options.exaggeration, 1.0); var structure = defaultValue(options.structure, HeightmapTessellator.DEFAULT_STRUCTURE); var heightScale = defaultValue(structure.heightScale, HeightmapTessellator.DEFAULT_STRUCTURE.heightScale); @@ -273,7 +275,7 @@ define([ } } - heightSample = heightSample * heightScale + heightOffset; + heightSample = (heightSample * heightScale + heightOffset) * exaggeration; maximumHeight = Math.max(maximumHeight, heightSample); minimumHeight = Math.min(minimumHeight, heightSample); diff --git a/Source/Core/IntersectionTests.js b/Source/Core/IntersectionTests.js index 808799071bc5..902cd076067b 100644 --- a/Source/Core/IntersectionTests.js +++ b/Source/Core/IntersectionTests.js @@ -344,7 +344,6 @@ define([ //>>includeEnd('debug'); var ray = scratchLineSegmentRay; - var origin = Cartesian3.clone(p0, ray.origin); var direction = Cartesian3.subtract(p1, p0, ray.direction); var maxT = Cartesian3.magnitude(direction); diff --git a/Source/Core/Intersections2D.js b/Source/Core/Intersections2D.js index b5e2434dd02c..7347218bd865 100644 --- a/Source/Core/Intersections2D.js +++ b/Source/Core/Intersections2D.js @@ -202,14 +202,13 @@ define([ result.push(2); result.push(u12Ratio); } - } else if (numBehind === 3) { - // Completely behind threshold - } else { + } else if (numBehind !== 3) { // Completely in front of threshold result.push(0); result.push(1); result.push(2); } + // else Completely behind threshold return result; }; @@ -283,4 +282,4 @@ define([ }; return Intersections2D; -}); \ No newline at end of file +}); diff --git a/Source/Core/JulianDate.js b/Source/Core/JulianDate.js index 390ff91b975f..c4b1a7a0f162 100644 --- a/Source/Core/JulianDate.js +++ b/Source/Core/JulianDate.js @@ -360,7 +360,7 @@ define([ tokens = time.match(matchHoursMinutes); if (tokens !== null) { dashCount = time.split(':').length - 1; - if (dashCount > 0 && dashCount !== 1) { + if (dashCount > 2) { throw new DeveloperError(iso8601ErrorMessage); } diff --git a/Source/Core/OrientedBoundingBox.js b/Source/Core/OrientedBoundingBox.js index a0394432d874..094a7087a439 100644 --- a/Source/Core/OrientedBoundingBox.js +++ b/Source/Core/OrientedBoundingBox.js @@ -470,7 +470,6 @@ define([ var scratchCorner = new Cartesian3(); var scratchToCenter = new Cartesian3(); - var scratchProj = new Cartesian3(); /** * The distances calculated by the vector from the center of the bounding box to position projected onto direction. diff --git a/Source/Core/PointGeometry.js b/Source/Core/PointGeometry.js new file mode 100644 index 000000000000..14385febb638 --- /dev/null +++ b/Source/Core/PointGeometry.js @@ -0,0 +1,104 @@ +/*global define*/ +define([ + './BoundingSphere', + './ComponentDatatype', + './defaultValue', + './defined', + './DeveloperError', + './Geometry', + './GeometryAttribute', + './GeometryAttributes', + './PrimitiveType' + ], function( + BoundingSphere, + ComponentDatatype, + defaultValue, + defined, + DeveloperError, + Geometry, + GeometryAttribute, + GeometryAttributes, + PrimitiveType) { + "use strict"; + + /** + * Describes a collection of points made up of positions and colors. + * + * @alias PointGeometry + * @constructor + * + * @param {Object} options Object with the following properties: + * @param {TypedArray} options.positionsTypedArray The position values of the points stored in a typed array. Positions are stored as packed (x, y, z) floats. + * @param {TypedArray} options.colorsTypedArray The color values of the points stored in a typed array. Colors are stored as packed (r, g, b) unsigned bytes. + * @param {BoundingSphere} [options.boundingSphere] Optional precomputed bounding sphere to save computation time. + * + * @example + * // Create a PointGeometry with two points + * var points = new Cesium.PointGeometry({ + * positionsTypedArray : new Float32Array([0.0, 0.0, 0.0, 1.0, 1.0, 1.0]), + * colorsTypedArray : new Uint8Array([255, 0, 0, 127, 127, 127]), + * boundingSphere : boundingSphere + * }); + * var geometry = Cesium.PointGeometry.createGeometry(points); + * + * @private + */ + var PointGeometry = function(options) { + options = defaultValue(options, defaultValue.EMPTY_OBJECT); + + //>>includeStart('debug', pragmas.debug); + if (!defined(options.positionsTypedArray)) { + throw new DeveloperError('options.positionsTypedArray is required.'); + } + if (!defined(options.colorsTypedArray)) { + throw new DeveloperError('options.colorsTypedArray is required'); + } + //>>includeEnd('debug'); + + this._positionsTypedArray = options.positionsTypedArray; + this._colorsTypedArray = options.colorsTypedArray; + this._boundingSphere = BoundingSphere.clone(options.boundingSphere); + + this._workerName = 'createPointGeometry'; + }; + + /** + * Computes the geometric representation a point collection, including its vertices and a bounding sphere. + * + * @param {PointGeometry} pointGeometry A description of the points. + * @returns {Geometry} The computed vertices. + */ + PointGeometry.createGeometry = function(pointGeometry) { + var positions = pointGeometry._positionsTypedArray; + var componentByteLength = positions.byteLength / positions.length; + var componentDatatype = componentByteLength === 4 ? ComponentDatatype.FLOAT : ComponentDatatype.DOUBLE; + + var attributes = new GeometryAttributes(); + attributes.position = new GeometryAttribute({ + componentDatatype : componentDatatype, + componentsPerAttribute : 3, + values : positions + }); + + attributes.color = new GeometryAttribute({ + componentDatatype : ComponentDatatype.UNSIGNED_BYTE, + componentsPerAttribute : 3, + values : pointGeometry._colorsTypedArray, + normalize : true + }); + + // User provided bounding sphere to save computation time. + var boundingSphere = pointGeometry._boundingSphere; + if (!defined(boundingSphere)) { + boundingSphere = BoundingSphere.fromVertices(positions); + } + + return new Geometry({ + attributes : attributes, + primitiveType : PrimitiveType.POINTS, + boundingSphere : boundingSphere + }); + }; + + return PointGeometry; +}); diff --git a/Source/Core/PolygonPipeline.js b/Source/Core/PolygonPipeline.js index e3805ed4625f..21cf15abba7b 100644 --- a/Source/Core/PolygonPipeline.js +++ b/Source/Core/PolygonPipeline.js @@ -547,7 +547,6 @@ define([ * * @private */ - var intersectionScratch = new Cartesian2(); var aDirectionScratch = new Cartesian2(); var bDirectionScratch = new Cartesian2(); diff --git a/Source/Core/PolylineGeometry.js b/Source/Core/PolylineGeometry.js index e480c7c30129..e1e1c62430a3 100644 --- a/Source/Core/PolylineGeometry.js +++ b/Source/Core/PolylineGeometry.js @@ -371,10 +371,6 @@ define([ var expandAndWidthIndex = 0; var stIndex = 0; var colorIndex = 0; - - var segmentLength; - var segmentIndex = 0; - var count = 0; var position; for (j = 0; j < positionsLength; ++j) { diff --git a/Source/Core/QuantizedMeshTerrainData.js b/Source/Core/QuantizedMeshTerrainData.js index 33260e797059..9d4db995b711 100644 --- a/Source/Core/QuantizedMeshTerrainData.js +++ b/Source/Core/QuantizedMeshTerrainData.js @@ -175,7 +175,6 @@ define([ return uValues[a] - uValues[b]; } - var requires32BitIndices = vertexCount > 64 * 1024; this._westIndices = sortIndicesIfNecessary(options.westIndices, sortByV, vertexCount); this._southIndices = sortIndicesIfNecessary(options.southIndices, sortByU, vertexCount); this._eastIndices = sortIndicesIfNecessary(options.eastIndices, sortByV, vertexCount); @@ -235,11 +234,12 @@ define([ * @param {Number} x The X coordinate of the tile for which to create the terrain data. * @param {Number} y The Y coordinate of the tile for which to create the terrain data. * @param {Number} level The level of the tile for which to create the terrain data. + * @param {Number} [exaggeration=1.0] The scale used to exaggerate the terrain. * @returns {Promise.|undefined} A promise for the terrain mesh, or undefined if too many * asynchronous mesh creations are already in progress and the operation should * be retried later. */ - QuantizedMeshTerrainData.prototype.createMesh = function(tilingScheme, x, y, level) { + QuantizedMeshTerrainData.prototype.createMesh = function(tilingScheme, x, y, level, exaggeration) { //>>includeStart('debug', pragmas.debug); if (!defined(tilingScheme)) { throw new DeveloperError('tilingScheme is required.'); @@ -257,6 +257,7 @@ define([ var ellipsoid = tilingScheme.ellipsoid; var rectangle = tilingScheme.tileXYToRectangle(x, y, level); + exaggeration = defaultValue(exaggeration, 1.0); var verticesPromise = createMeshTaskProcessor.scheduleTask({ minimumHeight : this._minimumHeight, @@ -274,7 +275,8 @@ define([ northSkirtHeight : this._northSkirtHeight, rectangle : rectangle, relativeToCenter : this._boundingSphere.center, - ellipsoid : ellipsoid + ellipsoid : ellipsoid, + exaggeration : exaggeration }); if (!defined(verticesPromise)) { @@ -288,16 +290,25 @@ define([ vertexCount += that._westIndices.length + that._southIndices.length + that._eastIndices.length + that._northIndices.length; var indicesTypedArray = IndexDatatype.createTypedArray(vertexCount, result.indices); + var vertices = new Float32Array(result.vertices); + var rtc = result.center; + var minimumHeight = result.minimumHeight; + 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 stride = result.vertexStride; + return new TerrainMesh( - that._boundingSphere.center, - new Float32Array(result.vertices), + rtc, + vertices, indicesTypedArray, - that._minimumHeight, - that._maximumHeight, - that._boundingSphere, - that._horizonOcclusionPoint, - defined(that._encodedNormals) ? 7 : 6, - that._orientedBoundingBox); + minimumHeight, + maximumHeight, + boundingSphere, + occlusionPoint, + stride, + obb); }); }; diff --git a/Source/Core/VideoSynchronizer.js b/Source/Core/VideoSynchronizer.js new file mode 100644 index 000000000000..4570cae1ed68 --- /dev/null +++ b/Source/Core/VideoSynchronizer.js @@ -0,0 +1,220 @@ +/*global define*/ +define([ + './defaultValue', + './defined', + './defineProperties', + './destroyObject', + './DeveloperError', + './Event', + './Iso8601', + './JulianDate' + ], function( + defaultValue, + defined, + defineProperties, + destroyObject, + DeveloperError, + Event, + Iso8601, + JulianDate) { + "use strict"; + + /** + * Synchronizes a video element with a simulation clock. + * + * @alias VideoSynchronizer + * @constructor + * + * @param {Object} [options] Object with the following properties: + * @param {Clock} [options.clock] The clock instance used to drive the video. + * @param {HTMLVideoElement} [options.element] The video element to be synchronized. + * @param {JulianDate} [options.epoch=Iso8601.MINIMUM_VALUE] The simulation time that marks the start of the video. + * @param {Number} [options.tolerance=1.0] The maximum amount of time, in seconds, that the clock and video can diverge. + * + * @demo {@link http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Video.html|Video Material Demo} + */ + var VideoSynchronizer = function(options) { + options = defaultValue(options, defaultValue.EMPTY_OBJECT); + + this._clock = undefined; + this._element = undefined; + this._clockSubscription = undefined; + this._seekFunction = undefined; + + this.clock = options.clock; + this.element = options.element; + + /** + * Gets or sets the simulation time that marks the start of the video. + * @type {JulianDate} + * @default Iso8601.MINIMUM_VALUE + */ + this.epoch = defaultValue(options.epoch, Iso8601.MINIMUM_VALUE); + + /** + * Gets or sets the amount of time in seconds the video's currentTime + * and the clock's currentTime can diverge before a video seek is performed. + * Lower values make the synchronization more accurate but video + * performance might suffer. Higher values provide better performance + * but at the cost of accuracy. + * @type {Number} + * @default 1.0 + */ + this.tolerance = defaultValue(options.tolerance, 1.0); + + this._seeking = false; + this._seekFunction = undefined; + this._firstTickAfterSeek = false; + }; + + defineProperties(VideoSynchronizer.prototype, { + /** + * Gets or sets the clock used to drive the video element. + * + * @memberof VideoSynchronizer.prototype + * @type {Clock} + */ + clock : { + get : function() { + return this._clock; + }, + set : function(value) { + var oldValue = this._clock; + + if (oldValue === value) { + return; + } + + if (defined(oldValue)) { + this._clockSubscription(); + this._clockSubscription = undefined; + } + + if (defined(value)) { + this._clockSubscription = value.onTick.addEventListener(VideoSynchronizer.prototype._onTick, this); + } + + this._clock = value; + } + }, + /** + * Gets or sets the video element to synchronize. + * + * @memberof VideoSynchronizer.prototype + * @type {HTMLVideoElement} + */ + element : { + get : function() { + return this._element; + }, + set : function(value) { + var oldValue = this._element; + + if (oldValue === value) { + return; + } + + if (defined(oldValue)) { + oldValue.removeEventListener("seeked", this._seekFunction, false); + } + + if (defined(value)) { + this._seeking = false; + this._seekFunction = createSeekFunction(this); + value.addEventListener("seeked", this._seekFunction, false); + } + + this._element = value; + this._seeking = false; + this._firstTickAfterSeek = false; + } + } + }); + + /** + * Destroys and resources used by the object. Once an object is destroyed, it should not be used. + * + * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called. + */ + VideoSynchronizer.prototype.destroy = function() { + this.element = undefined; + this.clock = undefined; + return destroyObject(this); + }; + + /** + * Returns true if this object was destroyed; otherwise, false. + * + * @returns {Boolean} True if this object was destroyed; otherwise, false. + */ + VideoSynchronizer.prototype.isDestroyed = function() { + return false; + }; + + VideoSynchronizer.prototype._onTick = function(clock) { + var element = this._element; + if (!defined(element) || element.readyState < 2) { + return; + } + + var paused = element.paused; + var shouldAnimate = clock.shouldAnimate; + if (shouldAnimate === paused) { + if (shouldAnimate) { + element.play(); + } else { + element.pause(); + } + } + + //We need to avoid constant seeking or the video will + //never contain a complete frame for us to render. + //So don't do anything if we're seeing or on the first + //tick after a seek (the latter of which allows the frame + //to actually be rendered. + if (this._seeking || this._firstTickAfterSeek) { + this._firstTickAfterSeek = false; + return; + } + + element.playbackRate = clock.multiplier; + + var clockTime = clock.currentTime; + var epoch = defaultValue(this.epoch, Iso8601.MINIMUM_VALUE); + var videoTime = JulianDate.secondsDifference(clockTime, epoch); + + var duration = element.duration; + var desiredTime; + var currentTime = element.currentTime; + if (element.loop) { + videoTime = videoTime % duration; + if (videoTime < 0.0) { + videoTime = duration - videoTime; + } + desiredTime = videoTime; + } else if (videoTime > duration) { + desiredTime = duration; + } else if (videoTime < 0.0) { + desiredTime = 0.0; + } else { + desiredTime = videoTime; + } + + //If the playing video's time and the scene's clock time + //ever drift too far apart, we want to set the video to match + var tolerance = shouldAnimate ? defaultValue(this.tolerance, 1.0) : 0.001; + if (Math.abs(desiredTime - currentTime) > tolerance) { + this._seeking = true; + element.currentTime = desiredTime; + } + }; + + function createSeekFunction(that) { + return function() { + that._seeking = false; + that._firstTickAfterSeek = true; + }; + } + + return VideoSynchronizer; +}); diff --git a/Source/Core/getBaseUri.js b/Source/Core/getBaseUri.js new file mode 100644 index 000000000000..b14876fcdfae --- /dev/null +++ b/Source/Core/getBaseUri.js @@ -0,0 +1,38 @@ +/*global define*/ +define([ + './defined', + './DeveloperError' + ], function( + defined, + DeveloperError) { + "use strict"; + + /** + * Given a URI, returns the base path of the URI. + * @exports getBaseUri + * + * @param {String} uri The Uri. + * @returns {String} The base path of the Uri. + * + * @example + * // basePath will be "/Gallery/"; + * var basePath = Cesium.getBaseUri('/Gallery/simple.czml?value=true&example=false'); + */ + var getBaseUri = function(uri) { + //>>includeStart('debug', pragmas.debug); + if (!defined(uri)) { + throw new DeveloperError('uri is required.'); + } + //>>includeEnd('debug'); + + var basePath = ''; + var i = uri.lastIndexOf('/'); + if (i !== -1) { + basePath = uri.substring(0, i + 1); + } + + return basePath; + }; + + return getBaseUri; +}); diff --git a/Source/Core/getFilenameFromUri.js b/Source/Core/getFilenameFromUri.js index a08ee2c26be6..09f7cd4ab8de 100644 --- a/Source/Core/getFilenameFromUri.js +++ b/Source/Core/getFilenameFromUri.js @@ -38,4 +38,4 @@ define([ }; return getFilenameFromUri; -}); \ No newline at end of file +}); diff --git a/Source/Core/scaleToGeodeticSurface.js b/Source/Core/scaleToGeodeticSurface.js new file mode 100644 index 000000000000..52cbfc958d5d --- /dev/null +++ b/Source/Core/scaleToGeodeticSurface.js @@ -0,0 +1,136 @@ +/*global define*/ +define([ + './Cartesian3', + './defined', + './DeveloperError', + './Math' + ], function( + Cartesian3, + defined, + DeveloperError, + CesiumMath) { + "use strict"; + + var scaleToGeodeticSurfaceIntersection = new Cartesian3(); + var scaleToGeodeticSurfaceGradient = new Cartesian3(); + + /** + * Scales the provided Cartesian position along the geodetic surface normal + * so that it is on the surface of this ellipsoid. If the position is + * at the center of the ellipsoid, this function returns undefined. + * + * @param {Cartesian3} cartesian The Cartesian position to scale. + * @param {Cartesian3} oneOverRadii One over radii of the ellipsoid. + * @param {Cartesian3} oneOverRadiiSquared One over radii squared of the ellipsoid. + * @param {Number} centerToleranceSquared Tolerance for closeness to the center. + * @param {Cartesian3} [result] The object onto which to store the result. + * @returns {Cartesian3} The modified result parameter, a new Cartesian3 instance if none was provided, or undefined if the position is at the center. + * + * @exports scaleToGeodeticSurface + * + * @private + */ + var scaleToGeodeticSurface = function(cartesian, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, result) { + //>>includeStart('debug', pragmas.debug); + if (!defined(cartesian)) { + throw new DeveloperError('cartesian is required.'); + } + if (!defined(oneOverRadii)) { + throw new DeveloperError('oneOverRadii is required.'); + } + if (!defined(oneOverRadiiSquared)) { + throw new DeveloperError('oneOverRadiiSquared is required.'); + } + if (!defined(centerToleranceSquared)) { + throw new DeveloperError('centerToleranceSquared is required.'); + } + //>>includeEnd('debug'); + + var positionX = cartesian.x; + var positionY = cartesian.y; + var positionZ = cartesian.z; + + var oneOverRadiiX = oneOverRadii.x; + var oneOverRadiiY = oneOverRadii.y; + var oneOverRadiiZ = oneOverRadii.z; + + var x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX; + var y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY; + var z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ; + + // Compute the squared ellipsoid norm. + var squaredNorm = x2 + y2 + z2; + var ratio = Math.sqrt(1.0 / squaredNorm); + + // As an initial approximation, assume that the radial intersection is the projection point. + var intersection = Cartesian3.multiplyByScalar(cartesian, ratio, scaleToGeodeticSurfaceIntersection); + + // If the position is near the center, the iteration will not converge. + if (squaredNorm < centerToleranceSquared) { + return !isFinite(ratio) ? undefined : Cartesian3.clone(intersection, result); + } + + var oneOverRadiiSquaredX = oneOverRadiiSquared.x; + var oneOverRadiiSquaredY = oneOverRadiiSquared.y; + var oneOverRadiiSquaredZ = oneOverRadiiSquared.z; + + // Use the gradient at the intersection point in place of the true unit normal. + // The difference in magnitude will be absorbed in the multiplier. + var gradient = scaleToGeodeticSurfaceGradient; + gradient.x = intersection.x * oneOverRadiiSquaredX * 2.0; + gradient.y = intersection.y * oneOverRadiiSquaredY * 2.0; + gradient.z = intersection.z * oneOverRadiiSquaredZ * 2.0; + + // Compute the initial guess at the normal vector multiplier, lambda. + var lambda = (1.0 - ratio) * Cartesian3.magnitude(cartesian) / (0.5 * Cartesian3.magnitude(gradient)); + var correction = 0.0; + + var func; + var denominator; + var xMultiplier; + var yMultiplier; + var zMultiplier; + var xMultiplier2; + var yMultiplier2; + var zMultiplier2; + var xMultiplier3; + var yMultiplier3; + var zMultiplier3; + + do { + lambda -= correction; + + xMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredX); + yMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredY); + zMultiplier = 1.0 / (1.0 + lambda * oneOverRadiiSquaredZ); + + xMultiplier2 = xMultiplier * xMultiplier; + yMultiplier2 = yMultiplier * yMultiplier; + zMultiplier2 = zMultiplier * zMultiplier; + + xMultiplier3 = xMultiplier2 * xMultiplier; + yMultiplier3 = yMultiplier2 * yMultiplier; + zMultiplier3 = zMultiplier2 * zMultiplier; + + func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0; + + // "denominator" here refers to the use of this expression in the velocity and acceleration + // computations in the sections to follow. + denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ; + + var derivative = -2.0 * denominator; + + correction = func / derivative; + } while (Math.abs(func) > CesiumMath.EPSILON12); + + if (!defined(result)) { + return new Cartesian3(positionX * xMultiplier, positionY * yMultiplier, positionZ * zMultiplier); + } + result.x = positionX * xMultiplier; + result.y = positionY * yMultiplier; + result.z = positionZ * zMultiplier; + return result; + }; + + return scaleToGeodeticSurface; +}); diff --git a/Source/DataSources/CzmlDataSource.js b/Source/DataSources/CzmlDataSource.js index 43cfb2ab268c..953ff46ab0be 100644 --- a/Source/DataSources/CzmlDataSource.js +++ b/Source/DataSources/CzmlDataSource.js @@ -180,16 +180,6 @@ define([ return rgbaf; } - function unwrapImageInterval(czmlInterval, sourceUri) { - var result = defaultValue(czmlInterval.image, czmlInterval); - if (defined(sourceUri)) { - var baseUri = new Uri(document.location.href); - sourceUri = new Uri(sourceUri); - result = new Uri(result).resolve(sourceUri.resolve(baseUri)).toString(); - } - return result; - } - function unwrapUriInterval(czmlInterval, sourceUri) { var result = defaultValue(czmlInterval.uri, czmlInterval); if (defined(sourceUri)) { diff --git a/Source/DataSources/DataSourceDisplay.js b/Source/DataSources/DataSourceDisplay.js index 2e309c54f730..a4991eeb8850 100644 --- a/Source/DataSources/DataSourceDisplay.js +++ b/Source/DataSources/DataSourceDisplay.js @@ -300,7 +300,6 @@ define([ var tmp = getBoundingSphereBoundingSphereScratch; var count = 0; - var resultState; var state = BoundingSphereState.DONE; var visualizers = dataSource._visualizers; var visualizersLength = visualizers.length; diff --git a/Source/DataSources/EntityCollection.js b/Source/DataSources/EntityCollection.js index a6fe50197841..837617d0a729 100644 --- a/Source/DataSources/EntityCollection.js +++ b/Source/DataSources/EntityCollection.js @@ -219,7 +219,6 @@ define([ entity.entityCollection = this; entities.set(id, entity); - var removedEntities = this._removedEntities; if (!this._removedEntities.remove(id)) { this._addedEntities.set(id, entity); } diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index 91aff895f8a8..b0c7e664fdb4 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -87,8 +87,6 @@ define([ 'marker-size', 'marker-symbol', 'marker-color', 'stroke', // 'stroke-opacity', 'stroke-width', 'fill', 'fill-opacity']; - var stringifyScratch = new Array(4); - function defaultDescribe(properties, nameProperty) { var html = ''; for ( var key in properties) { @@ -267,11 +265,6 @@ define([ } } - stringifyScratch[0] = symbol; - stringifyScratch[1] = color; - stringifyScratch[2] = size; - var id = JSON.stringify(stringifyScratch); - var canvasOrPromise; if (defined(symbol)) { if (symbol.length === 1) { diff --git a/Source/DataSources/GeometryVisualizer.js b/Source/DataSources/GeometryVisualizer.js index bd64c9933aba..a3235c15d708 100644 --- a/Source/DataSources/GeometryVisualizer.js +++ b/Source/DataSources/GeometryVisualizer.js @@ -259,7 +259,6 @@ define([ var tmp = getBoundingSphereBoundingSphereScratch; var count = 0; - var resultState; var state = BoundingSphereState.DONE; var batches = this._batches; var batchesLength = batches.length; diff --git a/Source/DataSources/ImageMaterialProperty.js b/Source/DataSources/ImageMaterialProperty.js index 81edbe839d3e..57859f8d7fa9 100644 --- a/Source/DataSources/ImageMaterialProperty.js +++ b/Source/DataSources/ImageMaterialProperty.js @@ -18,6 +18,7 @@ define([ "use strict"; var defaultRepeat = new Cartesian2(1, 1); + var defaultAlpha = 1.0; /** * A {@link MaterialProperty} that maps to image {@link Material} uniforms. @@ -25,7 +26,7 @@ define([ * @constructor * * @param {Object} [options] Object with the following properties: - * @param {Property} [options.image] A Property specifying the Image, URL, or Canvas. + * @param {Property} [options.image] A Property specifying the Image, URL, Canvas, or Video. * @param {Property} [options.repeat=new Cartesian2(1.0, 1.0)] A {@link Cartesian2} Property specifying the number of times the image repeats in each direction. */ var ImageMaterialProperty = function(options) { @@ -36,9 +37,12 @@ define([ this._imageSubscription = undefined; this._repeat = undefined; this._repeatSubscription = undefined; + this._alpha = undefined; + this._alphaSubscription = undefined; this.image = options.image; this.repeat = options.repeat; + this.alpha = options.alpha; }; defineProperties(ImageMaterialProperty.prototype, { @@ -70,7 +74,7 @@ define([ } }, /** - * Gets or sets the Property specifying Image, URL, or Canvas. + * Gets or sets the Property specifying Image, URL, Canvas, or Video to use. * @memberof ImageMaterialProperty.prototype * @type {Property} */ @@ -81,7 +85,14 @@ define([ * @type {Property} * @default new Cartesian2(1, 1) */ - repeat : createPropertyDescriptor('repeat') + repeat : createPropertyDescriptor('repeat'), + /** + * Gets or sets the Number Property specifying the desired opacity of the overall image. + * @memberof ImageMaterialProperty.prototype + * @type {Property} + * @default 1.0 + */ + alpha : createPropertyDescriptor('alpha') }); /** @@ -108,6 +119,8 @@ define([ result.image = Property.getValueOrUndefined(this._image, time); result.repeat = Property.getValueOrClonedDefault(this._repeat, time, defaultRepeat, result.repeat); + result.alpha = Property.getValueOrDefault(this._alpha, time, defaultAlpha); + return result; }; @@ -122,6 +135,7 @@ define([ return this === other || // (other instanceof ImageMaterialProperty && // Property.equals(this._image, other._image) && // + Property.equals(this._alpha, other._alpha) && // Property.equals(this._repeat, other._repeat)); }; diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index de82f19a7fea..39c668c9cf17 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -656,7 +656,6 @@ define([ function applyStyle(dataSource, styleNode, targetEntity, sourceUri, uriResolver) { for (var i = 0, len = styleNode.childNodes.length; i < len; i++) { var node = styleNode.childNodes.item(i); - var material; if (node.localName === 'IconStyle') { processBillboardIcon(dataSource, node, targetEntity, sourceUri, uriResolver); } else if (node.localName === 'LabelStyle') { @@ -1094,7 +1093,6 @@ define([ var trackNodes = queryChildNodes(geometryNode, 'Track', namespaces.gx); var times; - var data; var lastStop; var lastStopPosition; var needDropLine = false; @@ -1398,7 +1396,6 @@ define([ function processGroundOverlay(dataSource, parent, groundOverlay, entityCollection, styleCollection, sourceUri, uriResolver) { var r = processFeature(dataSource, parent, groundOverlay, entityCollection, styleCollection, sourceUri, uriResolver); var entity = r.entity; - var styleEntity = r.stylEntity; var geometry; var isLatLonQuad = false; @@ -1441,7 +1438,6 @@ define([ } } - var material; var iconNode = queryFirstNode(groundOverlay, 'Icon', namespaces.kml); var href = queryStringValue(iconNode, 'href', namespaces.kml); if (defined(href)) { @@ -1455,16 +1451,14 @@ define([ var altitudeMode = queryStringValue(groundOverlay, 'altitudeMode', namespaces.kml); - var altitude; if (defined(altitudeMode)) { if (altitudeMode === 'absolute') { //Use height above ellipsoid until we support MSL. geometry.height = queryNumericValue(groundOverlay, 'altitude', namespaces.kml); - } else if (altitudeMode === 'clampToGround') { - //Just use the default of 0 until we support terrain - } else { + } else if (altitudeMode !== 'clampToGround'){ window.console.log('KML - Unknown altitudeMode: ' + altitudeMode); } + // else just use the default of 0 until we support 'clampToGround' } else { altitudeMode = queryStringValue(groundOverlay, 'altitudeMode', namespaces.gx); if (altitudeMode === 'relativeToSeaFloor') { diff --git a/Source/DataSources/ModelVisualizer.js b/Source/DataSources/ModelVisualizer.js index f2824c89b2da..0ad6c5eaeea8 100644 --- a/Source/DataSources/ModelVisualizer.js +++ b/Source/DataSources/ModelVisualizer.js @@ -72,11 +72,9 @@ define([ } //>>includeEnd('debug'); - var context = this._scene.context; var entities = this._entitiesToVisualize.values; var modelHash = this._modelHash; var primitives = this._primitives; - var scene = this._scene; for (var i = 0, len = entities.length; i < len; i++) { var entity = entities[i]; diff --git a/Source/DataSources/SampledProperty.js b/Source/DataSources/SampledProperty.js index aa23d344768f..2d538eb19241 100644 --- a/Source/DataSources/SampledProperty.js +++ b/Source/DataSources/SampledProperty.js @@ -440,9 +440,7 @@ define([ var lastIndex = timesLength - 1; var pointsInCollection = lastIndex - firstIndex + 1; - if (pointsInCollection < degree + 1) { - // Use the entire range. - } else { + if (pointsInCollection >= degree + 1) { var computedFirstIndex = index - ((degree / 2) | 0) - 1; if (computedFirstIndex < firstIndex) { computedFirstIndex = firstIndex; diff --git a/Source/DataSources/VelocityOrientationProperty.js b/Source/DataSources/VelocityOrientationProperty.js index 7ff29915de38..ba41885cd841 100644 --- a/Source/DataSources/VelocityOrientationProperty.js +++ b/Source/DataSources/VelocityOrientationProperty.js @@ -181,7 +181,7 @@ define([ var velocity = Cartesian3.subtract(position2, position1, velocityScratch); Cartesian3.normalize(velocity, velocity); - var rotation = Transforms.rotationMatrixFromPositionVelocity(position1, velocity, this._ellipsoid, rotationScratch); + Transforms.rotationMatrixFromPositionVelocity(position1, velocity, this._ellipsoid, rotationScratch); return Quaternion.fromRotationMatrix(rotationScratch, result); }; diff --git a/Source/DataSources/createMaterialPropertyDescriptor.js b/Source/DataSources/createMaterialPropertyDescriptor.js index e83658b19929..8cc018e6b860 100644 --- a/Source/DataSources/createMaterialPropertyDescriptor.js +++ b/Source/DataSources/createMaterialPropertyDescriptor.js @@ -18,7 +18,7 @@ define([ return new ColorMaterialProperty(value); } - if (typeof value === 'string' || value instanceof HTMLCanvasElement) { + if (typeof value === 'string' || value instanceof HTMLCanvasElement || value instanceof HTMLVideoElement) { var result = new ImageMaterialProperty(); result.image = value; return result; @@ -37,4 +37,4 @@ define([ } return createMaterialPropertyDescriptor; -}); \ No newline at end of file +}); diff --git a/Source/Renderer/Texture.js b/Source/Renderer/Texture.js index 531e646e7435..275e6d5857e0 100644 --- a/Source/Renderer/Texture.js +++ b/Source/Renderer/Texture.js @@ -45,9 +45,19 @@ define([ //>>includeEnd('debug'); var context = options.context; + var width = options.width; + var height = options.height; var source = options.source; - var width = defined(source) ? source.width : options.width; - var height = defined(source) ? source.height : options.height; + + if (defined(source)) { + if (!defined(width)) { + width = defaultValue(source.videoWidth, source.width); + } + if (!defined(height)) { + height = defaultValue(source.videoHeight, source.height); + } + } + var pixelFormat = defaultValue(options.pixelFormat, PixelFormat.RGBA); var pixelDatatype = defaultValue(options.pixelDatatype, PixelDatatype.UNSIGNED_BYTE); var internalFormat = pixelFormat; diff --git a/Source/Renderer/UniformState.js b/Source/Renderer/UniformState.js index 49523552309d..6a68785ff32b 100644 --- a/Source/Renderer/UniformState.js +++ b/Source/Renderer/UniformState.js @@ -295,15 +295,7 @@ define([ */ view3D : { get : function() { - if (this._view3DDirty) { - if (this._mode === SceneMode.SCENE3D) { - Matrix4.clone(this._view, this._view3D); - } else { - view2Dto3D(this._cameraPosition, this._cameraDirection, this._cameraRight, this._cameraUp, this._frustum2DWidth, this._mode, this._mapProjection, this._view3D); - } - Matrix4.getRotation(this._view3D, this._viewRotation3D); - this._view3DDirty = false; - } + updateView3D(this); return this._view3D; } }, @@ -315,6 +307,7 @@ define([ */ viewRotation : { get : function() { + updateView3D(this); return this._viewRotation; } }, @@ -325,7 +318,7 @@ define([ */ viewRotation3D : { get : function() { - var view3D = this.view3D; + updateView3D(this); return this._viewRotation3D; } }, @@ -349,11 +342,7 @@ define([ */ inverseView3D : { get : function() { - if (this._inverseView3DDirty) { - Matrix4.inverseTransformation(this.view3D, this._inverseView3D); - Matrix4.getRotation(this._inverseView3D, this._inverseViewRotation3D); - this._inverseView3DDirty = false; - } + updateInverseView3D(this); return this._inverseView3D; } }, @@ -375,7 +364,7 @@ define([ */ inverseViewRotation3D : { get : function() { - var inverseView = this.inverseView3D; + updateInverseView3D(this); return this._inverseViewRotation3D; } }, @@ -1186,5 +1175,25 @@ define([ return result; } + function updateView3D(that) { + if (that._view3DDirty) { + if (that._mode === SceneMode.SCENE3D) { + Matrix4.clone(that._view, that._view3D); + } else { + view2Dto3D(that._cameraPosition, that._cameraDirection, that._cameraRight, that._cameraUp, that._frustum2DWidth, that._mode, that._mapProjection, that._view3D); + } + Matrix4.getRotation(that._view3D, that._viewRotation3D); + that._view3DDirty = false; + } + } + + function updateInverseView3D(that){ + if (that._inverseView3DDirty) { + Matrix4.inverseTransformation(that.view3D, that._inverseView3D); + Matrix4.getRotation(that._inverseView3D, that._inverseViewRotation3D); + that._inverseView3DDirty = false; + } + } + return UniformState; }); diff --git a/Source/Renderer/createUniform.js b/Source/Renderer/createUniform.js index b785e31d7384..ee4fa848f76e 100644 --- a/Source/Renderer/createUniform.js +++ b/Source/Renderer/createUniform.js @@ -22,7 +22,6 @@ define([ Matrix4, RuntimeError) { "use strict"; - /*global console*/ /** * @private diff --git a/Source/Renderer/createUniformArray.js b/Source/Renderer/createUniformArray.js index b8d4aefeebf1..7d72bac8b779 100644 --- a/Source/Renderer/createUniformArray.js +++ b/Source/Renderer/createUniformArray.js @@ -24,7 +24,6 @@ define([ Matrix4, RuntimeError) { "use strict"; - /*global console*/ /** * @private diff --git a/Source/Scene/BillboardCollection.js b/Source/Scene/BillboardCollection.js index 754419731376..5ade9e62db8b 100644 --- a/Source/Scene/BillboardCollection.js +++ b/Source/Scene/BillboardCollection.js @@ -1135,17 +1135,10 @@ define([ } } - var scratchPixelSize = new Cartesian2(); - function updateBoundingVolume(collection, frameState, boundingVolume) { var pixelScale = 1.0; if (!collection._allSizedInMeters || collection._maxPixelOffset !== 0.0) { - var camera = frameState.camera; - var distance = camera.distanceToBoundingSphere(boundingVolume); - - var context = frameState.context; - var pixelSize = frameState.camera.frustum.getPixelDimensions(context.drawingBufferWidth, context.drawingBufferHeight, distance, scratchPixelSize); - pixelScale = Math.max(pixelSize.x, pixelSize.y); + pixelScale = frameState.camera.getPixelSize(boundingVolume, frameState.context.drawingBufferWidth, frameState.context.drawingBufferHeight); } var size = pixelScale * collection._maxScale * collection._maxSize * 2.0; diff --git a/Source/Scene/Camera.js b/Source/Scene/Camera.js index 5af3b4ee911f..929407bec7f5 100644 --- a/Source/Scene/Camera.js +++ b/Source/Scene/Camera.js @@ -694,7 +694,6 @@ define([ heading : { get : function () { if (this._mode !== SceneMode.MORPHING) { - var origin = this.positionWC; var ellipsoid = this._projection.ellipsoid; var oldTransform = Matrix4.clone(this._transform, scratchHPRMatrix1); @@ -722,7 +721,6 @@ define([ pitch : { get : function() { if (this._mode !== SceneMode.MORPHING) { - var origin = this.positionWC; var ellipsoid = this._projection.ellipsoid; var oldTransform = Matrix4.clone(this._transform, scratchHPRMatrix1); @@ -750,7 +748,6 @@ define([ roll : { get : function() { if (this._mode !== SceneMode.MORPHING) { - var origin = this.positionWC; var ellipsoid = this._projection.ellipsoid; var oldTransform = Matrix4.clone(this._transform, scratchHPRMatrix1); @@ -1663,7 +1660,6 @@ define([ }; var scratchLookAtMatrix4 = new Matrix4(); - var scratchLookAtTransformMatrix4 = new Matrix4(); /** * Sets the camera position and orientation using a target and offset. The target must be given in @@ -2274,6 +2270,34 @@ define([ return Math.max(0.0, Cartesian3.magnitude(proj) - boundingSphere.radius); }; + var scratchPixelSize = new Cartesian2(); + + /** + * Return the pixel size in meters. + * + * @param {BoundingSphere} boundingSphere The bounding sphere in world coordinates. + * @param {Number} drawingBufferWidth The drawing buffer width. + * @param {Number} drawingBufferHeight The drawing buffer height. + * @returns {Number} The pixel size in meters. + */ + Camera.prototype.getPixelSize = function(boundingSphere, drawingBufferWidth, drawingBufferHeight) { + //>>includeStart('debug', pragmas.debug); + if (!defined(boundingSphere)) { + throw new DeveloperError('boundingSphere is required.'); + } + if (!defined(drawingBufferWidth)) { + throw new DeveloperError('drawingBufferWidth is required.'); + } + if (!defined(drawingBufferHeight)) { + throw new DeveloperError('drawingBufferHeight is required.'); + } + //>>includeEnd('debug'); + + var distance = this.distanceToBoundingSphere(boundingSphere); + var pixelSize = this.frustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, scratchPixelSize); + return Math.max(pixelSize.x, pixelSize.y); + }; + function createAnimation2D(camera, duration) { var position = camera.position; var translateX = position.x < -camera._maxCoord.x || position.x > camera._maxCoord.x; @@ -2429,11 +2453,6 @@ define([ var scratchFlyToDestination = new Cartesian3(); - var scratchFlyToQuaternion = new Quaternion(); - var scratchFlyToMatrix3 = new Matrix3(); - var scratchFlyToDirection = new Cartesian3(); - var scratchFlyToUp = new Cartesian3(); - var scratchFlyToMatrix4 = new Matrix4(); var newOptions = { destination : undefined, heading : undefined, diff --git a/Source/Scene/CameraFlightPath.js b/Source/Scene/CameraFlightPath.js index 82928c4aa720..23539cd0bccb 100644 --- a/Source/Scene/CameraFlightPath.js +++ b/Source/Scene/CameraFlightPath.js @@ -141,7 +141,6 @@ define([ var scratchStartCart = new Cartographic(); var scratchEndCart = new Cartographic(); - var scratchCurrentPositionCart = new Cartesian3(); function createUpdate3D(scene, duration, destination, heading, pitch, roll, optionAltitude) { var camera = scene.camera; @@ -227,9 +226,6 @@ define([ return update; } - var dirScratch = new Cartesian3(); - var rightScratch = new Cartesian3(); - var upScratch = new Cartesian3(); var scratchCartographic = new Cartographic(); var scratchDestination = new Cartesian3(); diff --git a/Source/Scene/EllipsoidPrimitive.js b/Source/Scene/EllipsoidPrimitive.js index 7bb3ad9ff2ba..b62da8300a68 100644 --- a/Source/Scene/EllipsoidPrimitive.js +++ b/Source/Scene/EllipsoidPrimitive.js @@ -343,7 +343,6 @@ define([ this._onlySunLighting = this.onlySunLighting; var colorCommand = this._colorCommand; - var vs; var fs; // Recompile shader when material, lighting, or translucency changes diff --git a/Source/Scene/FrameState.js b/Source/Scene/FrameState.js index d81711d57657..27310f79b880 100644 --- a/Source/Scene/FrameState.js +++ b/Source/Scene/FrameState.js @@ -156,6 +156,12 @@ define([ */ sse : undefined }; + + /** + * A scalar used to exaggerate the terrain. + * @type {Number} + */ + this.terrainExaggeration = 1.0; }; /** diff --git a/Source/Scene/Globe.js b/Source/Scene/Globe.js index 64f251d393ca..a4011095d2f5 100644 --- a/Source/Scene/Globe.js +++ b/Source/Scene/Globe.js @@ -1,13 +1,9 @@ /*global define*/ define([ - '../Core/BoundingRectangle', '../Core/BoundingSphere', '../Core/buildModuleUrl', - '../Core/Cartesian2', '../Core/Cartesian3', '../Core/Cartographic', - '../Core/combine', - '../Core/ComponentDatatype', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -15,49 +11,27 @@ define([ '../Core/DeveloperError', '../Core/Ellipsoid', '../Core/EllipsoidTerrainProvider', - '../Core/FeatureDetection', '../Core/GeographicProjection', - '../Core/Geometry', - '../Core/GeometryAttribute', - '../Core/Intersect', '../Core/IntersectionTests', '../Core/loadImage', - '../Core/Math', - '../Core/Matrix4', - '../Core/Occluder', - '../Core/PrimitiveType', '../Core/Ray', '../Core/Rectangle', - '../Core/Transforms', - '../Renderer/BufferUsage', - '../Renderer/DrawCommand', - '../Renderer/RenderState', - '../Renderer/ShaderProgram', '../Renderer/ShaderSource', '../Renderer/Texture', - '../Renderer/VertexArray', '../Shaders/GlobeFS', - '../Shaders/GlobeFSPole', '../Shaders/GlobeVS', - '../Shaders/GlobeVSPole', '../Shaders/GroundAtmosphere', '../ThirdParty/when', './GlobeSurfaceShaderSet', './GlobeSurfaceTileProvider', './ImageryLayerCollection', - './Pass', './QuadtreePrimitive', - './SceneMode', - './terrainAttributeLocations' + './SceneMode' ], function( - BoundingRectangle, BoundingSphere, buildModuleUrl, - Cartesian2, Cartesian3, Cartographic, - combine, - ComponentDatatype, defaultValue, defined, defineProperties, @@ -65,40 +39,22 @@ define([ DeveloperError, Ellipsoid, EllipsoidTerrainProvider, - FeatureDetection, GeographicProjection, - Geometry, - GeometryAttribute, - Intersect, IntersectionTests, loadImage, - CesiumMath, - Matrix4, - Occluder, - PrimitiveType, Ray, Rectangle, - Transforms, - BufferUsage, - DrawCommand, - RenderState, - ShaderProgram, ShaderSource, Texture, - VertexArray, GlobeFS, - GlobeFSPole, GlobeVS, - GlobeVSPole, GroundAtmosphere, when, GlobeSurfaceShaderSet, GlobeSurfaceTileProvider, ImageryLayerCollection, - Pass, QuadtreePrimitive, - SceneMode, - terrainAttributeLocations) { + SceneMode) { "use strict"; /** @@ -139,49 +95,12 @@ define([ }) }); - this._occluder = new Occluder(new BoundingSphere(Cartesian3.ZERO, ellipsoid.minimumRadius), Cartesian3.ZERO); - - this._rsColor = undefined; - this._rsColorWithoutDepthTest = undefined; - - this._northPoleCommand = new DrawCommand({ - pass : Pass.OPAQUE, - owner : this - }); - this._southPoleCommand = new DrawCommand({ - pass : Pass.OPAQUE, - owner : this - }); - - this._drawNorthPole = false; - this._drawSouthPole = false; - - this._mode = SceneMode.SCENE3D; - /** * The terrain provider providing surface geometry for this globe. * @type {TerrainProvider} */ this.terrainProvider = terrainProvider; - /** - * Determines the color of the north pole. If the day tile provider imagery does not - * extend over the north pole, it will be filled with this color before applying lighting. - * - * @type {Cartesian3} - * @default Cartesian3(2.0 / 255.0, 6.0 / 255.0, 18.0 / 255.0) - */ - this.northPoleColor = new Cartesian3(2.0 / 255.0, 6.0 / 255.0, 18.0 / 255.0); - - /** - * Determines the color of the south pole. If the day tile provider imagery does not - * extend over the south pole, it will be filled with this color before applying lighting. - * - * @type {Cartesian3} - * @default Cartesian3(1.0, 1.0, 1.0) - */ - this.southPoleColor = new Cartesian3(1.0, 1.0, 1.0); - /** * Determines if the globe will be shown. * @@ -271,21 +190,6 @@ define([ this._oceanNormalMap = undefined; this._zoomedOutOceanSpecularIntensity = 0.5; - this._lightingFadeDistance = new Cartesian2(this.lightingFadeOutDistance, this.lightingFadeInDistance); - - var that = this; - - this._drawUniforms = { - u_zoomedOutOceanSpecularIntensity : function() { - return that._zoomedOutOceanSpecularIntensity; - }, - u_oceanNormalMap : function() { - return that._oceanNormalMap; - }, - u_lightingFadeDistance : function() { - return that._lightingFadeDistance; - } - }; }; defineProperties(Globe.prototype, { @@ -482,206 +386,6 @@ define([ return ellipsoid.cartesianToCartographic(intersection, scratchGetHeightCartographic).height; }; - var rightScratch = new Cartesian3(); - var upScratch = new Cartesian3(); - var negativeZ = Cartesian3.negate(Cartesian3.UNIT_Z, new Cartesian3()); - var cartographicScratch = new Cartographic(0.0, 0.0); - var pt1Scratch = new Cartesian3(); - var pt2Scratch = new Cartesian3(); - - function computePoleQuad(globe, frameState, maxLat, maxGivenLat, viewProjMatrix, viewportTransformation) { - cartographicScratch.longitude = 0.0; - cartographicScratch.latitude = maxGivenLat; - var pt1 = globe._ellipsoid.cartographicToCartesian(cartographicScratch, pt1Scratch); - - cartographicScratch.longitude = Math.PI; - var pt2 = globe._ellipsoid.cartographicToCartesian(cartographicScratch, pt2Scratch); - - var radius = Cartesian3.magnitude(Cartesian3.subtract(pt1, pt2, rightScratch), rightScratch) * 0.5; - - cartographicScratch.longitude = 0.0; - cartographicScratch.latitude = maxLat; - var center = globe._ellipsoid.cartographicToCartesian(cartographicScratch, pt1Scratch); - - var right; - var dir = frameState.camera.direction; - if (1.0 - Cartesian3.dot(negativeZ, dir) < CesiumMath.EPSILON6) { - right = Cartesian3.UNIT_X; - } else { - right = Cartesian3.normalize(Cartesian3.cross(dir, Cartesian3.UNIT_Z, rightScratch), rightScratch); - } - - var screenRight = Cartesian3.add(center, Cartesian3.multiplyByScalar(right, radius, rightScratch), rightScratch); - var screenUp = Cartesian3.add(center, Cartesian3.multiplyByScalar(Cartesian3.normalize(Cartesian3.cross(Cartesian3.UNIT_Z, right, upScratch), upScratch), radius, upScratch), upScratch); - - Transforms.pointToGLWindowCoordinates(viewProjMatrix, viewportTransformation, center, center); - Transforms.pointToGLWindowCoordinates(viewProjMatrix, viewportTransformation, screenRight, screenRight); - Transforms.pointToGLWindowCoordinates(viewProjMatrix, viewportTransformation, screenUp, screenUp); - - var halfWidth = Math.floor(Math.max(Cartesian3.distance(screenUp, center), Cartesian3.distance(screenRight, center))); - var halfHeight = halfWidth; - - return new BoundingRectangle( - Math.floor(center.x) - halfWidth, - Math.floor(center.y) - halfHeight, - halfWidth * 2.0, - halfHeight * 2.0); - } - - var viewportScratch = new BoundingRectangle(); - var vpTransformScratch = new Matrix4(); - var polePositionsScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(8) : []; - - function fillPoles(globe, frameState) { - var terrainProvider = globe.terrainProvider; - if (frameState.mode !== SceneMode.SCENE3D) { - return; - } - - if (!terrainProvider.ready) { - return; - } - - var terrainMaxRectangle = terrainProvider.tilingScheme.rectangle; - - var context = frameState.context; - var viewProjMatrix = context.uniformState.viewProjection; - var viewport = viewportScratch; - viewport.width = context.drawingBufferWidth; - viewport.height = context.drawingBufferHeight; - var viewportTransformation = Matrix4.computeViewportTransformation(viewport, 0.0, 1.0, vpTransformScratch); - var latitudeExtension = 0.05; - - var rectangle; - var boundingVolume; - var frustumCull; - var occludeePoint; - var occluded; - var geometry; - var rect; - var occluder = globe._occluder; - - // handle north pole - if (terrainMaxRectangle.north < CesiumMath.PI_OVER_TWO) { - rectangle = new Rectangle(-Math.PI, terrainMaxRectangle.north, Math.PI, CesiumMath.PI_OVER_TWO); - boundingVolume = BoundingSphere.fromRectangle3D(rectangle, globe._ellipsoid); - frustumCull = frameState.cullingVolume.computeVisibility(boundingVolume) === Intersect.OUTSIDE; - occludeePoint = Occluder.computeOccludeePointFromRectangle(rectangle, globe._ellipsoid); - occluded = (occludeePoint && !occluder.isPointVisible(occludeePoint, 0.0)) || !occluder.isBoundingSphereVisible(boundingVolume); - - globe._drawNorthPole = !frustumCull && !occluded; - if (globe._drawNorthPole) { - rect = computePoleQuad(globe, frameState, rectangle.north, rectangle.south - latitudeExtension, viewProjMatrix, viewportTransformation); - polePositionsScratch[0] = rect.x; - polePositionsScratch[1] = rect.y; - polePositionsScratch[2] = rect.x + rect.width; - polePositionsScratch[3] = rect.y; - polePositionsScratch[4] = rect.x + rect.width; - polePositionsScratch[5] = rect.y + rect.height; - polePositionsScratch[6] = rect.x; - polePositionsScratch[7] = rect.y + rect.height; - - if (!defined(globe._northPoleCommand.vertexArray)) { - globe._northPoleCommand.boundingVolume = BoundingSphere.fromRectangle3D(rectangle, globe._ellipsoid); - geometry = new Geometry({ - attributes : { - position : new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 2, - values : polePositionsScratch - }) - } - }); - globe._northPoleCommand.vertexArray = VertexArray.fromGeometry({ - context : context, - geometry : geometry, - attributeLocations : { - position : 0 - }, - bufferUsage : BufferUsage.STREAM_DRAW - }); - } else { - globe._northPoleCommand.vertexArray.getAttribute(0).vertexBuffer.copyFromArrayView(polePositionsScratch); - } - } - } - - // handle south pole - if (terrainMaxRectangle.south > -CesiumMath.PI_OVER_TWO) { - rectangle = new Rectangle(-Math.PI, -CesiumMath.PI_OVER_TWO, Math.PI, terrainMaxRectangle.south); - boundingVolume = BoundingSphere.fromRectangle3D(rectangle, globe._ellipsoid); - frustumCull = frameState.cullingVolume.computeVisibility(boundingVolume) === Intersect.OUTSIDE; - occludeePoint = Occluder.computeOccludeePointFromRectangle(rectangle, globe._ellipsoid); - occluded = (occludeePoint && !occluder.isPointVisible(occludeePoint)) || !occluder.isBoundingSphereVisible(boundingVolume); - - globe._drawSouthPole = !frustumCull && !occluded; - if (globe._drawSouthPole) { - rect = computePoleQuad(globe, frameState, rectangle.south, rectangle.north + latitudeExtension, viewProjMatrix, viewportTransformation); - polePositionsScratch[0] = rect.x; - polePositionsScratch[1] = rect.y; - polePositionsScratch[2] = rect.x + rect.width; - polePositionsScratch[3] = rect.y; - polePositionsScratch[4] = rect.x + rect.width; - polePositionsScratch[5] = rect.y + rect.height; - polePositionsScratch[6] = rect.x; - polePositionsScratch[7] = rect.y + rect.height; - - if (!defined(globe._southPoleCommand.vertexArray)) { - globe._southPoleCommand.boundingVolume = BoundingSphere.fromRectangle3D(rectangle, globe._ellipsoid); - geometry = new Geometry({ - attributes : { - position : new GeometryAttribute({ - componentDatatype : ComponentDatatype.FLOAT, - componentsPerAttribute : 2, - values : polePositionsScratch - }) - } - }); - globe._southPoleCommand.vertexArray = VertexArray.fromGeometry({ - context : context, - geometry : geometry, - attributeLocations : { - position : 0 - }, - bufferUsage : BufferUsage.STREAM_DRAW - }); - } else { - globe._southPoleCommand.vertexArray.getAttribute(0).vertexBuffer.copyFromArrayView(polePositionsScratch); - } - } - } - - var poleIntensity = 0.0; - var baseLayer = globe._imageryLayerCollection.length > 0 ? globe._imageryLayerCollection.get(0) : undefined; - if (defined(baseLayer) && defined(baseLayer.imageryProvider) && defined(baseLayer.imageryProvider.getPoleIntensity)) { - poleIntensity = baseLayer.imageryProvider.getPoleIntensity(); - } - - var drawUniforms = { - u_dayIntensity : function() { - return poleIntensity; - } - }; - - if (!defined(globe._northPoleCommand.uniformMap)) { - var northPoleUniforms = combine(drawUniforms, { - u_color : function() { - return globe.northPoleColor; - } - }); - globe._northPoleCommand.uniformMap = combine(northPoleUniforms, globe._drawUniforms); - } - - if (!defined(globe._southPoleCommand.uniformMap)) { - var southPoleUniforms = combine(drawUniforms, { - u_color : function() { - return globe.southPoleColor; - } - }); - globe._southPoleCommand.uniformMap = combine(southPoleUniforms, globe._drawUniforms); - } - } - /** * @private */ @@ -698,48 +402,6 @@ define([ return; } - var mode = frameState.mode; - var projection = frameState.mapProjection; - var modeChanged = false; - - if (this._mode !== mode || !defined(this._rsColor)) { - modeChanged = true; - if (mode === SceneMode.SCENE3D || mode === SceneMode.COLUMBUS_VIEW) { - this._rsColor = RenderState.fromCache({ // Write color and depth - cull : { - enabled : true - }, - depthTest : { - enabled : true - } - }); - this._rsColorWithoutDepthTest = RenderState.fromCache({ // Write color, not depth - cull : { - enabled : true - } - }); - } else { - this._rsColor = RenderState.fromCache({ - cull : { - enabled : true - } - }); - this._rsColorWithoutDepthTest = RenderState.fromCache({ - cull : { - enabled : true - } - }); - } - } - - this._mode = mode; - - var northPoleCommand = this._northPoleCommand; - var southPoleCommand = this._southPoleCommand; - - northPoleCommand.renderState = this._rsColorWithoutDepthTest; - southPoleCommand.renderState = this._rsColorWithoutDepthTest; - var surface = this._surface; var tileProvider = surface.tileProvider; var terrainProvider = this.terrainProvider; @@ -769,40 +431,10 @@ define([ } } - if (!defined(northPoleCommand.shaderProgram) || - !defined(southPoleCommand.shaderProgram)) { - - var poleShaderProgram = ShaderProgram.replaceCache({ - context : context, - shaderProgram : northPoleCommand.shaderProgram, - vertexShaderSource : GlobeVSPole, - fragmentShaderSource : GlobeFSPole, - attributeLocations : terrainAttributeLocations - }); - - northPoleCommand.shaderProgram = poleShaderProgram; - southPoleCommand.shaderProgram = poleShaderProgram; - } - - this._occluder.cameraPosition = frameState.camera.positionWC; - - fillPoles(this, frameState); - - var commandList = frameState.commandList; + var mode = frameState.mode; var pass = frameState.passes; if (pass.render) { - // render quads to fill the poles - if (mode === SceneMode.SCENE3D) { - if (this._drawNorthPole) { - commandList.push(northPoleCommand); - } - - if (this._drawSouthPole) { - commandList.push(southPoleCommand); - } - } - // Don't show the ocean specular highlights when zoomed out in 2D and Columbus View. if (mode === SceneMode.SCENE3D) { this._zoomedOutOceanSpecularIntensity = 0.5; @@ -861,18 +493,9 @@ define([ * globe = globe && globe.destroy(); */ Globe.prototype.destroy = function() { - this._northPoleCommand.vertexArray = this._northPoleCommand.vertexArray && this._northPoleCommand.vertexArray.destroy(); - this._southPoleCommand.vertexArray = this._southPoleCommand.vertexArray && this._southPoleCommand.vertexArray.destroy(); - this._surfaceShaderSet = this._surfaceShaderSet && this._surfaceShaderSet.destroy(); - - this._northPoleCommand.shaderProgram = this._northPoleCommand.shaderProgram && this._northPoleCommand.shaderProgram.destroy(); - this._southPoleCommand.shaderProgram = this._northPoleCommand.shaderProgram; - this._surface = this._surface && this._surface.destroy(); - this._oceanNormalMap = this._oceanNormalMap && this._oceanNormalMap.destroy(); - return destroyObject(this); }; diff --git a/Source/Scene/GlobeSurfaceTile.js b/Source/Scene/GlobeSurfaceTile.js index 5140b3bc4f01..45719a5b72eb 100644 --- a/Source/Scene/GlobeSurfaceTile.js +++ b/Source/Scene/GlobeSurfaceTile.js @@ -295,7 +295,7 @@ define([ } }; - GlobeSurfaceTile.processStateMachine = function(tile, context, commandList, terrainProvider, imageryLayerCollection) { + GlobeSurfaceTile.processStateMachine = function(tile, frameState, terrainProvider, imageryLayerCollection) { var surfaceTile = tile.data; if (!defined(surfaceTile)) { surfaceTile = tile.data = new GlobeSurfaceTile(); @@ -307,7 +307,7 @@ define([ } if (tile.state === QuadtreeTileLoadState.LOADING) { - processTerrainStateMachine(tile, context, terrainProvider); + processTerrainStateMachine(tile, frameState, terrainProvider); } // The terrain is renderable as soon as we have a valid vertex array. @@ -345,7 +345,7 @@ define([ } } - var thisTileDoneLoading = tileImagery.processStateMachine(tile, context, commandList); + var thisTileDoneLoading = tileImagery.processStateMachine(tile, frameState); isDoneLoading = isDoneLoading && thisTileDoneLoading; // The imagery is renderable as soon as we have any renderable imagery for this region. @@ -433,14 +433,14 @@ define([ Cartesian3.normalize(northNormal, surfaceTile.northNormal); } - function processTerrainStateMachine(tile, context, terrainProvider) { + function processTerrainStateMachine(tile, frameState, terrainProvider) { var surfaceTile = tile.data; var loaded = surfaceTile.loadedTerrain; var upsampled = surfaceTile.upsampledTerrain; var suspendUpsampling = false; if (defined(loaded)) { - loaded.processLoadStateMachine(context, terrainProvider, tile.x, tile.y, tile.level); + loaded.processLoadStateMachine(frameState, terrainProvider, tile.x, tile.y, tile.level); // Publish the terrain data on the tile as soon as it is available. // We'll potentially need it to upsample child tiles. @@ -450,7 +450,7 @@ define([ // If there's a water mask included in the terrain data, create a // texture for it. - createWaterMaskTextureIfNeeded(context, surfaceTile); + createWaterMaskTextureIfNeeded(frameState.context, surfaceTile); propagateNewLoadedDataToChildren(tile); } @@ -473,7 +473,7 @@ define([ } if (!suspendUpsampling && defined(upsampled)) { - upsampled.processUpsampleStateMachine(context, terrainProvider, tile.x, tile.y, tile.level); + upsampled.processUpsampleStateMachine(frameState, terrainProvider, tile.x, tile.y, tile.level); // Publish the terrain data on the tile as soon as it is available. // We'll potentially need it to upsample child tiles. diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index 9ac7a7101dd4..63d9da528037 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -395,7 +395,6 @@ define([ var drawCommands = this._drawCommands; // Add the tile pick commands from the tiles drawn last frame. - var tilesToRenderByTextureCount = this._tilesToRenderByTextureCount; for (var i = 0, length = this._usedDrawCommands; i < length; ++i) { addPickCommandsForTile(this, drawCommands[i], frameState); } @@ -423,7 +422,7 @@ define([ * @exception {DeveloperError} loadTile must not be called before the tile provider is ready. */ GlobeSurfaceTileProvider.prototype.loadTile = function(frameState, tile) { - GlobeSurfaceTile.processStateMachine(tile, frameState.context, frameState.commandList, this._terrainProvider, this._imageryLayers); + GlobeSurfaceTile.processStateMachine(tile, frameState, this._terrainProvider, this._imageryLayers); }; var boundingSphereScratch = new BoundingSphere(); @@ -485,7 +484,6 @@ define([ return intersection; }; - var float32ArrayScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(1) : undefined; var modifiedModelViewScratch = new Matrix4(); var tileRectangleScratch = new Cartesian4(); var rtcScratch = new Cartesian3(); @@ -1183,7 +1181,7 @@ define([ var useWebMercatorProjection = frameState.projection instanceof WebMercatorProjection; - pickCommand.shaderProgram = tileProvider._surfaceShaderSet.getShaderProgram(frameState.context, frameState.mode, useWebMercatorProjection); + pickCommand.shaderProgram = tileProvider._surfaceShaderSet.getPickShaderProgram(frameState.context, frameState.mode, useWebMercatorProjection); pickCommand.renderState = tileProvider._pickRenderState; pickCommand.owner = drawCommand.owner; @@ -1198,4 +1196,4 @@ define([ } return GlobeSurfaceTileProvider; -}); +}); \ No newline at end of file diff --git a/Source/Scene/GroundPrimitive.js b/Source/Scene/GroundPrimitive.js index 0f8a5beb1744..ea05dd0807e7 100644 --- a/Source/Scene/GroundPrimitive.js +++ b/Source/Scene/GroundPrimitive.js @@ -317,9 +317,13 @@ define([ return scene.context.fragmentDepth; }; - GroundPrimitive._maxHeight = 9000.0; - GroundPrimitive._minHeight = -100000.0; - GroundPrimitive._minOBBHeight = -11500.0; + GroundPrimitive._maxHeight = undefined; + GroundPrimitive._minHeight = undefined; + GroundPrimitive._minOBBHeight = undefined; + + GroundPrimitive._maxTerrainHeight = 9000.0; + GroundPrimitive._minTerrainHeight = -100000.0; + GroundPrimitive._minOBBTerrainHeight = -11500.0; function computeMaximumHeight(granularity, ellipsoid) { var r = ellipsoid.maximumRadius; @@ -675,6 +679,13 @@ define([ return; } + if (!defined(GroundPrimitive._maxHeight)) { + var exaggeration = frameState.terrainExaggeration; + GroundPrimitive._maxHeight = GroundPrimitive._maxTerrainHeight * exaggeration; + GroundPrimitive._minHeight = GroundPrimitive._minTerrainHeight * exaggeration; + GroundPrimitive._minOBBHeight = GroundPrimitive._minOBBTerrainHeight * exaggeration; + } + if (!defined(this._primitive)) { var instance = this.geometryInstance; var geometry = instance.geometry; diff --git a/Source/Scene/Imagery.js b/Source/Scene/Imagery.js index 48bf4e330ec4..f03f1845ae4b 100644 --- a/Source/Scene/Imagery.js +++ b/Source/Scene/Imagery.js @@ -80,7 +80,7 @@ define([ return this.referenceCount; }; - Imagery.prototype.processStateMachine = function(context, commandList) { + Imagery.prototype.processStateMachine = function(frameState) { if (this.state === ImageryState.UNLOADED) { this.state = ImageryState.TRANSITIONING; this.imageryLayer._requestImagery(this); @@ -88,12 +88,12 @@ define([ if (this.state === ImageryState.RECEIVED) { this.state = ImageryState.TRANSITIONING; - this.imageryLayer._createTexture(context, this); + this.imageryLayer._createTexture(frameState.context, this); } if (this.state === ImageryState.TEXTURE_LOADED) { this.state = ImageryState.TRANSITIONING; - this.imageryLayer._reprojectTexture(context, commandList, this); + this.imageryLayer._reprojectTexture(frameState, this); } }; diff --git a/Source/Scene/ImageryLayer.js b/Source/Scene/ImageryLayer.js index d19117e44deb..bf337b69daf8 100644 --- a/Source/Scene/ImageryLayer.js +++ b/Source/Scene/ImageryLayer.js @@ -721,12 +721,13 @@ define([ * * @private * - * @param {Context} context The rendered context to use. + * @param {FrameState} frameState The frameState. * @param {Imagery} imagery The imagery instance to reproject. */ - ImageryLayer.prototype._reprojectTexture = function(context, commandList, imagery) { + ImageryLayer.prototype._reprojectTexture = function(frameState, imagery) { var texture = imagery.texture; var rectangle = imagery.rectangle; + var context = frameState.context; // Reproject this texture if it is not already in a geographic projection and // the pixels are more than 1e-5 radians apart. The pixel spacing cutoff @@ -749,7 +750,7 @@ define([ finalizeReprojectTexture(that, context, imagery, outputTexture); } }); - commandList.push(computeCommand); + frameState.commandList.push(computeCommand); } else { finalizeReprojectTexture(this, context, imagery, texture); } diff --git a/Source/Scene/ImageryLayerCollection.js b/Source/Scene/ImageryLayerCollection.js index f9bc588d9c22..b7d7de69137d 100644 --- a/Source/Scene/ImageryLayerCollection.js +++ b/Source/Scene/ImageryLayerCollection.js @@ -374,7 +374,6 @@ define([ // Find the terrain tile containing the picked location. var tilesToRender = scene.globe._surface._tilesToRender; - var length = tilesToRender.length; var pickedTile; for (var textureIndex = 0; !defined(pickedTile) && textureIndex < tilesToRender.length; ++textureIndex) { @@ -389,7 +388,6 @@ define([ } // Pick against all attached imagery tiles containing the pickedLocation. - var tileExtent = pickedTile.rectangle; var imageryTiles = pickedTile.data.imagery; var promises = []; diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js index f265e8b551e6..898f92aa7c7c 100644 --- a/Source/Scene/Material.js +++ b/Source/Scene/Material.js @@ -657,14 +657,44 @@ define([ }; function createTexture2DUpdateFunction(uniformId) { + var oldUniformValue; return function(material, context) { var uniforms = material.uniforms; var uniformValue = uniforms[uniformId]; + var uniformChanged = oldUniformValue !== uniformValue; + oldUniformValue = uniformValue; var texture = material._textures[uniformId]; var uniformDimensionsName; var uniformDimensions; + if (uniformValue instanceof HTMLVideoElement) { + // HTMLVideoElement.readyState >=2 means we have enough data for the current frame. + // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState + if (uniformValue.readyState >= 2) { + if (uniformChanged && defined(texture)) { + if (texture !== context.defaultTexture) { + texture.destroy(); + } + texture = undefined; + } + + if (!defined(texture) || texture === context.defaultTexture) { + texture = new Texture({ + context : context, + source : uniformValue + }); + material._textures[uniformId] = texture; + return; + } + + texture.copyFrom(uniformValue); + } else if (!defined(texture)) { + material._textures[uniformId] = context.defaultTexture; + } + return; + } + if (uniformValue instanceof Texture && uniformValue !== texture) { material._texturePaths[uniformId] = undefined; var tmp = material._textures[uniformId]; @@ -998,14 +1028,17 @@ define([ type : Material.ImageType, uniforms : { image : Material.DefaultImageId, - repeat : new Cartesian2(1.0, 1.0) + repeat : new Cartesian2(1.0, 1.0), + alpha : 1.0 }, components : { diffuse : 'texture2D(image, fract(repeat * materialInput.st)).rgb', - alpha : 'texture2D(image, fract(repeat * materialInput.st)).a' + alpha : 'texture2D(image, fract(repeat * materialInput.st)).a * alpha' } }, - translucent : true + translucent : function(material) { + return material.uniforms.alpha < 1.0; + } }); /** diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js index 53e1732d5238..31c401cb897b 100644 --- a/Source/Scene/Model.js +++ b/Source/Scene/Model.js @@ -13,8 +13,8 @@ define([ '../Core/deprecationWarning', '../Core/destroyObject', '../Core/DeveloperError', - '../Core/Event', '../Core/FeatureDetection', + '../Core/getBaseUri', '../Core/getMagic', '../Core/getStringFromTypedArray', '../Core/IndexDatatype', @@ -48,8 +48,8 @@ define([ './getModelAccessor', './ModelAnimationCache', './ModelAnimationCollection', - './modelMaterialsCommon', './ModelMaterial', + './modelMaterialsCommon', './ModelMesh', './ModelNode', './Pass', @@ -68,8 +68,8 @@ define([ deprecationWarning, destroyObject, DeveloperError, - Event, FeatureDetection, + getBaseUri, getMagic, getStringFromTypedArray, IndexDatatype, @@ -103,14 +103,13 @@ define([ getModelAccessor, ModelAnimationCache, ModelAnimationCollection, - modelMaterialsCommon, ModelMaterial, + modelMaterialsCommon, ModelMesh, ModelNode, Pass, SceneMode) { "use strict"; - /*global WebGLRenderingContext*/ // Bail out if the browser doesn't support typed arrays, to prevent the setup function // from failing, since we won't be able to create a WebGL context anyway. @@ -124,7 +123,7 @@ define([ var ModelState = { NEEDS_LOAD : 0, LOADING : 1, - LOADED : 2, + LOADED : 2, // Renderable, but textures can still be pending when incrementallyLoadTextures is true. FAILED : 3 }; @@ -154,25 +153,15 @@ define([ this.createUniformMaps = true; this.createRuntimeNodes = true; - this.skinnedNodesNames = []; + this.skinnedNodesIds = []; } LoadResources.prototype.getBuffer = function(bufferView) { return getSubarray(this.buffers[bufferView.buffer], bufferView.byteOffset, bufferView.byteLength); }; - LoadResources.prototype.finishedPendingLoads = function() { - return ((this.pendingBufferLoads === 0) && - (this.pendingShaderLoads === 0) && - (this.pendingTextureLoads === 0)); - }; - - LoadResources.prototype.finishedResourceCreation = function() { - return ((this.buffersToCreate.length === 0) && - (this.programsToCreate.length === 0) && - (this.texturesToCreate.length === 0) && - (this.texturesToCreateFromBufferView.length === 0) && - (this.pendingBufferViewToImage === 0)); + LoadResources.prototype.finishedPendingBufferLoads = function() { + return (this.pendingBufferLoads === 0); }; LoadResources.prototype.finishedBuffersCreation = function() { @@ -184,10 +173,28 @@ define([ }; LoadResources.prototype.finishedTextureCreation = function() { - return ((this.pendingTextureLoads === 0) && - (this.texturesToCreate.length === 0) && - (this.texturesToCreateFromBufferView.length === 0) && - (this.pendingBufferViewToImage === 0)); + var finishedPendingLoads = (this.pendingTextureLoads === 0); + var finishedResourceCreation = + (this.texturesToCreate.length === 0) && + (this.texturesToCreateFromBufferView.length === 0); + + return finishedPendingLoads && finishedResourceCreation; + }; + + LoadResources.prototype.finishedEverythingButTextureCreation = function() { + var finishedPendingLoads = + (this.pendingBufferLoads === 0) && + (this.pendingShaderLoads === 0); + var finishedResourceCreation = + (this.buffersToCreate.length === 0) && + (this.programsToCreate.length === 0) && + (this.pendingBufferViewToImage === 0); + + return finishedPendingLoads && finishedResourceCreation; + }; + + LoadResources.prototype.finished = function() { + return this.finishedTextureCreation() && this.finishedEverythingButTextureCreation(); }; /////////////////////////////////////////////////////////////////////////// @@ -249,9 +256,9 @@ define([ var animationIds = []; if (defined(cachedGltf) && defined(cachedGltf.gltf)) { var animations = cachedGltf.gltf.animations; - for (var name in animations) { - if (animations.hasOwnProperty(name)) { - animationIds.push(name); + for (var id in animations) { + if (animations.hasOwnProperty(id)) { + animationIds.push(id); } } } @@ -296,6 +303,7 @@ define([ * @param {Number} [options.maximumScale] The maximum scale size of a model. An upper limit for minimumPixelSize. * @param {Object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. * @param {Boolean} [options.allowPicking=true] When true, each glTF mesh and primitive is pickable with {@link Scene#pick}. + * @param {Boolean} [options.incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded. * @param {Boolean} [options.asynchronous=true] Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded. * @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Draws the bounding sphere for each draw command in the model. * @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe. @@ -459,6 +467,8 @@ define([ */ this.activeAnimations = new ModelAnimationCollection(this); + this._defaultTexture = undefined; + this._incrementallyLoadTextures = defaultValue(options.incrementallyLoadTextures, true); this._asynchronous = defaultValue(options.asynchronous, true); /** @@ -488,6 +498,22 @@ define([ this.debugWireframe = defaultValue(options.debugWireframe, false); this._debugWireframe = false; + // Undocumented options + this._precreatedAttributes = options.precreatedAttributes; + this._vertexShaderLoaded = options.vertexShaderLoaded; + this._fragmentShaderLoaded = options.fragmentShaderLoaded; + this._uniformMapLoaded = options.uniformMapLoaded; + this._pickVertexShaderLoaded = options.pickVertexShaderLoaded; + this._pickFragmentShaderLoaded = options.pickFragmentShaderLoaded; + this._pickUniformMapLoaded = options.pickUniformMapLoaded; + this._ignoreCommands = defaultValue(options.ignoreCommands, false); + + /** + * @private + * @readonly + */ + this.cull = defaultValue(options.cull, true); + this._computedModelMatrix = new Matrix4(); // Derived from modelMatrix and scale this._initialRadius = undefined; // Radius without model's scale property, model-matrix scale, animations, or skins this._boundingSphere = undefined; @@ -735,18 +761,38 @@ define([ get : function() { return this._allowPicking; } - } - }); + }, - function getBasePath(url) { - var basePath = ''; - var i = url.lastIndexOf('/'); - if (i !== -1) { - basePath = url.substring(0, i + 1); - } + /** + * Determine if textures may continue to stream in after the model is loaded. + * + * @memberof Model.prototype + * + * @type {Boolean} + * @readonly + * + * @default true + */ + incrementallyLoadTextures : { + get : function() { + return this._incrementallyLoadTextures; + } + }, - return basePath; - } + /** + * Return the number of pending texture loads. + * + * @memberof Model.prototype + * + * @type {Number} + * @readonly + */ + pendingTextureLoads : { + get : function() { + return defined(this._loadResources) ? this._loadResources.pendingTextureLoads : 0; + } + } + }); function getAbsoluteURL(url) { var docUri = new Uri(document.location.href); @@ -782,7 +828,7 @@ define([ //>>includeStart('debug', pragmas.debug); var version = view.getUint32(byteOffset, true); if (version !== 1) { - throw new DeveloperError('Only glTF Binary version 1 is supported. Version ' + version + ' is not.'); + throw new DeveloperError('Only Binary glTF version 1 is supported. Version ' + version + ' is not.'); } //>>includeEnd('debug'); byteOffset += sizeOfUint32; @@ -836,7 +882,9 @@ define([ * @param {Number} [options.scale=1.0] A uniform scale applied to this model. * @param {Number} [options.minimumPixelSize=0.0] The approximate minimum pixel size of the model regardless of zoom. * @param {Number} [options.maxiumumScale] The maximum scale for the model. + * @param {Object} [options.id] A user-defined object to return when the model is picked with {@link Scene#pick}. * @param {Boolean} [options.allowPicking=true] When true, each glTF mesh and primitive is pickable with {@link Scene#pick}. + * @param {Boolean} [options.incrementallyLoadTextures=true] Determine if textures may continue to stream in after the model is loaded. * @param {Boolean} [options.asynchronous=true] Determines if model WebGL resource creation will be spread out over several frames or block until completion once all glTF files are loaded. * @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Draws the bounding sphere for each {@link DrawCommand} in the model. * @param {Boolean} [options.debugWireframe=false] For debugging only. Draws the model in wireframe. @@ -886,7 +934,7 @@ define([ var cacheKey = defaultValue(options.cacheKey, getAbsoluteURL(url)); options = clone(options); - options.basePath = getBasePath(url); + options.basePath = getBaseUri(url); options.cacheKey = cacheKey; var model = new Model(options); @@ -1002,7 +1050,6 @@ define([ var aMaxScratch = new Cartesian3(); function computeBoundingSphere(gltf) { - var version = gltf.asset.version; var gltfNodes = gltf.nodes; var gltfMeshes = gltf.meshes; var gltfAccessors = gltf.accessors; @@ -1071,32 +1118,30 @@ define([ }; } - function bufferLoad(model, name) { + function bufferLoad(model, id) { return function(arrayBuffer) { var loadResources = model._loadResources; - loadResources.buffers[name] = new Uint8Array(arrayBuffer); + loadResources.buffers[id] = new Uint8Array(arrayBuffer); --loadResources.pendingBufferLoads; }; } function parseBuffers(model) { var buffers = model.gltf.buffers; - for (var name in buffers) { - if (buffers.hasOwnProperty(name)) { - var buffer = buffers[name]; + for (var id in buffers) { + if (buffers.hasOwnProperty(id)) { + var buffer = buffers[id]; - if (name === 'CESIUM_binary_glTF' || name === 'KHR_binary_glTF') { + if (id === 'CESIUM_binary_glTF' || id === 'KHR_binary_glTF') { // Buffer is the binary glTF file itself that is already loaded var loadResources = model._loadResources; - loadResources.buffers[name] = model._cachedGltf.bgltf; + loadResources.buffers[id] = model._cachedGltf.bgltf; } else if (buffer.type === 'arraybuffer') { ++model._loadResources.pendingBufferLoads; var uri = new Uri(buffer.uri); var bufferPath = uri.resolve(model._baseUri).toString(); - loadArrayBuffer(bufferPath).then(bufferLoad(model, name)).otherwise(getFailedLoadFunction(model, 'buffer', bufferPath)); - } else if (buffer.type === 'text') { - // GLTF_SPEC: Load compressed .bin with loadText. https://github.com/KhronosGroup/glTF/issues/230 + loadArrayBuffer(bufferPath).then(bufferLoad(model, id)).otherwise(getFailedLoadFunction(model, 'buffer', bufferPath)); } } } @@ -1104,19 +1149,19 @@ define([ function parseBufferViews(model) { var bufferViews = model.gltf.bufferViews; - for (var name in bufferViews) { - if (bufferViews.hasOwnProperty(name)) { - if (bufferViews[name].target === WebGLConstants.ARRAY_BUFFER) { - model._loadResources.buffersToCreate.enqueue(name); + for (var id in bufferViews) { + if (bufferViews.hasOwnProperty(id)) { + if (bufferViews[id].target === WebGLConstants.ARRAY_BUFFER) { + model._loadResources.buffersToCreate.enqueue(id); } } } } - function shaderLoad(model, name) { + function shaderLoad(model, id) { return function(source) { var loadResources = model._loadResources; - loadResources.shaders[name] = { + loadResources.shaders[id] = { source : source, bufferView : undefined }; @@ -1126,13 +1171,13 @@ define([ function parseShaders(model) { var shaders = model.gltf.shaders; - for (var name in shaders) { - if (shaders.hasOwnProperty(name)) { - var shader = shaders[name]; + for (var id in shaders) { + if (shaders.hasOwnProperty(id)) { + var shader = shaders[id]; // Shader references either uri (external or base64-encoded) or bufferView if (defined(shader.extras) && defined(shader.extras.source)) { - model._loadResources.shaders[name] = { + model._loadResources.shaders[id] = { source : shader.extras.source, bufferView : undefined }; @@ -1147,7 +1192,7 @@ define([ binary = shader.extensions.KHR_binary_glTF; } - model._loadResources.shaders[name] = { + model._loadResources.shaders[id] = { source : undefined, bufferView : binary.bufferView }; @@ -1155,7 +1200,7 @@ define([ ++model._loadResources.pendingShaderLoads; var uri = new Uri(shader.uri); var shaderPath = uri.resolve(model._baseUri).toString(); - loadText(shaderPath).then(shaderLoad(model, name)).otherwise(getFailedLoadFunction(model, 'shader', shaderPath)); + loadText(shaderPath).then(shaderLoad(model, id)).otherwise(getFailedLoadFunction(model, 'shader', shaderPath)); } } } @@ -1163,31 +1208,31 @@ define([ function parsePrograms(model) { var programs = model.gltf.programs; - for (var name in programs) { - if (programs.hasOwnProperty(name)) { - model._loadResources.programsToCreate.enqueue(name); + for (var id in programs) { + if (programs.hasOwnProperty(id)) { + model._loadResources.programsToCreate.enqueue(id); } } } - function imageLoad(model, name) { + function imageLoad(model, id) { return function(image) { var loadResources = model._loadResources; --loadResources.pendingTextureLoads; loadResources.texturesToCreate.enqueue({ - name : name, - image : image, - bufferView : undefined - }); - }; + id : id, + image : image, + bufferView : undefined + }); + }; } function parseTextures(model) { var images = model.gltf.images; var textures = model.gltf.textures; - for (var name in textures) { - if (textures.hasOwnProperty(name)) { - var gltfImage = images[textures[name].source]; + for (var id in textures) { + if (textures.hasOwnProperty(id)) { + var gltfImage = images[textures[id].source]; // Image references either uri (external or base64-encoded) or bufferView if (defined(gltfImage.extensions) && @@ -1200,7 +1245,7 @@ define([ binary = gltfImage.extensions.KHR_binary_glTF; } model._loadResources.texturesToCreateFromBufferView.enqueue({ - name : name, + id : id, image : undefined, bufferView : binary.bufferView, mimeType : binary.mimeType @@ -1209,7 +1254,7 @@ define([ ++model._loadResources.pendingTextureLoads; var uri = new Uri(gltfImage.uri); var imagePath = uri.resolve(model._baseUri).toString(); - loadImage(imagePath).then(imageLoad(model, name)).otherwise(getFailedLoadFunction(model, 'image', imagePath)); + loadImage(imagePath).then(imageLoad(model, id)).otherwise(getFailedLoadFunction(model, 'image', imagePath)); } } } @@ -1235,12 +1280,12 @@ define([ var runtimeNodesByName = {}; var skinnedNodes = []; - var skinnedNodesNames = model._loadResources.skinnedNodesNames; + var skinnedNodesIds = model._loadResources.skinnedNodesIds; var nodes = model.gltf.nodes; - for (var name in nodes) { - if (nodes.hasOwnProperty(name)) { - var node = nodes[name]; + for (var id in nodes) { + if (nodes.hasOwnProperty(id)) { + var node = nodes[id]; var runtimeNode = { // Animation targets @@ -1276,13 +1321,13 @@ define([ // Publicly-accessible ModelNode instance to modify animation targets publicNode : undefined }; - runtimeNode.publicNode = new ModelNode(model, node, runtimeNode, name, getTransform(node)); + runtimeNode.publicNode = new ModelNode(model, node, runtimeNode, id, getTransform(node)); - runtimeNodes[name] = runtimeNode; + runtimeNodes[id] = runtimeNode; runtimeNodesByName[node.name] = runtimeNode; if (defined(node.skin)) { - skinnedNodesNames.push(name); + skinnedNodesIds.push(id); skinnedNodes.push(runtimeNode); } } @@ -1294,44 +1339,44 @@ define([ } function parseMaterials(model) { - var runtimeMaterials = {}; + var runtimeMaterialsByName = {}; var runtimeMaterialsById = {}; var materials = model.gltf.materials; var uniformMaps = model._uniformMaps; - for (var name in materials) { - if (materials.hasOwnProperty(name)) { + for (var id in materials) { + if (materials.hasOwnProperty(id)) { // Allocated now so ModelMaterial can keep a reference to it. - uniformMaps[name] = { + uniformMaps[id] = { uniformMap : undefined, values : undefined, jointMatrixUniformName : undefined }; - var material = materials[name]; - var modelMaterial = new ModelMaterial(model, material, name); - runtimeMaterials[material.name] = modelMaterial; - runtimeMaterialsById[name] = modelMaterial; + var material = materials[id]; + var modelMaterial = new ModelMaterial(model, material, id); + runtimeMaterialsByName[material.name] = modelMaterial; + runtimeMaterialsById[id] = modelMaterial; } } - model._runtime.materialsByName = runtimeMaterials; + model._runtime.materialsByName = runtimeMaterialsByName; model._runtime.materialsById = runtimeMaterialsById; } function parseMeshes(model) { - var runtimeMeshes = {}; + var runtimeMeshesByName = {}; var runtimeMaterialsById = model._runtime.materialsById; var meshes = model.gltf.meshes; - for (var name in meshes) { - if (meshes.hasOwnProperty(name)) { - var mesh = meshes[name]; - runtimeMeshes[mesh.name] = new ModelMesh(mesh, runtimeMaterialsById, name); + for (var id in meshes) { + if (meshes.hasOwnProperty(id)) { + var mesh = meshes[id]; + runtimeMeshesByName[mesh.name] = new ModelMesh(mesh, runtimeMaterialsById, id); } } - model._runtime.meshesByName = runtimeMeshes; + model._runtime.meshesByName = runtimeMeshesByName; } function parse(model) { @@ -1362,8 +1407,8 @@ define([ var rendererBuffers = model._rendererResources.buffers; while (loadResources.buffersToCreate.length > 0) { - var bufferViewName = loadResources.buffersToCreate.dequeue(); - bufferView = bufferViews[bufferViewName]; + var bufferViewId = loadResources.buffersToCreate.dequeue(); + bufferView = bufferViews[bufferViewId]; // Only ARRAY_BUFFER here. ELEMENT_ARRAY_BUFFER created below. var vertexBuffer = Buffer.createVertexBuffer({ @@ -1372,16 +1417,16 @@ define([ usage : BufferUsage.STATIC_DRAW }); vertexBuffer.vertexArrayDestroyable = false; - rendererBuffers[bufferViewName] = vertexBuffer; + rendererBuffers[bufferViewId] = vertexBuffer; } // The Cesium Renderer requires knowing the datatype for an index buffer // at creation type, which is not part of the glTF bufferview so loop // through glTF accessors to create the bufferview's index buffer. var accessors = model.gltf.accessors; - for (var name in accessors) { - if (accessors.hasOwnProperty(name)) { - var accessor = accessors[name]; + for (var id in accessors) { + if (accessors.hasOwnProperty(id)) { + var accessor = accessors[id]; bufferView = bufferViews[accessor.bufferView]; if ((bufferView.target === WebGLConstants.ELEMENT_ARRAY_BUFFER) && !defined(rendererBuffers[accessor.bufferView])) { @@ -1424,32 +1469,55 @@ define([ return getStringFromTypedArray(loadResources.getBuffer(bufferView)); } - function createProgram(name, model, context) { + function modifyShader(shader, programName, callback) { + if (defined(callback)) { + shader = callback(shader, programName); + } + return shader; + } + + function createProgram(id, model, context) { var programs = model.gltf.programs; var shaders = model._loadResources.shaders; - var program = programs[name]; + var program = programs[id]; var attributeLocations = createAttributeLocations(program.attributes); var vs = getShaderSource(model, shaders[program.vertexShader]); var fs = getShaderSource(model, shaders[program.fragmentShader]); - model._rendererResources.programs[name] = ShaderProgram.fromCache({ + var drawVS = modifyShader(vs, id, model._vertexShaderLoaded); + var drawFS = modifyShader(fs, id, model._fragmentShaderLoaded); + + // Add pre-created attributes to attributeLocations + var attributesLength = program.attributes.length; + var precreatedAttributes = model._precreatedAttributes; + if (defined(precreatedAttributes)) { + for (var attrName in precreatedAttributes) { + if (precreatedAttributes.hasOwnProperty(attrName)) { + attributeLocations[attrName] = attributesLength++; + } + } + } + + model._rendererResources.programs[id] = ShaderProgram.fromCache({ context : context, - vertexShaderSource : vs, - fragmentShaderSource : fs, + vertexShaderSource : drawVS, + fragmentShaderSource : drawFS, attributeLocations : attributeLocations }); if (model.allowPicking) { // PERFORMANCE_IDEA: Can optimize this shader with a glTF hint. https://github.com/KhronosGroup/glTF/issues/181 - var pickFS = new ShaderSource({ - sources : [fs], - pickColorQualifier : 'uniform' - }); + var pickVS = modifyShader(vs, id, model._pickVertexShaderLoaded); + var pickFS = modifyShader(fs, id, model._pickFragmentShaderLoaded); + + if (!model._pickFragmentShaderLoaded) { + pickFS = ShaderSource.createPickFragmentShaderSource(fs, 'uniform'); + } - model._rendererResources.pickPrograms[name] = ShaderProgram.fromCache({ + model._rendererResources.pickPrograms[id] = ShaderProgram.fromCache({ context : context, - vertexShaderSource : vs, + vertexShaderSource : pickVS, fragmentShaderSource : pickFS, attributeLocations : attributeLocations }); @@ -1458,7 +1526,7 @@ define([ function createPrograms(model, context) { var loadResources = model._loadResources; - var name; + var id; if (loadResources.pendingShaderLoads !== 0) { return; @@ -1473,14 +1541,14 @@ define([ if (model.asynchronous) { // Create one program per frame if (loadResources.programsToCreate.length > 0) { - name = loadResources.programsToCreate.dequeue(); - createProgram(name, model, context); + id = loadResources.programsToCreate.dequeue(); + createProgram(id, model, context); } } else { // Create all loaded programs this frame while (loadResources.programsToCreate.length > 0) { - name = loadResources.programsToCreate.dequeue(); - createProgram(name, model, context); + id = loadResources.programsToCreate.dequeue(); + createProgram(id, model, context); } } } @@ -1488,7 +1556,7 @@ define([ function getOnImageCreatedFromTypedArray(loadResources, gltfTexture) { return function(image) { loadResources.texturesToCreate.enqueue({ - name : gltfTexture.name, + id : gltfTexture.id, image : image, bufferView : undefined }); @@ -1511,7 +1579,7 @@ define([ var bufferView = gltf.bufferViews[gltfTexture.bufferView]; var onload = getOnImageCreatedFromTypedArray(loadResources, gltfTexture); - var onerror = getFailedLoadFunction(model, 'image', 'name: ' + gltfTexture.name + ', bufferView: ' + gltfTexture.bufferView); + var onerror = getFailedLoadFunction(model, 'image', 'id: ' + gltfTexture.id + ', bufferView: ' + gltfTexture.bufferView); loadImageFromTypedArray(loadResources.getBuffer(bufferView), gltfTexture.mimeType). then(onload).otherwise(onerror); @@ -1527,11 +1595,11 @@ define([ var rendererSamplers = model._rendererResources.samplers; var samplers = model.gltf.samplers; - for (var name in samplers) { - if (samplers.hasOwnProperty(name)) { - var sampler = samplers[name]; + for (var id in samplers) { + if (samplers.hasOwnProperty(id)) { + var sampler = samplers[id]; - rendererSamplers[name] = new Sampler({ + rendererSamplers[id] = new Sampler({ wrapS : sampler.wrapS, wrapT : sampler.wrapT, minificationFilter : sampler.minFilter, @@ -1544,7 +1612,7 @@ define([ function createTexture(gltfTexture, model, context) { var textures = model.gltf.textures; - var texture = textures[gltfTexture.name]; + var texture = textures[gltfTexture.id]; var rendererSamplers = model._rendererResources.samplers; var sampler = rendererSamplers[texture.sampler]; @@ -1581,6 +1649,7 @@ define([ source : source, pixelFormat : texture.internalFormat, pixelDatatype : texture.type, + sampler : sampler, flipY : false }); } @@ -1589,9 +1658,8 @@ define([ if (mipmap) { tx.generateMipmap(); } - tx.sampler = sampler; - model._rendererResources.textures[gltfTexture.name] = tx; + model._rendererResources.textures[gltfTexture.id] = tx; } function createTextures(model, context) { @@ -1615,7 +1683,6 @@ define([ function getAttributeLocations(model, primitive) { var gltf = model.gltf; - var programs = gltf.programs; var techniques = gltf.techniques; var materials = gltf.materials; @@ -1630,8 +1697,15 @@ define([ // Note: WebGL shader compiler may have optimized and removed some attributes from programAttributeLocations for (var location in programAttributeLocations){ if (programAttributeLocations.hasOwnProperty(location)) { - var parameter = parameters[attributes[location]]; - attributeLocations[parameter.semantic] = programAttributeLocations[location].index; + var attribute = attributes[location]; + var index = programAttributeLocations[location].index; + if (defined(attribute)) { + var parameter = parameters[attribute]; + attributeLocations[parameter.semantic] = index; + } else { + // Pre-created attributes + attributeLocations[location] = index; + } } } @@ -1668,12 +1742,12 @@ define([ var nodes = gltf.nodes; var runtimeNodes = model._runtime.nodes; - var skinnedNodesNames = model._loadResources.skinnedNodesNames; - var length = skinnedNodesNames.length; + var skinnedNodesIds = model._loadResources.skinnedNodesIds; + var length = skinnedNodesIds.length; for (var j = 0; j < length; ++j) { - var name = skinnedNodesNames[j]; - var skinnedNode = runtimeNodes[name]; - var node = nodes[name]; + var id = skinnedNodesIds[j]; + var skinnedNode = runtimeNodes[id]; + var node = nodes[id]; var runtimeSkin = runtimeSkins[node.skin]; skinnedNode.inverseBindMatrices = runtimeSkin.inverseBindMatrices; @@ -1715,9 +1789,9 @@ define([ var skins = gltf.skins; var runtimeSkins = {}; - for (var name in skins) { - if (skins.hasOwnProperty(name)) { - var skin = skins[name]; + for (var id in skins) { + if (skins.hasOwnProperty(id)) { + var skin = skins[id]; var accessor = accessors[skin.inverseBindMatrices]; var bindShapeMatrix; @@ -1725,7 +1799,7 @@ define([ bindShapeMatrix = Matrix4.clone(skin.bindShapeMatrix); } - runtimeSkins[name] = { + runtimeSkins[id] = { inverseBindMatrices : ModelAnimationCache.getSkinInverseBindMatrices(model, accessor), bindShapeMatrix : bindShapeMatrix // not used when undefined }; @@ -1737,12 +1811,11 @@ define([ function getChannelEvaluator(model, runtimeNode, targetPath, spline) { return function(localAnimationTime) { -// Workaround for https://github.com/KhronosGroup/glTF/issues/219 -/* - if (targetPath === 'translation') { - return; - } -*/ + // Workaround for https://github.com/KhronosGroup/glTF/issues/219 + + //if (targetPath === 'translation') { + // return; + //} runtimeNode[targetPath] = spline.evaluate(localAnimationTime, runtimeNode[targetPath]); runtimeNode.dirtyNumber = model._maxDirtyNumber; }; @@ -1751,7 +1824,7 @@ define([ function createRuntimeAnimations(model) { var loadResources = model._loadResources; - if (!loadResources.finishedPendingLoads()) { + if (!loadResources.finishedPendingBufferLoads()) { return; } @@ -1766,18 +1839,17 @@ define([ var runtimeNodes = model._runtime.nodes; var animations = model.gltf.animations; var accessors = model.gltf.accessors; - var name; - for (var animationName in animations) { - if (animations.hasOwnProperty(animationName)) { - var animation = animations[animationName]; + for (var animationId in animations) { + if (animations.hasOwnProperty(animationId)) { + var animation = animations[animationId]; var channels = animation.channels; var parameters = animation.parameters; var samplers = animation.samplers; var parameterValues = {}; - for (name in parameters) { + for (var name in parameters) { if (parameters.hasOwnProperty(name)) { parameterValues[name] = ModelAnimationCache.getAnimationParameterValues(model, accessors[parameters[name]]); } @@ -1799,12 +1871,12 @@ define([ startTime = Math.min(startTime, times[0]); stopTime = Math.max(stopTime, times[times.length - 1]); - var spline = ModelAnimationCache.getAnimationSpline(model, animationName, animation, channel.sampler, sampler, parameterValues); + var spline = ModelAnimationCache.getAnimationSpline(model, animationId, animation, channel.sampler, sampler, parameterValues); // GLTF_SPEC: Support more targets like materials. https://github.com/KhronosGroup/glTF/issues/142 channelEvaluators[i] = getChannelEvaluator(model, runtimeNodes[target.id], target.path, spline); } - model._runtime.animations[animationName] = { + model._runtime.animations[animationId] = { startTime : startTime, stopTime : stopTime, channelEvaluators : channelEvaluators @@ -1831,9 +1903,9 @@ define([ var accessors = gltf.accessors; var meshes = gltf.meshes; - for (var meshName in meshes) { - if (meshes.hasOwnProperty(meshName)) { - var primitives = meshes[meshName].primitives; + for (var meshId in meshes) { + if (meshes.hasOwnProperty(meshId)) { + var primitives = meshes[meshId].primitives; var primitivesLength = primitives.length; for (var i = 0; i < primitivesLength; ++i) { @@ -1846,16 +1918,19 @@ define([ // https://github.com/KhronosGroup/glTF/issues/258 var attributeLocations = getAttributeLocations(model, primitive); - var attrs = []; + var attributeName; + var attributeLocation; + var attribute; + var attributes = []; var primitiveAttributes = primitive.attributes; - for (var attrName in primitiveAttributes) { - if (primitiveAttributes.hasOwnProperty(attrName)) { - var attributeLocation = attributeLocations[attrName]; + for (attributeName in primitiveAttributes) { + if (primitiveAttributes.hasOwnProperty(attributeName)) { + attributeLocation = attributeLocations[attributeName]; // Skip if the attribute is not used by the material, e.g., because the asset was exported // with an attribute that wasn't used and the asset wasn't optimized. if (defined(attributeLocation)) { - var a = accessors[primitiveAttributes[attrName]]; - attrs.push({ + var a = accessors[primitiveAttributes[attributeName]]; + attributes.push({ index : attributeLocation, vertexBuffer : rendererBuffers[a.bufferView], componentsPerAttribute : getModelAccessor(a).componentsPerAttribute, @@ -1868,14 +1943,29 @@ define([ } } + // Add pre-created attributes + var precreatedAttributes = model._precreatedAttributes; + if (defined(precreatedAttributes)) { + for (attributeName in precreatedAttributes) { + if (precreatedAttributes.hasOwnProperty(attributeName)) { + attributeLocation = attributeLocations[attributeName]; + if (defined(attributeLocation)) { + attribute = precreatedAttributes[attributeName]; + attribute.index = attributeLocation; + attributes.push(attribute); + } + } + } + } + var indexBuffer; if (defined(primitive.indices)) { var accessor = accessors[primitive.indices]; indexBuffer = rendererBuffers[accessor.bufferView]; } - rendererVertexArrays[meshName + '.primitive.' + i] = new VertexArray({ + rendererVertexArrays[meshId + '.primitive.' + i] = new VertexArray({ context : context, - attributes : attrs, + attributes : attributes, indexBuffer : indexBuffer }); } @@ -1909,9 +1999,9 @@ define([ loadResources.createRenderStates = false; var rendererRenderStates = model._rendererResources.renderStates; var techniques = model.gltf.techniques; - for (var name in techniques) { - if (techniques.hasOwnProperty(name)) { - var technique = techniques[name]; + for (var id in techniques) { + if (techniques.hasOwnProperty(id)) { + var technique = techniques[id]; var states = technique.states; var booleanStates = getBooleanStates(states); @@ -1930,7 +2020,7 @@ define([ var polygonOffset = defaultValue(statesFunctions.polygonOffset, [0.0, 0.0]); var scissor = defaultValue(statesFunctions.scissor, [0.0, 0.0, 0.0, 0.0]); - rendererRenderStates[name] = RenderState.fromCache({ + rendererRenderStates[id] = RenderState.fromCache({ frontFace : defined(statesFunctions.frontFace) ? statesFunctions.frontFace[0] : WebGLConstants.CCW, cull : { enabled : booleanStates[WebGLConstants.CULL_FACE], @@ -1988,6 +2078,7 @@ define([ } // This doesn't support LOCAL, which we could add if it is ever used. + var scratchTranslationRtc = new Cartesian3(); var gltfSemanticUniforms = { MODEL : function(uniformState, model) { return function() { @@ -2013,7 +2104,10 @@ define([ // CESIUM_RTC extension var mvRtc = new Matrix4(); return function() { - return Matrix4.setTranslation(uniformState.modelView, model._rtcCenterEye, mvRtc); + Matrix4.getTranslation(uniformState.model, scratchTranslationRtc); + Cartesian3.add(scratchTranslationRtc, model._rtcCenter, scratchTranslationRtc); + Matrix4.multiplyByPoint(uniformState.view, scratchTranslationRtc, scratchTranslationRtc); + return Matrix4.setTranslation(uniformState.modelView, scratchTranslationRtc, mvRtc); }; }, MODELVIEWPROJECTION : function(uniformState, model) { @@ -2061,7 +2155,7 @@ define([ return uniformState.viewportCartesian4; }; } - // JOINTMATRIX created in createCommands() + // JOINTMATRIX created in createCommand() }; /////////////////////////////////////////////////////////////////////////// @@ -2145,41 +2239,71 @@ define([ return that; } - function getTextureUniformFunction(value, model) { - var that = { - value : model._rendererResources.textures[value], - clone : function(source, result) { - return source; + /////////////////////////////////////////////////////////////////////////// + + var DelayLoadedTextureUniform = function(value, model) { + this._value = undefined; + this._textureId = value; + this._model = model; + }; + + defineProperties(DelayLoadedTextureUniform.prototype, { + value : { + get : function() { + // Use the default texture (1x1 white) until the model's texture is loaded + if (!defined(this._value)) { + var texture = this._model._rendererResources.textures[this._textureId]; + if (defined(texture)) { + this._value = texture; + } else { + return this._model._defaultTexture; + } + } + + return this._value; }, - func : function() { - return that.value; + set : function(value) { + this._value = value; } + } + }); + + DelayLoadedTextureUniform.prototype.clone = function(source, result) { + return source; + }; + + DelayLoadedTextureUniform.prototype.func = undefined; + + /////////////////////////////////////////////////////////////////////////// + + function getTextureUniformFunction(value, model) { + var uniform = new DelayLoadedTextureUniform(value, model); + // Define function here to access closure since 'this' can't be + // used when the Renderer sets uniforms. + uniform.func = function() { + return uniform.value; }; - return that; + return uniform; } var gltfUniformFunctions = {}; - - // this check must use typeof, not defined, because defined doesn't work with undeclared variables. - if (typeof WebGLRenderingContext !== 'undefined') { - gltfUniformFunctions[WebGLConstants.FLOAT] = getScalarUniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_VEC2] = getVec2UniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_VEC3] = getVec3UniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_VEC4] = getVec4UniformFunction; - gltfUniformFunctions[WebGLConstants.INT] = getScalarUniformFunction; - gltfUniformFunctions[WebGLConstants.INT_VEC2] = getVec2UniformFunction; - gltfUniformFunctions[WebGLConstants.INT_VEC3] = getVec3UniformFunction; - gltfUniformFunctions[WebGLConstants.INT_VEC4] = getVec4UniformFunction; - gltfUniformFunctions[WebGLConstants.BOOL] = getScalarUniformFunction; - gltfUniformFunctions[WebGLConstants.BOOL_VEC2] = getVec2UniformFunction; - gltfUniformFunctions[WebGLConstants.BOOL_VEC3] = getVec3UniformFunction; - gltfUniformFunctions[WebGLConstants.BOOL_VEC4] = getVec4UniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_MAT2] = getMat2UniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_MAT3] = getMat3UniformFunction; - gltfUniformFunctions[WebGLConstants.FLOAT_MAT4] = getMat4UniformFunction; - gltfUniformFunctions[WebGLConstants.SAMPLER_2D] = getTextureUniformFunction; - // GLTF_SPEC: Support SAMPLER_CUBE. https://github.com/KhronosGroup/glTF/issues/40 - } + gltfUniformFunctions[WebGLConstants.FLOAT] = getScalarUniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_VEC2] = getVec2UniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_VEC3] = getVec3UniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_VEC4] = getVec4UniformFunction; + gltfUniformFunctions[WebGLConstants.INT] = getScalarUniformFunction; + gltfUniformFunctions[WebGLConstants.INT_VEC2] = getVec2UniformFunction; + gltfUniformFunctions[WebGLConstants.INT_VEC3] = getVec3UniformFunction; + gltfUniformFunctions[WebGLConstants.INT_VEC4] = getVec4UniformFunction; + gltfUniformFunctions[WebGLConstants.BOOL] = getScalarUniformFunction; + gltfUniformFunctions[WebGLConstants.BOOL_VEC2] = getVec2UniformFunction; + gltfUniformFunctions[WebGLConstants.BOOL_VEC3] = getVec3UniformFunction; + gltfUniformFunctions[WebGLConstants.BOOL_VEC4] = getVec4UniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_MAT2] = getMat2UniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_MAT3] = getMat3UniformFunction; + gltfUniformFunctions[WebGLConstants.FLOAT_MAT4] = getMat4UniformFunction; + gltfUniformFunctions[WebGLConstants.SAMPLER_2D] = getTextureUniformFunction; + // GLTF_SPEC: Support SAMPLER_CUBE. https://github.com/KhronosGroup/glTF/issues/40 var gltfUniformsFromNode = { MODEL : function(uniformState, model, runtimeNode) { @@ -2286,7 +2410,7 @@ define([ function createUniformMaps(model, context) { var loadResources = model._loadResources; - if (!loadResources.finishedTextureCreation() || !loadResources.finishedProgramCreation()) { + if (!loadResources.finishedProgramCreation()) { return; } @@ -2298,12 +2422,11 @@ define([ var gltf = model.gltf; var materials = gltf.materials; var techniques = gltf.techniques; - var programs = gltf.programs; var uniformMaps = model._uniformMaps; - for (var materialName in materials) { - if (materials.hasOwnProperty(materialName)) { - var material = materials[materialName]; + for (var materialId in materials) { + if (materials.hasOwnProperty(materialId)) { + var material = materials[materialId]; var instanceParameters = material.values; var technique = techniques[material.technique]; var parameters = technique.parameters; @@ -2353,7 +2476,7 @@ define([ } } - var u = uniformMaps[materialName]; + var u = uniformMaps[materialId]; u.uniformMap = uniformMap; // uniform name -> function for the renderer u.values = uniformValues; // material parameter name -> ModelMaterial for modifying the parameter at runtime u.jointMatrixUniformName = jointMatrixUniformName; @@ -2377,9 +2500,7 @@ define([ var nodeCommands = model._nodeCommands; var pickIds = model._pickIds; var allowPicking = model.allowPicking; - var runtimeMeshes = model._runtime.meshesByName; - - var debugShowBoundingVolume = model.debugShowBoundingVolume; + var runtimeMeshesByName = model._runtime.meshesByName; var resources = model._rendererResources; var rendererVertexArrays = resources.vertexArrays; @@ -2398,8 +2519,8 @@ define([ var meshesLength = meshes.length; for (var j = 0; j < meshesLength; ++j) { - var name = meshes[j]; - var mesh = gltfMeshes[name]; + var id = meshes[j]; + var mesh = gltfMeshes[id]; var primitives = mesh.primitives; var length = primitives.length; @@ -2412,6 +2533,7 @@ define([ var ix = accessors[primitive.indices]; var material = materials[primitive.material]; var technique = techniques[material.technique]; + var programId = technique.program; var boundingSphere; var positionAttribute = primitive.attributes.POSITION; @@ -2420,7 +2542,7 @@ define([ boundingSphere = BoundingSphere.fromCornerPoints(Cartesian3.fromArray(a.min), Cartesian3.fromArray(a.max)); } - var vertexArray = rendererVertexArrays[name + '.primitive.' + i]; + var vertexArray = rendererVertexArrays[id + '.primitive.' + i]; var offset; var count; if (defined(ix)) { @@ -2443,18 +2565,25 @@ define([ uniformMap = combine(uniformMap, jointUniformMap); } + // Allow callback to modify the uniformMap + if (defined(model._uniformMapLoaded)) { + uniformMap = model._uniformMapLoaded(uniformMap, programId, runtimeNode); + } + var rs = rendererRenderStates[material.technique]; + // GLTF_SPEC: Offical means to determine translucency. https://github.com/KhronosGroup/glTF/issues/105 var isTranslucent = rs.blending.enabled; var owner = { primitive : defaultValue(model.pickPrimitive, model), id : model.id, node : runtimeNode.publicNode, - mesh : runtimeMeshes[mesh.name] + mesh : runtimeMeshesByName[mesh.name] }; var command = new DrawCommand({ boundingVolume : new BoundingSphere(), // updated in update() + cull : model.cull, modelMatrix : new Matrix4(), // computed in update() primitiveType : primitive.mode, vertexArray : vertexArray, @@ -2470,16 +2599,30 @@ define([ var pickCommand; if (allowPicking) { - var pickId = context.createPickId(owner); - pickIds.push(pickId); - - var pickUniformMap = combine( - uniformMap, { + var pickUniformMap; + + // Callback to override default model picking + if (defined(model._pickFragmentShaderLoaded)) { + if (defined(model._pickUniformMapLoaded)) { + pickUniformMap = model._pickUniformMapLoaded(uniformMap); + } else { + // This is unlikely, but could happen if the override shader does not + // need new uniforms since, for example, its pick ids are coming from + // a vertex attribute or are baked into the shader source. + pickUniformMap = combine(uniformMap); + } + } else { + var pickId = context.createPickId(owner); + pickIds.push(pickId); + var pickUniforms = { czm_pickColor : createPickColorFunction(pickId.color) - }); + }; + pickUniformMap = combine(uniformMap, pickUniforms); + } pickCommand = new DrawCommand({ boundingVolume : new BoundingSphere(), // updated in update() + cull : model.cull, modelMatrix : new Matrix4(), // computed in update() primitiveType : primitive.mode, vertexArray : vertexArray, @@ -2508,7 +2651,7 @@ define([ function createRuntimeNodes(model, context) { var loadResources = model._loadResources; - if (!loadResources.finishedPendingLoads() || !loadResources.finishedResourceCreation()) { + if (!loadResources.finishedEverythingButTextureCreation()) { return; } @@ -2521,7 +2664,6 @@ define([ var runtimeNodes = model._runtime.nodes; var gltf = model.gltf; - var version = gltf.asset.version; var nodes = gltf.nodes; var scene = gltf.scenes[gltf.scene]; @@ -2529,7 +2671,6 @@ define([ var length = sceneNodes.length; var stack = []; - var axis = new Cartesian3(); for (var i = 0; i < length; ++i) { stack.push({ @@ -2584,7 +2725,9 @@ define([ model._runtime.nodes = runtimeNodes; } - function createResources(model, context) { + function createResources(model, frameState) { + var context = frameState.context; + if (model._loadRendererResourcesFromCache) { var resources = model._rendererResources; var cachedResources = model._cachedRendererResources; @@ -2596,8 +2739,13 @@ define([ resources.textures = cachedResources.textures; resources.samplers = cachedResources.samplers; resources.renderStates = cachedResources.renderStates; + + // Vertex arrays are unique to this model, create instead of using the cache. + if (defined(model._precreatedAttributes)) { + createVertexArrays(model, context); + } } else { - createBuffers(model, context); // using glTF bufferViews + createBuffers(model, context); // using glTF bufferViews createPrograms(model, context); createSamplers(model, context); loadTexturesFromBufferViews(model); @@ -2662,15 +2810,16 @@ define([ var commands = n.commands; if ((n.dirtyNumber === maxDirtyNumber) || modelTransformChanged || justLoaded) { + var nodeMatrix = Matrix4.multiplyTransformation(computedModelMatrix, transformToRoot, n.computedMatrix); var commandsLength = commands.length; if (commandsLength > 0) { // Node has meshes, which has primitives. Update their commands. for (var j = 0 ; j < commandsLength; ++j) { var primitiveCommand = commands[j]; var command = primitiveCommand.command; - Matrix4.multiplyTransformation(computedModelMatrix, transformToRoot, command.modelMatrix); + Matrix4.clone(nodeMatrix, command.modelMatrix); - // PERFORMANCE_IDEA: Can use transformWithoutScale if no node up to the root has scale (inclug animation) + // PERFORMANCE_IDEA: Can use transformWithoutScale if no node up to the root has scale (including animation) BoundingSphere.transform(primitiveCommand.boundingSphere, command.modelMatrix, command.boundingVolume); if (defined(model._rtcCenter)) { @@ -2683,9 +2832,6 @@ define([ BoundingSphere.clone(command.boundingVolume, pickCommand.boundingVolume); } } - } else { - // Node has a light or camera - n.computedMatrix = Matrix4.multiplyTransformation(computedModelMatrix, transformToRoot, n.computedMatrix); } } @@ -2832,20 +2978,12 @@ define([ } } - var scratchPixelSize = new Cartesian2(); var scratchBoundingSphere = new BoundingSphere(); function scaleInPixels(positionWC, radius, frameState) { scratchBoundingSphere.center = positionWC; scratchBoundingSphere.radius = radius; - var camera = frameState.camera; - var distance = camera.distanceToBoundingSphere(scratchBoundingSphere); - - var context = frameState.context; - var pixelSize = camera.frustum.getPixelDimensions(context.drawingBufferWidth, context.drawingBufferHeight, distance, scratchPixelSize); - var pixelScale = Math.max(pixelSize.x, pixelSize.y); - - return pixelScale; + return frameState.camera.getPixelSize(scratchBoundingSphere, frameState.context.drawingBufferWidth, frameState.context.drawingBufferHeight); } var scratchPosition = new Cartesian3(); @@ -2972,6 +3110,7 @@ define([ } var context = frameState.context; + this._defaultTexture = context.defaultTexture; if ((this._state === ModelState.NEEDS_LOAD) && defined(this.gltf)) { // Use renderer resources from cache instead of loading/creating them? @@ -3021,19 +3160,35 @@ define([ } } - var justLoaded = false; - if (this._state === ModelState.FAILED) { throw this._loadError; } + var loadResources = this._loadResources; + var incrementallyLoadTextures = this._incrementallyLoadTextures; + var justLoaded = false; + if (this._state === ModelState.LOADING) { - // Incrementally create WebGL resources as buffers/shaders/textures are downloaded - createResources(this, context); + // Create WebGL resources as buffers/shaders/textures are downloaded + createResources(this, frameState); - var loadResources = this._loadResources; - if (loadResources.finishedPendingLoads() && loadResources.finishedResourceCreation()) { + // Transition from LOADING -> LOADED once resources are downloaded and created. + // Textures may continue to stream in while in the LOADED state. + if (loadResources.finished() || + (incrementallyLoadTextures && loadResources.finishedEverythingButTextureCreation())) { this._state = ModelState.LOADED; + justLoaded = true; + } + } + + // Incrementally stream textures. + if (defined(loadResources) && (this._state === ModelState.LOADED)) { + // Also check justLoaded so we don't process twice during the transition frame + if (incrementallyLoadTextures && !justLoaded) { + createResources(this, frameState); + } + + if (loadResources.finished()) { this._loadResources = undefined; // Clear CPU memory since WebGL resources were created. var resources = this._rendererResources; @@ -3048,11 +3203,14 @@ define([ cachedResources.renderStates = resources.renderStates; cachedResources.ready = true; + // Vertex arrays are unique to this model, do not store in cache. + if (defined(this._precreatedAttributes)) { + cachedResources.vertexArrays = {}; + } + if (this.releaseGltfJson) { releaseCachedGltf(this); } - - justLoaded = true; } } @@ -3097,12 +3255,6 @@ define([ updatePickIds(this, context); updateWireframe(this); updateShowBoundingVolume(this); - - if (defined(this._rtcCenter)) { - // The CESIUM_RTC extension is use. Compute the center in eye coordinates so it - // can be used to compute the model-view RTC matrix uniforms. - Matrix4.multiplyByPoint(frameState.camera.viewMatrix, this._rtcCenter, this._rtcCenterEye); - } } if (justLoaded) { @@ -3118,8 +3270,8 @@ define([ // We don't check show at the top of the function since we // want to be able to progressively load models when they are not shown, // and then have them visible immediately when show is set to true. - if (show) { -// PERFORMANCE_IDEA: This is terrible + if (show && !this._ignoreCommands) { + // PERFORMANCE_IDEA: This is terrible var commandList = frameState.commandList; var passes = frameState.passes; var nodeCommands = this._nodeCommands; @@ -3136,7 +3288,7 @@ define([ } } - if (passes.pick) { + if (passes.pick && this.allowPicking) { for (i = 0; i < length; ++i) { nc = nodeCommands[i]; if (nc.show) { @@ -3179,6 +3331,11 @@ define([ * model = model && model.destroy(); */ Model.prototype.destroy = function() { + // Vertex arrays are unique to this model, destroy here. + if (defined(this._precreatedAttributes)) { + destroy(this._rendererResources.vertexArrays); + } + this._rendererResources = undefined; this._cachedRendererResources = this._cachedRendererResources && this._cachedRendererResources.release(); diff --git a/Source/Scene/PointAppearance.js b/Source/Scene/PointAppearance.js new file mode 100644 index 000000000000..1cb152e5482d --- /dev/null +++ b/Source/Scene/PointAppearance.js @@ -0,0 +1,235 @@ +/*global define*/ +define([ + '../Core/clone', + '../Core/Color', + '../Core/combine', + '../Core/defaultValue', + '../Core/defined', + '../Core/defineProperties', + '../Core/VertexFormat', + '../Shaders/Appearances/PointAppearanceFS', + '../Shaders/Appearances/PointAppearanceVS', + './Appearance' + ], function( + clone, + Color, + combine, + defaultValue, + defined, + defineProperties, + VertexFormat, + PointAppearanceFS, + PointAppearanceVS, + Appearance) { + "use strict"; + + /** + * An appearance for point geometry {@link PointGeometry} + * + * @alias PointAppearance + * @constructor + * + * @param {Object} [options] Object with the following properties: + * @param {Boolean} [options.translucent=false] When true, the geometry is expected to appear translucent so {@link PointAppearance#renderState} has alpha blending enabled. + * @param {String} [options.vertexShaderSource] Optional GLSL vertex shader source to override the default vertex shader. + * @param {String} [options.fragmentShaderSource] Optional GLSL fragment shader source to override the default fragment shader. + * @param {RenderState} [options.renderState] Optional render state to override the default render state. + * @param {Object} [options.uniforms] Additional uniforms that are used by the vertex and fragment shaders. + * @param {Number} [options.pointSize] Point size in pixels. + * @param {Color} [options.highlightColor] Color multiplier in the fragment shader. The alpha channel is used for alpha blending when translucency is enabled. + * + * @example + * var primitive = new Cesium.Primitive({ + * geometryInstances : new Cesium.GeometryInstance({ + * geometry : new Cesium.PointGeometry({ + * positionsTypedArray : positions, + * colorsTypedArray : colors, + * boundingSphere : boundingSphere + * }) + * }), + * appearance : new Cesium.PointAppearance({ + * translucent : true + * }) + * }); + * + * @private + */ + var PointAppearance = function(options) { + options = defaultValue(options, defaultValue.EMPTY_OBJECT); + + this._vertexShaderSource = defaultValue(options.vertexShaderSource, PointAppearanceVS); + this._fragmentShaderSource = defaultValue(options.fragmentShaderSource, PointAppearanceFS); + this._renderState = Appearance.getDefaultRenderState(false, false, options.renderState); + this._pointSize = defaultValue(options.pointSize, 2.0); + this._highlightColor = defined(options.highlightColor) ? options.highlightColor : new Color(); + + /** + * This property is part of the {@link Appearance} interface, but is not + * used by {@link PointAppearance} since a fully custom fragment shader is used. + * + * @type Material + * + * @default undefined + */ + this.material = undefined; + + /** + * When true, the geometry is expected to appear translucent. + * + * @type {Boolean} + * + * @default false + */ + this.translucent = defaultValue(options.translucent, false); + + /** + * @private + */ + this.uniforms = { + highlightColor : this._highlightColor, + pointSize : this._pointSize + }; + + // Combine default uniforms and additional uniforms + var optionsUniforms = options.uniforms; + this.uniforms = combine(this.uniforms, optionsUniforms, true); + }; + + defineProperties(PointAppearance.prototype, { + /** + * The GLSL source code for the vertex shader. + * + * @memberof PointAppearance.prototype + * + * @type {String} + * @readonly + */ + vertexShaderSource : { + get : function() { + return this._vertexShaderSource; + } + }, + + /** + * The GLSL source code for the fragment shader. The full fragment shader + * source is built procedurally taking into account the {@link PointAppearance#material}. + * Use {@link PointAppearance#getFragmentShaderSource} to get the full source. + * + * @memberof PointAppearance.prototype + * + * @type {String} + * @readonly + */ + fragmentShaderSource : { + get : function() { + return this._fragmentShaderSource; + } + }, + + /** + * The WebGL fixed-function state to use when rendering the geometry. + * + * @memberof PointAppearance.prototype + * + * @type {Object} + * @readonly + */ + renderState : { + get : function() { + return this._renderState; + } + }, + + /** + * When true, the geometry is expected to be closed. + * + * @memberof PointAppearance.prototype + * + * @type {Boolean} + * @readonly + * + * @default false + */ + closed : { + get : function() { + return false; + } + }, + + /** + * The {@link VertexFormat} that this appearance instance is compatible with. + * A geometry can have more vertex attributes and still be compatible - at a + * potential performance cost - but it can't have less. + * + * @memberof PointAppearance.prototype + * + * @type VertexFormat + * @readonly + * + * @default {@link PointAppearance.VERTEX_FORMAT} + */ + vertexFormat : { + get : function() { + return PointAppearance.VERTEX_FORMAT; + } + }, + + /** + * The size in pixels used when rendering the primitive. This helps calculate an accurate + * bounding volume for point rendering and other appearances that are defined in pixel sizes. + * + * @memberof PointAppearance.prototype + * + * @type {Number} + * @readonly + */ + pixelSize : { + get : function() { + return this._pointSize; + } + } + }); + + /** + * The {@link VertexFormat} that all {@link PointAppearance} instances + * are compatible with, which requires only position and color + * attributes. Other attributes are procedurally computed in the fragment shader. + * + * @type VertexFormat + * + * @constant + */ + PointAppearance.VERTEX_FORMAT = VertexFormat.POSITION_AND_COLOR; + + /** + * Returns the full GLSL fragment shader source, which for {@link PointAppearance} is just + * {@link PointAppearance#fragmentShaderSource}. + * + * @function + * + * @returns {String} The full GLSL fragment shader source. + */ + PointAppearance.prototype.getFragmentShaderSource = Appearance.prototype.getFragmentShaderSource; + + /** + * Determines if the geometry is translucent based on {@link PointAppearance#translucent}. + * + * @function + * + * @returns {Boolean} true if the appearance is translucent. + */ + PointAppearance.prototype.isTranslucent = Appearance.prototype.isTranslucent; + + /** + * Creates a render state. This is not the final render state instance; instead, + * it can contain a subset of render state properties identical to the render state + * created in the context. + * + * @function + * + * @returns {Object} The render state. + */ + PointAppearance.prototype.getRenderState = Appearance.prototype.getRenderState; + + return PointAppearance; +}); diff --git a/Source/Scene/PointPrimitiveCollection.js b/Source/Scene/PointPrimitiveCollection.js index 7d039228747f..29e8d4399a3f 100644 --- a/Source/Scene/PointPrimitiveCollection.js +++ b/Source/Scene/PointPrimitiveCollection.js @@ -657,22 +657,9 @@ define([ } } - var scratchPixelSize = new Cartesian2(); - var scratchToCenter = new Cartesian3(); - var scratchProj = new Cartesian3(); function updateBoundingVolume(collection, frameState, boundingVolume) { - var camera = frameState.camera; - var frustum = camera.frustum; - - var toCenter = Cartesian3.subtract(camera.positionWC, boundingVolume.center, scratchToCenter); - var proj = Cartesian3.multiplyByScalar(camera.directionWC, Cartesian3.dot(toCenter, camera.directionWC), scratchProj); - var distance = Math.max(0.0, Cartesian3.magnitude(proj) - boundingVolume.radius); - - var context = frameState.context; - var pixelSize = frustum.getPixelDimensions(context.drawingBufferWidth, context.drawingBufferHeight, distance, scratchPixelSize); - var pixelScale = Math.max(pixelSize.x, pixelSize.y); - - var size = pixelScale * collection._maxPixelSize; + var pixelSize = frameState.camera.getPixelSize(boundingVolume, frameState.context.drawingBufferWidth, frameState.context.drawingBufferHeight); + var size = pixelSize * collection._maxPixelSize; boundingVolume.radius += size; } diff --git a/Source/Scene/Primitive.js b/Source/Scene/Primitive.js index e0455e9ac410..1cdf4d45ed86 100644 --- a/Source/Scene/Primitive.js +++ b/Source/Scene/Primitive.js @@ -1,6 +1,7 @@ /*global define*/ define([ '../Core/BoundingSphere', + '../Core/Cartesian2', '../Core/Cartesian3', '../Core/clone', '../Core/combine', @@ -35,6 +36,7 @@ define([ './SceneMode' ], function( BoundingSphere, + Cartesian2, Cartesian3, clone, combine, @@ -1224,6 +1226,22 @@ define([ attributes.length = 0; } + function updateBoundingVolumes(primitive, frameState) { + // Update bounding volumes for primitives that are sized in pixels. + // The pixel size in meters varies based on the distance from the camera. + var pixelSize = primitive.appearance.pixelSize; + if (defined(pixelSize)) { + var length = primitive._boundingSpheres.length; + for (var i = 0; i < length; ++i) { + var boundingSphere = primitive._boundingSpheres[i]; + var boundingSphereWC = primitive._boundingSphereWC[i]; + var pixelSizeInMeters = frameState.camera.getPixelSize(boundingSphere, frameState.context.drawingBufferWidth, frameState.context.drawingBufferHeight); + var sizeInMeters = pixelSizeInMeters * pixelSize; + boundingSphereWC.radius = boundingSphere.radius + sizeInMeters; + } + } + } + var rtcScratch = new Cartesian3(); function updateAndQueueCommands(primitive, frameState, colorCommands, pickCommands, modelMatrix, cull, debugShowBoundingVolume, twoPasses) { @@ -1233,6 +1251,8 @@ define([ } //>>includeEnd('debug'); + updateBoundingVolumes(primitive, frameState); + if (!Matrix4.equals(modelMatrix, primitive._modelMatrix)) { Matrix4.clone(modelMatrix, primitive._modelMatrix); var length = primitive._boundingSpheres.length; diff --git a/Source/Scene/QuadtreePrimitive.js b/Source/Scene/QuadtreePrimitive.js index 42329dd914f4..9a328d117c52 100644 --- a/Source/Scene/QuadtreePrimitive.js +++ b/Source/Scene/QuadtreePrimitive.js @@ -258,7 +258,7 @@ define([ } if (passes.pick && this._tilesToRender.length > 0) { - this._tileProvider.endUpdate(frameState); + this._tileProvider.updateForPick(frameState); } }; @@ -309,7 +309,6 @@ define([ } var i; - var j; var len; // Clear the render list. diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 5d929beecf59..0db216b6e874 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -172,7 +172,9 @@ define([ * @param {Element} [options.creditContainer] The HTML element in which the credits will be displayed. * @param {MapProjection} [options.mapProjection=new GeographicProjection()] The map projection to use in 2D and Columbus View modes. * @param {Boolean} [options.orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency. - * @param {Boolean} [options.scene3DOnly=false] If true, optimizes memory use and performance for 3D mode but disables the ability to use 2D or Columbus View. * + * @param {Boolean} [options.scene3DOnly=false] If true, optimizes memory use and performance for 3D mode but disables the ability to use 2D or Columbus View. + * @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. + * * @see CesiumWidget * @see {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes} * @@ -514,6 +516,8 @@ define([ */ this.fog = new Fog(); + this._terrainExaggeration = defaultValue(options.terrainExaggeration, 1.0); + this._performanceDisplay = undefined; this._debugVolume = undefined; @@ -924,6 +928,17 @@ define([ get : function() { return this._frustumCommandsList.length; } + }, + + /** + * Gets the scalar used to exaggerate the terrain. + * @memberof Scene.prototype + * @type {Number} + */ + terrainExaggeration : { + get : function() { + return this._terrainExaggeration; + } } }); @@ -982,6 +997,7 @@ define([ frameState.camera = camera; frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC); frameState.occluder = getOccluder(scene); + frameState.terrainExaggeration = scene._terrainExaggeration; clearPasses(frameState.passes); } @@ -1793,14 +1809,12 @@ define([ * @private */ Scene.prototype.clampLineWidth = function(width) { - var context = this._context; return Math.max(ContextLimits.minimumAliasedLineWidth, Math.min(width, ContextLimits.maximumAliasedLineWidth)); }; var orthoPickingFrustum = new OrthographicFrustum(); var scratchOrigin = new Cartesian3(); var scratchDirection = new Cartesian3(); - var scratchBufferDimensions = new Cartesian2(); var scratchPixelSize = new Cartesian2(); var scratchPickVolumeMatrix4 = new Matrix4(); @@ -1938,8 +1952,6 @@ define([ return object; }; - var scratchPickDepthPosition = new Cartesian3(); - var scratchMinDistPos = new Cartesian3(); var scratchPackedDepth = new Cartesian4(); var packedDepthScale = new Cartesian4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 160581375.0); diff --git a/Source/Scene/SceneTransforms.js b/Source/Scene/SceneTransforms.js index 59f8b1905535..ed03443d1283 100644 --- a/Source/Scene/SceneTransforms.js +++ b/Source/Scene/SceneTransforms.js @@ -236,8 +236,6 @@ define([ var uniformState = context.uniformState; var viewport = uniformState.viewport; - var viewportTransformation = uniformState.viewportTransformation; - var ndc = Cartesian4.clone(Cartesian4.UNIT_W, scratchNDC); ndc.x = (drawingBufferPosition.x - viewport.x) / viewport.width * 2.0 - 1.0; ndc.y = (drawingBufferPosition.y - viewport.y) / viewport.height * 2.0 - 1.0; diff --git a/Source/Scene/ScreenSpaceCameraController.js b/Source/Scene/ScreenSpaceCameraController.js index 7d6e725eeb1f..4f22b29b985f 100644 --- a/Source/Scene/ScreenSpaceCameraController.js +++ b/Source/Scene/ScreenSpaceCameraController.js @@ -238,12 +238,14 @@ define([ * @default 150000.0 */ this.minimumPickingTerrainHeight = 150000.0; + this._minimumPickingTerrainHeight = this.minimumPickingTerrainHeight; /** * The minimum height the camera must be before testing for collision with terrain. * @type {Number} * @default 10000.0 */ this.minimumCollisionTerrainHeight = 15000.0; + this._minimumCollisionTerrainHeight = this.minimumCollisionTerrainHeight; /** * The minimum height the camera must be before switching from rotating a track ball to * free look when clicks originate on the sky on in space. @@ -251,6 +253,7 @@ define([ * @default 7500000.0 */ this.minimumTrackBallHeight = 7500000.0; + this._minimumTrackBallHeight = this.minimumTrackBallHeight; /** * Enables or disables camera collision detection with terrain. * @type {Boolean} @@ -749,7 +752,7 @@ define([ var normal = Cartesian3.UNIT_X; var globePos; - if (camera.position.z < controller.minimumPickingTerrainHeight) { + if (camera.position.z < controller._minimumPickingTerrainHeight) { globePos = pickGlobe(controller, startMouse, translateCVStartPos); if (defined(globePos)) { origin.x = globePos.x; @@ -825,7 +828,7 @@ define([ var maxCoord = controller._maxCoord; var onMap = Math.abs(camera.position.x) - maxCoord.x < 0 && Math.abs(camera.position.y) - maxCoord.y < 0; - if (controller._tiltCVOffMap || !onMap || camera.position.z > controller.minimumPickingTerrainHeight) { + if (controller._tiltCVOffMap || !onMap || camera.position.z > controller._minimumPickingTerrainHeight) { controller._tiltCVOffMap = true; rotateCVOnPlane(controller, startPosition, movement); } else { @@ -904,7 +907,7 @@ define([ if (Cartesian2.equals(startPosition, controller._tiltCenterMousePosition)) { center = Cartesian3.clone(controller._tiltCenter, rotateCVCenter); } else { - if (camera.position.z < controller.minimumPickingTerrainHeight) { + if (camera.position.z < controller._minimumPickingTerrainHeight) { center = pickGlobe(controller, startPosition, rotateCVCenter); } @@ -1070,7 +1073,7 @@ define([ var ray = camera.getPickRay(windowPosition, zoomCVWindowRay); var intersection; - if (camera.position.z < controller.minimumPickingTerrainHeight) { + if (camera.position.z < controller._minimumPickingTerrainHeight) { intersection = pickGlobe(controller, windowPosition, zoomCVIntersection); } @@ -1157,7 +1160,6 @@ define([ } var spin3DPick = new Cartesian3(); - var scratchStartRay = new Ray(); var scratchCartographic = new Cartographic(); var scratchMousePos = new Cartesian3(); var scratchRadii = new Cartesian3(); @@ -1184,7 +1186,7 @@ define([ var mousePos; var tangentPick = false; - if (defined(globe) && height < controller.minimumPickingTerrainHeight) { + if (defined(globe) && height < controller._minimumPickingTerrainHeight) { mousePos = pickGlobe(controller, movement.startPosition, scratchMousePos); if (defined(mousePos)) { var ray = camera.getPickRay(movement.startPosition, pickGlobeScratchRay); @@ -1220,7 +1222,7 @@ define([ controller._strafing = false; } - if (defined(globe) && height < controller.minimumPickingTerrainHeight) { + if (defined(globe) && height < controller._minimumPickingTerrainHeight) { if (defined(mousePos)) { if (Cartesian3.magnitude(camera.position) < Cartesian3.magnitude(mousePos)) { Cartesian3.clone(mousePos, controller._strafeStartPosition); @@ -1243,7 +1245,7 @@ define([ } else if (defined(camera.pickEllipsoid(movement.startPosition, controller._ellipsoid, spin3DPick))) { pan3D(controller, startPosition, movement, controller._ellipsoid); Cartesian3.clone(spin3DPick, controller._rotateStartPosition); - } else if (height > controller.minimumTrackBallHeight) { + } else if (height > controller._minimumTrackBallHeight) { controller._rotating = true; rotate3D(controller, startPosition, movement); } else { @@ -1417,7 +1419,7 @@ define([ var intersection; var height = ellipsoid.cartesianToCartographic(camera.position, zoom3DCartographic).height; - if (height < controller.minimumPickingTerrainHeight) { + if (height < controller._minimumPickingTerrainHeight) { intersection = pickGlobe(controller, windowPosition, zoomCVIntersection); } @@ -1471,7 +1473,7 @@ define([ var ellipsoid = controller._ellipsoid; var cartographic = ellipsoid.cartesianToCartographic(camera.position, tilt3DCart); - if (controller._tiltOnEllipsoid || cartographic.height > controller.minimumCollisionTerrainHeight) { + if (controller._tiltOnEllipsoid || cartographic.height > controller._minimumCollisionTerrainHeight) { controller._tiltOnEllipsoid = true; tilt3DOnEllipsoid(controller, startPosition, movement); } else { @@ -1503,7 +1505,7 @@ define([ var intersection = IntersectionTests.rayEllipsoid(ray, ellipsoid); if (defined(intersection)) { center = Ray.getPoint(ray, intersection.start, tilt3DCenter); - } else if (height > controller.minimumTrackBallHeight) { + } else if (height > controller._minimumTrackBallHeight) { var grazingAltitudeLocation = IntersectionTests.grazingAltitudeLocation(ray, ellipsoid); if (!defined(grazingAltitudeLocation)) { return; @@ -1561,7 +1563,7 @@ define([ intersection = IntersectionTests.rayEllipsoid(ray, ellipsoid); if (!defined(intersection)) { var cartographic = ellipsoid.cartesianToCartographic(camera.position, tilt3DCart); - if (cartographic.height <= controller.minimumTrackBallHeight) { + if (cartographic.height <= controller._minimumTrackBallHeight) { controller._looking = true; var up = controller._ellipsoid.geodeticSurfaceNormal(camera.position, tilt3DLookUp); look3D(controller, startPosition, movement, up); @@ -1804,7 +1806,7 @@ define([ } var heightUpdated = false; - if (cartographic.height < controller.minimumCollisionTerrainHeight) { + if (cartographic.height < controller._minimumCollisionTerrainHeight) { var height = globe.getHeight(cartographic); if (defined(height)) { height += controller.minimumZoomDistance; @@ -1845,6 +1847,10 @@ define([ this._ellipsoid = defined(this._globe) ? this._globe.ellipsoid : this._scene.mapProjection.ellipsoid; } + this._minimumCollisionTerrainHeight = this.minimumCollisionTerrainHeight * this._scene.terrainExaggeration; + this._minimumPickingTerrainHeight = this.minimumPickingTerrainHeight * this._scene.terrainExaggeration; + this._minimumTrackBallHeight = this.minimumTrackBallHeight * this._scene.terrainExaggeration; + var radius = this._ellipsoid.maximumRadius; this._rotateFactor = 1.0 / radius; this._rotateRateRangeAdjustment = radius; diff --git a/Source/Scene/TileImagery.js b/Source/Scene/TileImagery.js index 009e8f4d2bad..c14416f5ca4a 100644 --- a/Source/Scene/TileImagery.js +++ b/Source/Scene/TileImagery.js @@ -41,14 +41,14 @@ define([ * Processes the load state machine for this instance. * * @param {Tile} tile The tile to which this instance belongs. - * @param {Context} context The context. + * @param {FrameState} frameState The frameState. * @returns {Boolean} True if this instance is done loading; otherwise, false. */ - TileImagery.prototype.processStateMachine = function(tile, context, commandList) { + TileImagery.prototype.processStateMachine = function(tile, frameState) { var loadingImagery = this.loadingImagery; var imageryLayer = loadingImagery.imageryLayer; - loadingImagery.processStateMachine(context, commandList); + loadingImagery.processStateMachine(frameState); if (loadingImagery.state === ImageryState.READY) { if (defined(this.readyImagery)) { @@ -90,7 +90,7 @@ define([ // Push the ancestor's load process along a bit. This is necessary because some ancestor imagery // tiles may not be attached directly to a terrain tile. Such tiles will never load if // we don't do it here. - closestAncestorThatNeedsLoading.processStateMachine(context, commandList); + closestAncestorThatNeedsLoading.processStateMachine(frameState); return false; // not done loading } else { // This imagery tile is failed or invalid, and we have the "best available" substitute. diff --git a/Source/Scene/TileTerrain.js b/Source/Scene/TileTerrain.js index f00ace57aae8..b604901bad62 100644 --- a/Source/Scene/TileTerrain.js +++ b/Source/Scene/TileTerrain.js @@ -96,17 +96,17 @@ define([ this.vertexArray = undefined; }; - TileTerrain.prototype.processLoadStateMachine = function(context, terrainProvider, x, y, level) { + TileTerrain.prototype.processLoadStateMachine = function(frameState, terrainProvider, x, y, level) { if (this.state === TerrainState.UNLOADED) { requestTileGeometry(this, terrainProvider, x, y, level); } if (this.state === TerrainState.RECEIVED) { - transform(this, context, terrainProvider, x, y, level); + transform(this, frameState, terrainProvider, x, y, level); } if (this.state === TerrainState.TRANSFORMED) { - createResources(this, context, terrainProvider, x, y, level); + createResources(this, frameState.context, terrainProvider, x, y, level); } }; @@ -150,7 +150,7 @@ define([ doRequest(); } - TileTerrain.prototype.processUpsampleStateMachine = function(context, terrainProvider, x, y, level) { + TileTerrain.prototype.processUpsampleStateMachine = function(frameState, terrainProvider, x, y, level) { if (this.state === TerrainState.UNLOADED) { var upsampleDetails = this.upsampleDetails; @@ -183,19 +183,19 @@ define([ } if (this.state === TerrainState.RECEIVED) { - transform(this, context, terrainProvider, x, y, level); + transform(this, frameState, terrainProvider, x, y, level); } if (this.state === TerrainState.TRANSFORMED) { - createResources(this, context, terrainProvider, x, y, level); + createResources(this, frameState.context, terrainProvider, x, y, level); } }; - function transform(tileTerrain, context, terrainProvider, x, y, level) { + function transform(tileTerrain, frameState, terrainProvider, x, y, level) { var tilingScheme = terrainProvider.tilingScheme; var terrainData = tileTerrain.data; - var meshPromise = terrainData.createMesh(tilingScheme, x, y, level); + var meshPromise = terrainData.createMesh(tilingScheme, x, y, level, frameState.terrainExaggeration); if (!defined(meshPromise)) { // Postponed. diff --git a/Source/Scene/modelMaterialsCommon.js b/Source/Scene/modelMaterialsCommon.js index 085225c99ad4..d9b99a5ae729 100644 --- a/Source/Scene/modelMaterialsCommon.js +++ b/Source/Scene/modelMaterialsCommon.js @@ -1,12 +1,12 @@ /*global define*/ define([ - '../Core/defaultValue', - '../Core/defined', - '../Renderer/WebGLConstants' -], function( - defaultValue, - defined, - WebGLConstants) { + '../Core/defaultValue', + '../Core/defined', + '../Renderer/WebGLConstants' + ], function( + defaultValue, + defined, + WebGLConstants) { "use strict"; function webGLConstantToGlslType(webGLValue) { diff --git a/Source/Shaders/Appearances/PointAppearanceFS.glsl b/Source/Shaders/Appearances/PointAppearanceFS.glsl new file mode 100644 index 000000000000..c34c2e3e67f9 --- /dev/null +++ b/Source/Shaders/Appearances/PointAppearanceFS.glsl @@ -0,0 +1,8 @@ +uniform vec4 highlightColor; + +varying vec3 v_color; + +void main() +{ + gl_FragColor = vec4(v_color * highlightColor.rgb, highlightColor.a); +} diff --git a/Source/Shaders/Appearances/PointAppearanceVS.glsl b/Source/Shaders/Appearances/PointAppearanceVS.glsl new file mode 100644 index 000000000000..dd4a639ea7fa --- /dev/null +++ b/Source/Shaders/Appearances/PointAppearanceVS.glsl @@ -0,0 +1,15 @@ +attribute vec3 position3DHigh; +attribute vec3 position3DLow; +attribute vec3 color; + +uniform float pointSize; + +varying vec3 v_positionEC; +varying vec3 v_color; + +void main() +{ + v_color = color; + gl_Position = czm_modelViewProjectionRelativeToEye * czm_computePosition(); + gl_PointSize = pointSize; +} diff --git a/Source/Shaders/GlobeFSPole.glsl b/Source/Shaders/GlobeFSPole.glsl deleted file mode 100644 index bf541874bafd..000000000000 --- a/Source/Shaders/GlobeFSPole.glsl +++ /dev/null @@ -1,29 +0,0 @@ -uniform vec3 u_color; - -varying vec2 v_textureCoordinates; - -void main() -{ - // TODO: make arbitrary ellipsoid - czm_ellipsoid ellipsoid = czm_getWgs84EllipsoidEC(); - vec3 direction = normalize(czm_windowToEyeCoordinates(gl_FragCoord).xyz); - czm_ray ray = czm_ray(vec3(0.0), direction); - czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid); - - if (!czm_isEmpty(intersection)) - { - vec3 positionEC = czm_pointAlongRay(ray, intersection.start); - vec3 positionMC = (czm_inverseModelView * vec4(positionEC, 1.0)).xyz; - - vec3 normalMC = normalize(czm_geodeticSurfaceNormal(positionMC, vec3(0.0), vec3(1.0))); - vec3 normalEC = normalize(czm_normal * normalMC); - - vec3 startDayColor = u_color; - - gl_FragColor = vec4(startDayColor, 1.0); - } - else - { - discard; - } -} \ No newline at end of file diff --git a/Source/Shaders/GlobeVS.glsl b/Source/Shaders/GlobeVS.glsl index c81c90f4653e..2a5b619af319 100644 --- a/Source/Shaders/GlobeVS.glsl +++ b/Source/Shaders/GlobeVS.glsl @@ -111,4 +111,4 @@ void main() v_rayleighColor = atmosColor.rayleigh; v_distance = length((czm_modelView3D * vec4(position3DWC, 1.0)).xyz); #endif -} +} \ No newline at end of file diff --git a/Source/Shaders/GlobeVSPole.glsl b/Source/Shaders/GlobeVSPole.glsl deleted file mode 100644 index 251ba1e88386..000000000000 --- a/Source/Shaders/GlobeVSPole.glsl +++ /dev/null @@ -1,12 +0,0 @@ -attribute vec4 position; - -varying vec2 v_textureCoordinates; - -void main() -{ - float x = (position.x - czm_viewport.x) / czm_viewport.z; - float y = (position.y - czm_viewport.y) / czm_viewport.w; - v_textureCoordinates = vec2(x, y); - - gl_Position = czm_viewportOrthographic * position; -} \ No newline at end of file diff --git a/Source/Widgets/Animation/Animation.js b/Source/Widgets/Animation/Animation.js index ac76f94c0969..66bbaea7e04c 100644 --- a/Source/Widgets/Animation/Animation.js +++ b/Source/Widgets/Animation/Animation.js @@ -284,7 +284,7 @@ define([ /** * - * + * *
Animation widget *
*

diff --git a/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js b/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js index 2008c67a04bb..d56897bba743 100644 --- a/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js +++ b/Source/Widgets/BaseLayerPicker/BaseLayerPicker.js @@ -21,7 +21,7 @@ define([ /** * - * + * *
BaseLayerPicker with its drop-panel open. *
*

diff --git a/Source/Widgets/CesiumWidget/CesiumWidget.js b/Source/Widgets/CesiumWidget/CesiumWidget.js index 9d285cc0078e..24511e23b132 100644 --- a/Source/Widgets/CesiumWidget/CesiumWidget.js +++ b/Source/Widgets/CesiumWidget/CesiumWidget.js @@ -153,6 +153,7 @@ define([ * @param {Object} [options.contextOptions] Context and WebGL creation properties corresponding to options passed to {@link Scene}. * @param {Element|String} [options.creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added * to the bottom of the widget itself. + * @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. * * @exception {DeveloperError} Element with id "container" does not exist in the document. * @@ -242,7 +243,8 @@ define([ creditContainer : creditContainer, mapProjection : options.mapProjection, orderIndependentTranslucency : options.orderIndependentTranslucency, - scene3DOnly : defaultValue(options.scene3DOnly, false) + scene3DOnly : defaultValue(options.scene3DOnly, false), + terrainExaggeration : options.terrainExaggeration }); this._scene = scene; diff --git a/Source/Widgets/SceneModePicker/SceneModePicker.js b/Source/Widgets/SceneModePicker/SceneModePicker.js index b58f46049d73..c05d4c059ee9 100644 --- a/Source/Widgets/SceneModePicker/SceneModePicker.js +++ b/Source/Widgets/SceneModePicker/SceneModePicker.js @@ -30,7 +30,7 @@ define([ var columbusViewPath = 'm 14.723969,17.675598 -0.340489,0.817175 -11.1680536,26.183638 -0.817175,1.872692 2.076986,0 54.7506996,0 2.07698,0 -0.81717,-1.872692 -11.16805,-26.183638 -0.34049,-0.817175 -0.91933,0 -32.414586,0 -0.919322,0 z m 1.838643,2.723916 6.196908,0 -2.928209,10.418977 -7.729111,0 4.460412,-10.418977 z m 9.02297,0 4.903049,0 0,10.418977 -7.831258,0 2.928209,-10.418977 z m 7.626964,0 5.584031,0 2.62176,10.418977 -8.205791,0 0,-10.418977 z m 8.410081,0 5.51593,0 4.46042,10.418977 -7.38863,0 -2.58772,-10.418977 z m -30.678091,13.142892 8.103649,0 -2.89416,10.282782 -9.6018026,0 4.3923136,-10.282782 z m 10.929711,0 8.614384,0 0,10.282782 -11.508544,0 2.89416,-10.282782 z m 11.338299,0 8.852721,0 2.58772,10.282782 -11.440441,0 0,-10.282782 z m 11.678781,0 7.86531,0 4.39231,10.282782 -9.6699,0 -2.58772,-10.282782 z'; /** - * + * *

The SceneModePicker is a single button widget for switching between scene modes; * shown to the left in its expanded state. Programatic switching of scene modes will * be automatically reflected in the widget as long as the specified Scene diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 74001f284302..edf54b8353a1 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -218,7 +218,8 @@ define([ * @param {Boolean} [options.orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency. * @param {Element|String} [options.creditContainer] The DOM element or ID that will contain the {@link CreditDisplay}. If not specified, the credits are added to the bottom of the widget itself. * @param {DataSourceCollection} [options.dataSources=new DataSourceCollection()] The collection of data sources visualized by the widget. If this parameter is provided, - the instance is assumed to be owned by the caller and will not be destroyed when the viewer is destroyed. + * the instance is assumed to be owned by the caller and will not be destroyed when the viewer is destroyed. + * @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. * * @exception {DeveloperError} Element with id "container" does not exist in the document. * @exception {DeveloperError} options.imageryProvider is not available when using the BaseLayerPicker widget, specify options.selectedImageryProviderViewModel instead. @@ -348,7 +349,8 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to targetFrameRate : options.targetFrameRate, showRenderLoopErrors : options.showRenderLoopErrors, creditContainer : defined(options.creditContainer) ? options.creditContainer : bottomContainer, - scene3DOnly : scene3DOnly + scene3DOnly : scene3DOnly, + terrainExaggeration : options.terrainExaggeration }); var dataSourceCollection = options.dataSources; diff --git a/Source/Widgets/Viewer/viewerPerformanceWatchdogMixin.js b/Source/Widgets/Viewer/viewerPerformanceWatchdogMixin.js index 724d173ea2cc..b35e2a5d0af6 100644 --- a/Source/Widgets/Viewer/viewerPerformanceWatchdogMixin.js +++ b/Source/Widgets/Viewer/viewerPerformanceWatchdogMixin.js @@ -12,7 +12,6 @@ define([ DeveloperError, PerformanceWatchdog) { "use strict"; - /*global console*/ /** * A mixin which adds the {@link PerformanceWatchdog} widget to the {@link Viewer} widget. diff --git a/Source/Workers/createPointGeometry.js b/Source/Workers/createPointGeometry.js new file mode 100644 index 000000000000..4ec4965955c4 --- /dev/null +++ b/Source/Workers/createPointGeometry.js @@ -0,0 +1,9 @@ +/*global define*/ +define([ + '../Core/PointGeometry' + ], function( + PointGeometry) { + "use strict"; + + return PointGeometry.createGeometry; +}); diff --git a/Source/Workers/createVerticesFromQuantizedTerrainMesh.js b/Source/Workers/createVerticesFromQuantizedTerrainMesh.js index 2a5f354e1daf..c26759561c14 100644 --- a/Source/Workers/createVerticesFromQuantizedTerrainMesh.js +++ b/Source/Workers/createVerticesFromQuantizedTerrainMesh.js @@ -1,23 +1,33 @@ /*global define*/ define([ '../Core/AttributeCompression', + '../Core/BoundingSphere', '../Core/Cartesian2', '../Core/Cartesian3', '../Core/Cartographic', '../Core/defined', '../Core/Ellipsoid', + '../Core/EllipsoidalOccluder', '../Core/IndexDatatype', '../Core/Math', + '../Core/Matrix4', + '../Core/OrientedBoundingBox', + '../Core/Transforms', './createTaskProcessorWorker' ], function( AttributeCompression, + BoundingSphere, Cartesian2, Cartesian3, Cartographic, defined, Ellipsoid, + EllipsoidalOccluder, IndexDatatype, CesiumMath, + Matrix4, + OrientedBoundingBox, + Transforms, createTaskProcessorWorker) { "use strict"; @@ -34,6 +44,9 @@ define([ var cartesian3Scratch = new Cartesian3(); var cartographicScratch = new Cartographic(); var toPack = new Cartesian2(); + var scratchNormal = new Cartesian3(); + var scratchToENU = new Matrix4(); + var scratchFromENU = new Matrix4(); function createVerticesFromQuantizedTerrainMesh(parameters, transferableObjects) { var quantizedVertices = parameters.quantizedVertices; @@ -45,6 +58,10 @@ define([ var maximumHeight = parameters.maximumHeight; var center = parameters.relativeToCenter; + var exaggeration = parameters.exaggeration; + minimumHeight *= exaggeration; + maximumHeight *= exaggeration; + var rectangle = parameters.rectangle; var west = rectangle.west; var south = rectangle.south; @@ -85,6 +102,22 @@ define([ if (hasVertexNormals) { toPack.x = octEncodedNormals[n]; toPack.y = octEncodedNormals[n + 1]; + + if (exaggeration !== 1.0) { + var normal = AttributeCompression.octDecode(toPack.x, toPack.y, scratchNormal); + var fromENU = Transforms.eastNorthUpToFixedFrame(cartesian3Scratch, ellipsoid, scratchFromENU); + var toENU = Matrix4.inverseTransformation(fromENU, scratchToENU); + + Matrix4.multiplyByPointAsVector(toENU, normal, normal); + normal.z *= exaggeration; + Cartesian3.normalize(normal, normal); + + Matrix4.multiplyByPointAsVector(fromENU, normal, normal); + Cartesian3.normalize(normal, normal); + + AttributeCompression.octEncode(normal, toPack); + } + vertexBuffer[bufferIndex + nIndex] = AttributeCompression.octPackFloat(toPack); } } @@ -94,6 +127,19 @@ define([ var indexBuffer = IndexDatatype.createTypedArray(quantizedVertexCount + edgeVertexCount, indexBufferLength); indexBuffer.set(parameters.indices, 0); + var occludeePointInScaledSpace; + var orientedBoundingBox; + var boundingSphere; + + if (exaggeration !== 1.0) { + // Bounding volumes and horizon culling point need to be recomputed since the tile payload assumes no exaggeration. + boundingSphere = BoundingSphere.fromVertices(vertexBuffer, center, vertexStride); + orientedBoundingBox = OrientedBoundingBox.fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid); + + var occluder = new EllipsoidalOccluder(ellipsoid); + occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromVertices(center, vertexBuffer, vertexStride); + } + // Add skirts. var vertexBufferIndex = quantizedVertexCount * vertexStride; var indexBufferIndex = parameters.indices.length; @@ -110,7 +156,14 @@ define([ return { vertices : vertexBuffer.buffer, - indices : indexBuffer.buffer + indices : indexBuffer.buffer, + vertexStride : vertexStride, + center : center, + minimumHeight : minimumHeight, + maximumHeight : maximumHeight, + boundingSphere : boundingSphere, + orientedBoundingBox : orientedBoundingBox, + occludeePointInScaledSpace : occludeePointInScaledSpace }; } diff --git a/Specs/Core/ArcGisImageServerTerrainProviderSpec.js b/Specs/Core/ArcGisImageServerTerrainProviderSpec.js index ccb770052b0e..aca3a818a051 100644 --- a/Specs/Core/ArcGisImageServerTerrainProviderSpec.js +++ b/Specs/Core/ArcGisImageServerTerrainProviderSpec.js @@ -24,7 +24,6 @@ defineSuite([ Uri, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ afterEach(function() { loadImage.createImage = loadImage.defaultCreateImage; @@ -187,7 +186,6 @@ defineSuite([ spyOn(loadImage, 'createImage').and.callFake(function(url, crossOrigin, deferred) { var uri = new Uri(url); - var params = queryToObject(uri.query); expect(uri.path).toEqual('/proxy/'); diff --git a/Specs/Core/AssociativeArraySpec.js b/Specs/Core/AssociativeArraySpec.js index aed73375df88..96cd239281b6 100644 --- a/Specs/Core/AssociativeArraySpec.js +++ b/Specs/Core/AssociativeArraySpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( AssociativeArray) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor has expected default values', function() { var associativeArray = new AssociativeArray(); diff --git a/Specs/Core/AttributeCompressionSpec.js b/Specs/Core/AttributeCompressionSpec.js index 020da752e6b9..fa5cb4955887 100644 --- a/Specs/Core/AttributeCompressionSpec.js +++ b/Specs/Core/AttributeCompressionSpec.js @@ -10,7 +10,6 @@ defineSuite([ Cartesian3, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var negativeUnitZ = new Cartesian3(0.0, 0.0, -1.0); it('oct decode(0, 0)', function() { diff --git a/Specs/Core/AxisAlignedBoundingBoxSpec.js b/Specs/Core/AxisAlignedBoundingBoxSpec.js index 9a3f95de98a7..931f7f624100 100644 --- a/Specs/Core/AxisAlignedBoundingBoxSpec.js +++ b/Specs/Core/AxisAlignedBoundingBoxSpec.js @@ -12,7 +12,6 @@ defineSuite([ Intersect, Plane) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var positions = [ new Cartesian3(3, -1, -3), diff --git a/Specs/Core/BingMapsApiSpec.js b/Specs/Core/BingMapsApiSpec.js index 4b1426c5db82..423b42829382 100644 --- a/Specs/Core/BingMapsApiSpec.js +++ b/Specs/Core/BingMapsApiSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( BingMapsApi) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('getKey returns provided key if one is provided', function() { expect(BingMapsApi.getKey('foo')).toEqual('foo'); diff --git a/Specs/Core/BoundingRectangleSpec.js b/Specs/Core/BoundingRectangleSpec.js index f2dce62e2444..b2793bb2226d 100644 --- a/Specs/Core/BoundingRectangleSpec.js +++ b/Specs/Core/BoundingRectangleSpec.js @@ -14,7 +14,6 @@ defineSuite([ Intersect, Rectangle) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor sets expected values', function() { var rectangle = new BoundingRectangle(); diff --git a/Specs/Core/BoundingSphereSpec.js b/Specs/Core/BoundingSphereSpec.js index 105d59680a89..373e60f2cb4b 100644 --- a/Specs/Core/BoundingSphereSpec.js +++ b/Specs/Core/BoundingSphereSpec.js @@ -30,7 +30,6 @@ defineSuite([ Rectangle, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var positionsRadius = 1.0; var positionsCenter = new Cartesian3(10000001.0, 0.0, 0.0); diff --git a/Specs/Core/BoxGeometrySpec.js b/Specs/Core/BoxGeometrySpec.js index f73bd0abd031..31093ef4242a 100644 --- a/Specs/Core/BoxGeometrySpec.js +++ b/Specs/Core/BoxGeometrySpec.js @@ -12,7 +12,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws without minimum corner', function() { expect(function() { @@ -101,8 +100,8 @@ defineSuite([ }); createPackableSpecs(BoxGeometry, new BoxGeometry({ - minimumCorner : new Cartesian3(1.0, 2.0, 3.0), - maximumCorner : new Cartesian3(4.0, 5.0, 6.0), + minimum : new Cartesian3(1.0, 2.0, 3.0), + maximum : new Cartesian3(4.0, 5.0, 6.0), vertexFormat : VertexFormat.POSITION_AND_NORMAL }), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0]); }); diff --git a/Specs/Core/BoxOutlineGeometrySpec.js b/Specs/Core/BoxOutlineGeometrySpec.js index d8a77ec2b2ad..c88346f35656 100644 --- a/Specs/Core/BoxOutlineGeometrySpec.js +++ b/Specs/Core/BoxOutlineGeometrySpec.js @@ -10,7 +10,6 @@ defineSuite([ Cartesian3, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws without minimum corner', function() { expect(function() { @@ -76,7 +75,7 @@ defineSuite([ }); createPackableSpecs(BoxOutlineGeometry, new BoxOutlineGeometry({ - minimumCorner : new Cartesian3(1.0, 2.0, 3.0), - maximumCorner : new Cartesian3(4.0, 5.0, 6.0) + minimum : new Cartesian3(1.0, 2.0, 3.0), + maximum : new Cartesian3(4.0, 5.0, 6.0) }), [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]); -}); \ No newline at end of file +}); diff --git a/Specs/Core/Cartesian2Spec.js b/Specs/Core/Cartesian2Spec.js index b326d25c119b..33fa962ec989 100644 --- a/Specs/Core/Cartesian2Spec.js +++ b/Specs/Core/Cartesian2Spec.js @@ -8,7 +8,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var cartesian = new Cartesian2(); @@ -803,4 +802,4 @@ defineSuite([ }); createPackableSpecs(Cartesian2, new Cartesian2(1, 2), [1, 2]); -}); \ No newline at end of file +}); diff --git a/Specs/Core/Cartesian3Spec.js b/Specs/Core/Cartesian3Spec.js index b45cd37a32cf..366358c24bed 100644 --- a/Specs/Core/Cartesian3Spec.js +++ b/Specs/Core/Cartesian3Spec.js @@ -12,7 +12,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var cartesian = new Cartesian3(); @@ -1168,4 +1167,4 @@ defineSuite([ }); createPackableSpecs(Cartesian3, new Cartesian3(1, 2, 3), [1, 2, 3]); -}); \ No newline at end of file +}); diff --git a/Specs/Core/Cartesian4Spec.js b/Specs/Core/Cartesian4Spec.js index 158db7d8e8a0..2c93b4000c1c 100644 --- a/Specs/Core/Cartesian4Spec.js +++ b/Specs/Core/Cartesian4Spec.js @@ -10,7 +10,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var cartesian = new Cartesian4(); @@ -902,4 +901,4 @@ defineSuite([ }); createPackableSpecs(Cartesian4, new Cartesian4(1, 2, 3, 4), [1, 2, 3, 4]); -}); \ No newline at end of file +}); diff --git a/Specs/Core/CartographicSpec.js b/Specs/Core/CartographicSpec.js index 62ebd516bc38..0db64f4fe085 100644 --- a/Specs/Core/CartographicSpec.js +++ b/Specs/Core/CartographicSpec.js @@ -1,10 +1,18 @@ /*global defineSuite*/ defineSuite([ - 'Core/Cartographic' + 'Core/Cartographic', + 'Core/Cartesian3', + 'Core/Ellipsoid', + 'Core/Math' ], function( - Cartographic) { + Cartographic, + Cartesian3, + Ellipsoid, + CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ + + var surfaceCartesian = new Cartesian3(4094327.7921465295, 1909216.4044747739, 4487348.4088659193); + var surfaceCartographic = new Cartographic(CesiumMath.toRadians(25.0), CesiumMath.toRadians(45.0), 0.0); it('default constructor sets expected properties', function() { var c = new Cartographic(); @@ -78,6 +86,31 @@ defineSuite([ expect(c.height).toEqual(0.0); }); + it('fromCartesian works without a result parameter', function() { + var ellipsoid = Ellipsoid.WGS84; + var c = Cartographic.fromCartesian(surfaceCartesian, ellipsoid); + expect(c).toEqualEpsilon(surfaceCartographic, CesiumMath.EPSILON8); + }); + + it('fromCartesian works with a result parameter', function() { + var ellipsoid = Ellipsoid.WGS84; + var result = new Cartographic(); + var c = Cartographic.fromCartesian(surfaceCartesian, ellipsoid, result); + expect(c).toEqualEpsilon(surfaceCartographic, CesiumMath.EPSILON8); + expect(result).toBe(c); + }); + + it('fromCartesian works without an ellipsoid', function() { + var c = Cartographic.fromCartesian(surfaceCartesian); + expect(c).toEqualEpsilon(surfaceCartographic, CesiumMath.EPSILON8); + }); + + it('fromCartesian throws when there is no cartesian', function() { + expect(function() { + Cartographic.fromCartesian(); + }).toThrowDeveloperError(); + }); + it('clone without a result parameter', function() { var cartographic = new Cartographic(1.0, 2.0, 3.0); var result = cartographic.clone(); diff --git a/Specs/Core/CatmullRomSplineSpec.js b/Specs/Core/CatmullRomSplineSpec.js index ea78d08f5a85..fd5d49562692 100644 --- a/Specs/Core/CatmullRomSplineSpec.js +++ b/Specs/Core/CatmullRomSplineSpec.js @@ -10,7 +10,6 @@ defineSuite([ HermiteSpline, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var points; var times; diff --git a/Specs/Core/CesiumTerrainProviderSpec.js b/Specs/Core/CesiumTerrainProviderSpec.js index 3cc9336accb3..3fc52881524c 100644 --- a/Specs/Core/CesiumTerrainProviderSpec.js +++ b/Specs/Core/CesiumTerrainProviderSpec.js @@ -28,7 +28,6 @@ defineSuite([ Uri, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ afterEach(function() { loadWithXhr.load = loadWithXhr.defaultLoad; @@ -53,14 +52,6 @@ defineSuite([ return returnTileJson('Data/CesiumTerrainTileJson/QuantizedMesh.tile.json'); } - function returnQuantizedMesh20TileJson() { - return returnTileJson('Data/CesiumTerrainTileJson/QuantizedMesh2.0.tile.json'); - } - - function returnQuantizedMesh11TileJson() { - return returnTileJson('Data/CesiumTerrainTileJson/QuantizedMesh1.1.tile.json'); - } - function returnVertexNormalTileJson() { return returnTileJson('Data/CesiumTerrainTileJson/VertexNormals.tile.json'); } @@ -442,8 +433,6 @@ defineSuite([ }); it('provides HeightmapTerrainData', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { // Just return any old file, as long as its big enough loadWithXhr.defaultLoad('Data/EarthOrientationParameters/IcrfToFixedStkComponentsRotationData.json', responseType, method, data, headers, deferred); @@ -457,8 +446,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.terrain', responseType, method, data, headers, deferred); }; @@ -471,8 +458,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with 32bit indices', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.32bitIndices.terrain', responseType, method, data, headers, deferred); }; @@ -486,8 +471,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with VertexNormals', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.vertexnormals.terrain', responseType, method, data, headers, deferred); }; @@ -501,8 +484,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with WaterMask', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.watermask.terrain', responseType, method, data, headers, deferred); }; @@ -516,8 +497,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with VertexNormals and WaterMask', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.octvertexnormals.watermask.terrain', responseType, method, data, headers, deferred); }; @@ -532,8 +511,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with OctVertexNormals', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.octvertexnormals.terrain', responseType, method, data, headers, deferred); }; @@ -547,8 +524,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with VertexNormals and unknown extensions', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.vertexnormals.unknownext.terrain', responseType, method, data, headers, deferred); }; @@ -562,8 +537,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with OctVertexNormals and unknown extensions', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.octvertexnormals.unknownext.terrain', responseType, method, data, headers, deferred); }; @@ -577,8 +550,6 @@ defineSuite([ }); it('provides QuantizedMeshTerrainData with unknown extension', function() { - var baseUrl = 'made/up/url'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { loadWithXhr.defaultLoad('Data/CesiumTerrainTileJson/tile.unknownext.terrain', responseType, method, data, headers, deferred); }; @@ -665,8 +636,6 @@ defineSuite([ }); it('supports a query string in the base URL', function() { - var baseUrl = 'made/up/url?a=some&b=query'; - loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { // Just return any old file, as long as its big enough loadWithXhr.defaultLoad('Data/EarthOrientationParameters/IcrfToFixedStkComponentsRotationData.json', responseType, method, data, headers, deferred); diff --git a/Specs/Core/CircleGeometrySpec.js b/Specs/Core/CircleGeometrySpec.js index 15f70821bc5e..1f20394e997e 100644 --- a/Specs/Core/CircleGeometrySpec.js +++ b/Specs/Core/CircleGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without a center', function() { expect(function() { diff --git a/Specs/Core/CircleOutlineGeometrySpec.js b/Specs/Core/CircleOutlineGeometrySpec.js index 0a2328b12e84..fe04068dd5d5 100644 --- a/Specs/Core/CircleOutlineGeometrySpec.js +++ b/Specs/Core/CircleOutlineGeometrySpec.js @@ -10,7 +10,6 @@ defineSuite([ Ellipsoid, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without a center', function() { expect(function() { diff --git a/Specs/Core/ClockSpec.js b/Specs/Core/ClockSpec.js index c3ae4ddf7252..b7a64f7e9c15 100644 --- a/Specs/Core/ClockSpec.js +++ b/Specs/Core/ClockSpec.js @@ -12,7 +12,6 @@ defineSuite([ JulianDate, pollToPromise) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor sets default parameters', function() { var clock = new Clock(); diff --git a/Specs/Core/ColorGeometryInstanceAttributeSpec.js b/Specs/Core/ColorGeometryInstanceAttributeSpec.js index 4a385d2699c5..9399f54181fc 100644 --- a/Specs/Core/ColorGeometryInstanceAttributeSpec.js +++ b/Specs/Core/ColorGeometryInstanceAttributeSpec.js @@ -8,7 +8,6 @@ defineSuite([ Color, ComponentDatatype) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var attribute = new ColorGeometryInstanceAttribute(1.0, 1.0, 0.0, 0.5); diff --git a/Specs/Core/ColorSpec.js b/Specs/Core/ColorSpec.js index 4278d9338a07..262e9a80d805 100644 --- a/Specs/Core/ColorSpec.js +++ b/Specs/Core/ColorSpec.js @@ -10,7 +10,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('Constructing without arguments produces expected defaults', function() { var v = new Color(); diff --git a/Specs/Core/ComponentDatatypeSpec.js b/Specs/Core/ComponentDatatypeSpec.js index 5f8ef0b88ab3..7873bc91996e 100644 --- a/Specs/Core/ComponentDatatypeSpec.js +++ b/Specs/Core/ComponentDatatypeSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( ComponentDatatype) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('fromTypedArray works', function() { expect(ComponentDatatype.fromTypedArray(new Int8Array())).toBe(ComponentDatatype.BYTE); @@ -126,4 +125,4 @@ defineSuite([ ComponentDatatype.createTypedArray(ComponentDatatype.BYTE, undefined, 0, 1); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/CorridorGeometrySpec.js b/Specs/Core/CorridorGeometrySpec.js index 58ea955b6a55..f9853ba4bdf6 100644 --- a/Specs/Core/CorridorGeometrySpec.js +++ b/Specs/Core/CorridorGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without positions', function() { expect(function() { diff --git a/Specs/Core/CorridorOutlineGeometrySpec.js b/Specs/Core/CorridorOutlineGeometrySpec.js index 7ab00c59d114..d177b09ccc47 100644 --- a/Specs/Core/CorridorOutlineGeometrySpec.js +++ b/Specs/Core/CorridorOutlineGeometrySpec.js @@ -12,7 +12,6 @@ defineSuite([ Ellipsoid, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without positions', function() { expect(function() { @@ -146,4 +145,4 @@ defineSuite([ packedInstance.push(Ellipsoid.WGS84.radii.x, Ellipsoid.WGS84.radii.y, Ellipsoid.WGS84.radii.z); packedInstance.push(30000.0, 0.0, 0.0, 2.0, 0.1); createPackableSpecs(CorridorOutlineGeometry, corridor, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/CubicRealPolynomialSpec.js b/Specs/Core/CubicRealPolynomialSpec.js index 820a27377e59..088f98e20fbf 100644 --- a/Specs/Core/CubicRealPolynomialSpec.js +++ b/Specs/Core/CubicRealPolynomialSpec.js @@ -6,7 +6,6 @@ defineSuite([ CubicRealPolynomial, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('discriminant throws without a', function() { expect(function() { @@ -134,4 +133,4 @@ defineSuite([ expect(roots.length).toEqual(1); expect(roots[0]).toEqual(0.0); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/CylinderGeometrySpec.js b/Specs/Core/CylinderGeometrySpec.js index af4aecec29b9..8946c7627f8d 100644 --- a/Specs/Core/CylinderGeometrySpec.js +++ b/Specs/Core/CylinderGeometrySpec.js @@ -8,7 +8,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with no length', function() { expect(function() { @@ -146,4 +145,4 @@ defineSuite([ }); var packedInstance = [1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 3.0]; createPackableSpecs(CylinderGeometry, cylinder, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/CylinderOutlineGeometrySpec.js b/Specs/Core/CylinderOutlineGeometrySpec.js index 4e373bee09f8..5b9e45beb36a 100644 --- a/Specs/Core/CylinderOutlineGeometrySpec.js +++ b/Specs/Core/CylinderOutlineGeometrySpec.js @@ -6,7 +6,6 @@ defineSuite([ CylinderOutlineGeometry, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with no length', function() { expect(function() { @@ -113,4 +112,4 @@ defineSuite([ }); var packedInstance = [1.0, 1.0, 0.0, 3.0, 0.0]; createPackableSpecs(CylinderOutlineGeometry, cylinder, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/DeveloperErrorSpec.js b/Specs/Core/DeveloperErrorSpec.js index 0b11119e064d..ee2856081fff 100644 --- a/Specs/Core/DeveloperErrorSpec.js +++ b/Specs/Core/DeveloperErrorSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( DeveloperError) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var name = 'DeveloperError'; var testMessage = 'Testing'; diff --git a/Specs/Core/EarthOrientationParametersSpec.js b/Specs/Core/EarthOrientationParametersSpec.js index 9b5edbe17504..f5ce2723edcb 100644 --- a/Specs/Core/EarthOrientationParametersSpec.js +++ b/Specs/Core/EarthOrientationParametersSpec.js @@ -10,7 +10,6 @@ defineSuite([ JulianDate, TimeStandard) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var officialLeapSeconds; @@ -193,4 +192,4 @@ defineSuite([ expect(Math.abs(resultBefore.ut1MinusUtc - resultAfter.ut1MinusUtc) > 0.5).toEqual(true); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/EllipseGeometrySpec.js b/Specs/Core/EllipseGeometrySpec.js index 1c72f7b57324..3b7bfaa77caa 100644 --- a/Specs/Core/EllipseGeometrySpec.js +++ b/Specs/Core/EllipseGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without a center', function() { expect(function() { diff --git a/Specs/Core/EllipseOutlineGeometrySpec.js b/Specs/Core/EllipseOutlineGeometrySpec.js index cd0e3ceb9c58..43a37236318b 100644 --- a/Specs/Core/EllipseOutlineGeometrySpec.js +++ b/Specs/Core/EllipseOutlineGeometrySpec.js @@ -10,7 +10,6 @@ defineSuite([ Ellipsoid, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without a center', function() { expect(function() { diff --git a/Specs/Core/EllipsoidGeodesicSpec.js b/Specs/Core/EllipsoidGeodesicSpec.js index 84d0e4f439bc..cd7cb09d722e 100644 --- a/Specs/Core/EllipsoidGeodesicSpec.js +++ b/Specs/Core/EllipsoidGeodesicSpec.js @@ -10,7 +10,6 @@ defineSuite([ Ellipsoid, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without start', function() { expect(function() { @@ -245,12 +244,4 @@ defineSuite([ expect(expectedMid.longitude).toEqualEpsilon(result.longitude, CesiumMath.EPSILON13); expect(expectedMid.latitude).toEqualEpsilon(result.latitude, CesiumMath.EPSILON13); }); - - it('doesn\'t modify incoming cartographics', function(){ - var start = new Cartographic(1,2,3); - var end = new Cartographic(2,3,4); - var geodesic = new EllipsoidGeodesic(start, end); - expect(start.height).toEqual(3); - expect(end.height).toEqual(4); - }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/EllipsoidGeometrySpec.js b/Specs/Core/EllipsoidGeometrySpec.js index 1b92a402fd51..6354995950f1 100644 --- a/Specs/Core/EllipsoidGeometrySpec.js +++ b/Specs/Core/EllipsoidGeometrySpec.js @@ -12,7 +12,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with invalid slicePartitions', function() { expect(function() { diff --git a/Specs/Core/EllipsoidOutlineGeometrySpec.js b/Specs/Core/EllipsoidOutlineGeometrySpec.js index e3c48e9761f7..c80897a74c90 100644 --- a/Specs/Core/EllipsoidOutlineGeometrySpec.js +++ b/Specs/Core/EllipsoidOutlineGeometrySpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws if stackPartitions less than 1', function() { expect(function() { @@ -54,4 +53,4 @@ defineSuite([ }); var packedInstance = [1.0, 2.0, 3.0, 3.0, 3.0, 3.0]; createPackableSpecs(EllipsoidOutlineGeometry, ellipsoidgeometry, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/EllipsoidSpec.js b/Specs/Core/EllipsoidSpec.js index eb18e81fd01d..df755a3a1a10 100644 --- a/Specs/Core/EllipsoidSpec.js +++ b/Specs/Core/EllipsoidSpec.js @@ -12,7 +12,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var radii = new Cartesian3(1.0, 2.0, 3.0); var radiiSquared = Cartesian3.multiplyComponents(radii, radii, new Cartesian3()); diff --git a/Specs/Core/EllipsoidTangentPlaneSpec.js b/Specs/Core/EllipsoidTangentPlaneSpec.js index bf88122417c1..f8535c399ccb 100644 --- a/Specs/Core/EllipsoidTangentPlaneSpec.js +++ b/Specs/Core/EllipsoidTangentPlaneSpec.js @@ -16,7 +16,6 @@ defineSuite([ Matrix3, OrientedBoundingBox) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor defaults to WGS84', function() { var origin = new Cartesian3(Ellipsoid.WGS84.radii.x, 0, 0); diff --git a/Specs/Core/EllipsoidTerrainProviderSpec.js b/Specs/Core/EllipsoidTerrainProviderSpec.js index 00736886b266..c2cfc15682c1 100644 --- a/Specs/Core/EllipsoidTerrainProviderSpec.js +++ b/Specs/Core/EllipsoidTerrainProviderSpec.js @@ -8,7 +8,6 @@ defineSuite([ TerrainProvider, createContext) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var context; @@ -49,4 +48,4 @@ defineSuite([ var provider = new EllipsoidTerrainProvider(); expect(provider.getTileDataAvailable()).toBeUndefined(); }); -}, 'WebGL'); \ No newline at end of file +}, 'WebGL'); diff --git a/Specs/Core/EllipsoidalOccluderSpec.js b/Specs/Core/EllipsoidalOccluderSpec.js index b4c7e6fedf62..4c0e8f2b1adc 100644 --- a/Specs/Core/EllipsoidalOccluderSpec.js +++ b/Specs/Core/EllipsoidalOccluderSpec.js @@ -18,7 +18,6 @@ defineSuite([ Ray, Rectangle) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('uses ellipsoid', function() { var ellipsoid = new Ellipsoid(2.0, 3.0, 4.0); diff --git a/Specs/Core/EncodedCartesian3Spec.js b/Specs/Core/EncodedCartesian3Spec.js index f68a750204f5..05ec90f02edc 100644 --- a/Specs/Core/EncodedCartesian3Spec.js +++ b/Specs/Core/EncodedCartesian3Spec.js @@ -6,7 +6,6 @@ defineSuite([ EncodedCartesian3, Cartesian3) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var encoded = new EncodedCartesian3(); diff --git a/Specs/Core/EventSpec.js b/Specs/Core/EventSpec.js index 8564a17aa788..47f26b336810 100644 --- a/Specs/Core/EventSpec.js +++ b/Specs/Core/EventSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( Event) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var event; var spyListener; @@ -203,4 +202,4 @@ defineSuite([ event.removeEventListener(null); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/FeatureDetectionSpec.js b/Specs/Core/FeatureDetectionSpec.js index 7f129d6ddf91..2acae758dfac 100644 --- a/Specs/Core/FeatureDetectionSpec.js +++ b/Specs/Core/FeatureDetectionSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( FeatureDetection) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ //generally, these tests just make sure the function runs, the test can't expect a value of true or false it('detects fullscreen support', function() { diff --git a/Specs/Core/FullscreenSpec.js b/Specs/Core/FullscreenSpec.js index fda6be67a616..0cf9747e9079 100644 --- a/Specs/Core/FullscreenSpec.js +++ b/Specs/Core/FullscreenSpec.js @@ -6,7 +6,6 @@ defineSuite([ Fullscreen, FeatureDetection) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can tell if fullscreen is supported', function() { // just make sure the function runs, the test can't expect a particular result. @@ -64,4 +63,4 @@ defineSuite([ } }); } -}); \ No newline at end of file +}); diff --git a/Specs/Core/GeographicProjectionSpec.js b/Specs/Core/GeographicProjectionSpec.js index 04f35e34fe5e..4fad9b3f286f 100644 --- a/Specs/Core/GeographicProjectionSpec.js +++ b/Specs/Core/GeographicProjectionSpec.js @@ -12,7 +12,6 @@ defineSuite([ Ellipsoid, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct0', function() { var projection = new GeographicProjection(); @@ -82,4 +81,4 @@ defineSuite([ return projection.unproject(); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/GeographicTilingSchemeSpec.js b/Specs/Core/GeographicTilingSchemeSpec.js index 2111a0a6b047..b246e65e7570 100644 --- a/Specs/Core/GeographicTilingSchemeSpec.js +++ b/Specs/Core/GeographicTilingSchemeSpec.js @@ -16,7 +16,6 @@ defineSuite([ Rectangle, TilingScheme) { "use strict"; - /*global describe,it,expect*/ it('conforms to TilingScheme interface.', function() { expect(GeographicTilingScheme).toConformToInterface(TilingScheme); @@ -179,4 +178,4 @@ defineSuite([ expect(resultParameter).toEqual(new Cartesian2(3, 0)); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/GeometryAttributeSpec.js b/Specs/Core/GeometryAttributeSpec.js index b38d5de98512..db69c29de245 100644 --- a/Specs/Core/GeometryAttributeSpec.js +++ b/Specs/Core/GeometryAttributeSpec.js @@ -6,7 +6,6 @@ defineSuite([ GeometryAttribute, ComponentDatatype) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var color = new GeometryAttribute({ diff --git a/Specs/Core/GeometryInstanceAttributeSpec.js b/Specs/Core/GeometryInstanceAttributeSpec.js index 8f6496c3a2c8..0412db2bd079 100644 --- a/Specs/Core/GeometryInstanceAttributeSpec.js +++ b/Specs/Core/GeometryInstanceAttributeSpec.js @@ -6,7 +6,6 @@ defineSuite([ GeometryInstanceAttribute, ComponentDatatype) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var color = new GeometryInstanceAttribute({ diff --git a/Specs/Core/GeometryInstanceSpec.js b/Specs/Core/GeometryInstanceSpec.js index e65e99a8a17a..7fe66d2b6c7f 100644 --- a/Specs/Core/GeometryInstanceSpec.js +++ b/Specs/Core/GeometryInstanceSpec.js @@ -20,7 +20,6 @@ defineSuite([ Matrix4, PrimitiveType) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var geometry = new Geometry({ diff --git a/Specs/Core/GeometryPipelineSpec.js b/Specs/Core/GeometryPipelineSpec.js index b3ecfc138492..60edc59d30b4 100644 --- a/Specs/Core/GeometryPipelineSpec.js +++ b/Specs/Core/GeometryPipelineSpec.js @@ -44,7 +44,6 @@ defineSuite([ Tipsify, VertexFormat) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('converts triangles to wireframe in place', function() { var geometry = GeometryPipeline.toWireframe(new Geometry({ @@ -695,9 +694,6 @@ defineSuite([ }); it('projectTo2D throws when trying to project a point close to the origin', function() { - var p1 = new Cartesian3(100000, 200000, 300000); - var p2 = new Cartesian3(400000, 500000, 600000); - var geometry = {}; geometry.attributes = {}; geometry.attributes.position = { @@ -1643,8 +1639,8 @@ defineSuite([ normal : true, st : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); geometry = GeometryPipeline.computeBinormalAndTangent(geometry); var actualTangents = geometry.attributes.tangent.values; @@ -1652,8 +1648,8 @@ defineSuite([ var expectedGeometry = BoxGeometry.createGeometry(new BoxGeometry({ vertexFormat: VertexFormat.ALL, - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); var expectedTangents = expectedGeometry.attributes.tangent.values; var expectedBinormals = expectedGeometry.attributes.binormal.values; @@ -1683,8 +1679,8 @@ defineSuite([ vertexFormat : new VertexFormat({ position : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); expect(geometry.attributes.normal).not.toBeDefined(); geometry = GeometryPipeline.compressVertices(geometry); @@ -1697,8 +1693,8 @@ defineSuite([ position : true, normal : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); expect(geometry.attributes.normal).toBeDefined(); var originalNormals = Array.prototype.slice.call(geometry.attributes.normal.values); @@ -1721,8 +1717,8 @@ defineSuite([ position : true, st : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); expect(geometry.attributes.st).toBeDefined(); var originalST = Array.prototype.slice.call(geometry.attributes.st.values); @@ -1751,8 +1747,8 @@ defineSuite([ normal : true, st : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); expect(geometry.attributes.normal).toBeDefined(); expect(geometry.attributes.st).toBeDefined(); @@ -1782,8 +1778,8 @@ defineSuite([ tangent : true, binormal : true }), - maximumCorner : new Cartesian3(250000.0, 250000.0, 250000.0), - minimumCorner : new Cartesian3(-250000.0, -250000.0, -250000.0) + maximum : new Cartesian3(250000.0, 250000.0, 250000.0), + minimum : new Cartesian3(-250000.0, -250000.0, -250000.0) })); expect(geometry.attributes.normal).toBeDefined(); expect(geometry.attributes.tangent).toBeDefined(); diff --git a/Specs/Core/GeometrySpec.js b/Specs/Core/GeometrySpec.js index 3d1daf7a7025..063b0facada8 100644 --- a/Specs/Core/GeometrySpec.js +++ b/Specs/Core/GeometrySpec.js @@ -16,7 +16,6 @@ defineSuite([ GeometryType, PrimitiveType) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var attributes = { diff --git a/Specs/Core/HeadingPitchRangeSpec.js b/Specs/Core/HeadingPitchRangeSpec.js index 89e45d71eaec..7c222a55060d 100644 --- a/Specs/Core/HeadingPitchRangeSpec.js +++ b/Specs/Core/HeadingPitchRangeSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( HeadingPitchRange) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var hpr = new HeadingPitchRange(); @@ -35,4 +34,4 @@ defineSuite([ expect(hpr).toBe(returnedResult); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/HeightmapTerrainDataSpec.js b/Specs/Core/HeightmapTerrainDataSpec.js index 380437c88fef..84ec93ed5e8c 100644 --- a/Specs/Core/HeightmapTerrainDataSpec.js +++ b/Specs/Core/HeightmapTerrainDataSpec.js @@ -12,7 +12,6 @@ defineSuite([ TerrainData, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('conforms to TerrainData interface', function() { expect(HeightmapTerrainData).toConformToInterface(TerrainData); @@ -302,4 +301,4 @@ defineSuite([ }).toThrowDeveloperError(); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/HermitePolynomialApproximationSpec.js b/Specs/Core/HermitePolynomialApproximationSpec.js index 672ffc763e77..acfef730a26c 100644 --- a/Specs/Core/HermitePolynomialApproximationSpec.js +++ b/Specs/Core/HermitePolynomialApproximationSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( HermitePolynomialApproximation) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ //The results of these specs were validated against STK Components //an aerospace SDK available from Analytical Graphics. www.agi.com/components/ @@ -76,4 +75,4 @@ defineSuite([ expect(result).toEqualEpsilon(expectedResult, 1e-8); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/HermiteSplineSpec.js b/Specs/Core/HermiteSplineSpec.js index 8ef6f6e4360e..b7a584eb7198 100644 --- a/Specs/Core/HermiteSplineSpec.js +++ b/Specs/Core/HermiteSplineSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var points; var times; diff --git a/Specs/Core/Iau2000OrientationSpec.js b/Specs/Core/Iau2000OrientationSpec.js index 82d28992ec99..f51d12fb9fde 100644 --- a/Specs/Core/Iau2000OrientationSpec.js +++ b/Specs/Core/Iau2000OrientationSpec.js @@ -8,7 +8,6 @@ defineSuite([ JulianDate, TimeStandard) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('compute moon', function() { var date = new JulianDate(2451545.0, -32.184, TimeStandard.TAI); diff --git a/Specs/Core/Iau2006XysDataSpec.js b/Specs/Core/Iau2006XysDataSpec.js index 131fcc28f37c..280e90df9d3f 100644 --- a/Specs/Core/Iau2006XysDataSpec.js +++ b/Specs/Core/Iau2006XysDataSpec.js @@ -10,7 +10,6 @@ defineSuite([ Iau2006XysSample, pollToPromise) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var xys; @@ -53,4 +52,4 @@ defineSuite([ it('returns undefined after the last XYS table sample', function() { expect(xys.computeXysRadians(2442396 + 27427, 0.0)).toBeUndefined(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/IauOrientationAxesSpec.js b/Specs/Core/IauOrientationAxesSpec.js index 0915d64eee38..75d5e5c8eeac 100644 --- a/Specs/Core/IauOrientationAxesSpec.js +++ b/Specs/Core/IauOrientationAxesSpec.js @@ -14,7 +14,6 @@ defineSuite([ Matrix3, TimeStandard) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('compute ICRF to Moon Fixed', function() { var date = new JulianDate(2451545.0, -32.184, TimeStandard.TAI); diff --git a/Specs/Core/IndexDatatypeSpec.js b/Specs/Core/IndexDatatypeSpec.js index fe14bc8679e3..9721fa80b1aa 100644 --- a/Specs/Core/IndexDatatypeSpec.js +++ b/Specs/Core/IndexDatatypeSpec.js @@ -6,7 +6,6 @@ defineSuite([ IndexDatatype, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('IndexDatatype.validate validates input', function() { expect(IndexDatatype.validate(IndexDatatype.UNSIGNED_SHORT)).toEqual(true); diff --git a/Specs/Core/IntersectionTestsSpec.js b/Specs/Core/IntersectionTestsSpec.js index 227d50361ab1..8eca66e54a7c 100644 --- a/Specs/Core/IntersectionTestsSpec.js +++ b/Specs/Core/IntersectionTestsSpec.js @@ -16,7 +16,6 @@ defineSuite([ Plane, Ray) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('rayPlane intersects', function() { var ray = new Ray(new Cartesian3(2.0, 0.0, 0.0), new Cartesian3(-1.0, 0.0, 0.0)); diff --git a/Specs/Core/Intersections2DSpec.js b/Specs/Core/Intersections2DSpec.js index 0fe3ea3eb2b4..c81e7a801186 100644 --- a/Specs/Core/Intersections2DSpec.js +++ b/Specs/Core/Intersections2DSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( Intersections2D) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ describe('clipTriangleAtAxisAlignedThreshold', function() { it('eliminates a triangle that is entirely on the wrong side of the threshold', function() { diff --git a/Specs/Core/IntervalSpec.js b/Specs/Core/IntervalSpec.js index 3479c1ff0984..7fc7638dfcfe 100644 --- a/Specs/Core/IntervalSpec.js +++ b/Specs/Core/IntervalSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( Interval) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructs without arguments', function() { var interval = new Interval(); @@ -19,4 +18,4 @@ defineSuite([ expect(interval.start).toEqual(start); expect(interval.stop).toEqual(stop); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/JulianDateSpec.js b/Specs/Core/JulianDateSpec.js index 933b3485ec50..8990061810cc 100644 --- a/Specs/Core/JulianDateSpec.js +++ b/Specs/Core/JulianDateSpec.js @@ -10,7 +10,6 @@ defineSuite([ TimeConstants, TimeStandard) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ // All exact Julian Dates found using NASA's Time Conversion Tool: http://ssd.jpl.nasa.gov/tc.cgi it('Construct a default date', function() { @@ -435,6 +434,18 @@ defineSuite([ expect(julianDate).toEqual(expectedDate); }); + it('Construct from ISO8601 local calendar date and time with no seconds and UTC offset in basic format', function() { + var expectedDate = JulianDate.fromDate(new Date(Date.UTC(2009, 7, 1, 12, 30, 0))); + var computedDate = JulianDate.fromIso8601('20090801T0730-0500'); + expect(computedDate).toEqual(expectedDate); + }); + + it('Construct from ISO8601 local calendar date and time with no seconds and UTC offset in extended format', function() { + var expectedDate = JulianDate.fromDate(new Date(Date.UTC(2009, 7, 1, 12, 30, 0))); + var computedDate = JulianDate.fromIso8601('2009-08-01T07:30-05:00'); + expect(computedDate).toEqual(expectedDate); + }); + it('Fails to construct an ISO8601 ordinal date with day less than 1', function() { expect(function() { return JulianDate.fromIso8601('2009-000'); diff --git a/Specs/Core/LagrangePolynomialApproximationSpec.js b/Specs/Core/LagrangePolynomialApproximationSpec.js index 6b69940176ce..9364148f571d 100644 --- a/Specs/Core/LagrangePolynomialApproximationSpec.js +++ b/Specs/Core/LagrangePolynomialApproximationSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( LagrangePolynomialApproximation) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ //The results of these specs were validated against STK Components //an aerospace SDK available from Analytical Graphics. www.agi.com/components/ @@ -43,4 +42,4 @@ defineSuite([ expect(LagrangePolynomialApproximation.getRequiredDataPoints(2)).toEqual(3); expect(LagrangePolynomialApproximation.getRequiredDataPoints(3)).toEqual(4); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/LeapSecondSpec.js b/Specs/Core/LeapSecondSpec.js index ce6b0fa4f5a1..f172dec185d3 100644 --- a/Specs/Core/LeapSecondSpec.js +++ b/Specs/Core/LeapSecondSpec.js @@ -6,7 +6,6 @@ defineSuite([ LeapSecond, JulianDate) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor sets expected values', function() { var leapSecond = new LeapSecond(); diff --git a/Specs/Core/LinearApproximationSpec.js b/Specs/Core/LinearApproximationSpec.js index d539eb99e1e7..5a3ed5abe783 100644 --- a/Specs/Core/LinearApproximationSpec.js +++ b/Specs/Core/LinearApproximationSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( LinearApproximation) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('should produce correct results', function() { var xTable = [2.0, 4.0]; @@ -73,4 +72,4 @@ defineSuite([ it('getRequiredDataPoints returns 2', function() { expect(LinearApproximation.getRequiredDataPoints(1)).toEqual(2); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/LinearSplineSpec.js b/Specs/Core/LinearSplineSpec.js index 5ffd5af92322..34ef885d72f5 100644 --- a/Specs/Core/LinearSplineSpec.js +++ b/Specs/Core/LinearSplineSpec.js @@ -6,7 +6,6 @@ defineSuite([ LinearSpline, Cartesian3) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var points; var times; diff --git a/Specs/Core/MapboxApiSpec.js b/Specs/Core/MapboxApiSpec.js index d7fbe284d664..dbd6a38117b3 100644 --- a/Specs/Core/MapboxApiSpec.js +++ b/Specs/Core/MapboxApiSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( MapboxApi) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('getAccessToken returns provided access token if one is provided', function() { expect(MapboxApi.getAccessToken('foo')).toEqual('foo'); diff --git a/Specs/Core/MathSpec.js b/Specs/Core/MathSpec.js index b5bd77a22726..20d84846b476 100644 --- a/Specs/Core/MathSpec.js +++ b/Specs/Core/MathSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('sign of -2', function() { expect(CesiumMath.sign(-2)).toEqual(-1); diff --git a/Specs/Core/Matrix2Spec.js b/Specs/Core/Matrix2Spec.js index 52331f275aeb..d8205ee3660c 100644 --- a/Specs/Core/Matrix2Spec.js +++ b/Specs/Core/Matrix2Spec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian2, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor creates values array with all zeros.', function() { var matrix = new Matrix2(); diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index b70a41bfb410..e40e87801465 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -10,7 +10,6 @@ defineSuite([ CesiumMath, Quaternion) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor creates values array with all zeros.', function() { var matrix = new Matrix3(); diff --git a/Specs/Core/Matrix4Spec.js b/Specs/Core/Matrix4Spec.js index 5dc0e0f0d458..664b7dd56762 100644 --- a/Specs/Core/Matrix4Spec.js +++ b/Specs/Core/Matrix4Spec.js @@ -14,7 +14,6 @@ defineSuite([ Matrix3, Quaternion) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor creates values array with all zeros.', function() { var matrix = new Matrix4(); @@ -1681,14 +1680,13 @@ defineSuite([ it('computeInfinitePerspectiveOffCenter throws without near', function() { expect(function() { - var left = 0, right = 0, bottom = 0, top = 0, far = 0; + var left = 0, right = 0, bottom = 0, top = 0; Matrix4.computeInfinitePerspectiveOffCenter (left, right, bottom, top, 0); }).toThrowDeveloperError(); }); it('computeViewportTransformation works', function() { expect(function() { - var left = 0, right = 0, bottom = 0, top = 0, far = 0; Matrix4.computeViewportTransformation ({ x : 0, y : 0, diff --git a/Specs/Core/NearFarScalarSpec.js b/Specs/Core/NearFarScalarSpec.js index 4566634bc13d..139c8061ef59 100644 --- a/Specs/Core/NearFarScalarSpec.js +++ b/Specs/Core/NearFarScalarSpec.js @@ -6,7 +6,6 @@ defineSuite([ NearFarScalar, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructs without arguments', function() { var scalar = new NearFarScalar(); diff --git a/Specs/Core/OccluderSpec.js b/Specs/Core/OccluderSpec.js index 962d9716c8a0..5f1bcb4e2f0c 100644 --- a/Specs/Core/OccluderSpec.js +++ b/Specs/Core/OccluderSpec.js @@ -16,7 +16,6 @@ defineSuite([ Rectangle, Visibility) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws an exception during construction (1 of 3)', function() { expect(function() { diff --git a/Specs/Core/OrientedBoundingBoxSpec.js b/Specs/Core/OrientedBoundingBoxSpec.js index 7773d1f751e7..39eddb411624 100644 --- a/Specs/Core/OrientedBoundingBoxSpec.js +++ b/Specs/Core/OrientedBoundingBoxSpec.js @@ -30,7 +30,6 @@ defineSuite([ Quaternion, Rectangle) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var positions = [ new Cartesian3(2.0, 0.0, 0.0), @@ -41,15 +40,6 @@ defineSuite([ new Cartesian3(0.0, 0.0, -4.0) ]; - var positions2 = [ - new Cartesian3(4.0, 0.0, 0.0), - new Cartesian3(0.0, 3.0, 0.0), - new Cartesian3(0.0, 0.0, 2.0), - new Cartesian3(-4.0, 0.0, 0.0), - new Cartesian3(0.0, -3.0, 0.0), - new Cartesian3(0.0, 0.0, -2.0) - ]; - function rotatePositions(positions, axis, angle) { var points = []; @@ -157,7 +147,6 @@ defineSuite([ expect(box1.center).toEqualEpsilon(box2.center, CesiumMath.EPSILON15); - var rotScale = Matrix3.ZERO; expect(box1.halfAxes).toEqualEpsilon(box2.halfAxes, CesiumMath.EPSILON15); }); @@ -762,7 +751,6 @@ defineSuite([ it('clone undefined OBB with a result parameter', function() { var box = new OrientedBoundingBox(); - var box2 = new OrientedBoundingBox(); expect(OrientedBoundingBox.clone(undefined, box)).toBe(undefined); }); diff --git a/Specs/Core/PinBuilderSpec.js b/Specs/Core/PinBuilderSpec.js index 68586f7ac06b..65c0fd8ec839 100644 --- a/Specs/Core/PinBuilderSpec.js +++ b/Specs/Core/PinBuilderSpec.js @@ -12,7 +12,6 @@ defineSuite([ defined, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ function getPinColor(canvas) { var context2D = canvas.getContext("2d"); @@ -143,4 +142,4 @@ defineSuite([ builder.fromMakiIconId('hospital', Color.RED, undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/PlaneSpec.js b/Specs/Core/PlaneSpec.js index 1d7d52dedbb6..bec3b90cbc5e 100644 --- a/Specs/Core/PlaneSpec.js +++ b/Specs/Core/PlaneSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, Cartesian4) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructs', function() { var normal = Cartesian3.UNIT_X; diff --git a/Specs/Core/PointGeometrySpec.js b/Specs/Core/PointGeometrySpec.js new file mode 100644 index 000000000000..a599b882b2d3 --- /dev/null +++ b/Specs/Core/PointGeometrySpec.js @@ -0,0 +1,69 @@ +/*global defineSuite*/ +defineSuite([ + 'Core/PointGeometry', + 'Core/BoundingSphere', + 'Core/Cartesian3' + ], function( + PointGeometry, + BoundingSphere, + Cartesian3) { + "use strict"; + + var positionsTypedArray = new Float32Array([0.0, 0.0, 0.0, 0.0, 0.0, 1.0]); + var colorsTypedArray = new Uint8Array([255, 0, 0, 0, 255, 0]); + var boundingSphere = BoundingSphere.fromVertices(positionsTypedArray); + var expectedCenter = new Cartesian3(0.0, 0.0, 0.5); + var expectedRadius = 0.5; + + it('throws without positionsTypedArray', function() { + expect(function() { + return new PointGeometry({ + colorsTypedArray : colorsTypedArray + }); + }).toThrowDeveloperError(); + }); + + it('throws without colorsTypedArray', function() { + expect(function() { + return new PointGeometry({ + positionsTypedArray : positionsTypedArray + }); + }).toThrowDeveloperError(); + }); + + it('creates with boundingSphere', function() { + var points = new PointGeometry({ + positionsTypedArray : positionsTypedArray, + colorsTypedArray : colorsTypedArray, + boundingSphere : boundingSphere + }); + + var geometry = PointGeometry.createGeometry(points); + expect(geometry.boundingSphere.center).toEqual(expectedCenter); + expect(geometry.boundingSphere.radius).toEqual(expectedRadius); + }); + + it('creates without boundingSphere', function() { + var points = new PointGeometry({ + positionsTypedArray : positionsTypedArray, + colorsTypedArray : colorsTypedArray + }); + + var geometry = PointGeometry.createGeometry(points); + expect(geometry.boundingSphere.center).toEqual(expectedCenter); + expect(geometry.boundingSphere.radius).toEqual(expectedRadius); + }); + + it('computes all vertex attributes', function() { + var points = new PointGeometry({ + positionsTypedArray : positionsTypedArray, + colorsTypedArray : colorsTypedArray, + boundingSphere : boundingSphere + }); + + var geometry = PointGeometry.createGeometry(points); + expect(geometry.attributes.position.values.length).toEqual(2 * 3); + expect(geometry.attributes.color.values.length).toEqual(2 * 3); + expect(geometry.indices).toBeUndefined(); + }); +}); diff --git a/Specs/Core/PolygonGeometrySpec.js b/Specs/Core/PolygonGeometrySpec.js index b0bfef972f62..d337ebde433a 100644 --- a/Specs/Core/PolygonGeometrySpec.js +++ b/Specs/Core/PolygonGeometrySpec.js @@ -17,7 +17,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without hierarchy', function() { expect(function() { diff --git a/Specs/Core/PolygonOutlineGeometrySpec.js b/Specs/Core/PolygonOutlineGeometrySpec.js index adebd60042c3..da86e2594a2f 100644 --- a/Specs/Core/PolygonOutlineGeometrySpec.js +++ b/Specs/Core/PolygonOutlineGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws without hierarchy', function() { expect(function() { diff --git a/Specs/Core/PolygonPipelineSpec.js b/Specs/Core/PolygonPipelineSpec.js index ba3ea70e34b0..d2fe687dcfab 100644 --- a/Specs/Core/PolygonPipelineSpec.js +++ b/Specs/Core/PolygonPipelineSpec.js @@ -14,7 +14,6 @@ defineSuite([ CesiumMath, WindingOrder) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ beforeEach(function() { CesiumMath.setRandomNumberSeed(0.0); @@ -547,4 +546,4 @@ defineSuite([ expect(positions.length).toEqual(28); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/PolylineGeometrySpec.js b/Specs/Core/PolylineGeometrySpec.js index 661ed7cc0767..252dc15d3755 100644 --- a/Specs/Core/PolylineGeometrySpec.js +++ b/Specs/Core/PolylineGeometrySpec.js @@ -16,7 +16,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with no positions', function() { expect(function() { @@ -186,4 +185,4 @@ defineSuite([ }); packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 1, 0, 0, 0, 0, 0, 10, 0, 0, 11]; createPackableSpecs(PolylineGeometry, line, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/PolylinePipelineSpec.js b/Specs/Core/PolylinePipelineSpec.js index fb9ce7acc2f0..37cb7d2d5187 100644 --- a/Specs/Core/PolylinePipelineSpec.js +++ b/Specs/Core/PolylinePipelineSpec.js @@ -12,7 +12,6 @@ defineSuite([ CesiumMath, Transforms) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('wrapLongitude', function() { var positions = Cartesian3.fromDegreesArray([ diff --git a/Specs/Core/PolylineVolumeGeometrySpec.js b/Specs/Core/PolylineVolumeGeometrySpec.js index a8cec93e6a27..8671a3dbfb88 100644 --- a/Specs/Core/PolylineVolumeGeometrySpec.js +++ b/Specs/Core/PolylineVolumeGeometrySpec.js @@ -16,7 +16,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var shape; beforeAll(function() { diff --git a/Specs/Core/PolylineVolumeOutlineGeometrySpec.js b/Specs/Core/PolylineVolumeOutlineGeometrySpec.js index ce290de21746..28589235f5fb 100644 --- a/Specs/Core/PolylineVolumeOutlineGeometrySpec.js +++ b/Specs/Core/PolylineVolumeOutlineGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ Ellipsoid, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var shape; @@ -154,4 +153,4 @@ defineSuite([ }); var packedInstance = [3.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 3.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 0.1]; createPackableSpecs(PolylineVolumeOutlineGeometry, volume, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/QuadraticRealPolynomialSpec.js b/Specs/Core/QuadraticRealPolynomialSpec.js index 53d5f9ddf8bc..013773399d8d 100644 --- a/Specs/Core/QuadraticRealPolynomialSpec.js +++ b/Specs/Core/QuadraticRealPolynomialSpec.js @@ -6,7 +6,6 @@ defineSuite([ QuadraticRealPolynomial, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('discriminant throws without a', function() { expect(function() { @@ -118,4 +117,4 @@ defineSuite([ expect(roots[0]).toEqual(0.0); expect(roots[1]).toEqual(3.0); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/QuantizedMeshTerrainDataSpec.js b/Specs/Core/QuantizedMeshTerrainDataSpec.js index 31f618644e0a..63e015409881 100644 --- a/Specs/Core/QuantizedMeshTerrainDataSpec.js +++ b/Specs/Core/QuantizedMeshTerrainDataSpec.js @@ -20,7 +20,6 @@ defineSuite([ TerrainMesh, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('conforms to TerrainData interface', function() { expect(QuantizedMeshTerrainData).toConformToInterface(TerrainData); @@ -427,44 +426,55 @@ defineSuite([ expect(mesh.boundingSphere3D).toEqual(data._boundingSphere); }); }); - }); - it('createMesh requires 32bit indices for large meshes', function() { - var tilingScheme = new GeographicTilingScheme(); - var quantizedVertices = []; - var i; - for (i = 0; i < 65 * 1024; i++) { - quantizedVertices.push(i % 32767); // u - } - for (i = 0; i < 65 * 1024; i++) { - quantizedVertices.push(Math.floor(i / 32767)); // v - } - for (i = 0; i < 65 * 1024; i++) { - quantizedVertices.push(0.0); // height - } - var data = new QuantizedMeshTerrainData({ - minimumHeight : 0.0, - maximumHeight : 4.0, - quantizedVertices : new Uint16Array(quantizedVertices), - indices : new Uint32Array([ 0, 3, 1, - 0, 2, 3, - 65000, 65002, 65003]), - boundingSphere : new BoundingSphere(), - horizonOcclusionPoint : new Cartesian3(), - westIndices : [0, 1], - southIndices : [0, 1], - eastIndices : [2, 3], - northIndices : [1, 3], - westSkirtHeight : 1.0, - southSkirtHeight : 1.0, - eastSkirtHeight : 1.0, - northSkirtHeight : 1.0, - childTileMask : 15 + it('exaggerates mesh', function() { + return data.createMesh(tilingScheme, 0, 0, 0, 2).then(function(mesh) { + expect(mesh).toBeInstanceOf(TerrainMesh); + expect(mesh.vertices.length).toBe(12 * 6); // 4 regular vertices, 8 skirt vertices. + expect(mesh.indices.length).toBe(10 * 3); // 2 regular triangles, 8 skirt triangles. + expect(mesh.minimumHeight).toBe(data._minimumHeight); + expect(mesh.maximumHeight).toBeGreaterThan(data._maximumHeight); + expect(mesh.boundingSphere3D.radius).toBeGreaterThan(data._boundingSphere.radius); + }); }); - return data.createMesh(tilingScheme, 0, 0, 0).then(function(mesh) { - expect(mesh).toBeInstanceOf(TerrainMesh); - expect(mesh.indices.BYTES_PER_ELEMENT).toBe(4); + it('requires 32bit indices for large meshes', function() { + var tilingScheme = new GeographicTilingScheme(); + var quantizedVertices = []; + var i; + for (i = 0; i < 65 * 1024; i++) { + quantizedVertices.push(i % 32767); // u + } + for (i = 0; i < 65 * 1024; i++) { + quantizedVertices.push(Math.floor(i / 32767)); // v + } + for (i = 0; i < 65 * 1024; i++) { + quantizedVertices.push(0.0); // height + } + var data = new QuantizedMeshTerrainData({ + minimumHeight : 0.0, + maximumHeight : 4.0, + quantizedVertices : new Uint16Array(quantizedVertices), + indices : new Uint32Array([ 0, 3, 1, + 0, 2, 3, + 65000, 65002, 65003]), + boundingSphere : new BoundingSphere(), + horizonOcclusionPoint : new Cartesian3(), + westIndices : [0, 1], + southIndices : [0, 1], + eastIndices : [2, 3], + northIndices : [1, 3], + westSkirtHeight : 1.0, + southSkirtHeight : 1.0, + eastSkirtHeight : 1.0, + northSkirtHeight : 1.0, + childTileMask : 15 + }); + + return data.createMesh(tilingScheme, 0, 0, 0).then(function(mesh) { + expect(mesh).toBeInstanceOf(TerrainMesh); + expect(mesh.indices.BYTES_PER_ELEMENT).toBe(4); + }); }); }); @@ -795,4 +805,4 @@ defineSuite([ expect(data.isChildAvailable(10, 20, 21, 41)).toBe(false); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/QuarticRealPolynomialSpec.js b/Specs/Core/QuarticRealPolynomialSpec.js index b7799f569ee1..86596ca2d8f7 100644 --- a/Specs/Core/QuarticRealPolynomialSpec.js +++ b/Specs/Core/QuarticRealPolynomialSpec.js @@ -6,7 +6,6 @@ defineSuite([ QuarticRealPolynomial, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('discriminant throws without a', function() { expect(function() { @@ -188,4 +187,4 @@ defineSuite([ expect(actual[0]).toEqualEpsilon(expected[0], CesiumMath.EPSILON11); expect(actual[1]).toEqualEpsilon(expected[1], CesiumMath.EPSILON11); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/QuaternionSpec.js b/Specs/Core/QuaternionSpec.js index 24f4700bbb28..1b01d410ff42 100644 --- a/Specs/Core/QuaternionSpec.js +++ b/Specs/Core/QuaternionSpec.js @@ -12,7 +12,6 @@ defineSuite([ Matrix3, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct with default values', function() { var quaternion = new Quaternion(); @@ -475,7 +474,6 @@ defineSuite([ it('slerp uses lerp when dot product is close to 1 and a result parameter', function() { var start = new Quaternion(0.0, 0.0, 0.0, 1.0); var end = new Quaternion(1.0, 2.0, 3.0, 1.0); - var expected = new Quaternion(0.5, 1.0, 1.5, 1.0); var result = new Quaternion(); var actual = Quaternion.slerp(start, end, 0.0, result); diff --git a/Specs/Core/QuaternionSplineSpec.js b/Specs/Core/QuaternionSplineSpec.js index 1aebf3386581..456968aa5849 100644 --- a/Specs/Core/QuaternionSplineSpec.js +++ b/Specs/Core/QuaternionSplineSpec.js @@ -10,7 +10,6 @@ defineSuite([ CesiumMath, Quaternion) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var points; var times; diff --git a/Specs/Core/QueueSpec.js b/Specs/Core/QueueSpec.js index df06887f58b6..96ba8b4deebd 100644 --- a/Specs/Core/QueueSpec.js +++ b/Specs/Core/QueueSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( Queue) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var queue; beforeEach(function() { diff --git a/Specs/Core/RaySpec.js b/Specs/Core/RaySpec.js index dafcfbe69e45..f84b7acd953f 100644 --- a/Specs/Core/RaySpec.js +++ b/Specs/Core/RaySpec.js @@ -6,7 +6,6 @@ defineSuite([ Ray, Cartesian3) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor create zero valued Ray', function() { var ray = new Ray(); diff --git a/Specs/Core/RectangleGeometrySpec.js b/Specs/Core/RectangleGeometrySpec.js index f8e96adf881c..74235895820d 100644 --- a/Specs/Core/RectangleGeometrySpec.js +++ b/Specs/Core/RectangleGeometrySpec.js @@ -22,7 +22,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('computes positions', function() { var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0); diff --git a/Specs/Core/RectangleOutlineGeometrySpec.js b/Specs/Core/RectangleOutlineGeometrySpec.js index f2911849d3b1..07a3a6368f11 100644 --- a/Specs/Core/RectangleOutlineGeometrySpec.js +++ b/Specs/Core/RectangleOutlineGeometrySpec.js @@ -20,7 +20,6 @@ defineSuite([ Rectangle, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('computes positions', function() { var rectangle = new Rectangle(-2.0, -1.0, 0.0, 1.0); diff --git a/Specs/Core/RectangleSpec.js b/Specs/Core/RectangleSpec.js index ea9eba8b6a18..8c6838dcdb30 100644 --- a/Specs/Core/RectangleSpec.js +++ b/Specs/Core/RectangleSpec.js @@ -14,7 +14,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var west = -0.9; var south = 0.5; @@ -647,4 +646,4 @@ defineSuite([ var rectangle = new Rectangle(west, south, east, north); var packedInstance = [west, south, east, north]; createPackableSpecs(Rectangle, rectangle, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/RequestErrorEventSpec.js b/Specs/Core/RequestErrorEventSpec.js index 378febb855aa..6142fd0670f9 100644 --- a/Specs/Core/RequestErrorEventSpec.js +++ b/Specs/Core/RequestErrorEventSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('parses response headers provided as a string', function() { var event = new RequestErrorEvent(404, 'foo', 'This-is-a-test: first\r\nAnother: second value!'); @@ -24,4 +23,4 @@ defineSuite([ 'Another': 'second value!' }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/RuntimeErrorSpec.js b/Specs/Core/RuntimeErrorSpec.js index 20acff6fd331..3ad348c7e788 100644 --- a/Specs/Core/RuntimeErrorSpec.js +++ b/Specs/Core/RuntimeErrorSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( RuntimeError) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var name = 'RuntimeError'; var testMessage = 'Testing'; diff --git a/Specs/Core/ScreenSpaceEventHandlerSpec.js b/Specs/Core/ScreenSpaceEventHandlerSpec.js index 02c69f6997a7..41995827ec81 100644 --- a/Specs/Core/ScreenSpaceEventHandlerSpec.js +++ b/Specs/Core/ScreenSpaceEventHandlerSpec.js @@ -20,7 +20,6 @@ defineSuite([ ScreenSpaceEventType, DomEventSimulator) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var usePointerEvents = FeatureDetection.supportsPointerEvents(); var element; diff --git a/Specs/Core/ShowGeometryInstanceAttributeSpec.js b/Specs/Core/ShowGeometryInstanceAttributeSpec.js index 7a6d5b0ced2c..2678e18a88cf 100644 --- a/Specs/Core/ShowGeometryInstanceAttributeSpec.js +++ b/Specs/Core/ShowGeometryInstanceAttributeSpec.js @@ -6,7 +6,6 @@ defineSuite([ ShowGeometryInstanceAttribute, ComponentDatatype) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor', function() { var attribute = new ShowGeometryInstanceAttribute(false); diff --git a/Specs/Core/Simon1994PlanetaryPositionsSpec.js b/Specs/Core/Simon1994PlanetaryPositionsSpec.js index 23c6f319f24f..5b357eb12d29 100644 --- a/Specs/Core/Simon1994PlanetaryPositionsSpec.js +++ b/Specs/Core/Simon1994PlanetaryPositionsSpec.js @@ -16,8 +16,6 @@ defineSuite([ TimeStandard, Transforms) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ - // Values for the X Y and Z were found using the STK Components GeometryTransformer on the position of the // sun center of mass point and the earth J2000 reference frame. diff --git a/Specs/Core/SimplePolylineGeometrySpec.js b/Specs/Core/SimplePolylineGeometrySpec.js index 6d7edc6c9a6e..05b63f59b9ac 100644 --- a/Specs/Core/SimplePolylineGeometrySpec.js +++ b/Specs/Core/SimplePolylineGeometrySpec.js @@ -18,7 +18,6 @@ defineSuite([ PrimitiveType, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with no positions', function() { expect(function() { @@ -156,4 +155,4 @@ defineSuite([ }); packedInstance = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 12, 13, 14, 0, 0, 11]; createPackableSpecs(SimplePolylineGeometry, line, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/SphereGeometrySpec.js b/Specs/Core/SphereGeometrySpec.js index e140f4499b09..a6bc1b7a28aa 100644 --- a/Specs/Core/SphereGeometrySpec.js +++ b/Specs/Core/SphereGeometrySpec.js @@ -12,7 +12,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor throws with invalid stackPartitions', function() { expect(function() { diff --git a/Specs/Core/SphereOutlineGeometrySpec.js b/Specs/Core/SphereOutlineGeometrySpec.js index e71b4209b107..dab6f5223085 100644 --- a/Specs/Core/SphereOutlineGeometrySpec.js +++ b/Specs/Core/SphereOutlineGeometrySpec.js @@ -6,7 +6,7 @@ defineSuite([ SphereOutlineGeometry, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ + it('constructor throws if stackPartitions less than 1', function() { expect(function() { return new SphereOutlineGeometry({ @@ -51,4 +51,4 @@ defineSuite([ }); var packedInstance = [1.0, 1.0, 1.0, 3.0, 3.0, 2.0]; createPackableSpecs(SphereOutlineGeometry, sphere, packedInstance); -}); \ No newline at end of file +}); diff --git a/Specs/Core/SphericalSpec.js b/Specs/Core/SphericalSpec.js index b5e23a1590a5..dc9da2a24ea1 100644 --- a/Specs/Core/SphericalSpec.js +++ b/Specs/Core/SphericalSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ //Mock object to make sure methods take non-sphericals. function NotSpherical(clock, cone, magnitude) { @@ -109,4 +108,4 @@ defineSuite([ var v = new Spherical(1, 2, 3); expect(v.toString()).toEqual('(1, 2, 3)'); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/SplineSpec.js b/Specs/Core/SplineSpec.js index 1f5f4e149842..800aeb7fa364 100644 --- a/Specs/Core/SplineSpec.js +++ b/Specs/Core/SplineSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, HermiteSpline) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('contructor throws', function() { expect(function() { diff --git a/Specs/Core/TaskProcessorSpec.js b/Specs/Core/TaskProcessorSpec.js index 363d51e544a9..87a3953fb52e 100644 --- a/Specs/Core/TaskProcessorSpec.js +++ b/Specs/Core/TaskProcessorSpec.js @@ -8,7 +8,6 @@ defineSuite([ require, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,fail*/ var taskProcessor; @@ -126,4 +125,4 @@ defineSuite([ expect(error).toContain('postMessage failed'); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/TimeIntervalCollectionSpec.js b/Specs/Core/TimeIntervalCollectionSpec.js index bda3c7a50f91..f8be2ce05b78 100644 --- a/Specs/Core/TimeIntervalCollectionSpec.js +++ b/Specs/Core/TimeIntervalCollectionSpec.js @@ -8,7 +8,6 @@ defineSuite([ JulianDate, TimeInterval) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ function TestObject(value) { this.value = value; diff --git a/Specs/Core/TimeIntervalSpec.js b/Specs/Core/TimeIntervalSpec.js index bd5a04d7da65..e8ff01f9dd21 100644 --- a/Specs/Core/TimeIntervalSpec.js +++ b/Specs/Core/TimeIntervalSpec.js @@ -6,7 +6,6 @@ defineSuite([ TimeInterval, JulianDate) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ function returnTrue() { return true; @@ -464,4 +463,4 @@ defineSuite([ TimeInterval.contains(timeInterval, undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/TipsifySpec.js b/Specs/Core/TipsifySpec.js index 0fb25cd1238e..0335b0bd536e 100644 --- a/Specs/Core/TipsifySpec.js +++ b/Specs/Core/TipsifySpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( Tipsify) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can calculate the ACMR', function() { //Hexagon formed from 6 triangles, 7 vertices @@ -113,4 +112,4 @@ defineSuite([ maximumIndex : 28, cacheSize: 6})); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/TransformsSpec.js b/Specs/Core/TransformsSpec.js index d8390f7320b1..58fa82126557 100644 --- a/Specs/Core/TransformsSpec.js +++ b/Specs/Core/TransformsSpec.js @@ -38,7 +38,6 @@ defineSuite([ TimeInterval, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var negativeX = new Cartesian4(-1, 0, 0, 0); var negativeZ = new Cartesian4(0, 0, -1, 0); @@ -337,9 +336,6 @@ defineSuite([ describe('computeIcrfToFixedMatrix', function() { function preloadTransformationData(start, stop, eopDescription) { - var ready = false; - var failed = false; - Transforms.earthOrientationParameters = new EarthOrientationParameters(eopDescription); var preloadInterval = new TimeInterval({ start : start, diff --git a/Specs/Core/TridiagonalSystemSolverSpec.js b/Specs/Core/TridiagonalSystemSolverSpec.js index 5434c5c465e1..f9e5de75b770 100644 --- a/Specs/Core/TridiagonalSystemSolverSpec.js +++ b/Specs/Core/TridiagonalSystemSolverSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('solve throws exception without lower diagonal', function() { expect(function() { diff --git a/Specs/Core/VRTheWorldTerrainProviderSpec.js b/Specs/Core/VRTheWorldTerrainProviderSpec.js index cf40d9e0fb44..2d4347ce2ac0 100644 --- a/Specs/Core/VRTheWorldTerrainProviderSpec.js +++ b/Specs/Core/VRTheWorldTerrainProviderSpec.js @@ -24,7 +24,6 @@ defineSuite([ pollToPromise, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ beforeEach(function() { loadWithXhr.load = function(url, responseType, method, data, headers, deferred, overrideMimeType) { @@ -125,7 +124,7 @@ defineSuite([ }); expect(function() { - var t = provider.tilingScheme; + return provider.tilingScheme; }).toThrowDeveloperError(); }); diff --git a/Specs/Core/VertexFormatSpec.js b/Specs/Core/VertexFormatSpec.js index 2beb4ad6a2d7..b41c630372db 100644 --- a/Specs/Core/VertexFormatSpec.js +++ b/Specs/Core/VertexFormatSpec.js @@ -6,7 +6,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('clone', function() { var vertexFormat = new VertexFormat({ diff --git a/Specs/Core/VideoSynchronizerSpec.js b/Specs/Core/VideoSynchronizerSpec.js new file mode 100644 index 000000000000..3ff98bf6ba43 --- /dev/null +++ b/Specs/Core/VideoSynchronizerSpec.js @@ -0,0 +1,188 @@ +/*global defineSuite*/ +defineSuite([ + 'Core/VideoSynchronizer', + 'Core/Clock', + 'Core/FeatureDetection', + 'Core/Iso8601', + 'Core/JulianDate', + 'Core/Math', + 'Specs/pollToPromise' + ], function( + VideoSynchronizer, + Clock, + FeatureDetection, + Iso8601, + JulianDate, + CesiumMath, + pollToPromise) { + "use strict"; + + //Video textures do not work on Internet Explorer + if (FeatureDetection.isInternetExplorer()) { + return; + } + + function loadVideo() { + var element = document.createElement('video'); + var source = document.createElement('source'); + source.setAttribute('src', 'http://cesiumjs.org/videos/Sandcastle/big-buck-bunny_trailer.webm'); + source.setAttribute('type', 'video/webm'); + element.appendChild(source); + + source = document.createElement('source'); + source.setAttribute('src', 'http://cesiumjs.org/videos/Sandcastle/big-buck-bunny_trailer.mp4'); + source.setAttribute('type', 'video/mp4'); + element.appendChild(source); + + source = document.createElement('source'); + source.setAttribute('src', 'http://cesiumjs.org/videos/Sandcastle/big-buck-bunny_trailer.mov'); + source.setAttribute('type', 'video/quicktime'); + element.appendChild(source); + + return element; + } + + it('Can default construct', function() { + var videoSynchronizer = new VideoSynchronizer(); + + expect(videoSynchronizer.clock).not.toBeDefined(); + expect(videoSynchronizer.element).not.toBeDefined(); + expect(videoSynchronizer.epoch).toBe(Iso8601.MINIMUM_VALUE); + expect(videoSynchronizer.tolerance).toBe(1.0); + expect(videoSynchronizer.isDestroyed()).toBe(false); + expect(videoSynchronizer.destroy()).not.toBeDefined(); + expect(videoSynchronizer.isDestroyed()).toBe(true); + }); + + it('Can construct with options', function() { + var clock = new Clock(); + var element = document.createElement('video'); + var epoch = new JulianDate(); + var tolerance = 0.15; + + var videoSynchronizer = new VideoSynchronizer({ + clock : clock, + element : element, + epoch : epoch, + tolerance: tolerance + }); + + expect(videoSynchronizer.clock).toBe(clock); + expect(videoSynchronizer.element).toBe(element); + expect(videoSynchronizer.epoch).toBe(epoch); + expect(videoSynchronizer.tolerance).toBe(tolerance); + expect(videoSynchronizer.isDestroyed()).toBe(false); + expect(videoSynchronizer.destroy()).not.toBeDefined(); + expect(videoSynchronizer.isDestroyed()).toBe(true); + }); + + it('Syncs time when looping', function() { + var epoch = JulianDate.fromIso8601('2015-11-01T00:00:00Z'); + var clock = new Clock(); + clock.shouldAnimate = false; + clock.currentTime = epoch.clone(); + + var element = loadVideo(); + element.loop = true; + + var videoSynchronizer = new VideoSynchronizer({ + clock : clock, + element : element, + epoch : epoch + }); + + return pollToPromise(function() { + clock.tick(); + return element.currentTime === 0; + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, 10, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return element.currentTime === 10; + }); + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, 60, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return CesiumMath.equalsEpsilon(element.currentTime, 60 - element.duration, CesiumMath.EPSILON3); + }); + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, -1, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return CesiumMath.equalsEpsilon(element.currentTime, element.duration - 1, CesiumMath.EPSILON1); + }); + }).then(function() { + videoSynchronizer.destroy(); + }); + }); + + it('Syncs time when not looping', function() { + var epoch = JulianDate.fromIso8601('2015-11-01T00:00:00Z'); + var clock = new Clock(); + clock.shouldAnimate = false; + clock.currentTime = epoch.clone(); + + var element = loadVideo(); + + var videoSynchronizer = new VideoSynchronizer({ + clock : clock, + element : element, + epoch : epoch + }); + + return pollToPromise(function() { + clock.tick(); + return element.currentTime === 0; + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, 10, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return element.currentTime === 10; + }); + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, 60, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return CesiumMath.equalsEpsilon(element.currentTime, element.duration, CesiumMath.EPSILON3); + }); + }).then(function() { + clock.currentTime = JulianDate.addSeconds(epoch, -1, clock.currentTime); + return pollToPromise(function() { + clock.tick(); + return element.currentTime === 0; + }); + }).then(function() { + videoSynchronizer.destroy(); + }); + }); + + it('Plays/pauses video based on clock', function() { + var epoch = JulianDate.fromIso8601('2015-11-01T00:00:00Z'); + var clock = new Clock(); + + var element = loadVideo(); + + var videoSynchronizer = new VideoSynchronizer({ + clock : clock, + element : element, + epoch : epoch + }); + + return pollToPromise(function() { + clock.shouldAnimate = false; + clock.tick(); + return element.paused === true; + }).then(function() { + clock.shouldAnimate = true; + clock.tick(); + return element.paused === false; + }).then(function() { + clock.shouldAnimate = false; + clock.tick(); + return element.paused === true; + }).then(function() { + videoSynchronizer.destroy(); + }); + }); +}); diff --git a/Specs/Core/WallGeometrySpec.js b/Specs/Core/WallGeometrySpec.js index 5834f894ff5c..93992c7ed793 100644 --- a/Specs/Core/WallGeometrySpec.js +++ b/Specs/Core/WallGeometrySpec.js @@ -14,7 +14,6 @@ defineSuite([ VertexFormat, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var ellipsoid = Ellipsoid.WGS84; diff --git a/Specs/Core/WallOutlineGeometrySpec.js b/Specs/Core/WallOutlineGeometrySpec.js index 7e2c4de2460e..a138b5276366 100644 --- a/Specs/Core/WallOutlineGeometrySpec.js +++ b/Specs/Core/WallOutlineGeometrySpec.js @@ -12,7 +12,6 @@ defineSuite([ CesiumMath, createPackableSpecs) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var ellipsoid = Ellipsoid.WGS84; diff --git a/Specs/Core/WebMercatorProjectionSpec.js b/Specs/Core/WebMercatorProjectionSpec.js index 0d36126cea15..b8629b95f55a 100644 --- a/Specs/Core/WebMercatorProjectionSpec.js +++ b/Specs/Core/WebMercatorProjectionSpec.js @@ -14,7 +14,6 @@ defineSuite([ Ellipsoid, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('construct0', function() { var projection = new WebMercatorProjection(); @@ -157,4 +156,4 @@ defineSuite([ return projection.unproject(); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/WebMercatorTilingSchemeSpec.js b/Specs/Core/WebMercatorTilingSchemeSpec.js index ed6833590ef4..7065411cec96 100644 --- a/Specs/Core/WebMercatorTilingSchemeSpec.js +++ b/Specs/Core/WebMercatorTilingSchemeSpec.js @@ -18,7 +18,6 @@ defineSuite([ TilingScheme, WebMercatorProjection) { "use strict"; - /*global describe,it,expect,beforeEach*/ var tilingScheme; beforeEach(function() { @@ -276,4 +275,4 @@ defineSuite([ expect(resultParameter).toEqual(new Cartesian2(1, 0)); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/appendForwardSlashSpec.js b/Specs/Core/appendForwardSlashSpec.js index 17ce6464e401..670cf0a5699f 100644 --- a/Specs/Core/appendForwardSlashSpec.js +++ b/Specs/Core/appendForwardSlashSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( appendForwardSlash) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('Appends to a url', function() { expect(appendForwardSlash('http://cesiumjs.org')).toEqual('http://cesiumjs.org/'); @@ -17,4 +16,4 @@ defineSuite([ it('Appends to an empty string', function() { expect(appendForwardSlash('')).toEqual('/'); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/barycentricCoordinatesSpec.js b/Specs/Core/barycentricCoordinatesSpec.js index f8f62f6a9f1f..3d4a94b763fb 100644 --- a/Specs/Core/barycentricCoordinatesSpec.js +++ b/Specs/Core/barycentricCoordinatesSpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, CesiumMath) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var p0 = new Cartesian3(-1.0, 0.0, 0.0); var p1 = new Cartesian3( 1.0, 0.0, 0.0); diff --git a/Specs/Core/binarySearchSpec.js b/Specs/Core/binarySearchSpec.js index 4a8c80fb1d2e..bcab8d2f5cd1 100644 --- a/Specs/Core/binarySearchSpec.js +++ b/Specs/Core/binarySearchSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( binarySearch) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can perform a binary search for 0', function() { var array = [0, 1, 2, 3, 4, 5, 6, 7]; @@ -72,4 +71,4 @@ defineSuite([ binarySearch([0, 1, 2], 1, undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/buildModuleUrlSpec.js b/Specs/Core/buildModuleUrlSpec.js index 2e40e819054b..680bb31cce40 100644 --- a/Specs/Core/buildModuleUrlSpec.js +++ b/Specs/Core/buildModuleUrlSpec.js @@ -1,4 +1,4 @@ -/*global defineSuite */ +/*global defineSuite*/ defineSuite([ 'Core/buildModuleUrl', 'Core/loadText', @@ -8,7 +8,6 @@ defineSuite([ loadText, Uri) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('produces an absolute URL for a module', function() { var url = buildModuleUrl('Workers/transferTypedArrayTest.js'); @@ -30,4 +29,4 @@ defineSuite([ expect(r.exec('assets/foo/bar.cesium.js')).toBeNull(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/cloneSpec.js b/Specs/Core/cloneSpec.js index 68a1f54dfe48..5a75db9a12ba 100644 --- a/Specs/Core/cloneSpec.js +++ b/Specs/Core/cloneSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( clone) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can make shallow clones', function() { var obj = { @@ -47,4 +46,4 @@ defineSuite([ expect(clonedObj.c.e.f).not.toBe(obj.c.e.f); expect(clonedObj.c.e.f.g).toEqual(obj.c.e.f.g); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/combineSpec.js b/Specs/Core/combineSpec.js index 24039f8ed239..53348f47bfbf 100644 --- a/Specs/Core/combineSpec.js +++ b/Specs/Core/combineSpec.js @@ -1,10 +1,9 @@ -/*global defineSuite */ +/*global defineSuite*/ defineSuite([ 'Core/combine' ], function( combine) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can combine shallow references', function() { var obj1 = { @@ -80,4 +79,4 @@ defineSuite([ expect(combine(undefined, undefined)).toEqual({}); expect(combine(undefined, undefined, true)).toEqual({}); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/createGuidSpec.js b/Specs/Core/createGuidSpec.js index 09fbedfb11d7..21661aa187af 100644 --- a/Specs/Core/createGuidSpec.js +++ b/Specs/Core/createGuidSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( createGuid) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates GUIDs', function() { var isGuidRegex = /^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$/; diff --git a/Specs/Core/definedNotNullSpec.js b/Specs/Core/definedNotNullSpec.js index cb1c4f5eec01..f7016db1c5cb 100644 --- a/Specs/Core/definedNotNullSpec.js +++ b/Specs/Core/definedNotNullSpec.js @@ -4,11 +4,10 @@ defineSuite([ ], function( definedNotNull) { "use strict"; - /*global jasmine,it,expect*/ it('works', function() { expect(definedNotNull(0)).toEqual(true); expect(definedNotNull(undefined)).toEqual(false); expect(definedNotNull(null)).toEqual(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/definedSpec.js b/Specs/Core/definedSpec.js index 4096bede1486..cf57fe50e115 100644 --- a/Specs/Core/definedSpec.js +++ b/Specs/Core/definedSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( defined) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var obj = 42; var obj2; @@ -16,4 +15,4 @@ defineSuite([ it('works for undefined object', function() { expect(defined(obj2)).toEqual(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/deprecationWarningSpec.js b/Specs/Core/deprecationWarningSpec.js index e60a219fe8e2..a7333c87a668 100644 --- a/Specs/Core/deprecationWarningSpec.js +++ b/Specs/Core/deprecationWarningSpec.js @@ -4,7 +4,7 @@ defineSuite([ ], function( deprecationWarning) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,console*/ + /*global console*/ it('logs a warning', function() { spyOn(console, 'log'); @@ -29,4 +29,4 @@ defineSuite([ deprecationWarning('identifier'); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/getBaseUriSpec.js b/Specs/Core/getBaseUriSpec.js new file mode 100644 index 000000000000..0cd6191fd166 --- /dev/null +++ b/Specs/Core/getBaseUriSpec.js @@ -0,0 +1,21 @@ +/*global defineSuite*/ +defineSuite([ + 'Core/getBaseUri' + ], function( + getBaseUri) { + "use strict"; + + it('works as expected', function() { + var result = getBaseUri('http://www.mysite.com/awesome?makeitawesome=true'); + expect(result).toEqual('http://www.mysite.com/'); + + result = getBaseUri('http://www.mysite.com/somefolder/awesome.png#makeitawesome'); + expect(result).toEqual('http://www.mysite.com/somefolder/'); + }); + + it('throws with undefined parameter', function() { + expect(function() { + getBaseUri(undefined); + }).toThrowDeveloperError(); + }); +}); diff --git a/Specs/Core/getFilenameFromUriSpec.js b/Specs/Core/getFilenameFromUriSpec.js index 5c1dde70ad1f..8d45ce033960 100644 --- a/Specs/Core/getFilenameFromUriSpec.js +++ b/Specs/Core/getFilenameFromUriSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( getFilenameFromUri) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('works as expected', function() { var result = getFilenameFromUri('http://www.mysite.com/awesome?makeitawesome=true'); diff --git a/Specs/Core/getStringFromTypedArraySpec.js b/Specs/Core/getStringFromTypedArraySpec.js index 9a268df14bce..c2156bfa5bbc 100644 --- a/Specs/Core/getStringFromTypedArraySpec.js +++ b/Specs/Core/getStringFromTypedArraySpec.js @@ -1,10 +1,9 @@ -/*global defineSuite */ +/*global defineSuite*/ defineSuite([ 'Core/getStringFromTypedArray' ], function( getStringFromTypedArray) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor*/ function verifyString() { var arr = new Uint8Array([67, 101, 115, 105, 117, 109]); diff --git a/Specs/Core/isCrossOriginUrlSpec.js b/Specs/Core/isCrossOriginUrlSpec.js index 5011da949e23..6f03cabd8754 100644 --- a/Specs/Core/isCrossOriginUrlSpec.js +++ b/Specs/Core/isCrossOriginUrlSpec.js @@ -6,7 +6,6 @@ defineSuite([ isCrossOriginUrl, Uri) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('returns false for relative urls', function() { expect(isCrossOriginUrl('/some/url.jpg')).toEqual(false); @@ -40,4 +39,4 @@ defineSuite([ absoluteUrl = pageUri.toString(); expect(isCrossOriginUrl(absoluteUrl)).toEqual(true); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/isLeapYearSpec.js b/Specs/Core/isLeapYearSpec.js index fff595d7a923..04d72e2f4e02 100644 --- a/Specs/Core/isLeapYearSpec.js +++ b/Specs/Core/isLeapYearSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( isLeapYear) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('Check for valid leap years', function() { expect(isLeapYear(2000)).toEqual(true); @@ -33,4 +32,4 @@ defineSuite([ isLeapYear('asd'); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/joinUrlsSpec.js b/Specs/Core/joinUrlsSpec.js index 7d88e9ecba44..dfff47ae7eaa 100644 --- a/Specs/Core/joinUrlsSpec.js +++ b/Specs/Core/joinUrlsSpec.js @@ -6,7 +6,6 @@ defineSuite([ joinUrls, URI) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var queryString = "a=some&b=query"; var fragment = "#iamaframent"; diff --git a/Specs/Core/loadArrayBufferSpec.js b/Specs/Core/loadArrayBufferSpec.js index 2005a3b6a565..42122a786e45 100644 --- a/Specs/Core/loadArrayBufferSpec.js +++ b/Specs/Core/loadArrayBufferSpec.js @@ -6,7 +6,6 @@ defineSuite([ loadArrayBuffer, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var fakeXHR; @@ -136,4 +135,4 @@ defineSuite([ expect(rejectedError.statusCode).toEqual(404); expect(rejectedError.response).toEqual(error); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadBlobSpec.js b/Specs/Core/loadBlobSpec.js index aa6c86781d2d..c17a599942c9 100644 --- a/Specs/Core/loadBlobSpec.js +++ b/Specs/Core/loadBlobSpec.js @@ -6,7 +6,6 @@ defineSuite([ loadBlob, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var fakeXHR; @@ -136,4 +135,4 @@ defineSuite([ expect(rejectedError.statusCode).toEqual(404); expect(rejectedError.response).toEqual(error); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadImageFromTypedArraySpec.js b/Specs/Core/loadImageFromTypedArraySpec.js index c5230bb4bb4b..0826912fbb94 100644 --- a/Specs/Core/loadImageFromTypedArraySpec.js +++ b/Specs/Core/loadImageFromTypedArraySpec.js @@ -10,7 +10,6 @@ defineSuite([ loadArrayBuffer, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs,waits,waitsFor,fail*/ it('can load an image', function() { return loadArrayBuffer('./Data/Images/Blue10x10.png').then(function(arrayBuffer) { @@ -41,4 +40,4 @@ defineSuite([ loadImageFromTypedArray(new Uint8Array()); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadImageSpec.js b/Specs/Core/loadImageSpec.js index 318801199ab3..ce90229cab71 100644 --- a/Specs/Core/loadImageSpec.js +++ b/Specs/Core/loadImageSpec.js @@ -8,7 +8,6 @@ defineSuite([ defined, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var dataUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2Nk+M/wHwAEBgIA5agATwAAAABJRU5ErkJggg=='; diff --git a/Specs/Core/loadImageViaBlobSpec.js b/Specs/Core/loadImageViaBlobSpec.js index f6b401c834dd..9eebb11236ab 100644 --- a/Specs/Core/loadImageViaBlobSpec.js +++ b/Specs/Core/loadImageViaBlobSpec.js @@ -8,7 +8,6 @@ defineSuite([ defined, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var dataUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2Nk+M/wHwAEBgIA5agATwAAAABJRU5ErkJggg=='; diff --git a/Specs/Core/loadJsonSpec.js b/Specs/Core/loadJsonSpec.js index 78d5409a6e21..5f04b3ba5c81 100644 --- a/Specs/Core/loadJsonSpec.js +++ b/Specs/Core/loadJsonSpec.js @@ -6,7 +6,6 @@ defineSuite([ loadJson, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var fakeXHR; @@ -140,4 +139,4 @@ defineSuite([ expect(rejectedError.statusCode).toEqual(404); expect(rejectedError.response).toEqual(error); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadJsonpSpec.js b/Specs/Core/loadJsonpSpec.js index 8a857d49f418..3c9de15ca54d 100644 --- a/Specs/Core/loadJsonpSpec.js +++ b/Specs/Core/loadJsonpSpec.js @@ -8,7 +8,6 @@ defineSuite([ DefaultProxy, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('throws with no url', function() { expect(function() { diff --git a/Specs/Core/loadTextSpec.js b/Specs/Core/loadTextSpec.js index dbc921c386f0..ffe8f98281a3 100644 --- a/Specs/Core/loadTextSpec.js +++ b/Specs/Core/loadTextSpec.js @@ -1,3 +1,4 @@ +/* jshint jasmine: true*/ /*global defineSuite*/ defineSuite([ 'Core/loadText', @@ -6,7 +7,6 @@ defineSuite([ loadText, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var fakeXHR; @@ -136,4 +136,4 @@ defineSuite([ expect(rejectedError.statusCode).toEqual(404); expect(rejectedError.response).toEqual(error); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadWithXhrSpec.js b/Specs/Core/loadWithXhrSpec.js index 4e6d93af95cf..3a6ab59e4434 100644 --- a/Specs/Core/loadWithXhrSpec.js +++ b/Specs/Core/loadWithXhrSpec.js @@ -6,7 +6,6 @@ defineSuite([ loadWithXhr, loadImage) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ describe('data URI loading', function() { it('can load URI escaped text with default response type', function() { @@ -134,4 +133,4 @@ defineSuite([ }); }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/loadXMLSpec.js b/Specs/Core/loadXMLSpec.js index 48b4584920a8..a9ee9467a7e4 100644 --- a/Specs/Core/loadXMLSpec.js +++ b/Specs/Core/loadXMLSpec.js @@ -6,7 +6,6 @@ defineSuite([ loadXML, RequestErrorEvent) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var fakeXHR; @@ -138,4 +137,4 @@ defineSuite([ expect(rejectedError.statusCode).toEqual(404); expect(rejectedError.response).toEqual(error); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/mergeSortSpec.js b/Specs/Core/mergeSortSpec.js index 73a1570574ec..70e16fb363b0 100644 --- a/Specs/Core/mergeSortSpec.js +++ b/Specs/Core/mergeSortSpec.js @@ -8,7 +8,6 @@ defineSuite([ BoundingSphere, Cartesian3) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('sorts', function() { var array = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]; @@ -58,4 +57,4 @@ defineSuite([ mergeSort([0, 1, 2], undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/objectToQuerySpec.js b/Specs/Core/objectToQuerySpec.js index 9c1f7a916732..43285d666f5a 100644 --- a/Specs/Core/objectToQuerySpec.js +++ b/Specs/Core/objectToQuerySpec.js @@ -6,7 +6,6 @@ defineSuite([ objectToQuery, queryToObject) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can encode data', function() { var obj = { @@ -56,4 +55,4 @@ defineSuite([ objectToQuery(); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/parseResponseHeadersSpec.js b/Specs/Core/parseResponseHeadersSpec.js index 341b2f77cbd1..3453912a69fe 100644 --- a/Specs/Core/parseResponseHeadersSpec.js +++ b/Specs/Core/parseResponseHeadersSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( parseResponseHeaders) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('returns an empty object literal when given falsy input', function() { expect(parseResponseHeaders()).toEqual({}); @@ -29,4 +28,4 @@ defineSuite([ 'Content-Type': 'text/plain; charset=utf-8' }); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/pointInsideTriangleSpec.js b/Specs/Core/pointInsideTriangleSpec.js index 7d4a4dbbdf87..8e96569b7d5c 100644 --- a/Specs/Core/pointInsideTriangleSpec.js +++ b/Specs/Core/pointInsideTriangleSpec.js @@ -6,7 +6,6 @@ defineSuite([ pointInsideTriangle, Cartesian2) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('pointInsideTriangle has point inside', function() { expect(pointInsideTriangle(new Cartesian2(0.25, 0.25), Cartesian2.ZERO, new Cartesian2(1.0, 0.0), new Cartesian2(0.0, 1.0))).toEqual(true); @@ -55,4 +54,4 @@ defineSuite([ pointInsideTriangle(new Cartesian2(), new Cartesian2(), new Cartesian2()); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/queryToObjectSpec.js b/Specs/Core/queryToObjectSpec.js index 1d2846caa875..154b23b8b4ee 100644 --- a/Specs/Core/queryToObjectSpec.js +++ b/Specs/Core/queryToObjectSpec.js @@ -4,7 +4,6 @@ defineSuite([ ], function( queryToObject) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('can decode data', function() { var str = 'key1=some%20value&key2=a%2Fb'; @@ -49,4 +48,4 @@ defineSuite([ queryToObject(); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/requestAnimationFrameSpec.js b/Specs/Core/requestAnimationFrameSpec.js index 7f284e30ec69..af3534f3b31e 100644 --- a/Specs/Core/requestAnimationFrameSpec.js +++ b/Specs/Core/requestAnimationFrameSpec.js @@ -8,7 +8,6 @@ defineSuite([ cancelAnimationFrame, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('calls the callback', function() { var deferred = when.defer(); diff --git a/Specs/Core/sampleTerrainSpec.js b/Specs/Core/sampleTerrainSpec.js index 58e0ae4aca30..b323759f2eaf 100644 --- a/Specs/Core/sampleTerrainSpec.js +++ b/Specs/Core/sampleTerrainSpec.js @@ -10,7 +10,6 @@ defineSuite([ CesiumTerrainProvider, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var terrainProvider = new CesiumTerrainProvider({ url : '//assets.agi.com/stk-terrain/world' diff --git a/Specs/Core/subdivideArraySpec.js b/Specs/Core/subdivideArraySpec.js index 07de2f85a2e7..d424c0a3f402 100644 --- a/Specs/Core/subdivideArraySpec.js +++ b/Specs/Core/subdivideArraySpec.js @@ -1,10 +1,9 @@ -/*global defineSuite */ +/*global defineSuite*/ defineSuite([ 'Core/subdivideArray' ], function( subdivideArray) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('Splits evenly divided arrays', function() { var values = [1, 2, 3, 4]; @@ -42,4 +41,4 @@ defineSuite([ subdivideArray([], -1); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/Core/throttleRequestByServerSpec.js b/Specs/Core/throttleRequestByServerSpec.js index a5891b7d3e18..2853bcefddd7 100644 --- a/Specs/Core/throttleRequestByServerSpec.js +++ b/Specs/Core/throttleRequestByServerSpec.js @@ -6,7 +6,6 @@ defineSuite([ throttleRequestByServer, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var originalMaximumRequestsPerServer; diff --git a/Specs/Core/writeTextToCanvasSpec.js b/Specs/Core/writeTextToCanvasSpec.js index d703c4bcdc5e..d89ffaa9ac93 100644 --- a/Specs/Core/writeTextToCanvasSpec.js +++ b/Specs/Core/writeTextToCanvasSpec.js @@ -1,4 +1,4 @@ -/*global defineSuite */ +/*global defineSuite*/ defineSuite([ 'Core/writeTextToCanvas', 'Core/Color' @@ -6,7 +6,6 @@ defineSuite([ writeTextToCanvas, Color) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('returns undefined when text is blank', function() { var canvas = writeTextToCanvas(''); @@ -94,4 +93,4 @@ defineSuite([ // canvas2 is stroked, so there should be four "edges" expect(getColorChangeCount(canvas2)).toEqual(4); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/BillboardGraphicsSpec.js b/Specs/DataSources/BillboardGraphicsSpec.js index 78668621865d..8d6f1dc08c27 100644 --- a/Specs/DataSources/BillboardGraphicsSpec.js +++ b/Specs/DataSources/BillboardGraphicsSpec.js @@ -18,7 +18,6 @@ defineSuite([ HorizontalOrigin, VerticalOrigin) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -240,4 +239,4 @@ defineSuite([ target.merge(undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/BillboardVisualizerSpec.js b/Specs/DataSources/BillboardVisualizerSpec.js index bed4d9cf49de..f549a03837b3 100644 --- a/Specs/DataSources/BillboardVisualizerSpec.js +++ b/Specs/DataSources/BillboardVisualizerSpec.js @@ -36,7 +36,6 @@ defineSuite([ createScene, pollToPromise) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var visualizer; diff --git a/Specs/DataSources/BoxGeometryUpdaterSpec.js b/Specs/DataSources/BoxGeometryUpdaterSpec.js index 9fbde34caf92..540756e54f36 100644 --- a/Specs/DataSources/BoxGeometryUpdaterSpec.js +++ b/Specs/DataSources/BoxGeometryUpdaterSpec.js @@ -42,7 +42,6 @@ defineSuite([ createDynamicProperty, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var time; @@ -467,4 +466,4 @@ defineSuite([ createDynamicGeometryBoundingSphereSpecs(BoxGeometryUpdater, entity, entity.box, function() { return scene; }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/BoxGraphicsSpec.js b/Specs/DataSources/BoxGraphicsSpec.js index 132cb85fcbb8..85d71a98b3d2 100644 --- a/Specs/DataSources/BoxGraphicsSpec.js +++ b/Specs/DataSources/BoxGraphicsSpec.js @@ -16,7 +16,6 @@ defineSuite([ testDefinitionChanged, testMaterialDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -137,4 +136,4 @@ defineSuite([ testDefinitionChanged(property, 'outlineWidth', 2, 3); testDefinitionChanged(property, 'dimensions', new Cartesian3(0, 0, 0), new Cartesian3(1, 1, 1)); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CallbackPropertySpec.js b/Specs/DataSources/CallbackPropertySpec.js index ea3f9c542a35..cfcd97872f7a 100644 --- a/Specs/DataSources/CallbackPropertySpec.js +++ b/Specs/DataSources/CallbackPropertySpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, JulianDate) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var time = JulianDate.now(); @@ -30,7 +29,6 @@ defineSuite([ }); it('isConstant returns correct value', function() { - var result = {}; var property = new CallbackProperty(function() { }, true); expect(property.isConstant).toBe(true); @@ -78,4 +76,4 @@ defineSuite([ }, true); expect(left.equals(right)).toEqual(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CheckerboardMaterialPropertySpec.js b/Specs/DataSources/CheckerboardMaterialPropertySpec.js index 651e4cba9cb3..b9e31c4866b1 100644 --- a/Specs/DataSources/CheckerboardMaterialPropertySpec.js +++ b/Specs/DataSources/CheckerboardMaterialPropertySpec.js @@ -18,7 +18,6 @@ defineSuite([ TimeIntervalCollectionProperty, testDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor provides the expected defaults', function() { var property = new CheckerboardMaterialProperty(); @@ -147,4 +146,4 @@ defineSuite([ testDefinitionChanged(property, 'oddColor', Color.RED, Color.BLUE); testDefinitionChanged(property, 'repeat', new Cartesian2(5, 5), new Cartesian2(7, 7)); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/ColorMaterialPropertySpec.js b/Specs/DataSources/ColorMaterialPropertySpec.js index 84582db6b8fe..640670f471f6 100644 --- a/Specs/DataSources/ColorMaterialPropertySpec.js +++ b/Specs/DataSources/ColorMaterialPropertySpec.js @@ -14,7 +14,6 @@ defineSuite([ ConstantProperty, TimeIntervalCollectionProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor provides the expected defaults', function() { var property = new ColorMaterialProperty(); @@ -102,4 +101,4 @@ defineSuite([ property.color = property.color; expect(listener.calls.count()).toEqual(0); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CompositeEntityCollectionSpec.js b/Specs/DataSources/CompositeEntityCollectionSpec.js index 43974ef38c8b..3bc417a7aed2 100644 --- a/Specs/DataSources/CompositeEntityCollectionSpec.js +++ b/Specs/DataSources/CompositeEntityCollectionSpec.js @@ -24,7 +24,6 @@ defineSuite([ Entity, EntityCollection) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var CollectionListener = function() { this.timesCalled = 0; diff --git a/Specs/DataSources/CompositeMaterialPropertySpec.js b/Specs/DataSources/CompositeMaterialPropertySpec.js index 028b8960a754..ef594604124e 100644 --- a/Specs/DataSources/CompositeMaterialPropertySpec.js +++ b/Specs/DataSources/CompositeMaterialPropertySpec.js @@ -16,7 +16,6 @@ defineSuite([ ColorMaterialProperty, GridMaterialProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor has expected values', function() { var property = new CompositeMaterialProperty(); @@ -186,4 +185,4 @@ defineSuite([ property.getType(undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CompositePositionPropertySpec.js b/Specs/DataSources/CompositePositionPropertySpec.js index c2b9922d62fd..b1116a9cdb32 100644 --- a/Specs/DataSources/CompositePositionPropertySpec.js +++ b/Specs/DataSources/CompositePositionPropertySpec.js @@ -18,7 +18,6 @@ defineSuite([ ConstantPositionProperty, PositionProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor has expected values', function() { var property = new CompositePositionProperty(); @@ -303,4 +302,4 @@ defineSuite([ interval1.data.setValue(new Cartesian3()); expect(listener.calls.count()).toBe(2); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CompositePropertySpec.js b/Specs/DataSources/CompositePropertySpec.js index e5b5b95c8856..a81e48088b2f 100644 --- a/Specs/DataSources/CompositePropertySpec.js +++ b/Specs/DataSources/CompositePropertySpec.js @@ -14,7 +14,6 @@ defineSuite([ TimeIntervalCollection, ConstantProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('default constructor has expected values', function() { var property = new CompositeProperty(); @@ -173,4 +172,4 @@ defineSuite([ property.getValue(undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/ConstantPositionPropertySpec.js b/Specs/DataSources/ConstantPositionPropertySpec.js index 7872e3522a1a..3355e5c878f0 100644 --- a/Specs/DataSources/ConstantPositionPropertySpec.js +++ b/Specs/DataSources/ConstantPositionPropertySpec.js @@ -12,7 +12,6 @@ defineSuite([ ReferenceFrame, PositionProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var time = JulianDate.now(); @@ -131,4 +130,4 @@ defineSuite([ property.getValueInReferenceFrame(time, undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/ConstantPropertySpec.js b/Specs/DataSources/ConstantPropertySpec.js index 9db8d28af527..c1e635bce581 100644 --- a/Specs/DataSources/ConstantPropertySpec.js +++ b/Specs/DataSources/ConstantPropertySpec.js @@ -8,7 +8,6 @@ defineSuite([ Cartesian3, JulianDate) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var time = JulianDate.now(); @@ -97,4 +96,4 @@ defineSuite([ right = new ConstantProperty(2); expect(left.equals(right)).toEqual(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CorridorGeometryUpdaterSpec.js b/Specs/DataSources/CorridorGeometryUpdaterSpec.js index df8c92d256bb..dd56757993c6 100644 --- a/Specs/DataSources/CorridorGeometryUpdaterSpec.js +++ b/Specs/DataSources/CorridorGeometryUpdaterSpec.js @@ -46,7 +46,6 @@ defineSuite([ createDynamicProperty, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var time; @@ -550,4 +549,4 @@ defineSuite([ createDynamicGeometryBoundingSphereSpecs(CorridorGeometryUpdater, entity, entity.corridor, function() { return scene; }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CorridorGraphicsSpec.js b/Specs/DataSources/CorridorGraphicsSpec.js index e0bb54f5caf5..712c78f01c60 100644 --- a/Specs/DataSources/CorridorGraphicsSpec.js +++ b/Specs/DataSources/CorridorGraphicsSpec.js @@ -16,7 +16,6 @@ defineSuite([ testDefinitionChanged, testMaterialDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -192,4 +191,4 @@ defineSuite([ testDefinitionChanged(property, 'outlineWidth', 2, 3); testDefinitionChanged(property, 'cornerType', CornerType.BEVELED, CornerType.MITERED); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CustomDataSourceSpec.js b/Specs/DataSources/CustomDataSourceSpec.js index 95f1e1ba5588..6c1d78447230 100644 --- a/Specs/DataSources/CustomDataSourceSpec.js +++ b/Specs/DataSources/CustomDataSourceSpec.js @@ -10,7 +10,6 @@ defineSuite([ DataSourceClock, EntityCollection) { "use strict"; - /*global jasmine,it,expect*/ it('constructor has expected defaults', function() { var dataSource = new CustomDataSource(); @@ -70,4 +69,4 @@ defineSuite([ expect(entityCollection.owner).toEqual(dataSource); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CylinderGeometryUpdaterSpec.js b/Specs/DataSources/CylinderGeometryUpdaterSpec.js index ad483a15b766..d5c1b9881546 100644 --- a/Specs/DataSources/CylinderGeometryUpdaterSpec.js +++ b/Specs/DataSources/CylinderGeometryUpdaterSpec.js @@ -46,7 +46,6 @@ defineSuite([ createDynamicProperty, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var time; @@ -541,4 +540,4 @@ defineSuite([ createDynamicGeometryBoundingSphereSpecs(CylinderGeometryUpdater, entity, entity.cylinder, function() { return scene; }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CylinderGraphicsSpec.js b/Specs/DataSources/CylinderGraphicsSpec.js index c3de9a70c274..95bac8303565 100644 --- a/Specs/DataSources/CylinderGraphicsSpec.js +++ b/Specs/DataSources/CylinderGraphicsSpec.js @@ -14,7 +14,6 @@ defineSuite([ testDefinitionChanged, testMaterialDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -171,4 +170,4 @@ defineSuite([ testDefinitionChanged(property, 'outlineColor', Color.RED, Color.BLUE); testDefinitionChanged(property, 'outlineWidth', 2, 3); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/CzmlDataSourceSpec.js b/Specs/DataSources/CzmlDataSourceSpec.js index cf44481f5ebd..eb8b681d76e9 100644 --- a/Specs/DataSources/CzmlDataSourceSpec.js +++ b/Specs/DataSources/CzmlDataSourceSpec.js @@ -54,7 +54,6 @@ defineSuite([ pollToPromise, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,fail*/ function makePacket(packet) { return [{ @@ -548,7 +547,6 @@ defineSuite([ var dataSource = new CzmlDataSource(); dataSource.load(clockPacket); - var entity = dataSource.entities.values[0]; expect(dataSource.clock).toBeDefined(); expect(dataSource.clock.startTime).toEqual(interval.start); @@ -1908,8 +1906,6 @@ defineSuite([ }); it('Can use interval reference properties for positions', function() { - var time = JulianDate.now(); - var packets = [{ id : 'document', version : '1.0' @@ -1998,7 +1994,6 @@ defineSuite([ }); it('Polyline glow.', function() { - var time = JulianDate.now(); var packet = { id : 'polylineGlow', polyline : { diff --git a/Specs/DataSources/DataSourceClockSpec.js b/Specs/DataSources/DataSourceClockSpec.js index c32368975637..10d6cf4d6841 100644 --- a/Specs/DataSources/DataSourceClockSpec.js +++ b/Specs/DataSources/DataSourceClockSpec.js @@ -10,7 +10,6 @@ defineSuite([ ClockStep, JulianDate) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('merge assigns unassigned properties', function() { var source = new DataSourceClock(); @@ -90,4 +89,4 @@ defineSuite([ target.merge(undefined); }).toThrowDeveloperError(); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/DataSourceCollectionSpec.js b/Specs/DataSources/DataSourceCollectionSpec.js index efc49ba04023..ef0417f3e248 100644 --- a/Specs/DataSources/DataSourceCollectionSpec.js +++ b/Specs/DataSources/DataSourceCollectionSpec.js @@ -8,7 +8,6 @@ defineSuite([ MockDataSource, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('contains, get, getLength, and indexOf work', function() { var collection = new DataSourceCollection(); diff --git a/Specs/DataSources/DataSourceDisplaySpec.js b/Specs/DataSources/DataSourceDisplaySpec.js index abc290ea7962..3e769bc7190c 100644 --- a/Specs/DataSources/DataSourceDisplaySpec.js +++ b/Specs/DataSources/DataSourceDisplaySpec.js @@ -20,7 +20,6 @@ defineSuite([ createScene, MockDataSource) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var dataSourceCollection; var scene; @@ -206,7 +205,6 @@ defineSuite([ dataSourceCollection : dataSourceCollection, scene : scene }); - var entity = new Entity(); var result = new BoundingSphere(); expect(function() { display.getBoundingSphere(undefined, false, result); diff --git a/Specs/DataSources/EllipseGeometryUpdaterSpec.js b/Specs/DataSources/EllipseGeometryUpdaterSpec.js index 873d4df400e2..a580ee33e1cb 100644 --- a/Specs/DataSources/EllipseGeometryUpdaterSpec.js +++ b/Specs/DataSources/EllipseGeometryUpdaterSpec.js @@ -44,7 +44,6 @@ defineSuite([ createDynamicProperty, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var time; @@ -593,4 +592,4 @@ defineSuite([ createDynamicGeometryBoundingSphereSpecs(EllipseGeometryUpdater, entity, entity.ellipse, function() { return scene; }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/EllipseGraphicsSpec.js b/Specs/DataSources/EllipseGraphicsSpec.js index 39c20445fc42..99c242b1d11e 100644 --- a/Specs/DataSources/EllipseGraphicsSpec.js +++ b/Specs/DataSources/EllipseGraphicsSpec.js @@ -14,7 +14,6 @@ defineSuite([ testDefinitionChanged, testMaterialDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -212,4 +211,4 @@ defineSuite([ testDefinitionChanged(property, 'outlineWidth', 2, 3); testDefinitionChanged(property, 'numberOfVerticalLines', 16, 32); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js b/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js index ecc199402fe6..f62f4f8432ec 100644 --- a/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js +++ b/Specs/DataSources/EllipsoidGeometryUpdaterSpec.js @@ -46,7 +46,6 @@ defineSuite([ createDynamicProperty, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var time = JulianDate.now(); var scene; @@ -595,4 +594,4 @@ defineSuite([ createDynamicGeometryBoundingSphereSpecs(EllipsoidGeometryUpdater, entity, entity.ellipsoid, function() { return scene; }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/EllipsoidGraphicsSpec.js b/Specs/DataSources/EllipsoidGraphicsSpec.js index 568f1c404cdf..3863849ae91f 100644 --- a/Specs/DataSources/EllipsoidGraphicsSpec.js +++ b/Specs/DataSources/EllipsoidGraphicsSpec.js @@ -16,7 +16,6 @@ defineSuite([ testDefinitionChanged, testMaterialDefinitionChanged) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('creates expected instance from raw assignment and construction', function() { var options = { @@ -167,4 +166,4 @@ defineSuite([ testDefinitionChanged(property, 'outlineColor', Color.RED, Color.BLUE); testDefinitionChanged(property, 'outlineWidth', 2, 3); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/EntityCollectionSpec.js b/Specs/DataSources/EntityCollectionSpec.js index 9f9640e0f09c..e1991f341164 100644 --- a/Specs/DataSources/EntityCollectionSpec.js +++ b/Specs/DataSources/EntityCollectionSpec.js @@ -14,7 +14,6 @@ defineSuite([ TimeIntervalCollection, Entity) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var CollectionListener = function() { this.timesCalled = 0; diff --git a/Specs/DataSources/EntitySpec.js b/Specs/DataSources/EntitySpec.js index 35b34c13d103..e3d61de4dd12 100644 --- a/Specs/DataSources/EntitySpec.js +++ b/Specs/DataSources/EntitySpec.js @@ -54,7 +54,6 @@ defineSuite([ RectangleGraphics, WallGraphics) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor sets expected properties.', function() { var entity = new Entity(); @@ -224,8 +223,6 @@ defineSuite([ source.addProperty(propertyName); source[propertyName] = value; - var listener = jasmine.createSpy('listener'); - var target = new Entity({ id : 'target' }); @@ -479,4 +476,4 @@ defineSuite([ expect(listener.calls.argsFor(0)).toEqual([entity, 'isShowing', true, false]); expect(entity.isShowing).toBe(true); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/EntityViewSpec.js b/Specs/DataSources/EntityViewSpec.js index b3500145badd..779be1345ecd 100644 --- a/Specs/DataSources/EntityViewSpec.js +++ b/Specs/DataSources/EntityViewSpec.js @@ -18,7 +18,6 @@ defineSuite([ Entity, createScene) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var scene; var defaultOffset = EntityView.defaultOffset3D; diff --git a/Specs/DataSources/GeoJsonDataSourceSpec.js b/Specs/DataSources/GeoJsonDataSourceSpec.js index e0f55dfb7346..86d4f493c58e 100644 --- a/Specs/DataSources/GeoJsonDataSourceSpec.js +++ b/Specs/DataSources/GeoJsonDataSourceSpec.js @@ -22,7 +22,6 @@ defineSuite([ EntityCollection, when) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,fail*/ var defaultMarkerSize; var defaultSymbol; diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index 2b884ed42028..b92c5cdc5a47 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -44,7 +44,6 @@ defineSuite([ createScene, pollToPromise) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ var time = JulianDate.now(); diff --git a/Specs/DataSources/GridMaterialPropertySpec.js b/Specs/DataSources/GridMaterialPropertySpec.js index 271778b0a456..2bbde794525b 100644 --- a/Specs/DataSources/GridMaterialPropertySpec.js +++ b/Specs/DataSources/GridMaterialPropertySpec.js @@ -18,7 +18,6 @@ defineSuite([ SampledProperty, TimeIntervalCollectionProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor provides the expected defaults', function() { var property = new GridMaterialProperty(); @@ -284,4 +283,4 @@ defineSuite([ property.lineOffset.addSample(JulianDate.now(), 1); expect(property.isConstant).toBe(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/ImageMaterialPropertySpec.js b/Specs/DataSources/ImageMaterialPropertySpec.js index db1407e5377a..66683ae3ad4d 100644 --- a/Specs/DataSources/ImageMaterialPropertySpec.js +++ b/Specs/DataSources/ImageMaterialPropertySpec.js @@ -14,7 +14,6 @@ defineSuite([ ConstantProperty, TimeIntervalCollectionProperty) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn*/ it('constructor provides the expected defaults', function() { var property = new ImageMaterialProperty(); @@ -23,20 +22,24 @@ defineSuite([ var result = property.getValue(); expect(result.image).toBeUndefined(); expect(result.repeat).toEqual(new Cartesian2(1.0, 1.0)); + expect(result.alpha).toEqual(1.0); }); it('constructor sets options and allows raw assignment', function() { var options = { image : 'test.invalid', - repeat : new Cartesian2(1, 2) + repeat : new Cartesian2(1, 2), + alpha : 0.5 }; var property = new ImageMaterialProperty(options); expect(property.image).toBeInstanceOf(ConstantProperty); expect(property.repeat).toBeInstanceOf(ConstantProperty); + expect(property.alpha).toBeInstanceOf(ConstantProperty); expect(property.image.getValue()).toEqual(options.image); expect(property.repeat.getValue()).toEqual(options.repeat); + expect(property.alpha.getValue()).toEqual(options.alpha); }); it('works with constant values', function() { @@ -165,4 +168,4 @@ defineSuite([ })); expect(property.isConstant).toBe(false); }); -}); \ No newline at end of file +}); diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 5dae4a3bffd7..2343f35c9cc2 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -46,7 +46,6 @@ defineSuite([ HorizontalOrigin, LabelStyle) { "use strict"; - /*global jasmine,describe,xdescribe,it,xit,expect,beforeEach,afterEach,beforeAll,afterAll,spyOn,runs*/ var parser = new DOMParser(); @@ -89,7 +88,6 @@ defineSuite([ var uberIconColor = Color.fromBytes(0xdd, 0xdd, 0xdd, 0xdd); var uberIconScale = 3; var uberIconHeading = CesiumMath.toRadians(-45); - var uberIcon = 'test.png'; var uberIconHotspot = new Cartesian2(45, -46); var uberLabelColor = Color.fromBytes(0xee, 0xee, 0xee, 0xee); @@ -458,9 +456,6 @@ defineSuite([ }); it('Feature: TimeSpan gracefully handles empty fields', function() { - var endDate = JulianDate.fromIso8601('1945-08-06'); - var beginDate = JulianDate.fromIso8601('1941-12-07'); - var kml = '\ \ \ @@ -1899,7 +1894,6 @@ defineSuite([ }); it('PolyStyle: Sets fill', function() { - var color = Color.fromBytes(0xcc, 0xdd, 0xee, 0xff); var kml = '\ \