Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,730 changes: 887 additions & 843 deletions Apps/Sandcastle/CesiumSandcastle.js

Large diffs are not rendered by default.

77 changes: 49 additions & 28 deletions Apps/Sandcastle/Sandcastle-client.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,90 @@
/*global console,Sandcastle*/
(function() {
"use strict";
/*global console,Sandcastle*/

window.parent.postMessage('reload', '*');

console.originalLog = console.log;
console.log = function (d1) {
console.log = function(d1) {
console.originalLog.apply(console, arguments);
window.parent.postMessage({ 'log': (typeof d1 === 'undefined') ? 'undefined' : d1.toString() }, '*');
window.parent.postMessage({
'log' : typeof d1 === 'undefined' ? 'undefined' : d1.toString()
}, '*');
};

console.originalError = console.error;
console.error = function (d1) {
console.error = function(d1) {
console.originalError.apply(console, arguments);
if (typeof d1 === 'undefined') {
window.parent.postMessage({ 'error': 'undefined' }, '*');
window.parent.postMessage({
'error' : 'undefined'
}, '*');
} else {
// Look for d1.stack, "bucket.html:line:char"
var lineNumber = -1, lineStart, lineEnd1, lineEnd2;
var lineNumber = -1;
var errorMsg = d1.toString();
var rawErrorMsg = errorMsg;
if (typeof d1.stack === 'string') {
var stack = d1.stack;
var pos = stack.indexOf(Sandcastle.bucket);
if (pos >= 0) {
lineStart = stack.indexOf(':', pos);
var lineStart = stack.indexOf(':', pos);
if (lineStart > pos) {
lineEnd1 = stack.indexOf(':', lineStart + 1);
lineEnd2 = stack.indexOf('\n', lineStart + 1);
var lineEnd1 = stack.indexOf(':', lineStart + 1);
var lineEnd2 = stack.indexOf('\n', lineStart + 1);
if (lineEnd2 > lineStart && (lineEnd2 < lineEnd1 || lineEnd1 < lineStart)) {
lineEnd1 = lineEnd2;
}
if (lineEnd1 > lineStart) {
try {
lineNumber = parseInt(stack.substring(lineStart + 1, lineEnd1), 10);
} catch (ex) { }
} catch (ex) {
}
}
}
}
}

if (lineNumber >= 0) {
errorMsg += ' (on line ' + lineNumber + ')';
window.parent.postMessage({ 'error': errorMsg, 'lineNumber': lineNumber, 'rawErrorMsg': rawErrorMsg }, '*');
window.parent.postMessage({
'error' : errorMsg,
'lineNumber' : lineNumber,
'rawErrorMsg' : rawErrorMsg
}, '*');
} else {
window.parent.postMessage({ 'error': errorMsg }, '*');
window.parent.postMessage({
'error' : errorMsg
}, '*');
}
}
};

window.onerror = function (errorMsg, url, lineNumber) {
window.onerror = function(errorMsg, url, lineNumber) {
var rawErrorMsg = errorMsg;
if (typeof lineNumber !== 'undefined') {
if (typeof url !== 'undefined' && url && url.indexOf(Sandcastle.bucket) < 0) {
errorMsg += ' (on line ' + lineNumber + ' of ' + url + ')';
} else {
errorMsg += ' (on line ' + lineNumber + ')';
}
window.parent.postMessage({ 'error': errorMsg, 'url': url, 'lineNumber': lineNumber, 'rawErrorMsg': rawErrorMsg }, '*');
window.parent.postMessage({
'error' : errorMsg,
'url' : url,
'lineNumber' : lineNumber,
'rawErrorMsg' : rawErrorMsg
}, '*');
} else {
window.parent.postMessage({ 'error': errorMsg, 'url': url }, '*');
window.parent.postMessage({
'error' : errorMsg,
'url' : url
}, '*');
}
console.originalError.apply(console, [ errorMsg ]);
console.originalError.apply(console, [errorMsg]);
return false;
};

Sandcastle.declare = function (obj) {
Sandcastle.declare = function(obj) {
try {
var stack = new Error().stack.toString();
var pos = stack.indexOf(Sandcastle.bucket + ':');
Expand All @@ -74,25 +93,27 @@
pos += 12;
lineNumber = parseInt(stack.substring(pos), 10);
Sandcastle.registered.push({
'obj': obj,
'lineNumber': lineNumber
'obj' : obj,
'lineNumber' : lineNumber
});
}
} catch (ex) { }
} catch (ex) {
}
};

Sandcastle.highlight = function (obj) {
var len = Sandcastle.registered.length;
var i;
Sandcastle.highlight = function(obj) {
if (typeof obj !== 'undefined') {
for (i = 0; i < len; ++i) {
for ( var i = 0, len = Sandcastle.registered.length; i < len; ++i) {
if (obj === Sandcastle.registered[i].obj) {
window.parent.postMessage({ 'highlight': Sandcastle.registered[i].lineNumber }, '*');
window.parent.postMessage({
'highlight' : Sandcastle.registered[i].lineNumber
}, '*');
return;
}
}
}
window.parent.postMessage({ 'highlight': 0 }, '*');
window.parent.postMessage({
'highlight' : 0
}, '*');
};

}());
}());
13 changes: 9 additions & 4 deletions Apps/Sandcastle/Sandcastle-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
}

