misc/graphicsqualitygovernor
그래픽 품질 정하기. (설정과 프레임 재기로 가벼운 길을 쓸지 정하고, 렌더 배율 상한을 고른다)
Decides graphics quality. (Decides whether to use the lite path from the setting and frame measurement, and picks the render pixel ratio cap)
GraphicsQualityGovernor
그래픽 품질 정하기. (설정과 프레임 재기로 가벼운 길을 쓸지 정하고, 렌더 배율 상한을 고른다)
- 가벼운 길(isLite)을 정하는 차례: 덮어쓰기(주소의 ?light 같은 것) → 설정 낮음(늘 가벼움), 높음(늘 아님) → 자동. 자동이면 처음부터 가벼운 길(setAutoLiteDefault, 손가락 기기 같은 것)이거나 FrameProbe 가 처지는 기기로 잰 때 가벼운 길이다.
- 매 프레임 update(프레임 초, 최대 프레임) 를 부르면 자동일 때만 FrameProbe 로 잰다. 가벼운 길이 바뀐 프레임에 true 를 돌려준다. 한 번 처지는 기기로 재면 다시 재지 않는다. (FrameProbe 와 같다)
- 렌더 배율 상한: setRenderPixelRatioLimits(보통, 가벼운 길) 로 주고 applyRenderPixelRatio(viewManager) 가 바뀔 때만 건다. (0 이면 제한 없음)
- 가벼운 길에서 무엇을 줄일지(그림자, 바깥선, 효과, 그리는 수)는 게임이 isLite 를 읽어 정한다.
- 엔진과 브라우저를 들여오지 않는다. 주소 글은 applyPageQuery 가 지금 페이지에서 읽거나, 부르는 쪽이 applySearchText(location.search) 로 넘긴다.
Decides graphics quality. (Decides whether to use the lite path from the setting and frame measurement, and picks the render pixel ratio cap)
- Order for deciding the lite path (isLite): override (such as ?light in the URL) → setting low (always lite), high (never) → auto. In auto, it is the lite path if lite from the start (setAutoLiteDefault, such as touch devices) or if FrameProbe measured a lagging device.
- Calling update(frame seconds, maximum frame) every frame measures with FrameProbe only in auto. Returns true on the frame where the lite path changed. Once measured as a lagging device, it does not measure again. (Same as FrameProbe)
- Render pixel ratio cap: given with setRenderPixelRatioLimits(normal, lite path), and applyRenderPixelRatio(viewManager) applies it only when it changes. (0 means no limit)
- What to reduce on the lite path (shadows, outlines, effects, draw count) is decided by the game reading isLite.
- Does not import the engine or the browser. applyPageQuery reads the URL text from the current page, or the caller passes it with applySearchText(location.search).
import { GraphicsQualityGovernor, GraphicsQuality } from "./build/vanilla.js";
const governor = new GraphicsQualityGovernor();
governor.setQuality(GraphicsQuality.auto);
governor.applySearchText("?mode=demo");
governor.setRenderPixelRatioLimits(2, 1);
const frameProbe = governor.getFrameProbe();
frameProbe.setSeconds(0.5, 1);
for (let frame = 0; frame < 120; ++frame) {
const isChanged = governor.update(1 / 20, 60);
if (isChanged) {
console.log("lite", governor.isLite(), frame);
}
}
console.log(governor.isLite(), governor.readMaxRenderPixelRatio());생성. (자동, 덮어쓰기 없음, 렌더 배율 제한 없음)
Constructor. (Auto, no override, no render pixel ratio limit)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.new
품질 설정. (GraphicsQuality, 모르는 값이면 자동)
Sets the quality setting. (GraphicsQuality, auto for an unknown value)
- qualitystring
- GraphicsQuality 값.A GraphicsQuality value.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.set_quality
품질 설정 반환.
Returns the quality setting.
반환Returnsstring GraphicsQuality 값.A GraphicsQuality value.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.get_quality
덮어쓰기 설정. (true 면 늘 가벼운 길, false 면 늘 아님, null 이면 풀기)
Sets the override. (true means always the lite path, false means never, null releases it)
- liteOverrideboolean | null
- 늘 가벼운 길이면 true, 늘 아니면 false, 풀면 null.True for always lite, false for never, null to clear.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.set_lite_override
덮어쓰기 반환.
Returns the override.
반환Returnsboolean | null 덮어쓰기. 없으면 null.The override. null if none.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.get_lite_override
주소의 쿼리 글로 덮어쓰기. (liteKey 가 있으면 가벼운 길, 값이 "0" 이나 "false" 면 늘 아님, 없으면 그대로)
Overrides from the URL query text. (Lite path if liteKey is present, never if its value is "0" or "false", unchanged if absent)
- searchTextstring
- location.search 꼴. ("?light", "?a=1&light=0")location.search format. ("?light", "?a=1&light=0")
- liteKeystring
- 볼 쿼리 이름. (처음은 "light")Query name to look for. ("light" by default)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.apply_search_text
import { GraphicsQualityGovernor } from "./build/vanilla.js";
const governor = new GraphicsQualityGovernor();
governor.applySearchText("?light");
console.log(governor.getLiteOverride(), governor.isLite());
governor.applySearchText("?a=1&light=0");
console.log(governor.getLiteOverride(), governor.isLite());페이지 주소의 쿼리로 덮어쓰기. (지금 페이지의 location.search 를 applySearchText 로 넘긴다, 주소가 없는 곳이면 그대로)
- 러스트 판은 웹에서 주소의 쿼리, 데스크탑에서 환경 변수 VANILLA_<이름> 을 읽는다. 원본은 크롬 위에서만 돌아 주소만 본다.
Overrides from the query of the page URL. (passes location.search of the current page to applySearchText, unchanged where there is no URL)
- The Rust version reads the URL query on the web and the environment variable VANILLA_<name> on desktop. This version runs only on Chrome so it reads only the URL.
- liteKeystring
- 볼 쿼리 이름. (처음은 "light")Query name to look for. ("light" by default)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.apply_page_query
import { GraphicsQualityGovernor } from "./build/vanilla.js";
const governor = new GraphicsQualityGovernor();
governor.applyPageQuery("light");
console.log(governor.getLiteOverride());자동일 때 처음부터 가벼운 길인지 설정. (손가락 기기처럼 재기 전부터 가볍게 갈 때)
Sets whether auto starts on the lite path. (When going lite even before measuring, like touch devices)
- isAutoLiteDefaultboolean
- 자동일 때 재지 않고 처음부터 가벼운 길이면 참.True to use the lite path from the start without measuring when automatic.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.set_auto_lite_default
자동일 때 처음부터 가벼운 길인지 반환.
Returns whether auto starts on the lite path.
반환Returnsboolean 자동일 때 처음부터 가벼운 길이면 참.True if the lite path is used from the start when automatic.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.is_auto_lite_default
프레임 재기 반환. (기다리는 초, 판정 문턱을 바꾸거나 무거운 장면에서 measureAgain 할 때)
Returns the frame probe. (To change the wait seconds or the decision threshold, or to measureAgain in a heavy scene)
반환ReturnsFrameProbe 이 품질 정하기가 쓰는 FrameProbe.The FrameProbe used by this governor.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.get_frame_probe
가벼운 길로 그리는지.
Whether drawing on the lite path.
반환Returnsboolean 가벼운 길이면 참.True if on the lite path.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.is_lite
한 프레임. (자동이고 아직 가벼운 길이 아니면 프레임을 잰다, 가벼운 길이 바뀐 프레임에 true)
One frame. (Measures frames if auto and not yet on the lite path, true on the frame where the lite path changed)
- frameSecondsnumber
- 지난 프레임과의 간격. (초)Interval since the last frame. (seconds)
- maximumFramePerSecondnumber
- 엔진 설정의 최대 프레임. (0 이면 무제한)Maximum frame of the engine setting. (0 means unlimited)
반환Returnsboolean 지난 update 때와 가벼운 길이 달라졌으면 참.True if the lite path changed since the last update.
짝Counterpart: vanilla-engine GraphicsQualityGovernor.update
렌더 배율 상한 설정. (보통 길과 가벼운 길, 0 이면 제한 없음)
Sets the render pixel ratio cap. (Normal path and lite path, 0 means no limit)
- normalMaxRenderPixelRationumber
- 보통 길의 렌더 배율 상한. (0 이면 제한 없음, 음수면 0)Render pixel ratio limit on the normal path. (0 means no limit, 0 if negative)
- liteMaxRenderPixelRationumber
- 가벼운 길의 렌더 배율 상한. (0 이면 제한 없음, 음수면 0)Render pixel ratio limit on the lite path. (0 means no limit, 0 if negative)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.set_render_pixel_ratio_limits
지금 길의 렌더 배율 상한.
Render pixel ratio cap of the current path.
반환Returnsnumber 지금 길의 렌더 배율 상한. (0 이면 제한 없음)Render pixel ratio limit for the current path. (0 means no limit)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.read_max_render_pixel_ratio
렌더 배율 상한 걸기. (ViewManager 의 값과 다를 때만, 걸었으면 true)
Applies the render pixel ratio cap. (Only when it differs from the ViewManager value, true if applied)
- viewManagerobject
- ViewManager
반환Returnsboolean 새 상한을 걸었으면 참. (같아서 그대로 두었으면 거짓)True if a new limit was applied. (false if it was the same and left as is)
짝Counterpart: vanilla-engine GraphicsQualityGovernor.apply_render_pixel_ratio
import { Engine, EngineConfiguration, Scene, GraphicsQualityGovernor } from "./build/vanilla.js";
const governor = new GraphicsQualityGovernor();
governor.setRenderPixelRatioLimits(2, 1);
class QualityScene extends Scene {
tick(timeDelta) {
super.tick(timeDelta);
const isChanged = governor.update(timeDelta, 60);
if (isChanged) {
console.log("lite", governor.isLite());
}
const engine = this.getEngine();
const viewManager = engine.getViewManager();
governor.applyRenderPixelRatio(viewManager);
}
}
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
engine.run(new QualityScene());GraphicsQualityenum
그래픽 품질 설정 값.
Graphics quality setting value.
| 이름Name | 값Value | 설명Description |
|---|---|---|
auto | auto | 자동. (프레임 재기로 정한다)Automatic. (decided by frame measurement) |
high | high | 높음. (늘 가벼운 길이 아니다)High. (never the lite path) |
low | low | 낮음. (늘 가벼운 길)Low. (always the lite path) |