UNPKG

@itwin/core-frontend

Version:
87 lines 3.88 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 Tiles */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MapTileLoader = void 0; const core_bentley_1 = require("@itwin/core-bentley"); const core_common_1 = require("@itwin/core-common"); const IModelApp_1 = require("../../../IModelApp"); const internal_1 = require("../../../tile/internal"); /** Specialization of map tile loader that includes terrain geometry with map imagery draped on it. */ class MapTileLoader extends internal_1.RealityTileLoader { _iModel; _modelId; _groundBias; _terrainProvider; get priority() { return internal_1.TileLoadPriority.Terrain; } get clipLowResolutionTiles() { return true; } _applyLights = false; featureTable; // public get heightRange(): Range1d | undefined { return this._heightRange; } _heightRange; get isContentUnbounded() { return true; } isTileAvailable(quadId) { return this.terrainProvider.isTileAvailable(quadId); } constructor(_iModel, _modelId, _groundBias, _terrainProvider) { super(); this._iModel = _iModel; this._modelId = _modelId; this._groundBias = _groundBias; this._terrainProvider = _terrainProvider; this.featureTable = new core_common_1.FeatureTable(0xffff, this._modelId); this.featureTable.insert(new core_common_1.Feature(this._modelId)); } getFeatureIndex(layerModelId) { return this.featureTable.insert(new core_common_1.Feature(layerModelId)); } get maxDepth() { return this._terrainProvider.maxDepth; } get minDepth() { return 0; } get terrainProvider() { return this._terrainProvider; } getRequestChannel(_tile) { // ###TODO use hostname from url - but so many layers to go through to get that... return IModelApp_1.IModelApp.tileAdmin.channels.getForHttp("itwinjs-imagery"); } async requestTileContent(tile, isCanceled) { (0, core_bentley_1.assert)(tile instanceof internal_1.MapTile); try { const data = await this.terrainProvider.requestMeshData({ tile, isCanceled }); return undefined !== data ? { data } : undefined; } catch { return undefined; } } forceTileLoad(tile) { return this._terrainProvider.forceTileLoad(tile); } async loadTileContent(tile, data, system, isCanceled) { (0, core_bentley_1.assert)("data" in data); isCanceled = isCanceled ?? (() => !tile.isLoading); const mesh = await this._terrainProvider.readMesh({ data: data.data, isCanceled, tile }); if (!mesh || isCanceled()) return {}; const projection = tile.getProjection(tile.heightRange); const terrainGeometry = system.createTerrainMesh(mesh, projection.transformFromLocal, true); return { contentRange: projection.transformFromLocal.multiplyRange(projection.localRange), terrain: { mesh, renderGeometry: terrainGeometry }, }; } loadPolyfaces() { (0, core_bentley_1.assert)(false, "load polyFaces not implmented for map tiles"); } getChildHeightRange(quadId, rectangle, parent) { return this._terrainProvider.getChildHeightRange(quadId, rectangle, parent); } async loadChildren(_tile) { (0, core_bentley_1.assert)(false); // children are generated synchronously in MapTile.... return undefined; } } exports.MapTileLoader = MapTileLoader; //# sourceMappingURL=MapTileLoader.js.map