效果
代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>cesium|xt3d</title>
<!-- 引入Cesium -->
<script src="https://unpkg.com/cesium@1.84.0/Build/Cesium/Cesium.js"></script>
<link rel="stylesheet" href="https://unpkg.com/cesium@1.84.0/Build/Cesium/Widgets/widgets.css">
<!-- 使用vue绑定控件 -->
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.15.5/lib/theme-chalk/index.css">
<script src="https://unpkg.com/element-ui@2.15.5/lib/index.js"></script>
<!-- 引入xt3d -->
<script src="http://www.xt3d.cn/xt3dlib/xt3d.min.js"></script>
<style>
html,
body,
#map3d {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
.form-container {
position: absolute;
left: 10px;
top: 90px;
padding: 10px 15px;
border-radius: 4px;
border: 1px solid rgba(128, 128, 128, 0.5);
color: #ffffff;
background: rgba(0, 0, 0, 0.4);
box-shadow: 0 3px 14px rgb(128 128 128 / 50%);
width: 380px;
}
.el-form-item__label {
color: white;
}
</style>
</head>
<body>
<div id="map3d"></div>
<div class="form-container" id="formContainer">
<el-form :model="form" label-width="140px" label-position="left" size="mini">
<el-form-item label="方向(heading)">
<el-slider v-model="form.heading" :show-tooltip="true" @input="valueChange" :min="0" :max="360"></el-slider>
</el-form-item>
<el-form-item label="前后摇摆(pitch)">
<el-slider v-model="form.pitch" :show-tooltip="true" @input="valueChange" :min="-180" :max="180"></el-slider>
</el-form-item>
<el-form-item label="左右摇摆(roll)">
<el-slider v-model="form.roll" :show-tooltip="true" @input="valueChange" :min="-180" :max="180"></el-slider>
</el-form-item>
<el-form-item label="夹角1">
<el-slider v-model="form.angle1" :show-tooltip="true" @input="valueChange" :min="0" :max="90"></el-slider>
</el-form-item>
<el-form-item label="夹角2">
<el-slider v-model="form.angle2" :show-tooltip="true" @input="valueChange" :min="0" :max="90"></el-slider>
</el-form-item>
<el-form-item label="距离">
<el-slider v-model="form.far" :show-tooltip="true" :step="20" @change="valueChange" :min="10" :max="9999999"></el-slider>
</el-form-item>
</el-form>
</div>
<script>
let xt3dInit = {
init(el) {
this.initViewer(el);
this.initPyramid();
this.setView();
},
initViewer(el) {
this.viewer = new Cesium.Viewer(el, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
shouldAnimate: true,
imageryProvider: new Cesium.ArcGisMapServerImageryProvider({
url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
}),
});
this.viewer.scene.globe.depthTestAgainstTerrain = true;
this.viewer.scene.fxaa = true;
this.viewer.scene.postProcessStages.fxaa.enabled = true;
},
initPyramid() {
let position = Cesium.Cartesian3.fromDegrees(117.169969, 31.840886, 899999.87);
this.pyramid = new xt3d.SpacePlugin.SatellitePyramid(this.viewer, position, {
modelUrl: "/data.xt3d.cn/assets/gltf/weixin.gltf",
scale: 60
});
},
setView() {
this.viewer.scene.camera.setView({
duration: 1,
destination: {
x: -3610616.535767916,
y: 7542288.61411993,
z: 2764700.1118213907
},
orientation: {
heading: 0.07548868416752708,
pitch: -0.9393689784973649,
roll: 6.283050993104599
}
});
},
destroy() {
this.viewer.entities.removeAll();
this.viewer.imageryLayers.removeAll(true);
this.viewer.destroy();
}
}
xt3dInit.init("map3d");
let vm = new Vue({
el: "#formContainer",
data() {
return {
form: {
farMax: 20000000
}
}
},
methods: {
valueChange() {
xt3dInit.pyramid.updateStyle(this.form);
}
}
})
vm.form = xt3dInit.pyramid.getStyle();
</script>
</body>
</html>
预览地址
xt3d 在线预览地址
|