mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
feat(globe): dynamic lines on both engines
engine.lines.createLine({ id, widthPx, color, depthFailAlpha, dash
({ lengthPx, gapPx } | 'tactical'), arc ('none'|'geodesic'), modelMatrix,
pickId }) → a Line: setPositions (Cartesian3[] or a flat Float64Array),
setColor, setModelMatrix, show, destroy; lines.list() for QA. Options,
flat positions, geodesic densification (great circles of the geodetic
normals, height interpolated, one step per degree) and the registry are
engine-neutral (src/globe/lines.js); the fake engine keeps every line.
- Cesium: a Primitive of a PolylineGeometry (synchronous, rebuilt when
the positions change) with a PolylineMaterialAppearance in an
engine-owned collection; depthFailAlpha is depthFailAppearance with the
alpha scaled; pixel dashes are PolylineDash (16-bit pattern); the
tactical dash is the launches' selected-orbit shader under its own type
(launches keep theirs until Task 15a moves them onto engine.lines).
- Navara: a public MeshDesc (transparent pass, unlit) holding a ribbon
of one quad per segment, widened to CSS pixels in the vertex shader;
a second copy drawn with GreaterDepth and the alpha scaled is the
depth-fail part; dashes are cut in the fragment shader (pixels along
the screen direction, or the tactical pattern over the fraction along
the line); positions relative to the first point, the model matrix on
the group. Geodesic arcs are densified on the CPU. Not pickable yet.
- The contract suite draws a three-point line on both engines: magenta
along both segments, nothing off it, 1° east once turned by its model
matrix, gone when hidden; a line 30 km under the ground shows only its
depth-fail copy, dimmer than the line.
Main chunk 2,867,499 bytes (+7,197, +0.25 %: the Cesium lines).
This commit is contained in:
1 parent
0109097440
commit
86aa0bc9ba
16 files changed
+1380
-2
No files matched your search
@@ -26,6 +26,7 @@ import {
|
||||
mergeSharpen,
|
||||
} from '../contract.js';
|
||||
import { createAppClock } from '../../time/clock.js';
|
||||
import { createLineRegistry } from '../lines.js';
|
||||
import { createMoverRegistry } from '../movers.js';
|
||||
|
||||
const { cartesian2, cartesian3, cartographic, ellipsoid, math, matrix4 } = geo;
|
||||
@@ -261,6 +262,42 @@ export function createFakeEngine(options = {}) {
|
||||
let wallMs = options.nowMs ?? FAKE_EPOCH_MS;
|
||||
const appClock = options.appClock ?? createAppClock({ now: () => wallMs });
|
||||
const ownsWall = !options.appClock;
|
||||
// Lines keep what they were given; each change counts as a render request.
|
||||
const fakeLines = new Map();
|
||||
const lineRegistry = createLineRegistry((options) => {
|
||||
const state = {
|
||||
options,
|
||||
positions: new Float64Array(0),
|
||||
color: [...options.color],
|
||||
modelMatrix: options.modelMatrix,
|
||||
shown: true,
|
||||
};
|
||||
fakeLines.set(options.id, state);
|
||||
const changed = () => {
|
||||
fake.renderRequests++;
|
||||
};
|
||||
return {
|
||||
setPositions(flat) {
|
||||
state.positions = flat;
|
||||
changed();
|
||||
},
|
||||
setColor(rgba) {
|
||||
state.color = rgba;
|
||||
changed();
|
||||
},
|
||||
setModelMatrix(matrix) {
|
||||
state.modelMatrix = matrix;
|
||||
changed();
|
||||
},
|
||||
show(visible) {
|
||||
state.shown = visible;
|
||||
changed();
|
||||
},
|
||||
destroy() {
|
||||
fakeLines.delete(options.id);
|
||||
},
|
||||
};
|
||||
});
|
||||
// Movers keep their store for tests; commit counts as a render request.
|
||||
const moverRegistry = createMoverRegistry(() => {
|
||||
const part = {
|
||||
@@ -807,6 +844,7 @@ export function createFakeEngine(options = {}) {
|
||||
horizonVisible,
|
||||
},
|
||||
movers: moverRegistry.movers,
|
||||
lines: lineRegistry.lines,
|
||||
clock: {
|
||||
now: () => appClock.now(),
|
||||
frameTime: () => appClock.frameTime(),
|
||||
@@ -922,6 +960,7 @@ export function createFakeEngine(options = {}) {
|
||||
record('destroy', []);
|
||||
cancelCurrentFlight();
|
||||
moverRegistry.destroyAll();
|
||||
lineRegistry.destroyAll();
|
||||
fake.destroyed = true;
|
||||
},
|
||||
isDestroyed: () => fake.destroyed,
|
||||
@@ -982,6 +1021,8 @@ export function createFakeEngine(options = {}) {
|
||||
scripts.delete(name);
|
||||
},
|
||||
lookAtTarget: () => (lookAtTarget ? copy3(lookAtTarget) : undefined),
|
||||
/** A live line's options, positions, colour, matrix and visibility, by id. */
|
||||
line: (id) => fakeLines.get(id),
|
||||
/** A live mover set's options, store and commit count, by id. */
|
||||
moverSet(id) {
|
||||
const entry = moverRegistry.sets.get(id);
|
||||
|
||||
Reference in new issue
Block a user