diff --git a/.npmignore b/.npmignore index 5c1ffb023c0..6074008c799 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,4 @@ +/.eslintcache /.externalToolBuilders /.gitattributes /.github diff --git a/CHANGES.md b/CHANGES.md index 74816b67617..f572fc657a3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,18 +5,8 @@ Change Log * Deprecated * `GoogleEarthImageryProvider` has been deprecated and will be removed in Cesium 1.37, use `GoogleEarthEnterpriseMapsProvider` instead. - * The `throttleRequest` parameter for `TerrainProvider.requestTileGeometry`, `CesiumTerrainProvider.requestTileGeometry`, `VRTheWorldTerrainProvider.requestTileGeometry`, and `EllipsoidTerrainProvider.requestTileGeometry` is deprecated and will be replaced with an optional `Request` object. The `throttleRequests` parameter will be removed in 1.37. Instead to throttle requests set the request's `throttle` property to `true`. + * The `throttleRequest` parameter for `TerrainProvider.requestTileGeometry`, `CesiumTerrainProvider.requestTileGeometry`, `VRTheWorldTerrainProvider.requestTileGeometry`, and `EllipsoidTerrainProvider.requestTileGeometry` is deprecated and will be replaced with an optional `Request` object. The `throttleRequests` parameter will be removed in 1.37. Instead set the request's `throttle` property to `true` to throttle requests. * The ability to provide a Promise for the `options.url` parameter of `loadWithXhr` and for the `url` parameter of `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadXML`, `loadImage`, `loadCRN`, `loadKTX`, and `loadCubeMap` is deprecated. This will be removed in 1.37, instead `url` must be a string. -* Added an `options.request` parameter to `loadWithXhr` and a `request` parameter to `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadJsonp`, `loadXML`, `loadImageFromTypedArray`, `loadImage`, `loadCRN`, and `loadKTX`. -* Fixed bug where if polylines were set to follow the surface of an undefined globe, Cesium would crash [#5413](https://github.com/AnalyticalGraphicsInc/cesium/pull/5413) -* Fixed a bug where picking clusters would return undefined instead of a list of the clustered entities. [#5286](https://github.com/AnalyticalGraphicsInc/cesium/issues/5286) -* Fixed a bug where picking would break when the Sun came into view [#5478](https://github.com/AnalyticalGraphicsInc/cesium/issues/5478) -* Reduced the amount of Sun bloom post-process effect near the horizon. [#5381](https://github.com/AnalyticalGraphicsInc/cesium/issues/5381) -* Updated glTF/glb MIME types. [#5420](https://github.com/AnalyticalGraphicsInc/cesium/issues/5420) -* Fixed a bug where camera zooming worked incorrectly when the display height was greater than the display width [#5421](https://github.com/AnalyticalGraphicsInc/cesium/pull/5421) -* Added Sandcastle demo for ArcticDEM data. [#5224](https://github.com/AnalyticalGraphicsInc/cesium/issues/5224) -* `CzmlDataSource` and `KmlDataSource` load functions now take an optional `query` object, which will append query parameters to all network requests. [#5419](https://github.com/AnalyticalGraphicsInc/cesium/pull/5419), [#5434](https://github.com/AnalyticalGraphicsInc/cesium/pull/5434) -* Fixed geocoder bug so geocoder can accurately handle NSEW inputs [#5407](https://github.com/AnalyticalGraphicsInc/cesium/pull/5407) * Added support for [3D Tiles](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/README.md) for streaming massive heterogeneous 3D geospatial datasets. The new Cesium APIs are: * `Cesium3DTileset` * `Cesium3DTileStyle`, `StyleExpression`, `Expression`, and `ConditionsExpression` @@ -25,8 +15,18 @@ Change Log * `Cesium3DTileFeature` * `Cesium3DTilesInspector`, `Cesium3DTilesInspectorViewModel`, and `viewerCesium3DTilesInspectorMixin` * `Cesium3DTileColorBlendMode` -* Added a Sandcastle demo for setting time with the Clock API [#5457](https://github.com/AnalyticalGraphicsInc/cesium/pull/5457); -* Added support for `ParticleSystem`s. [#5212](https://github.com/AnalyticalGraphicsInc/cesium/pull/5212) +* Added a particle system for effects like smoke, fire, sparks, etc. See `ParticleSystem`, `Particle`, `ParticleBurst`, `BoxEmitter`, `CircleEmitter`, `ConeEmitter`, `ParticleEmitter`, and `SphereEmitter`, and the new Sandcastle examples: `Particle System` and `Particle System Fireworks`. [#5212](https://github.com/AnalyticalGraphicsInc/cesium/pull/5212) +* Added an `options.request` parameter to `loadWithXhr` and a `request` parameter to `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadJsonp`, `loadXML`, `loadImageFromTypedArray`, `loadImage`, `loadCRN`, and `loadKTX`. +* `CzmlDataSource` and `KmlDataSource` load functions now take an optional `query` object, which will append query parameters to all network requests. [#5419](https://github.com/AnalyticalGraphicsInc/cesium/pull/5419), [#5434](https://github.com/AnalyticalGraphicsInc/cesium/pull/5434) +* Added Sandcastle demo for setting time with the Clock API [#5457](https://github.com/AnalyticalGraphicsInc/cesium/pull/5457); +* Added Sandcastle demo for ArcticDEM data. [#5224](https://github.com/AnalyticalGraphicsInc/cesium/issues/5224) +* Fixed geocoder bug so geocoder can accurately handle NSEW inputs [#5407](https://github.com/AnalyticalGraphicsInc/cesium/pull/5407) +* Fixed a bug where picking would break when the Sun came into view [#5478](https://github.com/AnalyticalGraphicsInc/cesium/issues/5478) +* Fixed a bug where picking clusters would return undefined instead of a list of the clustered entities. [#5286](https://github.com/AnalyticalGraphicsInc/cesium/issues/5286) +* Fixed bug where if polylines were set to follow the surface of an undefined globe, Cesium would throw an exception. [#5413](https://github.com/AnalyticalGraphicsInc/cesium/pull/5413) +* Reduced the amount of Sun bloom post-process effect near the horizon. [#5381](https://github.com/AnalyticalGraphicsInc/cesium/issues/5381) +* Fixed a bug where camera zooming worked incorrectly when the display height was greater than the display width [#5421](https://github.com/AnalyticalGraphicsInc/cesium/pull/5421) +* Updated glTF/glb MIME types. [#5420](https://github.com/AnalyticalGraphicsInc/cesium/issues/5420) * Added `Cesium.Math.randomBetween`. ### 1.34 - 2017-06-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 490c93c6650..c5b0760c6be 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -149,3 +149,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Hülya Yurtman](https://github.com/hulyayurtman) * [Esra ERİK](https://github.com/esraerik) * [Rishabh Shah](https://github.com/rms13) +* [Rudraksha Shah](https://github.com/Rudraksha20) diff --git a/Documentation/Contributors/CodingGuide/README.md b/Documentation/Contributors/CodingGuide/README.md index b4630246492..5e03df2fbca 100644 --- a/Documentation/Contributors/CodingGuide/README.md +++ b/Documentation/Contributors/CodingGuide/README.md @@ -14,6 +14,7 @@ To some extent, this guide can be summarized as _make new code similar to existi * [Naming](#naming) * [Formatting](#formatting) +* [Linting](#linting) * [Units](#units) * [Basic Code Construction](#basic-code-construction) * [Functions](#functions) @@ -135,7 +136,18 @@ function Model(options) { * Text files, including JavaScript files, end with a newline to minimize the noise in diffs. -* When [disabling rules with inline comments](http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments), place the comments on new lines and as close to the associated code as possible: +## Linting + +For syntax and style guidelines, we use the [ESLint](http://eslint.org/docs/rules/) recommended settings as a base and extend it with additional rules via a shared config Node module, [eslint-config-cesium](https://www.npmjs.com/package/eslint-config-cesium), which is maintained as part of the Cesium repository and also used throughout the Cesium ecosystem. For a list of which rules are enabled, look in [index.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Tools/eslint-config-cesium/index.js), [browser.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Tools/eslint-config-cesium/browser.js), and [node.js](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Tools/eslint-config-cesium/node.js). + +* When disabling linting for one line, use `//eslint-disable-line`: +```js +function exit(warningMessage) { + window.alert('Cannot exit: ' + warningMessage); //eslint-disable-line no-alert +} +``` + +* When disabling linting for blocks of code, place `eslint-disable` comments on new lines and as close to the associated code as possible: ```js /*eslint-disable no-empty*/ try { @@ -145,6 +157,8 @@ try { /*eslint-enable no-empty*/ ``` +* See [Disabling Rules with Inline Comments](http://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) for more examples. + ## Units * Cesium uses SI units: diff --git a/Source/Core/EllipsoidGeodesic.js b/Source/Core/EllipsoidGeodesic.js index 166942f77dd..920ec78aad0 100644 --- a/Source/Core/EllipsoidGeodesic.js +++ b/Source/Core/EllipsoidGeodesic.js @@ -1,20 +1,20 @@ /*global define*/ define([ + './Check', './Cartesian3', './Cartographic', './defaultValue', './defined', './defineProperties', - './DeveloperError', './Ellipsoid', './Math' ], function( + Check, Cartesian3, Cartographic, defaultValue, defined, defineProperties, - DeveloperError, Ellipsoid, CesiumMath) { 'use strict'; @@ -179,9 +179,7 @@ define([ var lastCartesian = Cartesian3.normalize(ellipsoid.cartographicToCartesian(end, scratchCart2), scratchCart2); //>>includeStart('debug', pragmas.debug); - if (Math.abs(Math.abs(Cartesian3.angleBetween(firstCartesian, lastCartesian)) - Math.PI) < 0.0125) { - throw new DeveloperError('geodesic position is not unique'); - } + Check.typeOf.number.greaterThanOrEquals('value', Math.abs(Math.abs(Cartesian3.angleBetween(firstCartesian, lastCartesian)) - Math.PI), 0.0125); //>>includeEnd('debug'); vincentyInverseFormula(ellipsoidGeodesic, ellipsoid.maximumRadius, ellipsoid.minimumRadius, @@ -244,9 +242,7 @@ define([ surfaceDistance : { get : function() { //>>includeStart('debug', pragmas.debug); - if (!defined(this._distance)) { - throw new DeveloperError('set end positions before getting surfaceDistance'); - } + Check.defined('distance', this._distance); //>>includeEnd('debug'); return this._distance; @@ -286,9 +282,7 @@ define([ startHeading : { get : function() { //>>includeStart('debug', pragmas.debug); - if (!defined(this._distance)) { - throw new DeveloperError('set end positions before getting startHeading'); - } + Check.defined('distance', this._distance); //>>includeEnd('debug'); return this._startHeading; @@ -304,9 +298,7 @@ define([ endHeading : { get : function() { //>>includeStart('debug', pragmas.debug); - if (!defined(this._distance)) { - throw new DeveloperError('set end positions before getting endHeading'); - } + Check.defined('distance', this._distance); //>>includeEnd('debug'); return this._endHeading; @@ -322,12 +314,8 @@ define([ */ EllipsoidGeodesic.prototype.setEndPoints = function(start, end) { //>>includeStart('debug', pragmas.debug); - if (!defined(start)) { - throw new DeveloperError('start cartographic position is required'); - } - if (!defined(end)) { - throw new DeveloperError('end cartgraphic position is required'); - } + Check.defined('start', start); + Check.defined('end', end); //>>includeEnd('debug'); computeProperties(this, start, end, this._ellipsoid); @@ -355,9 +343,7 @@ define([ */ EllipsoidGeodesic.prototype.interpolateUsingSurfaceDistance = function(distance, result) { //>>includeStart('debug', pragmas.debug); - if (!defined(this._distance)) { - throw new DeveloperError('start and end must be set before calling function interpolateUsingSurfaceDistance'); - } + Check.defined('distance', this._distance); //>>includeEnd('debug'); var constants = this._constants; diff --git a/Source/Scene/Expression.js b/Source/Scene/Expression.js index 860e9a88706..3dd75d70374 100644 --- a/Source/Scene/Expression.js +++ b/Source/Scene/Expression.js @@ -897,27 +897,27 @@ define([ function getEvaluateUnaryFunction(call) { var evaluate = unaryFunctions[call]; - return function(feature) { - var left = this._left.evaluate(feature); + return function(frameState, feature) { + var left = this._left.evaluate(frameState, feature); return evaluate(call, left); }; } function getEvaluateBinaryFunction(call) { var evaluate = binaryFunctions[call]; - return function(feature) { - var left = this._left.evaluate(feature); - var right = this._right.evaluate(feature); + return function(frameState, feature) { + var left = this._left.evaluate(frameState, feature); + var right = this._right.evaluate(frameState, feature); return evaluate(call, left, right); }; } function getEvaluateTernaryFunction(call) { var evaluate = ternaryFunctions[call]; - return function(feature) { - var left = this._left.evaluate(feature); - var right = this._right.evaluate(feature); - var test = this._test.evaluate(feature); + return function(frameState, feature) { + var left = this._left.evaluate(frameState, feature); + var right = this._right.evaluate(frameState, feature); + var test = this._test.evaluate(frameState, feature); return evaluate(call, left, right, test); }; } diff --git a/Specs/Scene/ExpressionSpec.js b/Specs/Scene/ExpressionSpec.js index e67410f727c..087f4effb3c 100644 --- a/Specs/Scene/ExpressionSpec.js +++ b/Specs/Scene/ExpressionSpec.js @@ -121,6 +121,9 @@ defineSuite([ expression = new Expression('\'${undefined}\''); expect(expression.evaluate(frameState, feature)).toEqual(''); + expression = new Expression('abs(-${height}) + max(${height}, ${width}) + clamp(${height}, 0, 2)'); + expect(expression.evaluate(frameState, feature)).toEqual(22); + expect(function() { return new Expression('${height'); }).toThrowRuntimeError(); diff --git a/Tools/eslint-config-cesium/CHANGES.md b/Tools/eslint-config-cesium/CHANGES.md index 28b4bebfeb7..1ea31fcd8b7 100644 --- a/Tools/eslint-config-cesium/CHANGES.md +++ b/Tools/eslint-config-cesium/CHANGES.md @@ -1,7 +1,7 @@ Change Log ========== -### 2.0.0 +### 2.0.0 - 2017-06-27 * Enable [no-floating-decimal](http://eslint.org/docs/rules/no-floating-decimal). * Enable [no-use-before-define](http://eslint.org/docs/rules/no-use-before-define). @@ -16,6 +16,10 @@ Change Log * Enable [no-unused-expressions](http://eslint.org/docs/rules/no-unused-expressions). * Enable [no-sequences](http://eslint.org/docs/rules/no-lonely-if). * Enable [block-scoped-var](http://eslint.org/docs/rules/block-scoped-var). +* Enable Node-specific rules: + * [global-require](http://eslint.org/docs/rules/global-require) + * [no-buffer-constructor](http://eslint.org/docs/rules/no-buffer-constructor) + * [no-new-require](http://eslint.org/docs/rules/no-new-require) ### 1.0.0 - 2017-06-12 diff --git a/Tools/eslint-config-cesium/node.js b/Tools/eslint-config-cesium/node.js index 2686d2251d8..9e4d2eeb57b 100644 --- a/Tools/eslint-config-cesium/node.js +++ b/Tools/eslint-config-cesium/node.js @@ -4,5 +4,10 @@ module.exports = { extends: './index.js', env: { node: true + }, + rules: { + 'global-require' : 'error', + 'no-buffer-constructor' : 'error', + 'no-new-require' : 'error' } }; diff --git a/Tools/eslint-config-cesium/package.json b/Tools/eslint-config-cesium/package.json index afa7027fbe8..3a9eea20eb8 100644 --- a/Tools/eslint-config-cesium/package.json +++ b/Tools/eslint-config-cesium/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-cesium", - "version": "1.0.0", + "version": "2.0.0", "description": "ESLint shareable configs for Cesium", "homepage": "http://cesiumjs.org", "license": "Apache-2.0",