1- export const EDITOR_GIZMO_SNAP_STORAGE_KEY = "editor-gizmo-snap" ;
1+ export const editorGizmoSnapStorageKey = "editor-gizmo-snap" ;
22
33/** Minimum snap step (two-decimal increments cannot be smaller than 0.01). */
4- export const GIZMO_SNAP_MIN_STEP = 0.01 ;
4+ export const gizmoSnapMinStep = 0.01 ;
55
6- const SNAP_DECIMAL_ROUND_FACTOR = 100 ;
6+ const snapDecimalRoundFactor = 100 ;
77
88export interface IGizmoSnapPreferences {
99 translationEnabled : boolean ;
@@ -19,9 +19,9 @@ export interface IGizmoSnapPreferences {
1919 */
2020export function roundGizmoSnapSteps ( prefs : IGizmoSnapPreferences ) : IGizmoSnapPreferences {
2121 const roundStep = ( value : number ) : number => {
22- const clampedLow = Math . max ( GIZMO_SNAP_MIN_STEP , value ) ;
23- const rounded = Math . round ( clampedLow * SNAP_DECIMAL_ROUND_FACTOR ) / SNAP_DECIMAL_ROUND_FACTOR ;
24- return Math . max ( GIZMO_SNAP_MIN_STEP , rounded ) ;
22+ const clampedLow = Math . max ( gizmoSnapMinStep , value ) ;
23+ const rounded = Math . round ( clampedLow * snapDecimalRoundFactor ) / snapDecimalRoundFactor ;
24+ return Math . max ( gizmoSnapMinStep , rounded ) ;
2525 } ;
2626
2727 return {
@@ -32,7 +32,7 @@ export function roundGizmoSnapSteps(prefs: IGizmoSnapPreferences): IGizmoSnapPre
3232 } ;
3333}
3434
35- export const DEFAULT_GIZMO_SNAP_PREFERENCES : IGizmoSnapPreferences = {
35+ export const defaultGizmoSnapPreferences : IGizmoSnapPreferences = {
3636 translationEnabled : false ,
3737 translationStep : 1 ,
3838 rotationEnabled : false ,
@@ -58,12 +58,12 @@ function asNumber(value: unknown, fallback: number): number {
5858
5959export function loadGizmoSnapPreferences ( ) : IGizmoSnapPreferences {
6060 try {
61- const raw = localStorage . getItem ( EDITOR_GIZMO_SNAP_STORAGE_KEY ) ;
61+ const raw = localStorage . getItem ( editorGizmoSnapStorageKey ) ;
6262 if ( ! raw ) {
63- return roundGizmoSnapSteps ( { ...DEFAULT_GIZMO_SNAP_PREFERENCES } ) ;
63+ return roundGizmoSnapSteps ( { ...defaultGizmoSnapPreferences } ) ;
6464 }
6565 const parsed = JSON . parse ( raw ) as Partial < IGizmoSnapPreferences > ;
66- const base = DEFAULT_GIZMO_SNAP_PREFERENCES ;
66+ const base = defaultGizmoSnapPreferences ;
6767 return roundGizmoSnapSteps ( {
6868 translationEnabled : asBoolean ( parsed . translationEnabled , base . translationEnabled ) ,
6969 translationStep : clampPositive ( asNumber ( parsed . translationStep , base . translationStep ) , base . translationStep ) ,
@@ -73,10 +73,10 @@ export function loadGizmoSnapPreferences(): IGizmoSnapPreferences {
7373 scaleStep : clampPositive ( asNumber ( parsed . scaleStep , base . scaleStep ) , base . scaleStep ) ,
7474 } ) ;
7575 } catch {
76- return roundGizmoSnapSteps ( { ...DEFAULT_GIZMO_SNAP_PREFERENCES } ) ;
76+ return roundGizmoSnapSteps ( { ...defaultGizmoSnapPreferences } ) ;
7777 }
7878}
7979
8080export function saveGizmoSnapPreferences ( prefs : IGizmoSnapPreferences ) : void {
81- localStorage . setItem ( EDITOR_GIZMO_SNAP_STORAGE_KEY , JSON . stringify ( roundGizmoSnapSteps ( prefs ) ) ) ;
81+ localStorage . setItem ( editorGizmoSnapStorageKey , JSON . stringify ( roundGizmoSnapSteps ( prefs ) ) ) ;
8282}
0 commit comments