代码拉取完成,页面将自动刷新
同步操作将从 Cubic/CesiumStudy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8" />
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<title>Hello World!</title>
<script src="Build/Cesium/Cesium.js"></script>
<script src="js/jquery.min.js"></script>
<style>
@import url(Build/Cesium/Widgets/widgets.css);
html,
body,
#cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
//创建一个基本地球
let viewer = new Cesium.Viewer("cesiumContainer", {
imageryProvider: new Cesium.WebMapTileServiceImageryProvider({
url: 'http://t0.tianditu.gov.cn/img\_w/wmts?tk=0702d09e30dca11ed07ba4cec6d6bdac',
layer: 'img',
style: 'default',
tileMatrixSetID: 'w',
format: 'tiles',
maximumLevel: 18
}),
animation: false, //动画控制,默认true (图中1)
baseLayerPicker: false,//地图切换控件(底图以及地形图)是否显示,默认显示true (图中6)
fullscreenButton: true,//全屏按钮,默认显示true (图中4)
geocoder: false,//地名查找,默认true (图中9)
// timeline: false,//时间线,默认true (图中3)
vrButton: false,//双屏模式,默认不显示false
homeButton: true,//主页按钮,默认true (图中8)
infoBox: false,//点击要素之后显示的信息,默认true
selectionIndicator: true,//选中元素显示,默认true
shadows: true,
});
viewer.cesiumWidget.creditContainer.style.display = "none";//去cesium logo水印
viewer.scene.debugShowFramesPerSecond = true;//开启帧数
//viewer.scene.globe.enableLighting = true;
var shadowMap = viewer.shadowMap;
shadowMap.softShadows = true;
shadowMap.maximumDistance = 350.0;
shadowMap.size = 8192;
//添加数据
//添加文字
viewer.entities.add({
name: '文字',
position: Cesium.Cartesian3.fromDegrees(116.3904715, 39.90571),
label: {
text: '看这里',
font: '19px Helvetica',
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
fillColor: Cesium.Color.AZURE,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 3,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM, //垂直方向以底部来计算标签的位置
}
});
var tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
// url: '测试辅助文件/Lab导出环氧乙烷/tileset.json', //数据路径
//url: '测试辅助文件/张单单大厦/tileset.json', //数据路径
// url: '测试辅助文件/eo/tileset.json', //数据路径
// url: '测试辅助文件/eo/tileset.json', //数据路径
url: '../GH/tileset.json', //数据路径
// url: '测试辅助文件/测试小模型/tileset.json', //数据路径
// url: '测试辅助文件/催化重整/催化重整.json', //数据路径
maximumScreenSpaceError: 22, //最大的屏幕空间误差,数值越小,显示越精细
maximumNumberOfLoadedTiles: 1500, //最大加载瓦片个数
//minimumPixelSize: 500,
}));
tileset.readyPromise.then(function (model) {
var params = {
tx: 116.3904715, //模型中心X轴坐标(经度,单位:十进制度)
ty: 39.90571, //模型中心Y轴坐标(纬度,单位:十进制度)
tz: 50, //模型中心Z轴坐标(高度,单位:米)
rx: -90, //X轴(经度)方向旋转角度(单位:度)圆心应该是在地心,改动其中一个值的时候,不止变化了该变量,比如改动ry,模型的高度也有了显著上升
ry: 180, //Y轴(纬度)方向旋转角度(单位:度)
rz: 0 //Z轴(高程)方向旋转角度(单位:度)
};
//旋转
var mx = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(params.rx));
var my = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(params.ry));
var mz = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(params.rz));
var rotationX = Cesium.Matrix4.fromRotationTranslation(mx);
var rotationY = Cesium.Matrix4.fromRotationTranslation(my);
var rotationZ = Cesium.Matrix4.fromRotationTranslation(mz);
//平移
var position = Cesium.Cartesian3.fromDegrees(params.tx, params.ty, params.tz);
var m = Cesium.Transforms.eastNorthUpToFixedFrame(position);
//旋转、平移矩阵相乘
Cesium.Matrix4.multiply(m, rotationX, m);
Cesium.Matrix4.multiply(m, rotationY, m);
Cesium.Matrix4.multiply(m, rotationZ, m);
//赋值给tileset
tileset._root.transform = m;
});
var boundingSphere = new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(116.3904715, 39.90571, 10), 18.7);
viewer.camera.flyToBoundingSphere(boundingSphere, { duration: 0 });
viewer.scene.postProcessStages.fxaa.enabled = true;
var utc = Cesium.JulianDate.fromDate(new Date("2019/10/04 12:30:00"));//UTC
viewer.screenSpaceEventHandler.setInputAction(function onMouseMove(movement) {
var pickedFeature = viewer.scene.pick(movement.endPosition);
//alert(!Cesium.defined(pickedFeature));
if (!Cesium.defined(pickedFeature)) {
//如果
return;
}
var name = pickedFeature.getProperty("name");
if (!Cesium.defined(name)) {
name = pickedFeature.getProperty("id");
}
console.log(name);
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
///
var clickHandler = viewer.screenSpaceEventHandler.getInputAction(
Cesium.ScreenSpaceEventType.LEFT_CLICK
);
// An entity object which will hold info about the currently selected feature for infobox display
//一个实体对象,它将保存有关当前所选功能的信息以供信息框显示
var selectedEntity = new Cesium.Entity();
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
// Pick a new feature
var pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
clickHandler(movement);
return;
}
// Set feature infobox description
var featureName = pickedFeature.getProperty("name");
selectedEntity.name = featureName;
selectedEntity.description = 'Loading <div class="cesium-infoBox-loading"></div>';
viewer.selectedEntity = selectedEntity;
pickedFeature.show = false;
console.log(featureName);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。