window.Sandcastle = {
'bucket' : bucket,
'declare' : function () {},
'highlight' : function () {},
'registered' : []
bucket : bucket,
declare : function() {
},
highlight : function() {
},
registered : [],
finishedLoading : function() {
document.body.className = document.body.className.replace(/(?:\s|^)sandcastle-loading(?:\s|$)/, ' ');
}
};

if (window.location.protocol === 'file:') {
Expand Down
2 changes: 1 addition & 1 deletion Apps/Sandcastle/Sandcastle-warn.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*global console*/
(function() {
"use strict";
/*global console*/

if (typeof window.Cesium === 'undefined') {
console.error('Cesium not built, run the combine build script first.');
Expand Down
110 changes: 40 additions & 70 deletions Apps/Sandcastle/gallery/Animations.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,94 +7,59 @@
<meta name="description" content="Apply animation effects to primitives such as polygons and sensors.">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../../ThirdParty/dojo-release-1.8.3-src/dojo/dojo.js"></script>
<script type="text/javascript">
require({
baseUrl : '../../..',
var dojoConfig = {
baseUrl : '../../../Source',
packages: [
{ name: 'dojo', location: 'ThirdParty/dojo-release-1.8.3-src/dojo' },
{ name: 'dijit', location: 'ThirdParty/dojo-release-1.8.3-src/dijit' },
{ name: 'dojox', location: 'ThirdParty/dojo-release-1.8.3-src/dojox' },
{ name: 'Assets', location: 'Source/Assets' },
{ name: 'Core', location: 'Source/Core' },
{ name: 'DynamicScene', location: 'Source/DynamicScene' },
{ name: 'Renderer', location: 'Source/Renderer' },
{ name: 'Scene', location: 'Source/Scene' },
{ name: 'Shaders', location: 'Source/Shaders' },
{ name: 'ThirdParty', location: 'Source/ThirdParty' },
{ name: 'Widgets', location: 'Source/Widgets' },
{ name: 'Workers', location: 'Source/Workers' }
{ name: 'dojo', location: '../ThirdParty/dojo-release-1.8.3-src/dojo' },
{ name: 'dijit', location: '../ThirdParty/dojo-release-1.8.3-src/dijit' },
{ name: 'dojox', location: '../ThirdParty/dojo-release-1.8.3-src/dojox' }
]
});
};
</script>
<link rel="Stylesheet" href="../../../ThirdParty/dojo-release-1.8.3-src/dijit/themes/claro/claro.css" type="text/css">
<link rel="Stylesheet" href="../../../Source/Widgets/Dojo/CesiumViewerWidget.css" type="text/css">
<script data-dojo-config="async: 1, tlmSiblingOfDojo: 0" src="../../../ThirdParty/dojo-release-1.8.3-src/dojo/dojo.js"></script>
<link rel="stylesheet" href="../../../ThirdParty/dojo-release-1.8.3-src/dijit/themes/claro/claro.css" type="text/css">
<link rel="stylesheet" href="../../../Source/Widgets/Dojo/CesiumViewerWidget.css" type="text/css">
</head>
<body class="claro" data-sandcastle-bucket="bucket-dojo.html" data-sandcastle-title="Cesium + Dojo">
<body class="claro sandcastle-loading" data-sandcastle-bucket="bucket-dojo.html" data-sandcastle-title="Cesium + Dojo">
<style>
body {
background: #000;
color: #eee;
font-family: sans-serif;
font-size: 9pt;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.fullSize {
display: block;
position: absolute;
top: 0;
left: 0;
border: none;
width: 100%;
height: 100%;
}
#toolbar {
margin: 5px;
padding: 2px 5px;
position: absolute;
}
@import url(../templates/bucket.css);
</style>

<div id="cesiumContainer" class="fullSize"></div>
<div id="toolbar">Loading...</div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
require([
'Source/Cesium', 'Widgets/Dojo/CesiumWidget',
'dojo/on', 'dojo/dom', 'dijit/form/Button'
'Cesium', 'Widgets/Dojo/CesiumWidget', 'dijit/form/Button'
], function(
Cesium, CesiumWidget,
on, dom, Button)
Cesium, CesiumWidget, Button)
{
"use strict";

var polygon;
var rectangularSensor;

function addAlphaAnimation(primitive, scene) {
Sandcastle.declare(addAlphaAnimation); // For highlighting in Sandcastle.
Sandcastle.declare(addAlphaAnimation); // For highlighting in Sandcastle.
scene.getAnimations().addAlpha(primitive.material, 0.0, 0.5);
}

function addErosionAnimation(primitive, scene) {
Sandcastle.declare(addErosionAnimation); // For highlighting in Sandcastle.
Sandcastle.declare(addErosionAnimation); // For highlighting in Sandcastle.
scene.getAnimations().addProperty(primitive.material.uniforms, 'time', 0.0, 1.0, {
duration : 1000
});
}

function addHeightAnimation(primitive, scene) {
Sandcastle.declare(addHeightAnimation); // For highlighting in Sandcastle.
Sandcastle.declare(addHeightAnimation); // For highlighting in Sandcastle.
scene.getAnimations().addProperty(primitive, 'height', 5000000.0, 0.0, {
duration: 1000
duration : 1000
});
}

function addStripeAnimation(primitive, scene) {
Sandcastle.declare(addStripeAnimation); // For highlighting in Sandcastle.
Sandcastle.declare(addStripeAnimation); // For highlighting in Sandcastle.
scene.getAnimations().addOffsetIncrement(primitive.material);
}

Expand All @@ -107,7 +72,7 @@
var ellipsoid = widget.ellipsoid;
var scene = widget.scene;
var primitives = scene.getPrimitives();

polygon = new Cesium.Polygon();
polygon.configureExtent(new Cesium.Extent(
Cesium.Math.toRadians(-120.0),
Expand All @@ -117,11 +82,15 @@
polygon.material = Cesium.Material.fromType(scene.getContext(), 'Erosion');
primitives.add(polygon);

var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-45.0, 45.0)));
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(200000.0, 0.0, -3000000.0)));
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(
ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-45.0, 45.0)));
modelMatrix = modelMatrix.multiply(
Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(200000.0, 0.0, -3000000.0)),
modelMatrix);

