cesium 笛卡尔坐标(单位:米) 与 经纬度(单位:弧度/度) 之间的转换。

this.model.readyPromise.then(function (tileset) {
                //记录模型原始的中心点
                var boundingSphere = tileset.boundingSphere;
                that.boundingSphere = boundingSphere;
                //模型原始的中心点。此处是笛卡尔坐标,单位:米。
                var position = boundingSphere.center; 
                // 此处是经纬度,单位:弧度;高度单位:米。
                var catographic = Cesium.Cartographic.fromCartesian(position);

                var height = Number(catographic.height.toFixed(2));
                // 此处是经纬度,单位:度。
                var longitude = Number(Cesium.Math.toDegrees(catographic.longitude).toFixed(6));
                var latitude = Number(Cesium.Math.toDegrees(catographic.latitude).toFixed(6));
                that.originalCenter = { x: longitude, y: latitude, z: height };
                console.log((that.config.name || "") + " 模型原始位置:" + JSON.stringify(that.originalCenter));


//offsetopt.x,y不能多次更改
        updateMatrix: function (offsetopt) {
            if (this.model == null) return;

            console.log(" 模型修改后位置:" + JSON.stringify(offsetopt));

            var boundingSphere = this.model.boundingSphere;
            var catographic = Cesium.Cartographic.fromCartesian(boundingSphere.center);
            var surface = Cesium.Cartesian3.fromRadians(catographic.longitude, catographic.latitude, 0.0);
            //  此处展示了,从经纬度(单位:度)-->笛卡尔坐标(单位:米)。
            var offset = Cesium.Cartesian3.fromDegrees(offsetopt.x, offsetopt.y, offsetopt.z);

            var translation = Cesium.Cartesian3.subtract(offset, surface, new Cesium.Cartesian3());
            this.model.modelMatrix = Cesium.Matrix4.fromTranslation(translation);
            //this.model.update();
        },
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值