UNPKG

@itwin/core-frontend

Version:
86 lines 4.52 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 Views */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ContextRealityModelState = void 0; const core_bentley_1 = require("@itwin/core-bentley"); const core_common_1 = require("@itwin/core-common"); const PlanarClipMaskState_1 = require("./PlanarClipMaskState"); const RealityDataSource_1 = require("./RealityDataSource"); const SpatialClassifiersState_1 = require("./SpatialClassifiersState"); const internal_1 = require("./tile/internal"); /** A [ContextRealityModel]($common) attached to a [[DisplayStyleState]] supplying a [[TileTreeReference]] used to draw the * reality model in a [[Viewport]]. * @see [DisplayStyleSettings.contextRealityModels]($common). * @see [[DisplayStyleState.contextRealityModelStates]]. * @see [[DisplayStyleState.attachRealityModel]]. * @public * @extensions */ class ContextRealityModelState extends core_common_1.ContextRealityModel { _treeRef; /** The iModel with which the reality model is associated. */ iModel; /** The reality data source key with which the reality model is associated. */ rdSourceKey; /** @internal */ constructor(props, iModel, displayStyle) { super(props, { createClassifiers: (container) => SpatialClassifiersState_1.SpatialClassifiersState.create(container) }); this.iModel = iModel; this._appearanceOverrides = props.appearanceOverrides ? core_common_1.FeatureAppearance.fromJSON(props.appearanceOverrides) : undefined; if (undefined === props.orbitGtBlob) { this.rdSourceKey = props.rdSourceKey ? props.rdSourceKey : RealityDataSource_1.RealityDataSource.createKeyFromUrl(props.tilesetUrl); } else { this.rdSourceKey = props.rdSourceKey ? props.rdSourceKey : RealityDataSource_1.RealityDataSource.createKeyFromOrbitGtBlobProps(props.orbitGtBlob); } const useOrbitGtTileTreeReference = this.rdSourceKey.format === core_common_1.RealityDataFormat.OPC; this._treeRef = (!useOrbitGtTileTreeReference) ? (0, internal_1.createRealityTileTreeReference)({ iModel, source: displayStyle, rdSourceKey: this.rdSourceKey, url: props.tilesetUrl, name: props.name, classifiers: this.classifiers, planarClipMask: this.planarClipMaskSettings, getDisplaySettings: () => this.displaySettings, getBackgroundBase: () => displayStyle.settings.mapImagery.backgroundBase, getBackgroundLayers: () => displayStyle.settings.mapImagery.backgroundLayers, }) : (0, internal_1.createOrbitGtTileTreeReference)({ iModel, orbitGtBlob: props.orbitGtBlob, rdSourceKey: this.rdSourceKey, name: props.name, classifiers: this.classifiers, source: displayStyle, getDisplaySettings: () => this.displaySettings, }); this.onPlanarClipMaskChanged.addListener((newSettings) => { this._treeRef.planarClipMask = newSettings ? PlanarClipMaskState_1.PlanarClipMaskState.create(newSettings) : undefined; }); } /** The tile tree reference responsible for drawing the reality model into a [[Viewport]]. */ get treeRef() { return this._treeRef; } /** The set of available [[ActiveSpatialClassifier]]s that can be used to classify the reality model. */ get classifiers() { (0, core_bentley_1.assert)(super.classifiers instanceof SpatialClassifiersState_1.SpatialClassifiersState); return super.classifiers; } /** The transient Id assigned to this reality model at run-time. */ get modelId() { return (this._treeRef instanceof internal_1.RealityModelTileTree.Reference) ? this._treeRef.modelId : undefined; } /** Whether the reality model spans the entire globe ellipsoid. */ get isGlobal() { return this.treeRef.isGlobal; } } exports.ContextRealityModelState = ContextRealityModelState; //# sourceMappingURL=ContextRealityModelState.js.map