Hi Cesium Devs,
I’m trying to combine the Sandbox Interpolation example with a sensor volume from Cesium Sensors. I’d like to show the area covered by a camera when flying along an interpolated path, basically what is described in this demo.
I couldn’t find a way to animate sensor movement using SampledPositionProperty with VelocityOrientationProperty, so instead I update it in the onTick event.
viewer.clock.onTick.addEventListener(function(clock) {
// Lookup the interpolated position for the current time
var tickPosition = position.getValue(clock.currentTime);
if(tickPosition) {
// Get the orientation (for heading/pitch/roll) of the plane model
var entityOrientation = myEntity.orientation.getValue(clock.currentTime);
// Have tried several methods of updating the sensor's ModelMatrix...
// 1. Compute the ModelMatrix using tickPosition and 0.0 for rotations.
// This draws the sensor volume pointing down, but it doesn't change heading/pitch/roll (as expected)
// Since it points down, do I have a reference frame issue?
var orientation = Cesium.Matrix3.multiply(
Cesium.Matrix3.multiply(
Cesium.Matrix3.fromRotationZ(0.0), Cesium.Matrix3.fromRotationY(0.0), new Cesium.Matrix3()),
Cesium.Matrix3.fromRotationX(0.0), new Cesium.Matrix3()
);
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(tickPosition);
rectangularPyramidSensor.modelMatrix = Cesium.Matrix4.multiply(modelMatrix, Cesium.Matrix4.fromRotationTranslation(entityOrientation, Cesium.Cartesian3.ZERO), new Cesium.Matrix4());
// 2. Compute the ModelMatrix of the sensor using the orientation of the plane model
// Instead of using the 0 rotation orientation from #1, use the orientation of the plane.
// The sensor volume is no longer visible.
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(tickPosition);
rectangularPyramidSensor.modelMatrix = Cesium.Matrix4.multiply(modelMatrix, Cesium.Matrix4.fromRotationTranslation(entityOrientation, Cesium.Cartesian3.ZERO), new Cesium.Matrix4());
// 3. Compute the heading/pitch/roll of the plane model, then use those values
// to call Cesium.Transforms.headingPitchRollToFixedFrame(tickPosition, heading, pitch, roll);
// I had trouble getting HPR calculated. I can share that code if needed, but this method seemed wrong.
}
});
``
To summarize, I want to mimic the orientation of the plane model on the sensor to visualize the area covered by a camera on the quadcopter/plane (so they move in sync). Any help would be greatly appreciated!
Thanks,
Ryan