| 55 | } |
| 56 | |
| 57 | update(status: ShaderTransitionState, loadingMode: string): void { |
| 58 | if (loadingMode !== "player") { |
| 59 | this.reset(); |
| 60 | return; |
| 61 | } |
| 62 | if (status.ready || !status.loading) { |
| 63 | this.hide(); |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | const progress = |
| 68 | typeof status.progress === "number" && Number.isFinite(status.progress) ? status.progress : 0; |
| 69 | const total = |
| 70 | typeof status.total === "number" && Number.isFinite(status.total) ? status.total : 0; |
| 71 | const ratio = total > 0 ? Math.min(1, Math.max(0, progress / total)) : 0; |
| 72 | |
| 73 | const phraseIndex = Math.min( |
| 74 | SHADER_LOADING_PHRASES.length - 1, |
| 75 | Math.floor(ratio * SHADER_LOADING_PHRASES.length), |
| 76 | ); |
| 77 | this._el.title.textContent = |
| 78 | SHADER_LOADING_PHRASES[phraseIndex] || "Preparing scene transitions"; |
| 79 | |
| 80 | this._el.detail.textContent = |
| 81 | status.phase === "cached" |
| 82 | ? "Loading cached transition frames before playback." |
| 83 | : status.phase === "finalizing" |
| 84 | ? "Uploading transition textures for smooth playback." |
| 85 | : "Rendering animated scene samples for shader transitions."; |
| 86 | |
| 87 | this._el.fill.style.transform = `scaleX(${ratio})`; |
| 88 | |
| 89 | this._el.transitionValue.textContent = |
| 90 | status.currentTransition !== undefined && status.transitionTotal !== undefined |
| 91 | ? `${status.currentTransition}/${status.transitionTotal}` |
| 92 | : total > 0 |
| 93 | ? `${progress}/${total}` |
| 94 | : ""; |
| 95 | |
| 96 | const frameValue = |
| 97 | status.transitionFrame !== undefined && status.transitionFrames !== undefined |
| 98 | ? `${status.transitionFrame}/${status.transitionFrames}` |
| 99 | : ""; |
| 100 | |
| 101 | this._el.frameLabel.textContent = |
| 102 | status.phase === "cached" |
| 103 | ? "cached transition frames" |
| 104 | : status.phase === "finalizing" |
| 105 | ? "finalizing transition frames" |
| 106 | : "rendering transition frames"; |
| 107 | |
| 108 | this._el.frameValue.textContent = frameValue; |
| 109 | this._el.frameRow.style.visibility = frameValue ? "visible" : "hidden"; |
| 110 | this._el.root.setAttribute("aria-valuenow", String(Math.round(ratio * 100))); |
| 111 | this.show(); |
| 112 | } |
| 113 | |
| 114 | get hideTimeout(): ReturnType<typeof setTimeout> | null { |