Merge remote-tracking branch 'origin/master' into webgl-mock-for-tests

This commit is contained in:
Patrick Cozzi 2017-01-27 06:23:17 -05:00
commit a588cc3875
82 changed files with 2965 additions and 1138 deletions

View File

@ -0,0 +1,105 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Use the split property to only show layers on one side of a slider.">
<meta name="cesium-sandcastle-labels" content="Beginner, Tutorials, Showcases">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl : '../../../Source',
waitSeconds : 60
});
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
#slider {
position: absolute;
left: 50%;
top: 0px;
background-color: #D3D3D3;
width: 2px;
height: 100%;
z-index: 9999;
}
#slider:hover {
cursor: ew-resize;
}
</style>
<div id="cesiumContainer" class="fullSize">
<div id="slider"></div>
</div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
imageryProvider : new Cesium.ArcGisMapServerImageryProvider({
url : 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer'
}),
baseLayerPicker : false
});
var layers = viewer.imageryLayers;
var blackMarble = layers.addImageryProvider(Cesium.createTileMapServiceImageryProvider({
url : 'https://cesiumjs.org/blackmarble',
credit : 'Black Marble imagery courtesy NASA Earth Observatory',
flipXY : true // Only old gdal2tile.py generated tilesets need this flag.
}));
blackMarble.splitDirection = Cesium.ImagerySplitDirection.LEFT; // Only show to the left of the slider.
// Sync the position of the slider with the split position
var slider = document.getElementById('slider');
viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth;
var dragStartX = 0;
document.getElementById('slider').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);
function mouseUp() {
window.removeEventListener('mousemove', sliderMove, true);
}
function mouseDown(e) {
var slider = document.getElementById('slider');
dragStartX = e.clientX - slider.offsetLeft;
window.addEventListener('mousemove', sliderMove, true);
}
function sliderMove(e) {
var slider = document.getElementById('slider');
var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
viewer.scene.imagerySplitPosition = splitPosition;
}
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -162,7 +162,7 @@ Sandcastle.addToolbarButton('Pick position', function() {
}
});
viewer.zoomTo(modelEntity);
var labelEntity = viewer.entities.add({
label : {
show : false,
@ -174,36 +174,43 @@ Sandcastle.addToolbarButton('Pick position', function() {
}
});
var sceneModeWarningPosted = false;
// Mouse over the globe to see the cartographic position
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
var foundPosition = false;
var scene = viewer.scene;
var pickedObject = scene.pick(movement.endPosition);
if (scene.pickPositionSupported && Cesium.defined(pickedObject) && pickedObject.id === modelEntity) {
var cartesian = viewer.scene.pickPosition(movement.endPosition);
if (Cesium.defined(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);
labelEntity.position = cartesian;
labelEntity.label.show = true;
labelEntity.label.text =
'Lon: ' + (' ' + longitudeString).slice(-7) + '\u00B0' +
'\nLat: ' + (' ' + latitudeString).slice(-7) + '\u00B0' +
'\nAlt: ' + (' ' + heightString).slice(-7) + 'm';
if (scene.mode === Cesium.SceneMode.SCENE3D) {
var cartesian = viewer.scene.pickPosition(movement.endPosition);
var camera = scene.camera;
labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, camera.frustum.near * 1.5 - Cesium.Cartesian3.distance(cartesian, camera.position));
foundPosition = true;
if (Cesium.defined(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);
labelEntity.position = cartesian;
labelEntity.label.show = true;
labelEntity.label.text =
'Lon: ' + (' ' + longitudeString).slice(-7) + '\u00B0' +
'\nLat: ' + (' ' + latitudeString).slice(-7) + '\u00B0' +
'\nAlt: ' + (' ' + heightString).slice(-7) + 'm';
var camera = scene.camera;
labelEntity.label.eyeOffset = new Cesium.Cartesian3(0.0, 0.0, camera.frustum.near * 1.5 - Cesium.Cartesian3.distance(cartesian, camera.position));
foundPosition = true;
}
} else if (!sceneModeWarningPosted) {
sceneModeWarningPosted = true;
console.log("pickPosition is currently only supported in 3D mode.");
}
}
if (!foundPosition) {
labelEntity.label.show = false;
}

View File

@ -125,7 +125,7 @@ function lookAtMtEverest() {
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
}
function sampleTerrainSuccess() {
function sampleTerrainSuccess(terrainSamplePositions) {
var ellipsoid = Cesium.Ellipsoid.WGS84;
//By default, Cesium does not obsure geometry
@ -162,22 +162,13 @@ function sampleTerrainSuccess() {
viewer.entities.resumeEvents();
}
Sandcastle.addToggleButton('Enable Lighting', viewer.scene.globe.enableLighting, function(checked) {
viewer.scene.globe.enableLighting = checked;
});
Sandcastle.addToggleButton('Enable fog', viewer.scene.fog.enabled, function(checked) {
viewer.scene.fog.enabled = checked;
});
Sandcastle.addToolbarButton('Sample Everest Terrain', function() {
function createGrid(rectangleHalfSize) {
var gridWidth = 41;
var gridHeight = 41;
var everestLatitude = Cesium.Math.toRadians(27.988257);
var everestLongitude = Cesium.Math.toRadians(86.925145);
var rectangleHalfSize = 0.005;
var e = new Cesium.Rectangle(everestLongitude - rectangleHalfSize, everestLatitude - rectangleHalfSize, everestLongitude + rectangleHalfSize, everestLatitude + rectangleHalfSize);
terrainSamplePositions = [];
var terrainSamplePositions = [];
for (var y = 0; y < gridHeight; ++y) {
for (var x = 0; x < gridWidth; ++x) {
var longitude = Cesium.Math.lerp(e.west, e.east, x / (gridWidth - 1));
@ -186,9 +177,26 @@ Sandcastle.addToolbarButton('Sample Everest Terrain', function() {
terrainSamplePositions.push(position);
}
}
return terrainSamplePositions;
}
Sandcastle.addToggleButton('Enable Lighting', viewer.scene.globe.enableLighting, function(checked) {
viewer.scene.globe.enableLighting = checked;
});
Sandcastle.addToggleButton('Enable fog', viewer.scene.fog.enabled, function(checked) {
viewer.scene.fog.enabled = checked;
});
Sandcastle.addToolbarButton('Sample Everest Terrain at Level 9', function() {
var terrainSamplePositions = createGrid(0.005);
Cesium.when(Cesium.sampleTerrain(viewer.terrainProvider, 9, terrainSamplePositions), sampleTerrainSuccess);
lookAtMtEverest();
}, 'sampleButtons');
Sandcastle.addToolbarButton('Sample Most Detailed Everest Terrain', function() {
var terrainSamplePositions = createGrid(0.0005);
Cesium.when(Cesium.sampleTerrainMostDetailed(viewer.terrainProvider, terrainSamplePositions), sampleTerrainSuccess);
lookAtMtEverest();
}, 'sampleButtons');

View File

@ -703,7 +703,7 @@ canvas.onclick = function() {
var handler = new Cesium.ScreenSpaceEventHandler(canvas);
// Double click object to turn castShadows on/off
// Click object to turn castShadows on/off
handler.setInputAction(function(movement) {
var picked = scene.pick(movement.position);
if (Cesium.defined(picked) && Cesium.defined(picked.primitive)) {
@ -711,9 +711,9 @@ handler.setInputAction(function(movement) {
var receiveShadows = Cesium.ShadowMode.receiveShadows(picked.primitive.shadows);
picked.primitive.shadows = Cesium.ShadowMode.fromCastReceive(!castShadows, receiveShadows);
}
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
// Double middle click object to turn receiveShadows on/off
// Middle click object to turn receiveShadows on/off
handler.setInputAction(function(movement) {
var picked = scene.pick(movement.position);
if (Cesium.defined(picked)) {
@ -721,7 +721,7 @@ handler.setInputAction(function(movement) {
var receiveShadows = Cesium.ShadowMode.receiveShadows(picked.primitive.shadows);
picked.primitive.shadows = Cesium.ShadowMode.fromCastReceive(castShadows, !receiveShadows);
}
}, Cesium.ScreenSpaceEventType.MIDDLE_DOUBLE_CLICK);
}, Cesium.ScreenSpaceEventType.MIDDLE_CLICK);
//Sandcastle_End
Sandcastle.finishedLoading();

View File

@ -113,7 +113,7 @@
View as Thumbnail
</div>
<span data-dojo-type="dijit.ToolbarSeparator"></span>
<input data-dojo-type="dijit.form.TextBox" type="text" id="search" name="search" data-dojo-props="trim:true, placeHolder:'Search Gallery', intermediateChanges:true"/>
<input data-dojo-type="dijit.form.TextBox" type="text" id="search" name="search" data-dojo-props="trim:true, placeHolder:'Search Gallery', intermediateChanges:true"/>
</div>
<div id="codeContainer" data-dojo-type="dijit.layout.TabContainer" data-dojo-props="region: 'leading', splitter: true">
<script type='dojo/method' event='_onKeyDown'></script>
@ -130,7 +130,7 @@
</div>
</div>
<div id="cesiumContainer" data-dojo-type="dijit.layout.TabContainer" data-dojo-props="region: 'center'">
<div id="bucketPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="title: 'Cesium'">
<div id="bucketPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="title: 'Cesium ' + Cesium.VERSION">
<iframe id="bucketFrame" src="templates/bucket.html" class="fullFrame" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>
</div>
</div>
@ -149,7 +149,7 @@
</div>
</div>
</div>
<div class="dijitTooltip dijitTooltipBelow" id="docPopup">
<div class="dijitTooltipContainer dijitTooltipContents" id="docPopupMessage"></div>
<div class="dijitTooltipConnector"></div>

View File

@ -2,13 +2,16 @@ Change Log
==========
### 1.30 - 2017-02-01
* Deprecated
* The properties `url` and `key` will be removed from `GeocoderViewModel` in 1.31. These properties will be available on geocoder services that support them, like `BingMapsGeocoderService`.
* The function `createBinormalAndBitangent` of `GeometryPipeline` will be removed in 1.31. Use the function `createTangentAndBitangent` instead. [#4856](https://github.com/AnalyticalGraphicsInc/cesium/pull/4856)
* The function `GeometryPipeline.computeBinormalAndTangent` will be removed in 1.31. Use the function `GeometryPipeline.createTangentAndBitangent` instead. [#4856](https://github.com/AnalyticalGraphicsInc/cesium/pull/4856)
* The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been deprecated and will be removed in 1.31. [#4910](https://github.com/AnalyticalGraphicsInc/cesium/pull/4910)
* Breaking changes
* Removed separate `heading`, `pitch`, `roll` parameters from `Transform.headingPitchRollToFixedFrame` and `Transform.headingPitchRollQuaternion`. Pass a `headingPitchRoll` object instead. [#4843](https://github.com/AnalyticalGraphicsInc/cesium/pull/4843)
* The property `binornmal` has been renamed to `bitangent` for `Geometry` and `VertexFormat`. [#4856](https://github.com/AnalyticalGraphicsInc/cesium/pull/4856)
* Removed separate `heading`, `pitch`, `roll` parameters from `Transform.headingPitchRollToFixedFrame` and `Transform.headingPitchRollQuaternion`. Pass a `HeadingPitchRoll` object instead. [#4843](https://github.com/AnalyticalGraphicsInc/cesium/pull/4843)
* The property `binormal` has been renamed to `bitangent` for `Geometry` and `VertexFormat`. [#4856](https://github.com/AnalyticalGraphicsInc/cesium/pull/4856)
* A handful of `CesiumInspectorViewModel` properties were removed or changed from variables to functions. See [#4857](https://github.com/AnalyticalGraphicsInc/cesium/pull/4857)
* The `ShadowMap` constructor has been made private. See [#4010](https://github.com/AnalyticalGraphicsInc/cesium/issues/4010)
* Added support for custom geocoder services and autocomplete [#4723](https://github.com/AnalyticalGraphicsInc/cesium/pull/4723).
* Added [Custom Geocoder Sandcastle example](http://localhost:8080/Apps/Sandcastle/index.html?src=Custom%20Geocoder.html)
* Added `GeocoderService`, an interface for geocoders.
@ -21,9 +24,21 @@ Change Log
* Fixed a bug that caused all models to use the same highlight color. [#4798] (https://github.com/AnalyticalGraphicsInc/cesium/pull/4798)
* Fixed KML for when color is an empty string [#4826](https://github.com/AnalyticalGraphicsInc/cesium/pull/4826)
* Added support for WMS version 1.3 by using CRS vice SRS query string parameter to request projection. SRS is still used for older versions.
* Added ability to draw an `ImageryLayer` with a splitter to allow layers to only display to the left or right of a splitter.
* `ImageryLayer.splitDirection` controls how the layer is rendered with the splitter. Values are taken from the new `ImagerySplitPosition` enum.
* New `Scene.imagerySplitPosition` property controls the splitter position. Values are from 0 to 1 relative across the width of the viewport.
* The attribute `perInstanceAttribute` of `DebugAppearance` has been made optional and defaults to `false`.
* Fixed a bug that would cause a crash when `debugShowFrustums` is enabled with OIT [#4864](https://github.com/AnalyticalGraphicsInc/cesium/pull/4864)
* Fixed a bug that affected dynamic graphics with time-dynamic modelMatrix [#4907](https://github.com/AnalyticalGraphicsInc/cesium/pull/4907).
* Added `Rectangle.fromRadians`.
* `TerrainProvider` now optionally exposes an `availability` property that can be used to query the terrain level that is available at a location or in a rectangle. Currently only `CesiumTerrainProvider` exposes this property.
* Added `sampleTerrainMostDetailed` to sample the height of an array of positions using the best available terrain data at each point. This requires a `TerrainProvider` with the `availability` property.
* Added 2D and Columbus View support for models using the RTC extension or whose vertices are in WGS84 coordinates. [#4922](https://github.com/AnalyticalGraphicsInc/cesium/pull/4922)
* Transparent parts of billboards, labels, and points no longer overwrite parts of the scene behind them. [#4886](https://github.com/AnalyticalGraphicsInc/cesium/pull/4886)
* Added `blendOption` property to `BillboardCollection`, `LabelCollection`, and `PointPrimitiveCollection`. The default is `BlendOption.OPAQUE_AND_TRANSLUCENT`; however, if all billboards, labels, or points are either completely opaque or completely translucent, `blendOption` can be changed to `BlendOption.OPAQUE` or `BlendOption.TRANSLUCENT`, respectively, to increase performance by up to 2x.
### 1.29 - 2017-01-02
* Improved 3D Models
* Added the ability to blend a `Model` with a color/translucency. Added `color`, `colorBlendMode`, and `colorBlendAmount` properties to `Model`, `ModelGraphics`, and CZML. Also added `ColorBlendMode` enum. [#4547](https://github.com/AnalyticalGraphicsInc/cesium/pull/4547)
* Added the ability to render a `Model` with a silhouette. Added `silhouetteColor` and `silhouetteSize` properties to `Model`, `ModelGraphics`, and CZML. [#4314](https://github.com/AnalyticalGraphicsInc/cesium/pull/4314)
@ -36,6 +51,7 @@ Change Log
* Fixed texture rotation for `RectangleGeometry`. [#2737](https://github.com/AnalyticalGraphicsInc/cesium/issues/2737)
* Fixed issue where billboards on terrain had an incorrect offset. [#4598](https://github.com/AnalyticalGraphicsInc/cesium/issues/4598)
* Fixed issue where `globe.getHeight` incorrectly returned `undefined`. [#3411](https://github.com/AnalyticalGraphicsInc/cesium/issues/3411)
* Fixed a crash when using Entity path visualization with reference properties. [#4915](https://github.com/AnalyticalGraphicsInc/cesium/issues/4915)
* Fixed a bug that caused `GroundPrimitive` to render incorrectly on systems without the `WEBGL_depth_texture` extension. [#4747](https://github.com/AnalyticalGraphicsInc/cesium/pull/4747)
* Fixed default Mapbox token and added a watermark to notify users that they need to sign up for their own token.
* Fixed glTF models with skinning that used `bindShapeMatrix`. [#4722](https://github.com/AnalyticalGraphicsInc/cesium/issues/4722)
@ -59,6 +75,7 @@ Change Log
* Fixed `Cartographic.fromCartesian` when the cartesian is not on the ellipsoid surface. [#4611](https://github.com/AnalyticalGraphicsInc/cesium/issues/4611)
### 1.27 - 2016-11-01
* Deprecated
* Individual heading, pitch, and roll options to `Transforms.headingPitchRollToFixedFrame` and `Transforms.headingPitchRollQuaternion` have been deprecated and will be removed in 1.30. Pass the new `HeadingPitchRoll` object instead. [#4498](https://github.com/AnalyticalGraphicsInc/cesium/pull/4498)
* Breaking changes
@ -197,9 +214,11 @@ Change Log
* Added `packArray` and `unpackArray` functions to `Cartesian2`, `Cartesian3`, and `Cartesian4`.
### 1.22.2 - 2016-06-14
* This is an npm only release to fix the improperly published 1.22.1. There were no code changes.
### 1.22.1 - 2016-06-13
* Fixed default Bing Key and added a watermark to notify users that they need to sign up for their own key.
### 1.22 - 2016-06-01
@ -318,6 +337,7 @@ Change Log
* Fixed hole that appeared in the top of in dynamic ellipsoids
### 1.18 - 2016-02-01
* Breaking changes
* Removed support for `CESIUM_binary_glTF`. Use `KHR_binary_glTF` instead, which is the default for the online [COLLADA-to-glTF converter](http://cesiumjs.org/convertmodel.html).
* Deprecated

View File

@ -65,6 +65,7 @@ Our code is our lifeblood so maintaining Cesium's high code quality is important
* Review the [Contributor Guides](Documentation/Contributors/README.md). In addition to Cesium-specific topics, they contain a lot of general software development best practices.
* If this is your first contribution to Cesium, add your name to [CONTRIBUTORS.md](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTORS.md).
* For an overview of our workflow see [github pull request workflows](http://cesiumjs.org/2013/10/08/GitHub-Pull-Request-Workflows/).
* Pull request tips
* If your pull request fixes an existing issue, include a link to the issue in the description (like this: [#1](https://github.com/AnalyticalGraphicsInc/cesium/issues/1)). Likewise, if your pull request fixes an issue reported on the Cesium forum, include a link to the thread.
* If your pull request needs additional work, include a [task list](https://github.com/blog/1375%0A-task-lists-in-gfm-issues-pulls-comments).

View File

@ -37,6 +37,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Erik Andersson](https://github.com/erikmaarten)
* [Austin Eng](https://github.com/austinEng)
* [Shehzan Mohammed](https://github.com/shehzan10)
* [Rachel Hwang](https://github.com/rahwang)
* [NICTA](http://www.nicta.com.au/)
* [Chris Cooper](https://github.com/chris-cooper)
* [Kevin Ring](https://github.com/kring)
@ -118,6 +119,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [David Friedman](https://github.com/duvifn)
* [Abhishek Potnis](https://github.com/abhishekvp)
* [Brad Hover](https://github.com/tekhaus)
* [Jason Beverage](https://github.com/jasonbeverage)
* [Hüseyin Ateş](https://github.com/ateshuseyin)
* [Zsolt Simon](https://github.com/szsolt)
* [Chris Grant](https://github.com/cwgrant)
* [Aristeidis Bampakos](https://github.com/bampakoa)

View File

@ -8,12 +8,13 @@
## Get the Code
* Setup Git if it isn't already ([link](https://help.github.com/articles/set-up-git/#platform-all)).
* New to git or need a refresher? Now's a good time to learn! [Easy tutorials here.](https://guides.github.com/)
* Make sure your SSH keys are configured ([linux](https://help.github.com/articles/generating-ssh-keys#platform-linux) | [mac](https://help.github.com/articles/generating-ssh-keys#platform-mac) | [windows](https://help.github.com/articles/generating-ssh-keys#platform-windows)).
* Double-check your settings for name and email: `git config --get-regexp user.*`.
* Recommended Git settings:
* `git config --global pull.rebase preserve` - when pulling remote changes, rebase your local changes on top of the remote changes, to avoid unnecessary merge commits.
* `git config --global fetch.prune true` - when fetching remote changes, remove any remote branches that no longer exist on the remote.
* Have commit access to cesium?
* Have [commit access](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/CommittersGuide/README.md) to cesium?
* No
* Fork [cesium](https://github.com/AnalyticalGraphicsInc/cesium).
* Use the [GitHub website](https://github.com/AnalyticalGraphicsInc/cesium/branches/all) to delete all branches in your fork except `master`.
@ -28,7 +29,7 @@
Prerequisites:
* Install [Node.js](http://nodejs.org/) on your system. Building Cesium requires Node 4.x or newer.
Cesium uses npm modules for development, so after syncing, you need to run `npm install` from the Cesium root directory:
Cesium uses [npm modules](https://docs.npmjs.com/getting-started/what-is-npm) for development, so after syncing, you need to run `npm install` from the Cesium root directory:
```
npm install
@ -44,9 +45,21 @@ Cesium ships with a simple HTTP server for testing, run `npm start` after buildi
```
npm start
```
```
Then browse to [http://localhost:8080/](http://localhost:8080/).
Then browse to [http://localhost:8080/](http://localhost:8080/). The landing page includes apps and tools commonly used during development, including:
* **Hello World** : an example using the combined and minified Cesium library to create a 3D globe. [Tutorial here](http://cesiumjs.org/tutorials/cesium-up-and-running/)
* **Sandcastle** : an app for viewing and creating [code examples](https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases), complete with a live preview
* **Test Suites** : tests using [Jasmine](https://jasmine.github.io/). [Testing guide here.](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/TestingGuide/README.md#testing-guide)
* **Documentation** : reference documentation built from source. [Documentation guide here.](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/DocumentationGuide/README.md#documentation-guide)
Cesium can be used in two different ways. Cesium can be either a set of modules using [Asynchronous Module Definition (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD), or it can be built as one combined file containing all modules. The basics:
* `npm run build` will build AMD Cesium. This also builds Cesium Viewer and Sandcastle.
* `npm run minifyRelease` creates the built version of Cesium. This also builds Hello World.
Read the complete list of build scripts below for more details.
By default, the server only allows connections from your local machine. To allow connections from other machines, pass
the `--public` option to npm. Note the extra `--` is intentional and required by npm.
@ -76,38 +89,43 @@ npm run [target-name]
```
Here's the full set of scripts and what they do.
* `build` - A fast, developer-oriented build that prepares the source tree for use as standard [Asynchronous Module Definition (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD) modules, suitable for running tests and most examples (some Sandcastle examples require running `combine`). This runs automatically when saving files in Eclipse.
* `build-watch` - A never-ending task that watches your file system for changes to Cesium and runs `build` on the source code as needed.
* `combine` - Runs `build`, plus the [the RequireJS optimizer](http://requirejs.org/docs/optimization.html) to combine Cesium and [the Almond AMD loader](http://requirejs.org/docs/faq-optimization.html#wrap) to produce all-in-one files in the `Build/Cesium` directory that expose the entire Cesium API attached to a single global Cesium object. This version is useful if you don't want to use the modules directly with a standard AMD loader.
* `minify` - Runs `combine`, plus [minifies](http://en.wikipedia.org/wiki/Minification_\(programming\)) Cesium.js using [UglifyJS2](https://github.com/mishoo/UglifyJS2) for a smaller deployable file.
* `combineRelease` - Runs `combine`, plus uses the optimizer to remove debugging code that validates function input and throws DeveloperErrors. The removed sections are marked with `//>>includeStart('debug', pragmas.debug);` blocks in the code.
* `minifyRelease` - Runs `minify`, and removes debugging code.
* `requirejs` - Used internally by the build system and can not be called directly.
* `buildApps` - Builds the example applications (such as Cesium Viewer) to produce self-contained, minified, deployable versions in the `Build` directory.
* `generateDocumentation` - Generates HTML documentation in `Build/Documentation` using [JSDoc 3](https://github.com/jsdoc3/jsdoc).
* `release` - A full release build that creates a shippable product, including building apps and generating documentation.
* `instrumentForCoverage` - Runs [JSCoverage](http://siliconforks.com/jscoverage/) on the source tree to allow running tests with coverage information. Use the link in index.html. Currently Windows only.
* `jsHint` - Runs [JSHint](http://www.jshint.com/) on the entire source tree.
* `jsHint-watch` - A never-ending task that watches your file system for changes to Cesium and runs [JSHint](http://www.jshint.com/) on any changed source files.
* `makeZipFile` - Builds a zip file containing all release files. This includes the source tree (suitable for use from an AMD-aware application), plus the combined and minified Cesium.js files, the generated documentation, the test suite, and the example applications (in both built and source form).
* `clean` - Removes all generated build artifacts.
* `cloc` - Runs [CLOC](https://github.com/AlDanial/cloc) to count the lines of code on the Source and Specs directories. This requires [Perl](http://www.perl.org/) to execute.
* `sortRequires` - Alphabetically sorts the list of required modules in every `js` file. It also makes sure that the top of every source file uses the same formatting.
* `test` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) using the default browser specified in the Karma config file.
* `test-all` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) using all browsers installed on the current system.
* `test-non-webgl` - Runs only non-WebGL tests with [Karma](http://karma-runner.github.io/0.13/index.html).
* `test-webgl` - Runs only WebGL tests with [Karma](http://karma-runner.github.io/0.13/index.html).
* `test-webgl-validation` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) and enables low-level WebGL validation.
* `test-release` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) on the minified release version of built Cesium.
* `deploy-s3` - Deploys the built cesium files, the npm package, and the zip file to Amazon S3. This requires having credentials set up for the S3 bucket to which you are deploying.
* `deploy-status` - Set the deployment statuses in GitHub, for use with Travis.
* `deploy-set-version` - Sets the version of `package.json`, for use with Travis.
* **Build scripts** -- build and package the source code and documentation
* `build` - A fast, developer-oriented build that prepares the source tree for use as standard [Asynchronous Module Definition (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD) modules, suitable for running tests and most examples (some Sandcastle examples require running `combine`). Run this when a GLSL shader is changed since the .glsl file is converted to a .js file with a string for the GLSL source. This runs automatically when saving files in Eclipse.
* `build-watch` - A never-ending task that watches your file system for changes to Cesium and runs `build` on the source code as needed.
* `combine` - Runs `build`, plus the [the RequireJS optimizer](http://requirejs.org/docs/optimization.html) to combine Cesium and [the Almond AMD loader](http://requirejs.org/docs/faq-optimization.html#wrap) to produce all-in-one files in the `Build/Cesium` directory that exposes the entire Cesium API attached to a single global `Cesium` object. This version is useful if you don't want to use the modules directly with a standard AMD loader.
* `minify` - Runs `combine`, plus [minifies](http://en.wikipedia.org/wiki/Minification_\(programming\)) Cesium.js using [UglifyJS2](https://github.com/mishoo/UglifyJS2) for a smaller deployable file.
* `combineRelease` - Runs `combine`, plus uses the optimizer to remove debugging code that validates function input and throws DeveloperErrors. The removed sections are marked with `//>>includeStart('debug', pragmas.debug);` blocks in the code.
* `minifyRelease` - Runs `minify`, and removes debugging code.
* `requirejs` - Used internally by the build system and can not be called directly.
* `buildApps` - Builds the example applications (such as Cesium Viewer) to produce self-contained, minified, deployable versions in the `Build` directory.
* `generateDocumentation` - Generates HTML documentation in `Build/Documentation` using [JSDoc 3](https://github.com/jsdoc3/jsdoc). More [details here](https://github.com/rahwang/cesium/tree/master/Documentation/Contributors/DocumentationGuide).
* `release` - A full release build that creates a shippable product, including building apps and generating documentation.
* `makeZipFile` - Builds a zip file containing all release files. This includes the source tree (suitable for use from an AMD-aware application), plus the combined and minified Cesium.js files, the generated documentation, the test suite, and the example applications (in both built and source form).
* **Utility scripts** -- code coverage, static code analysis, and other utilities
* `instrumentForCoverage` - Runs [JSCoverage](http://siliconforks.com/jscoverage/) on the source tree to allow running tests with coverage information. Use the link in index.html. Currently Windows only.
* `jsHint` - Runs [JSHint](http://www.jshint.com/), a static code analysis tool, on the entire source tree.
* `jsHint-watch` - A never-ending task that watches your file system for changes to Cesium and runs JSHint on any changed source files.
* `clean` - Removes all generated build artifacts.
* `cloc` - Runs [CLOC](https://github.com/AlDanial/cloc) to count the lines of code on the Source and Specs directories. This requires [Perl](http://www.perl.org/) to execute.
* `sortRequires` - Alphabetically sorts the list of required modules in every `js` file. It also makes sure that the top of every source file uses the same formatting.
* **Testing scripts** -- build and run the unit tests
* `test` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) using the default browser specified in the Karma config file.
* `test-all` - Runs all tests with Karma using all browsers installed on the current system.
* `test-non-webgl` - Runs only non-WebGL tests with Karma.
* `test-webgl` - Runs only WebGL tests with Karma.
* `test-webgl-validation` - Runs all tests with Karma and enables low-level WebGL validation.
* `test-release` - Runs all tests with Karma on the minified release version of built Cesium.
* **Deployment scripts**
* `deploy-s3` - Deploys the built cesium files, the npm package, and the zip file to Amazon S3. This requires having credentials set up for the S3 bucket to which you are deploying.
* `deploy-status` - Set the deployment statuses in GitHub, for use with Travis.
* `deploy-set-version` - Sets the version of `package.json`, for use with Travis.
## Travis and Continuous Integration
Cesium uses [Travis](https://travis-ci.org/) for continuous integration. The Travis configuration and all the steps of the build process are defined in `travis.yml`. The blog post [Cesium Continuous Integration](http://cesiumjs.org/2016/04/07/Cesium-Continuous-Integration/) contains an in-depth explaination of the travis build process.
After pushing code to the Cesium repository or when opening a pull request, the build is triggered. After the build has completed, at the bottom on the pull request, the status of the build is shown and you can access the build by clicking the "Details" link.
Travis triggers a build whenever someone opens a pull request or pushes code to the Cesium repository. After the build has completed, at the bottom on the pull request, the status of the build is shown and you can access the build by clicking the "Details" link.
![Checks](checks_failed.jpg)
@ -119,7 +137,7 @@ Additional set up is required for deployment if you do not have commit access to
### Configure a Different S3 Bucket
It is possible to configure your `travis.yml` and `gulpfile.js` to deploy to a different S3 Bucket. If you are using the cesium-dev bucket and have valid credentials, skip to [Configure S3 Credentials](#configure-s3-credentials)
It is possible to configure your `travis.yml` and `gulpfile.js` to deploy to a different S3 Bucket ([an Amazon Webservices storage unit](http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingBucket.html)). If you are using the cesium-dev bucket and have valid credentials, skip to [Configure S3 Credentials](#configure-s3-credentials)
* In `travis.yml`, edit the following line:

View File

@ -1,4 +1,4 @@
# Code Review Guide
All code in Cesium is publicly peer reviewed. We review code to share knowledge, foster shared ownership, and improve code quality and consistency. Just knowing that code will be reviewed improves its quality.
@ -54,6 +54,66 @@ This guide describes best practices for code reviews.
* Delete the branch after merging the pull request.
* Verify that the corresponding issue (if any) was closed.
## Useful Git Commit Management
Sometimes it is useful to clean up the pull request. Here are some scenarios and how to tackle them.
The tips below will use the following keywords:
* **origin** will refer to the user fork, ie. `git@github.com/username/cesium.git`.
* **upstream** will refer to the AGI repo, ie. `git@github.com/AnalyticalGraphicsInc/cesium.git`.
* **mybranch** will refer to your local branch name.
* **target** will refer to the target branch the PR is to be merged into (and also the source for `mybranch`).
If you are new to git, it may be useful to create a backup of your branch in case something goes wrong.
To do that, use:
```
git branch # This should show that you are currently on "mybranch", otherwise use "git checkout mybranch"
git checkout -b mybranch-backup # This should change your current branch to "mybranch-backup", which should be identical to "mybranch"
# if you wish to be even more conservative, you can push this to remote
git push origin mybranch-backup
# Now switch back to your working "mybranch"
git checkout mybranch
```
### You want to squash all the commits in your pull request into a single commit
```
git fetch --all # Ensures remote data is up to date
git merge origin/target # Merge the remote origin target with the local branch
git reset origin/target # This will reset your branch the same as origin/target, with your changes unstaged.
git add # Stage local changes, use `-u` for staging all tracked changes, `-p` to add interactively.
git commit -m "My single commit message"
git push -f origin mybranch # Requires force push as it is changing existing history on remote
```
### You want to merge the latest upstream target branch into mybranch
There are 2 ways to do this, **merge** (recommended) and **rebase** (pretty).
The rule of thumb here is if you are working on a longer term feature branch that may have conflicts with the target branch, then it is best to **merge**.
If you are working on a a shorter pull request (like a bug fix) with a few commits that probably will not result in a conflict, then it is best to **rebase**.
When in doubt, merge.
Futher Reading: [Merge vs Rebase](https://www.derekgourlay.com/blog/git-when-to-merge-vs-when-to-rebase/).
#### Merge
With merge, your commits will become interleaved with other target branch commits based on timestamp.
```
git fetch --all # Fetch updates from all remotes
git merge upstream/target
git push origin mybranch # Does not require force push as it does not change history
```
#### Rebase
With rebase, your commits will be added on top of the target branch and will look sequential.
```
git fetch --all # Fetch updates from all remotes
git rebase -i upstream/target
git push -f origin mybranch # Requires force push as it is changing existing history on remote
```
## Resources
* [Practice Conspicuous Code Review](http://producingoss.com/en/producingoss.html#code-review) in [Producing Open Source Software](http://producingoss.com/).

View File

@ -389,7 +389,7 @@ Use the functions of Cesium's [Check](https://github.com/AnalyticalGraphicsInc/c
```javascript
Cartesian3.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.max(cartesian.x, cartesian.y, cartesian.z);
@ -400,8 +400,8 @@ Cartesian3.maximumComponent = function(cartesian) {
```javascript
Cartesian3.unpackArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.numeric.minimum(array.length, 3);
Check.defined('array', array);
Check.typeOf.number.greaterThanOrEquals('array.length', array.length, 3);
if (array.length % 3 !== 0) {
throw new DeveloperError('array length must be a multiple of 3.');
}
@ -416,7 +416,7 @@ Cartesian3.unpackArray = function(array, result) {
Cartesian3.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
var c = cartesian;
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
// Works in debug. Fails in release since c is optimized out!

View File

@ -1,4 +1,4 @@
Copyright 2011-2016 Cesium Contributors
Copyright 2011-2017 Cesium Contributors
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

View File

@ -42,7 +42,7 @@ define([
console.log(errorString);
printedBingWarning = true;
}
return 'AhiQlDaPOwKbStA_3nJIdimUj4PRYkp0yHwcNpvxVlLNPRo5ZJWY5oX_h6B_dMbm';
return 'AudaMP3YocqmIOQrFAValZ9d_tFqS4JWwiSEnvt2jwP5lizGzV_mJxLaKaI0fWRT';
}
return BingMapsApi.defaultKey;

View File

@ -79,8 +79,8 @@ define([
*/
BoundingRectangle.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -103,7 +103,7 @@ define([
*/
BoundingRectangle.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -236,8 +236,8 @@ define([
*/
BoundingRectangle.union = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
if (!defined(result)) {
@ -266,8 +266,8 @@ define([
*/
BoundingRectangle.expand = function(rectangle, point, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(point, 'point');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('point', point);
//>>includeEnd('debug');
result = BoundingRectangle.clone(rectangle, result);
@ -301,8 +301,8 @@ define([
*/
BoundingRectangle.intersect = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
var leftX = left.x;

View File

@ -348,7 +348,7 @@ define([
stride = defaultValue(stride, 3);
//>>includeStart('debug', pragmas.debug);
Check.numeric.minimum(stride, 3);
Check.typeOf.number.greaterThanOrEquals('stride', stride, 3);
//>>includeEnd('debug');
var currentPos = fromPointsCurrentPos;
@ -654,8 +654,8 @@ define([
*/
BoundingSphere.fromCornerPoints = function(corner, oppositeCorner, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(corner, 'corner');
Check.typeOf.object(oppositeCorner, 'oppositeCorner');
Check.typeOf.object('corner', corner);
Check.typeOf.object('oppositeCorner', oppositeCorner);
//>>includeEnd('debug');
if (!defined(result)) {
@ -681,7 +681,7 @@ define([
*/
BoundingSphere.fromEllipsoid = function(ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(ellipsoid, 'ellipsoid');
Check.typeOf.object('ellipsoid', ellipsoid);
//>>includeEnd('debug');
if (!defined(result)) {
@ -809,8 +809,8 @@ define([
*/
BoundingSphere.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -834,7 +834,7 @@ define([
*/
BoundingSphere.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -863,8 +863,8 @@ define([
*/
BoundingSphere.union = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
if (!defined(result)) {
@ -915,8 +915,8 @@ define([
*/
BoundingSphere.expand = function(sphere, point, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(point, 'point');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('point', point);
//>>includeEnd('debug');
result = BoundingSphere.clone(sphere, result);
@ -941,8 +941,8 @@ define([
*/
BoundingSphere.intersectPlane = function(sphere, plane) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(plane, 'plane');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('plane', plane);
//>>includeEnd('debug');
var center = sphere.center;
@ -970,8 +970,8 @@ define([
*/
BoundingSphere.transform = function(sphere, transform, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(transform, 'transform');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('transform', transform);
//>>includeEnd('debug');
if (!defined(result)) {
@ -1001,8 +1001,8 @@ define([
*/
BoundingSphere.distanceSquaredTo = function(sphere, cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
var diff = Cartesian3.subtract(sphere.center, cartesian, distanceSquaredToScratch);
@ -1026,8 +1026,8 @@ define([
*/
BoundingSphere.transformWithoutScale = function(sphere, transform, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(transform, 'transform');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('transform', transform);
//>>includeEnd('debug');
if (!defined(result)) {
@ -1056,9 +1056,9 @@ define([
*/
BoundingSphere.computePlaneDistances = function(sphere, position, direction, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(position, 'position');
Check.typeOf.object(direction, 'direction');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('position', position);
Check.typeOf.object('direction', direction);
//>>includeEnd('debug');
if (!defined(result)) {
@ -1095,7 +1095,7 @@ define([
*/
BoundingSphere.projectTo2D = function(sphere, projection, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object('sphere', sphere);
//>>includeEnd('debug');
projection = defaultValue(projection, projectTo2DProjection);
@ -1192,8 +1192,8 @@ define([
*/
BoundingSphere.isOccluded = function(sphere, occluder) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(sphere, 'sphere');
Check.typeOf.object(occluder, 'occluder');
Check.typeOf.object('sphere', sphere);
Check.typeOf.object('occluder', occluder);
//>>includeEnd('debug');
return !occluder.isBoundingSphereVisible(sphere);
};

View File

@ -120,8 +120,8 @@ define([
*/
Cartesian2.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -142,7 +142,7 @@ define([
*/
Cartesian2.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -164,7 +164,7 @@ define([
*/
Cartesian2.packArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
@ -189,7 +189,7 @@ define([
*/
Cartesian2.unpackArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
@ -234,7 +234,7 @@ define([
*/
Cartesian2.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.max(cartesian.x, cartesian.y);
@ -248,7 +248,7 @@ define([
*/
Cartesian2.minimumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.min(cartesian.x, cartesian.y);
@ -264,9 +264,9 @@ define([
*/
Cartesian2.minimumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
@ -286,9 +286,9 @@ define([
*/
Cartesian2.maximumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.max(first.x, second.x);
@ -304,7 +304,7 @@ define([
*/
Cartesian2.magnitudeSquared = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return cartesian.x * cartesian.x + cartesian.y * cartesian.y;
@ -376,8 +376,8 @@ define([
*/
Cartesian2.normalize = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var magnitude = Cartesian2.magnitude(cartesian);
@ -403,8 +403,8 @@ define([
*/
Cartesian2.dot = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y;
@ -420,9 +420,9 @@ define([
*/
Cartesian2.multiplyComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x * right.x;
@ -440,9 +440,9 @@ define([
*/
Cartesian2.divideComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x / right.x;
@ -460,9 +460,9 @@ define([
*/
Cartesian2.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x + right.x;
@ -480,9 +480,9 @@ define([
*/
Cartesian2.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x - right.x;
@ -500,9 +500,9 @@ define([
*/
Cartesian2.multiplyByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x * scalar;
@ -520,9 +520,9 @@ define([
*/
Cartesian2.divideByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x / scalar;
@ -539,8 +539,8 @@ define([
*/
Cartesian2.negate = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -cartesian.x;
@ -557,8 +557,8 @@ define([
*/
Cartesian2.abs = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.abs(cartesian.x);
@ -578,10 +578,10 @@ define([
*/
Cartesian2.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
Cartesian2.multiplyByScalar(end, t, lerpScratch);
@ -600,8 +600,8 @@ define([
*/
Cartesian2.angleBetween = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian2.normalize(left, angleBetweenScratch);
@ -619,8 +619,8 @@ define([
*/
Cartesian2.mostOrthogonalAxis = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var f = Cartesian2.normalize(cartesian, mostOrthogonalAxisScratch);

View File

@ -60,7 +60,7 @@ define([
*/
Cartesian3.fromSpherical = function(spherical, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(spherical, 'spherical');
Check.typeOf.object('spherical', spherical);
//>>includeEnd('debug');
if (!defined(result)) {
@ -146,8 +146,8 @@ define([
*/
Cartesian3.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -169,7 +169,7 @@ define([
*/
Cartesian3.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -192,7 +192,7 @@ define([
*/
Cartesian3.packArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
@ -217,8 +217,8 @@ define([
*/
Cartesian3.unpackArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.numeric.minimum(array.length, 3);
Check.defined('array', array);
Check.typeOf.number.greaterThanOrEquals('array.length', array.length, 3);
if (array.length % 3 !== 0) {
throw new DeveloperError('array length must be a multiple of 3.');
}
@ -266,7 +266,7 @@ define([
*/
Cartesian3.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.max(cartesian.x, cartesian.y, cartesian.z);
@ -280,7 +280,7 @@ define([
*/
Cartesian3.minimumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.min(cartesian.x, cartesian.y, cartesian.z);
@ -296,9 +296,9 @@ define([
*/
Cartesian3.minimumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.min(first.x, second.x);
@ -318,9 +318,9 @@ define([
*/
Cartesian3.maximumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.max(first.x, second.x);
@ -337,7 +337,7 @@ define([
*/
Cartesian3.magnitudeSquared = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z;
@ -368,8 +368,8 @@ define([
*/
Cartesian3.distance = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian3.subtract(left, right, distanceScratch);
@ -390,8 +390,8 @@ define([
*/
Cartesian3.distanceSquared = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian3.subtract(left, right, distanceScratch);
@ -407,8 +407,8 @@ define([
*/
Cartesian3.normalize = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var magnitude = Cartesian3.magnitude(cartesian);
@ -435,8 +435,8 @@ define([
*/
Cartesian3.dot = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y + left.z * right.z;
@ -452,9 +452,9 @@ define([
*/
Cartesian3.multiplyComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x * right.x;
@ -500,9 +500,9 @@ define([
*/
Cartesian3.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x + right.x;
@ -521,9 +521,9 @@ define([
*/
Cartesian3.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x - right.x;
@ -542,9 +542,9 @@ define([
*/
Cartesian3.multiplyByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x * scalar;
@ -563,9 +563,9 @@ define([
*/
Cartesian3.divideByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x / scalar;
@ -583,8 +583,8 @@ define([
*/
Cartesian3.negate = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -cartesian.x;
@ -602,8 +602,8 @@ define([
*/
Cartesian3.abs = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.abs(cartesian.x);
@ -624,10 +624,10 @@ define([
*/
Cartesian3.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
Cartesian3.multiplyByScalar(end, t, lerpScratch);
@ -646,8 +646,8 @@ define([
*/
Cartesian3.angleBetween = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian3.normalize(left, angleBetweenScratch);
@ -667,8 +667,8 @@ define([
*/
Cartesian3.mostOrthogonalAxis = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var f = Cartesian3.normalize(cartesian, mostOrthogonalAxisScratch);
@ -747,9 +747,9 @@ define([
*/
Cartesian3.cross = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var leftX = left.x;
@ -784,8 +784,8 @@ define([
*/
Cartesian3.fromDegrees = function(longitude, latitude, height, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(longitude, 'longitude');
Check.typeOf.number(latitude, 'latitude');
Check.typeOf.number('longitude', longitude);
Check.typeOf.number('latitude', latitude);
//>>includeEnd('debug');
longitude = CesiumMath.toRadians(longitude);
@ -812,8 +812,8 @@ define([
*/
Cartesian3.fromRadians = function(longitude, latitude, height, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(longitude, 'longitude');
Check.typeOf.number(latitude, 'latitude');
Check.typeOf.number('longitude', longitude);
Check.typeOf.number('latitude', latitude);
//>>includeEnd('debug');
height = defaultValue(height, 0.0);
@ -849,7 +849,7 @@ define([
*/
Cartesian3.fromDegreesArray = function(coordinates, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(coordinates, 'coordinates');
Check.defined('coordinates', coordinates);
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
throw new DeveloperError('the number of coordinates must be a multiple of 2 and at least 2');
}
@ -885,7 +885,7 @@ define([
*/
Cartesian3.fromRadiansArray = function(coordinates, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(coordinates, 'coordinates');
Check.defined('coordinates', coordinates);
if (coordinates.length < 2 || coordinates.length % 2 !== 0) {
throw new DeveloperError('the number of coordinates must be a multiple of 2 and at least 2');
}
@ -921,7 +921,7 @@ define([
*/
Cartesian3.fromDegreesArrayHeights = function(coordinates, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(coordinates, 'coordinates');
Check.defined('coordinates', coordinates);
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
throw new DeveloperError('the number of coordinates must be a multiple of 3 and at least 3');
}
@ -958,7 +958,7 @@ define([
*/
Cartesian3.fromRadiansArrayHeights = function(coordinates, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(coordinates, 'coordinates');
Check.defined('coordinates', coordinates);
if (coordinates.length < 3 || coordinates.length % 3 !== 0) {
throw new DeveloperError('the number of coordinates must be a multiple of 3 and at least 3');
}

View File

@ -91,7 +91,7 @@ define([
*/
Cartesian4.fromColor = function(color, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(color, 'color');
Check.typeOf.object('color', color);
//>>includeEnd('debug');
if (!defined(result)) {
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
@ -145,8 +145,8 @@ define([
*/
Cartesian4.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -169,7 +169,7 @@ define([
*/
Cartesian4.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -193,7 +193,7 @@ define([
*/
Cartesian4.packArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
@ -218,7 +218,7 @@ define([
*/
Cartesian4.unpackArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
@ -263,7 +263,7 @@ define([
*/
Cartesian4.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
@ -277,7 +277,7 @@ define([
*/
Cartesian4.minimumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
@ -293,9 +293,9 @@ define([
*/
Cartesian4.minimumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.min(first.x, second.x);
@ -316,9 +316,9 @@ define([
*/
Cartesian4.maximumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(first, 'first');
Check.typeOf.object(second, 'second');
Check.typeOf.object(result, 'result');
Check.typeOf.object('first', first);
Check.typeOf.object('second', second);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.max(first.x, second.x);
@ -337,7 +337,7 @@ define([
*/
Cartesian4.magnitudeSquared = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
@ -370,8 +370,8 @@ define([
*/
Cartesian4.distance = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian4.subtract(left, right, distanceScratch);
@ -394,8 +394,8 @@ define([
*/
Cartesian4.distanceSquared = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian4.subtract(left, right, distanceScratch);
@ -411,8 +411,8 @@ define([
*/
Cartesian4.normalize = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var magnitude = Cartesian4.magnitude(cartesian);
@ -440,8 +440,8 @@ define([
*/
Cartesian4.dot = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
@ -457,9 +457,9 @@ define([
*/
Cartesian4.multiplyComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x * right.x;
@ -479,9 +479,9 @@ define([
*/
Cartesian4.divideComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x / right.x;
@ -501,9 +501,9 @@ define([
*/
Cartesian4.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x + right.x;
@ -523,9 +523,9 @@ define([
*/
Cartesian4.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x - right.x;
@ -545,9 +545,9 @@ define([
*/
Cartesian4.multiplyByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x * scalar;
@ -567,9 +567,9 @@ define([
*/
Cartesian4.divideByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x / scalar;
@ -588,8 +588,8 @@ define([
*/
Cartesian4.negate = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -cartesian.x;
@ -608,8 +608,8 @@ define([
*/
Cartesian4.abs = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.abs(cartesian.x);
@ -631,10 +631,10 @@ define([
*/
Cartesian4.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
Cartesian4.multiplyByScalar(end, t, lerpScratch);
@ -652,8 +652,8 @@ define([
*/
Cartesian4.mostOrthogonalAxis = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);

View File

@ -19,8 +19,11 @@ define([
'./Math',
'./OrientedBoundingBox',
'./QuantizedMeshTerrainData',
'./Rectangle',
'./RuntimeError',
'./TerrainProvider',
'./throttleRequestByServer',
'./TileAvailability',
'./TileProviderError'
], function(
Uri,
@ -42,8 +45,11 @@ define([
CesiumMath,
OrientedBoundingBox,
QuantizedMeshTerrainData,
Rectangle,
RuntimeError,
TerrainProvider,
throttleRequestByServer,
TileAvailability,
TileProviderError) {
'use strict';
@ -136,6 +142,7 @@ define([
this._requestWaterMask = defaultValue(options.requestWaterMask, false);
this._errorEvent = new Event();
this._availability = undefined;
var credit = options.credit;
if (typeof credit === 'string') {
@ -199,7 +206,21 @@ define([
that._tileUrlTemplates[i] = joinUrls(baseUri, template).toString().replace('{version}', data.version);
}
that._availableTiles = data.available;
var availableTiles = data.available;
if (defined(availableTiles)) {
that._availability = new TileAvailability(that._tilingScheme, availableTiles.length);
for (var level = 0; level < availableTiles.length; ++level) {
var rangesAtLevel = availableTiles[level];
var yTiles = that._tilingScheme.getNumberOfYTilesAtLevel(level);
for (var rangeIndex = 0; rangeIndex < rangesAtLevel.length; ++rangeIndex) {
var range = rangesAtLevel[rangeIndex];
that._availability.addAvailableTileRange(level, range.startX, yTiles - range.endY - 1, range.endX, yTiles - range.startY - 1);
}
}
}
if (!defined(that._credit) && defined(data.attribution) && data.attribution !== null) {
that._credit = new Credit(data.attribution);
@ -459,7 +480,7 @@ define([
southSkirtHeight : skirtHeight,
eastSkirtHeight : skirtHeight,
northSkirtHeight : skirtHeight,
childTileMask: getChildMaskForTile(provider, level, x, tmsY),
childTileMask: provider.availability.computeChildMaskForTile(level, x, y),
waterMask: waterMaskBuffer
});
}
@ -676,6 +697,25 @@ define([
get : function() {
return this._requestWaterMask;
}
},
/**
* Gets an object that can be used to determine availability of terrain from this provider, such as
* at points and in rectangles. This function should not be called before
* {@link CesiumTerrainProvider#ready} returns true. This property may be undefined if availability
* information is not available.
* @memberof CesiumTerrainProvider.prototype
* @type {TileAvailability}
*/
availability : {
get : function() {
//>>includeStart('debug', pragmas.debug)
if (!this._ready) {
throw new DeveloperError('availability must not be called before the terrain provider is ready.');
}
//>>includeEnd('debug');
return this._availability;
}
}
});
@ -689,40 +729,6 @@ define([
return this._levelZeroMaximumGeometricError / (1 << level);
};
function getChildMaskForTile(terrainProvider, level, x, y) {
var available = terrainProvider._availableTiles;
if (!available || available.length === 0) {
return 15;
}
var childLevel = level + 1;
if (childLevel >= available.length) {
return 0;
}
var levelAvailable = available[childLevel];
var mask = 0;
mask |= isTileInRange(levelAvailable, 2 * x, 2 * y) ? 1 : 0;
mask |= isTileInRange(levelAvailable, 2 * x + 1, 2 * y) ? 2 : 0;
mask |= isTileInRange(levelAvailable, 2 * x, 2 * y + 1) ? 4 : 0;
mask |= isTileInRange(levelAvailable, 2 * x + 1, 2 * y + 1) ? 8 : 0;
return mask;
}
function isTileInRange(levelAvailable, x, y) {
for (var i = 0, len = levelAvailable.length; i < len; ++i) {
var range = levelAvailable[i];
if (x >= range.startX && x <= range.endX && y >= range.startY && y <= range.endY) {
return true;
}
}
return false;
}
/**
* Determines whether data for a tile is available to be loaded.
*
@ -732,19 +738,10 @@ define([
* @returns {Boolean} Undefined if not supported, otherwise true or false.
*/
CesiumTerrainProvider.prototype.getTileDataAvailable = function(x, y, level) {
var available = this._availableTiles;
if (!available || available.length === 0) {
if (!defined(this.availability)) {
return undefined;
} else {
if (level >= available.length) {
return false;
}
var levelAvailable = available[level];
var yTiles = this._tilingScheme.getNumberOfYTilesAtLevel(level);
var tmsY = (yTiles - y - 1);
return isTileInRange(levelAvailable, x, tmsY);
}
return this.availability.isTileAvailable(level, x, y);
};
return CesiumTerrainProvider;

View File

@ -1,7 +1,7 @@
/*global define*/
define([
'./defined',
'./DeveloperError'
'./defined',
'./DeveloperError'
], function(
defined,
DeveloperError) {
@ -19,72 +19,35 @@ define([
*/
Check.typeOf = {};
/**
* Contains functions for checking numeric conditions such as minimum and maximum values
*/
Check.numeric = {};
function getUndefinedErrorMessage(name) {
return name + ' was required but undefined.';
return name + ' is required, actual value was undefined';
}
function getFailedTypeErrorMessage(actual, expected, name) {
return 'Expected ' + name + ' to be typeof ' + expected + ', got ' + actual;
return 'Expected ' + name + ' to be typeof ' + expected + ', actual typeof was ' + actual;
}
/**
* Throws if test is not defined
*
* @param {*} test The value that is to be checked
* @param {String} name The name of the variable being tested
* @param {*} test The value that is to be checked
* @exception {DeveloperError} test must be defined
*/
Check.defined = function (test, name) {
Check.defined = function (name, test) {
if (!defined(test)) {
throw new DeveloperError(getUndefinedErrorMessage(name));
}
};
/**
* Throws if test is greater than maximum
*
* @param {Number} test The value to test
* @param {Number} maximum The maximum allowed value
* @exception {DeveloperError} test must not be greater than maximum
* @exception {DeveloperError} Both test and maximum must be typeof 'number'
*/
Check.numeric.maximum = function (test, maximum) {
Check.typeOf.number(test);
Check.typeOf.number(maximum);
if (test > maximum) {
throw new DeveloperError('Expected ' + test + ' to be at most ' + maximum);
}
};
/**
* Throws if test is less than minimum
*
* @param {Number} test The value to test
* @param {Number} minimum The minimum allowed value
* @exception {DeveloperError} test must not be less than mininum
* @exception {DeveloperError} Both test and maximum must be typeof 'number'
*/
Check.numeric.minimum = function (test, minimum) {
Check.typeOf.number(test);
Check.typeOf.number(minimum);
if (test < minimum) {
throw new DeveloperError('Expected ' + test + ' to be at least ' + minimum);
}
};
/**
* Throws if test is not typeof 'function'
*
* @param {*} test The value to test
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'function'
*/
Check.typeOf.func = function (test, name) {
Check.typeOf.func = function (name, test) {
if (typeof test !== 'function') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'function', name));
}
@ -93,11 +56,11 @@ define([
/**
* Throws if test is not typeof 'string'
*
* @param {*} test The value to test
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'string'
*/
Check.typeOf.string = function (test, name) {
Check.typeOf.string = function (name, test) {
if (typeof test !== 'string') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'string', name));
}
@ -106,24 +69,84 @@ define([
/**
* Throws if test is not typeof 'number'
*
* @param {*} test The value to test
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'number'
*/
Check.typeOf.number = function (test, name) {
Check.typeOf.number = function (name, test) {
if (typeof test !== 'number') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'number', name));
}
};
/**
* Throws if test is not typeof 'number' and less than limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and less than limit
*/
Check.typeOf.number.lessThan = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test >= limit) {
throw new DeveloperError('Expected ' + name + ' to be less than ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and less than or equal to limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and less than or equal to limit
*/
Check.typeOf.number.lessThanOrEquals = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test > limit) {
throw new DeveloperError('Expected ' + name + ' to be less than or equal to ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and greater than limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and greater than limit
*/
Check.typeOf.number.greaterThan = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test <= limit) {
throw new DeveloperError('Expected ' + name + ' to be greater than ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and greater than or equal to limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and greater than or equal to limit
*/
Check.typeOf.number.greaterThanOrEquals = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test < limit) {
throw new DeveloperError('Expected ' + name + ' to be greater than or equal to' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'object'
*
* @param {*} test The value to test
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'object'
*/
Check.typeOf.object = function (test, name) {
Check.typeOf.object = function (name, test) {
if (typeof test !== 'object') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'object', name));
}
@ -132,11 +155,11 @@ define([
/**
* Throws if test is not typeof 'boolean'
*
* @param {*} test The value to test
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'boolean'
*/
Check.typeOf.bool = function (test, name) {
Check.typeOf.bool = function (name, test) {
if (typeof test !== 'boolean') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'boolean', name));
}

View File

@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian3',
'./Check',
'./defaultValue',
'./defined',
'./defineProperties',
@ -10,6 +11,7 @@ define([
'./VertexFormat'
], function(
Cartesian3,
Check,
defaultValue,
defined,
defineProperties,
@ -54,9 +56,7 @@ define([
var radius = options.radius;
//>>includeStart('debug', pragmas.debug);
if (!defined(radius)) {
throw new DeveloperError('radius is required.');
}
Check.typeOf.number('radius', radius);
//>>includeEnd('debug');
var ellipseGeometryOptions = {
@ -92,9 +92,7 @@ define([
*/
CircleGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!defined(value)) {
throw new DeveloperError('value is required');
}
Check.typeOf.object('value', value);
//>>includeEnd('debug');
return EllipseGeometry.pack(value._ellipseGeometry, array, startingIndex);
};

View File

@ -1,6 +1,7 @@
/*global define*/
define([
'./Cartesian3',
'./Check',
'./defaultValue',
'./defined',
'./DeveloperError',
@ -8,6 +9,7 @@ define([
'./Ellipsoid'
], function(
Cartesian3,
Check,
defaultValue,
defined,
DeveloperError,
@ -49,9 +51,7 @@ define([
var radius = options.radius;
//>>includeStart('debug', pragmas.debug);
if (!defined(radius)) {
throw new DeveloperError('radius is required.');
}
Check.typeOf.number('radius', radius);
//>>includeEnd('debug');
var ellipseGeometryOptions = {
@ -85,9 +85,7 @@ define([
*/
CircleOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!defined(value)) {
throw new DeveloperError('value is required');
}
Check.typeOf.object('value', value);
//>>includeEnd('debug');
return EllipseOutlineGeometry.pack(value._ellipseGeometry, array, startingIndex);
};

View File

@ -59,8 +59,8 @@ define([
*/
Matrix2.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -83,7 +83,7 @@ define([
*/
Matrix2.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -143,7 +143,7 @@ define([
*/
Matrix2.fromArray = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -168,7 +168,7 @@ define([
*/
Matrix2.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
return Matrix2.clone(values, result);
@ -184,7 +184,7 @@ define([
*/
Matrix2.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
if (!defined(result)) {
@ -213,7 +213,7 @@ define([
*/
Matrix2.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(scale, 'scale');
Check.typeOf.object('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -244,7 +244,7 @@ define([
*/
Matrix2.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(scale, 'scale');
Check.typeOf.number('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -275,7 +275,7 @@ define([
*/
Matrix2.fromRotation = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(angle, 'angle');
Check.typeOf.number('angle', angle);
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@ -303,7 +303,7 @@ define([
*/
Matrix2.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
if (!defined(result)) {
@ -334,13 +334,11 @@ define([
*/
Matrix2.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(row, 'row');
Check.numeric.minimum(row, 0);
Check.numeric.maximum(row, 1);
Check.typeOf.number.greaterThanOrEquals('row', row, 0);
Check.typeOf.number.lessThanOrEquals('row', row, 1);
Check.typeOf.number(column, 'column');
Check.numeric.minimum(column, 0);
Check.numeric.maximum(column, 1);
Check.typeOf.number.greaterThanOrEquals('column', column, 0);
Check.typeOf.number.lessThanOrEquals('column', column, 1);
//>>includeEnd('debug');
return column * 2 + row;
@ -358,13 +356,12 @@ define([
*/
Matrix2.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 1);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 1);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var startIndex = index * 2;
@ -389,14 +386,13 @@ define([
*/
Matrix2.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 1);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 1);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix2.clone(matrix, result);
@ -418,13 +414,12 @@ define([
*/
Matrix2.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 1);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 1);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = matrix[index];
@ -448,14 +443,13 @@ define([
*/
Matrix2.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 1);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 1);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix2.clone(matrix, result);
@ -475,8 +469,8 @@ define([
*/
Matrix2.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Cartesian2.magnitude(Cartesian2.fromElements(matrix[0], matrix[1], scratchColumn));
@ -508,9 +502,9 @@ define([
*/
Matrix2.multiply = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = left[0] * right[0] + left[2] * right[1];
@ -535,9 +529,9 @@ define([
*/
Matrix2.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@ -557,9 +551,9 @@ define([
*/
Matrix2.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@ -579,9 +573,9 @@ define([
*/
Matrix2.multiplyByVector = function(matrix, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = matrix[0] * cartesian.x + matrix[2] * cartesian.y;
@ -602,9 +596,9 @@ define([
*/
Matrix2.multiplyByScalar = function(matrix, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@ -632,9 +626,9 @@ define([
*/
Matrix2.multiplyByScale = function(matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(scale, 'scale');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('scale', scale);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0] * scale.x;
@ -653,8 +647,8 @@ define([
*/
Matrix2.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = -matrix[0];
@ -673,8 +667,8 @@ define([
*/
Matrix2.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = matrix[0];
@ -698,8 +692,8 @@ define([
*/
Matrix2.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@ -750,7 +744,7 @@ define([
*/
Matrix2.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(epsilon, 'epsilon');
Check.typeOf.number('epsilon', epsilon);
//>>includeEnd('debug');
return (left === right) ||

View File

@ -74,8 +74,8 @@ define([
*/
Matrix3.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -103,7 +103,7 @@ define([
*/
Matrix3.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -175,7 +175,7 @@ define([
*/
Matrix3.fromArray = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -205,7 +205,7 @@ define([
*/
Matrix3.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
return Matrix3.clone(values, result);
@ -221,7 +221,7 @@ define([
*/
Matrix3.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
if (!defined(result)) {
@ -250,7 +250,7 @@ define([
*/
Matrix3.fromQuaternion = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object('quaternion', quaternion);
//>>includeEnd('debug');
var x2 = quaternion.x * quaternion.x;
@ -302,7 +302,7 @@ define([
*/
Matrix3.fromHeadingPitchRoll = function(headingPitchRoll, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
Check.typeOf.object('headingPitchRoll', headingPitchRoll);
//>>includeEnd('debug');
var cosTheta = Math.cos(-headingPitchRoll.pitch);
@ -357,7 +357,7 @@ define([
*/
Matrix3.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(scale, 'scale');
Check.typeOf.object('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -395,7 +395,7 @@ define([
*/
Matrix3.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(scale, 'scale');
Check.typeOf.number('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -433,7 +433,7 @@ define([
*/
Matrix3.fromCrossProduct = function(vector, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(vector, 'vector');
Check.typeOf.object('vector', vector);
//>>includeEnd('debug');
if (!defined(result)) {
@ -470,7 +470,7 @@ define([
*/
Matrix3.fromRotationX = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(angle, 'angle');
Check.typeOf.number('angle', angle);
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@ -511,7 +511,7 @@ define([
*/
Matrix3.fromRotationY = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(angle, 'angle');
Check.typeOf.number('angle', angle);
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@ -552,7 +552,7 @@ define([
*/
Matrix3.fromRotationZ = function(angle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(angle, 'angle');
Check.typeOf.number('angle', angle);
//>>includeEnd('debug');
var cosAngle = Math.cos(angle);
@ -588,7 +588,7 @@ define([
*/
Matrix3.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
if (!defined(result)) {
@ -624,12 +624,10 @@ define([
*/
Matrix3.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(column, 'column');
Check.typeOf.number(row, 'row');
Check.numeric.minimum(row, 0);
Check.numeric.maximum(row, 2);
Check.numeric.minimum(column, 0);
Check.numeric.maximum(column, 2);
Check.typeOf.number.greaterThanOrEquals('row', row, 0);
Check.typeOf.number.lessThanOrEquals('row', row, 2);
Check.typeOf.number.greaterThanOrEquals('column', column, 0);
Check.typeOf.number.lessThanOrEquals('column', column, 2);
//>>includeEnd('debug');
return column * 3 + row;
@ -647,11 +645,10 @@ define([
*/
Matrix3.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 2);
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 2);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var startIndex = index * 3;
@ -678,12 +675,11 @@ define([
*/
Matrix3.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 2);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 2);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix3.clone(matrix, result);
@ -706,11 +702,10 @@ define([
*/
Matrix3.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 2);
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 2);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = matrix[index];
@ -736,12 +731,11 @@ define([
*/
Matrix3.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 2);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 2);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix3.clone(matrix, result);
@ -762,8 +756,8 @@ define([
*/
Matrix3.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Cartesian3.magnitude(Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn));
@ -796,9 +790,9 @@ define([
*/
Matrix3.multiply = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = left[0] * right[0] + left[3] * right[1] + left[6] * right[2];
@ -835,9 +829,9 @@ define([
*/
Matrix3.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@ -862,9 +856,9 @@ define([
*/
Matrix3.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@ -889,9 +883,9 @@ define([
*/
Matrix3.multiplyByVector = function(matrix, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var vX = cartesian.x;
@ -918,9 +912,9 @@ define([
*/
Matrix3.multiplyByScalar = function(matrix, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@ -953,9 +947,9 @@ define([
*/
Matrix3.multiplyByScale = function(matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(scale, 'scale');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('scale', scale);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0] * scale.x;
@ -979,8 +973,8 @@ define([
*/
Matrix3.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = -matrix[0];
@ -1004,8 +998,8 @@ define([
*/
Matrix3.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = matrix[0];
@ -1147,7 +1141,7 @@ define([
*/
Matrix3.computeEigenDecomposition = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
// This routine was created based upon Matrix Computations, 3rd ed., by Golub and Van Loan,
@ -1193,8 +1187,8 @@ define([
*/
Matrix3.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@ -1218,7 +1212,7 @@ define([
*/
Matrix3.determinant = function(matrix) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
var m11 = matrix[0];
@ -1245,8 +1239,8 @@ define([
*/
Matrix3.inverse = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var m11 = matrix[0];
@ -1316,7 +1310,7 @@ define([
*/
Matrix3.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(epsilon, 'epsilon');
Check.typeOf.number('epsilon', epsilon);
//>>includeEnd('debug');
return (left === right) ||

View File

@ -106,8 +106,8 @@ define([
*/
Matrix4.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -142,7 +142,7 @@ define([
*/
Matrix4.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -240,7 +240,7 @@ define([
*/
Matrix4.fromColumnMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
return Matrix4.clone(values, result);
@ -256,7 +256,7 @@ define([
*/
Matrix4.fromRowMajorArray = function(values, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(values, 'values');
Check.defined('values', values);
//>>includeEnd('debug');
if (!defined(result)) {
@ -295,7 +295,7 @@ define([
*/
Matrix4.fromRotationTranslation = function(rotation, translation, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rotation, 'rotation');
Check.typeOf.object('rotation', rotation);
//>>includeEnd('debug');
translation = defaultValue(translation, Cartesian3.ZERO);
@ -345,9 +345,9 @@ define([
*/
Matrix4.fromTranslationQuaternionRotationScale = function(translation, rotation, scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(translation, 'translation');
Check.typeOf.object(rotation, 'rotation');
Check.typeOf.object(scale, 'scale');
Check.typeOf.object('translation', translation);
Check.typeOf.object('rotation', rotation);
Check.typeOf.object('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -410,7 +410,7 @@ define([
*/
Matrix4.fromTranslationRotationScale = function(translationRotationScale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(translationRotationScale, 'translationRotationScale');
Check.typeOf.object('translationRotationScale', translationRotationScale);
//>>includeEnd('debug');
return Matrix4.fromTranslationQuaternionRotationScale(translationRotationScale.translation, translationRotationScale.rotation, translationRotationScale.scale, result);
@ -427,7 +427,7 @@ define([
*/
Matrix4.fromTranslation = function(translation, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(translation, 'translation');
Check.typeOf.object('translation', translation);
//>>includeEnd('debug');
return Matrix4.fromRotationTranslation(Matrix3.IDENTITY, translation, result);
@ -450,7 +450,7 @@ define([
*/
Matrix4.fromScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(scale, 'scale');
Check.typeOf.object('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -497,7 +497,7 @@ define([
*/
Matrix4.fromUniformScale = function(scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(scale, 'scale');
Check.typeOf.number('scale', scale);
//>>includeEnd('debug');
if (!defined(result)) {
@ -539,7 +539,7 @@ define([
*/
Matrix4.fromCamera = function(camera, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(camera, 'camera');
Check.typeOf.object('camera', camera);
//>>includeEnd('debug');
var position = camera.position;
@ -547,9 +547,9 @@ define([
var up = camera.up;
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(position, 'camera.position');
Check.typeOf.object(direction, 'camera.direction');
Check.typeOf.object(up, 'camera.up');
Check.typeOf.object('camera.position', position);
Check.typeOf.object('camera.direction', direction);
Check.typeOf.object('camera.up', up);
//>>includeEnd('debug');
Cartesian3.normalize(direction, fromCameraF);
@ -630,19 +630,11 @@ define([
*/
Matrix4.computePerspectiveFieldOfView = function(fovY, aspectRatio, near, far, result) {
//>>includeStart('debug', pragmas.debug);
if (fovY <= 0.0 || fovY > Math.PI) {
throw new DeveloperError('fovY must be in (0, PI].');
}
if (aspectRatio <= 0.0) {
throw new DeveloperError('aspectRatio must be greater than zero.');
}
if (near <= 0.0) {
throw new DeveloperError('near must be greater than zero.');
}
if (far <= 0.0) {
throw new DeveloperError('far must be greater than zero.');
}
Check.typeOf.object(result, 'result');
Check.typeOf.number.greaterThan('fovY', fovY, 0.0);
Check.typeOf.number.lessThan('fovY', fovY, Math.PI);
Check.typeOf.number.greaterThan('near', near, 0.0);
Check.typeOf.number.greaterThan('far', far, 0.0);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var bottom = Math.tan(fovY * 0.5);
@ -685,13 +677,13 @@ define([
*/
Matrix4.computeOrthographicOffCenter = function(left, right, bottom, top, near, far, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(left, 'left');
Check.typeOf.number(right, 'right');
Check.typeOf.number(bottom, 'bottom');
Check.typeOf.number(top, 'top');
Check.typeOf.number(near, 'near');
Check.typeOf.number(far, 'far');
Check.typeOf.object(result, 'result');
Check.typeOf.number('left', left);
Check.typeOf.number('right', right);
Check.typeOf.number('bottom', bottom);
Check.typeOf.number('top', top);
Check.typeOf.number('near', near);
Check.typeOf.number('far', far);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var a = 1.0 / (right - left);
@ -738,13 +730,13 @@ define([
*/
Matrix4.computePerspectiveOffCenter = function(left, right, bottom, top, near, far, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(left, 'left');
Check.typeOf.number(right, 'right');
Check.typeOf.number(bottom, 'bottom');
Check.typeOf.number(top, 'top');
Check.typeOf.number(near, 'near');
Check.typeOf.number(far, 'far');
Check.typeOf.object(result, 'result');
Check.typeOf.number('left', left);
Check.typeOf.number('right', right);
Check.typeOf.number('bottom', bottom);
Check.typeOf.number('top', top);
Check.typeOf.number('near', near);
Check.typeOf.number('far', far);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = 2.0 * near / (right - left);
@ -787,12 +779,12 @@ define([
*/
Matrix4.computeInfinitePerspectiveOffCenter = function(left, right, bottom, top, near, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(left, 'left');
Check.typeOf.number(right, 'right');
Check.typeOf.number(bottom, 'bottom');
Check.typeOf.number(top, 'top');
Check.typeOf.number(near, 'near');
Check.typeOf.object(result, 'result');
Check.typeOf.number('left', left);
Check.typeOf.number('right', right);
Check.typeOf.number('bottom', bottom);
Check.typeOf.number('top', top);
Check.typeOf.number('near', near);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var column0Row0 = 2.0 * near / (right - left);
@ -842,7 +834,7 @@ define([
*/
Matrix4.computeViewportTransformation = function(viewport, nearDepthRange, farDepthRange, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
viewport = defaultValue(viewport, defaultValue.EMPTY_OBJECT);
@ -896,11 +888,11 @@ define([
*/
Matrix4.computeView = function(position, direction, up, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(position, 'position');
Check.typeOf.object(direction, 'direction');
Check.typeOf.object(up, 'up');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('position', position);
Check.typeOf.object('direction', direction);
Check.typeOf.object('up', up);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = right.x;
@ -943,7 +935,7 @@ define([
*/
Matrix4.toArray = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
if (!defined(result)) {
@ -989,13 +981,11 @@ define([
*/
Matrix4.getElementIndex = function(column, row) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(row, 'row');
Check.numeric.minimum(row, 0);
Check.numeric.maximum(row, 3);
Check.typeOf.number.greaterThanOrEquals('row', row, 0);
Check.typeOf.number.lessThanOrEquals('row', row, 3);
Check.typeOf.number(column, 'column');
Check.numeric.minimum(column, 0);
Check.numeric.maximum(column, 3);
Check.typeOf.number.greaterThanOrEquals('column', column, 0);
Check.typeOf.number.lessThanOrEquals('column', column, 3);
//>>includeEnd('debug');
return column * 4 + row;
@ -1030,13 +1020,12 @@ define([
*/
Matrix4.getColumn = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 3);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 3);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var startIndex = index * 4;
@ -1080,14 +1069,13 @@ define([
*/
Matrix4.setColumn = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 3);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 3);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix4.clone(matrix, result);
@ -1110,9 +1098,9 @@ define([
*/
Matrix4.setTranslation = function(matrix, translation, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(translation, 'translation');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('translation', translation);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0];
@ -1167,13 +1155,12 @@ define([
*/
Matrix4.getRow = function(matrix, index, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 3);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 3);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = matrix[index];
@ -1216,14 +1203,13 @@ define([
*/
Matrix4.setRow = function(matrix, index, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number(index, 'index');
Check.numeric.minimum(index, 0);
Check.numeric.maximum(index, 3);
Check.typeOf.number.greaterThanOrEquals('index', index, 0);
Check.typeOf.number.lessThanOrEquals('index', index, 3);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result = Matrix4.clone(matrix, result);
@ -1245,8 +1231,8 @@ define([
*/
Matrix4.getScale = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Cartesian3.magnitude(Cartesian3.fromElements(matrix[0], matrix[1], matrix[2], scratchColumn));
@ -1280,9 +1266,9 @@ define([
*/
Matrix4.multiply = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var left0 = left[0];
@ -1368,9 +1354,9 @@ define([
*/
Matrix4.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] + right[0];
@ -1402,9 +1388,9 @@ define([
*/
Matrix4.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = left[0] - right[0];
@ -1447,9 +1433,9 @@ define([
*/
Matrix4.multiplyTransformation = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var left0 = left[0];
@ -1529,9 +1515,9 @@ define([
*/
Matrix4.multiplyByMatrix3 = function(matrix, rotation, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(rotation, 'rotation');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('rotation', rotation);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var left0 = matrix[0];
@ -1601,9 +1587,9 @@ define([
*/
Matrix4.multiplyByTranslation = function(matrix, translation, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(translation, 'translation');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('translation', translation);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = translation.x;
@ -1657,9 +1643,9 @@ define([
*/
Matrix4.multiplyByUniformScale = function(matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(scale, 'scale');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number('scale', scale);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
uniformScaleScratch.x = scale;
@ -1690,9 +1676,9 @@ define([
*/
Matrix4.multiplyByScale = function(matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(scale, 'scale');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('scale', scale);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var scaleX = scale.x;
@ -1733,9 +1719,9 @@ define([
*/
Matrix4.multiplyByVector = function(matrix, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var vX = cartesian.x;
@ -1773,9 +1759,9 @@ define([
*/
Matrix4.multiplyByPointAsVector = function(matrix, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var vX = cartesian.x;
@ -1807,9 +1793,9 @@ define([
*/
Matrix4.multiplyByPoint = function(matrix, cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var vX = cartesian.x;
@ -1851,9 +1837,9 @@ define([
*/
Matrix4.multiplyByScalar = function(matrix, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0] * scalar;
@ -1899,8 +1885,8 @@ define([
*/
Matrix4.negate = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = -matrix[0];
@ -1946,8 +1932,8 @@ define([
*/
Matrix4.transpose = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var matrix1 = matrix[1];
@ -1985,8 +1971,8 @@ define([
*/
Matrix4.abs = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = Math.abs(matrix[0]);
@ -2102,7 +2088,7 @@ define([
*/
Matrix4.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(epsilon, 'epsilon');
Check.typeOf.number('epsilon', epsilon);
//>>includeEnd('debug');
return (left === right) ||
@ -2135,8 +2121,8 @@ define([
*/
Matrix4.getTranslation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = matrix[12];
@ -2169,8 +2155,8 @@ define([
*/
Matrix4.getRotation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result[0] = matrix[0];
@ -2204,8 +2190,8 @@ define([
*/
Matrix4.inverse = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
// Special case for a zero scale matrix that can occur, for example,
@ -2345,8 +2331,8 @@ define([
*/
Matrix4.inverseTransformation = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object(result, 'result');
Check.typeOf.object('matrix', matrix);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
//This function is an optimized version of the below 4 lines.

View File

@ -75,8 +75,8 @@ define([
*/
Quaternion.fromAxisAngle = function(axis, angle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(axis, 'axis');
Check.typeOf.number(angle, 'angle');
Check.typeOf.object('axis', axis);
Check.typeOf.number('angle', angle);
//>>includeEnd('debug');
var halfAngle = angle / 2.0;
@ -110,7 +110,7 @@ define([
*/
Quaternion.fromRotationMatrix = function(matrix, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(matrix, 'matrix');
Check.typeOf.object('matrix', matrix);
//>>includeEnd('debug');
var root;
@ -186,9 +186,9 @@ define([
*/
Quaternion.fromHeadingPitchRoll = function(heading, pitch, roll, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(heading, 'heading');
Check.typeOf.number(pitch, 'pitch');
Check.typeOf.number(roll, 'roll');
Check.typeOf.number('heading', heading);
Check.typeOf.number('pitch', pitch);
Check.typeOf.number('roll', roll);
//>>includeEnd('debug');
var rollQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_X, roll, scratchHPRQuaternion);
@ -221,8 +221,8 @@ define([
*/
Quaternion.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -245,7 +245,7 @@ define([
*/
Quaternion.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -356,8 +356,8 @@ define([
*/
Quaternion.conjugate = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -quaternion.x;
@ -375,7 +375,7 @@ define([
*/
Quaternion.magnitudeSquared = function(quaternion) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object('quaternion', quaternion);
//>>includeEnd('debug');
return quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z + quaternion.w * quaternion.w;
@ -400,7 +400,7 @@ define([
*/
Quaternion.normalize = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var inverseMagnitude = 1.0 / Quaternion.magnitude(quaternion);
@ -425,7 +425,7 @@ define([
*/
Quaternion.inverse = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(result, 'result');
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var magnitudeSquared = Quaternion.magnitudeSquared(quaternion);
@ -443,9 +443,9 @@ define([
*/
Quaternion.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x + right.x;
@ -465,9 +465,9 @@ define([
*/
Quaternion.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x - right.x;
@ -486,8 +486,8 @@ define([
*/
Quaternion.negate = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -quaternion.x;
@ -506,8 +506,8 @@ define([
*/
Quaternion.dot = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
@ -523,9 +523,9 @@ define([
*/
Quaternion.multiply = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(left, 'left');
Check.typeOf.object(right, 'right');
Check.typeOf.object(result, 'result');
Check.typeOf.object('left', left);
Check.typeOf.object('right', right);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var leftX = left.x;
@ -560,9 +560,9 @@ define([
*/
Quaternion.multiplyByScalar = function(quaternion, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = quaternion.x * scalar;
@ -582,9 +582,9 @@ define([
*/
Quaternion.divideByScalar = function(quaternion, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.number(scalar, 'scalar');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.number('scalar', scalar);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = quaternion.x / scalar;
@ -603,8 +603,8 @@ define([
*/
Quaternion.computeAxis = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var w = quaternion.w;
@ -629,7 +629,7 @@ define([
*/
Quaternion.computeAngle = function(quaternion) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object('quaternion', quaternion);
//>>includeEnd('debug');
if (Math.abs(quaternion.w - 1.0) < CesiumMath.EPSILON6) {
@ -650,10 +650,10 @@ define([
*/
Quaternion.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
lerpScratch = Quaternion.multiplyByScalar(end, t, lerpScratch);
@ -677,10 +677,10 @@ define([
*/
Quaternion.slerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var dot = Quaternion.dot(start, end);
@ -715,8 +715,8 @@ define([
*/
Quaternion.log = function(quaternion, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(quaternion, 'quaternion');
Check.typeOf.object(result, 'result');
Check.typeOf.object('quaternion', quaternion);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var theta = CesiumMath.acosClamped(quaternion.w);
@ -738,8 +738,8 @@ define([
*/
Quaternion.exp = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian, 'cartesian');
Check.typeOf.object(result, 'result');
Check.typeOf.object('cartesian', cartesian);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var theta = Cartesian3.magnitude(cartesian);
@ -776,10 +776,10 @@ define([
*/
Quaternion.computeInnerQuadrangle = function(q0, q1, q2, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(q0, 'q0');
Check.typeOf.object(q1, 'q1');
Check.typeOf.object(q2, 'q2');
Check.typeOf.object(result, 'result');
Check.typeOf.object('q0', q0);
Check.typeOf.object('q1', q1);
Check.typeOf.object('q2', q2);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var qInv = Quaternion.conjugate(q1, squadScratchQuaternion0);
@ -823,12 +823,12 @@ define([
*/
Quaternion.squad = function(q0, q1, s0, s1, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(q0, 'q0');
Check.typeOf.object(q1, 'q1');
Check.typeOf.object(s0, 's0');
Check.typeOf.object(s1, 's1');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('q0', q0);
Check.typeOf.object('q1', q1);
Check.typeOf.object('s0', s0);
Check.typeOf.object('s1', s1);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var slerp0 = Quaternion.slerp(q0, q1, t, squadScratchQuaternion0);
@ -867,10 +867,10 @@ define([
*/
Quaternion.fastSlerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(start, 'start');
Check.typeOf.object(end, 'end');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('start', start);
Check.typeOf.object('end', end);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = Quaternion.dot(start, end);
@ -921,12 +921,12 @@ define([
*/
Quaternion.fastSquad = function(q0, q1, s0, s1, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(q0, 'q0');
Check.typeOf.object(q1, 'q1');
Check.typeOf.object(s0, 's0');
Check.typeOf.object(s1, 's1');
Check.typeOf.number(t, 't');
Check.typeOf.object(result, 'result');
Check.typeOf.object('q0', q0);
Check.typeOf.object('q1', q1);
Check.typeOf.object('s0', s0);
Check.typeOf.object('s1', s1);
Check.typeOf.number('t', t);
Check.typeOf.object('result', result);
//>>includeEnd('debug');
var slerp0 = Quaternion.fastSlerp(q0, q1, t, squadScratchQuaternion0);
@ -964,7 +964,7 @@ define([
*/
Quaternion.equalsEpsilon = function(left, right, epsilon) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(epsilon, 'epsilon');
Check.typeOf.number('epsilon', epsilon);
//>>includeEnd('debug');
return (left === right) ||

View File

@ -109,8 +109,8 @@ define([
*/
Rectangle.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.defined(array, 'array');
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -133,7 +133,7 @@ define([
*/
Rectangle.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(array, 'array');
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -156,7 +156,7 @@ define([
*/
Rectangle.computeWidth = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
var east = rectangle.east;
var west = rectangle.west;
@ -173,7 +173,7 @@ define([
*/
Rectangle.computeHeight = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
return rectangle.north - rectangle.south;
};
@ -209,6 +209,32 @@ define([
return result;
};
/**
* Creates an rectangle given the boundary longitude and latitude in radians.
*
* @param {Number} [west=0.0] The westernmost longitude in radians in the range [-Math.PI, Math.PI].
* @param {Number} [south=0.0] The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
* @param {Number} [east=0.0] The easternmost longitude in radians in the range [-Math.PI, Math.PI].
* @param {Number} [north=0.0] The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
* @param {Rectangle} [result] The object onto which to store the result, or undefined if a new instance should be created.
* @returns {Rectangle} The modified result parameter or a new Rectangle instance if none was provided.
*
* @example
* var rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);
*/
Rectangle.fromRadians = function(west, south, east, north, result) {
if (!defined(result)) {
return new Rectangle(west, south, east, north);
}
result.west = defaultValue(west, 0.0);
result.south = defaultValue(south, 0.0);
result.east = defaultValue(east, 0.0);
result.north = defaultValue(north, 0.0);
return result;
};
/**
* Creates the smallest possible Rectangle that encloses all positions in the provided array.
*
@ -218,7 +244,7 @@ define([
*/
Rectangle.fromCartographicArray = function(cartographics, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(cartographics, 'cartographics');
Check.defined('cartographics', cartographics);
//>>includeEnd('debug');
var west = Number.MAX_VALUE;
@ -273,7 +299,7 @@ define([
*/
Rectangle.fromCartesianArray = function(cartesians, ellipsoid, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined(cartesians, 'cartesians');
Check.defined('cartesians', cartesians);
//>>includeEnd('debug');
var west = Number.MAX_VALUE;
@ -391,7 +417,7 @@ define([
*/
Rectangle.prototype.equalsEpsilon = function(other, epsilon) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.number(epsilon, 'epsilon');
Check.typeOf.number('epsilon', epsilon);
//>>includeEnd('debug');
return defined(other) &&
@ -413,27 +439,23 @@ define([
*/
Rectangle.validate = function(rectangle) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
var north = rectangle.north;
Check.typeOf.number(north, 'north');
Check.numeric.minimum(north, -CesiumMath.PI_OVER_TWO);
Check.numeric.maximum(north, CesiumMath.PI_OVER_TWO);
Check.typeOf.number.greaterThanOrEquals('north', north, -CesiumMath.PI_OVER_TWO);
Check.typeOf.number.lessThanOrEquals('north', north, CesiumMath.PI_OVER_TWO);
var south = rectangle.south;
Check.typeOf.number(south, 'south');
Check.numeric.minimum(south, -CesiumMath.PI_OVER_TWO);
Check.numeric.maximum(south, CesiumMath.PI_OVER_TWO);
Check.typeOf.number.greaterThanOrEquals('south', south, -CesiumMath.PI_OVER_TWO);
Check.typeOf.number.lessThanOrEquals('south', south, CesiumMath.PI_OVER_TWO);
var west = rectangle.west;
Check.typeOf.number(west, 'west');
Check.numeric.minimum(west, -Math.PI);
Check.numeric.maximum(west, Math.PI);
Check.typeOf.number.greaterThanOrEquals('west', west, -Math.PI);
Check.typeOf.number.lessThanOrEquals('west', west, Math.PI);
var east = rectangle.east;
Check.typeOf.number(east, 'east');
Check.numeric.minimum(east, -Math.PI);
Check.numeric.maximum(east, Math.PI);
Check.typeOf.number.greaterThanOrEquals('east', east, -Math.PI);
Check.typeOf.number.lessThanOrEquals('east', east, Math.PI);
//>>includeEnd('debug');
};
@ -446,7 +468,7 @@ define([
*/
Rectangle.southwest = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
if (!defined(result)) {
@ -467,7 +489,7 @@ define([
*/
Rectangle.northwest = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
if (!defined(result)) {
@ -488,7 +510,7 @@ define([
*/
Rectangle.northeast = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
if (!defined(result)) {
@ -509,7 +531,7 @@ define([
*/
Rectangle.southeast = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
if (!defined(result)) {
@ -530,7 +552,7 @@ define([
*/
Rectangle.center = function(rectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
var east = rectangle.east;
@ -567,8 +589,8 @@ define([
*/
Rectangle.intersection = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(otherRectangle, 'otherRectangle');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('otherRectangle', otherRectangle);
//>>includeEnd('debug');
var rectangleEast = rectangle.east;
@ -626,8 +648,8 @@ define([
*/
Rectangle.simpleIntersection = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(otherRectangle, 'otherRectangle');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('otherRectangle', otherRectangle);
//>>includeEnd('debug');
var west = Math.max(rectangle.west, otherRectangle.west);
@ -660,8 +682,8 @@ define([
*/
Rectangle.union = function(rectangle, otherRectangle, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(otherRectangle, 'otherRectangle');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('otherRectangle', otherRectangle);
//>>includeEnd('debug');
if (!defined(result)) {
@ -707,8 +729,8 @@ define([
*/
Rectangle.expand = function(rectangle, cartographic, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(cartographic, 'cartographic');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('cartographic', cartographic);
//>>includeEnd('debug');
if (!defined(result)) {
@ -732,8 +754,8 @@ define([
*/
Rectangle.contains = function(rectangle, cartographic) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object(cartographic, 'cartographic');
Check.typeOf.object('rectangle', rectangle);
Check.typeOf.object('cartographic', cartographic);
//>>includeEnd('debug');
var longitude = cartographic.longitude;
@ -768,7 +790,7 @@ define([
*/
Rectangle.subsample = function(rectangle, ellipsoid, surfaceHeight, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(rectangle, 'rectangle');
Check.typeOf.object('rectangle', rectangle);
//>>includeEnd('debug');
ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);

View File

@ -4,6 +4,7 @@ define([
'./Cartesian2',
'./Cartesian3',
'./Cartographic',
'./Check',
'./ComponentDatatype',
'./defaultValue',
'./defined',
@ -30,6 +31,7 @@ define([
Cartesian2,
Cartesian3,
Cartographic,
Check,
ComponentDatatype,
defaultValue,
defined,
@ -647,12 +649,10 @@ define([
var rectangle = options.rectangle;
//>>includeStart('debug', pragmas.debug);
if (!defined(rectangle)) {
throw new DeveloperError('rectangle is required.');
}
Check.typeOf.object('rectangle', rectangle);
Rectangle.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError('options.rectangle.north must be greater than options.rectangle.south');
throw new DeveloperError('options.rectangle.north must be greater than or equal to options.rectangle.south');
}
//>>includeEnd('debug');
@ -690,13 +690,8 @@ define([
*/
RectangleGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!defined(value)) {
throw new DeveloperError('value is required');
}
if (!defined(array)) {
throw new DeveloperError('array is required');
}
Check.typeOf.object('value', value);
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);
@ -753,9 +748,7 @@ define([
*/
RectangleGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(array)) {
throw new DeveloperError('array is required');
}
Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = defaultValue(startingIndex, 0);

View File

@ -4,6 +4,7 @@ define([
'./Cartesian2',
'./defaultValue',
'./defined',
'./deprecationWarning',
'./destroyObject',
'./DeveloperError',
'./FeatureDetection',
@ -15,6 +16,7 @@ define([
Cartesian2,
defaultValue,
defined,
deprecationWarning,
destroyObject,
DeveloperError,
FeatureDetection,
@ -483,7 +485,7 @@ define([
action(touch2StartEvent);
// Touch-enabled devices, in particular iOS can have many default behaviours for
// Touch-enabled devices, in particular iOS can have many default behaviours for
// "pinch" events, which can still be executed unless we prevent them here.
event.preventDefault();
}
@ -684,6 +686,14 @@ define([
registerListeners(this);
}
function checkForDoubleClick(type) {
if (type === ScreenSpaceEventType.MIDDLE_DOUBLE_CLICK) {
deprecationWarning('MIDDLE_DOUBLE_CLICK', 'ScreenSpaceEventType.MIDDLE_DOUBLE_CLICK was deprecated in Cesium 1.30. It will be removed in 1.31.');
} else if (type === ScreenSpaceEventType.RIGHT_DOUBLE_CLICK) {
deprecationWarning('RIGHT_DOUBLE_CLICK', 'ScreenSpaceEventType.RIGHT_DOUBLE_CLICK was deprecated in Cesium 1.30. It will be removed in 1.31.');
}
}
/**
* Set a function to be executed on an input event.
*
@ -705,6 +715,8 @@ define([
}
//>>includeEnd('debug');
checkForDoubleClick(type);
var key = getInputEventKey(type, modifier);
this._inputEvents[key] = action;
};
@ -726,6 +738,8 @@ define([
}
//>>includeEnd('debug');
checkForDoubleClick(type);
var key = getInputEventKey(type, modifier);
return this._inputEvents[key];
};
@ -747,6 +761,8 @@ define([
}
//>>includeEnd('debug');
checkForDoubleClick(type);
var key = getInputEventKey(type, modifier);
delete this._inputEvents[key];
};

View File

@ -72,6 +72,8 @@ define([
*
* @type {Number}
* @constant
*
* @deprecated
*/
RIGHT_DOUBLE_CLICK : 8,
@ -104,6 +106,8 @@ define([
*
* @type {Number}
* @constant
*
* @deprecated
*/
MIDDLE_DOUBLE_CLICK : 13,

View File

@ -72,7 +72,7 @@ define([
*/
SphereGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.typeOf.object('value', value);
//>>includeEnd('debug');
return EllipsoidGeometry.pack(value._ellipsoidGeometry, array, startingIndex);

View File

@ -70,7 +70,7 @@ define([
*/
SphereOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(value, 'value');
Check.typeOf.object('value', value);
//>>includeEnd('debug');
return EllipsoidOutlineGeometry.pack(value._ellipsoidGeometry, array, startingIndex);

View File

@ -36,7 +36,7 @@ define([
*/
Spherical.fromCartesian3 = function(cartesian3, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(cartesian3, 'cartesian3');
Check.typeOf.object('cartesian3', cartesian3);
//>>includeEnd('debug');
var x = cartesian3.x;
@ -85,7 +85,7 @@ define([
*/
Spherical.normalize = function(spherical, result) {
//>>includeStart('debug', pragmas.debug);
Check.typeOf.object(spherical, 'spherical');
Check.typeOf.object('spherical', spherical);
//>>includeEnd('debug');
if (!defined(result)) {

View File

@ -99,6 +99,18 @@ define([
*/
hasVertexNormals : {
get : DeveloperError.throwInstantiationError
},
/**
* Gets an object that can be used to determine availability of terrain from this provider, such as
* at points and in rectangles. This function should not be called before
* {@link TerrainProvider#ready} returns true. This property may be undefined if availability
* information is not available.
* @memberof TerrainProvider.prototype
* @type {TileAvailability}
*/
availability : {
get : DeveloperError.throwInstantiationError
}
});

View File

@ -0,0 +1,434 @@
/*global define*/
define([
'../ThirdParty/when',
'./binarySearch',
'./Cartographic',
'./defined',
'./sampleTerrain',
'./DeveloperError',
'./Rectangle'
], function(
when,
binarySearch,
Cartographic,
defined,
sampleTerrain,
DeveloperError,
Rectangle) {
"use strict";
/**
* Reports the availability of tiles in a {@link TilingScheme}.
*
* @alias TileAvailability
* @constructor
*
* @param {TilingScheme} tilingScheme The tiling scheme in which to report availability.
* @param {Number} maximumLevel The maximum tile level that is potentially available.
*/
function TileAvailability(tilingScheme, maximumLevel) {
this._tilingScheme = tilingScheme;
this._maximumLevel = maximumLevel;
this._rootNodes = [];
for (var y = 0; y < tilingScheme.getNumberOfYTilesAtLevel(); ++y) {
for (var x = 0; x < tilingScheme.getNumberOfXTilesAtLevel(); ++x) {
this._rootNodes.push(new QuadtreeNode(tilingScheme, undefined, 0, x, y));
}
}
}
var rectangleScratch = new Rectangle();
/**
* Marks a rectangular range of tiles in a particular level as being available. For best performance,
* add your ranges in order of increasing level.
*
* @param {Number} level The level.
* @param {Number} startX The X coordinate of the first available tiles at the level.
* @param {Number} startY The Y coordinate of the first available tiles at the level.
* @param {Number} endX The X coordinate of the last available tiles at the level.
* @param {Number} endY The Y coordinate of the last available tiles at the level.
*/
TileAvailability.prototype.addAvailableTileRange = function(level, startX, startY, endX, endY) {
var tilingScheme = this._tilingScheme;
tilingScheme.tileXYToRectangle(startX, startY, level, rectangleScratch);
var west = rectangleScratch.west;
var north = rectangleScratch.north;
tilingScheme.tileXYToRectangle(endX, endY, level, rectangleScratch);
var east = rectangleScratch.east;
var south = rectangleScratch.south;
var rectangleWithLevel = new RectangleWithLevel(level, west, south, east, north);
for (var i = 0; i < this._rootNodes.length; ++i) {
var rootNode = this._rootNodes[i];
if (rectanglesOverlap(rootNode.extent, rectangleWithLevel)) {
putRectangleInQuadtree(this._maximumLevel, rootNode, rectangleWithLevel);
}
}
};
/**
* Determines the level of the most detailed tile covering the position. This function
* usually completes in time logarithmic to the number of rectangles added with
* {@link TileAvailability#addAvailableTileRange}.
*
* @param {Cartographic} position The position for which to determine the maximum available level. The height component is ignored.
* @return {Number} The level of the most detailed tile covering the position.
* @throws {DeveloperError} If position is outside any tile according to the tiling scheme.
*/
TileAvailability.prototype.computeMaximumLevelAtPosition = function(position) {
// Find the root node that contains this position.
var node;
for (var nodeIndex = 0; nodeIndex < this._rootNodes.length; ++nodeIndex) {
var rootNode = this._rootNodes[nodeIndex];
if (rectangleContainsPosition(rootNode.extent, position)) {
node = rootNode;
break;
}
}
//>>includeStart('debug', pragmas.debug);
if (!defined(node)) {
throw new DeveloperError('The specified position does not exist in any root node of the tiling scheme.');
}
//>>includeEnd('debug');
return findMaxLevelFromNode(undefined, node, position);
};
var rectanglesScratch = [];
var remainingToCoverByLevelScratch = [];
var westScratch = new Rectangle();
var eastScratch = new Rectangle();
/**
* Finds the most detailed level that is available _everywhere_ within a given rectangle. More detailed
* tiles may be available in parts of the rectangle, but not the whole thing. The return value of this
* function may be safely passed to {@link sampleTerrain} for any position within the rectangle. This function
* usually completes in time logarithmic to the number of rectangles added with
* {@link TileAvailability#addAvailableTileRange}.
*
* @param {Rectangle} rectangle The rectangle.
* @return {Number} The best available level for the entire rectangle.
*/
TileAvailability.prototype.computeBestAvailableLevelOverRectangle = function(rectangle) {
var rectangles = rectanglesScratch;
rectangles.length = 0;
if (rectangle.east < rectangle.west) {
// Rectangle crosses the IDL, make it two rectangles.
rectangles.push(Rectangle.fromRadians(-Math.PI, rectangle.south, rectangle.east, rectangle.north, westScratch));
rectangles.push(Rectangle.fromRadians(rectangle.west, rectangle.south, Math.PI, rectangle.north, eastScratch));
} else {
rectangles.push(rectangle);
}
var remainingToCoverByLevel = remainingToCoverByLevelScratch;
remainingToCoverByLevel.length = 0;
var i;
for (i = 0; i < this._rootNodes.length; ++i) {
updateCoverageWithNode(remainingToCoverByLevel, this._rootNodes[i], rectangles);
}
for (i = remainingToCoverByLevel.length - 1; i >= 0; --i) {
if (defined(remainingToCoverByLevel[i]) && remainingToCoverByLevel[i].length === 0) {
return i;
}
}
return 0;
};
var cartographicScratch = new Cartographic();
/**
* Determines if a particular tile is available.
* @param {Number} level The tile level to check.
* @param {Number} x The X coordinate of the tile to check.
* @param {Number} y The Y coordinate of the tile to check.
* @return {Boolean} True if the tile is available; otherwise, false.
*/
TileAvailability.prototype.isTileAvailable = function(level, x, y) {
// Get the center of the tile and find the maximum level at that position.
// Because availability is by tile, if the level is available at that point, it
// is sure to be available for the whole tile. We assume that if a tile at level n exists,
// then all its parent tiles back to level 0 exist too. This isn't really enforced
// anywhere, but Cesium would never load a tile for which this is not true.
var rectangle = this._tilingScheme.tileXYToRectangle(x, y, level, rectangleScratch);
Rectangle.center(rectangle, cartographicScratch);
return this.computeMaximumLevelAtPosition(cartographicScratch) >= level;
};
/**
* Computes a bit mask indicating which of a tile's four children exist.
* If a child's bit is set, a tile is available for that child. If it is cleared,
* the tile is not available. The bit values are as follows:
* <table>
* <tr><th>Bit Position</th><th>Bit Value</th><th>Child Tile</th></tr>
* <tr><td>0</td><td>1</td><td>Southwest</td></tr>
* <tr><td>1</td><td>2</td><td>Southeast</td></tr>
* <tr><td>2</td><td>4</td><td>Northwest</td></tr>
* <tr><td>3</td><td>8</td><td>Northeast</td></tr>
* </table>
*
* @param {Number} level The level of the parent tile.
* @param {Number} x The X coordinate of the parent tile.
* @param {Number} y The Y coordinate of the parent tile.
* @return {Number} The bit mask indicating child availability.
*/
TileAvailability.prototype.computeChildMaskForTile = function(level, x, y) {
var childLevel = level + 1;
if (childLevel >= this._maximumLevel) {
return 0;
}
var mask = 0;
mask |= this.isTileAvailable(childLevel, 2 * x, 2 * y + 1) ? 1 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x + 1, 2 * y + 1) ? 2 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x, 2 * y) ? 4 : 0;
mask |= this.isTileAvailable(childLevel, 2 * x + 1, 2 * y) ? 8 : 0;
return mask;
};
function QuadtreeNode(tilingScheme, parent, level, x, y) {
this.tilingScheme = tilingScheme;
this.parent = parent;
this.level = level;
this.x = x;
this.y = y;
this.extent = tilingScheme.tileXYToRectangle(x, y, level);
this.rectangles = [];
this._sw = undefined;
this._se = undefined;
this._nw = undefined;
this._ne = undefined;
}
Object.defineProperties(QuadtreeNode.prototype, {
nw: {
get: function() {
if (!this._nw) {
this._nw = new QuadtreeNode(this.tilingScheme, this, this.level + 1, this.x * 2, this.y * 2);
}
return this._nw;
}
},
ne: {
get: function() {
if (!this._ne) {
this._ne = new QuadtreeNode(this.tilingScheme, this, this.level + 1, this.x * 2 + 1, this.y * 2);
}
return this._ne;
}
},
sw: {
get: function() {
if (!this._sw) {
this._sw = new QuadtreeNode(this.tilingScheme, this, this.level + 1, this.x * 2, this.y * 2 + 1);
}
return this._sw;
}
},
se: {
get: function() {
if (!this._se) {
this._se = new QuadtreeNode(this.tilingScheme, this, this.level + 1, this.x * 2 + 1, this.y * 2 + 1);
}
return this._se;
}
}
});
function RectangleWithLevel(level, west, south, east, north) {
this.level = level;
this.west = west;
this.south = south;
this.east = east;
this.north = north;
}
function rectanglesOverlap(rectangle1, rectangle2) {
var west = Math.max(rectangle1.west, rectangle2.west);
var south = Math.max(rectangle1.south, rectangle2.south);
var east = Math.min(rectangle1.east, rectangle2.east);
var north = Math.min(rectangle1.north, rectangle2.north);
return south < north && west < east;
}
function putRectangleInQuadtree(maxDepth, node, rectangle) {
while (node.level < maxDepth) {
if (rectangleFullyContainsRectangle(node.nw.extent, rectangle)) {
node = node.nw;
} else if (rectangleFullyContainsRectangle(node.ne.extent, rectangle)) {
node = node.ne;
} else if (rectangleFullyContainsRectangle(node.sw.extent, rectangle)) {
node = node.sw;
} else if (rectangleFullyContainsRectangle(node.se.extent, rectangle)) {
node = node.se;
} else {
break;
}
}
if (node.rectangles.length === 0 || node.rectangles[node.rectangles.length - 1].level <= rectangle.level) {
node.rectangles.push(rectangle);
} else {
// Maintain ordering by level when inserting.
var index = binarySearch(node.rectangles, rectangle.level, rectangleLevelComparator);
if (index <= 0) {
index = ~index;
}
node.rectangles.splice(index, 0, rectangle);
}
}
function rectangleLevelComparator(a, b) {
return a.level - b;
}
function rectangleFullyContainsRectangle(potentialContainer, rectangleToTest) {
return rectangleToTest.west >= potentialContainer.west &&
rectangleToTest.east <= potentialContainer.east &&
rectangleToTest.south >= potentialContainer.south &&
rectangleToTest.north <= potentialContainer.north;
}
function rectangleContainsPosition(potentialContainer, positionToTest) {
return positionToTest.longitude >= potentialContainer.west &&
positionToTest.longitude <= potentialContainer.east &&
positionToTest.latitude >= potentialContainer.south &&
positionToTest.latitude <= potentialContainer.north;
}
function findMaxLevelFromNode(stopNode, node, position) {
var maxLevel = 0;
// Find the deepest quadtree node containing this point.
while (true) {
var nw = node._nw && rectangleContainsPosition(node._nw.extent, position);
var ne = node._ne && rectangleContainsPosition(node._ne.extent, position);
var sw = node._sw && rectangleContainsPosition(node._sw.extent, position);
var se = node._se && rectangleContainsPosition(node._se.extent, position);
// The common scenario is that the point is in only one quadrant and we can simply
// iterate down the tree. But if the point is on a boundary between tiles, it is
// in multiple tiles and we need to check all of them, so use recursion.
if (nw + ne + sw + se > 1) {
if (nw) {
maxLevel = Math.max(maxLevel, findMaxLevelFromNode(node, node._nw, position));
}
if (ne) {
maxLevel = Math.max(maxLevel, findMaxLevelFromNode(node, node._ne, position));
}
if (sw) {
maxLevel = Math.max(maxLevel, findMaxLevelFromNode(node, node._sw, position));
}
if (se) {
maxLevel = Math.max(maxLevel, findMaxLevelFromNode(node, node._se, position));
}
break;
} else if (nw) {
node = node._nw;
} else if (ne) {
node = node._ne;
} else if (sw) {
node = node._sw;
} else if (se) {
node = node._se;
} else {
break;
}
}
// Work up the tree until we find a rectangle that contains this point.
while (node !== stopNode) {
var rectangles = node.rectangles;
// Rectangles are sorted by level, lowest first.
for (var i = rectangles.length - 1; i >= 0 && rectangles[i].level > maxLevel; --i) {
var rectangle = rectangles[i];
if (rectangleContainsPosition(rectangle, position)) {
maxLevel = rectangle.level;
}
}
node = node.parent;
}
return maxLevel;
}
function updateCoverageWithNode(remainingToCoverByLevel, node, rectanglesToCover) {
if (!node) {
return;
}
var i;
var anyOverlap = false;
for (i = 0; i < rectanglesToCover.length; ++i) {
anyOverlap = anyOverlap || rectanglesOverlap(node.extent, rectanglesToCover[i]);
}
if (!anyOverlap) {
// This node is not applicable to the rectangle(s).
return;
}
var rectangles = node.rectangles;
for (i = 0; i < rectangles.length; ++i) {
var rectangle = rectangles[i];
if (!remainingToCoverByLevel[rectangle.level]) {
remainingToCoverByLevel[rectangle.level] = rectanglesToCover;
}
remainingToCoverByLevel[rectangle.level] = subtractRectangle(remainingToCoverByLevel[rectangle.level], rectangle);
}
// Update with child nodes.
updateCoverageWithNode(remainingToCoverByLevel, node._nw, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._ne, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._sw, rectanglesToCover);
updateCoverageWithNode(remainingToCoverByLevel, node._se, rectanglesToCover);
}
function subtractRectangle(rectangleList, rectangleToSubtract) {
var result = [];
for (var i = 0; i < rectangleList.length; ++i) {
var rectangle = rectangleList[i];
if (!rectanglesOverlap(rectangle, rectangleToSubtract)) {
// Disjoint rectangles. Original rectangle is unmodified.
result.push(rectangle);
} else {
// rectangleToSubtract partially or completely overlaps rectangle.
if (rectangle.west < rectangleToSubtract.west) {
result.push(new Rectangle(rectangle.west, rectangle.south, rectangleToSubtract.west, rectangle.north));
}
if (rectangle.east > rectangleToSubtract.east) {
result.push(new Rectangle(rectangleToSubtract.east, rectangle.south, rectangle.east, rectangle.north));
}
if (rectangle.south < rectangleToSubtract.south) {
result.push(new Rectangle(Math.max(rectangleToSubtract.west, rectangle.west), rectangle.south, Math.min(rectangleToSubtract.east, rectangle.east), rectangleToSubtract.south));
}
if (rectangle.north > rectangleToSubtract.north) {
result.push(new Rectangle(Math.max(rectangleToSubtract.west, rectangle.west), rectangleToSubtract.north, Math.min(rectangleToSubtract.east, rectangle.east), rectangle.north));
}
}
}
return result;
}
return TileAvailability;
});

View File

@ -474,7 +474,7 @@ define([
* var transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);
*/
Transforms.headingPitchRollToFixedFrame = function(origin, headingPitchRoll, ellipsoid, result) {
Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
Check.typeOf.object('headingPitchRoll', headingPitchRoll);
var heading = headingPitchRoll.heading;
var pitch = headingPitchRoll.pitch;
var roll = headingPitchRoll.roll;
@ -512,7 +512,7 @@ define([
*/
Transforms.headingPitchRollQuaternion = function(origin, headingPitchRoll, ellipsoid, result) {
// checks for required parameters happen in the called functions
Check.typeOf.object(headingPitchRoll, 'headingPitchRoll');
Check.typeOf.object('headingPitchRoll', headingPitchRoll);
var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, scratchENUMatrix4);
var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3);
return Quaternion.fromRotationMatrix(rotation, result);
@ -1001,5 +1001,47 @@ define([
return result;
};
var swizzleMatrix = new Matrix4(
0.0, 0.0, 1.0, 0.0,
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 0.0, 1.0);
/**
* @private
*/
Transforms.wgs84To2DModelMatrix = function(projection, center, result) {
//>>includeStart('debug', pragmas.debug);
if (!defined(projection)) {
throw new DeveloperError('projection is required.');
}
if (!defined(center)) {
throw new DeveloperError('center is required.');
}
if (!defined(result)) {
throw new DeveloperError('result is required.');
}
//>>includeEnd('debug');
var ellipsoid = projection.ellipsoid;
var fromENU = Transforms.eastNorthUpToFixedFrame(center, ellipsoid, scratchFromENU);
var toENU = Matrix4.inverseTransformation(fromENU, scratchToENU);
var cartographic = ellipsoid.cartesianToCartographic(center, scratchCartographic);
var projectedPosition = projection.project(cartographic, scratchCartesian3Projection);
var newOrigin = scratchCartesian4NewOrigin;
newOrigin.x = projectedPosition.z;
newOrigin.y = projectedPosition.x;
newOrigin.z = projectedPosition.y;
newOrigin.w = 1.0;
var translation = Matrix4.fromTranslation(newOrigin, scratchFromENU);
Matrix4.multiply(swizzleMatrix, toENU, result);
Matrix4.multiply(translation, result, result);
return result;
};
return Transforms;
});

View File

@ -42,7 +42,7 @@ define([
if (!defined(warnings[identifier])) {
warnings[identifier] = true;
console.log(defaultValue(message, identifier));
console.warn(defaultValue(message, identifier));
}
}

View File

@ -0,0 +1,84 @@
/*global define*/
define([
'../ThirdParty/when',
'./defined',
'./sampleTerrain',
'./DeveloperError',
'./Rectangle'
], function(
when,
defined,
sampleTerrain,
DeveloperError,
Rectangle) {
"use strict";
/**
* Initiates a sampleTerrain() request at the maximum available tile level for a terrain dataset.
*
* @exports sampleTerrainMostDetailed
*
* @param {TerrainProvider} terrainProvider The terrain provider from which to query heights.
* @param {Cartographic[]} positions The positions to update with terrain heights.
* @returns {Promise.<Cartographic[]>} A promise that resolves to the provided list of positions when terrain the query has completed. This
* promise will reject if the terrain provider's `availability` property is undefined.
*
* @example
* // Query the terrain height of two Cartographic positions
* var terrainProvider = new Cesium.CesiumTerrainProvider({
* url : '//assets.agi.com/stk-terrain/world'
* });
* var positions = [
* Cesium.Cartographic.fromDegrees(86.925145, 27.988257),
* Cesium.Cartographic.fromDegrees(87.0, 28.0)
* ];
* var promise = Cesium.sampleTerrainMostDetailed(terrainProvider, positions);
* Cesium.when(promise, function(updatedPositions) {
* // positions[0].height and positions[1].height have been updated.
* // updatedPositions is just a reference to positions.
* });
*/
function sampleTerrainMostDetailed(terrainProvider, positions) {
//>>includeStart('debug', pragmas.debug);
if (!defined(terrainProvider)) {
throw new DeveloperError('terrainProvider is required.');
}
if (!defined(positions)) {
throw new DeveloperError('positions is required.');
}
//>>includeEnd('debug');
return terrainProvider.readyPromise.then(function() {
var byLevel = [];
var availability = terrainProvider.availability;
//>>includeStart('debug', pragmas.debug);
if (!defined(availability)) {
throw new DeveloperError('sampleTerrainMostDetailed requires a terrain provider that has tile availability.');
}
//>>includeEnd('debug');
for (var i = 0; i < positions.length; ++i) {
var position = positions[i];
var maxLevel = availability.computeMaximumLevelAtPosition(position);
var atLevel = byLevel[maxLevel];
if (!defined(atLevel)) {
byLevel[maxLevel] = atLevel = [];
}
atLevel.push(position);
}
return when.all(byLevel.map(function(positionsAtLevel, index) {
if (defined(positionsAtLevel)) {
return sampleTerrain(terrainProvider, index, positionsAtLevel);
}
})).then(function() {
return positions;
});
});
}
return sampleTerrainMostDetailed;
});

View File

@ -228,25 +228,20 @@ define([
}
function reallySubSample(property, start, stop, updateTime, referenceFrame, maximumStep, index, result) {
var innerProperty = property;
while (innerProperty instanceof ReferenceProperty || innerProperty instanceof ScaledPositionProperty) {
if (innerProperty instanceof ReferenceProperty) {
innerProperty = innerProperty.resolvedProperty;
}
if (innerProperty instanceof ScaledPositionProperty) {
innerProperty = innerProperty._value;
}
//Unwrap any references until we have the actual property.
while (property instanceof ReferenceProperty) {
property = property.resolvedProperty;
}
if (innerProperty instanceof SampledPositionProperty) {
var times = innerProperty._property._times;
if (property instanceof SampledPositionProperty) {
var times = property._property._times;
index = subSampleSampledProperty(property, start, stop, times, updateTime, referenceFrame, maximumStep, index, result);
} else if (innerProperty instanceof CompositePositionProperty) {
} else if (property instanceof CompositePositionProperty) {
index = subSampleCompositeProperty(property, start, stop, updateTime, referenceFrame, maximumStep, index, result);
} else if (innerProperty instanceof TimeIntervalCollectionPositionProperty) {
} else if (property instanceof TimeIntervalCollectionPositionProperty) {
index = subSampleIntervalProperty(property, start, stop, updateTime, referenceFrame, maximumStep, index, result);
} else if (innerProperty instanceof ConstantPositionProperty) {
} else if (property instanceof ConstantPositionProperty ||
(property instanceof ScaledPositionProperty && Property.isConstant(property))) {
index = subSampleConstantProperty(property, start, stop, updateTime, referenceFrame, maximumStep, index, result);
} else {
//Fallback to generic sampling.

View File

@ -29,14 +29,12 @@ define([
//>>includeEnd('debug');
var attributes;
var modelMatrix;
//Outline and Fill geometries have the same bounding sphere, so just use whichever one is defined and ready
if (defined(primitive) && primitive.show && primitive.ready) {
attributes = primitive.getGeometryInstanceAttributes(entity);
if (defined(attributes) && defined(attributes.boundingSphere)) {
modelMatrix = defaultValue(primitive.modelMatrix, Matrix4.IDENTITY);
BoundingSphere.transform(attributes.boundingSphere, modelMatrix, result);
BoundingSphere.clone(attributes.boundingSphere, result);
return BoundingSphereState.DONE;
}
}
@ -44,8 +42,7 @@ define([
if (defined(outlinePrimitive) && outlinePrimitive.show && outlinePrimitive.ready) {
attributes = outlinePrimitive.getGeometryInstanceAttributes(entity);
if (defined(attributes) && defined(attributes.boundingSphere)) {
modelMatrix = defaultValue(outlinePrimitive.modelMatrix, Matrix4.IDENTITY);
BoundingSphere.transform(attributes.boundingSphere, modelMatrix, result);
BoundingSphere.clone(attributes.boundingSphere, result);
return BoundingSphereState.DONE;
}
}

View File

@ -1478,6 +1478,26 @@ define([
}
}),
/**
* An automatic GLSL uniform representing the splitter position to use when rendering imagery layers with a splitter.
* This will be in the range 0.0 to 1.0 with 0.0 being the far left of the viewport and 1.0 being the far right of the viewport.
*
* @alias czm_imagerySplitPosition
* @glslUniform
*
*
* @example
* // GLSL declaration
* uniform float czm_imagerySplitPosition;
*/
czm_imagerySplitPosition : new AutomaticUniform({
size : 1,
datatype : WebGLConstants.FLOAT,
getValue : function(uniformState) {
return uniformState.imagerySplitPosition;
}
}),
/**
* An automatic GLSL uniform scalar representing the geometric tolerance per meter
*

View File

@ -150,6 +150,7 @@ define([
this._fogDensity = undefined;
this._imagerySplitPosition = 0.0;
this._pixelSizePerMeter = undefined;
this._geometricToleranceOverMeter = undefined;
}
@ -789,6 +790,16 @@ define([
get : function() {
return this._pass;
}
},
/**
* @memberof UniformState.prototype
* @type {Number}
*/
imagerySplitPosition : {
get : function() {
return this._imagerySplitPosition;
}
}
});
@ -950,6 +961,7 @@ define([
this._frameState = frameState;
this._temeToPseudoFixed = Transforms.computeTemeToPseudoFixedMatrix(frameState.time, this._temeToPseudoFixed);
this._imagerySplitPosition = frameState.imagerySplitPosition;
var fov = camera.frustum.fov;
var viewport = this._viewport;
var pixelSizePerMeter;

View File

@ -28,6 +28,7 @@ define([
'../Shaders/BillboardCollectionVS',
'./Billboard',
'./BlendingState',
'./BlendOption',
'./HeightReference',
'./HorizontalOrigin',
'./SceneMode',
@ -62,6 +63,7 @@ define([
BillboardCollectionVS,
Billboard,
BlendingState,
BlendOption,
HeightReference,
HorizontalOrigin,
SceneMode,
@ -133,6 +135,9 @@ define([
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each billboard from model to world coordinates.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
* @param {Scene} [options.scene] Must be passed in for billboards that use the height reference property or will be depth tested against the globe.
* @param {BlendOption} [options.blendOption=BlendOption.OPAQUE_AND_TRANSLUCENT] The billboard blending option. The default
* is used for rendering both opaque and translucent billboards. However, if either all of the billboards are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve performance by up to 2x.
*
* @performance For best performance, prefer a few collections, each with many billboards, to
* many collections with only a few billboards each. Organize collections so that billboards
@ -168,9 +173,11 @@ define([
this._textureAtlasGUID = undefined;
this._destroyTextureAtlas = true;
this._sp = undefined;
this._rs = undefined;
this._vaf = undefined;
this._spTranslucent = undefined;
this._spPick = undefined;
this._rsOpaque = undefined;
this._rsTranslucent = undefined;
this._vaf = undefined;
this._billboards = [];
this._billboardsToUpdate = [];
@ -268,6 +275,17 @@ define([
*/
this.debugShowBoundingVolume = defaultValue(options.debugShowBoundingVolume, false);
/**
* The billboard blending option. The default is used for rendering both opaque and translucent billboards.
* However, if either all of the billboards are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve
* performance by up to 2x.
* @type {BlendOption}
* @default BlendOption.OPAQUE_AND_TRANSLUCENT
*/
this.blendOption = defaultValue(options.blendOption, BlendOption.OPAQUE_AND_TRANSLUCENT);
this._blendOption = undefined;
this._mode = SceneMode.SCENE3D;
// The buffer usage for each attribute is determined based on the usage of the attribute over time.
@ -1427,6 +1445,162 @@ define([
}
updateBoundingVolume(this, frameState, boundingVolume);
var blendOptionChanged = this._blendOption !== this.blendOption;
this._blendOption = this.blendOption;
if (blendOptionChanged) {
this._rsOpaque = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL // Allows label glyphs and billboards to overlap.
},
depthMask : true
});
if (this._blendOption === BlendOption.TRANSLUCENT || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
this._rsTranslucent = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL // Allows label glyphs and billboards to overlap.
},
depthMask : false,
blending : BlendingState.ALPHA_BLEND
});
} else {
this._rsTranslucent = undefined;
}
}
if (blendOptionChanged ||
(this._shaderRotation !== this._compiledShaderRotation) ||
(this._shaderAlignedAxis !== this._compiledShaderAlignedAxis) ||
(this._shaderScaleByDistance !== this._compiledShaderScaleByDistance) ||
(this._shaderTranslucencyByDistance !== this._compiledShaderTranslucencyByDistance) ||
(this._shaderPixelOffsetScaleByDistance !== this._compiledShaderPixelOffsetScaleByDistance) ||
(this._shaderDistanceDisplayCondition !== this._compiledShaderDistanceDisplayCondition)) {
vs = new ShaderSource({
sources : [BillboardCollectionVS]
});
if (this._instanced) {
vs.defines.push('INSTANCED');
}
if (this._shaderRotation) {
vs.defines.push('ROTATION');
}
if (this._shaderAlignedAxis) {
vs.defines.push('ALIGNED_AXIS');
}
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderPixelOffsetScaleByDistance) {
vs.defines.push('EYE_DISTANCE_PIXEL_OFFSET');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
if (this._blendOption === BlendOption.OPAQUE || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
fs = new ShaderSource({
defines : ['OPAQUE'],
sources : [BillboardCollectionFS]
});
this._sp = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._sp,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
} else {
this._sp = this._sp && this._sp.destroy();
this._sp = undefined;
}
if (this._blendOption === BlendOption.TRANSLUCENT || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
fs = new ShaderSource({
defines : ['TRANSLUCENT'],
sources : [BillboardCollectionFS]
});
this._spTranslucent = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spTranslucent,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
} else {
this._spTranslucent = this._spTranslucent && this._spTranslucent.destroy();
this._spTranslucent = undefined;
}
this._compiledShaderRotation = this._shaderRotation;
this._compiledShaderAlignedAxis = this._shaderAlignedAxis;
this._compiledShaderScaleByDistance = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistance = this._shaderTranslucencyByDistance;
this._compiledShaderPixelOffsetScaleByDistance = this._shaderPixelOffsetScaleByDistance;
this._compiledShaderDistanceDisplayCondition = this._shaderDistanceDisplayCondition;
}
if (!defined(this._spPick) ||
(this._shaderRotation !== this._compiledShaderRotationPick) ||
(this._shaderAlignedAxis !== this._compiledShaderAlignedAxisPick) ||
(this._shaderScaleByDistance !== this._compiledShaderScaleByDistancePick) ||
(this._shaderTranslucencyByDistance !== this._compiledShaderTranslucencyByDistancePick) ||
(this._shaderPixelOffsetScaleByDistance !== this._compiledShaderPixelOffsetScaleByDistancePick) ||
(this._shaderDistanceDisplayCondition !== this._compiledShaderDistanceDisplayConditionPick)) {
vs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [BillboardCollectionVS]
});
if(this._instanced) {
vs.defines.push('INSTANCED');
}
if (this._shaderRotation) {
vs.defines.push('ROTATION');
}
if (this._shaderAlignedAxis) {
vs.defines.push('ALIGNED_AXIS');
}
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderPixelOffsetScaleByDistance) {
vs.defines.push('EYE_DISTANCE_PIXEL_OFFSET');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
fs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [BillboardCollectionFS]
});
this._spPick = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spPick,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
this._compiledShaderRotationPick = this._shaderRotation;
this._compiledShaderAlignedAxisPick = this._shaderAlignedAxis;
this._compiledShaderScaleByDistancePick = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistancePick = this._shaderTranslucencyByDistance;
this._compiledShaderPixelOffsetScaleByDistancePick = this._shaderPixelOffsetScaleByDistance;
this._compiledShaderDistanceDisplayConditionPick = this._shaderDistanceDisplayCondition;
}
var va;
var vaLength;
var command;
@ -1439,85 +1613,33 @@ define([
if (pass.render) {
var colorList = this._colorCommands;
if (!defined(this._rs)) {
this._rs = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL // Allows label glyphs and billboards to overlap.
},
blending : BlendingState.ALPHA_BLEND
});
}
if (!defined(this._sp) ||
(this._shaderRotation !== this._compiledShaderRotation) ||
(this._shaderAlignedAxis !== this._compiledShaderAlignedAxis) ||
(this._shaderScaleByDistance !== this._compiledShaderScaleByDistance) ||
(this._shaderTranslucencyByDistance !== this._compiledShaderTranslucencyByDistance) ||
(this._shaderPixelOffsetScaleByDistance !== this._compiledShaderPixelOffsetScaleByDistance) ||
(this._shaderDistanceDisplayCondition !== this._compiledShaderDistanceDisplayCondition)) {
vs = new ShaderSource({
sources : [BillboardCollectionVS]
});
if (this._instanced) {
vs.defines.push('INSTANCED');
}
if (this._shaderRotation) {
vs.defines.push('ROTATION');
}
if (this._shaderAlignedAxis) {
vs.defines.push('ALIGNED_AXIS');
}
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderPixelOffsetScaleByDistance) {
vs.defines.push('EYE_DISTANCE_PIXEL_OFFSET');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
this._sp = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._sp,
vertexShaderSource : vs,
fragmentShaderSource : BillboardCollectionFS,
attributeLocations : attributeLocations
});
this._compiledShaderRotation = this._shaderRotation;
this._compiledShaderAlignedAxis = this._shaderAlignedAxis;
this._compiledShaderScaleByDistance = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistance = this._shaderTranslucencyByDistance;
this._compiledShaderPixelOffsetScaleByDistance = this._shaderPixelOffsetScaleByDistance;
this._compiledShaderDistanceDisplayCondition = this._shaderDistanceDisplayCondition;
}
var opaque = this._blendOption === BlendOption.OPAQUE;
var opaqueAndTranslucent = this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT;
va = this._vaf.va;
vaLength = va.length;
colorList.length = vaLength;
for (j = 0; j < vaLength; ++j) {
var totalLength = opaqueAndTranslucent ? vaLength * 2 : vaLength;
for (j = 0; j < totalLength; ++j) {
command = colorList[j];
if (!defined(command)) {
command = colorList[j] = new DrawCommand({
pass : Pass.OPAQUE,
owner : this
});
command = colorList[j] = new DrawCommand();
}
var opaqueCommand = opaque || (opaqueAndTranslucent && j % 2 === 0);
command.pass = opaqueCommand ? Pass.OPAQUE : Pass.TRANSLUCENT;
command.owner = this;
var index = opaqueAndTranslucent ? Math.floor(j / 2.0) : j;
command.boundingVolume = boundingVolume;
command.modelMatrix = modelMatrix;
command.count = va[j].indicesCount;
command.shaderProgram = this._sp;
command.count = va[index].indicesCount;
command.shaderProgram = opaqueCommand ? this._sp : this._spTranslucent;
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rs;
command.vertexArray = va[index].va;
command.renderState = opaqueCommand ? this._rsOpaque : this._rsTranslucent;
command.debugShowBoundingVolume = this.debugShowBoundingVolume;
if (this._instanced) {
@ -1532,61 +1654,6 @@ define([
if (picking) {
var pickList = this._pickCommands;
if (!defined(this._spPick) ||
(this._shaderRotation !== this._compiledShaderRotationPick) ||
(this._shaderAlignedAxis !== this._compiledShaderAlignedAxisPick) ||
(this._shaderScaleByDistance !== this._compiledShaderScaleByDistancePick) ||
(this._shaderTranslucencyByDistance !== this._compiledShaderTranslucencyByDistancePick) ||
(this._shaderPixelOffsetScaleByDistance !== this._compiledShaderPixelOffsetScaleByDistancePick) ||
(this._shaderDistanceDisplayCondition !== this._compiledShaderDistanceDisplayConditionPick)) {
vs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [BillboardCollectionVS]
});
if(this._instanced) {
vs.defines.push('INSTANCED');
}
if (this._shaderRotation) {
vs.defines.push('ROTATION');
}
if (this._shaderAlignedAxis) {
vs.defines.push('ALIGNED_AXIS');
}
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderPixelOffsetScaleByDistance) {
vs.defines.push('EYE_DISTANCE_PIXEL_OFFSET');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
fs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [BillboardCollectionFS]
});
this._spPick = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spPick,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
this._compiledShaderRotationPick = this._shaderRotation;
this._compiledShaderAlignedAxisPick = this._shaderAlignedAxis;
this._compiledShaderScaleByDistancePick = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistancePick = this._shaderTranslucencyByDistance;
this._compiledShaderPixelOffsetScaleByDistancePick = this._shaderPixelOffsetScaleByDistance;
this._compiledShaderDistanceDisplayConditionPick = this._shaderDistanceDisplayCondition;
}
va = this._vaf.va;
vaLength = va.length;
@ -1606,7 +1673,7 @@ define([
command.shaderProgram = this._spPick;
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rs;
command.renderState = this._rsOpaque;
if (this._instanced) {
command.count = 6;
@ -1658,6 +1725,7 @@ define([
this._textureAtlas = this._destroyTextureAtlas && this._textureAtlas && this._textureAtlas.destroy();
this._sp = this._sp && this._sp.destroy();
this._spTranslucent = this._spTranslucent && this._spTranslucent.destroy();
this._spPick = this._spPick && this._spPick.destroy();
this._vaf = this._vaf && this._vaf.destroy();
destroyBillboards(this._billboards);

View File

@ -0,0 +1,37 @@
/*global define*/
define([
'../Core/freezeObject'
], function(
freezeObject) {
'use strict';
/**
* Determines how opaque and translucent parts of billboards, points, and labels are blended with the scene.
*
* @exports BlendOption
*/
var BlendOption = {
/**
* The billboards, points, or labels in the collection are completely opaque.
* @type {Number}
* @constant
*/
OPAQUE : 0,
/**
* The billboards, points, or labels in the collection are completely translucent.
* @type {Number}
* @constant
*/
TRANSLUCENT : 1,
/**
* The billboards, points, or labels in the collection are both opaque and translucent.
* @type {Number}
* @constant
*/
OPAQUE_AND_TRANSLUCENT : 2
};
return freezeObject(BlendOption);
});

View File

@ -1087,7 +1087,7 @@ define([
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3|Rectangle} [options.destination] The final position of the camera in WGS84 (world) coordinates or a rectangle that would be visible from a top-down view.
* @param {Object} [options.orientation] An object that contains either direction and up properties or heading, pith and roll properties. By default, the direction will point
* @param {Object} [options.orientation] An object that contains either direction and up properties or heading, pitch and roll properties. By default, the direction will point
* towards the center of the frame in 3D and in the negative z direction in Columbus view. The up direction will point towards local north in 3D and in the positive
* y direction in Columbus view. Orientation is not used in 2D when in infinite scrolling mode.
* @param {Matrix4} [options.endTransform] Transform matrix representing the reference frame of the camera.

View File

@ -227,6 +227,14 @@ define([
*/
outOfView : true
};
/**
* The position of the splitter to use when rendering imagery layers on either side of a splitter.
* This value should be between 0.0 and 1.0 with 0 being the far left of the viewport and 1 being the far right of the viewport.
* @type {Number}
* @default 0.0
*/
this.imagerySplitPosition = 0.0;
}
/**

View File

@ -62,7 +62,7 @@ define([
return useWebMercatorProjection ? get2DYPositionFractionMercatorProjection : get2DYPositionFractionGeographicProjection;
}
GlobeSurfaceShaderSet.prototype.getShaderProgram = function(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, showReflectiveOcean, showOceanWaves, enableLighting, hasVertexNormals, useWebMercatorProjection, enableFog) {
GlobeSurfaceShaderSet.prototype.getShaderProgram = function(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, applySplit, showReflectiveOcean, showOceanWaves, enableLighting, hasVertexNormals, useWebMercatorProjection, enableFog) {
var quantization = 0;
var quantizationDefine = '';
@ -87,7 +87,8 @@ define([
(hasVertexNormals << 11) |
(useWebMercatorProjection << 12) |
(enableFog << 13) |
(quantization << 14);
(quantization << 14) |
(applySplit << 15);
var surfaceShader = surfaceTile.surfaceShader;
if (defined(surfaceShader) &&
@ -156,6 +157,10 @@ define([
fs.defines.push('FOG');
}
if (applySplit) {
fs.defines.push('APPLY_SPLIT');
}
var computeDayColor = '\
vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates)\n\
{\n\
@ -174,7 +179,8 @@ define([
' + (applyContrast ? 'u_dayTextureContrast[' + i + ']' : '0.0') + ',\n\
' + (applyHue ? 'u_dayTextureHue[' + i + ']' : '0.0') + ',\n\
' + (applySaturation ? 'u_dayTextureSaturation[' + i + ']' : '0.0') + ',\n\
' + (applyGamma ? 'u_dayTextureOneOverGamma[' + i + ']' : '0.0') + '\n\
' + (applyGamma ? 'u_dayTextureOneOverGamma[' + i + ']' : '0.0') + ',\n\
' + (applySplit ? 'u_dayTextureSplit[' + i + ']' : '0.0') + '\n\
);\n';
}

View File

@ -752,6 +752,9 @@ define([
u_scaleAndBias : function() {
return this.properties.scaleAndBias;
},
u_dayTextureSplit : function() {
return this.properties.dayTextureSplit;
},
// make a separate object so that changes to the properties are seen on
// derived commands that combine another uniform map with this one.
@ -776,6 +779,7 @@ define([
dayTextureHue : [],
dayTextureSaturation : [],
dayTextureOneOverGamma : [],
dayTextureSplit : [],
dayIntensity : 0.0,
southAndNorthLatitude : new Cartesian2(),
@ -1070,6 +1074,7 @@ define([
var applySaturation = false;
var applyGamma = false;
var applyAlpha = false;
var applySplit = false;
while (numberOfDayTextures < maxTextures && imageryIndex < imageryLen) {
var tileImagery = tileImageryCollection[imageryIndex];
@ -1127,6 +1132,9 @@ define([
uniformMapProperties.dayTextureOneOverGamma[numberOfDayTextures] = 1.0 / imageryLayer.gamma;
applyGamma = applyGamma || uniformMapProperties.dayTextureOneOverGamma[numberOfDayTextures] !== 1.0 / ImageryLayer.DEFAULT_GAMMA;
uniformMapProperties.dayTextureSplit[numberOfDayTextures] = imageryLayer.splitDirection;
applySplit = applySplit || uniformMapProperties.dayTextureSplit[numberOfDayTextures] !== 0.0;
if (defined(imagery.credits)) {
var creditDisplay = frameState.creditDisplay;
var credits = imagery.credits;
@ -1148,7 +1156,7 @@ define([
uniformMapProperties.minMaxHeight.y = encoding.maximumHeight;
Matrix4.clone(encoding.matrix, uniformMapProperties.scaleAndBias);
command.shaderProgram = tileProvider._surfaceShaderSet.getShaderProgram(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, showReflectiveOcean, showOceanWaves, tileProvider.enableLighting, hasVertexNormals, useWebMercatorProjection, applyFog);
command.shaderProgram = tileProvider._surfaceShaderSet.getShaderProgram(frameState, surfaceTile, numberOfDayTextures, applyBrightness, applyContrast, applyHue, applySaturation, applyGamma, applyAlpha, applySplit, showReflectiveOcean, showOceanWaves, tileProvider.enableLighting, hasVertexNormals, useWebMercatorProjection, applyFog);
command.castShadows = castShadows;
command.receiveShadows = receiveShadows;
command.renderState = renderState;

View File

@ -85,7 +85,7 @@ define([
* </p>
* <p>
* Because of the cutting edge nature of this feature in WebGL, it requires the EXT_frag_depth extension, which is currently only supported in Chrome,
* Firefox, and Edge. Apple support is expected in iOS 9 and MacOS Safari 9. Android support varies by hardware and IE11 will most likely never support
* Firefox, Edge, and Safari 10. It's not yet supported in iOS 10. Android support varies by hardware and IE11 will most likely never support
* it. You can use webglreport.com to verify support for your hardware.
* </p>
* <p>
@ -551,7 +551,7 @@ define([
function getRectangle(frameState, geometry) {
var ellipsoid = frameState.mapProjection.ellipsoid;
if (!defined(geometry.attributes) || !defined(geometry.attributes.position3DHigh)) {
if (defined(geometry.rectangle)) {
return geometry.rectangle;
@ -695,7 +695,7 @@ define([
var result = BoundingSphere.fromRectangle3D(rectangle, ellipsoid, 0.0);
BoundingSphere.fromRectangle3D(rectangle, ellipsoid, maxTerrainHeight, scratchBoundingSphere);
return BoundingSphere.union(result, scratchBoundingSphere, result);
}

View File

@ -33,6 +33,7 @@ define([
'../Shaders/ReprojectWebMercatorVS',
'../ThirdParty/when',
'./Imagery',
'./ImagerySplitDirection',
'./ImageryState',
'./TileImagery'
], function(
@ -69,6 +70,7 @@ define([
ReprojectWebMercatorVS,
when,
Imagery,
ImagerySplitDirection,
ImageryState,
TileImagery) {
'use strict';
@ -128,6 +130,7 @@ define([
* imagery tile for which the gamma is required, and it is expected to return
* the gamma value to use for the tile. The function is executed for every
* frame and for every tile, so it must be fast.
* @param {ImagerySplitDirection|Function} [options.splitDirection=ImagerySplitDirection.NONE] The {@link ImagerySplitDirection} split to apply to this layer.
* @param {Boolean} [options.show=true] True if the layer is shown; otherwise, false.
* @param {Number} [options.maximumAnisotropy=maximum supported] The maximum anisotropy level to use
* for texture filtering. If this parameter is not specified, the maximum anisotropy supported
@ -195,6 +198,14 @@ define([
*/
this.gamma = defaultValue(options.gamma, defaultValue(imageryProvider.defaultGamma, ImageryLayer.DEFAULT_GAMMA));
/**
* The {@link ImagerySplitDirection} to apply to this layer.
*
* @type {ImagerySplitDirection}
* @default {@link ImageryLayer.DEFAULT_SPLIT}
*/
this.splitDirection = defaultValue(options.splitDirection, defaultValue(imageryProvider.defaultSplit, ImageryLayer.DEFAULT_SPLIT));
/**
* Determines if this layer is shown.
*
@ -292,6 +303,14 @@ define([
*/
ImageryLayer.DEFAULT_GAMMA = 1.0;
/**
* This value is used as the default spliat for the imagery layer if one is not provided during construction
* or by the imagery provider.
* @type {ImagerySplitDirection}
* @default ImagerySplitDirection.NONE
*/
ImageryLayer.DEFAULT_SPLIT = ImagerySplitDirection.NONE;
/**
* Gets a value indicating whether this layer is the base layer in the
* {@link ImageryLayerCollection}. The base layer is the one that underlies all

View File

@ -0,0 +1,42 @@
/*global define*/
define([
'../Core/freezeObject'
], function(
freezeObject) {
'use strict';
/**
* The direction to display an ImageryLayer relative to the {@link Scene#imagerySplitPosition}.
*
* @exports ImagerySplitDirection
*
* @see ImageryLayer#splitDirection
*/
var ImagerySplitDirection = {
/**
* Display the ImageryLayer to the left of the {@link Scene#imagerySplitPosition}.
*
* @type {Number}
* @constant
*/
LEFT : -1.0,
/**
* Always display the ImageryLayer.
*
* @type {Number}
* @constant
*/
NONE: 0.0,
/**
* Display the ImageryLayer to the right of the {@link Scene#imagerySplitPosition}.
*
* @type {Number}
* @constant
*/
RIGHT : 1.0
};
return freezeObject(ImagerySplitDirection);
});

View File

@ -11,6 +11,7 @@ define([
'../Core/Matrix4',
'../Core/writeTextToCanvas',
'./BillboardCollection',
'./BlendOption',
'./HorizontalOrigin',
'./Label',
'./LabelStyle',
@ -28,6 +29,7 @@ define([
Matrix4,
writeTextToCanvas,
BillboardCollection,
BlendOption,
HorizontalOrigin,
Label,
LabelStyle,
@ -440,6 +442,9 @@ define([
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each label from model to world coordinates.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
* @param {Scene} [options.scene] Must be passed in for labels that use the height reference property or will be depth tested against the globe.
* @param {BlendOption} [options.blendOption=BlendOption.OPAQUE_AND_TRANSLUCENT] The label blending option. The default
* is used for rendering both opaque and translucent labels. However, if either all of the labels are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve performance by up to 2x.
*
* @performance For best performance, prefer a few collections, each with many labels, to
* many collections with only a few labels each. Avoid having collections where some
@ -533,6 +538,16 @@ define([
* @default false
*/
this.debugShowBoundingVolume = defaultValue(options.debugShowBoundingVolume, false);
/**
* The label blending option. The default is used for rendering both opaque and translucent labels.
* However, if either all of the labels are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve
* performance by up to 2x.
* @type {BlendOption}
* @default BlendOption.OPAQUE_AND_TRANSLUCENT
*/
this.blendOption = defaultValue(options.blendOption, BlendOption.OPAQUE_AND_TRANSLUCENT);
}
defineProperties(LabelCollection.prototype, {
@ -732,8 +747,10 @@ define([
billboardCollection.modelMatrix = this.modelMatrix;
billboardCollection.debugShowBoundingVolume = this.debugShowBoundingVolume;
billboardCollection.blendOption = this.blendOption;
backgroundBillboardCollection.modelMatrix = this.modelMatrix;
backgroundBillboardCollection.debugShowBoundingVolume = this.debugShowBoundingVolume;
backgroundBillboardCollection.blendOption = this.blendOption;
var context = frameState.context;

View File

@ -671,8 +671,10 @@ define([
this._pickIds = [];
// CESIUM_RTC extension
this._rtcCenter = undefined; // in world coordinates
this._rtcCenter = undefined; // reference to either 3D or 2D
this._rtcCenterEye = undefined; // in eye coordinates
this._rtcCenter3D = undefined; // in world coordinates
this._rtcCenter2D = undefined; // in projected world coordinates
}
defineProperties(Model.prototype, {
@ -2494,10 +2496,13 @@ define([
// CESIUM_RTC extension
var mvRtc = new Matrix4();
return function() {
Matrix4.getTranslation(uniformState.model, scratchTranslationRtc);
Cartesian3.add(scratchTranslationRtc, model._rtcCenter, scratchTranslationRtc);
Matrix4.multiplyByPoint(uniformState.view, scratchTranslationRtc, scratchTranslationRtc);
return Matrix4.setTranslation(uniformState.modelView, scratchTranslationRtc, mvRtc);
if (defined(model._rtcCenter)) {
Matrix4.getTranslation(uniformState.model, scratchTranslationRtc);
Cartesian3.add(scratchTranslationRtc, model._rtcCenter, scratchTranslationRtc);
Matrix4.multiplyByPoint(uniformState.view, scratchTranslationRtc, scratchTranslationRtc);
return Matrix4.setTranslation(uniformState.modelView, scratchTranslationRtc, mvRtc);
}
return uniformState.modelView;
};
},
MODELVIEWPROJECTION : function(uniformState, model) {
@ -3325,6 +3330,7 @@ define([
}
var scratchNodeStack = [];
var scratchComputedTranslation = new Cartesian4();
var scratchComputedMatrixIn2D = new Matrix4();
function updateNodeHierarchyModelMatrix(model, modelTransformChanged, justLoaded, projection) {
@ -3338,7 +3344,20 @@ define([
var computedModelMatrix = model._computedModelMatrix;
if (model._mode !== SceneMode.SCENE3D) {
computedModelMatrix = Transforms.basisTo2D(projection, computedModelMatrix, scratchComputedMatrixIn2D);
var translation = Matrix4.getColumn(computedModelMatrix, 3, scratchComputedTranslation);
if (!Cartesian4.equals(translation, Cartesian4.UNIT_W)) {
computedModelMatrix = Transforms.basisTo2D(projection, computedModelMatrix, scratchComputedMatrixIn2D);
model._rtcCenter = model._rtcCenter3D;
} else {
var center = model.boundingSphere.center;
var to2D = Transforms.wgs84To2DModelMatrix(projection, center, scratchComputedMatrixIn2D);
computedModelMatrix = Matrix4.multiply(to2D, computedModelMatrix, scratchComputedMatrixIn2D);
if (defined(model._rtcCenter)) {
Matrix4.setTranslation(computedModelMatrix, Cartesian4.UNIT_W, computedModelMatrix);
model._rtcCenter = model._rtcCenter2D;
}
}
}
for (var i = 0; i < length; ++i) {
@ -4091,8 +4110,20 @@ define([
if (this._state !== ModelState.FAILED) {
var extensions = this.gltf.extensions;
if (defined(extensions) && defined(extensions.CESIUM_RTC)) {
this._rtcCenter = Cartesian3.fromArray(extensions.CESIUM_RTC.center);
this._rtcCenterEye = new Cartesian3();
var center = Cartesian3.fromArray(extensions.CESIUM_RTC.center);
if (!Cartesian3.equals(center, Cartesian3.ZERO)) {
this._rtcCenter3D = center;
var projection = frameState.mapProjection;
var ellipsoid = projection.ellipsoid;
var cartographic = ellipsoid.cartesianToCartographic(this._rtcCenter3D);
var projectedCart = projection.project(cartographic);
Cartesian3.fromElements(projectedCart.z, projectedCart.x, projectedCart.y, projectedCart);
this._rtcCenter2D = projectedCart;
this._rtcCenterEye = new Cartesian3();
this._rtcCenter = this._rtcCenter3D;
}
}
this._loadResources = new LoadResources();

View File

@ -24,6 +24,7 @@ define([
'../Shaders/PointPrimitiveCollectionFS',
'../Shaders/PointPrimitiveCollectionVS',
'./BlendingState',
'./BlendOption',
'./PointPrimitive',
'./SceneMode'
], function(
@ -51,6 +52,7 @@ define([
PointPrimitiveCollectionFS,
PointPrimitiveCollectionVS,
BlendingState,
BlendOption,
PointPrimitive,
SceneMode) {
'use strict';
@ -87,6 +89,9 @@ define([
* @param {Object} [options] Object with the following properties:
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] The 4x4 transformation matrix that transforms each point from model to world coordinates.
* @param {Boolean} [options.debugShowBoundingVolume=false] For debugging only. Determines if this primitive's commands' bounding spheres are shown.
* @param {BlendOption} [options.blendOption=BlendOption.OPAQUE_AND_TRANSLUCENT] The point blending option. The default
* is used for rendering both opaque and translucent points. However, if either all of the points are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve performance by up to 2x.
*
* @performance For best performance, prefer a few collections, each with many points, to
* many collections with only a few points each. Organize collections so that points
@ -115,9 +120,11 @@ define([
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
this._sp = undefined;
this._rs = undefined;
this._vaf = undefined;
this._spTranslucent = undefined;
this._spPick = undefined;
this._rsOpaque = undefined;
this._rsTranslucent = undefined;
this._vaf = undefined;
this._pointPrimitives = [];
this._pointPrimitivesToUpdate = [];
@ -197,6 +204,17 @@ define([
*/
this.debugShowBoundingVolume = defaultValue(options.debugShowBoundingVolume, false);
/**
* The point blending option. The default is used for rendering both opaque and translucent points.
* However, if either all of the points are completely opaque or all are completely translucent,
* setting the technique to BillboardRenderTechnique.OPAQUE or BillboardRenderTechnique.TRANSLUCENT can improve
* performance by up to 2x.
* @type {BlendOption}
* @default BlendOption.OPAQUE_AND_TRANSLUCENT
*/
this.blendOption = defaultValue(options.blendOption, BlendOption.OPAQUE_AND_TRANSLUCENT);
this._blendOption = undefined;
this._mode = SceneMode.SCENE3D;
this._maxTotalPointSize = 1;
@ -835,6 +853,127 @@ define([
}
updateBoundingVolume(this, frameState, boundingVolume);
var blendOptionChanged = this._blendOption !== this.blendOption;
this._blendOption = this.blendOption;
if (blendOptionChanged) {
this._rsOpaque = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL
},
depthMask : true
});
if (this._blendOption === BlendOption.TRANSLUCENT || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
this._rsTranslucent = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL
},
depthMask : false,
blending : BlendingState.ALPHA_BLEND
});
} else {
this._rsTranslucent = undefined;
}
}
if (blendOptionChanged ||
(this._shaderScaleByDistance && !this._compiledShaderScaleByDistance) ||
(this._shaderTranslucencyByDistance && !this._compiledShaderTranslucencyByDistance) ||
(this._shaderDistanceDisplayCondition && !this._compiledShaderDistanceDisplayCondition)) {
vs = new ShaderSource({
sources : [PointPrimitiveCollectionVS]
});
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
if (this._blendOption === BlendOption.OPAQUE || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
fs = new ShaderSource({
defines : ['OPAQUE'],
sources : [PointPrimitiveCollectionFS]
});
this._sp = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._sp,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
} else {
this._sp = this._sp && this._sp.destroy();
this._sp = undefined;
}
if (this._blendOption === BlendOption.TRANSLUCENT || this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT) {
fs = new ShaderSource({
defines : ['TRANSLUCENT'],
sources : [PointPrimitiveCollectionFS]
});
this._spTranslucent = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spTranslucent,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
} else {
this._spTranslucent = this._spTranslucent && this._spTranslucent.destroy();
this._spTranslucent = undefined;
}
this._compiledShaderScaleByDistance = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistance = this._shaderTranslucencyByDistance;
this._compiledShaderDistanceDisplayCondition = this._shaderDistanceDisplayCondition;
}
if (!defined(this._spPick) ||
(this._shaderScaleByDistance && !this._compiledShaderScaleByDistancePick) ||
(this._shaderTranslucencyByDistance && !this._compiledShaderTranslucencyByDistancePick) ||
(this._shaderDistanceDisplayCondition && !this._compiledShaderDistanceDisplayConditionPick)) {
vs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [PointPrimitiveCollectionVS]
});
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
fs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [PointPrimitiveCollectionFS]
});
this._spPick = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spPick,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
this._compiledShaderScaleByDistancePick = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistancePick = this._shaderTranslucencyByDistance;
this._compiledShaderDistanceDisplayConditionPick = this._shaderDistanceDisplayCondition;
}
var va;
var vaLength;
var command;
@ -847,67 +986,33 @@ define([
if (pass.render) {
var colorList = this._colorCommands;
if (!defined(this._rs)) {
this._rs = RenderState.fromCache({
depthTest : {
enabled : true,
func : WebGLConstants.LEQUAL
},
blending : BlendingState.ALPHA_BLEND
});
}
if (!defined(this._sp) ||
(this._shaderScaleByDistance && !this._compiledShaderScaleByDistance) ||
(this._shaderTranslucencyByDistance && !this._compiledShaderTranslucencyByDistance) ||
(this._shaderDistanceDisplayCondition && !this._compiledShaderDistanceDisplayCondition)) {
vs = new ShaderSource({
sources : [PointPrimitiveCollectionVS]
});
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
this._sp = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._sp,
vertexShaderSource : vs,
fragmentShaderSource : PointPrimitiveCollectionFS,
attributeLocations : attributeLocations
});
this._compiledShaderScaleByDistance = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistance = this._shaderTranslucencyByDistance;
this._compiledShaderDistanceDisplayCondition = this._shaderDistanceDisplayCondition;
}
var opaque = this._blendOption === BlendOption.OPAQUE;
var opaqueAndTranslucent = this._blendOption === BlendOption.OPAQUE_AND_TRANSLUCENT;
va = this._vaf.va;
vaLength = va.length;
colorList.length = vaLength;
for (j = 0; j < vaLength; ++j) {
var totalLength = opaqueAndTranslucent ? vaLength * 2 : vaLength;
for (j = 0; j < totalLength; ++j) {
var opaqueCommand = opaque || (opaqueAndTranslucent && j % 2 === 0);
command = colorList[j];
if (!defined(command)) {
command = colorList[j] = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
pass : Pass.OPAQUE,
owner : this
});
command = colorList[j] = new DrawCommand();
}
command.primitiveType = PrimitiveType.POINTS;
command.pass = opaqueCommand ? Pass.OPAQUE : Pass.TRANSLUCENT;
command.owner = this;
var index = opaqueAndTranslucent ? Math.floor(j / 2.0) : j;
command.boundingVolume = boundingVolume;
command.modelMatrix = modelMatrix;
command.shaderProgram = this._sp;
command.shaderProgram = opaqueCommand ? this._sp : this._spTranslucent;
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rs;
command.vertexArray = va[index].va;
command.renderState = opaqueCommand ? this._rsOpaque : this._rsTranslucent;
command.debugShowBoundingVolume = this.debugShowBoundingVolume;
commandList.push(command);
@ -917,44 +1022,6 @@ define([
if (picking) {
var pickList = this._pickCommands;
if (!defined(this._spPick) ||
(this._shaderScaleByDistance && !this._compiledShaderScaleByDistancePick) ||
(this._shaderTranslucencyByDistance && !this._compiledShaderTranslucencyByDistancePick) ||
(this._shaderDistanceDisplayCondition && !this._compiledShaderDistanceDisplayConditionPick)) {
vs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [PointPrimitiveCollectionVS]
});
if (this._shaderScaleByDistance) {
vs.defines.push('EYE_DISTANCE_SCALING');
}
if (this._shaderTranslucencyByDistance) {
vs.defines.push('EYE_DISTANCE_TRANSLUCENCY');
}
if (this._shaderDistanceDisplayCondition) {
vs.defines.push('DISTANCE_DISPLAY_CONDITION');
}
fs = new ShaderSource({
defines : ['RENDER_FOR_PICK'],
sources : [PointPrimitiveCollectionFS]
});
this._spPick = ShaderProgram.replaceCache({
context : context,
shaderProgram : this._spPick,
vertexShaderSource : vs,
fragmentShaderSource : fs,
attributeLocations : attributeLocations
});
this._compiledShaderScaleByDistancePick = this._shaderScaleByDistance;
this._compiledShaderTranslucencyByDistancePick = this._shaderTranslucencyByDistance;
this._compiledShaderDistanceDisplayConditionPick = this._shaderDistanceDisplayCondition;
}
va = this._vaf.va;
vaLength = va.length;
@ -974,7 +1041,7 @@ define([
command.shaderProgram = this._spPick;
command.uniformMap = this._uniforms;
command.vertexArray = va[j].va;
command.renderState = this._rs;
command.renderState = this._rsOpaque;
commandList.push(command);
}
@ -1015,6 +1082,7 @@ define([
*/
PointPrimitiveCollection.prototype.destroy = function() {
this._sp = this._sp && this._sp.destroy();
this._spTranslucent = this._spTranslucent && this._spTranslucent.destroy();
this._spPick = this._spPick && this._spPick.destroy();
this._vaf = this._vaf && this._vaf.destroy();
destroyPointPrimitives(this._pointPrimitives);

View File

@ -1078,6 +1078,22 @@ define([
get : function() {
return this._mapMode2D;
}
},
/**
* Gets or sets the position of the Imagery splitter within the viewport. Valid values are between 0.0 and 1.0.
* @memberof Scene.prototype.
*
* @type {Number}
*/
imagerySplitPosition : {
get: function() {
return this._frameState.imagerySplitPosition;
},
set: function(value) {
this._frameState.imagerySplitPosition = value;
}
}
});
@ -1433,22 +1449,38 @@ define([
var sp = defaultValue(shaderProgram, command.shaderProgram);
var fs = sp.fragmentShaderSource.clone();
var targets = [];
fs.sources = fs.sources.map(function(source) {
source = ShaderSource.replaceMain(source, 'czm_Debug_main');
var re = /gl_FragData\[(\d+)\]/g;
var match;
while ((match = re.exec(source)) !== null) {
if (targets.indexOf(match[1]) === -1) {
targets.push(match[1]);
}
}
return source;
});
var length = targets.length;
var newMain =
'void main() \n' +
'{ \n' +
' czm_Debug_main(); \n';
var i;
if (scene.debugShowCommands) {
if (!defined(command._debugColor)) {
command._debugColor = Color.fromRandom();
}
var c = command._debugColor;
newMain += ' gl_FragColor.rgb *= vec3(' + c.red + ', ' + c.green + ', ' + c.blue + '); \n';
if (length > 0) {
for (i = 0; i < length; ++i) {
newMain += ' gl_FragData[' + targets[i] + '].rgb *= vec3(' + c.red + ', ' + c.green + ', ' + c.blue + '); \n';
}
} else {
newMain += ' ' + 'gl_FragColor' + '.rgb *= vec3(' + c.red + ', ' + c.green + ', ' + c.blue + '); \n';
}
}
if (scene.debugShowFrustums) {
@ -1457,7 +1489,13 @@ define([
var r = (command.debugOverlappingFrustums & (1 << 0)) ? '1.0' : '0.0';
var g = (command.debugOverlappingFrustums & (1 << 1)) ? '1.0' : '0.0';
var b = (command.debugOverlappingFrustums & (1 << 2)) ? '1.0' : '0.0';
newMain += ' gl_FragColor.rgb *= vec3(' + r + ', ' + g + ', ' + b + '); \n';
if (length > 0) {
for (i = 0; i < length; ++i) {
newMain += ' gl_FragData[' + targets[i] + '].rgb *= vec3(' + r + ', ' + g + ', ' + b + '); \n';
}
} else {
newMain += ' ' + 'gl_FragColor' + '.rgb *= vec3(' + r + ', ' + g + ', ' + b + '); \n';
}
}
newMain += '}';

View File

@ -106,16 +106,17 @@ define([
'use strict';
/**
* Creates a shadow map from the provided light camera.
* Use {@link Viewer#shadowMap} to get the scene's shadow map originating from the sun. Do not construct this directly.
*
* <p>
* The normalOffset bias pushes the shadows forward slightly, and may be disabled
* for applications that require ultra precise shadows.
* </p>
*
* @alias ShadowMap
* @constructor
* @internalConstructor
*
* @param {Object} options An object containing the following properties:
* @param {Context} options.context The context in which to create the shadow map.
* @param {Camera} options.lightCamera A camera representing the light source.
* @param {Boolean} [options.enabled=true] Whether the shadow map is enabled.
* @param {Boolean} [options.isPointLight=false] Whether the light source is a point light. Point light shadows do not use cascades.
@ -126,6 +127,7 @@ define([
* @param {Number} [options.size=2048] The width and height, in pixels, of each shadow map.
* @param {Boolean} [options.softShadows=false] Whether percentage-closer-filtering is enabled for producing softer shadows.
* @param {Number} [options.darkness=0.3] The shadow darkness.
* @param {Boolean} [options.normalOffset=true] Whether a normal bias is applied to shadows.
*
* @exception {DeveloperError} Only one or four cascades are supported.
*
@ -133,6 +135,7 @@ define([
*/
function ShadowMap(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
// options.context is an undocumented option
var context = options.context;
//>>includeStart('debug', pragmas.debug);
@ -149,6 +152,7 @@ define([
this._enabled = defaultValue(options.enabled, true);
this._softShadows = defaultValue(options.softShadows, false);
this._normalOffset = defaultValue(options.normalOffset, true);
this.dirty = true;
/**
@ -193,7 +197,7 @@ define([
polygonOffset : polygonOffsetSupported,
polygonOffsetFactor : 1.1,
polygonOffsetUnits : 4.0,
normalOffset : true,
normalOffset : this._normalOffset,
normalOffsetScale : 0.5,
normalShading : true,
normalShadingSmooth : 0.3,
@ -204,7 +208,7 @@ define([
polygonOffset : polygonOffsetSupported,
polygonOffsetFactor : 1.1,
polygonOffsetUnits : 4.0,
normalOffset : true,
normalOffset : this._normalOffset,
normalOffsetScale : 0.1,
normalShading : true,
normalShadingSmooth : 0.05,
@ -215,7 +219,7 @@ define([
polygonOffset : false,
polygonOffsetFactor : 1.1,
polygonOffsetUnits : 4.0,
normalOffset : false,
normalOffset : this._normalOffset,
normalOffsetScale : 0.0,
normalShading : true,
normalShadingSmooth : 0.1,
@ -384,6 +388,26 @@ define([
}
},
/**
* Determines if a normal bias will be applied to shadows.
*
* @memberof ShadowMap.prototype
* @type {Boolean}
* @default true
*/
normalOffset : {
get : function() {
return this._normalOffset;
},
set : function(value) {
this.dirty = this._normalOffset !== value;
this._normalOffset = value;
this._terrainBias.normalOffset = value;
this._primitiveBias.normalOffset = value;
this._pointBias.normalOffset = value;
}
},
/**
* Determines if soft shadows are enabled. Uses pcf filtering which requires more texture reads and may hurt performance.
*

View File

@ -15,13 +15,31 @@ void main()
#else
vec4 vertexColor = v_color;
#endif
vec4 color = texture2D(u_atlas, v_textureCoordinates) * vertexColor;
if (color.a == 0.0)
// Fully transparent parts of the billboard are not pickable.
#ifdef RENDER_FOR_PICK
if (color.a < 0.005) // matches 0/255 and 1/255
{
discard;
}
#else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
#ifdef OPAQUE
if (color.a < 0.995) // matches < 254/255
{
discard;
}
#else
if (color.a >= 0.995) // matches 254/255 and 255/255
{
discard;
}
#endif
#endif
#ifdef RENDER_FOR_PICK
gl_FragColor = v_pickColor;
#else

View File

@ -11,6 +11,10 @@ uniform bool u_dayTextureUseWebMercatorT[TEXTURE_UNITS];
uniform float u_dayTextureAlpha[TEXTURE_UNITS];
#endif
#ifdef APPLY_SPLIT
uniform float u_dayTextureSplit[TEXTURE_UNITS];
#endif
#ifdef APPLY_BRIGHTNESS
uniform float u_dayTextureBrightness[TEXTURE_UNITS];
#endif
@ -71,7 +75,8 @@ vec4 sampleAndBlend(
float textureContrast,
float textureHue,
float textureSaturation,
float textureOneOverGamma)
float textureOneOverGamma,
float split)
{
// This crazy step stuff sets the alpha to 0.0 if this following condition is true:
// tileTextureCoordinates.s < textureCoordinateRectangle.s ||
@ -93,6 +98,18 @@ vec4 sampleAndBlend(
vec3 color = value.rgb;
float alpha = value.a;
#ifdef APPLY_SPLIT
float splitPosition = czm_imagerySplitPosition * czm_viewport.z;
// Split to the left
if (split < 0.0 && gl_FragCoord.x > splitPosition) {
alpha = 0.0;
}
// Split to the right
else if (split > 0.0 && gl_FragCoord.x < splitPosition) {
alpha = 0.0;
}
#endif
#ifdef APPLY_BRIGHTNESS
color = mix(vec3(0.0), color, textureBrightness);
#endif

View File

@ -18,10 +18,28 @@ void main()
vec4 color = mix(v_outlineColor, v_color, innerAlpha);
color.a *= wholeAlpha;
if (color.a < 0.005)
// Fully transparent parts of the billboard are not pickable.
#ifdef RENDER_FOR_PICK
if (color.a < 0.005) // matches 0/255 and 1/255
{
discard;
}
#else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
#ifdef OPAQUE
if (color.a < 0.995) // matches < 254/255
{
discard;
}
#else
if (color.a >= 0.995) // matches 254/255 and 255/255
{
discard;
}
#endif
#endif
#ifdef RENDER_FOR_PICK
gl_FragColor = v_pickColor;

View File

@ -1,7 +1,7 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2016 Cesium Contributors
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,6 +1,6 @@
/*global defineSuite*/
defineSuite([
'Core/Check'
'Core/Check'
], function(
Check) {
'use strict';
@ -8,170 +8,225 @@ defineSuite([
describe('type checks', function () {
it('Check.typeOf.bool does not throw when passed a boolean', function () {
expect(function () {
Check.typeOf.bool(true);
Check.typeOf.bool('bool', true);
}).not.toThrowDeveloperError();
});
it('Check.typeOf.boolean throws when passed a non-boolean', function () {
it('Check.typeOf.bool throws when passed a non-boolean', function () {
expect(function () {
Check.typeOf.bool({}, 'mockName');
Check.typeOf.bool('mockName', {});
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.bool([], 'mockName');
Check.typeOf.bool('mockName', []);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.bool(1, 'mockName');
Check.typeOf.bool('mockName', 1);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.bool('snth', 'mockName');
Check.typeOf.bool('mockName', 'snth');
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.bool(function () {return true;}, 'mockName');
Check.typeOf.bool('mockName', function () {return true;});
}).toThrowDeveloperError();
});
it('Check.typeOf.func does not throw when passed a function', function () {
expect(function () {
Check.typeOf.func(function () {return true;}, 'mockName');
Check.typeOf.func('mockName', function () {return true;});
}).not.toThrowDeveloperError();
});
it('Check.typeOf.func throws when passed a non-function', function () {
expect(function () {
Check.typeOf.func({}, 'mockName');
Check.typeOf.func('mockName', {});
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.func([], 'mockName');
Check.typeOf.func('mockName', [2]);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.func(1, 'mockName');
Check.typeOf.func('mockName', 1);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.func('snth', 'mockName');
Check.typeOf.func('mockName', 'snth');
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.func(true, 'mockName');
Check.typeOf.func('mockName', true);
}).toThrowDeveloperError();
});
it('Check.typeOf.object does not throw when passed object', function() {
expect(function () {
Check.typeOf.object({}, 'mockName');
Check.typeOf.object('mockName', {});
}).not.toThrowDeveloperError();
});
it('Check.typeOf.object throws when passed non-object', function() {
expect(function () {
Check.typeOf.object('snth', 'mockName');
Check.typeOf.object('mockName', 'snth');
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.object(true, 'mockName');
Check.typeOf.object('mockName', true);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.object(1, 'mockName');
Check.typeOf.object('mockName', 1);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.object(function () {return true;}, 'mockName');
Check.typeOf.object('mockName', function () {return true;});
}).toThrowDeveloperError();
});
it('Check.typeOf.number does not throw when passed number', function() {
expect(function () {
Check.typeOf.number(2, 'mockName');
Check.typeOf.number('mockName', 2);
}).not.toThrowDeveloperError();
});
it('Check.typeOf.number throws when passed non-number', function() {
expect(function () {
Check.typeOf.number('snth', 'mockName');
Check.typeOf.number('mockName', 'snth');
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.number(true, 'mockName');
Check.typeOf.number('mockName', true);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.number({}, 'mockName');
Check.typeOf.number('mockName', {});
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.number([2], 'mockName');
Check.typeOf.number('mockName', [2]);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.number(function () {return true;}, 'mockName');
Check.typeOf.number('mockName', function () {return true;});
}).toThrowDeveloperError();
});
it('Check.typeOf.string does not throw when passed a string', function () {
expect(function () {
Check.typeOf.string('s', 'mockName');
Check.typeOf.string('mockName', 's');
}).not.toThrowDeveloperError();
});
it('Check.typeOf.string throws on non-string', function () {
expect(function () {
Check.typeOf.string({}, 'mockName');
Check.typeOf.string('mockName', {});
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.string(true, 'mockName');
Check.typeOf.string('mockName', true);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.string(1, 'mockName');
Check.typeOf.string('mockName', 1);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.string([2], 'mockName');
Check.typeOf.string('mockName', [2]);
}).toThrowDeveloperError();
expect(function () {
Check.typeOf.string(function () {return true;}, 'mockName');
Check.typeOf.string('mockName', function () {return true;});
}).toThrowDeveloperError();
});
});
describe('Check.numeric', function () {
it('minimum throws on value less than minimum', function () {
describe('Check.defined', function () {
it('does not throw unless passed value that is undefined or null', function () {
expect(function () {
Check.numeric.minimum(4, 5);
}).toThrowDeveloperError();
});
it('minimum does not throw on value at least as big as minimum', function () {
Check.defined('mockName', {});
}).not.toThrowDeveloperError();
expect(function () {
Check.numeric.minimum(4, 4);
Check.numeric.minimum(4, 3);
Check.defined('mockName', []);
}).not.toThrowDeveloperError();
expect(function () {
Check.defined('mockName', 2);
}).not.toThrowDeveloperError();
expect(function () {
Check.defined('mockName', function () {return true;});
}).not.toThrowDeveloperError();
expect(function () {
Check.defined('mockName', 'snt');
}).not.toThrowDeveloperError();
});
it('maximum throws on value greater than maximum', function () {
it('throws when passed undefined', function () {
expect(function () {
Check.numeric.maximum(6, 5);
Check.defined('mockName', undefined);
}).toThrowDeveloperError();
});
it('maximum does not throw on value at most as big as maximum', function () {
});
describe('Check.typeOf.number.lessThan', function () {
it('throws if test is equal to limit', function () {
expect(function () {
Check.numeric.maximum(5, 5);
Check.numeric.maximum(4, 5);
Check.typeOf.number.lessThan('mockName', 3, 3);
}).toThrowDeveloperError();
});
it('throws if test is greater than limit', function () {
expect(function () {
Check.typeOf.number.lessThan('mockName', 4, 3);
}).toThrowDeveloperError();
});
it('does not throw if test is less than limit', function () {
expect(function () {
Check.typeOf.number.lessThan('mockName', 2, 3);
}).not.toThrowDeveloperError();
});
});
it('Check.defined does not throw unless passed value that is undefined or null', function () {
expect(function () {
Check.defined({}, 'mockName');
}).not.toThrowDeveloperError();
expect(function () {
Check.defined([], 'mockName');
}).not.toThrowDeveloperError();
expect(function () {
Check.defined(2, 'mockName');
}).not.toThrowDeveloperError();
expect(function () {
Check.defined(function() {return true;}, 'mockName');
}).not.toThrowDeveloperError();
expect(function () {
Check.defined('snt', 'mockName');
}).not.toThrowDeveloperError();
describe('Check.typeOf.number.lessThanOrEquals', function () {
it('throws if test is greater than limit', function () {
expect(function () {
Check.typeOf.number.lessThanOrEquals('mockName', 4, 3);
}).toThrowDeveloperError();
});
it('does not throw if test is equal to limit', function () {
expect(function () {
Check.typeOf.number.lessThanOrEquals('mockName', 3, 3);
}).not.toThrowDeveloperError();
});
it('does not throw if test is less than limit', function () {
expect(function () {
Check.typeOf.number.lessThanOrEquals('mockName', 2, 3);
}).not.toThrowDeveloperError();
});
});
it('Check.defined throws when passed undefined', function () {
expect(function () {
Check.defined(undefined, 'mockName');
}).toThrowDeveloperError();
describe('Check.typeOf.number.greaterThan', function () {
it('throws if test is equal to limit', function () {
expect(function () {
Check.typeOf.number.greaterThan('mockName', 3, 3);
}).toThrowDeveloperError();
});
it('throws if test is less than limit', function () {
expect(function () {
Check.typeOf.number.greaterThan('mockName', 2, 3);
}).toThrowDeveloperError();
});
it('does not throw if test is greater than limit', function () {
expect(function () {
Check.typeOf.number.greaterThan('mockName', 4, 3);
}).not.toThrowDeveloperError();
});
});
describe('Check.typeOf.number.greaterThanOrEquals', function () {
it('throws if test is less than limit', function () {
expect(function () {
Check.typeOf.number.greaterThanOrEquals('mockName', 2, 3);
}).toThrowDeveloperError();
});
it('does not throw if test is equal to limit', function () {
expect(function () {
Check.typeOf.number.greaterThanOrEquals('mockName', 3, 3);
}).not.toThrowDeveloperError();
});
it('does not throw if test is greater than limit', function () {
expect(function () {
Check.typeOf.number.greaterThanOrEquals('mockName', 4, 3);
}).not.toThrowDeveloperError();
});
});
});

View File

@ -83,6 +83,34 @@ defineSuite([
expect(rectangle.north).toEqual(CesiumMath.toRadians(north));
});
it('fromRadians produces expected values.', function() {
var west = -1.0;
var south = -2.0;
var east = 1.0;
var north = 2.0;
var rectangle = Rectangle.fromRadians(west, south, east, north);
expect(rectangle.west).toEqual(west);
expect(rectangle.south).toEqual(south);
expect(rectangle.east).toEqual(east);
expect(rectangle.north).toEqual(north);
});
it('fromRadians works with a result parameter.', function() {
var west = -1.0;
var south = -2.0;
var east = 1.0;
var north = 2.0;
var result = new Rectangle();
var rectangle = Rectangle.fromRadians(west, south, east, north, result);
expect(result).toBe(rectangle);
expect(rectangle.west).toEqual(west);
expect(rectangle.south).toEqual(south);
expect(rectangle.east).toEqual(east);
expect(rectangle.north).toEqual(north);
});
it('fromCartographicArray produces expected values.', function() {
var minLon = new Cartographic(-0.1, 0.3, 0.0);
var minLat = new Cartographic(0.0, -0.2, 0.0);

View File

@ -0,0 +1,126 @@
/*global defineSuite*/
defineSuite([
'Core/TileAvailability',
'Core/Cartographic',
'Core/CesiumTerrainProvider',
'Core/GeographicTilingScheme',
'Core/Rectangle',
'Core/WebMercatorTilingScheme'
], function(
TileAvailability,
Cartographic,
CesiumTerrainProvider,
GeographicTilingScheme,
Rectangle,
WebMercatorTilingScheme) {
'use strict';
var webMercator = new WebMercatorTilingScheme();
var geographic = new GeographicTilingScheme();
describe('computeMaximumLevelAtPosition', function() {
it('throws if given a position outside the tiling scheme', function() {
var availability = new TileAvailability(webMercator, 15);
expect(function() {
availability.computeMaximumLevelAtPosition(Cartographic.fromDegrees(25.0, 88.0));
}).toThrowDeveloperError();
});
it('returns 0 if there are no rectangles', function() {
var availability = new TileAvailability(geographic, 15);
expect(availability.computeMaximumLevelAtPosition(Cartographic.fromDegrees(25.0, 88.0))).toBe(0);
});
it('returns the higher level when on a boundary at level 0', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(0, 0, 0, 0, 0);
availability.addAvailableTileRange(1, 1, 0, 1, 0);
expect(availability.computeMaximumLevelAtPosition(Cartographic.fromRadians(0.0, 0.0))).toBe(1);
// Make sure it isn't dependent on the order we add the rectangles.
availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(1, 1, 0, 1, 0);
availability.addAvailableTileRange(0, 0, 0, 0, 0);
expect(availability.computeMaximumLevelAtPosition(Cartographic.fromRadians(0.0, 0.0))).toBe(1);
});
it('returns the higher level when on a boundary at level 1', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(0, 0, 0, 1, 0);
availability.addAvailableTileRange(1, 1, 1, 1, 1);
expect(availability.computeMaximumLevelAtPosition(Cartographic.fromRadians(-Math.PI / 2.0, 0.0))).toBe(1);
});
});
describe('computeBestAvailableLevelOverRectangle', function() {
it('returns 0 if there are no rectangles', function() {
var availability = new TileAvailability(geographic, 15);
expect(availability.computeBestAvailableLevelOverRectangle(Rectangle.fromDegrees(1.0, 2.0, 3.0, 4.0))).toBe(0);
});
it('reports the correct level when entirely inside a worldwide rectangle of that level', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(5, 0, 0, geographic.getNumberOfXTilesAtLevel(5) - 1, geographic.getNumberOfYTilesAtLevel(5) - 1);
availability.addAvailableTileRange(6, 7, 8, 9, 10);
expect(availability.computeBestAvailableLevelOverRectangle(Rectangle.fromDegrees(1.0, 2.0, 3.0, 4.0))).toBe(5);
});
it('reports the correct level when entirely inside a smaller rectangle of that level', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(5, 0, 0, geographic.getNumberOfXTilesAtLevel(5) - 1, geographic.getNumberOfYTilesAtLevel(5) - 1);
availability.addAvailableTileRange(6, 7, 8, 9, 10);
var rectangle = geographic.tileXYToRectangle(8, 9, 6);
expect(availability.computeBestAvailableLevelOverRectangle(rectangle)).toBe(6);
});
it ('reports the correct level when partially overlapping a smaller rectangle', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(5, 0, 0, geographic.getNumberOfXTilesAtLevel(5) - 1, geographic.getNumberOfYTilesAtLevel(5) - 1);
availability.addAvailableTileRange(6, 7, 8, 7, 8);
var rectangle = geographic.tileXYToRectangle(7, 8, 6);
rectangle.west -= 0.01;
rectangle.east += 0.01;
rectangle.south -= 0.01;
rectangle.north += 0.01;
expect(availability.computeBestAvailableLevelOverRectangle(rectangle)).toBe(5);
});
it('works with a rectangle crossing 180 degrees longitude', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(5, 0, 0, geographic.getNumberOfXTilesAtLevel(5) - 1, geographic.getNumberOfYTilesAtLevel(5) - 1);
availability.addAvailableTileRange(6, 0, 0, 10, geographic.getNumberOfYTilesAtLevel(6) - 1);
availability.addAvailableTileRange(6, geographic.getNumberOfXTilesAtLevel(6) - 11, 0, geographic.getNumberOfXTilesAtLevel(6) - 1, geographic.getNumberOfYTilesAtLevel(6) - 1);
var rectangle = Rectangle.fromDegrees(179.0, 45.0, -179.0, 50.0);
expect(availability.computeBestAvailableLevelOverRectangle(rectangle)).toBe(6);
rectangle = Rectangle.fromDegrees(45.0, 45.0, -45.0, 50.0);
expect(availability.computeBestAvailableLevelOverRectangle(rectangle)).toBe(5);
});
it('works when four rectangles combine to cover the area', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(5, 0, 0, geographic.getNumberOfXTilesAtLevel(5) - 1, geographic.getNumberOfYTilesAtLevel(5) - 1);
availability.addAvailableTileRange(6, 0, 2, 1, 3);
availability.addAvailableTileRange(6, 2, 0, 3, 1);
availability.addAvailableTileRange(6, 0, 0, 1, 1);
availability.addAvailableTileRange(6, 2, 2, 3, 3);
var rectangle = geographic.tileXYToRectangle(0, 0, 4);
expect(availability.computeBestAvailableLevelOverRectangle(rectangle)).toBe(6);
});
});
describe('addAvailableTileRange', function() {
it('keeps availability ranges sorted by rectangle', function() {
var availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(0, 0, 0, 1, 0);
availability.addAvailableTileRange(1, 0, 0, 3, 1);
expect(availability.computeMaximumLevelAtPosition(new Cartographic(-Math.PI / 2.0, 0.0))).toBe(1);
// We should get the same result adding them in the opposite order.
availability = new TileAvailability(geographic, 15);
availability.addAvailableTileRange(1, 0, 0, 3, 1);
availability.addAvailableTileRange(0, 0, 0, 1, 0);
expect(availability.computeMaximumLevelAtPosition(new Cartographic(-Math.PI / 2.0, 0.0))).toBe(1);
});
});
});

View File

@ -899,6 +899,34 @@ defineSuite([
expect(rotation2D).toEqualEpsilon(expected, CesiumMath.EPSILON3);
});
it('wgs84To2DModelMatrix creates a model matrix to transform vertices centered origin to 2D', function() {
var ellipsoid = Ellipsoid.WGS84;
var projection = new GeographicProjection(ellipsoid);
var origin = Cartesian3.fromDegrees(-72.0, 40.0, 100.0, ellipsoid);
var actual = Transforms.wgs84To2DModelMatrix(projection, origin, new Matrix4());
var expected = Matrix4.fromTranslation(origin);
Transforms.basisTo2D(projection, expected, expected);
var actualRotation = Matrix4.getRotation(actual, new Matrix3());
var expectedRotation = Matrix4.getRotation(expected, new Matrix3());
expect(actualRotation).toEqualEpsilon(expectedRotation, CesiumMath.EPSILON14);
var fromENU = Transforms.eastNorthUpToFixedFrame(origin, ellipsoid, new Matrix4());
var toENU = Matrix4.inverseTransformation(fromENU, new Matrix4());
var toENUTranslation = Matrix4.getTranslation(toENU, new Cartesian4());
var projectedTranslation = Matrix4.getTranslation(expected, new Cartesian4());
var expectedTranslation = new Cartesian4();
expectedTranslation.x = projectedTranslation.x + toENUTranslation.z;
expectedTranslation.y = projectedTranslation.y + toENUTranslation.x;
expectedTranslation.z = projectedTranslation.z + toENUTranslation.y;
var actualTranslation = Matrix4.getTranslation(actual, new Cartesian4());
expect(actualTranslation).toEqualEpsilon(expectedTranslation, CesiumMath.EPSILON14);
});
it('eastNorthUpToFixedFrame throws without an origin', function() {
expect(function() {
Transforms.eastNorthUpToFixedFrame(undefined, Ellipsoid.WGS84);
@ -970,4 +998,22 @@ defineSuite([
Transforms.basisTo2D(new GeographicProjection(), Matrix4.IDENTITY, undefined);
}).toThrowDeveloperError();
});
it ('wgs84To2DModelMatrix throws without projection', function() {
expect(function() {
Transforms.wgs84To2DModelMatrix(undefined, Cartesian3.UNIT_X, new Matrix4());
}).toThrowDeveloperError();
});
it ('wgs84To2DModelMatrix throws without center', function() {
expect(function() {
Transforms.wgs84To2DModelMatrix(new GeographicProjection(), undefined, new Matrix4());
}).toThrowDeveloperError();
});
it ('wgs84To2DModelMatrix throws without result', function() {
expect(function() {
Transforms.wgs84To2DModelMatrix(new GeographicProjection(), Cartesian3.UNIT_X, undefined);
}).toThrowDeveloperError();
});
});

View File

@ -6,15 +6,15 @@ defineSuite([
'use strict';
it('logs a warning', function() {
spyOn(console, 'log');
spyOn(console, 'warn');
deprecationWarning('deprecation-identifier', 'message');
deprecationWarning('deprecation-identifier', 'message');
deprecationWarning('another deprecation-identifier', 'another message');
expect(console.log.calls.count()).toEqual(2);
expect(console.log.calls.argsFor(0)[0]).toBe('message');
expect(console.log.calls.argsFor(1)[0]).toBe('another message');
expect(console.warn.calls.count()).toEqual(2);
expect(console.warn.calls.argsFor(0)[0]).toBe('message');
expect(console.warn.calls.argsFor(1)[0]).toBe('another message');
});
it('throws without identifier', function() {

View File

@ -6,15 +6,15 @@ defineSuite([
"use strict";
it('logs a warning', function() {
spyOn(console, 'log');
spyOn(console, 'warn');
oneTimeWarning('oneTime-identifier', 'message');
oneTimeWarning('oneTime-identifier');
oneTimeWarning('another oneTime-identifier');
expect(console.log.calls.count()).toEqual(2);
expect(console.log.calls.argsFor(0)[0]).toBe('message');
expect(console.log.calls.argsFor(1)[0]).toBe('another oneTime-identifier');
expect(console.warn.calls.count()).toEqual(2);
expect(console.warn.calls.argsFor(0)[0]).toBe('message');
expect(console.warn.calls.argsFor(1)[0]).toBe('another oneTime-identifier');
});
it('throws without identifier', function() {

View File

@ -0,0 +1,95 @@
/*global defineSuite*/
defineSuite([
'Core/sampleTerrainMostDetailed',
'Core/Cartographic',
'Core/CesiumTerrainProvider',
'Core/GeographicTilingScheme',
'Core/Rectangle',
'ThirdParty/when'
], function(
sampleTerrainMostDetailed,
Cartographic,
CesiumTerrainProvider,
GeographicTilingScheme,
Rectangle,
when) {
"use strict";
var terrainProvider = new CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world'
});
it('queries heights', function() {
var positions = [
Cartographic.fromDegrees(86.925145, 27.988257),
Cartographic.fromDegrees(87.0, 28.0)
];
return sampleTerrainMostDetailed(terrainProvider, positions).then(function(passedPositions) {
expect(passedPositions).toBe(positions);
expect(positions[0].height).toBeGreaterThan(5000);
expect(positions[0].height).toBeLessThan(10000);
expect(positions[1].height).toBeGreaterThan(5000);
expect(positions[1].height).toBeLessThan(10000);
});
});
it('should throw querying heights from Small Terrain', function() {
var terrainProvider = new CesiumTerrainProvider({
url : '//cesiumjs.org/smallTerrain'
});
var positions = [
Cartographic.fromDegrees(86.925145, 27.988257),
Cartographic.fromDegrees(87.0, 28.0)
];
return sampleTerrainMostDetailed(terrainProvider, positions).then(function() {
fail('the promise should not resolve');
}).otherwise(function() {
});
});
it('uses a suitable common tile height for a range of locations', function() {
var positions = [
Cartographic.fromDegrees(86.925145, 27.988257),
Cartographic.fromDegrees(87.0, 28.0)
];
return sampleTerrainMostDetailed(terrainProvider, positions).then(function() {
expect(positions[0].height).toBeGreaterThan(5000);
expect(positions[0].height).toBeLessThan(10000);
expect(positions[1].height).toBeGreaterThan(5000);
expect(positions[1].height).toBeLessThan(10000);
});
});
it('requires terrainProvider and positions', function() {
var positions = [
Cartographic.fromDegrees(86.925145, 27.988257),
Cartographic.fromDegrees(87.0, 28.0)
];
expect(function() {
sampleTerrainMostDetailed(undefined, positions);
}).toThrowDeveloperError();
expect(function() {
sampleTerrainMostDetailed(terrainProvider, undefined);
}).toThrowDeveloperError();
});
it('works for a dodgy point right near the edge of a tile', function() {
var stkWorldTerrain = new CesiumTerrainProvider({
url : '//assets.agi.com/stk-terrain/world'
});
var positions = [new Cartographic(0.33179290856829535, 0.7363107781851078)];
return sampleTerrainMostDetailed(stkWorldTerrain, positions).then(function() {
expect(positions[0].height).toBeDefined();
});
});
});

Binary file not shown.

View File

@ -556,7 +556,7 @@ defineSuite([
expect(result).toEqual([sampledProperty.getValue(t1), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep, new JulianDate())), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep * 2, new JulianDate())), sampledProperty.getValue(updateTime), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep * 3, new JulianDate())), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep * 4, new JulianDate())), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep * 5, new JulianDate())), sampledProperty.getValue(JulianDate.addSeconds(t1, maximumStep * 6, new JulianDate()))]);
});
it('subSample works for composite properties', function() {
function createCompositeTest(useReferenceProperty){
var t1 = new JulianDate(0, 0);
var t2 = new JulianDate(1, 0);
var t3 = new JulianDate(2, 0);
@ -635,7 +635,15 @@ defineSuite([
var referenceFrame = ReferenceFrame.FIXED;
var maximumStep = 43200;
var result = [];
PathVisualizer._subSample(property, t1, t6, updateTime, referenceFrame, maximumStep, result);
var propertyToTest = property;
if (useReferenceProperty) {
var testReference = entities.getOrCreateEntity('testReference');
testReference.position = property;
propertyToTest = new ReferenceProperty(entities, 'testReference', ['position']);
}
PathVisualizer._subSample(propertyToTest, t1, t6, updateTime, referenceFrame, maximumStep, result);
expect(result).toEqual([intervalProperty.intervals.get(0).data,
constantProperty.getValue(t1),
sampledProperty.getValue(t3),
@ -643,6 +651,14 @@ defineSuite([
sampledProperty.getValue(t4),
targetEntity.position.getValue(t5),
scaledProperty.getValue(t6)]);
}
it('subSample works for composite properties', function() {
createCompositeTest(false);
});
it('subSample works for composite properties wrapped in reference properties', function() {
createCompositeTest(true);
});
}, 'WebGL');

View File

@ -1216,4 +1216,13 @@ defineSuite([
fragmentShader : fs
}).contextToRender();
});
it('has czm_imagerySplitPosition', function() {
var fs =
'void main() { ' +
' gl_FragColor = vec4(czm_imagerySplitPosition == 0.0); ' +
'}';
context.verifyDrawForSpecs(fs);
});
}, 'WebGL');

View File

@ -13,6 +13,7 @@ defineSuite([
'Core/NearFarScalar',
'Core/Rectangle',
'Scene/Billboard',
'Scene/BlendOption',
'Scene/HeightReference',
'Scene/HorizontalOrigin',
'Scene/OrthographicFrustum',
@ -36,6 +37,7 @@ defineSuite([
NearFarScalar,
Rectangle,
Billboard,
BlendOption,
HeightReference,
HorizontalOrigin,
OrthographicFrustum,
@ -230,6 +232,30 @@ defineSuite([
expect(billboards.isDestroyed()).toEqual(false);
});
it('renders billboard in multiple passes', function() {
billboards.add({
position : Cartesian3.ZERO,
image : greenImage
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
var frameState = scene.frameState;
frameState.commandList.length = 0;
billboards.blendOption = BlendOption.OPAQUE_AND_TRANSLUCENT;
billboards.update(frameState);
expect(frameState.commandList.length).toEqual(2);
frameState.commandList.length = 0;
billboards.blendOption = BlendOption.OPAQUE;
billboards.update(frameState);
expect(frameState.commandList.length).toEqual(1);
frameState.commandList.length = 0;
billboards.blendOption = BlendOption.TRANSLUCENT;
billboards.update(frameState);
expect(frameState.commandList.length).toEqual(1);
});
it('renders billboard with sizeInMeters', function() {
billboards.add({
position : Cartesian3.ZERO,

View File

@ -18,6 +18,7 @@ defineSuite([
'Scene/Globe',
'Scene/GlobeSurfaceShaderSet',
'Scene/ImageryLayerCollection',
'Scene/ImagerySplitDirection',
'Scene/QuadtreeTile',
'Scene/QuadtreeTileProvider',
'Scene/SceneMode',
@ -44,6 +45,7 @@ defineSuite([
Globe,
GlobeSurfaceShaderSet,
ImageryLayerCollection,
ImagerySplitDirection,
QuadtreeTile,
QuadtreeTileProvider,
SceneMode,
@ -477,6 +479,7 @@ defineSuite([
layer.gamma = 0.321;
layer.saturation = 0.123;
layer.hue = 0.456;
layer.splitDirection = ImagerySplitDirection.LEFT;
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
@ -502,6 +505,7 @@ defineSuite([
expect(uniforms.u_dayTextureOneOverGamma()).toEqual([1.0 / 0.321]);
expect(uniforms.u_dayTextureSaturation()).toEqual([0.123]);
expect(uniforms.u_dayTextureHue()).toEqual([0.456]);
expect(uniforms.u_dayTextureSplit()).toEqual([ImagerySplitDirection.LEFT]);
}
expect(tileCommandCount).toBeGreaterThan(0);

View File

@ -11,6 +11,7 @@ defineSuite([
'Core/Math',
'Core/NearFarScalar',
'Core/Rectangle',
'Scene/BlendOption',
'Scene/Globe',
'Scene/HeightReference',
'Scene/HorizontalOrigin',
@ -31,6 +32,7 @@ defineSuite([
CesiumMath,
NearFarScalar,
Rectangle,
BlendOption,
Globe,
HeightReference,
HorizontalOrigin,
@ -347,6 +349,32 @@ defineSuite([
});
});
it('renders in multiple passes', function() {
labels.add({
position : Cartesian3.ZERO,
text : 'x',
horizontalOrigin : HorizontalOrigin.CENTER,
verticalOrigin : VerticalOrigin.CENTER
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
var frameState = scene.frameState;
frameState.commandList.length = 0;
labels.blendOption = BlendOption.OPAQUE_AND_TRANSLUCENT;
labels.update(frameState);
expect(frameState.commandList.length).toEqual(2);
frameState.commandList.length = 0;
labels.blendOption = BlendOption.OPAQUE;
labels.update(frameState);
expect(frameState.commandList.length).toEqual(1);
frameState.commandList.length = 0;
labels.blendOption = BlendOption.TRANSLUCENT;
labels.update(frameState);
expect(frameState.commandList.length).toEqual(1);
});
it('can render after adding a label', function() {
labels.add({
position : Cartesian3.ZERO,

View File

@ -79,6 +79,7 @@ defineSuite([
var texturedBoxCustomUrl = './Data/Models/Box-Textured-Custom/CesiumTexturedBoxTest.gltf';
var texturedBoxKhrBinaryUrl = './Data/Models/Box-Textured-Binary/CesiumTexturedBoxTest.glb';
var boxRtcUrl = './Data/Models/Box-RTC/Box.gltf';
var boxesEcefUrl = './Data/Models/Boxes-ECEF/ecef.glb';
var cesiumAirUrl = './Data/Models/CesiumAir/Cesium_Air.gltf';
var cesiumAir_0_8Url = './Data/Models/CesiumAir/Cesium_Air_0_8.gltf';
var animBoxesUrl = './Data/Models/anim-test-1-boxes/anim-test-1-boxes.gltf';
@ -267,6 +268,50 @@ defineSuite([
});
});
it('renders RTC in 2D', function() {
return loadModel(boxRtcUrl, {
modelMatrix : Matrix4.IDENTITY,
minimumPixelSize : 1
}).then(function(m) {
scene.morphTo2D(0.0);
verifyRender(m);
primitives.remove(m);
});
});
it('renders ECEF in 2D', function() {
return loadModel(boxesEcefUrl, {
modelMatrix : Matrix4.IDENTITY,
minimumPixelSize : undefined
}).then(function(m) {
scene.morphTo2D(0.0);
verifyRender(m);
primitives.remove(m);
});
});
it('renders RTC in CV', function() {
return loadModel(boxRtcUrl, {
modelMatrix : Matrix4.IDENTITY,
minimumPixelSize : 1
}).then(function(m) {
scene.morphToColumbusView(0.0);
verifyRender(m);
primitives.remove(m);
});
});
it('renders ECEF in CV', function() {
return loadModel(boxesEcefUrl, {
modelMatrix : Matrix4.IDENTITY,
minimumPixelSize : undefined
}).then(function(m) {
scene.morphToColumbusView(0.0);
verifyRender(m);
primitives.remove(m);
});
});
it('resolves readyPromise', function() {
return texturedBoxModel.readyPromise.then(function(model) {
verifyRender(model);

View File

@ -10,6 +10,7 @@ defineSuite([
'Core/Math',
'Core/NearFarScalar',
'Core/Rectangle',
'Scene/BlendOption',
'Scene/PointPrimitive',
'Specs/createScene'
], function(
@ -23,6 +24,7 @@ defineSuite([
CesiumMath,
NearFarScalar,
Rectangle,
BlendOption,
PointPrimitive,
createScene) {
'use strict';
@ -155,6 +157,30 @@ defineSuite([
expect(pointPrimitives.isDestroyed()).toEqual(false);
});
it('renders pointPrimitive in multiple passes', function() {
pointPrimitives.add({
position : Cartesian3.ZERO,
color : Color.LIME
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
var frameState = scene.frameState;
frameState.commandList.length = 0;
pointPrimitives.blendOption = BlendOption.OPAQUE_AND_TRANSLUCENT;
pointPrimitives.update(frameState);
expect(frameState.commandList.length).toEqual(2);
frameState.commandList.length = 0;
pointPrimitives.blendOption = BlendOption.OPAQUE;
pointPrimitives.update(frameState);
expect(frameState.commandList.length).toEqual(1);
frameState.commandList.length = 0;
pointPrimitives.blendOption = BlendOption.TRANSLUCENT;
pointPrimitives.update(frameState);
expect(frameState.commandList.length).toEqual(1);
});
it('disables pointPrimitive scaleByDistance', function() {
var p = pointPrimitives.add({
scaleByDistance : new NearFarScalar(1.0, 3.0, 1.0e6, 0.0)

View File

@ -883,4 +883,48 @@ defineSuite([
expect(s.maximumCubeMapSize).toBeGreaterThanOrEqualTo(16);
s.destroyForSpecs();
});
it('does not throw with debugShowCommands', function() {
var s = createScene();
if (s.context.drawBuffers) {
s.debugShowCommands = true;
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
var rectanglePrimitive = createRectangle(rectangle, 1000.0);
rectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);
var primitives = s.primitives;
primitives.add(rectanglePrimitive);
s.camera.setView({ destination : rectangle });
expect(function() {
s.renderForSpecs();
}).not.toThrowRuntimeError();
}
s.destroyForSpecs();
});
it('does not throw with debugShowFrustums', function() {
var s = createScene();
if (s.context.drawBuffers) {
s.debugShowFrustums = true;
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
var rectanglePrimitive = createRectangle(rectangle, 1000.0);
rectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);
var primitives = s.primitives;
primitives.add(rectanglePrimitive);
s.camera.setView({ destination : rectangle });
expect(function() {
s.renderForSpecs();
}).not.toThrowRuntimeError();
}
s.destroyForSpecs();
});
}, 'WebGL');

View File

@ -438,6 +438,7 @@ defineSuite([
expect(scene.shadowMap._isSpotLight).toBe(false);
expect(scene.shadowMap._cascadesEnabled).toBe(true);
expect(scene.shadowMap._numberOfCascades).toBe(4);
expect(scene.shadowMap._normalOffset).toBe(true);
});
it('throws without options.context', function() {
@ -1032,6 +1033,16 @@ defineSuite([
});
});
it('set normalOffset', function() {
createCascadedShadowMap();
scene.shadowMap.normalOffset = false;
expect(scene.shadowMap._normalOffset, false);
expect(scene.shadowMap._terrainBias, false);
expect(scene.shadowMap._primitiveBias, false);
expect(scene.shadowMap._pointBias, false);
});
it('set maximumDistance', function() {
box.show = true;
floor.show = true;

View File

@ -130,6 +130,7 @@ defineSuite([
expect(viewModel._selectedSuggestion.displayName).toEqual('a');
viewModel._handleArrowUp(viewModel);
expect(viewModel._selectedSuggestion).toBeUndefined();
document.body.removeChild(container);
});
}, 'WebGL');

View File

@ -35,7 +35,7 @@ define([
var primitive = scene.primitives.get(0);
expect(state).toBe(BoundingSphereState.DONE);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(result).toEqualEpsilon(BoundingSphere.transform(attributes.boundingSphere, primitive.modelMatrix, new BoundingSphere()), CesiumMath.EPSILON6);
expect(result).toEqualEpsilon(attributes.boundingSphere, CesiumMath.EPSILON6);
updater.destroy();
scene.primitives.removeAll();
@ -62,7 +62,7 @@ define([
var primitive = scene.primitives.get(0);
expect(state).toBe(BoundingSphereState.DONE);
var attributes = primitive.getGeometryInstanceAttributes(entity);
expect(result).toEqualEpsilon(BoundingSphere.transform(attributes.boundingSphere, primitive.modelMatrix, new BoundingSphere()), CesiumMath.EPSILON6);
expect(result).toEqualEpsilon(attributes.boundingSphere, CesiumMath.EPSILON6);
updater.destroy();
scene.primitives.removeAll();

View File

@ -49,7 +49,7 @@
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-tap": "^0.1.3",
"gulp-zip": "^3.2.0",
"gulp-zip": "^4.0.0",
"jasmine-core": "^2.5.2",
"jsdoc": "^3.4.3",
"jshint": "^2.9.4",

View File

@ -47,6 +47,11 @@
var app = express();
app.use(compression());
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use(express.static(__dirname));
function getRemoteUrlFromParam(req) {