mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Read the weather texture limit and the reveal time in the body, not in a parameter default
esbuild compiles an optional method call reached through an optional chain (`a?.b?.()`) in a parameter's default, for browsers it lowers optional chaining for (Chrome and Edge before 91), into code that reads a variable out of its scope. The weather shell's texture limit was read that way, so every satellite frame threw a ReferenceError in the built app and the layer showed "Weather imagery unavailable"; the leader and card reveal took their default time the same way. A test now refuses the form anywhere under src/.
This commit is contained in:
1 parent
7f2dc81cf6
commit
84b60a92e0
3 files changed
+116
-14
No files matched your search
@@ -709,29 +709,31 @@ function leaderDrawRatio(entry) {
|
||||
return Number.isFinite(ratio) ? Math.max(0.1, Math.min(0.9, ratio)) : 0.68;
|
||||
}
|
||||
|
||||
export function leaderRevealProgress(
|
||||
entry,
|
||||
timestamp = globalThis.performance?.now?.() ?? Date.now(),
|
||||
) {
|
||||
/** Now, for a reveal given no time. Not a parameter default: an optional
|
||||
* method call in a default parameter is compiled for older browsers into code
|
||||
* that throws (esbuild). */
|
||||
function revealNow() {
|
||||
return globalThis.performance?.now?.() ?? Date.now();
|
||||
}
|
||||
|
||||
export function leaderRevealProgress(entry, timestamp) {
|
||||
const at = timestamp === undefined ? revealNow() : timestamp;
|
||||
const linear = Math.min(
|
||||
1,
|
||||
animationLinearProgress(entry, timestamp) / leaderDrawRatio(entry),
|
||||
animationLinearProgress(entry, at) / leaderDrawRatio(entry),
|
||||
);
|
||||
return 1 - Math.pow(1 - linear, 3);
|
||||
}
|
||||
|
||||
export function tacticalCardRevealAlpha(
|
||||
entry,
|
||||
timestamp = globalThis.performance?.now?.() ?? Date.now(),
|
||||
) {
|
||||
export function tacticalCardRevealAlpha(entry, timestamp) {
|
||||
if (!(Math.max(0, Number(entry?.leaderAnimationMs) || 0) > 0)) return 1;
|
||||
const at = timestamp === undefined ? revealNow() : timestamp;
|
||||
const start = leaderDrawRatio(entry);
|
||||
const linear = Math.max(
|
||||
0,
|
||||
Math.min(
|
||||
1,
|
||||
(animationLinearProgress(entry, timestamp) - start) /
|
||||
Math.max(0.1, 1 - start),
|
||||
(animationLinearProgress(entry, at) - start) / Math.max(0.1, 1 - start),
|
||||
),
|
||||
);
|
||||
return linear * linear * (3 - 2 * linear);
|
||||
|
||||
Reference in new issue
Block a user