【发布时间】:2021-04-27 02:33:03
【问题描述】:
我已经成功实施了有关如何构建飞行跟踪器的教程。我希望能够在我的应用程序的当前时间访问我的数据索引。换句话说,当铯显示飞机沿着飞行路径的动画时,我怎样才能得到飞机的当前索引? (我的数据的索引)。
我有两个实体,一个在循环下生成路径的所有点,另一个用于加载飞机模型。我需要将我的应用程序的其他部分与 Cesium 的当前状态同步。 (如果我暂停 Cesium,我需要暂停其他事情等)
我正在使用 Resium。顺便提一句。这是我的飞机模型。它根据派生自 const positionProperty = new SampledPositionProperty();的位置属性进行动画处理
// this is the loop that draws the path with points
{flightData.map((data, i) => {
const time = JulianDate.fromIso8601(data.timestamp);
const position = Cartesian3.fromDegrees(
data.longitude,
data.latitude,
data.height + 5.0
);
// here we add a sample, per object in the array
positionProperty.addSample(time, position);
return (
<Entity
key={`${i}${position}`}
position={position}
point={{ pixelSize: 5, color: PhaseColors[data.phase] }}
/>
);
})}
// this is the airplane model that follows the path above
<Entity
style={{ border: "10px solid green" }}
// Here is where we pass the positionProperty sample. How can I get the current index out of this?
position={positionProperty}
// Automatically compute the orientation from the position.
orientation={new VelocityOrientationProperty(positionProperty)}
tracked
selected
model={{ uri: model, minimumPixelSize: 100, maximumScale: 100.0 }}
path={
new PathGraphics({
width: 3,
material: Color.fromCssColorString("#202025"),
})
}
availability={
new TimeIntervalCollection([
new TimeInterval({ start: start, stop: stop }),
])
}
我认为的一种方法是使用时钟并获取时间戳。使用时间戳我可以查找我自己的数据。但我想避免这种情况,这非常昂贵。
那里有任何铯专家吗? :D
【问题讨论】:
标签: javascript reactjs cesium