UNPKG

@itwin/core-frontend

Version:
67 lines 2.46 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 WebGL */ import { assert } from "@itwin/core-bentley"; import { Transform } from "@itwin/core-geometry"; import { ViewFlags } from "@itwin/core-common"; import { FeatureSymbology } from "../../../render/FeatureSymbology"; import { BranchState } from "./BranchState"; import { EdgeSettings } from "./EdgeSettings"; /** * Represents the current state of the scene graph. As the scene graph is traversed, * branch states are pushed and popped. Pushing a branch state replaces the current view flags * and multiplies the current transform with the branch's transform. Popping it inverts this * operation. The state at the top of the stack applies to the rendering of all primitives. * The stack does not store the scene graph itself. * @internal */ export class BranchStack { _stack = []; constructor() { const state = new BranchState({ viewFlags: new ViewFlags(), transform: Transform.createIdentity(), edgeSettings: EdgeSettings.create(undefined), contourLine: undefined, is3d: true, symbologyOverrides: new FeatureSymbology.Overrides(), }); this.pushState(state); } get top() { assert(!this.empty); return this._stack[this._stack.length - 1]; } get bottom() { assert(!this.empty); return this._stack[0]; } get length() { return this._stack.length; } get empty() { return 0 === this.length; } pushBranch(branch) { assert(this.length > 0); this.pushState(BranchState.fromBranch(this.top, branch)); } pushState(state) { this._stack.push(state); } pop() { assert(!this.empty); if (!this.empty) { this._stack.pop(); } } changeRenderPlan(vf, is3d, hline, contour) { assert(1 === this.length); this.top.changeRenderPlan(vf, is3d, hline, contour); } setSymbologyOverrides(ovrs) { assert(1 === this.length); this.top.symbologyOverrides = ovrs; } } //# sourceMappingURL=BranchStack.js.map