UNPKG

@itwin/core-frontend

Version:
104 lines 5.9 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 { Transform } from "@itwin/core-geometry"; import { RenderMode, ViewFlags, } from "@itwin/core-common"; import { FeatureSymbology } from "../../../render/FeatureSymbology"; import { EdgeSettings } from "./EdgeSettings"; /** * Represents a branch node in the scene graph, with associated view flags and transform to be applied to * all sub-nodes of the branch. * @internal */ export class BranchState { _opts; get transform() { return this._opts.transform; } get viewFlags() { return this._opts.viewFlags; } set viewFlags(vf) { this._opts.viewFlags = vf.normalize(); } get clipVolume() { return this._opts.clipVolume; } get forceViewCoords() { return true === this._opts.forceViewCoords; } get planarClassifier() { return this._opts.planarClassifier; } get textureDrape() { return this._opts.textureDrape; } get edgeSettings() { return this._opts.edgeSettings; } get iModel() { return this._opts.iModel; } get transformFromIModel() { return this._opts.transformFromIModel; } get is3d() { return this._opts.is3d; } get frustumScale() { return this._opts.frustumScale; } get appearanceProvider() { return this._opts.appearanceProvider; } get secondaryClassifiers() { return this._opts.secondaryClassifiers; } get realityModelDisplaySettings() { return this._opts.realityModelDisplaySettings; } get viewAttachmentId() { return this._opts.viewAttachmentId; } get inSectionDrawingAttachment() { return this._opts.inSectionDrawingAttachment; } get groupNodeId() { return this._opts.groupNodeId; } get disableClipStyle() { return this._opts.disableClipStyle; } get contourLine() { return this._opts.contourLine; } get symbologyOverrides() { return this._opts.symbologyOverrides; } set symbologyOverrides(ovrs) { this._opts.symbologyOverrides = ovrs; } changeRenderPlan(viewFlags, is3d, hline, contour) { this.viewFlags = viewFlags; this._opts.is3d = is3d; this.edgeSettings.init(hline); this._opts.contourLine = contour; } /** Create a BranchState from a Branch. Any properties not explicitly specified by the new Branch are inherited from the previous BranchState. */ static fromBranch(prev, branch) { return new BranchState({ viewFlags: branch.branch.getViewFlags(prev.viewFlags), transform: prev.transform.multiplyTransformTransform(branch.localToWorldTransform), symbologyOverrides: branch.branch.symbologyOverrides ?? prev.symbologyOverrides, iModel: branch.iModel ?? prev.iModel, transformFromIModel: branch.transformFromExternalIModel ?? prev.transformFromIModel, planarClassifier: (undefined !== branch.planarClassifier && undefined !== branch.planarClassifier.texture) ? branch.planarClassifier : prev.planarClassifier, textureDrape: branch.textureDrape ?? prev.textureDrape, clipVolume: branch.clips, forceViewCoords: prev.forceViewCoords, edgeSettings: branch.edgeSettings ?? prev.edgeSettings, is3d: branch.frustum?.is3d ?? prev.is3d, frustumScale: branch.frustum?.scale ?? prev.frustumScale, secondaryClassifiers: branch.secondaryClassifiers ?? prev.secondaryClassifiers, // The branch can augment the symbology overrides. If it doesn't want to, allow its parent to do so, unless this branch supplies its own symbology overrides. appearanceProvider: branch.appearanceProvider ?? (branch.branch.symbologyOverrides ? undefined : prev.appearanceProvider), realityModelDisplaySettings: branch.branch.realityModelDisplaySettings ?? prev.realityModelDisplaySettings, viewAttachmentId: branch.viewAttachmentId ?? prev.viewAttachmentId, inSectionDrawingAttachment: branch.inSectionDrawingAttachment ?? prev.inSectionDrawingAttachment, groupNodeId: branch.branch.groupNodeId ?? prev.groupNodeId, disableClipStyle: branch.disableClipStyle ?? prev.disableClipStyle, contourLine: branch.contourLine ?? prev.contourLine, }); } getFeatureAppearance(overrides, elemLo, elemHi, subcatLo, subcatHi, geomClass, modelLo, modelHi, type, animationNodeId) { if (this._opts.appearanceProvider) return this._opts.appearanceProvider.getFeatureAppearance(overrides, elemLo, elemHi, subcatLo, subcatHi, geomClass, modelLo, modelHi, type, animationNodeId); return overrides.getAppearance(elemLo, elemHi, subcatLo, subcatHi, geomClass, modelLo, modelHi, type, animationNodeId); } static createForDecorations() { const viewFlags = new ViewFlags({ renderMode: RenderMode.SmoothShade, lighting: false, whiteOnWhiteReversal: false }); const symbologyOverrides = new FeatureSymbology.Overrides(); symbologyOverrides.ignoreSubCategory = true; return new BranchState({ viewFlags, transform: Transform.createIdentity(), symbologyOverrides, edgeSettings: EdgeSettings.create(undefined), is3d: true, }); } withViewCoords() { return new BranchState({ ...this._opts, forceViewCoords: true }); } constructor(opts) { if (!opts.frustumScale) opts.frustumScale = { x: 1, y: 1 }; this._opts = opts; this._opts.viewFlags = this._opts.viewFlags.normalize(); } } //# sourceMappingURL=BranchState.js.map