奇怪的是,ModelGraphics调用uri
参数,但 CzmlDataSource 加载器通过gltf
CZML 文件中的名称查找此属性。不确定这是否是故意的。无论如何,如果您使用正确的名称,您可以让模型显示在 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');