@itwin/frontend-devtools
Version:
Debug menu and supporting UI widgets
64 lines • 2.55 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Tools
*/
import { IModelApp, NotifyMessageDetails, OutputMessagePriority, Tool } from "@itwin/core-frontend";
import { parseToggle } from "./parseToggle";
/** Executes some code against a RenderSystemDebugControl obtained from the IModelApp's RenderSystem.
* @beta
*/
export class RenderSystemDebugControlTool extends Tool {
async run(_args) {
const control = IModelApp.renderSystem.debugControl;
if (undefined !== control)
this.execute(control);
return true;
}
}
/** Forces webgl context loss.
* @beta
*/
export class LoseWebGLContextTool extends RenderSystemDebugControlTool {
static toolId = "LoseWebGLContext";
execute(control) {
control.loseContext();
}
}
/** Compiles all registered shader programs for which compilation has not already been attempted.
* This is useful for uncovering/debugging platform-specific shader issues.
* @beta
*/
export class CompileShadersTool extends RenderSystemDebugControlTool {
static toolId = "CompileShaders";
execute(control) {
const compiled = control.compileAllShaders();
IModelApp.notifications.outputMessage(new NotifyMessageDetails(compiled ? OutputMessagePriority.Info : OutputMessagePriority.Error, `${compiled ? "No" : "Some"} compilation errors occurred.`));
}
}
/** Toggles whether or not device pixel ratio should be taken into account when computing LOD for tiles and decoration graphics.
* @see [RenderSystem.Options.dpiAwareLOD]($frontend)
* @beta
*/
export class ToggleDPIForLODTool extends RenderSystemDebugControlTool {
static toolId = "ToggleDPIForLOD";
static get minArgs() { return 0; }
static get maxArgs() { return 1; }
_enable;
execute(control) {
const enable = this._enable ?? !control.dpiAwareLOD;
control.dpiAwareLOD = enable;
IModelApp.viewManager.invalidateViewportScenes();
}
async parseAndRun(...args) {
const enable = parseToggle(args[0]);
if (typeof enable !== "string") {
this._enable = enable;
await this.run([]);
}
return true;
}
}
//# sourceMappingURL=RenderSystemTools.js.map