UNPKG

@itwin/frontend-devtools

Version:

Debug menu and supporting UI widgets

162 lines 6.15 kB
/*--------------------------------------------------------------------------------------------- * 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, PrimitiveVisibility, Tool } from "@itwin/core-frontend"; import { parseToggle } from "./parseToggle"; /** Executes some code against a RenderTargetDebugControl obtained from the selected viewport. * @beta */ export class RenderTargetDebugControlTool extends Tool { async run(_args) { const view = IModelApp.viewManager.selectedView; const control = undefined !== view ? view.target.debugControl : undefined; if (undefined !== control) this.execute(control, view); return true; } } /** Toggles some aspect of a RenderTargetDebugControl for the selected viewport. * @beta */ export class RenderTargetDebugControlToggleTool extends RenderTargetDebugControlTool { static get minArgs() { return 0; } static get maxArgs() { return 1; } _enable; execute(control, vp) { const value = undefined !== this._enable ? this._enable : !control[this.aspect]; control[this.aspect] = value; vp.invalidateRenderPlan(); } async parseAndRun(...args) { const enable = parseToggle(args[0]); if (typeof enable !== "string") { this._enable = enable; await this.run([]); } return true; } } /** Toggles between normal rendering and rendering as if drawing to an off-screen framebuffer for element locate. Useful for debugging locate issues. * @beta */ export class ToggleReadPixelsTool extends RenderTargetDebugControlToggleTool { static toolId = "ToggleReadPixels"; get aspect() { return "drawForReadPixels"; } } /** Turn on the display of the draping frustum. * @beta */ export class ToggleDrapeFrustumTool extends RenderTargetDebugControlToggleTool { static toolId = "ToggleDrapeFrustum"; get aspect() { return "displayDrapeFrustum"; } } /** Turn on the display of the planar mask frustum. * @beta */ export class ToggleMaskFrustumTool extends RenderTargetDebugControlToggleTool { static toolId = "ToggleMaskFrustum"; get aspect() { return "displayMaskFrustum"; } } /** Control whether all geometry renders, or only instanced or batched geometry. * Allowed argument: "instanced", "batched", "all". Defaults to "all" if no arguments supplied. * @beta */ export class TogglePrimitiveVisibilityTool extends RenderTargetDebugControlTool { static toolId = "TogglePrimitiveVisibility"; static get minArgs() { return 0; } static get maxArgs() { return 1; } _visibility = PrimitiveVisibility.All; execute(control, vp) { control.primitiveVisibility = this._visibility; vp.invalidateScene(); } async parseAndRun(...args) { if (0 < args.length) { switch (args[0].toLowerCase()) { case "instanced": this._visibility = PrimitiveVisibility.Instanced; break; case "batched": this._visibility = PrimitiveVisibility.Uninstanced; break; case "all": break; default: return true; } } return this.run(args); } } /** Turn on display of reality tile boundaries. * @beta */ export class ToggleRealityTileBounds extends RenderTargetDebugControlToggleTool { static toolId = "ToggleRealityTileBounds"; get aspect() { return "displayRealityTileRanges"; } } /** Turn on display of reality tile preload debugging. * @beta */ export class ToggleRealityTilePreload extends RenderTargetDebugControlToggleTool { static toolId = "ToggleRealityTilePreload"; get aspect() { return "displayRealityTilePreload"; } } /** Freeze loading of reality tiles. * @beta */ export class ToggleRealityTileFreeze extends RenderTargetDebugControlToggleTool { static toolId = "ToggleRealityTileFreeze"; get aspect() { return "freezeRealityTiles"; } } /** Turn on logging of console tile selection and loading (to console). * @beta */ export class ToggleRealityTileLogging extends RenderTargetDebugControlToggleTool { static toolId = "ToggleRealityTileLogging"; get aspect() { return "logRealityTiles"; } } /** Toggles support for intersecting volume classifiers. * @beta */ export class ToggleVolClassIntersect extends RenderTargetDebugControlToggleTool { static toolId = "ToggleVCIntersect"; get aspect() { return "vcSupportIntersectingVolumes"; } } /** Set the number of antialiasing samples to use (<=1 for no antialiasing). * @beta */ export class SetAASamplesTool extends RenderTargetDebugControlTool { static toolId = "SetAASamples"; static get minArgs() { return 1; } static get maxArgs() { return 2; } _aaSamples = 1; _changeAll = false; execute(_control, vp) { if (this._changeAll) IModelApp.viewManager.setAntialiasingAllViews(this._aaSamples); else vp.antialiasSamples = this._aaSamples; } /** Runs this tool, setting the number of antialiasing samples to use (<=1 for no antialiasing). * @param args contains the arguments used by the tool's run method: args[0] contains the number of samples; optionally args[1] can contain the word "all" in order to set those number of samples for all viewports. */ async parseAndRun(...args) { if (0 < args.length) this._aaSamples = parseInt(args[0], 10); this._changeAll = (1 < args.length && args[1].toLowerCase() === "all"); return this.run(args); } } /** Toggles support for normal maps. * @beta */ export class ToggleNormalMaps extends RenderTargetDebugControlToggleTool { static toolId = "ToggleNormalMaps"; get aspect() { return "displayNormalMaps"; } } //# sourceMappingURL=RenderTargetTools.js.map