Drape a 'tiles' ground set only on 3D tiles on Navara

Navara's ground pass took a pixel for a tile whenever its depth lay in
front of the saved globe depth, without checking which buffer the visible
depth came from; the scene buffer can be cleared apart from the globe
depth, so a set draped on 'tiles' also drew on bare terrain, which Cesium
never does. The pass now matches the visible depth to the globe or the
tiles before it drapes. A contract check compares a 'tiles' set hidden,
shown and hidden again over terrain, with a mutant.
This commit is contained in:
German Khokhlov committed 2026-11-10 19:12:25 +04:00
1 parent facc9541ab
commit b3daed4a9b
5 files changed
+207 -42

No files matched your search

+36 -1
View File
@@ -2,7 +2,10 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import { createFakeEngine } from '../src/globe/testing/fakeEngine.js';
import { fakeContractOptions } from '../src/globe/testing/contractFixtures.js';
import { runContractSuite } from '../src/globe/testing/contractSuite/index.mjs';
import {
createContractSuite,
runContractSuite,
} from '../src/globe/testing/contractSuite/index.mjs';
const replace = (object, member, wrap) => {
object[member] = wrap(object[member].bind(object));
@@ -396,3 +399,35 @@ for (const [name, killedBy, mutate] of mutants) {
}
});
}
test('tiles-only ground pixels on terrain are detected without a tileset fixture or a picking defect', async () => {
for (const drawsOnTerrain of [false, true]) {
const engine = createFakeEngine();
try {
const check = createContractSuite(engine, {
...fakeContractOptions(engine),
fixtures: null,
mapSources: null,
readRegion(x, y, width, height) {
const shown = engine.ground
.list()
.some((set) => set.id === 'contract-tiles-drape' && set.shown);
const color =
drawsOnTerrain && shown
? [255, 0, 255, 255]
: [50, 100, 150, 255];
return Uint8Array.from(
{ length: width * height * 4 },
(_, i) => color[i % 4],
);
},
}).find(({ name }) => name.startsWith('ground.createSet: tiles drape'));
assert.ok(check, 'tiles drape check runs without a tileset fixture');
if (drawsOnTerrain)
await assert.rejects(check.run(), /tiles drape changed terrain pixels/);
else await check.run();
} finally {
engine.destroy();
}
}
});