renderTargetCamera() {
        const { viewer } = this.state
        const _this = this

        viewer.camera.moveEnd.addEventListener(function () {

            const { gpsamera, cameraHeightInit } = _this.state
            let cameraHeight = cameraHeightInit
            let gpsPoint = gpsamera[0][0]
            if (!gpsamera) { return }
            // console.log('cameraHeight--', gpsPoint, cameraHeight)
            if (!cameraHeight) {
                // 倾斜之后,需调整相机高度
                cameraHeight = Math.round(viewer.camera.positionCartographic.height);
                // viewer.zoomTo(_labelEntity, new Cesium.HeadingPitchRange(0.0, Cesium.Math.toRadians(-25.0), cameraHeight));
                _this.setState({ cameraHeightInit: cameraHeight })
                setTimeout(function () {
                    let center = Cesium.Cartesian3.fromDegrees(gpsPoint.lng, gpsPoint.lat, 1000.0);
                    viewer.camera.lookAt(center, new Cesium.HeadingPitchRange(0.0, -Math.PI / 4, cameraHeight));
                }, 300)

            }

        });
    }
Posted on 2023-07-20 10:37  博客sl  阅读(303)  评论(0编辑  收藏  举报