Merge branch 'develop' of http://xny.yj-3d.com:3000/zh/sdk4.0
This commit is contained in:
@ -53,8 +53,7 @@ class TextBox extends Base {
|
||||
|
||||
// 配置CSS样式和内容结构
|
||||
viewer.cesiumWidget.container.appendChild(dom);
|
||||
let posi = Cesium.Cartesian3.fromDegrees(that.options.position.lng.toFixed(4), that.options.position.lat.toFixed(4), that.options.position.alt.toFixed(4))
|
||||
|
||||
let posi = Cesium.Cartesian3.fromDegrees(that.options.position.lng, that.options.position.lat, that.options.position.alt)
|
||||
that.handler = function () {
|
||||
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||
viewer.scene, posi
|
||||
@ -72,20 +71,31 @@ class TextBox extends Base {
|
||||
}
|
||||
async setHandeler(data) {
|
||||
let that = this
|
||||
const ray = this.sdk.viewer.camera.getPickRay(new Cesium.Cartesian2(data.x, data.y));
|
||||
var cartesian = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||
|
||||
let cartesian = this.sdk.viewer.scene.pickPosition(new Cesium.Cartesian2(data.x, data.y)); //屏幕坐标转为笛卡尔空间坐标
|
||||
// if (!cartesian) return;
|
||||
|
||||
// let c = Cesium.Cartographic.fromCartesian(position);
|
||||
if (!cartesian) {
|
||||
const ray = this.sdk.viewer.camera.getPickRay(new Cesium.Cartesian2(data.x, data.y));
|
||||
cartesian = this.sdk.viewer.scene.globe.pick(ray, this.sdk.viewer.scene);
|
||||
}
|
||||
|
||||
if (Cesium.defined(cartesian)) {
|
||||
that.sdk.viewer.scene.postRender.removeEventListener(that.handler);
|
||||
|
||||
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);
|
||||
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
|
||||
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
|
||||
|
||||
let height = await that.getClampToHeight({ lng: longitude, lat: latitude })
|
||||
that.position = {
|
||||
lng: longitude,
|
||||
lat: latitude,
|
||||
alt: cartographic.height
|
||||
// alt: height
|
||||
}
|
||||
let posi = Cesium.Cartesian3.fromDegrees(longitude.toFixed(4), latitude.toFixed(4), cartographic.height.toFixed(4))
|
||||
let posi = Cesium.Cartesian3.fromDegrees(longitude, latitude, cartographic.height)
|
||||
|
||||
that.handler = function () {
|
||||
const position = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
|
||||
|
Reference in New Issue
Block a user