欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

cesium 分屏对比 多窗同步

程序员文章站 2022-06-09 19:06:01
不说废话, 代码// 视图同步this.leftViewer.eventManager.addCameraMoveListener(e => {if (this.isLeft() && this.synchronous) {const viewPoint = this.leftViewer.getViewPoint()this.rightViewer.baseViewer.camera.setView({destination: vi...

不说废话, 代码

		// 视图同步
		this.leftViewer.eventManager.addCameraMoveListener(e => {
			if (this.isLeft() && this.synchronous) {
				const viewPoint = this.leftViewer.getViewPoint()
				this.rightViewer.baseViewer.camera.setView({
					destination: viewPoint.position,
					orientation: viewPoint.orientation
				})
			}
		})

		this.rightViewer.eventManager.addCameraMoveListener(e => {
			if (!this.isLeft() && this.synchronous) {
				const viewPoint = this.rightViewer.getViewPoint()
				this.leftViewer.baseViewer.camera.setView({
					destination: viewPoint.position,
					orientation: viewPoint.orientation
				})
			}
		})

获取相机位置

	/**
	 * 获取相机位置及旋转角度
	 * @return {{orientation: {heading: number, roll: number, pitch: number}, position: Cesium.Cartesian3}}
	 */
	getViewPoint() {
		return {
			position: this.baseViewer.camera.position.clone(),
			orientation: {
				heading: this.baseViewer.camera.heading,
				pitch: this.baseViewer.camera.pitch,
				roll: this.baseViewer.camera.roll
			}
		}
	}

监听move, 看鼠标在哪边

		// 记忆是哪一边在操作
		this.leftViewer.eventManager.addEventListener(EventConstant.MOUSE_MOVE, e => {
			this.currentOperation = ManyWindowViewer.LEFT_VIEWER
		})

		this.rightViewer.eventManager.addEventListener(EventConstant.MOUSE_MOVE, e => {
			this.currentOperation = ManyWindowViewer.RIGHT_VIEWER
		})


	/**
	 * 是否操纵左边
	 * @return {boolean}
	 */
	isLeft() {
		return this.currentOperation === ManyWindowViewer.LEFT_VIEWER
	}

本文地址:https://blog.csdn.net/d351064378/article/details/114298976

相关标签: Cesium 超图 js