UNPKG

@itwin/core-frontend

Version:
86 lines 4.29 kB
/** @packageDocumentation * @module WebGL */ import { ClipVector, Range3d, Transform } from "@itwin/core-geometry"; import { ClipIntersectionStyle, RgbColor } from "@itwin/core-common"; import { RenderClipVolume } from "../../../render/RenderClipVolume"; import { FloatRgba } from "./FloatRGBA"; import { Texture2DData, Texture2DHandle, TextureHandle } from "./Texture"; interface Clip { readonly numRows: number; readonly getData: (transform: Transform) => Uint8Array; } /** Maintains a stack of ClipVolumes. The volumes nest such that the stack represents the intersection of all the volumes. * The bottom of the stack represents the view's clip volume and is always present even if the view has no clip. * It also maintains the inside/outside clip colors, where the alpha component is 1 if the color should be applied and 0 if not. * @internal */ export declare class ClipStack { /** Encoded data for all clips on the stack, update when the stack or the transform changes. */ protected _cpuBuffer: Uint8Array; /** A view of the encoded buffer in the format expected by the GPU. */ protected _gpuBuffer: Texture2DData; protected _texture?: Texture2DHandle; /** The maximum number of rows we have ever required. Determines the texture height. Grows as needed, reallocating a larger texture, but never shrinks. */ protected _numTotalRows: number; /** The number of rows in the texture actually required to encode the current contents of the stack. */ protected _numRowsInUse: number; /** The first entry always represents the view clip. The rest are pushed and popped with GraphicBranches. */ protected readonly _stack: Clip[]; /** True if we need to recompute the texture. */ protected _isStackDirty: boolean; /** Obtain the transform to be applied to the clips - i.e., the view matrix. */ protected readonly _getTransform: () => Transform; /** If this returns false, the clip at the bottom of the stack is ignored. */ protected readonly _wantViewClip: () => boolean; /** If alpha is 1 then geometry inside the clip will be drawn in this color. */ protected readonly _insideColor: FloatRgba; /** If alpha is 1 then geometry outside the clip will be drawn in this color. */ protected readonly _outsideColor: FloatRgba; /** For detecting whether the transform changed from one invocation of setViewClip to the next. */ protected readonly _prevTransform: Transform; /** True if we want to colorize geometry intersecting clip planes */ protected _colorizeIntersection: boolean; /** The style to colorize the geometry intersecting clip planes */ protected readonly _intersectionStyle: FloatRgba; constructor(getTransform: () => Transform, wantViewClip: () => boolean); get insideColor(): FloatRgba; get outsideColor(): FloatRgba; get hasOutsideColor(): boolean; get colorizeIntersection(): boolean; set colorizeIntersection(b: boolean); get intersectionStyle(): FloatRgba; get bytesUsed(): number; setViewClip(clip: ClipVector | undefined, style: { insideColor?: RgbColor; outsideColor?: RgbColor; colorizeIntersection?: boolean; intersectionStyle?: ClipIntersectionStyle; }): void; push(clip: RenderClipVolume): void; pop(): void; get hasClip(): boolean; get hasViewClip(): boolean; get startIndex(): number; get endIndex(): number; get textureHeight(): number; get texture(): TextureHandle | undefined; isRangeClipped(range: Range3d, transform: Transform): boolean; /** Exposed strictly for tests. */ get clips(): ReadonlyArray<{ numRows: number; }>; /** Exposed strictly for tests. */ static get emptyViewClip(): { numRows: number; getData: () => Uint8Array; }; protected updateTexture(): void; protected recomputeTexture(): void; protected uploadTexture(): void; protected allocateGpuBuffer(): Texture2DData; protected updateColor(rgb: RgbColor | undefined, rgba: FloatRgba): void; protected updateIntersectionStyle(colorizeIntersection: boolean | undefined, style: ClipIntersectionStyle | undefined, _thisStyle: FloatRgba): void; } export {}; //# sourceMappingURL=ClipStack.d.ts.map