150 lines
6.9 KiB
HTML
150 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <!-- Use Chrome Frame in IE -->
|
|
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
|
|
<meta name="description" content="Construct polygons from a set of points, an extent, or a nested hierarchy and apply materials to them.">
|
|
<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.7.2-src/dojo/dojo.js"></script>
|
|
<script type="text/javascript">
|
|
require({
|
|
baseUrl : '../../..',
|
|
packages: [
|
|
{ name: 'dojo', location: 'ThirdParty/dojo-release-1.7.2-src/dojo' },
|
|
{ name: 'dijit', location: 'ThirdParty/dojo-release-1.7.2-src/dijit' },
|
|
{ name: 'dojox', location: 'ThirdParty/dojo-release-1.7.2-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' }
|
|
]
|
|
});
|
|
</script>
|
|
<link rel="Stylesheet" href="../../../ThirdParty/dojo-release-1.7.2-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">
|
|
<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;
|
|
}
|
|
</style>
|
|
|
|
<div id="cesiumContainer" class="fullSize"></div>
|
|
<div id="toolbar">Loading...</div>
|
|
<script id="cesium_sandcastle_script">
|
|
require([
|
|
'Source/Cesium', 'Widgets/Dojo/CesiumViewerWidget',
|
|
'dojo/on', 'dojo/dom'
|
|
], function(
|
|
Cesium, CesiumViewerWidget,
|
|
on, dom)
|
|
{
|
|
"use strict";
|
|
|
|
function createPrimitives(widget) {
|
|
var scene = widget.scene;
|
|
var ellipsoid = widget.ellipsoid;
|
|
var primitives = scene.getPrimitives();
|
|
|
|
// Create a simple polygon
|
|
var polygon = new Cesium.Polygon();
|
|
Sandcastle.declare(polygon); // For highlighting on mouseover in Sandcastle.
|
|
polygon.setPositions(ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-72.0, 40.0),
|
|
Cesium.Cartographic.fromDegrees(-70.0, 35.0),
|
|
Cesium.Cartographic.fromDegrees(-75.0, 30.0),
|
|
Cesium.Cartographic.fromDegrees(-70.0, 30.0),
|
|
Cesium.Cartographic.fromDegrees(-68.0, 40.0)
|
|
]));
|
|
primitives.add(polygon);
|
|
|
|
// Create a nested polygon with holes
|
|
var polygonHierarchy = new Cesium.Polygon();
|
|
Sandcastle.declare(polygonHierarchy); // For highlighting on mouseover in Sandcastle.
|
|
var hierarchy = {
|
|
positions: ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-109.0, 30.0, 0.0), Cesium.Cartographic.fromDegrees(-95.0, 30.0, 0.0), Cesium.Cartographic.fromDegrees(-95.0, 40.0, 0.0), Cesium.Cartographic.fromDegrees(-109.0, 40.0, 0.0)]),
|
|
holes: [{
|
|
positions: ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-107.0, 31.0, 0.0), Cesium.Cartographic.fromDegrees(-107.0, 39.0, 0.0), Cesium.Cartographic.fromDegrees(-97.0, 39.0, 0.0), Cesium.Cartographic.fromDegrees(-97.0, 31.0, 0.0)]),
|
|
holes: [{
|
|
positions: ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-105.0, 33.0, 0.0), Cesium.Cartographic.fromDegrees(-99.0, 33.0, 0.0), Cesium.Cartographic.fromDegrees(-99.0, 37.0, 0.0), Cesium.Cartographic.fromDegrees(-105.0, 37.0, 0.0)]),
|
|
holes: [{
|
|
positions: ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-103.0, 34.0, 0.0), Cesium.Cartographic.fromDegrees(-101.0, 34.0, 0.0), Cesium.Cartographic.fromDegrees(-101.0, 36.0, 0.0), Cesium.Cartographic.fromDegrees(-103.0, 36.0, 0.0)])
|
|
}]
|
|
}]
|
|
}]
|
|
};
|
|
polygonHierarchy.material = Cesium.Material.fromType(scene.getContext(), 'Color');
|
|
polygonHierarchy.material.uniforms.color = new Cesium.Color(0.0, 1.0, 1.0, 0.75);
|
|
polygonHierarchy.configureFromPolygonHierarchy(hierarchy);
|
|
primitives.add(polygonHierarchy);
|
|
|
|
// Create a polygon from an extent
|
|
var polygonExtent = new Cesium.Polygon();
|
|
Sandcastle.declare(polygonExtent); // For highlighting on mouseover in Sandcastle.
|
|
polygonExtent.configureExtent(new Cesium.Extent(
|
|
Cesium.Math.toRadians(-180.0), Cesium.Math.toRadians(50.0), Cesium.Math.toRadians(180.0), Cesium.Math.toRadians(90.0)));
|
|
primitives.add(polygonExtent);
|
|
|
|
// Apply a material to a polygon
|
|
var checkeredPolygon = new Cesium.Polygon();
|
|
Sandcastle.declare(checkeredPolygon); // For highlighting on mouseover in Sandcastle.
|
|
checkeredPolygon.setPositions(ellipsoid.cartographicArrayToCartesianArray([
|
|
Cesium.Cartographic.fromDegrees(-90.0, 30.0),
|
|
Cesium.Cartographic.fromDegrees(-80.0, 30.0),
|
|
Cesium.Cartographic.fromDegrees(-80.0, 40.0),
|
|
Cesium.Cartographic.fromDegrees(-90.0, 40.0)
|
|
]));
|
|
checkeredPolygon.material = Cesium.Material.fromType(scene.getContext(), 'Checkerboard');
|
|
primitives.add(checkeredPolygon);
|
|
}
|
|
|
|
var widget = new CesiumViewerWidget({
|
|
onObjectMousedOver : function(mousedOverObject) {
|
|
widget.highlightObject(mousedOverObject);
|
|
Sandcastle.highlight(mousedOverObject);
|
|
}
|
|
});
|
|
widget.placeAt(dom.byId('cesiumContainer'));
|
|
widget.startup();
|
|
dom.byId('toolbar').innerHTML = '';
|
|
|
|
createPrimitives(widget);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|