With the sensors plugin having recently been updated, I'd really like to take advantage of it but the repo only provides a single example (in the README) that isn't complete, and the examples provided use Primitives directly which, according to Matt Amato, we shouldn't really be using directly anymore. The examples also perform a scene.viewer.primitives.removeAll() which Matt also said was a big no-no.
I'm trying to get a rectangularSensor to work using entities but so far haven't had any luck. I'm not getting any errors, but it's not showing anything on the globe either.
Could we get a few more examples of using the plugin? For reference, here is the code that I've been attempting to make work and haven't had success with.
function getModelMatrix(lat,lon,alt,clock,ele,azi) {
var ellipsoid = viewer.scene.globe.ellipsoid;
var location = ellipsoid.cartographicToCartesian(new Cesium.Cartographic(lon, lat, alt));
var modelMatrix = Cesium.Transforms.northEastDownToFixedFrame(location);
var orientation = Cesium.Matrix3.multiply(
Cesium.Matrix3.multiply(Cesium.Matrix3.fromRotationZ(clock), Cesium.Matrix3.fromRotationY(ele), new Cesium.Matrix3()),
Cesium.Matrix3.fromRotationX(azi), new Cesium.Matrix3()
);
return Cesium.Matrix4.multiply(modelMatrix, Cesium.Matrix4.fromRotationTranslation(orientation, Cesium.Cartesian3.ZERO), new Cesium.Matrix4());
}
var entity = viewer.entities.getOrCreateEntity('sample-sensor');
entity.addProperty('rectangularSensor');
entity.rectangularSensor = new CesiumSensors.RectangularSensorGraphics();
entity.rectangularSensor.xHalfAngle = Cesium.Math.toRadians(30);
entity.rectangularSensor.yHalfAngle = Cesium.Math.toRadians(30);
entity.rectangularSensor.radius = 300000;
entity.rectangularSensor.modelMatrix = getModelMatrix(Cesium.Math.toRadians(obj.longitude), Cesium.Math.toRadians(obj.latitude), obj.altitude, 0, Cesium.Math.toRadians(90+obj.attributes.elevation), Cesium.Math.toRadians(obj.attributes.azimuth));
entity.rectangularSensor.lateralSurfaceMaterial = Cesium.Material.fromType('Color', {color: Cesium.Color.BLUE});
Any help with this would be greatly appreciated.