diff --git a/.concierge/templates/pullRequestOpened.hbs b/.concierge/templates/pullRequestOpened.hbs index f494947adb9..8408c266f8a 100644 --- a/.concierge/templates/pullRequestOpened.hbs +++ b/.concierge/templates/pullRequestOpened.hbs @@ -1,7 +1,7 @@ {{#if askAboutContributors}} Thank you so much for the pull request @{{ userName }}! I noticed this is your first pull request and I wanted to say welcome to the Cesium community! -The [Pull Request Guidelines](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#pull-request-guidelines) is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that. +The [Pull Request Guidelines](https://github.com/CesiumGS/cesium/blob/master/CONTRIBUTING.md#pull-request-guidelines) is a handy reference for making sure your PR gets accepted quickly, so make sure to skim that. * :x: Missing `CONTRIBUTORS.md` entry. * Please add yourself to the [contributors]({{ contributorsUrl }}) file! @@ -10,7 +10,7 @@ Thanks for the pull request @{{ userName }}! {{/if}} {{#if claEnabled}} {{#if errorCla}} -* :grey_exclamation: There was an error checking the CLA! If this is your first contribution, please send in a [Contributor License Agreement](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#contributor-license-agreement-cla). +* :grey_exclamation: There was an error checking the CLA! If this is your first contribution, please send in a [Contributor License Agreement](https://github.com/CesiumGS/cesium/blob/master/CONTRIBUTING.md#contributor-license-agreement-cla). * Maintainers, this was the error I ran into while attempting to process the CLA check. Please resolve it to continue CLA checking. ``` {{ errorCla }} @@ -18,7 +18,7 @@ Thanks for the pull request @{{ userName }}! {{else}} {{#if askForCla}} * :x: Missing CLA. - * Please send in a [Contributor License Agreement](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md#contributor-license-agreement-cla) (CLA) and comment back here to let us know to check this! + * Please send in a [Contributor License Agreement](https://github.com/CesiumGS/cesium/blob/master/CONTRIBUTING.md#contributor-license-agreement-cla) (CLA) and comment back here to let us know to check this! {{else}} * :heavy_check_mark: Signed CLA found. {{/if}} @@ -34,7 +34,7 @@ Thanks for the pull request @{{ userName }}! {{/if}} {{#if askAboutTests}} * :grey_question: Unit tests were not updated. - * Make sure you've [updated tests](https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/TestingGuide) to reflect your changes, added tests for any new code, and ran the code coverage tool. + * Make sure you've [updated tests](https://github.com/CesiumGS/cesium/tree/master/Documentation/Contributors/TestingGuide) to reflect your changes, added tests for any new code, and ran the code coverage tool. {{/if}} Reviewers, don't forget to make sure that: diff --git a/.editorconfig b/.editorconfig index 1c96445761b..10198a9679d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,7 +3,7 @@ root = true [*] indent_style = space -indent_size = 4 +indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true @@ -11,5 +11,5 @@ insert_final_newline = true [*.md] trim_trailing_whitespace = false -[package.json] -indent_size = 2 +[*.glsl] +indent_size = 4 diff --git a/.eslintrc.json b/.eslintrc.json index 6c69dcbf3be..9cdd09c0f44 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": "./Tools/eslint-config-cesium/browser.js", + "extends": ["./Tools/eslint-config-cesium/browser.js", "prettier"], "plugins": [ "html" ], @@ -9,8 +9,8 @@ "overrides": [ { "files": [ - "index.js", - "server.js", + "index.cjs", + "server.cjs", "gulpfile.js", "Source/Workers/transferTypedArrayTest.js" ], diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 4790cd680f4..bba36ec66c7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,25 +4,25 @@ about: Let us know so we can fix it! --- +--> -Sandcastle example: +Sandcastle example: Browser: Operating System: - \ No newline at end of file +--> diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 13ea40291f8..db5de8edb56 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -3,12 +3,12 @@ name: Request a feature about: New ideas & improvements to Cesium are always welcome. --- - +https://github.com/CesiumGS/cesium/blob/master/CONTRIBUTING.md +--> diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md index d22278d4782..7f8d2800d44 100644 --- a/.github/ISSUE_TEMPLATE/question.md +++ b/.github/ISSUE_TEMPLATE/question.md @@ -1,6 +1,6 @@ --- name: Ask a question -about: Please use the forum (https://groups.google.com/forum/#!forum/cesium-dev) for general questions about using Cesium. +about: Please use the community forum (https://community.cesium.com/) for general questions about using Cesium. --- -:exclamation: Please use the [forum](https://groups.google.com/forum/#!forum/cesium-dev) for asking questions about how to use Cesium and best practices. The core Cesium team actively monitors the forum and we love seeing what people are working on! :exclamation: \ No newline at end of file +:exclamation: Please use the [community forum](https://community.cesium.com/) for asking questions about how to use Cesium and best practices. The core Cesium team actively monitors the forum and we love seeing what people are working on! :exclamation: diff --git a/.gitignore b/.gitignore index 0a6c57a54ee..65c4e736be6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /Build /Cesium-*.zip /cesium-*.tgz +.directory .DS_Store Thumbs.db .eslintcache @@ -13,6 +14,7 @@ Thumbs.db /Apps/Sandcastle/templates/bucket.css /Source/Cesium.js +/Source/Cesium.d.ts /Specs/SpecList.js /Source/Shaders/**/*.js @@ -25,7 +27,12 @@ Thumbs.db npm-debug.log npm-debug.log.* package-lock.json +yarn.lock # WebStorm user-specific .idea/workspace.xml .idea/tasks.xml + +# Codeship +deployment/secrets +deployment/*.aes \ No newline at end of file diff --git a/.gulp.json b/.gulp.json new file mode 100644 index 00000000000..96507cb26cf --- /dev/null +++ b/.gulp.json @@ -0,0 +1,5 @@ +{ + "flags": { + "gulpfile": "gulpfile.cjs" + } +} diff --git a/.npmignore b/.npmignore index 98c5270d4a0..4cd522beade 100644 --- a/.npmignore +++ b/.npmignore @@ -23,11 +23,11 @@ /index.html /index.release.html /launches -/server.js +/server.cjs /Source/copyrightHeader.js /Specs /ThirdParty /Tools /web.config - +/deployment Thumbs.db diff --git a/.npmrc b/.npmrc index 43c97e719a5..ae643592e76 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1 @@ -package-lock=false +//registry.npmjs.org/:_authToken=${NPM_TOKEN} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..c4fbdbbe4e0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,31 @@ + +# Ignore everything +* + +# Unignore directories (to all depths) and unignore code and style files in these directories +!.concierge/**/ +!.github/**/ +!.vscode/**/ +!Apps/**/ +!Documentation/**/ +!Source/**/ +!Specs/**/ +!Tools/**/ + +!**/*.js +!**/*.cjs +!**/*.css +!**/*.html +!**/*.md +!**/*.ts + +# Re-ignore a few things caught above +**/*.min.js +Source/Cesium.js +Source/Shaders/**/*.js +Source/ThirdParty/** +Source/Workers/**/* +Apps/Sandcastle/ThirdParty + +!Source/Workers/cesiumWorkerBootstrapper.js +!Source/Workers/transferTypedArrayTest.js diff --git a/.slackbot.yml b/.slackbot.yml index a43423d77aa..3b5002c9582 100644 --- a/.slackbot.yml +++ b/.slackbot.yml @@ -1,15 +1,12 @@ +# List of Slack usernames (not GitHub) for the Cesium Concierge Slackbot to send release reminders for. releaseSchedule: - OmarShehata: 9/2/2019 - mramato: 10/1/2019 - hpinkos: 11/1/2019 - lilleyse: 12/1/2019 - ggetz: 1/2/2020 - likangning93: 2/3/2020 - tfili: 3/2/2020 - -greetings: - - Happy Friday everyone! - - Can you believe Friday is already here? - - I hope you all had awesome week! - - I skipped breakfast, so I hope Gary baked something good today... - - Good morning everyone! + mamato: 3/2/2020 + oshehata: 4/1/2020 + lilleyse: 5/1/2020 + ian: 6/1/2020 + sam.suhag: 7/1/2020 + sam.vargas: 8/3/2020 + kevin: 9/1/2020 + mamato: 10/1/2020 + oshehata: 11/2/2020 + lilleyse: 12/1/2020 diff --git a/.travis.yml b/.travis.yml index be47106c948..0011687bc9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,18 @@ language: node_js node_js: - - "8" -sudo: false + - "10" addons: chrome: stable firefox: latest -services: - - xvfb -before_script: - - export DISPLAY=:99.0 script: - npm --silent run deploy-set-version -- --buildVersion $TRAVIS_BRANCH.$TRAVIS_BUILD_NUMBER - npm --silent run deploy-status -- --status pending --message 'Waiting for build' - npm --silent run eslint + - npm --silent run prettier-check - npm --silent run build + - npm --silent run build-ts - npm --silent run coverage -- --browsers FirefoxHeadless --webgl-stub --failTaskOnError --suppressPassed - travis_wait 20 npm --silent run makeZipFile -- --concurrency 1 @@ -29,9 +26,9 @@ script: - npm --silent run build-specs - npm --silent run test -- --browsers ChromeCI --failTaskOnError --webgl-stub --release --suppressPassed -# Various Node.js smoke-screen tests + # Various Node.js smoke-screen tests - node -e "const Cesium = require('./');" - - NODE_ENV=development node index.js - - NODE_ENV=production node index.js + - NODE_ENV=development node index.cjs + - NODE_ENV=production node index.cjs - npm --silent run cloc diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5858a95eb3f..e88b02a9cb4 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", "slevesque.shader", "cesium.gltf-vscode" ] diff --git a/.vscode/launch.json b/.vscode/launch.json index 85fb445c2db..7e924cbc0ed 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,5 @@ { - // Use IntelliSense to learn about possible Node.js debug attributes. + // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", @@ -8,14 +8,10 @@ "type": "node", "request": "launch", "name": "Launch Program", - "program": "${workspaceRoot}\\server.js", - "cwd": "${workspaceRoot}" - }, - { - "type": "node", - "request": "attach", - "name": "Attach to Process", - "port": 5858 + "cwd": "${workspaceFolder}", + "runtimeExecutable": "npm", + "runtimeArgs": ["run-script", "start"], + "noDebug": true } ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index df34d28b3c8..1989f69b7f9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,11 +19,6 @@ "files.associations": { "*.czml": "json" }, - "files.trimTrailingWhitespace": true, - "files.insertFinalNewline": true, - "editor.insertSpaces": true, - "editor.tabSize": 4, - "editor.detectIndentation": false, "eslint.enable": true, "javascript.format.insertSpaceAfterCommaDelimiter": true, "javascript.format.insertSpaceAfterSemicolonInForStatements": true, @@ -33,5 +28,6 @@ "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, "javascript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, "javascript.format.placeOpenBraceOnNewLineForFunctions": false, - "javascript.format.placeOpenBraceOnNewLineForControlBlocks": false + "javascript.format.placeOpenBraceOnNewLineForControlBlocks": false, + "glTF.defaultV2Engine": "Cesium" } diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 4befb021f0c..00000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "0.1.0", - "command": "gulp", - "isShellCommand": true, - "args": [ - "--no-color" - ], - "tasks": [ - { - "taskName": "build", - "args": [], - "isBuildCommand": true, - "isBackground": false, - "problemMatcher": [ - "$lessCompile", - "$tsc", - "$jshint" - ] - }, - { - "taskName": "test", - "args": [], - "isTestCommand": true - }, - { - "taskName": "build-watch", - "isBackground": true - } - ] -} diff --git a/Apps/.jshintrc b/Apps/.jshintrc index ad12e9a7e03..b7b6dc60c89 100644 --- a/Apps/.jshintrc +++ b/Apps/.jshintrc @@ -21,7 +21,6 @@ "boss": false, "debug": false, "eqnull": false, - "esnext": false, "moz": false, "evil": false, "expr": false, diff --git a/Apps/CesiumViewer/CesiumViewer.css b/Apps/CesiumViewer/CesiumViewer.css index 9345e863194..9f8fde9875b 100644 --- a/Apps/CesiumViewer/CesiumViewer.css +++ b/Apps/CesiumViewer/CesiumViewer.css @@ -2,40 +2,40 @@ @import url(../../Source/Widgets/lighter.css); html { - height: 100%; + height: 100%; } body { - height: 100%; - width: 100%; - margin: 0; - overflow: hidden; - padding: 0; - background: #000; + height: 100%; + width: 100%; + margin: 0; + overflow: hidden; + padding: 0; + background: #000; } .fullWindow { - position: absolute; - top: 0; - left: 0; - height: 100%; - width: 100%; - margin: 0; - overflow: hidden; - padding: 0; - font-family: sans-serif; + position: absolute; + top: 0; + left: 0; + height: 100%; + width: 100%; + margin: 0; + overflow: hidden; + padding: 0; + font-family: sans-serif; } .loadingIndicator { - display: block; - position: absolute; - top: 50%; - left: 50%; - margin-top: -33px; - margin-left: -33px; - width: 66px; - height: 66px; - background-position: center; - background-repeat: no-repeat; - background-image: url(Images/ajax-loader.gif); + display: block; + position: absolute; + top: 50%; + left: 50%; + margin-top: -33px; + margin-left: -33px; + width: 66px; + height: 66px; + background-position: center; + background-repeat: no-repeat; + background-image: url(Images/ajax-loader.gif); } diff --git a/Apps/CesiumViewer/CesiumViewer.js b/Apps/CesiumViewer/CesiumViewer.js index 9b6104c2fdf..764424718f4 100644 --- a/Apps/CesiumViewer/CesiumViewer.js +++ b/Apps/CesiumViewer/CesiumViewer.js @@ -1,24 +1,24 @@ -window.CESIUM_BASE_URL = '../../Source/'; +window.CESIUM_BASE_URL = "../../Source/"; import { - Cartesian3, - createWorldTerrain, - defined, - formatError, - Math as CesiumMath, - objectToQuery, - queryToObject, - CzmlDataSource, - GeoJsonDataSource, - KmlDataSource, - TileMapServiceImageryProvider, - Viewer, - viewerCesiumInspectorMixin, - viewerDragDropMixin -} from '../../Source/Cesium.js'; + Cartesian3, + createWorldTerrain, + defined, + formatError, + Math as CesiumMath, + objectToQuery, + queryToObject, + CzmlDataSource, + GeoJsonDataSource, + KmlDataSource, + TileMapServiceImageryProvider, + Viewer, + viewerCesiumInspectorMixin, + viewerDragDropMixin, +} from "../../Source/Cesium.js"; function main() { - /* + /* Options parsed from query string: source=url The URL of a CZML/GeoJSON/KML data source to load at startup. Automatic data type detection uses file extension. @@ -37,174 +37,210 @@ function main() { [height,heading,pitch,roll] default is looking straight down, [300,0,-90,0] saveCamera=false Don't automatically update the camera view in the URL when it changes. */ - var endUserOptions = queryToObject(window.location.search.substring(1)); + var endUserOptions = queryToObject(window.location.search.substring(1)); - var imageryProvider; - if (defined(endUserOptions.tmsImageryUrl)) { - imageryProvider = new TileMapServiceImageryProvider({ - url : endUserOptions.tmsImageryUrl - }); - } - - var loadingIndicator = document.getElementById('loadingIndicator'); - var viewer; - try { - var hasBaseLayerPicker = !defined(imageryProvider); - viewer = new Viewer('cesiumContainer', { - imageryProvider : imageryProvider, - baseLayerPicker : hasBaseLayerPicker, - scene3DOnly : endUserOptions.scene3DOnly, - requestRenderMode : true - }); - - if (hasBaseLayerPicker) { - var viewModel = viewer.baseLayerPicker.viewModel; - viewModel.selectedTerrain = viewModel.terrainProviderViewModels[1]; - } else { - viewer.terrainProvider = createWorldTerrain({ - requestWaterMask: true, - requestVertexNormals: true - }); - } - } catch (exception) { - loadingIndicator.style.display = 'none'; - var message = formatError(exception); - console.error(message); - if (!document.querySelector('.cesium-widget-errorPanel')) { - window.alert(message); //eslint-disable-line no-alert - } - return; - } - - viewer.extend(viewerDragDropMixin); - if (endUserOptions.inspector) { - viewer.extend(viewerCesiumInspectorMixin); - } - - var showLoadError = function(name, error) { - var title = 'An error occurred while loading the file: ' + name; - var message = 'An error occurred while loading the file, which may indicate that it is invalid. A detailed error report is below:'; - viewer.cesiumWidget.showErrorPanel(title, message, error); - }; - - viewer.dropError.addEventListener(function(viewerArg, name, error) { - showLoadError(name, error); + var imageryProvider; + if (defined(endUserOptions.tmsImageryUrl)) { + imageryProvider = new TileMapServiceImageryProvider({ + url: endUserOptions.tmsImageryUrl, + }); + } + + var loadingIndicator = document.getElementById("loadingIndicator"); + var viewer; + try { + var hasBaseLayerPicker = !defined(imageryProvider); + viewer = new Viewer("cesiumContainer", { + imageryProvider: imageryProvider, + baseLayerPicker: hasBaseLayerPicker, + scene3DOnly: endUserOptions.scene3DOnly, + requestRenderMode: true, }); - var scene = viewer.scene; - var context = scene.context; - if (endUserOptions.debug) { - context.validateShaderProgram = true; - context.validateFramebuffer = true; - context.logShaderCompilation = true; - context.throwOnWebGLError = true; + if (hasBaseLayerPicker) { + var viewModel = viewer.baseLayerPicker.viewModel; + viewModel.selectedTerrain = viewModel.terrainProviderViewModels[1]; + } else { + viewer.terrainProvider = createWorldTerrain({ + requestWaterMask: true, + requestVertexNormals: true, + }); } - - var view = endUserOptions.view; - var source = endUserOptions.source; - if (defined(source)) { - var sourceType = endUserOptions.sourceType; - if (!defined(sourceType)) { - // autodetect using file extension if not specified - if (/\.czml$/i.test(source)) { - sourceType = 'czml'; - } else if (/\.geojson$/i.test(source) || /\.json$/i.test(source) || /\.topojson$/i.test(source)) { - sourceType = 'geojson'; - } else if (/\.kml$/i.test(source) || /\.kmz$/i.test(source)) { - sourceType = 'kml'; - } - } - - var loadPromise; - if (sourceType === 'czml') { - loadPromise = CzmlDataSource.load(source); - } else if (sourceType === 'geojson') { - loadPromise = GeoJsonDataSource.load(source); - } else if (sourceType === 'kml') { - loadPromise = KmlDataSource.load(source, { - camera: scene.camera, - canvas: scene.canvas - }); - } else { - showLoadError(source, 'Unknown format.'); - } - - if (defined(loadPromise)) { - viewer.dataSources.add(loadPromise).then(function(dataSource) { - var lookAt = endUserOptions.lookAt; - if (defined(lookAt)) { - var entity = dataSource.entities.getById(lookAt); - if (defined(entity)) { - viewer.trackedEntity = entity; - } else { - var error = 'No entity with id "' + lookAt + '" exists in the provided data source.'; - showLoadError(source, error); - } - } else if (!defined(view) && endUserOptions.flyTo !== 'false') { - viewer.flyTo(dataSource); - } - }).otherwise(function(error) { - showLoadError(source, error); - }); - } + } catch (exception) { + loadingIndicator.style.display = "none"; + var message = formatError(exception); + console.error(message); + if (!document.querySelector(".cesium-widget-errorPanel")) { + //eslint-disable-next-line no-alert + window.alert(message); } - - if (endUserOptions.stats) { - scene.debugShowFramesPerSecond = true; + return; + } + + viewer.extend(viewerDragDropMixin); + if (endUserOptions.inspector) { + viewer.extend(viewerCesiumInspectorMixin); + } + + var showLoadError = function (name, error) { + var title = "An error occurred while loading the file: " + name; + var message = + "An error occurred while loading the file, which may indicate that it is invalid. A detailed error report is below:"; + viewer.cesiumWidget.showErrorPanel(title, message, error); + }; + + viewer.dropError.addEventListener(function (viewerArg, name, error) { + showLoadError(name, error); + }); + + var scene = viewer.scene; + var context = scene.context; + if (endUserOptions.debug) { + context.validateShaderProgram = true; + context.validateFramebuffer = true; + context.logShaderCompilation = true; + context.throwOnWebGLError = true; + } + + var view = endUserOptions.view; + var source = endUserOptions.source; + if (defined(source)) { + var sourceType = endUserOptions.sourceType; + if (!defined(sourceType)) { + // autodetect using file extension if not specified + if (/\.czml$/i.test(source)) { + sourceType = "czml"; + } else if ( + /\.geojson$/i.test(source) || + /\.json$/i.test(source) || + /\.topojson$/i.test(source) + ) { + sourceType = "geojson"; + } else if (/\.kml$/i.test(source) || /\.kmz$/i.test(source)) { + sourceType = "kml"; + } } - var theme = endUserOptions.theme; - if (defined(theme)) { - if (endUserOptions.theme === 'lighter') { - document.body.classList.add('cesium-lighter'); - viewer.animation.applyThemeChanges(); - } else { - var error = 'Unknown theme: ' + theme; - viewer.cesiumWidget.showErrorPanel(error, ''); - } + var loadPromise; + if (sourceType === "czml") { + loadPromise = CzmlDataSource.load(source); + } else if (sourceType === "geojson") { + loadPromise = GeoJsonDataSource.load(source); + } else if (sourceType === "kml") { + loadPromise = KmlDataSource.load(source, { + camera: scene.camera, + canvas: scene.canvas, + }); + } else { + showLoadError(source, "Unknown format."); } - if (defined(view)) { - var splitQuery = view.split(/[ ,]+/); - if (splitQuery.length > 1) { - var longitude = !isNaN(+splitQuery[0]) ? +splitQuery[0] : 0.0; - var latitude = !isNaN(+splitQuery[1]) ? +splitQuery[1] : 0.0; - var height = ((splitQuery.length > 2) && (!isNaN(+splitQuery[2]))) ? +splitQuery[2] : 300.0; - var heading = ((splitQuery.length > 3) && (!isNaN(+splitQuery[3]))) ? CesiumMath.toRadians(+splitQuery[3]) : undefined; - var pitch = ((splitQuery.length > 4) && (!isNaN(+splitQuery[4]))) ? CesiumMath.toRadians(+splitQuery[4]) : undefined; - var roll = ((splitQuery.length > 5) && (!isNaN(+splitQuery[5]))) ? CesiumMath.toRadians(+splitQuery[5]) : undefined; - - viewer.camera.setView({ - destination: Cartesian3.fromDegrees(longitude, latitude, height), - orientation: { - heading: heading, - pitch: pitch, - roll: roll - } - }); - } + if (defined(loadPromise)) { + viewer.dataSources + .add(loadPromise) + .then(function (dataSource) { + var lookAt = endUserOptions.lookAt; + if (defined(lookAt)) { + var entity = dataSource.entities.getById(lookAt); + if (defined(entity)) { + viewer.trackedEntity = entity; + } else { + var error = + 'No entity with id "' + + lookAt + + '" exists in the provided data source.'; + showLoadError(source, error); + } + } else if (!defined(view) && endUserOptions.flyTo !== "false") { + viewer.flyTo(dataSource); + } + }) + .otherwise(function (error) { + showLoadError(source, error); + }); } - - var camera = viewer.camera; - function saveCamera() { - var position = camera.positionCartographic; - var hpr = ''; - if (defined(camera.heading)) { - hpr = ',' + CesiumMath.toDegrees(camera.heading) + ',' + CesiumMath.toDegrees(camera.pitch) + ',' + CesiumMath.toDegrees(camera.roll); - } - endUserOptions.view = CesiumMath.toDegrees(position.longitude) + ',' + CesiumMath.toDegrees(position.latitude) + ',' + position.height + hpr; - history.replaceState(undefined, '', '?' + objectToQuery(endUserOptions)); + } + + if (endUserOptions.stats) { + scene.debugShowFramesPerSecond = true; + } + + var theme = endUserOptions.theme; + if (defined(theme)) { + if (endUserOptions.theme === "lighter") { + document.body.classList.add("cesium-lighter"); + viewer.animation.applyThemeChanges(); + } else { + var error = "Unknown theme: " + theme; + viewer.cesiumWidget.showErrorPanel(error, ""); } - - var timeout; - if (endUserOptions.saveCamera !== 'false') { - camera.changed.addEventListener(function() { - window.clearTimeout(timeout); - timeout = window.setTimeout(saveCamera, 1000); - }); + } + + if (defined(view)) { + var splitQuery = view.split(/[ ,]+/); + if (splitQuery.length > 1) { + var longitude = !isNaN(+splitQuery[0]) ? +splitQuery[0] : 0.0; + var latitude = !isNaN(+splitQuery[1]) ? +splitQuery[1] : 0.0; + var height = + splitQuery.length > 2 && !isNaN(+splitQuery[2]) + ? +splitQuery[2] + : 300.0; + var heading = + splitQuery.length > 3 && !isNaN(+splitQuery[3]) + ? CesiumMath.toRadians(+splitQuery[3]) + : undefined; + var pitch = + splitQuery.length > 4 && !isNaN(+splitQuery[4]) + ? CesiumMath.toRadians(+splitQuery[4]) + : undefined; + var roll = + splitQuery.length > 5 && !isNaN(+splitQuery[5]) + ? CesiumMath.toRadians(+splitQuery[5]) + : undefined; + + viewer.camera.setView({ + destination: Cartesian3.fromDegrees(longitude, latitude, height), + orientation: { + heading: heading, + pitch: pitch, + roll: roll, + }, + }); } + } + + var camera = viewer.camera; + function saveCamera() { + var position = camera.positionCartographic; + var hpr = ""; + if (defined(camera.heading)) { + hpr = + "," + + CesiumMath.toDegrees(camera.heading) + + "," + + CesiumMath.toDegrees(camera.pitch) + + "," + + CesiumMath.toDegrees(camera.roll); + } + endUserOptions.view = + CesiumMath.toDegrees(position.longitude) + + "," + + CesiumMath.toDegrees(position.latitude) + + "," + + position.height + + hpr; + history.replaceState(undefined, "", "?" + objectToQuery(endUserOptions)); + } + + var timeout; + if (endUserOptions.saveCamera !== "false") { + camera.changed.addEventListener(function () { + window.clearTimeout(timeout); + timeout = window.setTimeout(saveCamera, 1000); + }); + } - loadingIndicator.style.display = 'none'; + loadingIndicator.style.display = "none"; } main(); diff --git a/Apps/CesiumViewer/index.html b/Apps/CesiumViewer/index.html index 35b67a8902b..85944f4833a 100644 --- a/Apps/CesiumViewer/index.html +++ b/Apps/CesiumViewer/index.html @@ -1,19 +1,22 @@ -
+ - + - + - +