misc/loadingprogress
로딩 진행률.
Loading progress.
LoadingProgressextends Object
로딩 진행률.
- 로딩의 단계가 알려 준 정도(setProgress, 0 ~ 1, 줄어들지 않음)를 보이는 정도(getShownProgress)가 부드럽게 따라간다. 받기가 몰려 진행률이 한 번에 뛰어도 막대가 튀지 않고 미끄러진다.
- 매 프레임 update(timeDelta) 를 부른다. 따라가는 몫은 1 - exp(-빠르기 * 시간) 이라 프레임 간격이 달라도 같은 빠르기다.
Loading progress.
- The shown progress (getShownProgress) smoothly follows the progress reported by the loading stages (setProgress, 0 ~ 1, never decreases). Even if progress jumps at once because loads bunch up, the bar slides instead of jumping.
- Call update(timeDelta) every frame. The follow fraction is 1 - exp(-speed * time), so the speed is the same even with different frame intervals.
import { LoadingProgress } from "./build/vanilla.js";
const loadingProgress = new LoadingProgress(6);
loadingProgress.setProgress(0.5);
for (let frame = 0; frame < 30; ++frame) {
loadingProgress.update(1 / 60);
}
console.log(loadingProgress.getProgress(), loadingProgress.getShownProgress().toFixed(3));
loadingProgress.setProgress(0.3);
console.log(loadingProgress.getProgress());
loadingProgress.setProgress(1);
while (!loadingProgress.isFinished()) {
loadingProgress.update(1 / 60);
}
console.log(loadingProgress.getShownProgress());생성.
Constructor.
- followRatenumber
- 따라가는 빠르기. (초당 남은 거리의 비율, 기본 6)Follow speed. (Fraction of the remaining distance per second, default 6)
짝Counterpart: vanilla-engine LoadingProgress.new
알려 준 정도 설정. (0 ~ 1 로 자르고, 앞서 알린 것보다 작으면 무시한다)
Sets the reported progress. (Clamped to 0 ~ 1, ignored if smaller than what was reported before)
- progressnumber
- 알려 줄 정도. (0 ~ 1)Progress to report. (0 ~ 1)
짝Counterpart: vanilla-engine LoadingProgress.set_progress
알려 준 정도 반환.
Returns the reported progress.
반환Returnsnumber 0 ~ 1
짝Counterpart: vanilla-engine LoadingProgress.get_progress
보이는 정도 반환. (그릴 때 읽는다)
Returns the shown progress. (Read when drawing)
반환Returnsnumber 0 ~ 1
짝Counterpart: vanilla-engine LoadingProgress.get_shown_progress
갱신. (보이는 정도가 알려 준 정도를 따라간다)
Updates. (The shown progress follows the reported progress)
- timeDeltanumber
- 지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
짝Counterpart: vanilla-engine LoadingProgress.update
따라가는 빠르기 설정. (초당 남은 거리의 비율, 0 보다 커야 한다. 아니면 그대로 둔다)
Sets the follow speed. (Fraction of the remaining distance per second, must be greater than 0. Otherwise left unchanged)
- followRatenumber
- 따라가는 빠르기. (초당 남은 거리의 비율)Follow speed. (Fraction of the remaining distance per second)
짝Counterpart: vanilla-engine LoadingProgress.set_follow_rate
따라가는 빠르기 반환.
Returns the follow speed.
반환Returnsnumber 따라가는 빠르기. (초당 남은 거리의 비율)Follow speed. (Fraction of the remaining distance per second)
짝Counterpart: vanilla-engine LoadingProgress.get_follow_rate
보이는 정도가 끝(1)에 닿았는지.
Whether the shown progress has reached the end (1).
반환Returnsboolean 보이는 정도가 1 에 닿았으면 참.True if the shown progress has reached 1.
짝Counterpart: vanilla-engine LoadingProgress.is_finished
처음으로. (알려 준 정도와 보이는 정도를 0 으로)
Resets. (Sets the reported progress and the shown progress to 0)
짝Counterpart: vanilla-engine LoadingProgress.reset