@itwin/core-frontend
Version:
iTwin.js frontend components
222 lines • 12.4 kB
TypeScript
/** @packageDocumentation
* @module Rendering
*/
import { Id64String } from "@itwin/core-bentley";
import { Matrix3d, Point2d, Point3d, Range1d, Transform, XAndY } from "@itwin/core-geometry";
import { Frustum, FrustumPlanes, ViewFlags } from "@itwin/core-common";
import { DecorationsCache } from "./DecorationsCache";
import { PlanarClipMaskState } from "./PlanarClipMaskState";
import { CanvasDecoration } from "./render/CanvasDecoration";
import { Decorations } from "./render/Decorations";
import { GraphicBranch, GraphicBranchOptions } from "./render/GraphicBranch";
import { GraphicBuilder, ViewportGraphicBuilderOptions } from "./render/GraphicBuilder";
import { RenderGraphic } from "./render/RenderGraphic";
import { RenderPlanarClassifier } from "./internal/render/RenderPlanarClassifier";
import { RenderSystem } from "./render/RenderSystem";
import { RenderTarget } from "./render/RenderTarget";
import { Scene } from "./render/Scene";
import { SpatialClassifierTileTreeReference, Tile, TileGraphicType, TileTreeReference } from "./tile/internal";
import { ViewingSpace } from "./ViewingSpace";
import { ScreenViewport, Viewport, ViewportDecorator } from "./Viewport";
import { ActiveSpatialClassifier } from "./SpatialClassifiersState";
import { GraphicType } from "./common/render/GraphicType";
import { RenderTextureDrape } from "./internal/render/RenderTextureDrape";
/** Provides context for producing [[RenderGraphic]]s for drawing within a [[Viewport]].
* @public
* @extensions
*/
export declare class RenderContext {
/** ViewFlags extracted from the context's [[Viewport]]. */
readonly viewFlags: ViewFlags;
private readonly _viewport;
/** Frustum extracted from the context's [[Viewport]]. */
readonly frustum: Frustum;
/** Frustum planes extracted from the context's [[Viewport]]. */
readonly frustumPlanes: FrustumPlanes;
constructor(vp: Viewport, frustum?: Frustum);
/** Given a point in world coordinates, determine approximately how many pixels it occupies on screen based on this context's frustum. */
getPixelSizeAtPoint(inPoint?: Point3d): number;
/** The [[Viewport]] associated with this context. */
get viewport(): Viewport;
/** The [[RenderSystem]] being used to produce graphics for this context. */
get renderSystem(): RenderSystem;
/** @internal */
get target(): RenderTarget;
/** @internal */
protected _createGraphicBuilder(options: Omit<ViewportGraphicBuilderOptions, "viewport">): GraphicBuilder;
/** Create a builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].
* @param transform the local-to-world transform in which the builder's geometry is to be defined.
* @returns A builder for creating a [[GraphicType.Scene]] [[RenderGraphic]] for rendering within this context's [[Viewport]].
*/
createSceneGraphicBuilder(transform?: Transform): GraphicBuilder;
/** Create a graphic from a [[GraphicBranch]]. */
createGraphicBranch(branch: GraphicBranch, location: Transform, opts?: GraphicBranchOptions): RenderGraphic;
/** Create a [[RenderGraphic]] which groups a set of graphics into a node in a scene graph, applying to each a transform and optional clip volume and symbology overrides.
* @param branch Contains the group of graphics and the symbology overrides.
* @param location the local-to-world transform applied to the grouped graphics.
* @returns A RenderGraphic suitable for drawing the scene graph node within this context's [[Viewport]].
* @see [[RenderSystem.createBranch]]
*/
createBranch(branch: GraphicBranch, location: Transform): RenderGraphic;
/** Given the size of a logical pixel in meters, convert it to the size of a physical pixel in meters, if [[RenderSystem.dpiAwareLOD]] is `true`.
* Used when computing LOD for graphics.
* @internal
*/
adjustPixelSizeForLOD(cssPixelSize: number): number;
}
/** Provides context for an [[InteractiveTool]] to display decorations representing its current state.
* @see [[InteractiveTool.onDynamicFrame]]
* @public
*/
export declare class DynamicsContext extends RenderContext {
private _foreground?;
private _overlay?;
/** Add a graphic to the list of dynamic graphics to be drawn in this context's [[Viewport]].
* These graphics are drawn as [[GraphicType.Scene]].
* @see [[addOverlay]] to add a graphic to be drawn as an overlay instead.
*/
addGraphic(graphic: RenderGraphic): void;
/** Add a graphic to the list of dynamic graphics to be drawn in this context's [[Viewport]].
* These graphics are drawn as part of the viewport's scene as described by [[GraphicType.Scene]], except
* that they always draw on top of other graphics as with [[GraphicType.WorldOverlay]].
* @see [[addGraphic]] to add an ordinary scene graphic instead.
*/
addOverlay(graphic: RenderGraphic): void;
/** @internal */
add(graphic: RenderGraphic, isOverlay: boolean): void;
/** @internal */
changeDynamics(): void;
/** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].
* @param options Options describing how to create the builder.
* @returns A builder that produces a [[RenderGraphic]].
*/
createGraphic(options: Omit<ViewportGraphicBuilderOptions, "viewport">): GraphicBuilder;
}
/** Arguments supplied to [[DecorateContext.create]].
* @public
*/
export interface DecorateContextCreateArgs {
/** The viewport to be decorated. */
viewport: ScreenViewport;
/** The set of decoration graphics to be populated by the context. */
output: Decorations;
/** Optional cache. If omitted, one will be created.
* @internal
*/
cache?: DecorationsCache;
}
/** Provides context for a [[ViewportDecorator]] to add [[Decorations]] to be rendered within a [[Viewport]].
* @public
* @extensions
*/
export declare class DecorateContext extends RenderContext {
private readonly _decorations;
private readonly _cache;
private _curCacheableDecorator?;
/** The [[ScreenViewport]] in which this context's [[Decorations]] will be drawn. */
get viewport(): ScreenViewport;
/** @internal */
constructor(vp: ScreenViewport, decorations: Decorations, cache: DecorationsCache);
/** Create a new DecorateContext.
* @param args Describes the inputs to the context.
* @note Typically the [[ScreenViewport]] takes care of creating the context for you.
* @public
*/
static create(args: DecorateContextCreateArgs): DecorateContext;
/** Create a builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].
* @param type The type of builder to create.
* @param transform the local-to-world transform in which the builder's geometry is to be defined.
* @param id If the decoration is to be pickable, a unique identifier to associate with the resultant [[RenderGraphic]].
* @returns A builder for creating a [[RenderGraphic]] of the specified type appropriate for rendering within this context's [[Viewport]].
* @see [[IModelConnection.transientIds]] for obtaining an ID for a pickable decoration.
* @see [[createGraphic]] for more options.
*/
createGraphicBuilder(type: GraphicType, transform?: Transform, id?: Id64String): GraphicBuilder;
/** Create a builder for producing a [[RenderGraphic]] appropriate for rendering within this context's [[Viewport]].
* @param options Options describing how to create the builder.
* @returns A builder that produces a [[RenderGraphic]].
*/
createGraphic(options: Omit<ViewportGraphicBuilderOptions, "viewport">): GraphicBuilder;
/** @internal */
addFromDecorator(decorator: ViewportDecorator): void;
/** Restores decorations onto this context from the specified array of cached decorations. */
private restoreCache;
private _appendToCache;
/** Calls [[GraphicBuilder.finish]] on the supplied builder to obtain a [[RenderGraphic]], then adds the graphic to the appropriate list of
* [[Decorations]].
* @param builder The builder from which to extract the graphic.
* @note The builder should not be used after calling this method.
*/
addDecorationFromBuilder(builder: GraphicBuilder): void;
/** Adds a graphic to the set of [[Decorations]] to be drawn in this context's [[ScreenViewport]].
* @param The type of the graphic, which determines to which list of decorations it is added.
* @param decoration The decoration graphic to add.
* @note The type must match the type with which the [[RenderGraphic]]'s [[GraphicBuilder]] was constructed.
* @see [[DecorateContext.addDecorationFromBuilder]] for a more convenient API.
*/
addDecoration(type: GraphicType, decoration: RenderGraphic): void;
/** Add a [[CanvasDecoration]] to be drawn in this context's [[ScreenViewport]]. */
addCanvasDecoration(decoration: CanvasDecoration, atFront?: boolean): void;
/** Add an HTMLElement to be drawn as a decoration in this context's [[ScreenViewport]]. */
addHtmlDecoration(decoration: HTMLElement): void;
/** @internal */
drawStandardGrid(gridOrigin: Point3d, rMatrix: Matrix3d, spacing: XAndY, gridsPerRef: number, _isoGrid?: boolean, _fixedRepetitions?: Point2d): void;
/** Display skyBox graphic that encompasses entire scene and rotates with camera.
* @see [[RenderSystem.createSkyBox]].
*/
setSkyBox(graphic: RenderGraphic): void;
/** Set the graphic to be displayed behind all other geometry as the background of this context's [[ScreenViewport]]. */
setViewBackground(graphic: RenderGraphic): void;
}
/** Context used to create the scene to be drawn in a [[Viewport]]. The scene consists of a set of [[RenderGraphic]]s produced by the
* [[TileTree]]s visible within the viewport. Creating the scene may result in the enqueueing of requests for [[Tile]] content which
* should be displayed in the viewport but are not yet loaded.
* @public
*/
export declare class SceneContext extends RenderContext {
private _missingChildTiles;
/** The graphics comprising the scene. */
readonly scene: Scene;
/** @internal */
readonly missingTiles: Set<Tile>;
/** @internal */
markChildrenLoading(): void;
/** @internal */
get hasMissingTiles(): boolean;
private _viewingSpace?;
private _graphicType;
constructor(vp: Viewport, frustum?: Frustum);
/** The viewed volume containing the scene. */
get viewingSpace(): ViewingSpace;
/** @internal */
get graphicType(): TileGraphicType;
/** Add the specified graphic to the scene. */
outputGraphic(graphic: RenderGraphic): void;
/** Indicate that the specified tile is desired for the scene but is not yet ready. A request to load its contents will later be enqueued. */
insertMissingTile(tile: Tile): void;
/** @internal */
requestMissingTiles(): void;
/** @internal */
addPlanarClassifier(classifiedModelId: Id64String, classifierTree?: SpatialClassifierTileTreeReference, planarClipMask?: PlanarClipMaskState): RenderPlanarClassifier | undefined;
/** @internal */
getPlanarClassifierForModel(modelId: Id64String): RenderPlanarClassifier | undefined;
/** @internal */
addBackgroundDrapedModel(drapedTreeRef: TileTreeReference, _heightRange: Range1d | undefined): RenderTextureDrape | undefined;
/** @internal */
getTextureDrapeForModel(modelId: Id64String): RenderTextureDrape | undefined;
/** @internal */
withGraphicType(type: TileGraphicType, func: () => void): void;
/** The graphics in the scene that will be drawn with depth. */
get graphics(): RenderGraphic[];
/** The graphics that will be drawn behind everything else in the scene. */
get backgroundGraphics(): RenderGraphic[];
/** The graphics that will be drawn in front of everything else in the scene. */
get overlayGraphics(): RenderGraphic[];
/** @internal */
get planarClassifiers(): Map<string, RenderPlanarClassifier>;
/** @internal */
get textureDrapes(): Map<string, RenderTextureDrape>;
/** @internal */
setVolumeClassifier(classifier: ActiveSpatialClassifier, modelId: Id64String): void;
}
//# sourceMappingURL=ViewContext.d.ts.map