@itwin/core-frontend
Version:
iTwin.js frontend components
83 lines • 3.36 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 IModelApp
*/
import { EmptyLocalization } from "@itwin/core-common";
import { IModelApp } from "./IModelApp";
import { RenderSystem } from "./render/RenderSystem";
import { RenderTarget } from "./render/RenderTarget";
import { ViewRect } from "./common/ViewRect";
import { _implementationProhibited } from "./common/internal/Symbols";
/**
* A RenderTarget for applications that must run in environments where WebGL is not present.
* This is typically used in tests.
* @internal
*/
export class NullTarget extends RenderTarget {
[_implementationProhibited] = undefined;
get analysisFraction() { return 0; }
set analysisFraction(_fraction) { }
get renderSystem() { return undefined; }
get viewRect() { return new ViewRect(); }
get wantInvertBlackBackground() { return false; }
get animationBranches() { return undefined; }
set animationBranches(_branches) { }
onDestroy() { }
reset(_realityMapLayerChanged) { }
changeScene() { }
changeDynamics() { }
changeDecorations() { }
changeRenderPlan() { }
drawFrame(_sceneMilSecElapsed) { }
overrideFeatureSymbology() { }
setHiliteSet() { }
setFlashed() { }
setViewRect() { }
onResized() { }
[Symbol.dispose]() { }
updateViewRect() { return false; }
readPixels() { }
get screenSpaceEffects() { return []; }
set screenSpaceEffects(_effects) { }
}
/**
* A RenderSystem for applications that must run in environments where WebGL is not present.
* This is typically used in tests.
* @internal
*/
export class NullRenderSystem extends RenderSystem {
get isValid() { return false; }
doIdleWork() { return false; }
createTarget() { return new NullTarget(); }
createOffscreenTarget() { return new NullTarget(); }
createGraphic() { return undefined; }
createGraphicList() { return undefined; }
createGraphicBranch() { return undefined; }
createBatch() { return undefined; }
dispose() { }
constructor() { super(); }
createRenderGraphic() { return undefined; }
createGraphicFromTemplate() { return undefined; }
}
/** A utility class intended for applications (primarily test-runners) that run in environments that lack support for WebGL.
* It installs a [[RenderSystem]] that produces no graphics.
* Use [[NoRenderApp.startup]] instead of [[IModelApp.startup]] to initialize your application frontend.
* You may then use the [[IModelApp]] API as normal.
* @public
*/
export class NoRenderApp {
/** Initializes [[IModelApp]] with a [[RenderSystem]] that produces no graphics.
* Use this in place of [[IModelApp.startup]], then proceed to use [[IModelApp]]'s API as normal.
*/
static async startup(opts) {
opts = opts ? opts : {};
opts.renderSys = new NullRenderSystem();
opts.noRender = true;
opts.localization = opts.localization ?? new EmptyLocalization();
await IModelApp.startup(opts);
}
}
//# sourceMappingURL=NoRenderApp.js.map