mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
fix(globe): Navara aircraft models face, size and light as Cesium's (10b review 3)
The near-pose finding (Navara models faint, Cesium ~23 bright aircraft) came from the side-by-side's frozen page clock: the fleet tick ran once per pose, so Cesium never handed its aircraft to their models and drew 3× glyphs, against real models on Navara. With the hand-off driven (the move ends every 10 frames while a pose loads), both engines draw models, and the comparison showed three real differences, all fixed: - Orientation: Navara's glTF loader is three's GLTFLoader, which keeps the scene Y-up; the instance turn is now Cesium's whole axis correction (Y_UP_TO_Z_UP × Z_UP_TO_X_UP), not Z_UP_TO_X_UP alone. Every fleet model drew 90° off its heading. - Size: minimumPixelSize is taken at Cesium's distance (Camera distanceToBoundingSphere: view depth less the radius at the model's own scale), in the mover and in ModelHandle.computedScale; the straight-line distance drew off-centre models up to 16 % larger. - Colour: the instance colour tints by the set's blend amount (Cesium's colorBlendAmount) and its alpha is the model's opacity (Cesium: a model colour's alpha makes it translucent), not a blend weight; a model is translucent only while faded. An ambient share of the tinted surface (MODEL_AMBIENT 0.5, Cesium's image-based lighting) keeps a tinted aircraft near-white at a low sun (median luminance 139 → 190; Cesium 197). qa-flights-engines (now --layer=flights|military) gates the near pose with --models=on: computed scale within ±5 % per model (ratio 1.000007), footprint against the same view with the layer off within ±20 % (1553 vs 1496 px, 104 %), median luminance within ±10 % (189.8 vs 196.7). The probe's drawn() reports a model's computedScale. Flights models on: 19/19.
This commit is contained in:
1 parent
9dc446bd24
commit
10d0e49ddb
6 files changed
+158
-23
No files matched your search
@@ -9,7 +9,7 @@ import {
|
||||
Vector3,
|
||||
} from 'three';
|
||||
import { createMoverStore, normalizeMoverSetOptions } from '../../movers.js';
|
||||
import { createModelMover } from './modelMover.js';
|
||||
import { createModelMover, modelPixelDistance } from './modelMover.js';
|
||||
|
||||
const options = normalizeMoverSetOptions({
|
||||
id: 'm',
|
||||
@@ -69,6 +69,7 @@ test('a far model keeps its minimum pixel size', async () => {
|
||||
await mover.group.ready;
|
||||
mover.update({
|
||||
cameraPosition: { x: 6_378_137 + 100_000, y: 0, z: 0 },
|
||||
cameraDirection: { x: -1, y: 0, z: 0 },
|
||||
cameraHeight: 100_000,
|
||||
fovDeg: 60,
|
||||
viewportHeightPx: 800,
|
||||
@@ -76,11 +77,57 @@ test('a far model keeps its minimum pixel size', async () => {
|
||||
const matrix = new Matrix4();
|
||||
mover.group.meshes[0].getMatrixAt(0, matrix);
|
||||
const scale = new Vector3().setFromMatrixScale(matrix).x;
|
||||
// Box radius √3; 40 px at 100 km with a 60° fov over 800 px.
|
||||
// Box radius √3; 40 px at 100 km (less the radius, as Cesium) with a 60°
|
||||
// fov over 800 px.
|
||||
const footprint = (2 * Math.tan(Math.PI / 6)) / 800;
|
||||
const expected = (40 * footprint * 100_000) / (2 * Math.sqrt(3));
|
||||
const expected =
|
||||
(40 * footprint * (100_000 - Math.sqrt(3))) / (2 * Math.sqrt(3));
|
||||
assert.ok(
|
||||
Math.abs(scale - expected) / expected < 1e-6,
|
||||
`${scale} vs ${expected}`,
|
||||
);
|
||||
});
|
||||
|
||||
test("the instance colour tints by the set's blend amount; its alpha is opacity, as Cesium's model colour", async () => {
|
||||
const store = createMoverStore(options);
|
||||
const mover = createModelMover(options, store, {
|
||||
load: async () => fakeGltf(),
|
||||
});
|
||||
store.set(0, {
|
||||
position: { x: 6_378_137, y: 0, z: 0 },
|
||||
color: [1, 1, 1, 0.4],
|
||||
});
|
||||
store.setCount(1);
|
||||
mover.commit(store.dirty());
|
||||
await mover.group.ready;
|
||||
const [mesh] = mover.group.meshes;
|
||||
const shader = {
|
||||
uniforms: {},
|
||||
vertexShader: 'void main() {\n#include <begin_vertex>\n}',
|
||||
fragmentShader:
|
||||
'void main() {\n#include <map_fragment>\n#include <emissivemap_fragment>\n}',
|
||||
};
|
||||
mesh.material.onBeforeCompile(shader);
|
||||
assert.match(
|
||||
shader.fragmentShader,
|
||||
/diffuseColor\.rgb = mix\(diffuseColor\.rgb, vGevColor\.rgb, uGevBlend\);\s*diffuseColor\.a \*= vGevColor\.a;/,
|
||||
);
|
||||
// Ambient light on the tinted surface (Cesium's image-based lighting).
|
||||
assert.match(
|
||||
shader.fragmentShader,
|
||||
/totalEmissiveRadiance \+= diffuseColor\.rgb \* uGevAmbient;/,
|
||||
);
|
||||
assert.equal(mover.uniforms.uGevAmbient.value, 0.5);
|
||||
assert.equal(mesh.material.transparent, true, 'a faded instance');
|
||||
store.set(0, { color: [1, 1, 1, 1] });
|
||||
mover.commit(store.dirty());
|
||||
assert.equal(mesh.material.transparent, false, 'all opaque again');
|
||||
});
|
||||
|
||||
test("the minimum pixel size is taken at Cesium's distance: view depth less the radius", () => {
|
||||
const ahead = { x: 0, y: 0, z: -1 };
|
||||
// 3 km ahead and 4 km aside: depth 3 km, not the 5 km straight line.
|
||||
assert.equal(modelPixelDistance(4000, 0, -3000, ahead, 30), 2970);
|
||||
assert.equal(modelPixelDistance(0, 0, -10, ahead, 30), 0);
|
||||
assert.equal(modelPixelDistance(4000, 0, -3000, null, 0), 5000);
|
||||
});
|
||||
Reference in new issue
Block a user