-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10052 from CesiumGS/manager-msaa
Add MSAA option for Webgl2
- Loading branch information
Showing
24 changed files
with
1,223 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" | ||
/> | ||
<meta name="description" content="Add MSAA to the scene." /> | ||
<meta name="cesium-sandcastle-labels" content="Showcases" /> | ||
<title>Cesium Demo</title> | ||
<script type="text/javascript" src="../Sandcastle-header.js"></script> | ||
<script | ||
type="text/javascript" | ||
src="../../../Build/CesiumUnminified/Cesium.js" | ||
nomodule | ||
></script> | ||
<script type="module" src="../load-cesium-es6.js"></script> | ||
</head> | ||
<body | ||
class="sandcastle-loading" | ||
data-sandcastle-bucket="bucket-requirejs.html" | ||
> | ||
<style> | ||
@import url(../templates/bucket.css); | ||
</style> | ||
<div id="cesiumContainer" class="fullSize"></div> | ||
<div id="loadingOverlay"><h1>Loading...</h1></div> | ||
<div id="toolbar"></div> | ||
<script id="cesium_sandcastle_script"> | ||
function startup(Cesium) { | ||
"use strict"; | ||
//Sandcastle_Begin | ||
const viewer = new Cesium.Viewer("cesiumContainer", { | ||
terrainProvider: Cesium.createWorldTerrain(), | ||
contextOptions: { | ||
requestWebgl2: true, | ||
}, | ||
}); | ||
|
||
const scene = viewer.scene; | ||
if (!scene.msaaSupported) { | ||
window.alert("This browser does not support MSAA."); | ||
} | ||
|
||
function createModel(url, height) { | ||
const position = Cesium.Cartesian3.fromDegrees( | ||
-123.0744619, | ||
44.0503706, | ||
height | ||
); | ||
const heading = Cesium.Math.toRadians(135); | ||
const pitch = 0; | ||
const roll = 0; | ||
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); | ||
const orientation = Cesium.Transforms.headingPitchRollQuaternion( | ||
position, | ||
hpr | ||
); | ||
|
||
const entity = viewer.entities.add({ | ||
name: url, | ||
position: position, | ||
orientation: orientation, | ||
model: { | ||
uri: url, | ||
minimumPixelSize: 128, | ||
maximumScale: 20000, | ||
}, | ||
}); | ||
const target = Cesium.Cartesian3.fromDegrees( | ||
-123.0744619, | ||
44.0503706, | ||
height + 7.5 | ||
); | ||
const offset = new Cesium.Cartesian3(50.0, -15.0, 0.0); | ||
viewer.scene.camera.lookAt(target, offset); | ||
} | ||
|
||
const options = [ | ||
{ | ||
text: "Statue of Liberty", | ||
onselect: function () { | ||
viewer.entities.removeAll(); | ||
scene.primitives.removeAll(); | ||
scene.camera.setView({ | ||
destination: new Cesium.Cartesian3( | ||
1331419.302230775, | ||
-4656681.5022043325, | ||
4136232.6465900405 | ||
), | ||
orientation: new Cesium.HeadingPitchRoll( | ||
6.032455545102689, | ||
-0.056832496140112765, | ||
6.282360923090216 | ||
), | ||
endTransform: Cesium.Matrix4.IDENTITY, | ||
}); | ||
|
||
scene.primitives.add( | ||
new Cesium.Cesium3DTileset({ | ||
url: Cesium.IonResource.fromAssetId(75343), | ||
}) | ||
); | ||
}, | ||
}, | ||
{ | ||
text: "3D Tiles BIM", | ||
onselect: function () { | ||
viewer.entities.removeAll(); | ||
scene.primitives.removeAll(); | ||
const tileset = scene.primitives.add( | ||
new Cesium.Cesium3DTileset({ | ||
url: Cesium.IonResource.fromAssetId(8564), | ||
}) | ||
); | ||
viewer.camera.setView({ | ||
destination: new Cesium.Cartesian3( | ||
1234138.7804841248, | ||
-5086063.633843134, | ||
3633284.606361642 | ||
), | ||
orientation: { | ||
heading: 0.4304630387656614, | ||
pitch: -0.16969316864215878, | ||
roll: 6.283184816241989, | ||
}, | ||
}); | ||
}, | ||
}, | ||
{ | ||
text: "Hot Air Balloon", | ||
onselect: function () { | ||
viewer.entities.removeAll(); | ||
scene.primitives.removeAll(); | ||
createModel( | ||
"../../SampleData/models/CesiumBalloon/CesiumBalloon.glb", | ||
1000.0 | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
const samplingOptions = [ | ||
{ | ||
text: "MSAA off", | ||
onselect: function () { | ||
scene.msaaSamples = 1; | ||
}, | ||
}, | ||
{ | ||
text: "MSAA 2x", | ||
onselect: function () { | ||
scene.msaaSamples = 2; | ||
}, | ||
}, | ||
{ | ||
text: "MSAA 4x", | ||
onselect: function () { | ||
scene.msaaSamples = 4; | ||
}, | ||
}, | ||
{ | ||
text: "MSAA 8x", | ||
onselect: function () { | ||
scene.msaaSamples = 8; | ||
}, | ||
}, | ||
]; | ||
|
||
Sandcastle.addToolbarMenu(options); | ||
Sandcastle.addToolbarMenu(samplingOptions); | ||
//Sandcastle_End | ||
Sandcastle.finishedLoading(); | ||
} | ||
if (typeof Cesium !== "undefined") { | ||
window.startupCalled = true; | ||
startup(Cesium); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.