UNPKG

@itwin/core-frontend

Version:
35 lines 2.23 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.Frustum2d = void 0; const core_geometry_1 = require("@itwin/core-geometry"); /** Constants and functions for working with two-dimensions [Frustum]($common)s. * A 2d view is rendered using an orthographic frustum with depth. 2d elements have no meaningful placement in Z, but they can have a display priority * that controls which elements draw in front of others. Usable priority values range from -500 (behind everything else) to 500 (in front of everything else). * Priority values are mapped to Z coordinates in [-1, 1] meters. Therefore a 2d view always has *at least* that same depth range. * Sometimes, 3d views are displayed in the context of 2d views. Because 3d views can have arbitrarily large depths, the 2d view's extents are expanded * in Z to accommodate the 3d geometry. Expanding the frustum depth does *not* affect the mapping of display priorities to depth values. * @public */ var Frustum2d; (function (Frustum2d) { /** The minimum distance in positive or negative Z for a 2d frustum, in meters. */ Frustum2d.minimumZDistance = 1; /** The minimum total z extents for a 2d frustum, in meters. */ Frustum2d.minimumZExtents = core_geometry_1.Range1d.createXX(-Frustum2d.minimumZDistance, Frustum2d.minimumZDistance); const maxPriorityAbs = 500; const priorityToZDistanceRatio = Frustum2d.minimumZDistance / maxPriorityAbs; /** Convert display priority to Z. */ function depthFromDisplayPriority(priority) { priority = Math.max(-maxPriorityAbs, Math.min(maxPriorityAbs, priority)); return priority * priorityToZDistanceRatio; } Frustum2d.depthFromDisplayPriority = depthFromDisplayPriority; })(Frustum2d || (exports.Frustum2d = Frustum2d = {})); //# sourceMappingURL=Frustum2d.js.map