I’ve written code to generate a Custom Sensor Pattern and a polyline volume pattern, using czml-writer. the polyline looks great, but the Custom Sensor Pattern is not showing on either CesiumJs or with the ION SDK. Is there something I’m missing?
CustomSphericalSensor.czml (1.8 KB)
/// <summary>
/// Generates a complete CZML string containing a Custom Sensor Pattern.
/// </summary>
public static string GenerateCustomSensorPattern(
string id,
string name,
Cartesian position,
List<Spherical> directions,
double radius,
int r, int g, int b, int a = 255)
{
using (StringWriter stringWriter = new StringWriter())
{
CesiumOutputStream output = new CesiumOutputStream(stringWriter);
CesiumStreamWriter writer = new CesiumStreamWriter();
output.WriteStartSequence();
// 1. Write the initial document packet
WriteDocumentPacket(writer, output);
// 2. Write the Custom Sensor packet
using (var packet = writer.OpenPacket(output))
{
packet.WriteId(id);
packet.WriteName(name);
// Set the origin position
using (var posWriter = packet.OpenPositionProperty())
{
posWriter.WriteCartesian(position);
}
// Define the custom pattern sensor
using (var sensor = packet.OpenCustomPatternSensorProperty())
{
using (var interval = sensor.OpenInterval())
{
// Ensure the sensor is visible
interval.WriteShowProperty(true);
// Set the radius (length of the sensor beam)
interval.WriteRadiusProperty(radius);
// Open and write the directions (the pattern/shape of the beam)
using (var dirWriter = interval.OpenDirectionsProperty())
{
dirWriter.WriteSpherical(directions);
}
// Set the lateral surface material (color of the sensor volume)
using (var material = interval.OpenLateralSurfaceMaterialProperty())
{
using (var solidColor = material.OpenSolidColorProperty())
{
using (var colorWriter = solidColor.OpenColorProperty())
{
colorWriter.WriteRgba(r, g, b, a);
}
}
}
}
}
}
output.WriteEndSequence();
return stringWriter.ToString();
}
}

