cesium 模型偏移-定位节点2


//offsetopt.x,y不能多次更改
updateMatrix: function (offsetopt) {
    /*此函数用于计算,同一个模型的偏移前后位置的偏移量。
    * 并转换成Matrix4,保存到模型的modelMatrix属性下。
    * 其中,offsetopt类似这样:"offset": {
                    "x": 117.75327858104695,
                    "y": 39.12059826155268,
                    "z": -11
                },
    */
    if (this.model == null) return;

    console.log(" 模型修改后位置:" + JSON.stringify(offsetopt));
    /*模型修改后位置:{"x":117.75327858104696,"y":39.12059826155268,"z":-11,"heading":0}*/
    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(transla
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值