mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Make SetSpec.drawOrder exact and draw it in Cesium and the stub
Among sets that skip the depth test, a higher drawOrder draws over a lower one whatever order they were made in, and picks name them topmost first. Cesium draws the earlier of two opaque near-plane icons on top and picks it, so the draw port stacks the sets' hosts with a higher order earlier, ties in the order the sets were made. Hosts trade places only among the slots draw-set hosts already hold, so no other primitive moves; nothing moves while every set is at 0. Translucent items blend order-independently in Cesium and are not ordered by it. The stub sorts its hits the same way. A conformance check draws two icon sets at one spot and swaps their orders.
This commit is contained in:
1 parent
45302e9fbf
commit
8fe8b8e14d
6 files changed
+219
-3
No files matched your search
@@ -313,6 +313,7 @@ export function createStubRenderer(options = {}) {
|
||||
const sets = new Map();
|
||||
const atlases = new Map();
|
||||
|
||||
let setSeq = 0;
|
||||
function makeSet(kind, spec) {
|
||||
if (!spec?.id) throw new TypeError('A draw set needs an id');
|
||||
if (sets.has(spec.id))
|
||||
@@ -320,6 +321,8 @@ export function createStubRenderer(options = {}) {
|
||||
const record = {
|
||||
kind,
|
||||
spec: { ...spec },
|
||||
// When it was made: of sets of one `drawOrder`, the earlier is on top.
|
||||
seq: (setSeq += 1),
|
||||
items: new Map(),
|
||||
show: spec.show ?? true,
|
||||
readyListeners: [],
|
||||
@@ -443,6 +446,8 @@ export function createStubRenderer(options = {}) {
|
||||
const record = {
|
||||
kind,
|
||||
spec: { ...spec },
|
||||
// When it was made: of sets of one `drawOrder`, the earlier is on top.
|
||||
seq: (setSeq += 1),
|
||||
items: new Map(),
|
||||
show: true,
|
||||
readyListeners: [],
|
||||
@@ -779,17 +784,32 @@ export function createStubRenderer(options = {}) {
|
||||
...(item.lodGroup !== undefined ? { lodGroup: item.lodGroup } : {}),
|
||||
surface: false,
|
||||
position: p,
|
||||
depth: magnitude(sub(p, eye().position)),
|
||||
depth: distance,
|
||||
blocked: blockedItem(item),
|
||||
// Drawn over depth here: stacked by its set's draw order.
|
||||
over: (item.disableDepthTest ?? 0) > distance,
|
||||
order: set.spec.drawOrder ?? 0,
|
||||
seq: set.seq,
|
||||
});
|
||||
}
|
||||
}
|
||||
hits.sort((a, b) => a.depth - b.depth);
|
||||
// What skips the depth test is on top, the highest draw order first and
|
||||
// of one order the set made first (as the default renderer stacks
|
||||
// opaque ones); the rest nearest first.
|
||||
hits.sort(
|
||||
(a, b) =>
|
||||
(b.over === true) - (a.over === true) ||
|
||||
(a.over ? b.order - a.order || a.seq - b.seq : 0) ||
|
||||
a.depth - b.depth,
|
||||
);
|
||||
const looked = depth === undefined ? hits : hits.slice(0, depth);
|
||||
const out = looked.filter((hit) => !hit.blocked);
|
||||
for (const hit of out) {
|
||||
delete hit.depth;
|
||||
delete hit.blocked;
|
||||
delete hit.over;
|
||||
delete hit.order;
|
||||
delete hit.seq;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user