Skip to content

Commit

Permalink
Pull and resolve merge conflict CesiumGS#5819
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Bernstein committed Oct 2, 2017
2 parents 6c40ecb + b5ffdff commit b0a3834
Show file tree
Hide file tree
Showing 20 changed files with 171 additions and 94 deletions.
81 changes: 48 additions & 33 deletions Apps/Sandcastle/CesiumSandcastle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ require({
}, {
name : 'Source',
location : '.'
}, {
name: 'CesiumUnminified',
location : '../Build/CesiumUnminified',
main: 'Cesium'
}, {
name : 'CodeMirror',
location : '../ThirdParty/codemirror-4.6'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -295,7 +310,7 @@ require({
}

function closeGalleryTooltip() {
if (Cesium.defined(activeGalleryTooltipDemo)) {
if (defined(activeGalleryTooltipDemo)) {
popup.close(demoTooltips[activeGalleryTooltipDemo.name]);
activeGalleryTooltipDemo = undefined;
}
Expand All @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -383,22 +398,22 @@ require({
}

function scheduleHint() {
if (Cesium.defined(hintTimer)) {
if (defined(hintTimer)) {
window.clearTimeout(hintTimer);
}
hintTimer = setTimeout(clearErrorsAddHints, 550);
highlightRun();
}

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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 = '<html><head></head><body data-sandcastle-bucket-loaded="no">';
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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, '');
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down Expand Up @@ -1093,15 +1108,15 @@ 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,
description: 'Code imported from GitHub Gist'
};
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 {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/3D Models Coloring.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Apps/Sandcastle/gallery/Classification.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Distance Display Conditions.html
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Projection.html
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions Apps/Sandcastle/gallery/development/3D Models.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions Apps/Sandcastle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<script src="jsHintOptions.js"></script>
<script src="gallery/gallery-index.js"></script>
<script src="CesiumSandcastle.js"></script>
<!-- The next three lines are for autocomplete -->
<!-- Needed for autocomplete -->
<link rel="stylesheet" href="../../ThirdParty/codemirror-4.6/addon/hint/show-hint.css">
<!-- End of autocomplete -->
<meta property="og:title" content="Cesium Sandcastle" />
<meta property="og:description" content="The Cesium Sandcastle provides an interactive environment for testing Cesium code." />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html" />
<meta property="og:image" content="http://cesiumjs.org/images/Sandcastle.png" />
<meta property="og:url" content="https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html" />
<meta property="og:image" content="https://cesiumjs.org/images/Sandcastle.png" />
<meta property="og:site_name" content="Cesium" />
<meta property="fb:admins" content="1222088662,1322006496" />
</head>
Expand Down
10 changes: 6 additions & 4 deletions Apps/Sandcastle/templates/bucket-requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<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
});
if(typeof require === "function") {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
Expand Down
Loading

0 comments on commit b0a3834

Please sign in to comment.