mirror of
				https://github.com/jiawanlong/Cesium-Examples.git
				synced 2025-11-04 09:14:17 +00:00 
			
		
		
		
	
		
			
	
	
		
			74 lines
		
	
	
		
			86 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			74 lines
		
	
	
		
			86 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<!--********************************************************************
							 | 
						||
| 
								 | 
							
								* by jiawanlong
							 | 
						||
| 
								 | 
							
								*********************************************************************-->
							 | 
						||
| 
								 | 
							
								<!DOCTYPE html>
							 | 
						||
| 
								 | 
							
								<html>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<head>
							 | 
						||
| 
								 | 
							
								    <meta charset="UTF-8" />
							 | 
						||
| 
								 | 
							
								    <link rel="stylesheet" href="./../../cesium/Cesium1.98/Widgets/widgets.css">
							 | 
						||
| 
								 | 
							
								    <script type="text/javascript" src="./../../cesium/Cesium1.98/Cesium.js"></script>
							 | 
						||
| 
								 | 
							
								    <script src="./Roaming.js"></script>
							 | 
						||
| 
								 | 
							
								    <style>
							 | 
						||
| 
								 | 
							
								        .cotrols {
							 | 
						||
| 
								 | 
							
								            position: absolute;
							 | 
						||
| 
								 | 
							
								            left: 0;
							 | 
						||
| 
								 | 
							
								            top: 0;
							 | 
						||
| 
								 | 
							
								            z-index: 10000;
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    </style>
							 | 
						||
| 
								 | 
							
								</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>
							 | 
						||
| 
								 | 
							
								    <div class="cotrols">
							 | 
						||
| 
								 | 
							
								        <button onclick="cameraRoaming()">运动</button>
							 | 
						||
| 
								 | 
							
								        <button onclick="PauseOrContinue(false)">暂停</button>
							 | 
						||
| 
								 | 
							
								        <button onclick="PauseOrContinue(true)">继续</button>
							 | 
						||
| 
								 | 
							
								        <button onclick="EndRoaming()">取消</button>
							 | 
						||
| 
								 | 
							
								    </div>
							 | 
						||
| 
								 | 
							
								    <script type="text/javascript">
							 | 
						||
| 
								 | 
							
								        let obj = {
							 | 
						||
| 
								 | 
							
								            "type": "FeatureCollection", "features": [
							 | 
						||
| 
								 | 
							
								                { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [[112.48530039808273, 18.607323617168394], [112.4845939918718, 18.60837830893151], [112.48388639072692, 18.60943145251763], [112.48317759466049, 18.61048304790811], [112.48246760365336, 18.61153309513154], [112.48175641771306, 18.612581594176557], [112.48104403684164, 18.61362854504029], [112.4803304610247, 18.614673947743977], [112.47961569025513, 18.61571780229792], [112.47889972453821, 18.616760108694336], [112.47818256386316, 18.61780086694911], [112.47746420822752, 18.61884007706557], [112.47674465764918, 18.619877739017934], [112.4760239120908, 18.620913852860365], [112.47530197156992, 18.62194841856717], [112.47457883607903, 18.622981436149534], [112.47385450559386, 18.62401290564194], [112.47312898013834, 18.62504282701021], [112.47240225970111, 18.626071200270594], [112.47167434427598, 18.627098025431856], [112.47094523384396, 18.628123302520766], [112.47021492842615, 18.62914703150745], [112.46948342800378, 18.630169212418515], [112.46875073257145, 18.63118984526115], [112.4680168421524, 18.632208930003298], [112.46728175670702, 18.633226466699956], [112.46654547625286, 18.634242455326724], [112.4658080007767, 18.635256895901968], [112.46506933027413, 18.63626978843161], [112.46432946474917, 18.63728113291021], [112.46358840418787, 18.638290929356863], [112.46284614859066, 18.639299177770894], [112.46210269795739, 18.640305878152517], [112.4613580522722, 18.641311030523177], [112.46061221155861, 18.642314634851143], [112.45986517579244, 18.643316691169233], [112.4591169449556, 18.644317199501444], [112.45836751906435, 18.645316159825928], [112.4576168981178, 18.64631357214409], [112.4568650821016, 18.647309436474917], [112.45611207101204, 18.648303752823328], [112.45535786484984, 18.649296521188347], [112.45460246360489, 18.65028774158331], [112.45384586727138, 18.651277414015674], [112.45308807587452, 18.652265538452614], [112.45232908937572, 18.653252114944628], [112.45156890778244, 18.654237143481865], [112.45080753109114, 18.655220624068914], [112.45004495929015, 18.65620255672086], [112.44928119238686, 18.657182941428], [112.44851623036917, 18.658161778206164], [112.44775007323568, 18.65913906705683], [112.44698272099765, 18.660114807965837], [112.44621417362916, 18.66108900096623], [112.44544443113197, 18.66206164605562], [112.4446734934999, 18.66303274324184], [112.44390136074263, 18.66400229251277], [112.44312803284814, 18.6649702938835], [112.44235350979969, 18.665936747374964], [112.44157779160783, 18.666901652973902], [112.4408008782629, 18.667865010692402], [112.4400227697598, 18.668826820536733], [112.43924346610626, 18.66978708249741], [112.43846296728825, 18.670745796591753], [112.43768127329278, 18.671702962835678], [112.4368983841355, 18.672658581209966], [112.43611429979205, 18.67361265174442], [112.43532902026993, 18.67456517442979], [112.43454254557106, 18.67551614926384], [112.43375487567211, 18.676465576274794], [112.43296601059296, 18.67741345543857], [112.43217595030943, 18.678359786784405], [112.43138469483982, 18.679304570290277], [112.43059224416874, 18.680247805974954], [112.42979859826045, 18.681189493880463], [112.429003757143, 18.682129633973595], [112.42820772082526, 18.683068226243837], [112.42741048927998, 18.684005270723627], [112.42661206250469, 18.68494076741557], [112.42581244050088, 18.68587471631808], [112.42501162325536, 18.686807117446513], [112.42420961079364, 18.687737970771206], [112.4234064030582, 18.688667276358895], [112.42260200008417, 18.689595034168747], [112.42179640186555, 18.69052124420778], [112.42098960838956, 18.691445906490813], [112.4201816196489, 18.692369021026074], [112.4193724356405, 18.693290587817117], [112.41856205638413, 18.694210606841374], [112.41775048184546, 18.69512907813807], [112.41693771202426, 18.696046001707344], [112.41612374692308, 18.69696137754624], [112.41530858653721, 18.697875205660036], [112.41449223086033, 18.698787486055934], [112.41367467989163, 18.699698218734707], [112.4128559336286, 18.700607403699284], [112.41203599204577, 18.7015150
							 | 
						||
| 
								 | 
							
								            ]
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3ZjQ5ZGUzNC1jNWYwLTQ1ZTMtYmNjYS05YTY4ZTVmN2I2MDkiLCJpZCI6MTE3MTM4LCJpYXQiOjE2NzY0NDUyODB9.ZaNSBIfc1sGLhQd_xqhiSsc0yr8oS0wt1hAo9gbke6M'
							 | 
						||
| 
								 | 
							
								        const viewer = new Cesium.Viewer('map', {});
							 | 
						||
| 
								 | 
							
								        // 开启帧率
							 | 
						||
| 
								 | 
							
								        viewer.scene.debugShowFramesPerSecond = true;
							 | 
						||
| 
								 | 
							
								        var roaming = new Roaming(viewer, { time: 30 });
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								        function cameraRoaming() {
							 | 
						||
| 
								 | 
							
								            let arr = obj.features[0].geometry.coordinates;
							 | 
						||
| 
								 | 
							
								            let a111 = []
							 | 
						||
| 
								 | 
							
								            arr.forEach((k) => {
							 | 
						||
| 
								 | 
							
								                a111.push(Cesium.Cartesian3.fromDegrees(k[0], k[1], 1000))
							 | 
						||
| 
								 | 
							
								            })
							 | 
						||
| 
								 | 
							
								            roaming.modelRoaming({
							 | 
						||
| 
								 | 
							
								                model: {
							 | 
						||
| 
								 | 
							
								                    uri: './feiji.glb',
							 | 
						||
| 
								 | 
							
								                    scale: 30,
							 | 
						||
| 
								 | 
							
								                    silhouetteSize: 5, //边框大小
							 | 
						||
| 
								 | 
							
								                    silhouetteColor: Cesium.Color.fromCssColorString("#001aff"), //边框
							 | 
						||
| 
								 | 
							
								                },
							 | 
						||
| 
								 | 
							
								                Lines: a111,
							 | 
						||
| 
								 | 
							
								                path: {
							 | 
						||
| 
								 | 
							
								                    show: true,
							 | 
						||
| 
								 | 
							
								                },
							 | 
						||
| 
								 | 
							
								                polyline: {
							 | 
						||
| 
								 | 
							
								                    show: true,
							 | 
						||
| 
								 | 
							
								                    material: Cesium.Color.RED
							 | 
						||
| 
								 | 
							
								                }
							 | 
						||
| 
								 | 
							
								            })
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        function PauseOrContinue(params) {
							 | 
						||
| 
								 | 
							
								            roaming.PauseOrContinue(params)
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								        function EndRoaming() {
							 | 
						||
| 
								 | 
							
								            roaming.EndRoaming()
							 | 
						||
| 
								 | 
							
								        }
							 | 
						||
| 
								 | 
							
								    </script>
							 | 
						||
| 
								 | 
							
								</body>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								</html>
							 |