refactor(launches): Cesium rendering behind a renderer interface

This commit is contained in:
German Khokhlov committed 2026-10-23 00:32:10 +04:00
1 parent 1839d62160
commit 4baefeb8f9
31 files changed
+1202 -420

No files matched your search

+7
View File
@@ -44,6 +44,13 @@ export class Rgba {
);
}
/** Cesium's CSS form, including its float-to-byte conversion. */
toCssColorString() {
const byte = (v) => (v === 1 ? 255 : (v * 256) | 0);
const rgb = `${byte(this.red)},${byte(this.green)},${byte(this.blue)}`;
return this.alpha === 1 ? `rgb(${rgb})` : `rgba(${rgb},${this.alpha})`;
}
/** `[red, green, blue, alpha]`, 0..1. */
rgba() {
return [this.red, this.green, this.blue, this.alpha];
+13
View File
@@ -75,3 +75,16 @@ test('Cesium billboards and models take an Rgba as their colour', () => {
assert.notEqual(billboard.color, CYAN, 'the billboard keeps its own copy');
collection.destroy();
});
test('CSS serialization keeps native byte rounding and alpha formatting', async () => {
const { constantRgba } = await import('./color.js');
for (const values of [
[0.1, 0.5, 1, 1],
[1, 0, 0.3, 0.42],
[0, 0, 0, 0],
])
assert.equal(
constantRgba(...values).toCssColorString(),
new Cesium.Color(...values).toCssColorString(),
);
});