我是Cesium的新手,我有3D模型,如下所示:
this.model = scene.primitives.add(Cesium.Model.fromGltf({
url : './assets/cesium/myPlane.glb',
modelMatrix : modelMatrix,
minimumPixelSize : 128,
maximumScale : 20000
}));
谢谢,
拉里
答案 0 :(得分:0)
您可以将模型加载为czml并设置方向。参见下文:
var position = Cesium.Cartesian3.fromDegrees(<lon>, <lat>, <alt>);
var pheading = Cesium.Math.toRadians(<heading>);
var pitch = Cesium.Math.toRadians(0);
var roll = Cesium.Math.toRadians(0);
var hpr = new Cesium.HeadingPitchRoll(pheading, pitch, roll);
var orientation = new Cesium.ConstantProperty(Cesium.Transforms.headingPitchRollQuaternion(position, hpr));
var czml = [
{
"id": "document",
"name": "CZML Model",
"version": "1.0"
}, {
"id": id,
"name": id,
"position": {
"cartographicDegrees": [
lon, lat, alt
]
},
"model": {
"gltf": <gltfpath>
}
}
];
var promise = olcesium.nc.viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));
promise.orientation = orientation;
promise.then(function (dataSource) {
for (var i = 0; i < dataSource.entities.values.length; i++) {
dataSource.entities.values[i].orientation = orientation;
}
});
答案 1 :(得分:0)