mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(satellites): render on Navara
Render satellite fleets and selected targets through mover banks and orbit lines. Enable the celestial HUD on Navara and keep native follow explicitly in ENU. Add deterministic interaction, share, orbit, motion and cleanup acceptance QA. Record complete targeted acceptance and remaining shared cross-shell tile failures.
This commit is contained in:
1 parent
000ef99464
commit
6bdb995fe3
25 files changed
+727
-53
No files matched your search
@@ -158,7 +158,7 @@ function pointPart(options, store, factories, requestRender, owners) {
|
||||
const { point, depthTest } = options;
|
||||
const style = {
|
||||
outlineWidth: point.outlinePx,
|
||||
outlineColor: Cesium.Color.BLACK,
|
||||
outlineColor: new Cesium.Color(...point.outlineColor),
|
||||
scaleByDistance: nearFar(point.scaleByDistance),
|
||||
disableDepthTestDistance: depthTestDistance(depthTest),
|
||||
};
|
||||
|
||||
@@ -285,9 +285,6 @@
|
||||
* - launches: the replay timeline (replay.js, Date.now/performance.now),
|
||||
* the mission orbit's GMST frame (orbitRendering.js new Date()), launch
|
||||
* pad and panel throttles (phase 3 Task 15a);
|
||||
* - satellites: the point cloud's SGP4 propagation and orbit bake
|
||||
* (rendering.js new Date()/Date.now) (Task 14a); only the tracked
|
||||
* satellite reads the app clock;
|
||||
* - wall-clock throttles and feed receipt stamps everywhere (they measure
|
||||
* real elapsed time, not scene time).
|
||||
* @property {() => number} now The current app time.
|
||||
@@ -321,8 +318,9 @@
|
||||
* each sprite is a square of sizePx CSS px times its scale, times the
|
||||
* NearFarScalar [nearM, nearScale, farM, farScale] when given (Cesium's
|
||||
* interpolation: over the squared camera distance, eased by ^0.2).
|
||||
* @property {{ sizePx: number, outlinePx?: number, scaleByDistance?: number[] }} [point]
|
||||
* A filled disc of sizePx CSS px diameter with a dark outline.
|
||||
* @property {{ sizePx: number, outlinePx?: number, outlineColor?: number[], scaleByDistance?: number[] }} [point]
|
||||
* A filled disc of sizePx CSS px diameter plus outlinePx on each side;
|
||||
* outlineColor is rgba in 0..1 (opaque black by default).
|
||||
* @property {{ url: string, minimumPixelSize?: number, maximumScale?: number,
|
||||
* colorBlend?: { mode: 'mix'|'replace', amount: number }, unlit?: boolean }} [model]
|
||||
* A glTF drawn per instance in metres, at least minimumPixelSize px.
|
||||
|
||||
@@ -77,9 +77,13 @@ function moverRadius(options, scale, distance, modelRadiusPx = null) {
|
||||
? options.point
|
||||
: null;
|
||||
const size = style
|
||||
? style.sizePx * distanceScale(style.scaleByDistance, distance)
|
||||
? (style.sizePx * scale +
|
||||
(options.kind === 'point' ? 2 * style.outlinePx : 0)) *
|
||||
distanceScale(style.scaleByDistance, distance)
|
||||
: Math.max(options.model.minimumPixelSize, 24);
|
||||
return Math.max((size * scale) / 2, PICK_RADIUS_PX) + PICK_RADIUS_PX;
|
||||
return (
|
||||
Math.max((style ? size : size * scale) / 2, PICK_RADIUS_PX) + PICK_RADIUS_PX
|
||||
);
|
||||
}
|
||||
|
||||
function transformed(matrix, flat, index, result) {
|
||||
|
||||
@@ -104,7 +104,17 @@ export function normalizeMoverSetOptions(options) {
|
||||
} else if (kind === 'point') {
|
||||
const point = options.point;
|
||||
if (!isObject(point)) fail('a point set needs point options');
|
||||
const outlineColor = point.outlineColor ?? [0, 0, 0, 1];
|
||||
if (
|
||||
!Array.isArray(outlineColor) ||
|
||||
outlineColor.length !== 4 ||
|
||||
!outlineColor.every(
|
||||
(value) => isFiniteNumber(value) && value >= 0 && value <= 1,
|
||||
)
|
||||
)
|
||||
fail('point.outlineColor must be [r, g, b, a] in 0..1');
|
||||
normalized.point = {
|
||||
outlineColor: Object.freeze([...outlineColor]),
|
||||
sizePx: positive(point.sizePx, 'point.sizePx'),
|
||||
outlinePx: nonNegative(point.outlinePx, 'point.outlinePx', 0),
|
||||
scaleByDistance: scaleByDistanceOf(point.scaleByDistance),
|
||||
|
||||
@@ -236,3 +236,31 @@ test('a set is ready() once what it draws has loaded, never once destroyed', ()
|
||||
'an engine part without ready() draws at once',
|
||||
);
|
||||
});
|
||||
|
||||
test('point outline RGBA is validated and copied independently of the caller', () => {
|
||||
const color = [1, 0.5, 0, 0.3];
|
||||
const options = normalizeMoverSetOptions({
|
||||
id: 'outlined',
|
||||
kind: 'point',
|
||||
capacity: 1,
|
||||
point: { sizePx: 14, outlinePx: 2, outlineColor: color },
|
||||
});
|
||||
color[0] = 0;
|
||||
assert.deepEqual(options.point.outlineColor, [1, 0.5, 0, 0.3]);
|
||||
assert.ok(Object.isFrozen(options.point.outlineColor));
|
||||
for (const outlineColor of [
|
||||
[1, 0, 0],
|
||||
[1, 0, 0, 2],
|
||||
[NaN, 0, 0, 1],
|
||||
])
|
||||
assert.throws(
|
||||
() =>
|
||||
normalizeMoverSetOptions({
|
||||
id: 'bad',
|
||||
kind: 'point',
|
||||
capacity: 1,
|
||||
point: { sizePx: 14, outlineColor },
|
||||
}),
|
||||
TypeError,
|
||||
);
|
||||
});
|
||||
@@ -76,10 +76,12 @@ const frameCamera = {
|
||||
cameraHeight: 0,
|
||||
fovDeg: 60,
|
||||
viewportHeightPx: 0,
|
||||
pixelRatio: 1,
|
||||
};
|
||||
function updateMover(view, ctx, mover) {
|
||||
const raw = view.camera.raw;
|
||||
const height = ctx?.getRenderer().domElement.clientHeight;
|
||||
const renderer = ctx?.getRenderer();
|
||||
const height = renderer?.domElement.clientHeight;
|
||||
if (!raw || !(height > 0)) return;
|
||||
raw.updateMatrixWorld();
|
||||
const e = raw.matrixWorld.elements;
|
||||
@@ -97,6 +99,7 @@ function updateMover(view, ctx, mover) {
|
||||
Math.hypot(position.x, position.y, position.z) - EARTH_RADIUS_M;
|
||||
frameCamera.fovDeg = raw.fov;
|
||||
frameCamera.viewportHeightPx = height;
|
||||
frameCamera.pixelRatio = renderer.getPixelRatio?.() ?? 1;
|
||||
mover.update(frameCamera);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,18 @@ uniform vec4 uGevScaleByDistance;
|
||||
uniform float uGevHasScaleByDistance;
|
||||
uniform float uGevDisableWithinM;
|
||||
uniform float uGevOutlinePx;
|
||||
uniform float uGevPixelRatio;
|
||||
varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
varying float vGevPixelDistance;
|
||||
${OVERLAY_DEPTH_VERTEX}
|
||||
`;
|
||||
|
||||
const VERTEX_PROJECT = /* glsl */ `
|
||||
vec4 mvCenter = modelViewMatrix * instanceMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
||||
float gevScale = gevStyle.y;
|
||||
float gevDistanceScale = 1.0;
|
||||
float gevDistance = length(mvCenter.xyz);
|
||||
if (uGevHasScaleByDistance > 0.5) {
|
||||
// Cesium's czm_nearFarScalar: over the squared distance, eased by ^0.2.
|
||||
@@ -60,9 +63,21 @@ if (uGevHasScaleByDistance > 0.5) {
|
||||
1.0
|
||||
);
|
||||
t = pow(t, 0.2);
|
||||
gevScale *= mix(uGevScaleByDistance.y, uGevScaleByDistance.w, t);
|
||||
gevDistanceScale = mix(uGevScaleByDistance.y, uGevScaleByDistance.w, t);
|
||||
gevScale *= gevDistanceScale;
|
||||
}
|
||||
float gevSizePx = uGevSizePx * gevScale;
|
||||
vGevOutline = 0.0;
|
||||
vGevPixelDistance = 0.0;
|
||||
#ifdef GEV_POINT
|
||||
float gevBorderPx = 2.0 * uGevOutlinePx * gevDistanceScale;
|
||||
float gevOutlinedSize = gevSizePx + gevBorderPx;
|
||||
vGevOutline = gevBorderPx / max(gevOutlinedSize, 1e-3);
|
||||
// Cesium reserves three physical pixels for the point's smooth edge.
|
||||
gevSizePx = gevOutlinedSize + 3.0 / uGevPixelRatio;
|
||||
vGevPixelDistance = 2.0 / max(gevSizePx * uGevPixelRatio, 1e-3);
|
||||
if (gevStyle.y <= 0.0) gevSizePx = 0.0;
|
||||
#endif
|
||||
float gevCos = cos(gevStyle.x);
|
||||
float gevSin = sin(gevStyle.x);
|
||||
vec2 gevCorner = position.xy;
|
||||
@@ -75,7 +90,6 @@ mvPosition.xy += gevTurned * gevSizePx * uGevFootprint * max(-mvCenter.z, 0.0);
|
||||
gl_Position = projectionMatrix * mvPosition;
|
||||
vGevColor = gevColor;
|
||||
vGevLocal = gevCorner;
|
||||
vGevOutline = uGevOutlinePx / max(gevSizePx, 1e-3);
|
||||
vGevDepthFree = gevDistance < uGevDisableWithinM ? 1.0 : 0.0;
|
||||
`;
|
||||
|
||||
@@ -87,9 +101,11 @@ vMapUv = mix(gevUv.xy, gevUv.zw, uv);
|
||||
`;
|
||||
|
||||
const FRAGMENT_HEAD = /* glsl */ `
|
||||
uniform vec4 uGevOutlineColor;
|
||||
varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
varying float vGevPixelDistance;
|
||||
${OVERLAY_DEPTH_FRAGMENT}
|
||||
`;
|
||||
|
||||
@@ -103,8 +119,14 @@ const fragmentColor = (point) =>
|
||||
if (gevOverlayHidden()) discard;
|
||||
float gevRadius = length(vGevLocal) * 2.0;
|
||||
if (gevRadius > 1.0) discard;
|
||||
diffuseColor *= sRGBTransferEOTF(vGevColor);
|
||||
if (gevRadius > 1.0 - vGevOutline) diffuseColor.rgb = vec3(0.0);
|
||||
float gevMaxDistance = max(0.0, 0.5 - vGevPixelDistance);
|
||||
float gevDistanceToCenter = gevRadius * 0.5;
|
||||
float gevWholeAlpha = 1.0 - smoothstep(gevMaxDistance, 0.5, gevDistanceToCenter);
|
||||
float gevInner = 1.0 - vGevOutline;
|
||||
float gevInnerAlpha = 1.0 - smoothstep(gevMaxDistance * gevInner, 0.5 * gevInner, gevDistanceToCenter);
|
||||
diffuseColor *= sRGBTransferEOTF(mix(uGevOutlineColor, vGevColor, gevInnerAlpha));
|
||||
diffuseColor.a *= gevWholeAlpha;
|
||||
if (diffuseColor.a < 0.005) discard;
|
||||
`
|
||||
: /* glsl */ `
|
||||
#include <color_fragment>
|
||||
@@ -129,7 +151,7 @@ export function patchMoverShader(shader, uniforms, { point = false } = {}) {
|
||||
let vertex = replace(
|
||||
shader.vertexShader,
|
||||
'void main() {',
|
||||
`${VERTEX_HEAD}\nvoid main() {`,
|
||||
`${point ? '#define GEV_POINT\n' : ''}${VERTEX_HEAD}\nvoid main() {`,
|
||||
);
|
||||
vertex = replace(vertex, '#include <project_vertex>', VERTEX_PROJECT);
|
||||
vertex = replace(vertex, '#include <uv_vertex>', VERTEX_UV);
|
||||
@@ -212,6 +234,10 @@ export function createMoverMesh(
|
||||
value: typeof depthTest === 'object' ? depthTest.disableWithinM : -1,
|
||||
},
|
||||
uGevOutlinePx: { value: point ? options.point.outlinePx : 0 },
|
||||
uGevOutlineColor: {
|
||||
value: point ? [...options.point.outlineColor] : [0, 0, 0, 1],
|
||||
},
|
||||
uGevPixelRatio: { value: 1 },
|
||||
uGevDepthMode: {
|
||||
value:
|
||||
depthTest === 'always'
|
||||
@@ -232,7 +258,7 @@ export function createMoverMesh(
|
||||
onTextureLoad();
|
||||
}),
|
||||
transparent: true,
|
||||
alphaTest: 0.02,
|
||||
alphaTest: point ? 0.005 : 0.02,
|
||||
// Drawn after tone mapping, with no depth buffer: the shader tests the
|
||||
// scene depth itself (overlayDepth.js).
|
||||
depthTest: false,
|
||||
@@ -299,7 +325,14 @@ export function createMoverMesh(
|
||||
* origin moved to the camera when it has gone too far (a full rewrite).
|
||||
* Returns true when it rewrote the instances.
|
||||
*/
|
||||
update({ cameraPosition, cameraHeight, fovDeg, viewportHeightPx }) {
|
||||
update({
|
||||
cameraPosition,
|
||||
cameraHeight,
|
||||
fovDeg,
|
||||
viewportHeightPx,
|
||||
pixelRatio = 1,
|
||||
}) {
|
||||
uniforms.uGevPixelRatio.value = pixelRatio;
|
||||
uniforms.uGevFootprint.value = footprintPerDepth(
|
||||
fovDeg,
|
||||
viewportHeightPx,
|
||||
|
||||
Reference in new issue
Block a user