|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| 6 | + <meta |
| 7 | + name="viewport" |
| 8 | + content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" |
| 9 | + /> |
| 10 | + <meta name="description" content="Add MSAA to the scene." /> |
| 11 | + <meta name="cesium-sandcastle-labels" content="Showcases" /> |
| 12 | + <title>Cesium Demo</title> |
| 13 | + <script type="text/javascript" src="../Sandcastle-header.js"></script> |
| 14 | + <script |
| 15 | + type="text/javascript" |
| 16 | + src="../../../Build/CesiumUnminified/Cesium.js" |
| 17 | + nomodule |
| 18 | + ></script> |
| 19 | + <script type="module" src="../load-cesium-es6.js"></script> |
| 20 | + </head> |
| 21 | + <body |
| 22 | + class="sandcastle-loading" |
| 23 | + data-sandcastle-bucket="bucket-requirejs.html" |
| 24 | + > |
| 25 | + <style> |
| 26 | + @import url(../templates/bucket.css); |
| 27 | + </style> |
| 28 | + <div id="cesiumContainer" class="fullSize"></div> |
| 29 | + <div id="loadingOverlay"><h1>Loading...</h1></div> |
| 30 | + <div id="toolbar"></div> |
| 31 | + <script id="cesium_sandcastle_script"> |
| 32 | + function startup(Cesium) { |
| 33 | + "use strict"; |
| 34 | + //Sandcastle_Begin |
| 35 | + const viewer = new Cesium.Viewer("cesiumContainer", { |
| 36 | + terrainProvider: Cesium.createWorldTerrain(), |
| 37 | + contextOptions: { |
| 38 | + requestWebgl2: true, |
| 39 | + }, |
| 40 | + }); |
| 41 | + |
| 42 | + const scene = viewer.scene; |
| 43 | + if (!scene.msaaSupported) { |
| 44 | + window.alert("This browser does not support MSAA."); |
| 45 | + } |
| 46 | + |
| 47 | + function createModel(url, height) { |
| 48 | + const position = Cesium.Cartesian3.fromDegrees( |
| 49 | + -123.0744619, |
| 50 | + 44.0503706, |
| 51 | + height |
| 52 | + ); |
| 53 | + const heading = Cesium.Math.toRadians(135); |
| 54 | + const pitch = 0; |
| 55 | + const roll = 0; |
| 56 | + const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); |
| 57 | + const orientation = Cesium.Transforms.headingPitchRollQuaternion( |
| 58 | + position, |
| 59 | + hpr |
| 60 | + ); |
| 61 | + |
| 62 | + const entity = viewer.entities.add({ |
| 63 | + name: url, |
| 64 | + position: position, |
| 65 | + orientation: orientation, |
| 66 | + model: { |
| 67 | + uri: url, |
| 68 | + minimumPixelSize: 128, |
| 69 | + maximumScale: 20000, |
| 70 | + }, |
| 71 | + }); |
| 72 | + const target = Cesium.Cartesian3.fromDegrees( |
| 73 | + -123.0744619, |
| 74 | + 44.0503706, |
| 75 | + height + 7.5 |
| 76 | + ); |
| 77 | + const offset = new Cesium.Cartesian3(50.0, -15.0, 0.0); |
| 78 | + viewer.scene.camera.lookAt(target, offset); |
| 79 | + } |
| 80 | + |
| 81 | + const options = [ |
| 82 | + { |
| 83 | + text: "Statue of Liberty", |
| 84 | + onselect: function () { |
| 85 | + viewer.entities.removeAll(); |
| 86 | + scene.primitives.removeAll(); |
| 87 | + scene.camera.setView({ |
| 88 | + destination: new Cesium.Cartesian3( |
| 89 | + 1331419.302230775, |
| 90 | + -4656681.5022043325, |
| 91 | + 4136232.6465900405 |
| 92 | + ), |
| 93 | + orientation: new Cesium.HeadingPitchRoll( |
| 94 | + 6.032455545102689, |
| 95 | + -0.056832496140112765, |
| 96 | + 6.282360923090216 |
| 97 | + ), |
| 98 | + endTransform: Cesium.Matrix4.IDENTITY, |
| 99 | + }); |
| 100 | + |
| 101 | + scene.primitives.add( |
| 102 | + new Cesium.Cesium3DTileset({ |
| 103 | + url: Cesium.IonResource.fromAssetId(75343), |
| 104 | + }) |
| 105 | + ); |
| 106 | + }, |
| 107 | + }, |
| 108 | + { |
| 109 | + text: "3D Tiles BIM", |
| 110 | + onselect: function () { |
| 111 | + viewer.entities.removeAll(); |
| 112 | + scene.primitives.removeAll(); |
| 113 | + const tileset = scene.primitives.add( |
| 114 | + new Cesium.Cesium3DTileset({ |
| 115 | + url: Cesium.IonResource.fromAssetId(8564), |
| 116 | + }) |
| 117 | + ); |
| 118 | + viewer.camera.setView({ |
| 119 | + destination: new Cesium.Cartesian3( |
| 120 | + 1234138.7804841248, |
| 121 | + -5086063.633843134, |
| 122 | + 3633284.606361642 |
| 123 | + ), |
| 124 | + orientation: { |
| 125 | + heading: 0.4304630387656614, |
| 126 | + pitch: -0.16969316864215878, |
| 127 | + roll: 6.283184816241989, |
| 128 | + }, |
| 129 | + }); |
| 130 | + }, |
| 131 | + }, |
| 132 | + { |
| 133 | + text: "Hot Air Balloon", |
| 134 | + onselect: function () { |
| 135 | + viewer.entities.removeAll(); |
| 136 | + scene.primitives.removeAll(); |
| 137 | + createModel( |
| 138 | + "../../SampleData/models/CesiumBalloon/CesiumBalloon.glb", |
| 139 | + 1000.0 |
| 140 | + ); |
| 141 | + }, |
| 142 | + }, |
| 143 | + ]; |
| 144 | + |
| 145 | + const samplingOptions = [ |
| 146 | + { |
| 147 | + text: "MSAA off", |
| 148 | + onselect: function () { |
| 149 | + scene.msaaSamples = 1; |
| 150 | + }, |
| 151 | + }, |
| 152 | + { |
| 153 | + text: "MSAA 2x", |
| 154 | + onselect: function () { |
| 155 | + scene.msaaSamples = 2; |
| 156 | + }, |
| 157 | + }, |
| 158 | + { |
| 159 | + text: "MSAA 4x", |
| 160 | + onselect: function () { |
| 161 | + scene.msaaSamples = 4; |
| 162 | + }, |
| 163 | + }, |
| 164 | + { |
| 165 | + text: "MSAA 8x", |
| 166 | + onselect: function () { |
| 167 | + scene.msaaSamples = 8; |
| 168 | + }, |
| 169 | + }, |
| 170 | + ]; |
| 171 | + |
| 172 | + Sandcastle.addToolbarMenu(options); |
| 173 | + Sandcastle.addToolbarMenu(samplingOptions); |
| 174 | + //Sandcastle_End |
| 175 | + Sandcastle.finishedLoading(); |
| 176 | + } |
| 177 | + if (typeof Cesium !== "undefined") { |
| 178 | + window.startupCalled = true; |
| 179 | + startup(Cesium); |
| 180 | + } |
| 181 | + </script> |
| 182 | + </body> |
| 183 | +</html> |
0 commit comments