mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Dash a line's parts behind the surface, and the Draw tool's rubber band there
A line item gains an optional depthFailDash ({ length, pattern16? }): the
parts behind the surface are dashed in depthFailColor, as a dash style
dashes a line. Without a depthFailColor, and on draped lines, it is
ignored; a renderer that predates it draws those parts solid. The Cesium
draw port gives the depth-fail appearance a PolylineDash material, and a
change of dash is a new look. The Draw tool's rubber band uses
{ length: 16 }, the dash its old entity asked for (that entity, a dynamic
polyline, never drew its depth-fail material, so the parts behind the
surface were hidden before the tool moved onto the draw port).
This commit is contained in:
1 parent
90e73f2ef2
commit
7ad65b2e87
10 files changed
+115
-2
No files matched your search
@@ -1281,7 +1281,14 @@ export function createCesiumDraw({
|
||||
depthFailAppearance: new Cesium.PolylineMaterialAppearance({
|
||||
material: lineMaterial(
|
||||
record,
|
||||
{ kind: 'solid', color: item.depthFailColor },
|
||||
item.depthFailDash
|
||||
? {
|
||||
kind: 'dash',
|
||||
color: item.depthFailColor,
|
||||
length: item.depthFailDash.length,
|
||||
pattern16: item.depthFailDash.pattern16,
|
||||
}
|
||||
: { kind: 'solid', color: item.depthFailColor },
|
||||
reveal,
|
||||
),
|
||||
}),
|
||||
@@ -1488,6 +1495,10 @@ export function createCesiumDraw({
|
||||
item.clampTo,
|
||||
item.style,
|
||||
item.depthFailColor,
|
||||
// A dash is drawn only with a depth-fail colour, the same in any key order.
|
||||
item.depthFailColor && item.depthFailDash
|
||||
? [item.depthFailDash.length, item.depthFailDash.pattern16]
|
||||
: null,
|
||||
// Segment colours and shows change in place.
|
||||
item.segmentColors != null,
|
||||
item.segmentShow != null,
|
||||
|
||||
@@ -2892,6 +2892,58 @@ test('a line with a depth-fail colour draws it behind the surface, and moves in
|
||||
assert.equal(scene.added.length, 0);
|
||||
}));
|
||||
|
||||
test('a depth-fail dash dashes the parts behind the surface, in the depth-fail colour', () =>
|
||||
withImageClasses(() => {
|
||||
const { scene, draw } = drawOver();
|
||||
const set = draw.lines({ id: 'band' });
|
||||
const band = (extra = {}) => ({
|
||||
id: 'band',
|
||||
positions: [
|
||||
Cesium.Cartesian3.fromDegrees(0, 0, 100),
|
||||
Cesium.Cartesian3.fromDegrees(0.01, 0.01, 100),
|
||||
],
|
||||
widthPx: 3,
|
||||
mode: 'geodesic',
|
||||
style: { kind: 'dash', color: [1, 1, 0, 0.9], length: 16 },
|
||||
depthFailColor: [0, 1, 1, 0.35],
|
||||
depthFailDash: { length: 16 },
|
||||
...extra,
|
||||
});
|
||||
set.set([band()]);
|
||||
const host = scene.added[0];
|
||||
const deep = host.get(1).get(0);
|
||||
const hidden = deep.depthFailAppearance.material;
|
||||
assert.equal(hidden.type, 'PolylineDash');
|
||||
assert.ok(
|
||||
Cesium.Color.equals(
|
||||
hidden.uniforms.color,
|
||||
new Cesium.Color(0, 1, 1, 0.35),
|
||||
),
|
||||
);
|
||||
assert.equal(hidden.uniforms.dashLength, 16);
|
||||
assert.equal(hidden.uniforms.dashPattern, 255, 'the default pattern');
|
||||
// A move keeps the dash; its fields in another order are the same look.
|
||||
set.upsert([band({ depthFailDash: { length: 16 } })]);
|
||||
assert.equal(scene.added[0], host, 'not rebuilt');
|
||||
assert.equal(
|
||||
host.get(1).get(0).depthFailAppearance.material.type,
|
||||
'PolylineDash',
|
||||
);
|
||||
set.upsert([band({ depthFailDash: { pattern16: 0xf0f0, length: 8 } })]);
|
||||
const patterned = scene.added[0].get(1).get(0).depthFailAppearance.material;
|
||||
assert.equal(patterned.uniforms.dashPattern, 0xf0f0);
|
||||
assert.equal(patterned.uniforms.dashLength, 8);
|
||||
const again = scene.added[0];
|
||||
set.upsert([band({ depthFailDash: { length: 8, pattern16: 0xf0f0 } })]);
|
||||
assert.equal(scene.added[0], again, 'the same dash in another order');
|
||||
// Without it the hidden parts are solid; the change is a new look.
|
||||
set.upsert([band({ depthFailDash: undefined })]);
|
||||
assert.notEqual(scene.added[0], host, 'rebuilt');
|
||||
const solid = scene.added[0].get(1).get(0).depthFailAppearance.material;
|
||||
assert.equal(solid.type, 'Color');
|
||||
set.dispose();
|
||||
}));
|
||||
|
||||
test('a draped flow line still drawing while its rebuilds build keeps flowing', () =>
|
||||
withImageClasses(() => {
|
||||
const { scene, draw, frame } = drawOver();
|
||||
|
||||
@@ -41,6 +41,7 @@ export const CESIUM_CHECKS = new Set([
|
||||
'draw.drillPick',
|
||||
'draw.icons.distance',
|
||||
'draw.icons.update',
|
||||
'draw.lines.depthFailDash',
|
||||
'draw.lines.styles',
|
||||
'draw.lines.drape',
|
||||
'draw.lines.segments',
|
||||
|
||||
@@ -1348,6 +1348,36 @@ export function portChecks() {
|
||||
set.dispose();
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.lines.depthFailDash',
|
||||
'a line dashed behind the surface draws, moves in place and changes back to solid',
|
||||
async (h, r) => {
|
||||
await overAustin(h, r);
|
||||
const lines = r.draw.lines({ id: 'conf:line-dash' });
|
||||
const at = (dLon, height) =>
|
||||
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat, height });
|
||||
const band = (height, extra = {}) => ({
|
||||
id: 'band',
|
||||
positions: [at(-0.002, 50), at(0.002, height)],
|
||||
widthPx: 3,
|
||||
mode: 'geodesic',
|
||||
style: { kind: 'dash', color: [1, 1, 0, 0.9], length: 16 },
|
||||
depthFailColor: [0, 1, 1, 0.35],
|
||||
depthFailDash: { length: 16 },
|
||||
...extra,
|
||||
});
|
||||
lines.set([band(-200)]);
|
||||
await drawn(h, r);
|
||||
equal(lines.size(), 1, 'held');
|
||||
lines.upsert([band(-100)]);
|
||||
await drawn(h, r);
|
||||
equal(lines.size(), 1, 'moved in place, not added');
|
||||
lines.upsert([band(-100, { depthFailDash: undefined })]);
|
||||
await drawn(h, r);
|
||||
equal(lines.size(), 1, 'solid behind the surface again');
|
||||
lines.dispose();
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.lines.styles',
|
||||
'flow lines draw draped and in space, and a line with a depth-fail colour moves every frame, without stopping the frame or picks',
|
||||
|
||||
@@ -178,6 +178,12 @@ test('members added to version 0 later are optional, each behind its capability'
|
||||
// A renderer written before an addition still conforms without it.
|
||||
assert.equal(PORTS.globe.isGlobeVisible, 'globeVisibility');
|
||||
assert.equal(PORTS.camera.followFrame, 'followFrame');
|
||||
// Item fields added later are optional too.
|
||||
const optional = (shape, field) =>
|
||||
Object.fromEntries(
|
||||
members(checker.getTypeAtLocation(declared(shape).name)),
|
||||
)[field];
|
||||
assert.equal(optional('LineItem', 'depthFailDash'), true);
|
||||
});
|
||||
|
||||
test('the shape check names what is missing and what a capability does not allow', () => {
|
||||
|
||||
Vendored
+7
@@ -229,6 +229,13 @@ export interface LineItem {
|
||||
style: LineStyle;
|
||||
/** Colour where the line is behind the surface; `null` hides those parts. */
|
||||
depthFailColor?: Color | null;
|
||||
/**
|
||||
* Dash the parts behind the surface, in `depthFailColor`, as a `dash`
|
||||
* style's `length` and `pattern16` dash a line. Omitted, they are solid; a
|
||||
* renderer that predates it draws them solid too. Ignored without a
|
||||
* `depthFailColor`, and on draped lines, which are never behind it.
|
||||
*/
|
||||
depthFailDash?: { length: number; pattern16?: number };
|
||||
/** Per-segment colours; changing them does not rebuild the line. */
|
||||
segmentColors?: Color[];
|
||||
segmentShow?: boolean[];
|
||||
|
||||
Reference in new issue
Block a user