@itwin/frontend-devtools
Version:
Debug menu and supporting UI widgets
71 lines • 3.04 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToggleDPIForLODTool = exports.CompileShadersTool = exports.LoseWebGLContextTool = exports.RenderSystemDebugControlTool = void 0;
/** @packageDocumentation
* @module Tools
*/
const core_frontend_1 = require("@itwin/core-frontend");
const parseToggle_1 = require("./parseToggle");
/** Executes some code against a RenderSystemDebugControl obtained from the IModelApp's RenderSystem.
* @beta
*/
class RenderSystemDebugControlTool extends core_frontend_1.Tool {
async run(_args) {
const control = core_frontend_1.IModelApp.renderSystem.debugControl;
if (undefined !== control)
this.execute(control);
return true;
}
}
exports.RenderSystemDebugControlTool = RenderSystemDebugControlTool;
/** Forces webgl context loss.
* @beta
*/
class LoseWebGLContextTool extends RenderSystemDebugControlTool {
static toolId = "LoseWebGLContext";
execute(control) {
control.loseContext();
}
}
exports.LoseWebGLContextTool = LoseWebGLContextTool;
/** Compiles all registered shader programs for which compilation has not already been attempted.
* This is useful for uncovering/debugging platform-specific shader issues.
* @beta
*/
class CompileShadersTool extends RenderSystemDebugControlTool {
static toolId = "CompileShaders";
execute(control) {
const compiled = control.compileAllShaders();
core_frontend_1.IModelApp.notifications.outputMessage(new core_frontend_1.NotifyMessageDetails(compiled ? core_frontend_1.OutputMessagePriority.Info : core_frontend_1.OutputMessagePriority.Error, `${compiled ? "No" : "Some"} compilation errors occurred.`));
}
}
exports.CompileShadersTool = CompileShadersTool;
/** 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
*/
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;
core_frontend_1.IModelApp.viewManager.invalidateViewportScenes();
}
async parseAndRun(...args) {
const enable = (0, parseToggle_1.parseToggle)(args[0]);
if (typeof enable !== "string") {
this._enable = enable;
await this.run([]);
}
return true;
}
}
exports.ToggleDPIForLODTool = ToggleDPIForLODTool;
//# sourceMappingURL=RenderSystemTools.js.map