mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-06 11:24:00 +00:00
refactor(ui): engine-specific sharpen defaults instead of reading 49 as 80
The baseline and the style presets name ENGINE_SHARPEN_DEFAULT, which resolves to 49 % on Cesium and 80 % on Navara. Share links and explicit calls restore their value unchanged.
This commit is contained in:
1 parent
abf16ae8af
commit
a8a2ad5582
4 files changed
+73
-66
No files matched your search
@@ -182,6 +182,7 @@ test('on Navara, presets set the Sharpen slider to 80 % and the engine draws it'
|
|||||||
governorRequestRender() {},
|
governorRequestRender() {},
|
||||||
holdContinuousRender() {},
|
holdContinuousRender() {},
|
||||||
releaseContinuousRender() {},
|
releaseContinuousRender() {},
|
||||||
|
setKeyholeFadeTuning() {},
|
||||||
},
|
},
|
||||||
readHud: () => ({ getVariant: () => 'tactical', setMode() {} }),
|
readHud: () => ({ getVariant: () => 'tactical', setMode() {} }),
|
||||||
});
|
});
|
||||||
@@ -195,5 +196,9 @@ test('on Navara, presets set the Sharpen slider to 80 % and the engine draws it'
|
|||||||
{ enabled: true },
|
{ enabled: true },
|
||||||
{ amount: 1.7000000000000002 },
|
{ amount: 1.7000000000000002 },
|
||||||
]);
|
]);
|
||||||
|
// A share link carries an explicit value: 49 stays 49 on Navara.
|
||||||
|
await owner.restoreShareState({ sharpenIntensity: 49, sharpen: true });
|
||||||
|
assert.equal(elements._sharpenSlider.value, '49');
|
||||||
|
assert.deepEqual(sharpen.at(-1), { amount: 1.08 });
|
||||||
owner.destroy();
|
owner.destroy();
|
||||||
});
|
});
|
||||||
@@ -5,10 +5,10 @@ import {
|
|||||||
GLOBAL_POST_DEFAULTS,
|
GLOBAL_POST_DEFAULTS,
|
||||||
STYLE_PRESET_DEFAULTS,
|
STYLE_PRESET_DEFAULTS,
|
||||||
MILITARY_DETECTION_PRESET,
|
MILITARY_DETECTION_PRESET,
|
||||||
NAVARA_SHARPEN_INTENSITY_DEFAULT,
|
ENGINE_SHARPEN_DEFAULT,
|
||||||
SHARPEN_INTENSITY_DEFAULT,
|
SHARPEN_INTENSITY_DEFAULTS,
|
||||||
|
presetSharpenIntensity,
|
||||||
sharpenAmount,
|
sharpenAmount,
|
||||||
sharpenIntensityForEngine,
|
|
||||||
} from './visualPresets.js';
|
} from './visualPresets.js';
|
||||||
|
|
||||||
function fixture(engine = null) {
|
function fixture(engine = null) {
|
||||||
@@ -234,15 +234,26 @@ test('with a viewer the Cesium stage sharpens and the engine is left alone', ()
|
|||||||
f.effects.destroy();
|
f.effects.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Navara reads the Cesium sharpen default as 80 %, other values stay', () => {
|
test('presets and the baseline take the engine default sharpen: Cesium 49 %, Navara 80 %', () => {
|
||||||
assert.equal(SHARPEN_INTENSITY_DEFAULT, 49);
|
assert.deepEqual(SHARPEN_INTENSITY_DEFAULTS, { cesium: 49, navara: 80 });
|
||||||
assert.equal(NAVARA_SHARPEN_INTENSITY_DEFAULT, 80);
|
for (const preset of [
|
||||||
assert.equal(sharpenIntensityForEngine(49, 'navara'), 80);
|
GLOBAL_POST_DEFAULTS,
|
||||||
assert.equal(sharpenIntensityForEngine(49, 'cesium'), 49);
|
...Object.values(STYLE_PRESET_DEFAULTS),
|
||||||
assert.equal(sharpenIntensityForEngine(65, 'navara'), 65);
|
]) {
|
||||||
assert.equal(sharpenIntensityForEngine(0, 'navara'), 0);
|
assert.equal(preset.sharpen.intensity, ENGINE_SHARPEN_DEFAULT);
|
||||||
for (const preset of Object.values(STYLE_PRESET_DEFAULTS))
|
assert.equal(
|
||||||
assert.equal(preset.sharpen.intensity, SHARPEN_INTENSITY_DEFAULT);
|
presetSharpenIntensity(preset.sharpen.intensity, 'cesium'),
|
||||||
|
49,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
presetSharpenIntensity(preset.sharpen.intensity, 'navara'),
|
||||||
|
80,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert.equal(presetSharpenIntensity(ENGINE_SHARPEN_DEFAULT, undefined), 49);
|
||||||
|
// An explicit value is never remapped: 49 stays 49 on Navara.
|
||||||
|
assert.equal(presetSharpenIntensity(49, 'navara'), 49);
|
||||||
|
assert.equal(presetSharpenIntensity(65, 'cesium'), 65);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('stop revokes pending work immediately but retains stages until final destruction', () => {
|
test('stop revokes pending work immediately but retains stages until final destruction', () => {
|
||||||
@@ -292,7 +303,10 @@ test('destroying one instance does not remove another pipeline or clock', () =>
|
|||||||
test('existing baseline and military presets keep one detection default', () => {
|
test('existing baseline and military presets keep one detection default', () => {
|
||||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionMode, 'DENSE');
|
assert.equal(GLOBAL_POST_DEFAULTS.detectionMode, 'DENSE');
|
||||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionDensity, 75);
|
assert.equal(GLOBAL_POST_DEFAULTS.detectionDensity, 75);
|
||||||
assert.equal(GLOBAL_POST_DEFAULTS.sharpen.intensity, 49);
|
assert.equal(
|
||||||
|
presetSharpenIntensity(GLOBAL_POST_DEFAULTS.sharpen.intensity, 'cesium'),
|
||||||
|
49,
|
||||||
|
);
|
||||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionFadePct, 7);
|
assert.equal(GLOBAL_POST_DEFAULTS.detectionFadePct, 7);
|
||||||
assert.equal(GLOBAL_POST_DEFAULTS.detectionOutsideOpacityPct, 1);
|
assert.equal(GLOBAL_POST_DEFAULTS.detectionOutsideOpacityPct, 1);
|
||||||
for (const name of ['retro', 'surveillance', 'thermal']) {
|
for (const name of ['retro', 'surveillance', 'thermal']) {
|
||||||
|
|||||||
+25
-15
@@ -40,20 +40,30 @@ export const MILITARY_DETECTION_PRESET = Object.freeze({
|
|||||||
densityPct: 75,
|
densityPct: 75,
|
||||||
});
|
});
|
||||||
|
|
||||||
/** The Sharpen slider's default (%) on Cesium, in every preset. */
|
/** The Sharpen slider's default (%) on each globe engine. */
|
||||||
export const SHARPEN_INTENSITY_DEFAULT = 49;
|
export const SHARPEN_INTENSITY_DEFAULTS = Object.freeze({
|
||||||
/** The Sharpen slider's default (%) on the Navara engine. */
|
cesium: 49,
|
||||||
export const NAVARA_SHARPEN_INTENSITY_DEFAULT = 80;
|
navara: 80,
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sharpen intensity (%) a default, a preset or a share link sets on an
|
* A preset's sharpen intensity that means "the engine's default"
|
||||||
* engine: Navara reads Cesium's default (49, every preset's value) as its own
|
* (SHARPEN_INTENSITY_DEFAULTS): the baseline and every style preset use it,
|
||||||
* default (80); any other value, and everything on Cesium, stays as given.
|
* so Cesium opens and switches styles at 49 % and Navara at 80 %.
|
||||||
*/
|
*/
|
||||||
export function sharpenIntensityForEngine(pct, engineKind) {
|
export const ENGINE_SHARPEN_DEFAULT = 'engine-default';
|
||||||
return engineKind === 'navara' && pct === SHARPEN_INTENSITY_DEFAULT
|
|
||||||
? NAVARA_SHARPEN_INTENSITY_DEFAULT
|
/**
|
||||||
: pct;
|
* The intensity (%) a preset sets on an engine: its engine's default for
|
||||||
|
* ENGINE_SHARPEN_DEFAULT (Cesium's for an unknown engine), else the explicit
|
||||||
|
* value as given. Share links and scene shots carry explicit values and do
|
||||||
|
* not come through here.
|
||||||
|
*/
|
||||||
|
export function presetSharpenIntensity(intensity, engineKind) {
|
||||||
|
if (intensity !== ENGINE_SHARPEN_DEFAULT) return intensity;
|
||||||
|
return (
|
||||||
|
SHARPEN_INTENSITY_DEFAULTS[engineKind] ?? SHARPEN_INTENSITY_DEFAULTS.cesium
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The unsharp mask's `amount` for a slider value normalized to 0..1. */
|
/** The unsharp mask's `amount` for a slider value normalized to 0..1. */
|
||||||
@@ -62,7 +72,7 @@ export const sharpenAmount = (value) => 0.1 + value * 2.0;
|
|||||||
/** Baseline post-processing settings applied on first load (before share-link restore). */
|
/** Baseline post-processing settings applied on first load (before share-link restore). */
|
||||||
export const GLOBAL_POST_DEFAULTS = {
|
export const GLOBAL_POST_DEFAULTS = {
|
||||||
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
||||||
sharpen: { enabled: true, intensity: SHARPEN_INTENSITY_DEFAULT },
|
sharpen: { enabled: true, intensity: ENGINE_SHARPEN_DEFAULT },
|
||||||
hudVariant: 'tactical',
|
hudVariant: 'tactical',
|
||||||
hudVisible: true,
|
hudVisible: true,
|
||||||
// Detection is ON for EVERY style on a first run, Normal included (owner
|
// Detection is ON for EVERY style on a first run, Normal included (owner
|
||||||
@@ -88,7 +98,7 @@ export const GLOBAL_POST_DEFAULTS = {
|
|||||||
export const STYLE_PRESET_DEFAULTS = {
|
export const STYLE_PRESET_DEFAULTS = {
|
||||||
retro: {
|
retro: {
|
||||||
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
||||||
sharpen: { enabled: true, intensity: SHARPEN_INTENSITY_DEFAULT },
|
sharpen: { enabled: true, intensity: ENGINE_SHARPEN_DEFAULT },
|
||||||
styleParams: {
|
styleParams: {
|
||||||
retro: {
|
retro: {
|
||||||
pixelation: 1.0,
|
pixelation: 1.0,
|
||||||
@@ -102,7 +112,7 @@ export const STYLE_PRESET_DEFAULTS = {
|
|||||||
},
|
},
|
||||||
surveillance: {
|
surveillance: {
|
||||||
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
||||||
sharpen: { enabled: true, intensity: SHARPEN_INTENSITY_DEFAULT },
|
sharpen: { enabled: true, intensity: ENGINE_SHARPEN_DEFAULT },
|
||||||
styleParams: {
|
styleParams: {
|
||||||
surveillance: {
|
surveillance: {
|
||||||
gain: 0.18,
|
gain: 0.18,
|
||||||
@@ -117,7 +127,7 @@ export const STYLE_PRESET_DEFAULTS = {
|
|||||||
},
|
},
|
||||||
thermal: {
|
thermal: {
|
||||||
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
bloom: { enabled: false, intensity: BLOOM_INTENSITY_DEFAULT },
|
||||||
sharpen: { enabled: true, intensity: SHARPEN_INTENSITY_DEFAULT },
|
sharpen: { enabled: true, intensity: ENGINE_SHARPEN_DEFAULT },
|
||||||
styleParams: {
|
styleParams: {
|
||||||
thermal: {
|
thermal: {
|
||||||
sensitivity: 0.85,
|
sensitivity: 0.85,
|
||||||
|
|||||||
+16
-38
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
STYLE_STATUS_LABELS,
|
STYLE_STATUS_LABELS,
|
||||||
sharpenIntensityForEngine,
|
presetSharpenIntensity,
|
||||||
} from './visualPresets.js';
|
} from './visualPresets.js';
|
||||||
import { UiLifetime } from './uiLifetime.js';
|
import { UiLifetime } from './uiLifetime.js';
|
||||||
import {
|
import {
|
||||||
@@ -95,15 +95,7 @@ export class VisualSettings {
|
|||||||
this._setBloomIntensity(intensity, { syncShare: false });
|
this._setBloomIntensity(intensity, { syncShare: false });
|
||||||
}
|
}
|
||||||
if (typeof sharpenIntensity === 'number' && this._sharpenSlider) {
|
if (typeof sharpenIntensity === 'number' && this._sharpenSlider) {
|
||||||
const pct = Math.max(
|
const pct = Math.max(0, Math.min(100, Math.round(sharpenIntensity)));
|
||||||
0,
|
|
||||||
Math.min(
|
|
||||||
100,
|
|
||||||
Math.round(
|
|
||||||
sharpenIntensityForEngine(sharpenIntensity, this._engineKind),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
this._sharpenSlider.value = String(pct);
|
this._sharpenSlider.value = String(pct);
|
||||||
this._sharpenSliderValue.textContent = `${pct}%`;
|
this._sharpenSliderValue.textContent = `${pct}%`;
|
||||||
this._applySharpenIntensity(pct / 100);
|
this._applySharpenIntensity(pct / 100);
|
||||||
@@ -201,8 +193,8 @@ export class VisualSettings {
|
|||||||
readDisplayPortalActive,
|
readDisplayPortalActive,
|
||||||
});
|
});
|
||||||
this._lifetime = new UiLifetime();
|
this._lifetime = new UiLifetime();
|
||||||
// Defaults, presets and share links read Cesium's sharpen default as the
|
// The baseline and the style presets take this engine's default sharpen
|
||||||
// engine's own (sharpenIntensityForEngine).
|
// (presetSharpenIntensity); share links restore their explicit value.
|
||||||
this._engineKind = engine?.kind ?? 'cesium';
|
this._engineKind = engine?.kind ?? 'cesium';
|
||||||
this._visualEffects = new VisualEffects({
|
this._visualEffects = new VisualEffects({
|
||||||
viewer,
|
viewer,
|
||||||
@@ -759,16 +751,12 @@ export class VisualSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sharpenInput = preset.sharpen || {};
|
const sharpenInput = preset.sharpen || {};
|
||||||
if (typeof sharpenInput.intensity === 'number' && this._sharpenSlider) {
|
const presetSharpen = presetSharpenIntensity(
|
||||||
const sharpenPct = Math.max(
|
sharpenInput.intensity,
|
||||||
0,
|
this._engineKind,
|
||||||
Math.min(
|
);
|
||||||
100,
|
if (typeof presetSharpen === 'number' && this._sharpenSlider) {
|
||||||
Math.round(
|
const sharpenPct = Math.max(0, Math.min(100, Math.round(presetSharpen)));
|
||||||
sharpenIntensityForEngine(sharpenInput.intensity, this._engineKind),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
this._sharpenSlider.value = String(sharpenPct);
|
this._sharpenSlider.value = String(sharpenPct);
|
||||||
this._sharpenSliderValue.textContent = `${sharpenPct}%`;
|
this._sharpenSliderValue.textContent = `${sharpenPct}%`;
|
||||||
this._applySharpenIntensity(sharpenPct / 100);
|
this._applySharpenIntensity(sharpenPct / 100);
|
||||||
@@ -819,22 +807,12 @@ export class VisualSettings {
|
|||||||
this._setBloomEnabled(defaults.bloom.enabled);
|
this._setBloomEnabled(defaults.bloom.enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const defaultSharpen = presetSharpenIntensity(
|
||||||
typeof defaults.sharpen?.intensity === 'number' &&
|
defaults.sharpen?.intensity,
|
||||||
this._sharpenSlider
|
this._engineKind,
|
||||||
) {
|
);
|
||||||
const sharpenPct = Math.max(
|
if (typeof defaultSharpen === 'number' && this._sharpenSlider) {
|
||||||
0,
|
const sharpenPct = Math.max(0, Math.min(100, Math.round(defaultSharpen)));
|
||||||
Math.min(
|
|
||||||
100,
|
|
||||||
Math.round(
|
|
||||||
sharpenIntensityForEngine(
|
|
||||||
defaults.sharpen.intensity,
|
|
||||||
this._engineKind,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
this._sharpenSlider.value = String(sharpenPct);
|
this._sharpenSlider.value = String(sharpenPct);
|
||||||
this._sharpenSliderValue.textContent = `${sharpenPct}%`;
|
this._sharpenSliderValue.textContent = `${sharpenPct}%`;
|
||||||
this._applySharpenIntensity(sharpenPct / 100);
|
this._applySharpenIntensity(sharpenPct / 100);
|
||||||
|
|||||||
Reference in new issue
Block a user