Allow configuring fps autoscaler
This commit is contained in:
parent
b355132861
commit
2659d531b4
1 changed files with 10 additions and 2 deletions
|
|
@ -42,6 +42,8 @@ import { DrawableDescriptor, Renderer } from './main';
|
||||||
* return value must be given.
|
* return value must be given.
|
||||||
* @param startupSettingOverrides Sensible defaults are provided, but these can be overridden.
|
* @param startupSettingOverrides Sensible defaults are provided, but these can be overridden.
|
||||||
* @param initialRuntimeSettingOverrides Sensible defaults are provided, but these can be overridden.
|
* @param initialRuntimeSettingOverrides Sensible defaults are provided, but these can be overridden.
|
||||||
|
* Set `enableAutoscaler` to `false` to keep the render scales exactly as configured
|
||||||
|
* instead of letting the FPS-based autoscaler adjust them.
|
||||||
*/
|
*/
|
||||||
export async function runAnimation(
|
export async function runAnimation(
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
|
|
@ -51,7 +53,9 @@ export async function runAnimation(
|
||||||
currentTimeInMilliseconds: DOMHighResTimeStamp,
|
currentTimeInMilliseconds: DOMHighResTimeStamp,
|
||||||
deltaTimeInMilliseconds: DOMHighResTimeStamp
|
deltaTimeInMilliseconds: DOMHighResTimeStamp
|
||||||
) => boolean,
|
) => boolean,
|
||||||
settings: Partial<StartupSettings & RuntimeSettings> = {}
|
settings: Partial<StartupSettings & RuntimeSettings> & {
|
||||||
|
enableAutoscaler?: boolean;
|
||||||
|
} = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (settings.enableContextLostSimulator) {
|
if (settings.enableContextLostSimulator) {
|
||||||
enableContextLostSimulator(canvas);
|
enableContextLostSimulator(canvas);
|
||||||
|
|
@ -62,7 +66,11 @@ export async function runAnimation(
|
||||||
let triggerIsOver: () => void;
|
let triggerIsOver: () => void;
|
||||||
const isOver = new Promise<void>((resolve) => (triggerIsOver = resolve));
|
const isOver = new Promise<void>((resolve) => (triggerIsOver = resolve));
|
||||||
renderer.setRuntimeSettings(settings);
|
renderer.setRuntimeSettings(settings);
|
||||||
const autoscaler = new FpsQualityAutoscaler(renderer);
|
const autoscaler = new FpsQualityAutoscaler(renderer, {
|
||||||
|
distanceRenderScale: settings.distanceRenderScale,
|
||||||
|
lightsRenderScale: settings.lightsRenderScale,
|
||||||
|
});
|
||||||
|
autoscaler.scalingEnabled = settings.enableAutoscaler !== false;
|
||||||
|
|
||||||
await renderer.initializedPromise;
|
await renderer.initializedPromise;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue