Draw imported files through the draw port, off Cesium

Import no longer loads KML, KMZ, GeoJSON and GPX through Cesium's data
source loaders. geoImportFeatures.js reads the sanitized file into plain
pins, lines, walls, polygons and ground overlays with the looks those
loaders gave them: icon, scale, colour, heading and hot spot, the shared
and inline style precedence, line and polygon colours and widths,
extruded and clamped geometry, rotated boxes and quads, and GeoJSON's
48 px pins, draped lines along rhumb lines and quarter-opacity fills.
geoImportPins.js draws them in three draw sets per file, places ground
pins through the height service (0 on the bare ellipsoid, whose coarse
tiles sag below it; the mesh nearby on photoreal maps), follows a
double-clicked pin, frames Fly-to, and shows, hides and removes them.

The Cesium adapter now draws two members the contract already had: an
icon's pixel offset and the wall shape. Image fills draw in the
translucent pass, so an overlay's own alpha blends as it did.

The Cesium allow-list is now empty; the ratchet test checks that its
scan still sees each way of reaching Cesium. The QA scripts read what a
file drew through the import's drawn(id), and the large-file check
compares it with Cesium's own reading of the same KML. A file the
renderer refuses to draw is refused by itself, without stopping its
batch. Two translations no longer used are dropped.
This commit is contained in:
Sameh Khamis committed 2026-11-09 15:50:53 -08:00
1 parent c073064507
commit 6c1f91014c
33 files changed
+2608 -1177

No files matched your search

+47 -11
View File
@@ -224,6 +224,23 @@ const DEPTH_BIASED_STATE = Object.freeze({
blending: Cesium.BlendingState.ALPHA_BLEND,
});
/**
* An image fill's material. The image carries its own alpha, so it draws in
* the translucent pass whatever its colour, as the entities' image
* materials did.
*/
function imageMaterial(image, repeat = [1, 1]) {
// Typed first and given its uniforms after, as `Material.fromType` does:
// the image loads when first drawn, not here.
const material = new Cesium.Material({
fabric: { type: 'Image' },
translucent: true,
});
material.uniforms.image = image;
material.uniforms.repeat = new Cesium.Cartesian2(...repeat);
return material;
}
/** A `radialRim` fill's material. */
function radialRimMaterial(fill) {
const uniforms = {
@@ -1024,6 +1041,11 @@ export function createCesiumDraw({
// The defaults, so a restyle in place puts back what an item dropped.
rotation: 0,
alignedAxis: Cesium.Cartesian3.ZERO,
// CSS pixels, y down, as the billboard takes them.
pixelOffset: new Cesium.Cartesian2(
item.pixelOffset?.x ?? 0,
item.pixelOffset?.y ?? 0,
),
};
if (item.rotationMode === 'screen') look.rotation = item.rotation ?? 0;
if (item.rotationMode === 'course') {
@@ -1066,6 +1088,9 @@ export function createCesiumDraw({
rotationMode: item.rotationMode,
rotation: item.rotation,
course: item.course,
pixelOffset: item.pixelOffset
? [item.pixelOffset.x ?? 0, item.pixelOffset.y ?? 0]
: undefined,
};
}
@@ -1112,7 +1137,11 @@ export function createCesiumDraw({
sameCurve(style.fadeByDistance, item.fadeByDistance) &&
style.rotationMode === item.rotationMode &&
(item.rotationMode === 'screen' || style.rotation === item.rotation) &&
style.course === item.course
style.course === item.course &&
(item.pixelOffset
? style.pixelOffset?.[0] === (item.pixelOffset.x ?? 0) &&
style.pixelOffset[1] === (item.pixelOffset.y ?? 0)
: style.pixelOffset === undefined)
);
}
@@ -3255,6 +3284,21 @@ export function createCesiumDraw({
),
};
}
case 'wall': {
// Up from `minimumHeights` (the ellipsoid) to `maximumHeights` (the
// positions' own), as the entities' walls draw.
const wall = {
positions: g.positions.map(toCartesian),
minimumHeights: g.minimumHeights,
maximumHeights: g.maximumHeights,
};
return {
fill: new Cesium.WallGeometry({ ...wall, vertexFormat }),
outline: item.outline
? new Cesium.WallOutlineGeometry(wall)
: undefined,
};
}
default:
throw new Error(`the Cesium renderer has no ${g.kind} shapes`);
}
@@ -3523,12 +3567,7 @@ export function createCesiumDraw({
: UnpickableGroundPrimitive;
const grounds = batches.map((batch) => {
const material = batch.imageFill
? Cesium.Material.fromType('Image', {
image: batch.image,
repeat: new Cesium.Cartesian2(
...(batch.imageFill.repeat ?? [1, 1]),
),
})
? imageMaterial(batch.image, batch.imageFill.repeat)
: batch.rimFill
? radialRimMaterial(batch.rimFill)
: null;
@@ -4147,10 +4186,7 @@ export function createCesiumDraw({
);
} else if (imageFill && !item.outlineOnly) {
const material = ownMaterial(
Cesium.Material.fromType('Image', {
image: toImage(imageFill.image),
repeat: new Cesium.Cartesian2(...(imageFill.repeat ?? [1, 1])),
}),
imageMaterial(toImage(imageFill.image), imageFill.repeat),
);
host.add(
new Cesium.Primitive({