Advertisement
Guest User

Cesium

a guest
Jun 15th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.25 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <!-- Use correct character set. -->
  5.   <meta charset="utf-8">
  6.   <!-- Tell IE to use the latest, best version (or Chrome Frame if pre-IE11). -->
  7.   <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  8.   <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
  9.   <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
  10.   <title>Hello World!</title>
  11.   <script src="Cesium/Cesium.js"></script>
  12.   <style>
  13.       @import url(Cesium/Widgets/widgets.css);
  14.  
  15.       #cesiumContainer {
  16.           position: absolute;
  17.           top: 0;
  18.           left: 0;
  19.           height: 100%;
  20.           width: 100%;
  21.           margin: 0;
  22.           overflow: hidden;
  23.           padding: 0;
  24.           font-family: sans-serif;
  25.       }
  26.  
  27.       body {
  28.           padding: 0;
  29.           margin: 0;
  30.           overflow: hidden;
  31.       }
  32.   </style>
  33. </head>
  34. <body>
  35.   <div id="cesiumContainer"></div>
  36.   <script>
  37.  
  38.     var viewer = new Cesium.Viewer('cesiumContainer');
  39.     var primitives = viewer.scene.primitives;
  40.    
  41.     // Create box and position with a model matrix
  42.     var dimensions = new Cesium.Cartesian3(400000.0, 300000.0, 9000000.0);
  43.     var positionOnEllipsoid = Cesium.Cartesian3.fromDegrees(-105.0, 45.0);
  44.     var boxModelMatrix = Cesium.Matrix4.multiplyByTranslation(
  45.         Cesium.Transforms.eastNorthUpToFixedFrame(positionOnEllipsoid),
  46.         new Cesium.Cartesian3(0.0, 0.0, dimensions.z * 0.5));
  47.    
  48.     var boxGeometry = Cesium.BoxGeometry.fromDimensions({
  49.         vertexFormat : Cesium.PerInstanceColorAppearance.VERTEX_FORMAT,
  50.         dimensions : dimensions
  51.     });
  52.  
  53.     var boxGeometryInstance = new Cesium.GeometryInstance({
  54.         geometry : boxGeometry,
  55.         modelMatrix : boxModelMatrix,
  56.         attributes : {
  57.             color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
  58.         }
  59.     });
  60.  
  61.     primitives.add(new Cesium.Primitive({
  62.         geometryInstances : boxGeometryInstance,
  63.         appearance : new Cesium.PerInstanceColorAppearance({
  64.             closed: true
  65.         })
  66.     }));
  67.  
  68.  
  69.   </script>
  70. </body>
  71. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement