UNPKG

@itwin/core-frontend

Version:
71 lines 2.84 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.BranchStack = void 0; const core_bentley_1 = require("@itwin/core-bentley"); const core_geometry_1 = require("@itwin/core-geometry"); const core_common_1 = require("@itwin/core-common"); const FeatureSymbology_1 = require("../../../render/FeatureSymbology"); const BranchState_1 = require("./BranchState"); const EdgeSettings_1 = require("./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 */ class BranchStack { _stack = []; constructor() { const state = new BranchState_1.BranchState({ viewFlags: new core_common_1.ViewFlags(), transform: core_geometry_1.Transform.createIdentity(), edgeSettings: EdgeSettings_1.EdgeSettings.create(undefined), contourLine: undefined, is3d: true, symbologyOverrides: new FeatureSymbology_1.FeatureSymbology.Overrides(), }); this.pushState(state); } get top() { (0, core_bentley_1.assert)(!this.empty); return this._stack[this._stack.length - 1]; } get bottom() { (0, core_bentley_1.assert)(!this.empty); return this._stack[0]; } get length() { return this._stack.length; } get empty() { return 0 === this.length; } pushBranch(branch) { (0, core_bentley_1.assert)(this.length > 0); this.pushState(BranchState_1.BranchState.fromBranch(this.top, branch)); } pushState(state) { this._stack.push(state); } pop() { (0, core_bentley_1.assert)(!this.empty); if (!this.empty) { this._stack.pop(); } } changeRenderPlan(vf, is3d, hline, contour) { (0, core_bentley_1.assert)(1 === this.length); this.top.changeRenderPlan(vf, is3d, hline, contour); } setSymbologyOverrides(ovrs) { (0, core_bentley_1.assert)(1 === this.length); this.top.symbologyOverrides = ovrs; } } exports.BranchStack = BranchStack; //# sourceMappingURL=BranchStack.js.map