mirror of
https://github.com/jiawanlong/Cesium-Examples.git
synced 2025-07-04 15:17:36 +00:00
64 lines
2.5 KiB
HTML
64 lines
2.5 KiB
HTML
<!--********************************************************************
|
|
* 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">
|
|
|
|
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyMjBhMzcxMC0wNjBiLTRmYjItYjY1MC0wMzAwMzMyMGUyMmEiLCJpZCI6MzAzNzc3LCJpYXQiOjE3NDc2Mzk0NTV9.E_90aKtVdzRGlU2z48VwJ4mWvl-uuDkfQBCOO6zbzn4'
|
|
const viewer = new Cesium.Viewer('map', {});
|
|
|
|
// -------------------------------------------------------------------Material----------------------------------------------------------------------
|
|
// 使用Fabric JSON定义材质
|
|
const material = new Cesium.Material({
|
|
fabric: {
|
|
type: "Color", // 内置材质类型
|
|
uniforms: {
|
|
color: new Cesium.Color(1.0, 1.0, 0.0, 1.0) // 黄色
|
|
}
|
|
}
|
|
});
|
|
|
|
// 或使用内置简写
|
|
// const material = Cesium.Material.fromType("Color", {
|
|
// color: Cesium.Color.RED
|
|
// });
|
|
|
|
const primitive = new Cesium.Primitive({
|
|
geometryInstances: new Cesium.GeometryInstance(
|
|
{
|
|
id: 'polygon',
|
|
geometry: new Cesium.PolygonGeometry({
|
|
polygonHierarchy: new Cesium.PolygonHierarchy(
|
|
Cesium.Cartesian3.fromDegreesArray([
|
|
-115.0, 37.0,
|
|
-115.0, 32.0,
|
|
-102.0, 31.0,
|
|
-102.0, 35.0
|
|
])
|
|
),
|
|
})
|
|
}
|
|
),
|
|
appearance: new Cesium.MaterialAppearance({
|
|
material: material
|
|
})
|
|
});
|
|
|
|
viewer.scene.primitives.add(primitive);
|
|
// -------------------------------------------------------------------Material----------------------------------------------------------------------
|
|
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |