@itwin/core-frontend
Version:
iTwin.js frontend components
197 lines • 11.6 kB
TypeScript
/** @packageDocumentation
* @module Rendering
*/
import { Id64String } from "@itwin/core-bentley";
import { AnyCurvePrimitive, Arc3d, Loop, Path, Point2d, Point3d, Polyface, Range3d, SolidPrimitive, Transform } from "@itwin/core-geometry";
import { AnalysisStyle, ColorDef, Feature, Frustum, Gradient, GraphicParams, LinePixels, RenderTexture } from "@itwin/core-common";
import { _accumulator, _implementationProhibited } from "../internal/Symbols";
import { GraphicType } from "./GraphicType";
import { PickableGraphicOptions } from "./BatchOptions";
import { GraphicPrimitive } from "./GraphicPrimitive";
import { GeometryAccumulator } from "../internal/render/GeometryAccumulator";
import { Geometry } from "../internal/render/GeometryPrimitives";
/** @internal Used by GraphicAssembler's internal constructor. Subclasses define their own constructor arguments. */
export interface GraphicAssemblerOptions {
/** The constructor is internal, but protected.
* Prevent anyone outside of itwinjs-core from being able to invoke it, thereby preventing them from creating their own subclasses of GraphicAssembler.
*/
[_implementationProhibited]: unknown;
type: GraphicType;
placement: Transform;
pickable?: PickableGraphicOptions;
preserveOrder: boolean;
wantNormals: boolean;
wantEdges: boolean;
analysisStyle?: AnalysisStyle;
}
/** Provides methods for assembling geometric primitives and symbology into a graphical representation.
* Two concrete implementations are provided:
* - [[GraphicBuilder]], for creating [[RenderGraphic]]s directly; and
* - [[GraphicDescriptionBuilder]], for creating a [[GraphicDescription]] from which a [[RenderGraphic]] can be produced.
*
* GraphicBuilder can only be used on the main JavaScript thread, so its use should be reserved for relatively simple, quick-to-produce graphics like [[Decorations]].
* GraphicDescriptionBuilder is designed for use in a [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker). It can be used to assemble more
* complex graphics without blocking the main thread.
*
* @note Most of the methods which add geometry to the builder take ownership of their inputs rather than cloning them.
* So, for example, if you pass an array of points to [[addLineString]], you should not subsequently modify that array.
* @public
* @extensions
*/
export declare abstract class GraphicAssembler {
/** @internal */
abstract [_implementationProhibited]: unknown;
/** @internal */
readonly [_accumulator]: GeometryAccumulator;
private readonly _graphicParams;
/** The local-to-world transform in which the builder's geometry is to be defined. */
readonly placement: Transform;
/** The type of graphic to be produced. */
readonly type: GraphicType;
/** If the graphic is to be interactive, specifies its Id and other options. */
readonly pickable?: Readonly<PickableGraphicOptions>;
/** If true, the order in which geometry is added to the builder is preserved.
* This enables overlay and background graphics, which draw without using the depth buffer, to specify which geometry display in front of others when
* they overlap.
* For example, to draw an overlay containing a red shape with a white outline, you would add the shape to the GraphicAssember first, followed by its outline,
* to ensure the outline draws on top of the shape.
* This incurs a performance penalty due to the increased number of draw calls, and is never useful for graphics that draw using the depth buffer.
*/
readonly preserveOrder: boolean;
/** If true, normal vectors will be generated for surfaces, allowing 3d geometry to receive lighting and reduce z-fighting. */
readonly wantNormals: boolean;
/** If true, edges are generated for surfaces, to be drawn if edge display is enabled for the view in which the graphic is drawn. */
readonly wantEdges: boolean;
/** @alpha */
readonly analysisStyle?: AnalysisStyle;
/** @internal */
protected constructor(options: GraphicAssemblerOptions);
/** Whether the builder's geometry is defined in [[CoordSystem.View]] coordinates.
* Only graphics of type [[GraphicType.ViewBackground]] or [[GraphicType.ViewOverlay]] are defined in view coordinates.
* @see [[isWorldCoordinates]].
*/
get isViewCoordinates(): boolean;
/** Whether the builder's geometry is defined in [[CoordSystem.World]] coordinates - the inverse of [[isViewCoordinates]]. */
get isWorldCoordinates(): boolean;
/** True if the builder produces a graphic of [[GraphicType.Scene]]. */
get isSceneGraphic(): boolean;
/** True if the builder produces a graphic of [[GraphicType.ViewBackground]]. */
get isViewBackground(): boolean;
/** True if the builder produces a graphic of [[GraphicType.WorldOverlay]] or [[GraphicType.ViewOerlay]]. */
get isOverlay(): boolean;
/** Sets the current active symbology for this builder. Any new geometry subsequently added to the builder will be drawn using the specified symbology.
* @param graphicParams The symbology to apply to subsequent geometry.
* @see [[setSymbology]] for a convenient way to set common symbology options.
*/
activateGraphicParams(graphicParams: GraphicParams): void;
/** Change the [Feature]($common) to be associated with subsequently-added geometry. This permits multiple features to be batched together into a single graphic
* for more efficient rendering.
* @note This method has no effect if [[pickable]] is not defined.
*/
activateFeature(feature: Feature): void;
/** Change the pickable Id to be associated with subsequently-added geometry. This permits multiple pickable objects to be batched together into a single graphic
* for more efficient rendering. This method calls [[activateFeature]], using the subcategory Id and [GeometryClass]($common) specified in [[pickable]]
* at construction, if any.
* @note This method has no effect if [[pickable]] is not defined.
*/
activatePickableId(id: Id64String): void;
/**
* Appends a 3d line string to the builder.
* @param points Array of vertices in the line string.
*/
addLineString(points: Point3d[]): void;
/**
* Appends a 2d line string to the builder.
* @param points Array of vertices in the line string.
* @param zDepth Z value in local coordinates to use for each point.
*/
addLineString2d(points: Point2d[], zDepth: number): void;
/**
* Appends a 3d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].
* @param points Array of vertices in the point string.
*/
addPointString(points: Point3d[]): void;
/**
* Appends a 2d point string to the builder. The points are drawn disconnected, with a diameter in pixels defined by the builder's active [[GraphicParams.rasterWidth]].
* @param points Array of vertices in the point string.
* @param zDepth Z value in local coordinates to use for each point.
*/
addPointString2d(points: Point2d[], zDepth: number): void;
/**
* Appends a closed 3d planar region to the builder.
* @param points Array of vertices of the shape.
*/
addShape(points: Point3d[]): void;
/**
* Appends a closed 2d region to the builder.
* @param points Array of vertices of the shape.
* @param zDepth Z value in local coordinates to use for each point.
*/
addShape2d(points: Point2d[], zDepth: number): void;
/**
* Appends a 3d open arc or closed ellipse to the builder.
* @param arc Description of the arc or ellipse.
* @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.
* @param filled If true, and isEllipse is also true, then draw ellipse filled.
*/
addArc(ellipse: Arc3d, isEllipse: boolean, filled: boolean): void;
/**
* Appends a 2d open arc or closed ellipse to the builder.
* @param arc Description of the arc or ellipse.
* @param isEllipse If true, and if the arc defines a full sweep, then draw as a closed ellipse instead of an arc.
* @param filled If true, and isEllipse is also true, then draw ellipse filled.
* @param zDepth Z value in local coordinates to use for each point in the arc or ellipse.
*/
addArc2d(ellipse: Arc3d, isEllipse: boolean, filled: boolean, zDepth: number): void;
/** Append a 3d open path to the builder. */
addPath(path: Path): void;
/** Append a 3d planar region to the builder. */
addLoop(loop: Loop): void;
/** Append a [CurvePrimitive]($core-geometry) to the builder. */
addCurvePrimitive(curve: AnyCurvePrimitive): void;
/** Append a mesh to the builder.
* @param meshData Describes the mesh
* @param _filled If the mesh describes a planar region, indicates whether its interior area should be drawn with fill in [[RenderMode.Wireframe]].
*/
addPolyface(meshData: Polyface, _filled?: boolean): void;
/** Append a solid primitive to the builder. */
addSolidPrimitive(primitive: SolidPrimitive): void;
/** Append any primitive to the builder.
* @param primitive The graphic primitive to append.
*/
addPrimitive(primitive: GraphicPrimitive): void;
/** Add a box representing a volume of space. Typically used for debugging purposes.
* @param range The volume of space.
* @param solid If true, a [[Box]] solid primitive will be added; otherwise, a wireframe outline of the box will be added.
*/
addRangeBox(range: Range3d, solid?: boolean): void;
/** Add Frustum edges. Useful for debugging. */
addFrustum(frustum: Frustum): void;
/** Add Frustum sides. Useful for debugging. */
addFrustumSides(frustum: Frustum): void;
/** Add range edges from corner points */
addRangeBoxFromCorners(p: Point3d[]): void;
/** Add range sides from corner points */
addRangeBoxSidesFromCorners(p: Point3d[]): void;
/** Sets the current active symbology for this builder. Any new geometry subsequently added will be drawn using the specified symbology.
* @param lineColor The color in which to draw lines.
* @param fillColor The color in which to draw filled regions.
* @param lineWidth The width in pixels to draw lines. The renderer will clamp this value to an integer in the range [1, 32].
* @param linePixels The pixel pattern in which to draw lines.
* @see [[activateGraphicParams]] for additional symbology options.
*/
setSymbology(lineColor: ColorDef, fillColor: ColorDef, lineWidth: number, linePixels?: LinePixels): void;
/** Set the current active symbology for this builder to be a blanking fill before adding a planar region.
* A planar region drawn with blanking fill renders behind other geometry in the same graphic.
* Blanking fill is not affected by the fill [[ViewFlags]] being disabled.
* An example would be to add a line to a graphic containing a shape with blanking fill so that the line is always shown in front of the fill.
* @param fillColor The color in which to draw filled regions.
*/
setBlankingFill(fillColor: ColorDef): void;
private getMeshDisplayParams;
private getLinearDisplayParams;
/** @internal */
protected abstract resolveGradient(gradient: Gradient.Symb): RenderTexture | undefined;
add(geom: Geometry): void;
}
//# sourceMappingURL=GraphicAssembler.d.ts.map