Cesium-Examples/examples/cesiumEx/2.3.3、entity面.html
2025-11-26 14:20:25 +08:00

145 lines
4.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--********************************************************************
* by jiawanlong
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="./../../libs/cesium/Cesium1.98/Widgets/widgets.css">
<script type="text/javascript" src="./../../libs/cesium/Cesium1.98/Cesium.js"></script>
</head>
<body style="margin: 0; overflow: hidden; background: #fff; width: 100%; height: 100%; position: absolute; top: 0">
<div id="map" style="margin: 0 auto; width: 100%; height: 100%"></div>
<script type="text/javascript">
const viewer = new Cesium.Viewer('map', {
imageryProvider: false,
baseLayerPicker: false,
});
var xyz = new Cesium.UrlTemplateImageryProvider({
"url": '//data.mars3d.cn/tile/img/{z}/{x}/{y}.jpg'
})
viewer.imageryLayers.addImageryProvider(xyz)
// Cesium地形
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
url: '//data.mars3d.cn/terrain'
});
// 深度监测
viewer.scene.globe.depthTestAgainstTerrain = true;
// extrudedHeight是本身高度
// height是离地高度
// --------注意贴地时候没extrudedHeight所以outline不会生效---------------
const redPolygon = viewer.entities.add({
name: "最简单的贴地面",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([
-115.0,
37.0,
-115.0,
32.0,
-107.0,
33.0,
-102.0,
31.0,
-102.0,
35.0,
]),
material: Cesium.Color.RED.withAlpha(0.5),
},
polyline: {
positions: Cesium.Cartesian3.fromDegreesArray([-115.0,
37.0,
-115.0,
32.0,
-107.0,
33.0,
-102.0,
31.0,
-102.0,
35.0,
-115.0,
37.0,]),
width: 3,
material: Cesium.Color.BLUE,
clampToGround: true,//贴地画线
}
});
const greenPolygon = viewer.entities.add({
name: "贴地围墙",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray([
-108.0,
42.0,
-100.0,
42.0,
-104.0,
40.0,
]),
extrudedHeight: 50000.0,
material: Cesium.Color.GREEN,
closeTop: false,
closeBottom: false,
},
});
const orangePolygon = viewer.entities.add({
name: "立面拉伸填充面",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([
-108.0,
25.0,
100000,
-100.0,
25.0,
100000,
-100.0,
30.0,
100000,
-108.0,
30.0,
300000,
]),
extrudedHeight: 0,
perPositionHeight: true,
material: Cesium.Color.ORANGE.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});
const cyanPolygon = viewer.entities.add({
name: "立体悬浮面",
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArrayHeights([
-90.0,
41.0,
0.0,
-85.0,
41.0,
5000.0,
-80.0,
36.0,
95550.0,
]),
perPositionHeight: true,
material: Cesium.Color.CYAN.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.BLACK,
},
});
viewer.zoomTo(viewer.entities);
</script>
</body>
</html>