1 Star 0 Fork 6

cc/CesiumStudy

forked from Cubic/CesiumStudy 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
44.旋转模型.html 5.02 KB
一键复制 编辑 原始数据 按行查看 历史
pop 提交于 2021-01-20 17:47 . 日常
<!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;
}
#getposition {
position: absolute;
top: 0;
left: 0;
width: 300px;
height: 600px;
background-color: gray
}
</style>
</head>
<body>
<button onClick="rotatex()">rotatex</button>
<button onClick="rotatey()">rotatey</button>
<button onClick="rotatez()">rotatez</button>
<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;//开启帧数
var shadowMap = viewer.shadowMap;
shadowMap.softShadows = true;
shadowMap.maximumDistance = 1300.0;
//添加数据
//添加文字
viewer.entities.add({
name: '文字',
position: Cesium.Cartesian3.fromDegrees(116.39123, 39.90691),
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: '测试辅助文件/彩版压缩环氧乙烷/tileset.json', //数据路径
// url: '测试辅助文件/催化重整/催化重整.json', //数据路径
maximumScreenSpaceError: 20, //最大的屏幕空间误差,数值越小,显示越精细
maximumNumberOfLoadedTiles: 1000, //最大加载瓦片个数
//minimumPixelSize: 500,
}));
viewer.scene.postProcessStages.fxaa.enabled = true;
var utc = Cesium.JulianDate.fromDate(new Date("2019/10/04 12:30:00"));//UTC
var boundingSphere = new Cesium.BoundingSphere(Cesium.Cartesian3.fromDegrees(116.39123, 39.90691, 10), 18.7);
viewer.camera.flyToBoundingSphere(boundingSphere, { duration: 0 });
///下面是本次代码
var m = tileset.modelMatrix;
var anglex = 0;
function rotatex() {
anglex += 0.001;
let m1 = Cesium.Matrix3.fromRotationX(Cesium.Math.toRadians(anglex));
tileset.modelMatrix = Cesium.Matrix4.multiplyByMatrix3(m, m1, new Cesium.Matrix4());
}
var angley = 1;
function rotatey() {
angley += 0.001;
let m1 = Cesium.Matrix3.fromRotationY(Cesium.Math.toRadians(angley));
tileset.modelMatrix = Cesium.Matrix4.multiplyByMatrix3(m, m1, new Cesium.Matrix4());
}
var anglez = 1;
function rotatez() {
anglez += 0.001;
let m1 = Cesium.Matrix3.fromRotationZ(Cesium.Math.toRadians(anglez));
tileset.modelMatrix = Cesium.Matrix4.multiplyByMatrix3(m, m1, new Cesium.Matrix4());
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/cc_chan/cesium-study.git
[email protected]:cc_chan/cesium-study.git
cc_chan
cesium-study
CesiumStudy
master

搜索帮助