diff --git a/Apps/Sandcastle/CesiumSandcastle.js b/Apps/Sandcastle/CesiumSandcastle.js index 9f5f91270acd..40074438ec48 100644 --- a/Apps/Sandcastle/CesiumSandcastle.js +++ b/Apps/Sandcastle/CesiumSandcastle.js @@ -16,6 +16,10 @@ require({ }, { name : 'Source', location : '.' + }, { + name: 'CesiumUnminified', + location : '../Build/CesiumUnminified', + main: 'Cesium' }, { name : 'CodeMirror', location : '../ThirdParty/codemirror-4.6' @@ -43,6 +47,10 @@ require({ 'dojo/query', 'dojo/when', 'Sandcastle/LinkButton', + 'Source/Core/defined', + 'Source/Core/getBaseUri', + 'Source/Core/loadJsonp', + 'Source/Core/loadWithXhr', 'Source/Cesium', 'CodeMirror/addon/hint/show-hint', 'CodeMirror/addon/hint/javascript-hint', @@ -86,11 +94,18 @@ require({ query, when, LinkButton, - Cesium) { + defined, + getBaseUri, + loadJsonp, + loadWithXhr, + Cesium +) { 'use strict'; //In order for CodeMirror auto-complete to work, Cesium needs to be defined as a global. - window.Cesium = Cesium; + if (!defined(window.Cesium)) { + window.Cesium = Cesium; + } parser.parse(); @@ -214,7 +229,7 @@ require({ } function openDocTab(title, link) { - if (!Cesium.defined(docTabs[title])) { + if (!defined(docTabs[title])) { docTabs[title] = new ContentPane({ title : title, focused : true, @@ -271,7 +286,7 @@ require({ function onCursorActivity() { docNode.style.left = '-999px'; - if (Cesium.defined(docTimer)) { + if (defined(docTimer)) { window.clearTimeout(docTimer); } docTimer = window.setTimeout(showDocPopup, 500); @@ -295,7 +310,7 @@ require({ } function closeGalleryTooltip() { - if (Cesium.defined(activeGalleryTooltipDemo)) { + if (defined(activeGalleryTooltipDemo)) { popup.close(demoTooltips[activeGalleryTooltipDemo.name]); activeGalleryTooltipDemo = undefined; } @@ -312,7 +327,7 @@ require({ suffix = 'searchDemo'; } - if (Cesium.defined(activeGalleryTooltipDemo)) { + if (defined(activeGalleryTooltipDemo)) { popup.open({ popup : demoTooltips[activeGalleryTooltipDemo.name], around : dom.byId(activeGalleryTooltipDemo.name + suffix), @@ -324,7 +339,7 @@ require({ function scheduleGalleryTooltip(demo) { if (demo !== activeGalleryTooltipDemo) { activeGalleryTooltipDemo = demo; - if (Cesium.defined(galleryTooltipTimer)) { + if (defined(galleryTooltipTimer)) { window.clearTimeout(galleryTooltipTimer); } galleryTooltipTimer = window.setTimeout(openGalleryTooltip, 220); @@ -372,7 +387,7 @@ require({ var hints = JSHINT.errors; for (i = 0, len = hints.length; i < len; ++i) { var hint = hints[i]; - if (hint !== null && Cesium.defined(hint.reason) && hint.line > 0) { + if (hint !== null && defined(hint.reason) && hint.line > 0) { line = jsEditor.setGutterMarker(scriptLineToEditorLine(hint.line), 'hintGutter', makeLineLabel(hint.reason, 'hintMarker')); jsEditor.addLineClass(line, 'text', 'hintLine'); errorLines.push(line); @@ -383,7 +398,7 @@ require({ } function scheduleHint() { - if (Cesium.defined(hintTimer)) { + if (defined(hintTimer)) { window.clearTimeout(hintTimer); } hintTimer = setTimeout(clearErrorsAddHints, 550); @@ -391,14 +406,14 @@ require({ } function scheduleHintNoChange() { - if (Cesium.defined(hintTimer)) { + if (defined(hintTimer)) { window.clearTimeout(hintTimer); } hintTimer = setTimeout(clearErrorsAddHints, 550); } function scrollToLine(lineNumber) { - if (Cesium.defined(lineNumber)) { + if (defined(lineNumber)) { jsEditor.setCursor(lineNumber); // set selection twice in order to force the editor to scroll // to this location if the cursor is already there @@ -457,13 +472,13 @@ require({ function registerScroll(demoContainer) { if (document.onmousewheel !== undefined) { demoContainer.addEventListener('mousewheel', function(e) { - if (Cesium.defined(e.wheelDelta) && e.wheelDelta) { + if (defined(e.wheelDelta) && e.wheelDelta) { demoContainer.scrollLeft -= e.wheelDelta * 70 / 120; } }, false); } else { demoContainer.addEventListener('DOMMouseScroll', function(e) { - if (Cesium.defined(e.detail) && e.detail) { + if (defined(e.detail) && e.detail) { demoContainer.scrollLeft += e.detail * 70 / 3; } }, false); @@ -662,7 +677,7 @@ require({ function loadBucket(bucketName) { if (local.bucketName !== bucketName) { local.bucketName = bucketName; - if (Cesium.defined(bucketTypes[bucketName])) { + if (defined(bucketTypes[bucketName])) { local.headers = bucketTypes[bucketName]; } else { local.headers = ''; @@ -686,13 +701,13 @@ require({ var gistId = ioQuery.queryToObject(window.location.search.substring(1)).gist; if (window.location.search) { queryObject = ioQuery.queryToObject(window.location.search.substring(1)); - if (Cesium.defined(gistId)) { + if (defined(gistId)) { queryObject.gistId = gistId; } } else { queryObject.src = 'Hello World.html'; queryObject.label = 'Showcases'; - if (Cesium.defined(gistId)) { + if (defined(gistId)) { queryObject.gistId = gistId; } } @@ -731,13 +746,13 @@ require({ var scriptCode = scriptMatch[1]; demoCode = scriptCode.replace(/\s/g, ''); - if (Cesium.defined(queryObject.gistId)) { - Cesium.loadJsonp('https://api.github.com/gists/' + queryObject.gistId + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60') + if (defined(queryObject.gistId)) { + loadJsonp('https://api.github.com/gists/' + queryObject.gistId + '?access_token=dd8f755c2e5d9bbb26806bb93eaa2291f2047c60') .then(function(data) { var files = data.data.files; var code = files['Cesium-Sandcastle.js'].content; var htmlFile = files['Cesium-Sandcastle.html']; - var html = Cesium.defined(htmlFile) ? htmlFile.content : defaultHtml; // Use the default html for old gists + var html = defined(htmlFile) ? htmlFile.content : defaultHtml; // Use the default html for old gists jsEditor.setValue(code); htmlEditor.setValue(html); demoCode = code.replace(/\s/g, ''); @@ -746,7 +761,7 @@ require({ gistHtml = html; previousCode = code; previousHtml = html; - sandcastleUrl = Cesium.getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId; + sandcastleUrl = getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId; CodeMirror.commands.runCesium(jsEditor); clearRun(); }).otherwise(function(error) { @@ -813,14 +828,14 @@ require({ appendConsole('consoleLog', 'Unable to load demo named ' + queryObject.src.replace('.html', '') + '. Redirecting to HelloWorld.\n', true); } } - } else if (Cesium.defined(e.data.log)) { + } else if (defined(e.data.log)) { // Console log messages from the iframe display in Sandcastle. appendConsole('consoleLog', e.data.log, false); - } else if (Cesium.defined(e.data.error)) { + } else if (defined(e.data.error)) { // Console error messages from the iframe display in Sandcastle var errorMsg = e.data.error; var lineNumber = e.data.lineNumber; - if (Cesium.defined(lineNumber)) { + if (defined(lineNumber)) { errorMsg += ' (on line '; if (e.data.url) { @@ -835,10 +850,10 @@ require({ } } appendConsole('consoleError', errorMsg, true); - } else if (Cesium.defined(e.data.warn)) { + } else if (defined(e.data.warn)) { // Console warning messages from the iframe display in Sandcastle. appendConsole('consoleWarn', e.data.warn, true); - } else if (Cesium.defined(e.data.highlight)) { + } else if (defined(e.data.highlight)) { // Hovering objects in the embedded Cesium window. highlightLine(e.data.highlight); } @@ -925,12 +940,12 @@ require({ } } }; - return Cesium.loadWithXhr({ + return loadWithXhr({ url : 'https://api.github.com/gists', data : JSON.stringify(data), method : 'POST' }).then(function(content) { - sandcastleUrl = Cesium.getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + JSON.parse(content).id; + sandcastleUrl = getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + JSON.parse(content).id; textArea.value = sandcastleUrl; textArea.select(); }).otherwise(function(error) { @@ -946,7 +961,7 @@ require({ if (gistIndex !== -1) { gistId = gistId.substring(gistIndex + gistParameter.length); } - window.location.href = Cesium.getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId; + window.location.href = getBaseUri(window.location.href) + '?src=Hello%20World.html&label=Showcases&gist=' + gistId; }); registry.byId('buttonNew').on('click', function() { @@ -1093,7 +1108,7 @@ require({ demo.label = labels ? labels : ''; // Select the demo to load upon opening based on the query parameter. - if (Cesium.defined(queryObject.src)) { + if (defined(queryObject.src)) { var gistDemo = { name : 'Gist Import', code : demo.code, @@ -1101,7 +1116,7 @@ require({ }; if (demo.name === queryObject.src.replace('.html', '')) { loadFromGallery(demo).then(function() { - if (Cesium.defined(queryObject.gistId)) { + if (defined(queryObject.gistId)) { window.history.replaceState(gistDemo, gistDemo.name, '?src=Hello World.html&label=' + queryObject.label + '&gist=' + queryObject.gistId); document.title = 'Gist Import - Cesium Sandcastle'; } else { @@ -1126,7 +1141,7 @@ require({ var loading = true; function setSubtab(tabName) { - currentTab = Cesium.defined(tabName) && !loading ? tabName : queryObject.label; + currentTab = defined(tabName) && !loading ? tabName : queryObject.label; queryObject.label = tabName; loading = false; } @@ -1178,7 +1193,7 @@ require({ function createGalleryButton(demo, tabName) { var imgSrc = 'templates/Gallery_tile.jpg'; - if (Cesium.defined(demo.img)) { + if (defined(demo.img)) { imgSrc = 'gallery/' + demo.img; } @@ -1231,7 +1246,7 @@ require({ } var promise; - if (!Cesium.defined(gallery_demos)) { + if (!defined(gallery_demos)) { galleryErrorMsg.textContent = 'No demos found, please run the build script.'; galleryErrorMsg.style.display = 'inline-block'; } else { diff --git a/Apps/Sandcastle/gallery/3D Models Coloring.html b/Apps/Sandcastle/gallery/3D Models Coloring.html index 979c9a6f955a..4c93eb361365 100644 --- a/Apps/Sandcastle/gallery/3D Models Coloring.html +++ b/Apps/Sandcastle/gallery/3D Models Coloring.html @@ -172,7 +172,7 @@ viewer.entities.removeAll(); var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height); - var heading = Cesium.Math.toRadians(135); + var heading = -Cesium.Math.toRadians(135); var pitch = 0; var roll = 0; var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); diff --git a/Apps/Sandcastle/gallery/Classification.html b/Apps/Sandcastle/gallery/Classification.html index b5ec8301a0bc..acce340b4274 100644 --- a/Apps/Sandcastle/gallery/Classification.html +++ b/Apps/Sandcastle/gallery/Classification.html @@ -56,7 +56,7 @@ var center = new Cesium.Cartesian3(1216378.730451297, -4736275.917774027, 4081266.871000864); var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center); - var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(2.619728786416368, 0.0, 0.0)); + var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-2.619728786416368, 0.0, 0.0)); var hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(0.0, 0.0, -2.0)); Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix); @@ -91,7 +91,7 @@ var center = new Cesium.Cartesian3(1216398.6054139996, -4736204.533089285, 4081338.6585485404); var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center); - var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(5.785339046755887, 0.0, 0.0)); + var hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-5.785339046755887, 0.0, 0.0)); var hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(0.4, 0.0, -2.0)); Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix); @@ -111,7 +111,7 @@ center = new Cesium.Cartesian3(1216394.3346955755, -4736207.431365568, 4081336.7768881875); modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(center); - hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(5.785339046755887, 0.0, 0.0)); + hprRotation = Cesium.Matrix3.fromHeadingPitchRoll(new Cesium.HeadingPitchRoll(-5.785339046755887, 0.0, 0.0)); hpr = Cesium.Matrix4.fromRotationTranslation(hprRotation, new Cesium.Cartesian3(-0.25, 0.0, -2.0)); Cesium.Matrix4.multiply(modelMatrix, hpr, modelMatrix); diff --git a/Apps/Sandcastle/gallery/Distance Display Conditions.html b/Apps/Sandcastle/gallery/Distance Display Conditions.html index d4475cabe5d8..46d8a2f05652 100644 --- a/Apps/Sandcastle/gallery/Distance Display Conditions.html +++ b/Apps/Sandcastle/gallery/Distance Display Conditions.html @@ -54,7 +54,7 @@ var position = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883, 0.0); var heading = Cesium.Math.toRadians(135); - var hpr = new Cesium.HeadingPitchRoll(heading, 0.0, 0.0); + var hpr = new Cesium.HeadingPitchRoll(-heading, 0.0, 0.0); var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); viewer.entities.add({ diff --git a/Apps/Sandcastle/gallery/Projection.html b/Apps/Sandcastle/gallery/Projection.html index faa01ed692d1..eda3b3ceeecc 100644 --- a/Apps/Sandcastle/gallery/Projection.html +++ b/Apps/Sandcastle/gallery/Projection.html @@ -36,7 +36,7 @@ viewer.projectionPicker.viewModel.switchToOrthographic(); var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 0.0); -var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(135), 0.0, 0.0); +var hpr = new Cesium.HeadingPitchRoll(-Cesium.Math.toRadians(135), 0.0, 0.0); var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); var entity = viewer.entities.add({ diff --git a/Apps/Sandcastle/gallery/development/3D Models.html b/Apps/Sandcastle/gallery/development/3D Models.html index 9739f74752ef..a7956d555994 100644 --- a/Apps/Sandcastle/gallery/development/3D Models.html +++ b/Apps/Sandcastle/gallery/development/3D Models.html @@ -123,8 +123,8 @@ function createModel(url, height, heading, pitch, roll) { height = Cesium.defaultValue(height, 0.0); - heading = Cesium.defaultValue(heading, 0.0); - pitch = Cesium.defaultValue(pitch, 0.0); + heading = -Cesium.defaultValue(heading, 0.0); + pitch = -Cesium.defaultValue(pitch, 0.0); roll = Cesium.defaultValue(roll, 0.0); var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); diff --git a/Apps/Sandcastle/index.html b/Apps/Sandcastle/index.html index 19851688af84..2f40003d957e 100644 --- a/Apps/Sandcastle/index.html +++ b/Apps/Sandcastle/index.html @@ -21,14 +21,14 @@ - + - - + + diff --git a/Apps/Sandcastle/templates/bucket-requirejs.html b/Apps/Sandcastle/templates/bucket-requirejs.html index 575e33fb77d0..75c88309f303 100644 --- a/Apps/Sandcastle/templates/bucket-requirejs.html +++ b/Apps/Sandcastle/templates/bucket-requirejs.html @@ -8,10 +8,12 @@ diff --git a/CHANGES.md b/CHANGES.md index 5dc4282ab213..90417c021a4f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,20 +3,22 @@ Change Log ### 1.38 - 2017-10-02 * Breaking changes + * `HeadingPitchRoll.fromQuaternion`, `Matrix3.fromHeadingPitchRoll`, `Quaternion.fromHeadingPitchRoll`, `Transforms.headingPitchRollToFixedFrame`, and `Transforms.headingPitchRollQuaternion` now use the classical orientation of heading and pitch calculated counter-clockwise. With this new behavior, heading and pitch need to be the negative of their previous values. The warning message will be removed in Cesium 1.40.[#5666](https://github.com/AnalyticalGraphicsInc/cesium/issues/5666) * `Scene/CullingVolume` has been removed. Use `Core/CullingVolume`. * `Scene/OrthographicFrustum` has been removed. Use `Core/OrthographicFrustum`. * `Scene/OrthographicOffCenterFrustum` has been removed. Use `Core/OrthographicOffCenterFrustum`. * `Scene/PerspectiveFrustum` has been removed. Use `Core/PerspectiveFrustum`. * `Scene/PerspectiveOffCenterFrustum` has been removed. Use `Core/PerspectiveOffCenterFrustum`. -* Fixed where unicode string loaded from a typed array would be incorrect in Internet Explorer and Edge. This mainly popped up in 3dTiles batch tables. -* Added ability to add an animation to `ModelAnimationCollection` by its index. [#5815](https://github.com/AnalyticalGraphicsInc/cesium/pull/5815) -* Fixed a bug in `ModelAnimationCollection` that caused adding an animation by its name to throw an error. [#5815](https://github.com/AnalyticalGraphicsInc/cesium/pull/5815) * Added support in CZML for expressing `orientation` as the velocity vector of an entity, using `velocityReference` syntax. [#5807](https://github.com/AnalyticalGraphicsInc/cesium/pull/5807) * Fixed CZML processing of `velocityReference` within an interval. [#5738](https://github.com/AnalyticalGraphicsInc/cesium/issues/5738) -* Zoom about mouse now maintains camera heading, pitch, and roll [#4639](https://github.com/AnalyticalGraphicsInc/cesium/pull/5603) -* Fixed a bug in `PolylineCollection` preventing the display of more than 16K points in a single collection [#5538](https://github.com/AnalyticalGraphicsInc/cesium/pull/5782) -* Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/AnalyticalGraphicsInc/cesium/issues/5827) +* Added ability to add an animation to `ModelAnimationCollection` by its index. [#5815](https://github.com/AnalyticalGraphicsInc/cesium/pull/5815) +* Fixed a bug in `ModelAnimationCollection` that caused adding an animation by its name to throw an error. [#5815](https://github.com/AnalyticalGraphicsInc/cesium/pull/5815) +* Fixed issue in Internet Explorer and Edge with loading unicode strings in typed arrays that impacted 3D Tiles Batch Table values. +* Zoom now maintains camera heading, pitch, and roll. [#4639](https://github.com/AnalyticalGraphicsInc/cesium/pull/5603) +* Fixed a bug in `PolylineCollection` preventing the display of more than 16K points in a single collection. [#5538](https://github.com/AnalyticalGraphicsInc/cesium/pull/5782) * Fixed a 3D Tiles point cloud bug causing a stray point to appear at the center of the screen on certain hardware. [#5599](https://github.com/AnalyticalGraphicsInc/cesium/issues/5599) +* Fixed removing multiple event listeners within event callbacks. [#5827](https://github.com/AnalyticalGraphicsInc/cesium/issues/5827) +* Running `buildApps` now creates a built version of Sandcastle which uses the built version of Cesium for better performance. * Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon. [#5819](https://github.com/AnalyticalGraphicsInc/cesium/issues/5819) ### 1.37 - 2017-09-01 diff --git a/Source/Core/HeadingPitchRoll.js b/Source/Core/HeadingPitchRoll.js index b934f6d04f3e..66448aede003 100644 --- a/Source/Core/HeadingPitchRoll.js +++ b/Source/Core/HeadingPitchRoll.js @@ -2,12 +2,14 @@ define([ './defaultValue', './defined', './DeveloperError', - './Math' + './Math', + './deprecationWarning' ], function( defaultValue, defined, DeveloperError, - CesiumMath) { + CesiumMath, + deprecationWarning) { 'use strict'; /** @@ -40,17 +42,23 @@ define([ throw new DeveloperError('quaternion is required'); } //>>includeEnd('debug'); + + deprecationWarning('HeadingPitchRoll.fromQuaternion', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.'); + if (!defined(result)) { result = new HeadingPitchRoll(); } + var test = 2 * (quaternion.w * quaternion.y - quaternion.z * quaternion.x); var denominatorRoll = 1 - 2 * (quaternion.x * quaternion.x + quaternion.y * quaternion.y); var numeratorRoll = 2 * (quaternion.w * quaternion.x + quaternion.y * quaternion.z); var denominatorHeading = 1 - 2 * (quaternion.y * quaternion.y + quaternion.z * quaternion.z); var numeratorHeading = 2 * (quaternion.w * quaternion.z + quaternion.x * quaternion.y); - result.heading = -Math.atan2(numeratorHeading, denominatorHeading); + + result.heading = Math.atan2(numeratorHeading, denominatorHeading); result.roll = Math.atan2(numeratorRoll, denominatorRoll); - result.pitch = -Math.asin(test); + result.pitch = Math.asin(test); + return result; }; diff --git a/Source/Core/Matrix3.js b/Source/Core/Matrix3.js index 23e9b6c21376..933ff08e7dc7 100644 --- a/Source/Core/Matrix3.js +++ b/Source/Core/Matrix3.js @@ -6,7 +6,8 @@ define([ './defineProperties', './DeveloperError', './freezeObject', - './Math' + './Math', + './deprecationWarning' ], function( Cartesian3, Check, @@ -15,7 +16,8 @@ define([ defineProperties, DeveloperError, freezeObject, - CesiumMath) { + CesiumMath, + deprecationWarning) { 'use strict'; /** @@ -304,11 +306,13 @@ define([ Check.typeOf.object('headingPitchRoll', headingPitchRoll); //>>includeEnd('debug'); - var cosTheta = Math.cos(-headingPitchRoll.pitch); - var cosPsi = Math.cos(-headingPitchRoll.heading); + deprecationWarning('Matrix3.fromHeadingPitchRoll', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.'); + + var cosTheta = Math.cos(headingPitchRoll.pitch); + var cosPsi = Math.cos(headingPitchRoll.heading); var cosPhi = Math.cos(headingPitchRoll.roll); - var sinTheta = Math.sin(-headingPitchRoll.pitch); - var sinPsi = Math.sin(-headingPitchRoll.heading); + var sinTheta = Math.sin(headingPitchRoll.pitch); + var sinPsi = Math.sin(headingPitchRoll.heading); var sinPhi = Math.sin(headingPitchRoll.roll); var m00 = cosTheta * cosPsi; diff --git a/Source/Core/Quaternion.js b/Source/Core/Quaternion.js index 346c135d71d9..0a1e2cae8ec5 100644 --- a/Source/Core/Quaternion.js +++ b/Source/Core/Quaternion.js @@ -7,7 +7,8 @@ define([ './freezeObject', './HeadingPitchRoll', './Math', - './Matrix3' + './Matrix3', + './deprecationWarning' ], function( Cartesian3, Check, @@ -17,7 +18,8 @@ define([ freezeObject, HeadingPitchRoll, CesiumMath, - Matrix3) { + Matrix3, + deprecationWarning) { 'use strict'; /** @@ -189,10 +191,13 @@ define([ Check.typeOf.object('headingPitchRoll', headingPitchRoll); //>>includeEnd('debug'); + deprecationWarning('Quaternion.fromHeadingPitchRoll', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.'); + scratchRollQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_X, headingPitchRoll.roll, scratchHPRQuaternion); - scratchPitchQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Y, -headingPitchRoll.pitch, result); + scratchPitchQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Y, headingPitchRoll.pitch, result); result = Quaternion.multiply(scratchPitchQuaternion, scratchRollQuaternion, scratchPitchQuaternion); - scratchHeadingQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Z, -headingPitchRoll.heading, scratchHPRQuaternion); + scratchHeadingQuaternion = Quaternion.fromAxisAngle(Cartesian3.UNIT_Z, headingPitchRoll.heading, scratchHPRQuaternion); + return Quaternion.multiply(scratchHeadingQuaternion, result, result); }; diff --git a/Source/Core/Transforms.js b/Source/Core/Transforms.js index ef3ce08a0cbe..737bf10c4982 100644 --- a/Source/Core/Transforms.js +++ b/Source/Core/Transforms.js @@ -18,7 +18,8 @@ define([ './Matrix3', './Matrix4', './Quaternion', - './TimeConstants' + './TimeConstants', + './deprecationWarning' ], function( when, Cartesian2, @@ -39,7 +40,8 @@ define([ Matrix3, Matrix4, Quaternion, - TimeConstants) { + TimeConstants, + deprecationWarning) { 'use strict'; /** @@ -334,8 +336,12 @@ define([ Check.typeOf.object( 'HeadingPitchRoll', headingPitchRoll); //>>includeEnd('debug'); + deprecationWarning('Transforms.headingPitchRollToFixedFrame', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.'); + fixedFrameTransform = defaultValue(fixedFrameTransform, Transforms.eastNorthUpToFixedFrame); - var hprQuaternion = Quaternion.fromHeadingPitchRoll(headingPitchRoll, scratchHPRQuaternion); + + var hprQuaternion = Quaternion.fromHeadingPitchRoll(headingPitchRoll, scratchHPRQuaternion); + var hprMatrix = Matrix4.fromTranslationQuaternionRotationScale(Cartesian3.ZERO, hprQuaternion, scratchScale, scratchHPRMatrix4); result = fixedFrameTransform(origin, ellipsoid, result); return Matrix4.multiply(result, hprMatrix, result); @@ -372,6 +378,11 @@ define([ Check.typeOf.object( 'HeadingPitchRoll', headingPitchRoll); //>>includeEnd('debug'); + deprecationWarning('Transforms.headingPitchRollQuaternion', 'This function now uses a counter-clockwise orientation of heading and pitch as per mathematical conventions. With this new behavior, heading and pitch will need to be the negative of their previous values. This was introduced in 1.38 and the deprecation warning will be removed in Cesium 1.40.'); + + scratchENUMatrix4 = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, scratchENUMatrix4); + Matrix4.getRotation(scratchENUMatrix4, scratchHPRMatrix3); + var transform = Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, scratchENUMatrix4); var rotation = Matrix4.getRotation(transform, scratchHPRMatrix3); return Quaternion.fromRotationMatrix(rotation, result); diff --git a/Source/Scene/Camera.js b/Source/Scene/Camera.js index f7155fc5c35e..a0d38927b66b 100644 --- a/Source/Scene/Camera.js +++ b/Source/Scene/Camera.js @@ -1039,7 +1039,6 @@ define([ var scratchSetViewCartesian = new Cartesian3(); var scratchSetViewTransform1 = new Matrix4(); var scratchSetViewTransform2 = new Matrix4(); - var scratchSetViewQuaternion = new Quaternion(); var scratchSetViewMatrix3 = new Matrix3(); var scratchSetViewCartographic = new Cartographic(); @@ -1049,10 +1048,10 @@ define([ camera._setTransform(localTransform); Cartesian3.clone(Cartesian3.ZERO, camera.position); - hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO; + hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO; + hpr.pitch = -hpr.pitch; - var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion); - var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3); + var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3); Matrix3.getColumn(rotMat, 0, camera.direction); Matrix3.getColumn(rotMat, 2, camera.up); @@ -1075,10 +1074,10 @@ define([ } Cartesian3.clone(position, camera.position); } - hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO; + hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO; + hpr.pitch = -hpr.pitch; - var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion); - var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3); + var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3); Matrix3.getColumn(rotMat, 0, camera.direction); Matrix3.getColumn(rotMat, 2, camera.up); @@ -1116,11 +1115,10 @@ define([ } if (camera._scene.mapMode2D === MapMode2D.ROTATE) { - hpr.heading = hpr.heading - CesiumMath.PI_OVER_TWO; - hpr.pitch = -CesiumMath.PI_OVER_TWO; + hpr.heading = -hpr.heading + CesiumMath.PI_OVER_TWO; + hpr.pitch = CesiumMath.PI_OVER_TWO; hpr.roll = 0.0; - var rotQuat = Quaternion.fromHeadingPitchRoll(hpr, scratchSetViewQuaternion); - var rotMat = Matrix3.fromQuaternion(rotQuat, scratchSetViewMatrix3); + var rotMat = Matrix3.fromHeadingPitchRoll(hpr, scratchSetViewMatrix3); Matrix3.getColumn(rotMat, 2, camera.up); Cartesian3.cross(camera.direction, camera.up, camera.right); diff --git a/Specs/Core/Matrix3Spec.js b/Specs/Core/Matrix3Spec.js index b87c0775d199..7e94a7b58eea 100644 --- a/Specs/Core/Matrix3Spec.js +++ b/Specs/Core/Matrix3Spec.js @@ -154,7 +154,7 @@ defineSuite([ 0.133022221559489, 0.656295369162553, -0.742685314912828, -0.642787609686539, 0.627506871597133, 0.439385041770705); - var headingPitchRoll = new HeadingPitchRoll(-CesiumMath.toRadians(10), -CesiumMath.toRadians(40), CesiumMath.toRadians(55)); + var headingPitchRoll = new HeadingPitchRoll(CesiumMath.toRadians(10), CesiumMath.toRadians(40), CesiumMath.toRadians(55)); var result = new Matrix3(); var returnedResult = Matrix3.fromHeadingPitchRoll(headingPitchRoll, result); expect(result).toBe(returnedResult); diff --git a/Specs/Core/QuaternionSpec.js b/Specs/Core/QuaternionSpec.js index c969f95f690c..ddaac291b46a 100644 --- a/Specs/Core/QuaternionSpec.js +++ b/Specs/Core/QuaternionSpec.js @@ -108,14 +108,14 @@ defineSuite([ var angle = CesiumMath.toRadians(20.0); var hpr = new HeadingPitchRoll(angle, 0.0, 0.0); var quaternion = Quaternion.fromHeadingPitchRoll(hpr); - expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationZ(-angle), CesiumMath.EPSILON11); + expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationZ(angle), CesiumMath.EPSILON11); }); it('fromHeadingPitchRoll with just pitch', function() { var angle = CesiumMath.toRadians(20.0); var hpr = new HeadingPitchRoll(0.0, angle, 0.0); var quaternion = Quaternion.fromHeadingPitchRoll(hpr); - expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationY(-angle), CesiumMath.EPSILON11); + expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(Matrix3.fromRotationY(angle), CesiumMath.EPSILON11); }); it('fromHeadingPitchRoll with just roll', function() { @@ -130,8 +130,8 @@ defineSuite([ var hpr = new HeadingPitchRoll( angle, angle, angle); var quaternion = Quaternion.fromHeadingPitchRoll(hpr); var expected = Matrix3.fromRotationX(angle); - Matrix3.multiply(Matrix3.fromRotationY(-angle), expected, expected); - Matrix3.multiply(Matrix3.fromRotationZ(-angle), expected, expected); + Matrix3.multiply(Matrix3.fromRotationY(angle), expected, expected); + Matrix3.multiply(Matrix3.fromRotationZ(angle), expected, expected); expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(expected, CesiumMath.EPSILON11); }); @@ -142,8 +142,8 @@ defineSuite([ var hpr = new HeadingPitchRoll( heading, pitch, roll); var quaternion = Quaternion.fromHeadingPitchRoll(hpr); var expected = Matrix3.fromRotationX(roll); - Matrix3.multiply(Matrix3.fromRotationY(-pitch), expected, expected); - Matrix3.multiply(Matrix3.fromRotationZ(-heading), expected, expected); + Matrix3.multiply(Matrix3.fromRotationY(pitch), expected, expected); + Matrix3.multiply(Matrix3.fromRotationZ(heading), expected, expected); expect(Matrix3.fromQuaternion(quaternion)).toEqualEpsilon(expected, CesiumMath.EPSILON11); }); diff --git a/Specs/Core/TransformsSpec.js b/Specs/Core/TransformsSpec.js index 07a702507f56..59643313d657 100644 --- a/Specs/Core/TransformsSpec.js +++ b/Specs/Core/TransformsSpec.js @@ -587,7 +587,6 @@ defineSuite([ expect(actual).toEqualEpsilon(expected, CesiumMath.EPSILON11); }); - it('headingPitchRollQuaternion works with a custom fixedFrameTransform', function() { var origin = new Cartesian3(1.0, 0.0, 0.0); var heading = CesiumMath.toRadians(20.0); @@ -1048,7 +1047,7 @@ defineSuite([ var heading = CesiumMath.toRadians(90.0); var pitch = CesiumMath.toRadians(45.0); var roll = 0.0; - var hpr = new HeadingPitchRoll(heading, pitch, roll); + var hpr = new HeadingPitchRoll(-heading, -pitch, roll); var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid); var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4()); @@ -1069,7 +1068,7 @@ defineSuite([ var heading = CesiumMath.toRadians(90.0); var pitch = CesiumMath.toRadians(45.0); var roll = 0.0; - var hpr = new HeadingPitchRoll(heading, pitch, roll); + var hpr = new HeadingPitchRoll(-heading, -pitch, roll); var modelMatrix = Transforms.headingPitchRollToFixedFrame(origin, hpr, ellipsoid); var modelMatrix2D = Transforms.basisTo2D(projection, modelMatrix, new Matrix4()); diff --git a/Specs/Scene/ModelInstanceCollectionSpec.js b/Specs/Scene/ModelInstanceCollectionSpec.js index 1b493721d190..9f2caa63b5c0 100644 --- a/Specs/Scene/ModelInstanceCollectionSpec.js +++ b/Specs/Scene/ModelInstanceCollectionSpec.js @@ -133,7 +133,7 @@ defineSuite([ var heading = Math.PI/2.0; var pitch = 0.0; var roll = 0.0; - var hpr = new HeadingPitchRoll(heading, pitch, roll); + var hpr = new HeadingPitchRoll(-heading, -pitch, roll); var modelMatrix = Transforms.headingPitchRollToFixedFrame(position, hpr); instances.push({ modelMatrix : modelMatrix diff --git a/gulpfile.js b/gulpfile.js index d48f498c4c0e..8e3e65c6f19f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -113,7 +113,10 @@ gulp.task('build-watch', function() { }); gulp.task('buildApps', function() { - return buildCesiumViewer(); + return Promise.join( + buildCesiumViewer(), + buildSandcastle() + ); }); gulp.task('clean', function(done) { @@ -1153,6 +1156,35 @@ var sandcastleJsHintOptions = ' + JSON.stringify(primary, null, 4) + ';'; fs.writeFileSync(path.join('Apps', 'Sandcastle', 'jsHintOptions.js'), contents); } +function buildSandcastle() { + var appStream = gulp.src([ + 'Apps/Sandcastle/**', + '!Apps/Sandcastle/images/**', + '!Apps/Sandcastle/gallery/**.jpg' + ]) + // Replace require Source with pre-built Cesium + .pipe(gulpReplace('../../../ThirdParty/requirejs-2.1.20/require.js', '../../../CesiumUnminified/Cesium.js')) + // Use unminified cesium instead of source + .pipe(gulpReplace('Source/Cesium', 'CesiumUnminified')) + // Fix relative paths for new location + .pipe(gulpReplace('../../Source', '../../../Source')) + .pipe(gulpReplace('../../ThirdParty', '../../../ThirdParty')) + .pipe(gulpReplace('../../SampleData', '../../../../Apps/SampleData')) + .pipe(gulpReplace('Build/Documentation', 'Documentation')) + .pipe(gulp.dest('Build/Apps/Sandcastle')); + + var imageStream = gulp.src([ + 'Apps/Sandcastle/gallery/**.jpg', + 'Apps/Sandcastle/images/**' + ], { + base: 'Apps/Sandcastle', + buffer: false + }) + .pipe(gulp.dest('Build/Apps/Sandcastle')); + + return eventStream.merge(appStream, imageStream); +} + function buildCesiumViewer() { var cesiumViewerOutputDirectory = 'Build/Apps/CesiumViewer'; var cesiumViewerStartup = path.join(cesiumViewerOutputDirectory, 'CesiumViewerStartup.js'); diff --git a/index.html b/index.html index f4e700456904..bf40eef356d3 100644 --- a/index.html +++ b/index.html @@ -27,6 +27,7 @@
  • Sandcastle + (built version)
  • Cesium Inspector