Skip to content

Commit 16b28b4

Browse files
committed
Merge remote-tracking branch 'origin' into cesium.com
2 parents 62f5efb + f7244d3 commit 16b28b4

File tree

132 files changed

+3060
-2429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+3060
-2429
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- name: message result in slack
1616
id: slack
17-
uses: slackapi/slack-github-action@v1.26.0
17+
uses: slackapi/slack-github-action@v1.27.0
1818
env:
1919
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
2020
with:

Apps/CesiumViewer/CesiumViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ async function main() {
125125
sourceType = "geojson";
126126
} else if (/\.kml$/i.test(source) || /\.kmz$/i.test(source)) {
127127
sourceType = "kml";
128-
} else if (/\.gpx$/i.test(source) || /\.gpx$/i.test(source)) {
128+
} else if (/\.gpx$/i.test(source)) {
129129
sourceType = "gpx";
130130
}
131131
}

Apps/Sandcastle/gallery/Bathymetry.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106

107107
const scene = viewer.scene;
108108

109-
// prevent aliasing from countour lines
110-
scene.msaaSamples = 4;
111-
112109
const globe = scene.globe;
113110
globe.enableLighting = true;
114111
globe.maximumScreenSpaceError = 1.0; // Load higher resolution tiles for better seafloor shading
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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="Apply materials to the globe." />
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">
31+
<div id="zoomButtons"></div>
32+
</div>
33+
<script id="cesium_sandcastle_script">
34+
window.startup = async function (Cesium) {
35+
"use strict";
36+
//Sandcastle_Begin
37+
const viewer = new Cesium.Viewer("cesiumContainer", {
38+
terrain: Cesium.Terrain.fromWorldTerrain({
39+
requestVertexNormals: true, // Needed for hillshading
40+
requestWaterMask: true, // Needed to distinguish land from water
41+
}),
42+
timeline: false,
43+
animation: false,
44+
});
45+
46+
// Create a globe material for shading elevation only on land
47+
const customElevationMaterial = new Cesium.Material({
48+
fabric: {
49+
type: "ElevationLand",
50+
materials: {
51+
waterMaskMaterial: {
52+
type: "WaterMask",
53+
},
54+
elevationRampMaterial: {
55+
type: "ElevationRamp",
56+
},
57+
},
58+
components: {
59+
diffuse: "elevationRampMaterial.diffuse",
60+
alpha: "1.0 - waterMaskMaterial.alpha", // We'll need the inverse of the watermask to shade land
61+
},
62+
},
63+
translucent: false,
64+
});
65+
66+
const minHeight = -414.0; // approximate dead sea elevation
67+
const maxHeight = 8777.0; // approximate everest elevation
68+
const elevationRamp = [0.0, 0.045, 0.45, 0.5, 0.55, 1.0];
69+
function getColorRamp() {
70+
const ramp = document.createElement("canvas");
71+
ramp.width = 100;
72+
ramp.height = 1;
73+
const ctx = ramp.getContext("2d");
74+
75+
const values = elevationRamp;
76+
77+
const grd = ctx.createLinearGradient(0, 0, 100, 0);
78+
79+
// See https://gis.stackexchange.com/questions/25099/choosing-colour-ramp-to-use-for-elevation
80+
grd.addColorStop(values[0], "#344f31");
81+
grd.addColorStop(values[1], "#5b8742");
82+
grd.addColorStop(values[2], "#e6daa5");
83+
grd.addColorStop(values[3], "#fdc771");
84+
grd.addColorStop(values[4], "#b99d89");
85+
grd.addColorStop(values[5], "#f0f0f0");
86+
87+
ctx.fillStyle = grd;
88+
ctx.fillRect(0, 0, 100, 1);
89+
90+
return ramp;
91+
}
92+
93+
const globe = viewer.scene.globe;
94+
const material = customElevationMaterial;
95+
const shadingUniforms =
96+
material.materials.elevationRampMaterial.uniforms;
97+
shadingUniforms.minimumHeight = minHeight;
98+
shadingUniforms.maximumHeight = maxHeight;
99+
shadingUniforms.image = getColorRamp();
100+
101+
globe.material = material;
102+
globe.showWaterEffect = false;
103+
globe.enableLighting = true;
104+
globe.maximumScreenSpaceError = 0.5; // Load higher resolution tiles for more detailed shading
105+
106+
// Light the scene with a hillshade effect similar to https://pro.arcgis.com/en/pro-app/latest/tool-reference/3d-analyst/how-hillshade-works.htm
107+
const scene = viewer.scene;
108+
scene.light = new Cesium.DirectionalLight({
109+
direction: new Cesium.Cartesian3(1, 0, 0), // Updated every frame
110+
});
111+
112+
// Update the light position base on the camera
113+
const scratchNormal = new Cesium.Cartesian3();
114+
scene.preRender.addEventListener(function (scene, time) {
115+
const surfaceNormal = globe.ellipsoid.geodeticSurfaceNormal(
116+
scene.camera.positionWC,
117+
scratchNormal
118+
);
119+
const negativeNormal = Cesium.Cartesian3.negate(
120+
surfaceNormal,
121+
surfaceNormal
122+
);
123+
scene.light.direction = Cesium.Cartesian3.normalize(
124+
Cesium.Cartesian3.add(
125+
negativeNormal,
126+
scene.camera.rightWC,
127+
surfaceNormal
128+
),
129+
scene.light.direction
130+
);
131+
});
132+
//Sandcastle_End
133+
};
134+
if (typeof Cesium !== "undefined") {
135+
window.startupCalled = true;
136+
window.startup(Cesium).catch((error) => {
137+
"use strict";
138+
console.error(error);
139+
});
140+
Sandcastle.finishedLoading();
141+
}
142+
</script>
143+
</body>
144+
</html>
21.6 KB
Loading

