Simplify options and improve destroy
This commit is contained in:
parent
0cf8e8dac5
commit
88530fdb94
2 changed files with 12 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ import { LightDrawable } from '../../../drawables/lights/light-drawable';
|
|||
import { colorToString } from '../../../helper/color-to-string';
|
||||
import { DefaultFrameBuffer } from '../../graphics-library/frame-buffer/default-frame-buffer';
|
||||
import { IntermediateFrameBuffer } from '../../graphics-library/frame-buffer/intermediate-frame-buffer';
|
||||
import { enableExtension } from '../../graphics-library/helper/enable-extension';
|
||||
import { getHardwareInfo } from '../../graphics-library/helper/get-hardware-info';
|
||||
import { WebGlStopwatch } from '../../graphics-library/helper/stopwatch';
|
||||
import { ParallelCompiler } from '../../graphics-library/parallel-compiler';
|
||||
|
|
@ -77,7 +78,9 @@ export class RendererImplementation implements Renderer {
|
|||
|
||||
setRuntimeSettings(overrides: Partial<RuntimeSettings>): void {
|
||||
Object.entries(overrides).forEach(([k, v]) => {
|
||||
this.applyRuntimeSettings[k as keyof RuntimeSettings](v);
|
||||
if (k in this.applyRuntimeSettings) {
|
||||
this.applyRuntimeSettings[k as keyof RuntimeSettings](v);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -287,8 +290,12 @@ export class RendererImplementation implements Renderer {
|
|||
|
||||
public destroy(): void {
|
||||
this.canvasResizeObserver.disconnect();
|
||||
|
||||
this.distancePass.destroy();
|
||||
this.lightsPass.destroy();
|
||||
this.palette.destroy();
|
||||
|
||||
const ext = enableExtension(this.gl, 'WEBGL_lose_context');
|
||||
ext.loseContext();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,18 +51,17 @@ export async function runAnimation(
|
|||
currentTimeInMilliseconds: DOMHighResTimeStamp,
|
||||
deltaTimeInMilliseconds: DOMHighResTimeStamp
|
||||
) => boolean,
|
||||
startupSettingOverrides: Partial<StartupSettings> = {},
|
||||
initialRuntimeSettingOverrides: Partial<RuntimeSettings> = {}
|
||||
settings: Partial<StartupSettings & RuntimeSettings> = {}
|
||||
): Promise<void> {
|
||||
if (startupSettingOverrides.enableContextLostSimulator) {
|
||||
if (settings.enableContextLostSimulator) {
|
||||
enableContextLostSimulator(canvas);
|
||||
}
|
||||
const renderer = new ContextAwareRenderer(canvas, descriptors, startupSettingOverrides);
|
||||
const renderer = new ContextAwareRenderer(canvas, descriptors, settings);
|
||||
|
||||
const deltaTimeCalculator = new DeltaTimeCalculator();
|
||||
let triggerIsOver: () => void;
|
||||
const isOver = new Promise((resolve) => (triggerIsOver = resolve));
|
||||
renderer.setRuntimeSettings(initialRuntimeSettingOverrides);
|
||||
renderer.setRuntimeSettings(settings);
|
||||
const autoscaler = new FpsQualityAutoscaler(renderer);
|
||||
|
||||
await renderer.initializedPromise;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue