mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(bikeshare): render GBFS stations on Navara
This commit is contained in:
1 parent
1a694baf5a
commit
d82a6f1550
32 files changed
+1394
-278
No files matched your search
@@ -160,6 +160,7 @@ function pointPart(options, store, factories, requestRender, owners) {
|
||||
outlineWidth: point.outlinePx,
|
||||
outlineColor: new Cesium.Color(...point.outlineColor),
|
||||
scaleByDistance: nearFar(point.scaleByDistance),
|
||||
translucencyByDistance: nearFar(point.translucencyByDistance),
|
||||
disableDepthTestDistance: depthTestDistance(depthTest),
|
||||
};
|
||||
const points = [];
|
||||
|
||||
@@ -316,7 +316,7 @@
|
||||
* 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, outlineColor?: number[], scaleByDistance?: number[] }} [point]
|
||||
* @property {{ sizePx: number, outlinePx?: number, outlineColor?: number[], scaleByDistance?: number[], translucencyByDistance?: 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,
|
||||
|
||||
@@ -123,6 +123,7 @@ export function normalizeMoverSetOptions(options) {
|
||||
sizePx: positive(point.sizePx, 'point.sizePx'),
|
||||
outlinePx: nonNegative(point.outlinePx, 'point.outlinePx', 0),
|
||||
scaleByDistance: scaleByDistanceOf(point.scaleByDistance),
|
||||
translucencyByDistance: scaleByDistanceOf(point.translucencyByDistance),
|
||||
};
|
||||
} else {
|
||||
const model = options.model;
|
||||
|
||||
@@ -39,6 +39,7 @@ uniform float uGevSizePx;
|
||||
uniform float uGevFootprint;
|
||||
uniform vec4 uGevScaleByDistance;
|
||||
uniform float uGevHasScaleByDistance;
|
||||
uniform vec4 uGevTranslucencyByDistance;
|
||||
uniform float uGevDisableWithinM;
|
||||
uniform float uGevOutlinePx;
|
||||
uniform float uGevPixelRatio;
|
||||
@@ -46,6 +47,7 @@ varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
varying float vGevPixelDistance;
|
||||
varying float vGevTranslucency;
|
||||
${OVERLAY_DEPTH_VERTEX}
|
||||
`;
|
||||
|
||||
@@ -54,6 +56,13 @@ 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);
|
||||
float gevAlphaNearSq = uGevTranslucencyByDistance.x * uGevTranslucencyByDistance.x;
|
||||
float gevAlphaFarSq = uGevTranslucencyByDistance.z * uGevTranslucencyByDistance.z;
|
||||
float gevAlphaT = pow(clamp(
|
||||
(gevDistance * gevDistance - gevAlphaNearSq) / max(gevAlphaFarSq - gevAlphaNearSq, 1e-6),
|
||||
0.0, 1.0
|
||||
), 0.2);
|
||||
vGevTranslucency = mix(uGevTranslucencyByDistance.y, uGevTranslucencyByDistance.w, gevAlphaT);
|
||||
if (uGevHasScaleByDistance > 0.5) {
|
||||
// Cesium's czm_nearFarScalar: over the squared distance, eased by ^0.2.
|
||||
float gevNearSq = uGevScaleByDistance.x * uGevScaleByDistance.x;
|
||||
@@ -107,6 +116,7 @@ varying vec4 vGevColor;
|
||||
varying vec2 vGevLocal;
|
||||
varying float vGevOutline;
|
||||
varying float vGevPixelDistance;
|
||||
varying float vGevTranslucency;
|
||||
${OVERLAY_DEPTH_FRAGMENT}
|
||||
`;
|
||||
|
||||
@@ -126,7 +136,7 @@ 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;
|
||||
diffuseColor.a *= gevWholeAlpha * vGevTranslucency;
|
||||
if (diffuseColor.a < 0.005) discard;
|
||||
`
|
||||
: /* glsl */ `
|
||||
@@ -251,6 +261,9 @@ export function createMoverMesh(
|
||||
uGevFootprint: { value: 0 },
|
||||
uGevScaleByDistance: { value: sbd ? [...sbd] : [0, 1, 1, 1] },
|
||||
uGevHasScaleByDistance: { value: sbd ? 1 : 0 },
|
||||
uGevTranslucencyByDistance: {
|
||||
value: style.translucencyByDistance ?? [0, 1, 1, 1],
|
||||
},
|
||||
uGevDisableWithinM: {
|
||||
value: typeof depthTest === 'object' ? depthTest.disableWithinM : -1,
|
||||
},
|
||||
|
||||
@@ -29,6 +29,38 @@ const basicShader = () => ({
|
||||
fragmentShader: ShaderLib.basic.fragmentShader,
|
||||
});
|
||||
|
||||
test('point translucency applies to fill and outline and defaults to no fade', () => {
|
||||
const options = normalizeMoverSetOptions({
|
||||
id: 'stations',
|
||||
kind: 'point',
|
||||
capacity: 1,
|
||||
point: { sizePx: 8, translucencyByDistance: [200, 1, 180000, 0.15] },
|
||||
});
|
||||
const mover = createMoverMesh(options, createMoverStore(options));
|
||||
assert.deepEqual(
|
||||
mover.uniforms.uGevTranslucencyByDistance.value,
|
||||
[200, 1, 180000, 0.15],
|
||||
);
|
||||
const shader = patchMoverShader(basicShader(), mover.uniforms, {
|
||||
point: true,
|
||||
});
|
||||
assert.match(shader.fragmentShader, /gevWholeAlpha \* vGevTranslucency/);
|
||||
assert.match(
|
||||
shader.vertexShader,
|
||||
/gevDistance \* gevDistance - gevAlphaNearSq/,
|
||||
);
|
||||
mover.dispose();
|
||||
const ordinary = createMoverMesh(
|
||||
spriteOptions,
|
||||
createMoverStore(spriteOptions),
|
||||
);
|
||||
assert.deepEqual(
|
||||
ordinary.uniforms.uGevTranslucencyByDistance.value,
|
||||
[0, 1, 1, 1],
|
||||
);
|
||||
ordinary.dispose();
|
||||
});
|
||||
|
||||
test('the shader patch sizes the quad in pixels and colours it per instance', () => {
|
||||
const shader = patchMoverShader(basicShader(), { uGevSizePx: { value: 9 } });
|
||||
assert.equal(shader.uniforms.uGevSizePx.value, 9);
|
||||
|
||||
Reference in new issue
Block a user