准备工作:
- Vscode
- Node.js
步骤:
- 配置好Node的环境,
- 打开cmd,全局安装http-server
npm install http-server -g
- 创建一个项目文件夹cesium-temp,在根目录下创建scripts文件夹,在cesium官网下载解压后的文件中Build/Cesium复制到scripts文件夹下
- cmd 进入到项目文件路径下执行
http-server -p 8082
执行后别关闭这个cmd窗口
- 将项目文件夹用Vscode打开,在根目录下创建index.html
<!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.0">
<title>CesiumApp</title>
<script src="./scripts/Cesium/Cesium.js"></script>
<link rel="stylesheet" href="./scripts/Cesium/Widgets/widgets.css">
<style>
html,
body,
#cesiumContainer {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer', {
geocoder: false,
navigationHelpButton: false,
animation: false,
timeline: false,
fullscreenButton: false,
terrainProvider: Cesium.createWorldTerrain(),
shadows: true,
});
</script>
</body>
</html>
- 最后在8082端口验证