var material = Cesium.Material.fromType(scene.getContext(), 'Stripe'); // Use default colors
material.uniforms.repeat = 10;
var sensors = new Cesium.SensorVolumeCollection(undefined);
var sensors = new Cesium.SensorVolumeCollection();
rectangularSensor = sensors.addRectangularPyramid({
modelMatrix : modelMatrix,
radius : 10000000.0,
Expand All @@ -134,8 +103,8 @@

function createButtons(scene) {
new Button({
label: 'Alpha Animation',
onClick: function() {
label : 'Alpha Animation',
onClick : function() {
scene.getAnimations().removeAll();
resetPolygonPropeties(polygon);
addAlphaAnimation(polygon, scene);
Expand All @@ -144,8 +113,8 @@
}).placeAt('toolbar');

new Button({
label: 'Erosion Animation',
onClick: function() {
label : 'Erosion Animation',
onClick : function() {
scene.getAnimations().removeAll();
resetPolygonPropeties(polygon);
addErosionAnimation(polygon, scene);
Expand All @@ -154,8 +123,8 @@
}).placeAt('toolbar');

new Button({
label: 'Height Animation',
onClick: function() {
label : 'Height Animation',
onClick : function() {
scene.getAnimations().removeAll();
resetPolygonPropeties(polygon);
addHeightAnimation(polygon, scene);
Expand All @@ -164,8 +133,8 @@
}).placeAt('toolbar');

new Button({
label: 'Stripe Animation',
onClick: function() {
label : 'Stripe Animation',
onClick : function() {
scene.getAnimations().removeAll();
addStripeAnimation(rectangularSensor, scene);
Sandcastle.highlight(addStripeAnimation);
Expand All @@ -174,12 +143,13 @@
}

var widget = new CesiumWidget();
widget.placeAt(dom.byId('cesiumContainer'));
widget.placeAt('cesiumContainer');
widget.startup();
dom.byId('toolbar').innerHTML = '';

createPrimitives(widget);
createButtons(widget.scene);

Sandcastle.finishedLoading();
});
</script>
</body>
Expand Down
Loading