From 1936a142b1ae308772a134a823466bad3f50fd15 Mon Sep 17 00:00:00 2001 From: zh <972939975@qq.com> Date: Tue, 19 Aug 2025 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3scale=E5=A4=AA=E5=B0=8F?= =?UTF-8?q?=E6=97=B6flyto=E9=AB=98=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Obj/Base/GroundSvg/index.js | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Obj/Base/GroundSvg/index.js b/src/Obj/Base/GroundSvg/index.js index 5a1e306..3f1200c 100644 --- a/src/Obj/Base/GroundSvg/index.js +++ b/src/Obj/Base/GroundSvg/index.js @@ -10,6 +10,7 @@ import { FontLoader } from '../../../../static/3rdparty/three/jsm/loaders/FontLo import { TextGeometry } from '../../../../static/3rdparty/three/jsm/geometries/TextGeometry.js'; import * as variable from '../../../../static/3rdparty/three/fonts/FZZongYi-M05S_regular.typeface.json' import Base from "../index"; +import { setActiveViewer, closeRotateAround, closeViewFollow } from '../../../Global/global' import { setSplitDirection, syncSplitData, setActiveId } from '../../../Global/SplitScreen' class GroundSvg extends Base { @@ -2171,6 +2172,59 @@ class GroundSvg extends Base { } this._update() } + + async flyTo(options = {}) { + if (this._error) { + return + } + setActiveViewer(0) + closeRotateAround(this.sdk) + closeViewFollow(this.sdk) + + if (this.options.customView && this.options.customView.relativePosition && this.options.customView.orientation) { + let orientation = { + heading: Cesium.Math.toRadians(this.options.customView.orientation.heading || 0.0), + pitch: Cesium.Math.toRadians(this.options.customView.orientation.pitch || -60.0), + roll: Cesium.Math.toRadians(this.options.customView.orientation.roll || 0.0) + } + + let lng = this.options.customView.relativePosition.lng + let lat = this.options.customView.relativePosition.lat + let alt = this.options.customView.relativePosition.alt + let destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) + + let position = { ...this.options.position } + // 如果没有高度值,则获取紧贴高度计算 + if (!position.hasOwnProperty('alt')) { + position.alt = await this.getClampToHeight(position) + } + lng = this.options.customView.relativePosition.lng + position.lng + lat = this.options.customView.relativePosition.lat + position.lat + alt = this.options.customView.relativePosition.alt + position.alt + destination = Cesium.Cartesian3.fromDegrees(lng, lat, alt) + this.sdk.viewer.camera.flyTo({ + destination: destination, + orientation: orientation + }) + } + else { + let array = [] + for (let i = 0; i < this.controlPoints.length; i++) { + let height = await this.getClampToHeight({lng: this.controlPoints[i][0], lat: this.controlPoints[i][1]}) + let cartesian = Cesium.Cartesian3.fromDegrees(this.controlPoints[i][0], this.controlPoints[i][1], height) + array.push(cartesian.x, cartesian.y, cartesian.z) + } + let BoundingSphere = Cesium.BoundingSphere.fromVertices(array) + + this.sdk.viewer.camera.flyToBoundingSphere(BoundingSphere, { + offset: options.orientation || { + heading: Cesium.Math.toRadians(0.0), + pitch: Cesium.Math.toRadians(-60.0), + roll: Cesium.Math.toRadians(0.0) + } + }) + } + } } export default GroundSvg \ No newline at end of file