官方封装的方法,
function createModel(url, height) { viewer.entities.removeAll(); var position = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, height); var heading = Cesium.Math.toRadians(135); var pitch = 0; var roll = 0; var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll); var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr); //orientation为模型的方向,由三个参数决定pitch为绕x轴旋转的角度,通常称为俯仰角 //roll为绕z轴旋转,通常称为翻滚角,heading为绕y轴旋转的角度,通常称为横滚角 //这三个参数决定了我们初始看到模型时的角度 //摄影测量里又称为航向倾角,旁向倾角,相片旋角 var entity = viewer.entities.add({ name : url, position : position, orientation : orientation, model : { uri : url, minimumPixelSize : 128, maximumScale : 20000 } }); viewer.trackedEntity = entity; }
其中url为模型的地址,height为离地面的高度