@itwin/core-frontend
Version:
iTwin.js frontend components
160 lines • 7.79 kB
TypeScript
import { Range3d, Transform } from "@itwin/core-geometry";
import { ElementAlignedBox3d, RenderFeatureTable } from "@itwin/core-common";
import { IModelAppOptions } from "../../IModelApp";
import { IModelConnection } from "../../IModelConnection";
import { MeshParams } from "../../common/internal/render/MeshParams";
import { PointStringParams } from "../../common/internal/render/PointStringParams";
import { PolylineParams } from "../../common/internal/render/PolylineParams";
import { ViewRect } from "../../common/ViewRect";
import { Decorations } from "../../render/Decorations";
import { GraphicBranch, GraphicBranchOptions } from "../../render/GraphicBranch";
import { CustomGraphicBuilderOptions, GraphicBuilder, ViewportGraphicBuilderOptions } from "../../render/GraphicBuilder";
import { Pixel } from "../../render/Pixel";
import { PrimitiveBuilder } from "../../internal/render/PrimitiveBuilder";
import { PointCloudArgs } from "../../common/internal/render/PointCloudPrimitive";
import { GraphicList, RenderGraphic } from "../../render/RenderGraphic";
import { RenderMemory } from "../../render/RenderMemory";
import { RenderPlan } from "../../internal/render/RenderPlan";
import { RenderSystem } from "../../render/RenderSystem";
import { RenderTarget } from "../../render/RenderTarget";
import { Scene } from "../../render/Scene";
import { _implementationProhibited } from "../../common/internal/Symbols";
import { RenderGeometry } from "./RenderGeometry";
import { RenderAreaPattern } from "./RenderAreaPattern";
/** Contains extensible mock implementations of the various components of a RenderSystem, intended for use in tests.
* Use these for tests instead of the default RenderSystem wherever possible because:
* (1) Electron has a bug on Windows in which it fails to obtain a WebGLRenderingContext when running inside a VM (e.g., during CI job); and
* (2) To decouple the logic which uses aspects of the RenderSystem from the full implementation.
* Any and all of these types can be extended for the purposes of specific tests.
* To use this:
* (1) If overriding anything in the implementation supplied herein, pass a SystemFactory function to MockRender.App.systemFactory.
* (2) Call MockRender.App.startup() instead of IModelApp.startup() before tests begin.
* (3) Likewise call MockRender.App.shutdown() when finished. This resets the SystemFactory to its default.
* @note The APIs within this namespace are intended *strictly* for use with unit tests.
* @internal
*/
export declare namespace MockRender {
/** @internal */
abstract class Target extends RenderTarget {
private readonly _system;
protected readonly [_implementationProhibited]: undefined;
protected constructor(_system: RenderSystem);
get renderSystem(): RenderSystem;
get wantInvertBlackBackground(): boolean;
get analysisFraction(): number;
set analysisFraction(_fraction: number);
changeScene(_scene: Scene): void;
changeDynamics(_foreground: GraphicList | undefined, _overlay: GraphicList | undefined): void;
changeDecorations(_decs: Decorations): void;
changeRenderPlan(_plan: RenderPlan): void;
drawFrame(_sceneTime?: number): void;
updateViewRect(): boolean;
readPixels(_rect: ViewRect, _selector: Pixel.Selector, receiver: Pixel.Receiver, _excludeNonLocatable: boolean): void;
get screenSpaceEffects(): Iterable<string>;
set screenSpaceEffects(_effects: Iterable<string>);
}
/** @internal */
class OnScreenTarget extends Target {
private readonly _canvas;
constructor(system: RenderSystem, _canvas: HTMLCanvasElement);
get viewRect(): ViewRect;
setViewRect(_rect: ViewRect, _temp: boolean): void;
}
/** @internal */
class OffScreenTarget extends Target {
private readonly _viewRect;
constructor(system: RenderSystem, _viewRect: ViewRect);
get viewRect(): ViewRect;
setViewRect(rect: ViewRect, _temp: boolean): void;
}
/** @internal */
class Builder extends PrimitiveBuilder {
constructor(system: System, options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions);
}
class Graphic extends RenderGraphic {
constructor();
dispose(): void;
collectStatistics(_stats: RenderMemory.Statistics): void;
unionRange(): void;
}
class List extends Graphic {
readonly graphics: RenderGraphic[];
constructor(graphics: RenderGraphic[]);
dispose(): void;
}
class Branch extends Graphic {
readonly branch: GraphicBranch;
readonly transform: Transform;
readonly options?: GraphicBranchOptions | undefined;
constructor(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions | undefined);
dispose(): void;
}
class Batch extends Graphic {
readonly graphic: RenderGraphic;
readonly featureTable: RenderFeatureTable;
readonly range: ElementAlignedBox3d;
constructor(graphic: RenderGraphic, featureTable: RenderFeatureTable, range: ElementAlignedBox3d);
dispose(): void;
}
/** @internal */
class Geometry implements RenderGeometry {
readonly renderGeometryType: "mesh" | "polyline" | "point-string";
noDispose: boolean;
readonly isInstanceable = true;
isDisposed: boolean;
constructor(renderGeometryType: "mesh" | "polyline" | "point-string");
[Symbol.dispose](): void;
collectStatistics(): void;
computeRange(): Range3d;
}
/** @internal */
class AreaPattern implements RenderAreaPattern {
readonly [_implementationProhibited] = "renderAreaPattern";
[Symbol.dispose](): void;
collectStatistics(): void;
}
class System extends RenderSystem {
get isValid(): boolean;
dispose(): void;
get maxTextureSize(): number;
constructor();
/** @internal */
doIdleWork(): boolean;
/** @internal */
createTarget(canvas: HTMLCanvasElement): OnScreenTarget;
/** @internal */
createOffscreenTarget(rect: ViewRect): RenderTarget;
createGraphic(options: CustomGraphicBuilderOptions | ViewportGraphicBuilderOptions): GraphicBuilder;
createGraphicList(primitives: RenderGraphic[]): List;
createGraphicBranch(branch: GraphicBranch, transform: Transform, options?: GraphicBranchOptions): Branch;
createBatch(graphic: RenderGraphic, features: RenderFeatureTable, range: ElementAlignedBox3d): Batch;
/** @internal */
createMesh(_params: MeshParams): Graphic;
/** @internal */
createPolyline(_params: PolylineParams): Graphic;
/** @internal */
createPointString(_params: PointStringParams): Graphic;
/** @internal */
createPointCloud(_args: PointCloudArgs, _imodel: IModelConnection): Graphic;
createRenderGraphic(): Graphic;
/** @internal */
createMeshGeometry(): Geometry;
/** @internal */
createPolylineGeometry(): Geometry;
/** @internal */
createPointStringGeometry(): Geometry;
/** @internal */
createAreaPattern(): AreaPattern;
/** @internal */
createGraphicFromTemplate(): Graphic;
}
type SystemFactory = () => RenderSystem;
/** An implementation of IModelApp which uses a MockRender.System by default. */
class App {
static systemFactory: SystemFactory;
static startup(opts?: IModelAppOptions): Promise<void>;
static shutdown(): Promise<void>;
protected static createDefaultRenderSystem(): System;
}
}
//# sourceMappingURL=MockRender.d.ts.map