-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(world): add fade constants and scaling logic
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const WORLD_FADE_SIZE_DEFAULT = [1.0, 4.0, 15.0, 100.0, 100000.0]; | ||
|
||
const WORLD_FADE_DIST_DEFAULT = [30.0, 100.0, 200.0, 750.0, 1250.0]; | ||
|
||
const WORLD_FADE_RANGE_DEFAULT = [5.0, 10.0, 15.0, 20.0, 50.0]; | ||
|
||
const WORLD_FADE_SIZE = [1.0, 4.0, 15.0, 100.0, 100000.0]; | ||
|
||
const WORLD_FADE_DIST_MIN = [25.0, 90.0, 185.0, 730.0, 1200.0]; | ||
|
||
const WORLD_FADE_DIST_MAX = [30.0, 100.0, 200.0, 750.0, 1250.0]; | ||
|
||
const getSizeCategory = (size: number) => { | ||
let f: number; | ||
for (f = 0; f < WORLD_FADE_SIZE.length; f++) { | ||
if (size <= WORLD_FADE_SIZE[f]) { | ||
break; | ||
} | ||
} | ||
|
||
return f; | ||
}; | ||
|
||
const scaleFadeDist = (scale: number) => { | ||
for (let i = 0; i < WORLD_FADE_SIZE_DEFAULT.length; i++) { | ||
const first = i === 0; | ||
const last = i === WORLD_FADE_SIZE_DEFAULT.length - 1; | ||
const s = first || last ? 1.0 : scale; | ||
|
||
WORLD_FADE_SIZE[i] = WORLD_FADE_SIZE_DEFAULT[i]; | ||
WORLD_FADE_DIST_MAX[i] = WORLD_FADE_DIST_DEFAULT[i] * s; | ||
WORLD_FADE_DIST_MIN[i] = WORLD_FADE_DIST_MAX[i] - WORLD_FADE_RANGE_DEFAULT[i]; | ||
} | ||
}; | ||
|
||
// TODO modify scale based on config | ||
scaleFadeDist(1.5); | ||
|
||
export { | ||
getSizeCategory, | ||
scaleFadeDist, | ||
WORLD_FADE_SIZE, | ||
WORLD_FADE_DIST_MIN, | ||
WORLD_FADE_DIST_MAX, | ||
}; |