mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): mover sets report ready(); Navara scales by distance as Cesium
Task 10b foundation. - MoverSet.ready(): whether what the set draws has loaded (Navara: the model set's glTF, a URL atlas; Cesium: every instance's Model, the cropped atlas; parts without it draw at once). The aircraft renderer keeps the 2D glyph until a model set is ready, as the Cesium path waits on Model.ready. Contract suite: a drawn model set is ready() (both engines); unit test of the neutral store. - Navara sprites and points interpolate scaleByDistance as Cesium's NearFarScalar (over the squared camera distance, eased by ^0.2) instead of linearly in distance, so aircraft glyphs have Cesium's size at every range; the CPU pick radius follows (distanceScale, tested equal to focusDeemphasis' port of czm_nearFarScalar). The contract text says so.
This commit is contained in:
1 parent
d81ebf1268
commit
4dfcba8989
10 files changed
+103
-14
No files matched your search
@@ -129,6 +129,7 @@ export function createNavaraMovers(view, { overlay }) {
|
||||
}
|
||||
overlay.add(mover.mesh, () => updateMover(view, overlay.ctx, mover));
|
||||
return {
|
||||
ready: mover.ready,
|
||||
commit() {
|
||||
mover.commit(store.dirty());
|
||||
request();
|
||||
@@ -158,6 +159,7 @@ export function createNavaraMovers(view, { overlay }) {
|
||||
},
|
||||
});
|
||||
return {
|
||||
ready: mover.ready,
|
||||
commit() {
|
||||
mover.commit(store.dirty());
|
||||
request();
|
||||
|
||||
@@ -176,6 +176,7 @@ export function createModelMover(options, store, { load, onLoad = () => {} }) {
|
||||
return {
|
||||
group,
|
||||
uniforms,
|
||||
ready: () => loaded,
|
||||
origin: () => origin,
|
||||
commit(range) {
|
||||
if (!origin && store.count > 0)
|
||||
|
||||
@@ -50,12 +50,15 @@ vec4 mvCenter = modelViewMatrix * instanceMatrix * vec4(0.0, 0.0, 0.0, 1.0);
|
||||
float gevScale = gevStyle.y;
|
||||
float gevDistance = length(mvCenter.xyz);
|
||||
if (uGevHasScaleByDistance > 0.5) {
|
||||
// Cesium's czm_nearFarScalar: over the squared distance, eased by ^0.2.
|
||||
float gevNearSq = uGevScaleByDistance.x * uGevScaleByDistance.x;
|
||||
float gevFarSq = uGevScaleByDistance.z * uGevScaleByDistance.z;
|
||||
float t = clamp(
|
||||
(gevDistance - uGevScaleByDistance.x) /
|
||||
max(uGevScaleByDistance.z - uGevScaleByDistance.x, 1e-6),
|
||||
(gevDistance * gevDistance - gevNearSq) / max(gevFarSq - gevNearSq, 1e-6),
|
||||
0.0,
|
||||
1.0
|
||||
);
|
||||
t = pow(t, 0.2);
|
||||
gevScale *= mix(uGevScaleByDistance.y, uGevScaleByDistance.w, t);
|
||||
}
|
||||
float gevSizePx = uGevSizePx * gevScale;
|
||||
@@ -213,8 +216,15 @@ export function createMoverMesh(
|
||||
tGevSceneDepth: overlayUniforms.tGevSceneDepth,
|
||||
uGevResolution: overlayUniforms.uGevResolution,
|
||||
};
|
||||
// A canvas atlas is there at once; a URL one once its image loads.
|
||||
let textureReady = point || Boolean(options.sprite.atlas.canvas);
|
||||
const material = new MeshBasicMaterial({
|
||||
map: point ? null : atlasTexture(options.sprite.atlas, onTextureLoad),
|
||||
map: point
|
||||
? null
|
||||
: atlasTexture(options.sprite.atlas, () => {
|
||||
textureReady = true;
|
||||
onTextureLoad();
|
||||
}),
|
||||
transparent: true,
|
||||
alphaTest: 0.02,
|
||||
// Drawn after tone mapping, with no depth buffer: the shader tests the
|
||||
@@ -260,6 +270,7 @@ export function createMoverMesh(
|
||||
return {
|
||||
mesh,
|
||||
uniforms,
|
||||
ready: () => textureReady,
|
||||
origin: () => origin,
|
||||
/** Writes the changed instances; the origin starts at the first one. */
|
||||
commit(range) {
|
||||
|
||||
Reference in new issue
Block a user