我正在创建一个CZML文件,我有一条路径,我希望我的对象遵循该路径并逐个位置移动(我根据时间纪元定义了位置。)
它与带有图像的广告牌完美配合,但是当我更改我的代码以获得模型时,例如沙堡中的一个3D模型,而不是广告牌,它不起作用。它甚至没有显示模型。我只是有一个标签,在路径上移动,但没有模型的迹象。
有什么问题?我非常想在CZML文件中使用3D模型,而不是在javaScript中。如果有人可以帮助我,我会很高兴。
我将我的数据保存在.czml文件中,然后我将通过javaScript将它们加载到html中,如下所示:
viewer.dataSources.add(Cesium.CzmlDataSource.load('../../SampleData/fstsp_solution.czml'));
我的czml文件的副本是:
[
{
"id":"document",
"version":"1.0"
},
{
"id":"Vehicle",
"availability":"2012-08-04T16:00:00Z/2012-08-04T17:04:54.9962195740191Z",
"model":{
"show":true,
"gltf":"../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.bgltf",
"scale":2,
"minimumPixelSize":25
},
"oriantation":{
"interpolationAlgorithm":"LAGRANGE",
"interpolationDegree":1,
"epoch":"2012-08-04T16:00:00Z",
"unitQuaternion":[some numbers, I am working on it]
},
"position":{
"interpolationAlgorithm":"LAGRANGE",
"interpolationDegree":1,
"epoch":"2012-08-04T16:00:00Z",
"cartographicDegrees":[time,long,lat,height,time,long,lat,height,time,long,lat,height]
}
}
]
由于
答案 0 :(得分:1)
ModelGraphics调用uri
参数的情况很奇怪,但CzmlDataSource加载程序通过CZML文件中的名称gltf
查找此属性。不确定这是否是故意的。在任何情况下,如果使用正确的名称,您可以让模型显示在CZML文件中。我的下面示例缺少正确的模型方向,但显示模型已加载。
尝试加载Sandcastle并将以下内容粘贴到代码编辑器中,然后点击Run(F8)。
var viewer = new Cesium.Viewer('cesiumContainer');
var builtInCzml = [{
"id" : "document",
"version" : "1.0",
"clock" : {
"interval" : "2012-08-04T16:00:00Z/2012-08-04T16:02:00Z",
"currentTime" : "2012-08-04T16:00:00Z",
"multiplier" : 1,
"range" : "LOOP_STOP",
"step" : "SYSTEM_CLOCK_MULTIPLIER"
}
}, {
"id" : "Vehicle",
"availability" : "2012-08-04T16:00:00Z/2012-08-04T16:02:00Z",
"model" : {
"show" : true,
"gltf" : "../../SampleData/models/CesiumGround/Cesium_Ground.bgltf"
},
"billboard" : {
"eyeOffset" : {
"cartesian" : [0.0, 0.0, 0.0]
},
"horizontalOrigin" : "CENTER",
"image" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEISURBVEhLvVXBDYQwDOuojHKj8LhBbpTbpBCEkZsmIVTXq1RVQGrHiWlLmTTqPiZBlyLgy/KSZQ5JSHDQ/mCYCsC8106kDU0AdwRnvYZArWRcAl0dcYJq1hWCb3hBrumbDAVMwAC82WoRvgMnVMDBnB0nYZFTbE6BBvdUGqVqCbjBIk3PyFFR/NU7EKzru+qZsau3ryPwwCRLKYOzutZuCL6fUmWeJGzNzL/RxAMrUmASSCkkAayk2IxPlwhAAYGpsiHQjbLccfdOY5gKkCXAMi7SscAwbQpAnKyctWyUZ6z8ja3OGMepwD8asz+9FnSvbhU8uVOHFIwQsI3/p0CfhuqCSQuxLqsN6mu8SS+N42MAAAAASUVORK5CYII=",
"pixelOffset" : {
"cartesian2" : [0.0, 0.0]
},
"scale" : 0.8,
"show" : true,
"verticalOrigin" : "BOTTOM"
},
"label" : {
"fillColor" : {
"rgba" : [255, 255, 0, 255]
},
"font" : "bold 10pt Segoe UI Semibold",
"horizontalOrigin" : "LEFT",
"outlineColor" : {
"rgba" : [0, 0, 0, 255]
},
"pixelOffset" : {
"cartesian2" : [10.0, 0.0]
},
"scale" : 1.0,
"show" : true,
"style" : "FILL",
"text" : "Vehicle",
"verticalOrigin" : "CENTER"
},
"path" : {
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 255, 0, 255]
}
}
},
"width" : 5.0,
"show" : true
},
"position" : {
"interpolationAlgorithm" : "LAGRANGE",
"interpolationDegree" : 1,
"epoch" : "2012-08-04T16:00:00Z",
"cartesian" : [0.0, 1254962.0093268978, -4732330.528380746, 4074172.505865612,
120.0, 1256995.7322857284, -4732095.2154790815, 4073821.2249589274]
}
}];
var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.load(builtInCzml, 'Sample CZML with 3D model');
viewer.dataSources.add(czmlDataSource);
viewer.trackedEntity = czmlDataSource.entities.getById('Vehicle');
答案 1 :(得分:0)
我发现了问题,我没有给它在我的计算机上找到模型的正确位置,当我使用我的本地主机时,我实际上应该从我的localhost或Cesium地址给它完整的地址,所以我应该输入它
"gltf":"../../Apps/SampleData/models/CesiumMilkTruck/CesiumMilkTruck.bgltf",
而不是仅仅给它的地址
"../../SampleData/models/CesiumMilkTruck/CesiumMilkTruck.bgltf",
所以它现在有效,感谢所有帮助过的人!
答案 2 :(得分:-1)
仅供参考-如果您要使用uri路线,则必须添加https