UNPKG

@itwin/core-frontend

Version:
102 lines 4.4 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Rendering */ import { disposeArray } from "@itwin/core-bentley"; /** * A node in a scene graph. The branch itself is not renderable. Instead it contains a list of RenderGraphics, * and a transform, symbology overrides, and clip volume which are to be applied when rendering them. * Branches can be nested to build an arbitrarily-complex scene graph. * @see [[RenderSystem.createBranch]] * @public * @extensions */ export class GraphicBranch { /** The child nodes of this branch */ entries = []; /** If true, when the branch is disposed of, the RenderGraphics in its entries array will also be disposed */ ownsEntries; /** Selectively overrides the view's [ViewFlags]($common) while drawing graphics within this branch. The default overrides nothing. * @see [[setViewFlagOverrides]]. */ viewFlagOverrides = {}; /** Controls how reality models are displayed within this branch. * @beta */ realityModelDisplaySettings; /** @internal */ realityModelRange; /** Optional symbology overrides to be applied to all graphics in this branch */ symbologyOverrides; /** Optional animation branch Id that incorporates the model Id and, for element timelines, the batch Id. * @internal */ animationId; /** Identifies the node in the [RenderSchedule.Script]($backend) with which this branch is associated. * @internal */ animationNodeId; /** Identifies the "group" to which this branch belongs. * Groups represent cross-cutting subsets of a tile tree's contents. * For example, if a tile tree contains geometry from multiple models, each model (or smaller groups of multiple models) could be considered a group. * The top-level branches containing graphics from multiple tiles will each specify the group they represent, and the child branches within each * tile will likewise specify the group to which they belong. * When drawing, only the graphics within a tile that correlate with the current group will be drawn. * Groups cannot nest. * @internal */ groupNodeId; /** Constructor * @param ownsEntries If true, when this branch is [[dispose]]d, all of the [[RenderGraphic]]s it contains will also be disposed. */ constructor(ownsEntries = false) { this.ownsEntries = ownsEntries; } /** Add a graphic to this branch. */ add(graphic) { this.entries.push(graphic); } /** Compute the view flags that result from applying this branch's [[viewFlagOverrides]] to the input flags. * @param flags The input view flags, e.g., from the view's [[DisplayStyleState]]. * @returns The result of applying [[viewFlagOverrides]] to `flags`. */ getViewFlags(flags) { return flags.override(this.viewFlagOverrides); } /** Set [[viewFlagOverrides]] to override **all** ViewFlags as specified by `flags`. */ setViewFlags(flags) { this.viewFlagOverrides = { ...flags }; } /** Change [[viewFlagOverrides]]. */ setViewFlagOverrides(ovr) { this.viewFlagOverrides = { ...ovr }; } /** Disposes of all graphics in this branch, if and only if [[ownsEntries]] is true. */ [Symbol.dispose]() { this.clear(); } /** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */ dispose() { this[Symbol.dispose](); } /** Returns true if this branch contains no graphics. */ get isEmpty() { return 0 === this.entries.length; } /** Empties the list of [[RenderGraphic]]s contained in this branch, and if the [[ownsEntries]] flag is set, also disposes of them. */ clear() { if (this.ownsEntries) disposeArray(this.entries); else this.entries.length = 0; } /** @internal */ collectStatistics(stats) { for (const entry of this.entries) entry.collectStatistics(stats); } } //# sourceMappingURL=GraphicBranch.js.map