162 lines
6.3 KiB
HTML
162 lines
6.3 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 and apply materials to rectangular and custom 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.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', 'dijit/form/Button', 'dijit/form/DropDownButton', 'dijit/DropDownMenu', 'dijit/MenuItem'
|
|
], function(
|
|
Cesium, CesiumViewerWidget,
|
|
on, dom, Button, DropDownButton, DropDownMenu, MenuItem)
|
|
{
|
|
"use strict";
|
|
|
|
function addRectangularSensor(sensors, ellipsoid, scene) {
|
|
var rectangularPyramidSensor = sensors.addRectangularPyramid();
|
|
Sandcastle.declare(rectangularPyramidSensor); // For highlighting in Sandcastle.
|
|
|
|
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
|
|
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));
|
|
|
|
rectangularPyramidSensor.modelMatrix = modelMatrix;
|
|
rectangularPyramidSensor.radius = 20000000.0;
|
|
rectangularPyramidSensor.xHalfAngle = Cesium.Math.toRadians(40.0);
|
|
rectangularPyramidSensor.yHalfAngle = Cesium.Math.toRadians(20.0);
|
|
|
|
rectangularPyramidSensor.material = Cesium.Material.fromType(scene.getContext(), 'Color');
|
|
rectangularPyramidSensor.material.uniforms.color = {
|
|
red : 0.0,
|
|
green : 1.0,
|
|
blue : 1.0,
|
|
alpha : 0.5
|
|
};
|
|
}
|
|
|
|
function addCustomSensor(sensors, ellipsoid, scene) {
|
|
var customSensor = sensors.addCustom();
|
|
Sandcastle.declare(customSensor); // For highlighting in Sandcastle.
|
|
|
|
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(ellipsoid.cartographicToCartesian(Cesium.Cartographic.fromDegrees(-90.0, 0.0)));
|
|
modelMatrix = modelMatrix.multiply(Cesium.Matrix4.fromTranslation(new Cesium.Cartesian3(3000000.0, 0.0, -3000000.0)));
|
|
var directions = [];
|
|
for (var i = 0; i < 8; ++i) {
|
|
directions.push({
|
|
clock : Cesium.Math.toRadians(45.0 * i),
|
|
cone : Cesium.Math.toRadians(25.0)
|
|
});
|
|
}
|
|
|
|
customSensor.modelMatrix = modelMatrix;
|
|
customSensor.radius = 20000000.0;
|
|
customSensor.setDirections(directions);
|
|
}
|
|
|
|
function createButtons(widget, sensors) {
|
|
var ellipsoid = widget.ellipsoid;
|
|
var scene = widget.scene;
|
|
var primitives = scene.getPrimitives();
|
|
primitives.add(sensors);
|
|
|
|
var sensorMenu = new DropDownMenu({ style: 'display: none;'});
|
|
|
|
sensorMenu.addChild(new MenuItem({
|
|
label: 'Rectangular',
|
|
onClick: function() {
|
|
sensors.removeAll();
|
|
addRectangularSensor(sensors, ellipsoid, scene);
|
|
}
|
|
}));
|
|
|
|
sensorMenu.addChild(new MenuItem({
|
|
label: 'Custom',
|
|
onClick: function() {
|
|
sensors.removeAll();
|
|
addCustomSensor(sensors, ellipsoid, scene);
|
|
}
|
|
}));
|
|
|
|
|
|
new DropDownButton({
|
|
label : 'Select a sensor',
|
|
dropDown: sensorMenu
|
|
}).placeAt('toolbar');
|
|
}
|
|
|
|
var widget = new CesiumViewerWidget({
|
|
onObjectMousedOver : function(mousedOverObject) {
|
|
widget.highlightObject(mousedOverObject);
|
|
Sandcastle.highlight(mousedOverObject);
|
|
}
|
|
});
|
|
widget.placeAt(dom.byId('cesiumContainer'));
|
|
widget.startup();
|
|
dom.byId('toolbar').innerHTML = '';
|
|
|
|
var sensors = new Cesium.SensorVolumeCollection();
|
|
createButtons(widget, sensors);
|
|
addRectangularSensor(sensors, widget.ellipsoid, widget.scene);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|