Apps/Sandcastle/gallery/Globe Materials.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
name="viewport"
88
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"
99
/>
10-
<meta name="description" content="Apply materials to the globe." />
10+
<meta name="description" content="Apply an elevation map to the globe." />
1111
<meta name="cesium-sandcastle-labels" content="Showcases" />
1212
<title>Cesium Demo</title>
1313
<script type="text/javascript" src="../Sandcastle-header.js"></script>

Apps/Sandcastle/gallery/High Dynamic Range.html

Lines changed: 136 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,120 @@
2424
>
2525
<style>
2626
@import url(../templates/bucket.css);
27+
28+
#toolbar {
29+
background: rgba(42, 42, 42, 0.8);
30+
padding: 4px;
31+
border-radius: 4px;
32+
}
33+
34+
#toolbar input {
35+
vertical-align: middle;
36+
padding-top: 2px;
37+
padding-bottom: 2px;
38+
}
2739
</style>
2840
<div id="cesiumContainer" class="fullSize"></div>
2941
<div id="loadingOverlay"><h1>Loading...</h1></div>
30-
<div id="toolbar"></div>
42+
<div id="toolbar">
43+
<div id="hdr-toggle"></div>
44+
<span>Tonemap</span>
45+
<span id="tonemap-select"></span>
46+
<br />
47+
<span>Exposure</span>
48+
<input
49+
type="range"
50+
min="0.1"
51+
max="10.0"
52+
step="0.1"
53+
data-bind="value: exposure, valueUpdate: 'input'"
54+
/>
55+
<input type="text" size="5" data-bind="value: exposure" />
56+
</div>
3157
<script id="cesium_sandcastle_script">
3258
window.startup = async function (Cesium) {
3359
"use strict";
3460
//Sandcastle_Begin
3561
const viewer = new Cesium.Viewer("cesiumContainer", {
3662
terrain: Cesium.Terrain.fromWorldTerrain(),
3763
shadows: true,
64+
timeline: false,
65+
animation: false,
66+
geocoder: false,
67+
sceneModePicker: false,
68+
baseLayerPicker: false,
3869
});
3970

4071
if (!viewer.scene.highDynamicRangeSupported) {
4172
window.alert("This browser does not support high dynamic range.");
4273
}
4374

44-
viewer.scene.camera.setView({
45-
destination: new Cesium.Cartesian3(
46-
-1915097.7863741855,
47-
-4783356.851539908,
48-
3748887.43462683
49-
),
50-
orientation: new Cesium.HeadingPitchRoll(
51-
6.166004548388564,
52-
-0.043242401760068994,
53-
0.002179961955988574
54-
),
55-
endTransform: Cesium.Matrix4.IDENTITY,
56-
});
57-
5875
viewer.scene.highDynamicRange = true;
5976

60-
Sandcastle.addToggleButton("HDR", true, function (checked) {
61-
viewer.scene.highDynamicRange = checked;
62-
});
77+
Sandcastle.addToggleButton(
78+
"HDR",
79+
true,
80+
function (checked) {
81+
viewer.scene.highDynamicRange = checked;
82+
},
83+
"hdr-toggle"
84+
);
85+
86+
const toneMapOptions = [
87+
{
88+
text: "PBR Neutral",
89+
onselect: function () {
90+
viewer.scene.postProcessStages.tonemapper =
91+
Cesium.Tonemapper.PBR_NEUTRAL;
92+
},
93+
},
94+
{
95+
text: "Aces",
96+
onselect: function () {
97+
viewer.scene.postProcessStages.tonemapper =
98+
Cesium.Tonemapper.ACES;
99+
},
100+
},
101+
{
102+
text: "Reinhard",
103+
onselect: function () {
104+
viewer.scene.postProcessStages.tonemapper =
105+
Cesium.Tonemapper.REINHARD;
106+
},
107+
},
108+
{
109+
text: "Modified_Reinhard",
110+
onselect: function () {
111+
viewer.scene.postProcessStages.tonemapper =
112+
Cesium.Tonemapper.MODIFIED_REINHARD;
113+
},
114+
},
115+
{
116+
text: "Filmic",
117+
onselect: function () {
118+
viewer.scene.postProcessStages.tonemapper =
119+
Cesium.Tonemapper.FILMIC;
120+
},
121+
},
122+
];
123+
Sandcastle.addDefaultToolbarMenu(toneMapOptions, "tonemap-select");
124+
125+
const viewModel = {
126+
exposure: 1,
127+
};
128+
// Convert the viewModel members into knockout observables.
129+
Cesium.knockout.track(viewModel);
130+
// Bind the viewModel to the DOM elements of the UI that call for it.
131+
const toolbar = document.getElementById("toolbar");
132+
Cesium.knockout.applyBindings(viewModel, toolbar);
133+
134+
Cesium.knockout
135+
.getObservable(viewModel, "exposure")
136+
.subscribe(function (newValue) {
137+
viewer.scene.postProcessStages.exposure = Number.parseFloat(
138+
newValue
139+
);
140+
});
63141

64142
const url =
65143
"../../SampleData/models/DracoCompressed/CesiumMilkTruck.gltf";
@@ -86,7 +164,46 @@
86164
uri: url,
87165
scale: scale,
88166
},
89-
}); //Sandcastle_End
167+
});
168+
169+
// set up canyon view
170+
viewer.scene.camera.setView({
171+
destination: new Cesium.Cartesian3(
172+
-1915097.7863741855,
173+
-4783356.851539908,
174+
3748887.43462683
175+
),
176+
orientation: new Cesium.HeadingPitchRoll(
177+
6.166004548388564,
178+
-0.043242401760068994,
179+
0.002179961955988574
180+
),
181+
endTransform: Cesium.Matrix4.IDENTITY,
182+
});
183+
// set time so the sun is overhead
184+
viewer.clock.currentTime = new Cesium.JulianDate(2460550, 21637);
185+
186+
viewer.scene.debugShowFramesPerSecond = true;
187+
// override the default home location to return to the start
188+
viewer.homeButton.viewModel.command.beforeExecute.addEventListener(
189+
(e) => {
190+
e.cancel = true;
191+
viewer.scene.camera.setView({
192+
destination: new Cesium.Cartesian3(
193+
-1915097.7863741855,
194+
-4783356.851539908,
195+
3748887.43462683
196+
),
197+
orientation: new Cesium.HeadingPitchRoll(
198+
6.166004548388564,
199+
-0.043242401760068994,
200+
0.002179961955988574
201+
),
202+
endTransform: Cesium.Matrix4.IDENTITY,
203+
});
204+
}
205+
);
206+
//Sandcastle_End
90207
};
91208
if (typeof Cesium !== "undefined") {
92209
window.startupCalled = true;

Apps/Sandcastle/gallery/I3S Building Scene Layer.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ <h1>Loading...</h1>
5656
animation: false,
5757
timeline: false,
5858
orderIndependentTranslucency: false,
59-
msaaSamples: 4, // enables multisample antialiasing for improved visual quality
6059
});
6160

6261
// More datasets to tour can be added here...

Apps/Sandcastle/gallery/Japan Buildings.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
sceneModePicker: false,
4646
animation: false,
4747
timeline: false,
48-
msaaSamples: 4,
4948
});
5049
const scene = viewer.scene;
5150
scene.globe.depthTestAgainstTerrain = true;

Apps/Sandcastle/gallery/Star Burst.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320

321321
// Remove the star burst if the mouse exits the screen space circle.
322322
// If the mouse is inside the circle, show the label of the billboard the mouse is hovering over.
323-
const screenPosition = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
323+
const screenPosition = Cesium.SceneTransforms.worldToWindowCoordinates(
324324
scene,
325325
starBurstState.center
326326
);

0 commit comments

Comments
 (0)