mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +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
@@ -30,7 +30,13 @@ export function aircraftQaDrawn(state) {
|
||||
}
|
||||
: null,
|
||||
model: model
|
||||
? { scale: model.scale, show: model.show, ready: model.ready }
|
||||
? {
|
||||
scale: model.scale,
|
||||
// The drawn scale, after the minimum pixel size.
|
||||
computedScale: model.computedScale,
|
||||
show: model.show,
|
||||
ready: model.ready,
|
||||
}
|
||||
: null,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,15 +27,15 @@ import { registerViewerEngine } from '../../../globe/cesium/engineFromViewer.js'
|
||||
const BASE_SIZE_PX = 20;
|
||||
|
||||
/**
|
||||
* The model frame → glTF scene axes on Navara. Cesium draws a glTF through
|
||||
* Y_UP_TO_Z_UP × Z_UP_TO_X_UP (data/modelVisualAnchor.js); Navara's glTF
|
||||
* loader already turns the scene Y-up to Z-up, so here it is Z_UP_TO_X_UP
|
||||
* alone: nose, top and heading of airplane.glb where Cesium draws them
|
||||
* (checked side by side with Cesium on a tracked aircraft at 300 m against
|
||||
* five other axis candidates).
|
||||
* The model frame → glTF scene axes on Navara: Cesium's own glTF axis
|
||||
* correction, Y_UP_TO_Z_UP × Z_UP_TO_X_UP (data/modelVisualAnchor.js).
|
||||
* Navara's glTF loader is three's GLTFLoader, which keeps the scene Y-up.
|
||||
* (10b used Z_UP_TO_X_UP alone, on the belief that the loader turned the
|
||||
* scene Z-up: every fleet model drew 90° off its heading — side by side
|
||||
* with Cesium at the near pose, 10b review item 3.)
|
||||
*/
|
||||
// Cesium's Axis.Z_UP_TO_X_UP, column-major.
|
||||
const NAVARA_GLTF_AXIS = [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1];
|
||||
// Cesium's Axis.Y_UP_TO_Z_UP × Axis.Z_UP_TO_X_UP, column-major.
|
||||
const NAVARA_GLTF_AXIS = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1];
|
||||
const FIRST_CAPACITY = 1024;
|
||||
const ATLAS_PAD = 2;
|
||||
const TRAIL_ALPHA = 0.85;
|
||||
@@ -644,6 +644,8 @@ export function createAircraftNavaraRenderer({
|
||||
return bank;
|
||||
};
|
||||
|
||||
const scratchOffset = geo.cartesian3.create();
|
||||
|
||||
class ModelHandle {
|
||||
constructor(spec) {
|
||||
this.spec = spec;
|
||||
@@ -669,9 +671,13 @@ export function createAircraftNavaraRenderer({
|
||||
const minimum = this.spec.minimumPixelSize ?? 0;
|
||||
if (!(minimum > 0)) return this._scale;
|
||||
const cam = freshCamera();
|
||||
const distance = geo.cartesian3.distance(
|
||||
cam.positionWC,
|
||||
this.translation,
|
||||
// Cesium's distance (Camera distanceToBoundingSphere): the depth
|
||||
// along the view less the radius at the model's own scale.
|
||||
geo.cartesian3.subtract(this.translation, cam.positionWC, scratchOffset);
|
||||
const distance = Math.max(
|
||||
0,
|
||||
Math.abs(geo.cartesian3.dot(scratchOffset, cam.directionWC)) -
|
||||
this.radiusM * this._scale,
|
||||
);
|
||||
const height = engine.host.size().height;
|
||||
if (!(distance > 0) || !(height > 0)) return this._scale;
|
||||
|
||||
@@ -227,11 +227,15 @@ test("a model pose is the Cesium model frame, turned to Navara's glTF axes", asy
|
||||
);
|
||||
for (let index = 0; index < 16; index++)
|
||||
assert.ok(Math.abs(model.modelMatrix[index] - expected[index]) < 1e-6);
|
||||
// The instance orientation: modelMatrix × Cesium's Z_UP_TO_X_UP (Navara's
|
||||
// loader already turned the glTF Z-up).
|
||||
// The instance orientation: modelMatrix × Cesium's glTF axis correction
|
||||
// (Y_UP_TO_Z_UP × Z_UP_TO_X_UP; Navara's loader keeps the glTF Y-up).
|
||||
const corrected = Cesium.Matrix4.multiplyTransformation(
|
||||
expected,
|
||||
Cesium.Axis.Z_UP_TO_X_UP,
|
||||
Cesium.Matrix4.multiplyTransformation(
|
||||
Cesium.Axis.Y_UP_TO_Z_UP,
|
||||
Cesium.Axis.Z_UP_TO_X_UP,
|
||||
new Cesium.Matrix4(),
|
||||
),
|
||||
new Cesium.Matrix4(),
|
||||
);
|
||||
const q = Cesium.Quaternion.fromRotationMatrix(
|
||||
|
||||
Reference in new issue
Block a user