diff --git a/src/components/theme/__tests__/GlassNavbarRefractionDefs.spec.ts b/src/components/theme/__tests__/GlassNavbarRefractionDefs.spec.ts index bc46d80c..31558636 100644 --- a/src/components/theme/__tests__/GlassNavbarRefractionDefs.spec.ts +++ b/src/components/theme/__tests__/GlassNavbarRefractionDefs.spec.ts @@ -168,7 +168,7 @@ describe('GlassNavbarRefractionDefs', () => { effectiveSettings.value = { glassDeformationStrength: 48, glassTranslationStrength: 48 } await settle() expect(createGlassNavbarDisplacementMap).toHaveBeenLastCalledWith( - expect.objectContaining({ optics: expect.objectContaining({ translationPx: 8.16 }) }), + expect.objectContaining({ optics: expect.objectContaining({ translationPx: expect.closeTo(1.880064) }) }), ) }) diff --git a/src/utils/__tests__/glassNavbarRefraction.spec.ts b/src/utils/__tests__/glassNavbarRefraction.spec.ts index 770c646b..1c0f36d9 100644 --- a/src/utils/__tests__/glassNavbarRefraction.spec.ts +++ b/src/utils/__tests__/glassNavbarRefraction.spec.ts @@ -6,20 +6,28 @@ import { } from '@/utils/glassNavbarRefraction' describe('getGlassNavbarOpticalResponse', () => { - it('keeps default vertical deformation small while retaining substantial translation', () => { + it('prioritizes default reading while retaining the horizontal lens', () => { const optics = getGlassNavbarOpticalResponse({ deformation: 48, translation: 48 }) - expect(optics.translationPx).toBeCloseTo(8.16) - expect(optics.verticalRatio * 24).toBeLessThan(0.4) - expect(optics.horizontalRatio * 24).toBeGreaterThan(3) + expect(optics.translationPx).toBeCloseTo(1.880064) + expect(optics.verticalRatio * 24).toBeLessThan(0.02) + expect(optics.horizontalRatio * 24).toBeGreaterThan(2.9) }) it.each([ [0, 0], - [50, 8.5], - [99, 16.83], + [50, 2.125], + [80, 8.704], + [99, 16.495083], [100, 17], - ])('maps translation %s linearly to %s pixels', (translation, pixels) => { + ])('maps translation %s to the readable curve at %s pixels', (translation, pixels) => { expect(getGlassNavbarOpticalResponse({ deformation: 48, translation }).translationPx).toBeCloseTo(pixels) }) + it('keeps the midpoint deformation equivalent to the original 12.5% input', () => { + const parameters = Object.freeze({ deformation: 50, translation: 50 }) + const optics = getGlassNavbarOpticalResponse(parameters) + expect(optics.horizontalRatio).toBeCloseTo(0.1386328125) + expect(optics.verticalRatio).toBeCloseTo(0.000859375) + expect(parameters).toEqual({ deformation: 50, translation: 50 }) + }) it('separates translation from deformation and limits the maximum translation', () => { expect(getGlassNavbarOpticalResponse({ deformation: 0, translation: 100 })).toEqual({ horizontalRatio: 0, diff --git a/src/utils/glassNavbarRefraction.ts b/src/utils/glassNavbarRefraction.ts index c7e75b9a..0d13de55 100644 --- a/src/utils/glassNavbarRefraction.ts +++ b/src/utils/glassNavbarRefraction.ts @@ -36,16 +36,16 @@ export interface GlassNavbarOpticalResponse { translationPx: number } -/** 自然默认值即呈现明显短边折射;纵向形变与平移独立限幅以保护阅读。 */ +/** 导航以低中段可读性为优先,高段保留完整位移预算;不改写共享参数或材质响应。 */ export function getGlassNavbarOpticalResponse( parameters: Pick, ): GlassNavbarOpticalResponse { - const deformation = normalizeGlassOpticalStrength(parameters.deformation) / 100 - const translation = normalizeGlassOpticalStrength(parameters.translation) / 100 + // 两个滑杆分别映射,50% 均使用 12.5% 的光学输入,避免平移维持高强度而抵消阅读改善。 + const deformation = (normalizeGlassOpticalStrength(parameters.deformation) / 100) ** 3 + const translation = (normalizeGlassOpticalStrength(parameters.translation) / 100) ** 3 return { horizontalRatio: 0.42 * (1 - (1 - deformation) ** 3), verticalRatio: 0.055 * deformation ** 2, - // 平移使用线性刻度,50% 对应 8.5px;不把平移强度叠加到字形纵向缩放。 translationPx: 17 * translation, } }