@itwin/core-frontend 4.10.0-dev.25 → 4.10.0-dev.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/ViewingSpace.d.ts.map +1 -1
- package/lib/cjs/ViewingSpace.js +3 -0
- package/lib/cjs/ViewingSpace.js.map +1 -1
- package/lib/esm/ViewingSpace.d.ts.map +1 -1
- package/lib/esm/ViewingSpace.js +3 -0
- package/lib/esm/ViewingSpace.js.map +1 -1
- package/lib/public/scripts/parse-imdl-worker.js +1 -1
- package/lib/workers/webpack/parse-imdl-worker.js +1 -1
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewingSpace.d.ts","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACsC,KAAK,EAAE,QAAQ,EAAgC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAW,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EACxK,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAwC,MAAM,oBAAoB,CAAC;AAErG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAE9C,gBAAgB;IACT,aAAa,SAAO;IAC3B;;OAEG;IACH,OAAc,iBAAiB,SAAU;IACzC;;OAEG;IACH,OAAc,cAAc,SAAU;IACtC,wCAAwC;IACxC,SAAgB,UAAU,UAAiB;IAC3C,uCAAuC;IACvC,SAAgB,SAAS,WAAkB;IAC3C,+CAA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
|
|
247
247
|
delta.z = 2.0 * zMax;
|
|
248
248
|
origin.z = -zMax;
|
|
249
|
+
const ds = this.view.displayStyle;
|
|
250
|
+
if (ds.getIsBackgroundMapVisible() && undefined !== ds.getBackgroundMapGeometry())
|
|
251
|
+
this.adjustZPlanes(origin, delta); // make sure view volume includes background map
|
|
249
252
|
}
|
|
250
253
|
else {
|
|
251
254
|
if (view.isCameraOn)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewingSpace.js","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAE8B;AAC9B,oDAAqG;AACrG,2EAAwE;AACxE,+CAA4C;AAE5C,gDAA6C;AAE7C,2CAAwC;AACxC,mEAAgF;AAEhF;;;;;GAKG;AACH,MAAa,YAAY;IAmCvB,sCAAsC;IACtC,IAAW,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,IAAW,IAAI,CAAC,IAAe,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAKvD,6DAA6D;IAC7D,IAAY,SAAS;QACnB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,IAAS,EAAE,EAAQ;QAC5C,IAAI,EAAE,GAAG,IAAI,CAAC;QACd,IAAI,EAAE,EAAE,CAAC;YACP,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACjB,EAAE,GAAG,EAAE,CAAC;QACV,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,gBAAgB;IACT,iBAAiB,CAAC,IAAS,EAAE,EAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,qBAAq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------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\nimport {\r\n AxisOrder, ClipPlaneContainment, Constant, Map4d, Matrix3d, Plane3dByOriginAndUnitNormal, Point3d, Point4d, Range1d, Range2d, Range3d, Transform, Vector3d, XYAndZ, XYZ,\r\n} from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, Frustum, GridOrientationType, Npc, NpcCorners } from \"@itwin/core-common\";\r\nimport { ApproximateTerrainHeights } from \"./ApproximateTerrainHeights\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { Viewport } from \"./Viewport\";\r\nimport { ViewRect } from \"./common/ViewRect\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { getFrustumPlaneIntersectionDepthRange } from \"./BackgroundMapGeometry\";\r\n\r\n/** Describes a [[Viewport]]'s viewing volume, plus its size on the screen. A new\r\n * instance of ViewingSpace is created every time the Viewport's frustum changes.\r\n * @see [[Viewport.viewingSpace]].\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewingSpace {\r\n private readonly _viewRange = new ViewRect(); // scratch variable\r\n private readonly _viewCorners = new Range3d(); // scratch variable\r\n\r\n /** @internal */\r\n public frustFraction = 1.0;\r\n /** Maximum ratio of frontplane to backplane distance for 24 bit non-logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleNonLog24 = 0.0003;\r\n /** Maximum fraction of frontplane to backplane distance for 24 bit logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleLog24 = 1.0E-8;\r\n /** View origin, potentially expanded */\r\n public readonly viewOrigin = new Point3d();\r\n /** View delta, potentially expanded */\r\n public readonly viewDelta = new Vector3d();\r\n /** View origin (from ViewState, unexpanded) */\r\n public readonly viewOriginUnexpanded = new Point3d();\r\n /** View delta (from ViewState, unexpanded) */\r\n public readonly viewDeltaUnexpanded = new Vector3d();\r\n /** View rotation matrix (copied from ViewState) */\r\n public readonly rotation = new Matrix3d();\r\n /** Provides conversions between world and view coordinates. */\r\n public readonly worldToViewMap = Map4d.createIdentity();\r\n /** Providers conversions between world and Npc (non-dimensional perspective) coordinates. */\r\n public readonly worldToNpcMap = Map4d.createIdentity();\r\n /** @internal */\r\n public readonly zClipAdjusted: boolean = false; // were the view z clip planes adjusted due to front/back clipping off?\r\n /** Eye point - undefined if not a perspective projection. */\r\n public readonly eyePoint: Point3d | undefined;\r\n\r\n private _view: ViewState;\r\n\r\n /** The ViewState for this Viewport */\r\n public get view(): ViewState { return this._view; }\r\n public set view(view: ViewState) { this._view = view; }\r\n\r\n private readonly _clientWidth: number;\r\n private readonly _clientHeight: number;\r\n\r\n /** Get the rectangle of this Viewport in ViewCoordinates. */\r\n private get _viewRect(): ViewRect {\r\n this._viewRange.init(0, 0, this._clientWidth, this._clientHeight);\r\n return this._viewRange;\r\n }\r\n\r\n private static _copyOutput(from: XYZ, to?: XYZ) {\r\n let pt = from;\r\n if (to) {\r\n to.setFrom(from);\r\n pt = to;\r\n }\r\n\r\n return pt;\r\n }\r\n\r\n /** @internal */\r\n public toViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n /** @internal */\r\n public fromViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyTransposeVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n\r\n /** Ensure the rotation matrix for this view is aligns the root z with the view out (i.e. a \"2d view\"). */\r\n private alignWithRootZ() {\r\n const zUp = Vector3d.unitZ();\r\n if (zUp.isAlmostEqual(this.rotation.rowZ()))\r\n return;\r\n const r = this.rotation.transpose();\r\n r.setColumn(2, zUp);\r\n Matrix3d.createRigidFromMatrix3d(r, AxisOrder.ZXY, r);\r\n r.transpose(this.rotation);\r\n this.view.setRotation(this.rotation); // Don't let viewState and viewport rotation be different.\r\n }\r\n\r\n private validateCamera() {\r\n const view = this.view;\r\n if (!view.is3d())\r\n return;\r\n\r\n const camera = view.camera;\r\n camera.validateLens();\r\n if (camera.isFocusValid)\r\n return;\r\n\r\n const vDelta = view.getExtents();\r\n const maxDelta = vDelta.x > vDelta.y ? vDelta.x : vDelta.y;\r\n let focusDistance = maxDelta / (2.0 * Math.tan(camera.getLensAngle().radians / 2.0));\r\n\r\n if (focusDistance < vDelta.z / 2.0)\r\n focusDistance = vDelta.z / 2.0;\r\n\r\n const eyePoint = new Point3d(vDelta.x / 2.0, vDelta.y / 2.0, (vDelta.z / 2.0) + focusDistance);\r\n\r\n this.fromViewOrientation(eyePoint);\r\n eyePoint.plus(view.getOrigin(), eyePoint);\r\n camera.setEyePoint(eyePoint);\r\n camera.setFocusDistance(focusDistance);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeightRange(): Range1d | undefined {\r\n const frustum = this.getFrustum();\r\n const cartoRange = Range2d.createNull();\r\n for (let i = 0; i < 8; i++) {\r\n const corner = frustum.getCorner(i);\r\n const carto = this.view.iModel.spatialToCartographicFromEcef(corner);\r\n cartoRange.extendXY(carto.longitude, carto.latitude);\r\n }\r\n\r\n return ApproximateTerrainHeights.instance.getMinimumMaximumHeights(cartoRange);\r\n }\r\n\r\n private static _minDepth = 1; // Allowing very small depth will cause frustum calculations to fail.\r\n\r\n /** Compute the bounding box of this viewing space in [[CoordSystem.World]] coordinates, including the extents of any [[TiledGraphicsProvider]]s registered with the [[Viewport]]. */\r\n public readonly getViewedExtents: () => AxisAlignedBox3d;\r\n\r\n /** Adjust the front and back planes to encompass the entire viewed volume */\r\n private adjustZPlanes(origin: Point3d, delta: Vector3d): void {\r\n const view = this.view;\r\n if (!view.is3d()) // only necessary for 3d views\r\n return;\r\n\r\n delta.z = Math.max(delta.z, ViewingSpace._minDepth);\r\n\r\n const extents = this.getViewedExtents();\r\n const frustum = new Frustum();\r\n const worldToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOrigin, this.viewDelta, false).map as Map4d;\r\n\r\n if (worldToNpc === undefined)\r\n return;\r\n\r\n worldToNpc.transform1.multiplyPoint3dArrayQuietNormalize(frustum.points);\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewedExtentCorners = extents.corners();\r\n\r\n // Only extend depth to include viewed geometry if it is within the frustum. (if viewing global locations).\r\n if (clipPlanes.classifyPointContainment(viewedExtentCorners, false) === ClipPlaneContainment.StronglyOutside)\r\n extents.setNull();\r\n\r\n let depthRange;\r\n let gridPlane;\r\n if (this.view.viewFlags.grid) {\r\n const gridOrigin = this.view.isSpatialView() ? this.view.iModel.globalOrigin : Point3d.create();\r\n switch(this.view.getGridOrientation()) {\r\n case GridOrientationType.WorldXY:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 0, 1));\r\n break;\r\n case GridOrientationType.WorldYZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(1, 0, 0));\r\n break;\r\n case GridOrientationType.WorldXZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 1, 0));\r\n break;\r\n\r\n case GridOrientationType.AuxCoord:\r\n if (this.view.auxiliaryCoordinateSystem)\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, this.view.auxiliaryCoordinateSystem.getRotation().rowZ());\r\n\r\n break;\r\n }\r\n }\r\n const globalGeometry = this.view.displayStyle.getGlobalGeometryAndHeightRange();\r\n if (undefined !== globalGeometry) {\r\n const viewZ = this.rotation.getRow(2);\r\n const eyeDepth = this.eyePoint ? viewZ.dotProduct(this.eyePoint) : undefined;\r\n\r\n depthRange = globalGeometry.geometry.getFrustumIntersectionDepthRange(frustum, extents, globalGeometry.heightRange, gridPlane, this.view.maxGlobalScopeFactor > 1);\r\n\r\n if (eyeDepth !== undefined) {\r\n const maxBackgroundFrontBackRatio = 1.0E6;\r\n const frontDist = Math.max(.1, eyeDepth - depthRange.high);\r\n const backDist = eyeDepth - depthRange.low;\r\n if (backDist / frontDist > maxBackgroundFrontBackRatio)\r\n depthRange.high = eyeDepth - backDist / maxBackgroundFrontBackRatio;\r\n }\r\n } else\r\n depthRange = gridPlane ? getFrustumPlaneIntersectionDepthRange(frustum, gridPlane) : Range1d.createNull();\r\n\r\n if (!extents.isNull) {\r\n const viewZ = this.rotation.getRow(2);\r\n const corners = extents.corners();\r\n for (const corner of corners)\r\n depthRange.extendX(viewZ.dotProduct(corner));\r\n }\r\n\r\n if (depthRange.isNull)\r\n return;\r\n\r\n this.rotation.multiplyVectorInPlace(origin); // put origin in view coordinates\r\n origin.z = depthRange.low; // set origin to back of viewed extents\r\n delta.z = Math.max(depthRange.high - depthRange.low, ViewingSpace._minDepth); // and delta to front of viewed extents\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n\r\n if (!view.isCameraOn)\r\n return;\r\n\r\n // if the camera is on, we need to make sure that the viewed volume is not behind the eye\r\n const eyeOrg = this.eyePoint!.minus(origin);\r\n this.rotation.multiplyVectorInPlace(eyeOrg);\r\n\r\n // if the distance from the eye to origin in less than 1 meter, move the origin away from the eye. Usually, this means\r\n // that the camera is outside the viewed extents and pointed away from it. There's nothing to see anyway.\r\n if (eyeOrg.z < 1.0) {\r\n this.rotation.multiplyVectorInPlace(origin);\r\n origin.z -= (2.0 - eyeOrg.z);\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n delta.z = 1.0;\r\n return;\r\n }\r\n\r\n // if part of the viewed extents are behind the eye, don't include that.\r\n if (delta.z > eyeOrg.z)\r\n delta.z = eyeOrg.z;\r\n }\r\n\r\n /* get the mapping from NPC to view\r\n * @internal\r\n */\r\n public calcNpcToView(): Map4d {\r\n const corners = this.getViewCorners();\r\n const map = Map4d.createBoxMap(NpcCorners[Npc._000], NpcCorners[Npc._111], corners.low, corners.high);\r\n\r\n // The map may be undefined if the view rect's width or height is zero.\r\n return undefined === map ? Map4d.createIdentity() : map;\r\n }\r\n\r\n /* Get the extents of this view, in ViewCoordinates, as a Range3d */\r\n public getViewCorners(): Range3d {\r\n const corners = this._viewCorners;\r\n const viewRect = this._viewRect;\r\n corners.high.x = viewRect.right;\r\n corners.low.y = viewRect.bottom; // y's are swapped on the screen!\r\n corners.low.x = 0;\r\n corners.high.y = 0;\r\n corners.low.z = -32767;\r\n corners.high.z = 32767;\r\n return corners;\r\n }\r\n\r\n private constructor(vp: Viewport) {\r\n const view = this._view = vp.view;\r\n const viewRect = vp.viewRect;\r\n this._clientWidth = viewRect.width;\r\n this._clientHeight = viewRect.height;\r\n const origin = view.getOrigin().clone();\r\n const delta = view.getExtents().clone();\r\n this.rotation.setFrom(view.getRotation());\r\n\r\n this.getViewedExtents = () => {\r\n const extents = this._view.getViewedExtents();\r\n vp.forEachTiledGraphicsProvider((provider) => {\r\n provider.forEachTileTreeRef(vp, (ref) => {\r\n ref.unionFitRange(extents);\r\n });\r\n });\r\n\r\n return extents;\r\n };\r\n\r\n // first, make sure none of the deltas are negative\r\n delta.x = Math.abs(delta.x);\r\n delta.y = Math.abs(delta.y);\r\n delta.z = Math.abs(delta.z);\r\n\r\n this.viewOriginUnexpanded.setFrom(origin);\r\n this.viewDeltaUnexpanded.setFrom(delta);\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n this.zClipAdjusted = false;\r\n this.eyePoint = undefined;\r\n\r\n if (view.is3d()) {\r\n if (!view.allow3dManipulations()) {\r\n // we're in a \"2d\" view of a physical model. That means that we must have our orientation with z out of the screen with z=0 at the center.\r\n this.alignWithRootZ(); // make sure we're in a z Up view\r\n\r\n const extents = this.getViewedExtents();\r\n if (extents.isNull) {\r\n extents.low.z = Frustum2d.minimumZExtents.low;\r\n extents.high.z = Frustum2d.minimumZExtents.high;\r\n }\r\n\r\n let zMax = Math.max(Math.abs(extents.low.z), Math.abs(extents.high.z));\r\n zMax = Math.max(zMax, 1.0); // make sure we have at least +-1m. Data may be purely planar\r\n delta.z = 2.0 * zMax;\r\n origin.z = -zMax;\r\n } else {\r\n if (view.isCameraOn)\r\n this.validateCamera();\r\n\r\n if (view.isCameraOn)\r\n this.eyePoint = view.camera.getEyePoint().clone();\r\n\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes entire volume of view\r\n\r\n // if the camera is on, don't allow front plane behind camera\r\n if (this.eyePoint) {\r\n const eyeOrg = this.eyePoint.minus(origin); // vector from eye to origin\r\n this.toViewOrientation(eyeOrg);\r\n\r\n const frontDist = eyeOrg.z - delta.z; // front distance is backDist - delta.z\r\n\r\n // allow ViewState to specify a minimum front dist, but in no case less than 6 inches\r\n const minFrontDist = Math.max(15.2 * Constant.oneCentimeter, view.forceMinFrontDist);\r\n if (frontDist < minFrontDist) {\r\n // camera is too close to front plane, move origin away from eye to maintain a minimum front distance.\r\n this.toViewOrientation(origin);\r\n origin.z -= (minFrontDist - frontDist);\r\n this.fromViewOrientation(origin);\r\n }\r\n }\r\n\r\n // if we moved the z planes, set the \"zClipAdjusted\" flag.\r\n if (!origin.isExactEqual(this.viewOriginUnexpanded) || !delta.isExactEqual(this.viewDeltaUnexpanded))\r\n this.zClipAdjusted = true;\r\n }\r\n } else { // 2d viewport\r\n this.alignWithRootZ();\r\n }\r\n\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n\r\n const newRootToNpc = this.view.computeWorldToNpc(this.rotation, origin, delta, !this.view.displayStyle.getIsBackgroundMapVisible() /* if displaying background map, don't enforce front/back ratio as no Z-Buffer */);\r\n if (newRootToNpc.map === undefined) {\r\n this.frustFraction = 0; // invalid frustum\r\n return;\r\n }\r\n\r\n this.worldToNpcMap.setFrom(newRootToNpc.map);\r\n this.frustFraction = newRootToNpc.frustFraction;\r\n this.worldToViewMap.setFrom(this.calcNpcToView().multiplyMapMap(this.worldToNpcMap));\r\n }\r\n\r\n /** Create from a Viewport. */\r\n public static createFromViewport(vp: Viewport): ViewingSpace | undefined {\r\n return new ViewingSpace(vp);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.Npc */\r\n public viewToNpcArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n scrToNpcTran.multiplyPoint3dArrayInPlace(pts);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.View */\r\n public npcToViewArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n for (const p of pts)\r\n corners.fractionToPoint(p.x, p.y, p.z, p);\r\n }\r\n\r\n /** Convert a point from CoordSystem.View to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToNpc(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n return scrToNpcTran.multiplyPoint3d(pt, out);\r\n }\r\n\r\n /** Convert a point from CoordSystem.Npc to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToView(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n return corners.fractionToPoint(pt.x, pt.y, pt.z, out);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.Npc */\r\n public worldToNpcArray(pts: Point3d[]): void { this.worldToNpcMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.World */\r\n public npcToWorldArray(pts: Point3d[]): void { this.worldToNpcMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View */\r\n public worldToViewArray(pts: Point3d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View, as Point4ds */\r\n public worldToView4dArray(worldPts: Point3d[], viewPts: Point4d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArray(worldPts, viewPts); }\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.World */\r\n public viewToWorldArray(pts: Point3d[]) { this.worldToViewMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.View as Point4ds to CoordSystem.World */\r\n public view4dToWorldArray(viewPts: Point4d[], worldPts: Point3d[]): void { this.worldToViewMap.transform1.multiplyPoint4dArrayQuietRenormalize(viewPts, worldPts); }\r\n\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToNpc(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform0.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.Npc to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToWorld(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform1.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToView(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform0.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View as Point4d\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point4d is created.\r\n */\r\n public worldToView4d(input: XYAndZ, out?: Point4d): Point4d { return this.worldToViewMap.transform0.multiplyPoint3d(input, 1.0, out); }\r\n /**\r\n * Convert a point from CoordSystem.View to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToWorld(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.View as a Point4d to CoordSystem.View\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public view4dToWorld(input: Point4d, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyXYZWQuietRenormalize(input.x, input.y, input.z, input.w, out); }\r\n\r\n /** Get an 8-point Frustum corresponding to the 8 corners of the Viewport in the specified coordinate system.\r\n *\r\n * There are two sets of corners that may be of interest.\r\n * The \"adjusted\" box is the one that is computed by examining the \"viewed extents\" and moving\r\n * the front and back planes to enclose everything in the view.\r\n * The \"unadjusted\" box is the one that is stored in the ViewState.\r\n * @param sys Coordinate system for points\r\n * @param adjustedBox If true, retrieve the adjusted box. Otherwise retrieve the box that came from the view definition.\r\n * @param box optional Frustum for return value\r\n * @return the view frustum\r\n * @note The \"adjusted\" box may be either larger or smaller than the \"unadjusted\" box.\r\n */\r\n public getFrustum(sys: CoordSystem = CoordSystem.World, adjustedBox: boolean = true, box?: Frustum): Frustum {\r\n box = box ? box.initNpc() : new Frustum();\r\n\r\n // if they are looking for the \"unexpanded\" (that is before f/b clipping expansion) box, we need to get the npc\r\n // coordinates that correspond to the unexpanded box in the npc space of the Expanded view (that's the basis for all\r\n // of the root-based maps.)\r\n if (!adjustedBox && this.zClipAdjusted) {\r\n // to get unexpanded box, we have to go recompute rootToNpc from original View.\r\n const ueRootToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOriginUnexpanded, this.viewDeltaUnexpanded);\r\n if (undefined === ueRootToNpc.map)\r\n return box; // invalid frustum\r\n\r\n // get the root corners of the unexpanded box\r\n const ueRootBox = new Frustum();\r\n ueRootToNpc.map.transform1.multiplyPoint3dArrayQuietNormalize(ueRootBox.points);\r\n\r\n // and convert them to npc coordinates of the expanded view\r\n this.worldToNpcArray(ueRootBox.points);\r\n box.setFrom(ueRootBox);\r\n }\r\n\r\n // now convert from NPC space to the specified coordinate system.\r\n switch (sys) {\r\n case CoordSystem.View:\r\n this.npcToViewArray(box.points);\r\n break;\r\n\r\n case CoordSystem.World:\r\n this.npcToWorldArray(box.points);\r\n break;\r\n }\r\n return box;\r\n }\r\n\r\n /** @internal */\r\n public getPixelSizeAtPoint(inPoint?: Point3d) {\r\n const viewPt = !!inPoint ? this.worldToView(inPoint) : this.npcToView(new Point3d(0.5, 0.5, 0.5));\r\n const viewPt2 = new Point3d(viewPt.x + 1.0, viewPt.y, viewPt.z);\r\n return this.viewToWorld(viewPt).distance(this.viewToWorld(viewPt2));\r\n }\r\n\r\n /** @internal */\r\n public getPreloadFrustum(transformOrScale?: Transform | number, result?: Frustum) {\r\n const viewFrustum = this.getFrustum(CoordSystem.World, true);\r\n\r\n if (transformOrScale && transformOrScale instanceof Transform) {\r\n return viewFrustum.transformBy(transformOrScale, result);\r\n } else {\r\n const scale = transformOrScale === undefined ? 2 : transformOrScale;\r\n const expandedFrustum = viewFrustum.clone(result);\r\n expandedFrustum.scaleXYAboutCenter(scale);\r\n return expandedFrustum;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ViewingSpace.js","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAE8B;AAC9B,oDAAqG;AACrG,2EAAwE;AACxE,+CAA4C;AAE5C,gDAA6C;AAE7C,2CAAwC;AACxC,mEAAgF;AAEhF;;;;;GAKG;AACH,MAAa,YAAY;IAmCvB,sCAAsC;IACtC,IAAW,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,IAAW,IAAI,CAAC,IAAe,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAKvD,6DAA6D;IAC7D,IAAY,SAAS;QACnB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CA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UAAU,CAAC,yBAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE7D,IAAI,gBAAgB,IAAI,gBAAgB,YAAY,yBAAS,EAAE,CAAC;YAC9D,OAAO,WAAW,CAAC,WAAW,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC;YACpE,MAAM,eAAe,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAClD,eAAe,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;YAC1C,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;;AA9eH,oCA+eC;AAzeC;;GAEG;AACW,8BAAiB,GAAG,MAAM,AAAT,CAAU;AACzC;;GAEG;AACW,2BAAc,GAAG,MAAM,AAAT,CAAU;AAoGvB,sBAAS,GAAG,CAAC,AAAJ,CAAK,CAAC,qEAAqE","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\nimport {\r\n AxisOrder, ClipPlaneContainment, Constant, Map4d, Matrix3d, Plane3dByOriginAndUnitNormal, Point3d, Point4d, Range1d, Range2d, Range3d, Transform, Vector3d, XYAndZ, XYZ,\r\n} from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, Frustum, GridOrientationType, Npc, NpcCorners } from \"@itwin/core-common\";\r\nimport { ApproximateTerrainHeights } from \"./ApproximateTerrainHeights\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { Viewport } from \"./Viewport\";\r\nimport { ViewRect } from \"./common/ViewRect\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { getFrustumPlaneIntersectionDepthRange } from \"./BackgroundMapGeometry\";\r\n\r\n/** Describes a [[Viewport]]'s viewing volume, plus its size on the screen. A new\r\n * instance of ViewingSpace is created every time the Viewport's frustum changes.\r\n * @see [[Viewport.viewingSpace]].\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewingSpace {\r\n private readonly _viewRange = new ViewRect(); // scratch variable\r\n private readonly _viewCorners = new Range3d(); // scratch variable\r\n\r\n /** @internal */\r\n public frustFraction = 1.0;\r\n /** Maximum ratio of frontplane to backplane distance for 24 bit non-logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleNonLog24 = 0.0003;\r\n /** Maximum fraction of frontplane to backplane distance for 24 bit logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleLog24 = 1.0E-8;\r\n /** View origin, potentially expanded */\r\n public readonly viewOrigin = new Point3d();\r\n /** View delta, potentially expanded */\r\n public readonly viewDelta = new Vector3d();\r\n /** View origin (from ViewState, unexpanded) */\r\n public readonly viewOriginUnexpanded = new Point3d();\r\n /** View delta (from ViewState, unexpanded) */\r\n public readonly viewDeltaUnexpanded = new Vector3d();\r\n /** View rotation matrix (copied from ViewState) */\r\n public readonly rotation = new Matrix3d();\r\n /** Provides conversions between world and view coordinates. */\r\n public readonly worldToViewMap = Map4d.createIdentity();\r\n /** Providers conversions between world and Npc (non-dimensional perspective) coordinates. */\r\n public readonly worldToNpcMap = Map4d.createIdentity();\r\n /** @internal */\r\n public readonly zClipAdjusted: boolean = false; // were the view z clip planes adjusted due to front/back clipping off?\r\n /** Eye point - undefined if not a perspective projection. */\r\n public readonly eyePoint: Point3d | undefined;\r\n\r\n private _view: ViewState;\r\n\r\n /** The ViewState for this Viewport */\r\n public get view(): ViewState { return this._view; }\r\n public set view(view: ViewState) { this._view = view; }\r\n\r\n private readonly _clientWidth: number;\r\n private readonly _clientHeight: number;\r\n\r\n /** Get the rectangle of this Viewport in ViewCoordinates. */\r\n private get _viewRect(): ViewRect {\r\n this._viewRange.init(0, 0, this._clientWidth, this._clientHeight);\r\n return this._viewRange;\r\n }\r\n\r\n private static _copyOutput(from: XYZ, to?: XYZ) {\r\n let pt = from;\r\n if (to) {\r\n to.setFrom(from);\r\n pt = to;\r\n }\r\n\r\n return pt;\r\n }\r\n\r\n /** @internal */\r\n public toViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n /** @internal */\r\n public fromViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyTransposeVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n\r\n /** Ensure the rotation matrix for this view is aligns the root z with the view out (i.e. a \"2d view\"). */\r\n private alignWithRootZ() {\r\n const zUp = Vector3d.unitZ();\r\n if (zUp.isAlmostEqual(this.rotation.rowZ()))\r\n return;\r\n const r = this.rotation.transpose();\r\n r.setColumn(2, zUp);\r\n Matrix3d.createRigidFromMatrix3d(r, AxisOrder.ZXY, r);\r\n r.transpose(this.rotation);\r\n this.view.setRotation(this.rotation); // Don't let viewState and viewport rotation be different.\r\n }\r\n\r\n private validateCamera() {\r\n const view = this.view;\r\n if (!view.is3d())\r\n return;\r\n\r\n const camera = view.camera;\r\n camera.validateLens();\r\n if (camera.isFocusValid)\r\n return;\r\n\r\n const vDelta = view.getExtents();\r\n const maxDelta = vDelta.x > vDelta.y ? vDelta.x : vDelta.y;\r\n let focusDistance = maxDelta / (2.0 * Math.tan(camera.getLensAngle().radians / 2.0));\r\n\r\n if (focusDistance < vDelta.z / 2.0)\r\n focusDistance = vDelta.z / 2.0;\r\n\r\n const eyePoint = new Point3d(vDelta.x / 2.0, vDelta.y / 2.0, (vDelta.z / 2.0) + focusDistance);\r\n\r\n this.fromViewOrientation(eyePoint);\r\n eyePoint.plus(view.getOrigin(), eyePoint);\r\n camera.setEyePoint(eyePoint);\r\n camera.setFocusDistance(focusDistance);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeightRange(): Range1d | undefined {\r\n const frustum = this.getFrustum();\r\n const cartoRange = Range2d.createNull();\r\n for (let i = 0; i < 8; i++) {\r\n const corner = frustum.getCorner(i);\r\n const carto = this.view.iModel.spatialToCartographicFromEcef(corner);\r\n cartoRange.extendXY(carto.longitude, carto.latitude);\r\n }\r\n\r\n return ApproximateTerrainHeights.instance.getMinimumMaximumHeights(cartoRange);\r\n }\r\n\r\n private static _minDepth = 1; // Allowing very small depth will cause frustum calculations to fail.\r\n\r\n /** Compute the bounding box of this viewing space in [[CoordSystem.World]] coordinates, including the extents of any [[TiledGraphicsProvider]]s registered with the [[Viewport]]. */\r\n public readonly getViewedExtents: () => AxisAlignedBox3d;\r\n\r\n /** Adjust the front and back planes to encompass the entire viewed volume */\r\n private adjustZPlanes(origin: Point3d, delta: Vector3d): void {\r\n const view = this.view;\r\n if (!view.is3d()) // only necessary for 3d views\r\n return;\r\n\r\n delta.z = Math.max(delta.z, ViewingSpace._minDepth);\r\n\r\n const extents = this.getViewedExtents();\r\n const frustum = new Frustum();\r\n const worldToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOrigin, this.viewDelta, false).map as Map4d;\r\n\r\n if (worldToNpc === undefined)\r\n return;\r\n\r\n worldToNpc.transform1.multiplyPoint3dArrayQuietNormalize(frustum.points);\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewedExtentCorners = extents.corners();\r\n\r\n // Only extend depth to include viewed geometry if it is within the frustum. (if viewing global locations).\r\n if (clipPlanes.classifyPointContainment(viewedExtentCorners, false) === ClipPlaneContainment.StronglyOutside)\r\n extents.setNull();\r\n\r\n let depthRange;\r\n let gridPlane;\r\n if (this.view.viewFlags.grid) {\r\n const gridOrigin = this.view.isSpatialView() ? this.view.iModel.globalOrigin : Point3d.create();\r\n switch(this.view.getGridOrientation()) {\r\n case GridOrientationType.WorldXY:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 0, 1));\r\n break;\r\n case GridOrientationType.WorldYZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(1, 0, 0));\r\n break;\r\n case GridOrientationType.WorldXZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 1, 0));\r\n break;\r\n\r\n case GridOrientationType.AuxCoord:\r\n if (this.view.auxiliaryCoordinateSystem)\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, this.view.auxiliaryCoordinateSystem.getRotation().rowZ());\r\n\r\n break;\r\n }\r\n }\r\n const globalGeometry = this.view.displayStyle.getGlobalGeometryAndHeightRange();\r\n if (undefined !== globalGeometry) {\r\n const viewZ = this.rotation.getRow(2);\r\n const eyeDepth = this.eyePoint ? viewZ.dotProduct(this.eyePoint) : undefined;\r\n\r\n depthRange = globalGeometry.geometry.getFrustumIntersectionDepthRange(frustum, extents, globalGeometry.heightRange, gridPlane, this.view.maxGlobalScopeFactor > 1);\r\n\r\n if (eyeDepth !== undefined) {\r\n const maxBackgroundFrontBackRatio = 1.0E6;\r\n const frontDist = Math.max(.1, eyeDepth - depthRange.high);\r\n const backDist = eyeDepth - depthRange.low;\r\n if (backDist / frontDist > maxBackgroundFrontBackRatio)\r\n depthRange.high = eyeDepth - backDist / maxBackgroundFrontBackRatio;\r\n }\r\n } else\r\n depthRange = gridPlane ? getFrustumPlaneIntersectionDepthRange(frustum, gridPlane) : Range1d.createNull();\r\n\r\n if (!extents.isNull) {\r\n const viewZ = this.rotation.getRow(2);\r\n const corners = extents.corners();\r\n for (const corner of corners)\r\n depthRange.extendX(viewZ.dotProduct(corner));\r\n }\r\n\r\n if (depthRange.isNull)\r\n return;\r\n\r\n this.rotation.multiplyVectorInPlace(origin); // put origin in view coordinates\r\n origin.z = depthRange.low; // set origin to back of viewed extents\r\n delta.z = Math.max(depthRange.high - depthRange.low, ViewingSpace._minDepth); // and delta to front of viewed extents\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n\r\n if (!view.isCameraOn)\r\n return;\r\n\r\n // if the camera is on, we need to make sure that the viewed volume is not behind the eye\r\n const eyeOrg = this.eyePoint!.minus(origin);\r\n this.rotation.multiplyVectorInPlace(eyeOrg);\r\n\r\n // if the distance from the eye to origin in less than 1 meter, move the origin away from the eye. Usually, this means\r\n // that the camera is outside the viewed extents and pointed away from it. There's nothing to see anyway.\r\n if (eyeOrg.z < 1.0) {\r\n this.rotation.multiplyVectorInPlace(origin);\r\n origin.z -= (2.0 - eyeOrg.z);\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n delta.z = 1.0;\r\n return;\r\n }\r\n\r\n // if part of the viewed extents are behind the eye, don't include that.\r\n if (delta.z > eyeOrg.z)\r\n delta.z = eyeOrg.z;\r\n }\r\n\r\n /* get the mapping from NPC to view\r\n * @internal\r\n */\r\n public calcNpcToView(): Map4d {\r\n const corners = this.getViewCorners();\r\n const map = Map4d.createBoxMap(NpcCorners[Npc._000], NpcCorners[Npc._111], corners.low, corners.high);\r\n\r\n // The map may be undefined if the view rect's width or height is zero.\r\n return undefined === map ? Map4d.createIdentity() : map;\r\n }\r\n\r\n /* Get the extents of this view, in ViewCoordinates, as a Range3d */\r\n public getViewCorners(): Range3d {\r\n const corners = this._viewCorners;\r\n const viewRect = this._viewRect;\r\n corners.high.x = viewRect.right;\r\n corners.low.y = viewRect.bottom; // y's are swapped on the screen!\r\n corners.low.x = 0;\r\n corners.high.y = 0;\r\n corners.low.z = -32767;\r\n corners.high.z = 32767;\r\n return corners;\r\n }\r\n\r\n private constructor(vp: Viewport) {\r\n const view = this._view = vp.view;\r\n const viewRect = vp.viewRect;\r\n this._clientWidth = viewRect.width;\r\n this._clientHeight = viewRect.height;\r\n const origin = view.getOrigin().clone();\r\n const delta = view.getExtents().clone();\r\n this.rotation.setFrom(view.getRotation());\r\n\r\n this.getViewedExtents = () => {\r\n const extents = this._view.getViewedExtents();\r\n vp.forEachTiledGraphicsProvider((provider) => {\r\n provider.forEachTileTreeRef(vp, (ref) => {\r\n ref.unionFitRange(extents);\r\n });\r\n });\r\n\r\n return extents;\r\n };\r\n\r\n // first, make sure none of the deltas are negative\r\n delta.x = Math.abs(delta.x);\r\n delta.y = Math.abs(delta.y);\r\n delta.z = Math.abs(delta.z);\r\n\r\n this.viewOriginUnexpanded.setFrom(origin);\r\n this.viewDeltaUnexpanded.setFrom(delta);\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n this.zClipAdjusted = false;\r\n this.eyePoint = undefined;\r\n\r\n if (view.is3d()) {\r\n if (!view.allow3dManipulations()) {\r\n // we're in a \"2d\" view of a physical model. That means that we must have our orientation with z out of the screen with z=0 at the center.\r\n this.alignWithRootZ(); // make sure we're in a z Up view\r\n\r\n const extents = this.getViewedExtents();\r\n if (extents.isNull) {\r\n extents.low.z = Frustum2d.minimumZExtents.low;\r\n extents.high.z = Frustum2d.minimumZExtents.high;\r\n }\r\n\r\n let zMax = Math.max(Math.abs(extents.low.z), Math.abs(extents.high.z));\r\n zMax = Math.max(zMax, 1.0); // make sure we have at least +-1m. Data may be purely planar\r\n delta.z = 2.0 * zMax;\r\n origin.z = -zMax;\r\n const ds = this.view.displayStyle;\r\n if (ds.getIsBackgroundMapVisible() && undefined !== ds.getBackgroundMapGeometry())\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes background map\r\n } else {\r\n if (view.isCameraOn)\r\n this.validateCamera();\r\n\r\n if (view.isCameraOn)\r\n this.eyePoint = view.camera.getEyePoint().clone();\r\n\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes entire volume of view\r\n\r\n // if the camera is on, don't allow front plane behind camera\r\n if (this.eyePoint) {\r\n const eyeOrg = this.eyePoint.minus(origin); // vector from eye to origin\r\n this.toViewOrientation(eyeOrg);\r\n\r\n const frontDist = eyeOrg.z - delta.z; // front distance is backDist - delta.z\r\n\r\n // allow ViewState to specify a minimum front dist, but in no case less than 6 inches\r\n const minFrontDist = Math.max(15.2 * Constant.oneCentimeter, view.forceMinFrontDist);\r\n if (frontDist < minFrontDist) {\r\n // camera is too close to front plane, move origin away from eye to maintain a minimum front distance.\r\n this.toViewOrientation(origin);\r\n origin.z -= (minFrontDist - frontDist);\r\n this.fromViewOrientation(origin);\r\n }\r\n }\r\n\r\n // if we moved the z planes, set the \"zClipAdjusted\" flag.\r\n if (!origin.isExactEqual(this.viewOriginUnexpanded) || !delta.isExactEqual(this.viewDeltaUnexpanded))\r\n this.zClipAdjusted = true;\r\n }\r\n } else { // 2d viewport\r\n this.alignWithRootZ();\r\n }\r\n\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n\r\n const newRootToNpc = this.view.computeWorldToNpc(this.rotation, origin, delta, !this.view.displayStyle.getIsBackgroundMapVisible() /* if displaying background map, don't enforce front/back ratio as no Z-Buffer */);\r\n if (newRootToNpc.map === undefined) {\r\n this.frustFraction = 0; // invalid frustum\r\n return;\r\n }\r\n\r\n this.worldToNpcMap.setFrom(newRootToNpc.map);\r\n this.frustFraction = newRootToNpc.frustFraction;\r\n this.worldToViewMap.setFrom(this.calcNpcToView().multiplyMapMap(this.worldToNpcMap));\r\n }\r\n\r\n /** Create from a Viewport. */\r\n public static createFromViewport(vp: Viewport): ViewingSpace | undefined {\r\n return new ViewingSpace(vp);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.Npc */\r\n public viewToNpcArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n scrToNpcTran.multiplyPoint3dArrayInPlace(pts);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.View */\r\n public npcToViewArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n for (const p of pts)\r\n corners.fractionToPoint(p.x, p.y, p.z, p);\r\n }\r\n\r\n /** Convert a point from CoordSystem.View to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToNpc(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n return scrToNpcTran.multiplyPoint3d(pt, out);\r\n }\r\n\r\n /** Convert a point from CoordSystem.Npc to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToView(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n return corners.fractionToPoint(pt.x, pt.y, pt.z, out);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.Npc */\r\n public worldToNpcArray(pts: Point3d[]): void { this.worldToNpcMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.World */\r\n public npcToWorldArray(pts: Point3d[]): void { this.worldToNpcMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View */\r\n public worldToViewArray(pts: Point3d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View, as Point4ds */\r\n public worldToView4dArray(worldPts: Point3d[], viewPts: Point4d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArray(worldPts, viewPts); }\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.World */\r\n public viewToWorldArray(pts: Point3d[]) { this.worldToViewMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.View as Point4ds to CoordSystem.World */\r\n public view4dToWorldArray(viewPts: Point4d[], worldPts: Point3d[]): void { this.worldToViewMap.transform1.multiplyPoint4dArrayQuietRenormalize(viewPts, worldPts); }\r\n\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToNpc(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform0.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.Npc to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToWorld(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform1.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToView(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform0.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View as Point4d\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point4d is created.\r\n */\r\n public worldToView4d(input: XYAndZ, out?: Point4d): Point4d { return this.worldToViewMap.transform0.multiplyPoint3d(input, 1.0, out); }\r\n /**\r\n * Convert a point from CoordSystem.View to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToWorld(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.View as a Point4d to CoordSystem.View\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public view4dToWorld(input: Point4d, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyXYZWQuietRenormalize(input.x, input.y, input.z, input.w, out); }\r\n\r\n /** Get an 8-point Frustum corresponding to the 8 corners of the Viewport in the specified coordinate system.\r\n *\r\n * There are two sets of corners that may be of interest.\r\n * The \"adjusted\" box is the one that is computed by examining the \"viewed extents\" and moving\r\n * the front and back planes to enclose everything in the view.\r\n * The \"unadjusted\" box is the one that is stored in the ViewState.\r\n * @param sys Coordinate system for points\r\n * @param adjustedBox If true, retrieve the adjusted box. Otherwise retrieve the box that came from the view definition.\r\n * @param box optional Frustum for return value\r\n * @return the view frustum\r\n * @note The \"adjusted\" box may be either larger or smaller than the \"unadjusted\" box.\r\n */\r\n public getFrustum(sys: CoordSystem = CoordSystem.World, adjustedBox: boolean = true, box?: Frustum): Frustum {\r\n box = box ? box.initNpc() : new Frustum();\r\n\r\n // if they are looking for the \"unexpanded\" (that is before f/b clipping expansion) box, we need to get the npc\r\n // coordinates that correspond to the unexpanded box in the npc space of the Expanded view (that's the basis for all\r\n // of the root-based maps.)\r\n if (!adjustedBox && this.zClipAdjusted) {\r\n // to get unexpanded box, we have to go recompute rootToNpc from original View.\r\n const ueRootToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOriginUnexpanded, this.viewDeltaUnexpanded);\r\n if (undefined === ueRootToNpc.map)\r\n return box; // invalid frustum\r\n\r\n // get the root corners of the unexpanded box\r\n const ueRootBox = new Frustum();\r\n ueRootToNpc.map.transform1.multiplyPoint3dArrayQuietNormalize(ueRootBox.points);\r\n\r\n // and convert them to npc coordinates of the expanded view\r\n this.worldToNpcArray(ueRootBox.points);\r\n box.setFrom(ueRootBox);\r\n }\r\n\r\n // now convert from NPC space to the specified coordinate system.\r\n switch (sys) {\r\n case CoordSystem.View:\r\n this.npcToViewArray(box.points);\r\n break;\r\n\r\n case CoordSystem.World:\r\n this.npcToWorldArray(box.points);\r\n break;\r\n }\r\n return box;\r\n }\r\n\r\n /** @internal */\r\n public getPixelSizeAtPoint(inPoint?: Point3d) {\r\n const viewPt = !!inPoint ? this.worldToView(inPoint) : this.npcToView(new Point3d(0.5, 0.5, 0.5));\r\n const viewPt2 = new Point3d(viewPt.x + 1.0, viewPt.y, viewPt.z);\r\n return this.viewToWorld(viewPt).distance(this.viewToWorld(viewPt2));\r\n }\r\n\r\n /** @internal */\r\n public getPreloadFrustum(transformOrScale?: Transform | number, result?: Frustum) {\r\n const viewFrustum = this.getFrustum(CoordSystem.World, true);\r\n\r\n if (transformOrScale && transformOrScale instanceof Transform) {\r\n return viewFrustum.transformBy(transformOrScale, result);\r\n } else {\r\n const scale = transformOrScale === undefined ? 2 : transformOrScale;\r\n const expandedFrustum = viewFrustum.clone(result);\r\n expandedFrustum.scaleXYAboutCenter(scale);\r\n return expandedFrustum;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewingSpace.d.ts","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACsC,KAAK,EAAE,QAAQ,EAAgC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAW,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EACxK,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAwC,MAAM,oBAAoB,CAAC;AAErG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAE9C,gBAAgB;IACT,aAAa,SAAO;IAC3B;;OAEG;IACH,OAAc,iBAAiB,SAAU;IACzC;;OAEG;IACH,OAAc,cAAc,SAAU;IACtC,wCAAwC;IACxC,SAAgB,UAAU,UAAiB;IAC3C,uCAAuC;IACvC,SAAgB,SAAS,WAAkB;IAC3C,+CAA+C;IAC/C,SAAgB,oBAAoB,UAAiB;IACrD,8CAA8C;IAC9C,SAAgB,mBAAmB,WAAkB;IACrD,mDAAmD;IACnD,SAAgB,QAAQ,WAAkB;IAC1C,+DAA+D;IAC/D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E;IACtC,wFAAwF;IACjF,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI;IAExE;;;;OAIG;IACI,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IACrD;;;;OAIG;IACI,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IACrD;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IACzD;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IAC3D;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IACzD;;;;OAIG;IACI,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IAE5D;;;;;;;;;;;OAWG;IACI,UAAU,CAAC,GAAG,GAAE,WAA+B,EAAE,WAAW,GAAE,OAAc,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO;IAkC5G,gBAAgB;IACT,mBAAmB,CAAC,OAAO,CAAC,EAAE,OAAO;IAM5C,gBAAgB;IACT,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO;CAYjF"}
|
package/lib/esm/ViewingSpace.js
CHANGED
|
@@ -243,6 +243,9 @@ export class ViewingSpace {
|
|
|
243
243
|
zMax = Math.max(zMax, 1.0); // make sure we have at least +-1m. Data may be purely planar
|
|
244
244
|
delta.z = 2.0 * zMax;
|
|
245
245
|
origin.z = -zMax;
|
|
246
|
+
const ds = this.view.displayStyle;
|
|
247
|
+
if (ds.getIsBackgroundMapVisible() && undefined !== ds.getBackgroundMapGeometry())
|
|
248
|
+
this.adjustZPlanes(origin, delta); // make sure view volume includes background map
|
|
246
249
|
}
|
|
247
250
|
else {
|
|
248
251
|
if (view.isCameraOn)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewingSpace.js","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,4BAA4B,EAAE,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAC3J,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAoB,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qCAAqC,EAAE,MAAM,yBAAyB,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAmCvB,sCAAsC;IACtC,IAAW,IAAI,KAAgB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnD,IAAW,IAAI,CAAC,IAAe,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAKvD,6DAA6D;IAC7D,IAAY,SAAS;QACnB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,I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CAAC;YAC1C,OAAO,eAAe,CAAC;QACzB,CAAC;IACH,CAAC;;AAreD;;GAEG;AACW,8BAAiB,GAAG,MAAM,AAAT,CAAU;AACzC;;GAEG;AACW,2BAAc,GAAG,MAAM,AAAT,CAAU;AAoGvB,sBAAS,GAAG,CAAC,AAAJ,CAAK,CAAC,qEAAqE","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\nimport {\r\n AxisOrder, ClipPlaneContainment, Constant, Map4d, Matrix3d, Plane3dByOriginAndUnitNormal, Point3d, Point4d, Range1d, Range2d, Range3d, Transform, Vector3d, XYAndZ, XYZ,\r\n} from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, Frustum, GridOrientationType, Npc, NpcCorners } from \"@itwin/core-common\";\r\nimport { ApproximateTerrainHeights } from \"./ApproximateTerrainHeights\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { Viewport } from \"./Viewport\";\r\nimport { ViewRect } from \"./common/ViewRect\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { getFrustumPlaneIntersectionDepthRange } from \"./BackgroundMapGeometry\";\r\n\r\n/** Describes a [[Viewport]]'s viewing volume, plus its size on the screen. A new\r\n * instance of ViewingSpace is created every time the Viewport's frustum changes.\r\n * @see [[Viewport.viewingSpace]].\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewingSpace {\r\n private readonly _viewRange = new ViewRect(); // scratch variable\r\n private readonly _viewCorners = new Range3d(); // scratch variable\r\n\r\n /** @internal */\r\n public frustFraction = 1.0;\r\n /** Maximum ratio of frontplane to backplane distance for 24 bit non-logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleNonLog24 = 0.0003;\r\n /** Maximum fraction of frontplane to backplane distance for 24 bit logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleLog24 = 1.0E-8;\r\n /** View origin, potentially expanded */\r\n public readonly viewOrigin = new Point3d();\r\n /** View delta, potentially expanded */\r\n public readonly viewDelta = new Vector3d();\r\n /** View origin (from ViewState, unexpanded) */\r\n public readonly viewOriginUnexpanded = new Point3d();\r\n /** View delta (from ViewState, unexpanded) */\r\n public readonly viewDeltaUnexpanded = new Vector3d();\r\n /** View rotation matrix (copied from ViewState) */\r\n public readonly rotation = new Matrix3d();\r\n /** Provides conversions between world and view coordinates. */\r\n public readonly worldToViewMap = Map4d.createIdentity();\r\n /** Providers conversions between world and Npc (non-dimensional perspective) coordinates. */\r\n public readonly worldToNpcMap = Map4d.createIdentity();\r\n /** @internal */\r\n public readonly zClipAdjusted: boolean = false; // were the view z clip planes adjusted due to front/back clipping off?\r\n /** Eye point - undefined if not a perspective projection. */\r\n public readonly eyePoint: Point3d | undefined;\r\n\r\n private _view: ViewState;\r\n\r\n /** The ViewState for this Viewport */\r\n public get view(): ViewState { return this._view; }\r\n public set view(view: ViewState) { this._view = view; }\r\n\r\n private readonly _clientWidth: number;\r\n private readonly _clientHeight: number;\r\n\r\n /** Get the rectangle of this Viewport in ViewCoordinates. */\r\n private get _viewRect(): ViewRect {\r\n this._viewRange.init(0, 0, this._clientWidth, this._clientHeight);\r\n return this._viewRange;\r\n }\r\n\r\n private static _copyOutput(from: XYZ, to?: XYZ) {\r\n let pt = from;\r\n if (to) {\r\n to.setFrom(from);\r\n pt = to;\r\n }\r\n\r\n return pt;\r\n }\r\n\r\n /** @internal */\r\n public toViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n /** @internal */\r\n public fromViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyTransposeVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n\r\n /** Ensure the rotation matrix for this view is aligns the root z with the view out (i.e. a \"2d view\"). */\r\n private alignWithRootZ() {\r\n const zUp = Vector3d.unitZ();\r\n if (zUp.isAlmostEqual(this.rotation.rowZ()))\r\n return;\r\n const r = this.rotation.transpose();\r\n r.setColumn(2, zUp);\r\n Matrix3d.createRigidFromMatrix3d(r, AxisOrder.ZXY, r);\r\n r.transpose(this.rotation);\r\n this.view.setRotation(this.rotation); // Don't let viewState and viewport rotation be different.\r\n }\r\n\r\n private validateCamera() {\r\n const view = this.view;\r\n if (!view.is3d())\r\n return;\r\n\r\n const camera = view.camera;\r\n camera.validateLens();\r\n if (camera.isFocusValid)\r\n return;\r\n\r\n const vDelta = view.getExtents();\r\n const maxDelta = vDelta.x > vDelta.y ? vDelta.x : vDelta.y;\r\n let focusDistance = maxDelta / (2.0 * Math.tan(camera.getLensAngle().radians / 2.0));\r\n\r\n if (focusDistance < vDelta.z / 2.0)\r\n focusDistance = vDelta.z / 2.0;\r\n\r\n const eyePoint = new Point3d(vDelta.x / 2.0, vDelta.y / 2.0, (vDelta.z / 2.0) + focusDistance);\r\n\r\n this.fromViewOrientation(eyePoint);\r\n eyePoint.plus(view.getOrigin(), eyePoint);\r\n camera.setEyePoint(eyePoint);\r\n camera.setFocusDistance(focusDistance);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeightRange(): Range1d | undefined {\r\n const frustum = this.getFrustum();\r\n const cartoRange = Range2d.createNull();\r\n for (let i = 0; i < 8; i++) {\r\n const corner = frustum.getCorner(i);\r\n const carto = this.view.iModel.spatialToCartographicFromEcef(corner);\r\n cartoRange.extendXY(carto.longitude, carto.latitude);\r\n }\r\n\r\n return ApproximateTerrainHeights.instance.getMinimumMaximumHeights(cartoRange);\r\n }\r\n\r\n private static _minDepth = 1; // Allowing very small depth will cause frustum calculations to fail.\r\n\r\n /** Compute the bounding box of this viewing space in [[CoordSystem.World]] coordinates, including the extents of any [[TiledGraphicsProvider]]s registered with the [[Viewport]]. */\r\n public readonly getViewedExtents: () => AxisAlignedBox3d;\r\n\r\n /** Adjust the front and back planes to encompass the entire viewed volume */\r\n private adjustZPlanes(origin: Point3d, delta: Vector3d): void {\r\n const view = this.view;\r\n if (!view.is3d()) // only necessary for 3d views\r\n return;\r\n\r\n delta.z = Math.max(delta.z, ViewingSpace._minDepth);\r\n\r\n const extents = this.getViewedExtents();\r\n const frustum = new Frustum();\r\n const worldToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOrigin, this.viewDelta, false).map as Map4d;\r\n\r\n if (worldToNpc === undefined)\r\n return;\r\n\r\n worldToNpc.transform1.multiplyPoint3dArrayQuietNormalize(frustum.points);\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewedExtentCorners = extents.corners();\r\n\r\n // Only extend depth to include viewed geometry if it is within the frustum. (if viewing global locations).\r\n if (clipPlanes.classifyPointContainment(viewedExtentCorners, false) === ClipPlaneContainment.StronglyOutside)\r\n extents.setNull();\r\n\r\n let depthRange;\r\n let gridPlane;\r\n if (this.view.viewFlags.grid) {\r\n const gridOrigin = this.view.isSpatialView() ? this.view.iModel.globalOrigin : Point3d.create();\r\n switch(this.view.getGridOrientation()) {\r\n case GridOrientationType.WorldXY:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 0, 1));\r\n break;\r\n case GridOrientationType.WorldYZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(1, 0, 0));\r\n break;\r\n case GridOrientationType.WorldXZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 1, 0));\r\n break;\r\n\r\n case GridOrientationType.AuxCoord:\r\n if (this.view.auxiliaryCoordinateSystem)\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, this.view.auxiliaryCoordinateSystem.getRotation().rowZ());\r\n\r\n break;\r\n }\r\n }\r\n const globalGeometry = this.view.displayStyle.getGlobalGeometryAndHeightRange();\r\n if (undefined !== globalGeometry) {\r\n const viewZ = this.rotation.getRow(2);\r\n const eyeDepth = this.eyePoint ? viewZ.dotProduct(this.eyePoint) : undefined;\r\n\r\n depthRange = globalGeometry.geometry.getFrustumIntersectionDepthRange(frustum, extents, globalGeometry.heightRange, gridPlane, this.view.maxGlobalScopeFactor > 1);\r\n\r\n if (eyeDepth !== undefined) {\r\n const maxBackgroundFrontBackRatio = 1.0E6;\r\n const frontDist = Math.max(.1, eyeDepth - depthRange.high);\r\n const backDist = eyeDepth - depthRange.low;\r\n if (backDist / frontDist > maxBackgroundFrontBackRatio)\r\n depthRange.high = eyeDepth - backDist / maxBackgroundFrontBackRatio;\r\n }\r\n } else\r\n depthRange = gridPlane ? getFrustumPlaneIntersectionDepthRange(frustum, gridPlane) : Range1d.createNull();\r\n\r\n if (!extents.isNull) {\r\n const viewZ = this.rotation.getRow(2);\r\n const corners = extents.corners();\r\n for (const corner of corners)\r\n depthRange.extendX(viewZ.dotProduct(corner));\r\n }\r\n\r\n if (depthRange.isNull)\r\n return;\r\n\r\n this.rotation.multiplyVectorInPlace(origin); // put origin in view coordinates\r\n origin.z = depthRange.low; // set origin to back of viewed extents\r\n delta.z = Math.max(depthRange.high - depthRange.low, ViewingSpace._minDepth); // and delta to front of viewed extents\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n\r\n if (!view.isCameraOn)\r\n return;\r\n\r\n // if the camera is on, we need to make sure that the viewed volume is not behind the eye\r\n const eyeOrg = this.eyePoint!.minus(origin);\r\n this.rotation.multiplyVectorInPlace(eyeOrg);\r\n\r\n // if the distance from the eye to origin in less than 1 meter, move the origin away from the eye. Usually, this means\r\n // that the camera is outside the viewed extents and pointed away from it. There's nothing to see anyway.\r\n if (eyeOrg.z < 1.0) {\r\n this.rotation.multiplyVectorInPlace(origin);\r\n origin.z -= (2.0 - eyeOrg.z);\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n delta.z = 1.0;\r\n return;\r\n }\r\n\r\n // if part of the viewed extents are behind the eye, don't include that.\r\n if (delta.z > eyeOrg.z)\r\n delta.z = eyeOrg.z;\r\n }\r\n\r\n /* get the mapping from NPC to view\r\n * @internal\r\n */\r\n public calcNpcToView(): Map4d {\r\n const corners = this.getViewCorners();\r\n const map = Map4d.createBoxMap(NpcCorners[Npc._000], NpcCorners[Npc._111], corners.low, corners.high);\r\n\r\n // The map may be undefined if the view rect's width or height is zero.\r\n return undefined === map ? Map4d.createIdentity() : map;\r\n }\r\n\r\n /* Get the extents of this view, in ViewCoordinates, as a Range3d */\r\n public getViewCorners(): Range3d {\r\n const corners = this._viewCorners;\r\n const viewRect = this._viewRect;\r\n corners.high.x = viewRect.right;\r\n corners.low.y = viewRect.bottom; // y's are swapped on the screen!\r\n corners.low.x = 0;\r\n corners.high.y = 0;\r\n corners.low.z = -32767;\r\n corners.high.z = 32767;\r\n return corners;\r\n }\r\n\r\n private constructor(vp: Viewport) {\r\n const view = this._view = vp.view;\r\n const viewRect = vp.viewRect;\r\n this._clientWidth = viewRect.width;\r\n this._clientHeight = viewRect.height;\r\n const origin = view.getOrigin().clone();\r\n const delta = view.getExtents().clone();\r\n this.rotation.setFrom(view.getRotation());\r\n\r\n this.getViewedExtents = () => {\r\n const extents = this._view.getViewedExtents();\r\n vp.forEachTiledGraphicsProvider((provider) => {\r\n provider.forEachTileTreeRef(vp, (ref) => {\r\n ref.unionFitRange(extents);\r\n });\r\n });\r\n\r\n return extents;\r\n };\r\n\r\n // first, make sure none of the deltas are negative\r\n delta.x = Math.abs(delta.x);\r\n delta.y = Math.abs(delta.y);\r\n delta.z = Math.abs(delta.z);\r\n\r\n this.viewOriginUnexpanded.setFrom(origin);\r\n this.viewDeltaUnexpanded.setFrom(delta);\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n this.zClipAdjusted = false;\r\n this.eyePoint = undefined;\r\n\r\n if (view.is3d()) {\r\n if (!view.allow3dManipulations()) {\r\n // we're in a \"2d\" view of a physical model. That means that we must have our orientation with z out of the screen with z=0 at the center.\r\n this.alignWithRootZ(); // make sure we're in a z Up view\r\n\r\n const extents = this.getViewedExtents();\r\n if (extents.isNull) {\r\n extents.low.z = Frustum2d.minimumZExtents.low;\r\n extents.high.z = Frustum2d.minimumZExtents.high;\r\n }\r\n\r\n let zMax = Math.max(Math.abs(extents.low.z), Math.abs(extents.high.z));\r\n zMax = Math.max(zMax, 1.0); // make sure we have at least +-1m. Data may be purely planar\r\n delta.z = 2.0 * zMax;\r\n origin.z = -zMax;\r\n } else {\r\n if (view.isCameraOn)\r\n this.validateCamera();\r\n\r\n if (view.isCameraOn)\r\n this.eyePoint = view.camera.getEyePoint().clone();\r\n\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes entire volume of view\r\n\r\n // if the camera is on, don't allow front plane behind camera\r\n if (this.eyePoint) {\r\n const eyeOrg = this.eyePoint.minus(origin); // vector from eye to origin\r\n this.toViewOrientation(eyeOrg);\r\n\r\n const frontDist = eyeOrg.z - delta.z; // front distance is backDist - delta.z\r\n\r\n // allow ViewState to specify a minimum front dist, but in no case less than 6 inches\r\n const minFrontDist = Math.max(15.2 * Constant.oneCentimeter, view.forceMinFrontDist);\r\n if (frontDist < minFrontDist) {\r\n // camera is too close to front plane, move origin away from eye to maintain a minimum front distance.\r\n this.toViewOrientation(origin);\r\n origin.z -= (minFrontDist - frontDist);\r\n this.fromViewOrientation(origin);\r\n }\r\n }\r\n\r\n // if we moved the z planes, set the \"zClipAdjusted\" flag.\r\n if (!origin.isExactEqual(this.viewOriginUnexpanded) || !delta.isExactEqual(this.viewDeltaUnexpanded))\r\n this.zClipAdjusted = true;\r\n }\r\n } else { // 2d viewport\r\n this.alignWithRootZ();\r\n }\r\n\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n\r\n const newRootToNpc = this.view.computeWorldToNpc(this.rotation, origin, delta, !this.view.displayStyle.getIsBackgroundMapVisible() /* if displaying background map, don't enforce front/back ratio as no Z-Buffer */);\r\n if (newRootToNpc.map === undefined) {\r\n this.frustFraction = 0; // invalid frustum\r\n return;\r\n }\r\n\r\n this.worldToNpcMap.setFrom(newRootToNpc.map);\r\n this.frustFraction = newRootToNpc.frustFraction;\r\n this.worldToViewMap.setFrom(this.calcNpcToView().multiplyMapMap(this.worldToNpcMap));\r\n }\r\n\r\n /** Create from a Viewport. */\r\n public static createFromViewport(vp: Viewport): ViewingSpace | undefined {\r\n return new ViewingSpace(vp);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.Npc */\r\n public viewToNpcArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n scrToNpcTran.multiplyPoint3dArrayInPlace(pts);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.View */\r\n public npcToViewArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n for (const p of pts)\r\n corners.fractionToPoint(p.x, p.y, p.z, p);\r\n }\r\n\r\n /** Convert a point from CoordSystem.View to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToNpc(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n return scrToNpcTran.multiplyPoint3d(pt, out);\r\n }\r\n\r\n /** Convert a point from CoordSystem.Npc to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToView(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n return corners.fractionToPoint(pt.x, pt.y, pt.z, out);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.Npc */\r\n public worldToNpcArray(pts: Point3d[]): void { this.worldToNpcMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.World */\r\n public npcToWorldArray(pts: Point3d[]): void { this.worldToNpcMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View */\r\n public worldToViewArray(pts: Point3d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View, as Point4ds */\r\n public worldToView4dArray(worldPts: Point3d[], viewPts: Point4d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArray(worldPts, viewPts); }\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.World */\r\n public viewToWorldArray(pts: Point3d[]) { this.worldToViewMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.View as Point4ds to CoordSystem.World */\r\n public view4dToWorldArray(viewPts: Point4d[], worldPts: Point3d[]): void { this.worldToViewMap.transform1.multiplyPoint4dArrayQuietRenormalize(viewPts, worldPts); }\r\n\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToNpc(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform0.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.Npc to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToWorld(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform1.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToView(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform0.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View as Point4d\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point4d is created.\r\n */\r\n public worldToView4d(input: XYAndZ, out?: Point4d): Point4d { return this.worldToViewMap.transform0.multiplyPoint3d(input, 1.0, out); }\r\n /**\r\n * Convert a point from CoordSystem.View to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToWorld(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.View as a Point4d to CoordSystem.View\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public view4dToWorld(input: Point4d, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyXYZWQuietRenormalize(input.x, input.y, input.z, input.w, out); }\r\n\r\n /** Get an 8-point Frustum corresponding to the 8 corners of the Viewport in the specified coordinate system.\r\n *\r\n * There are two sets of corners that may be of interest.\r\n * The \"adjusted\" box is the one that is computed by examining the \"viewed extents\" and moving\r\n * the front and back planes to enclose everything in the view.\r\n * The \"unadjusted\" box is the one that is stored in the ViewState.\r\n * @param sys Coordinate system for points\r\n * @param adjustedBox If true, retrieve the adjusted box. Otherwise retrieve the box that came from the view definition.\r\n * @param box optional Frustum for return value\r\n * @return the view frustum\r\n * @note The \"adjusted\" box may be either larger or smaller than the \"unadjusted\" box.\r\n */\r\n public getFrustum(sys: CoordSystem = CoordSystem.World, adjustedBox: boolean = true, box?: Frustum): Frustum {\r\n box = box ? box.initNpc() : new Frustum();\r\n\r\n // if they are looking for the \"unexpanded\" (that is before f/b clipping expansion) box, we need to get the npc\r\n // coordinates that correspond to the unexpanded box in the npc space of the Expanded view (that's the basis for all\r\n // of the root-based maps.)\r\n if (!adjustedBox && this.zClipAdjusted) {\r\n // to get unexpanded box, we have to go recompute rootToNpc from original View.\r\n const ueRootToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOriginUnexpanded, this.viewDeltaUnexpanded);\r\n if (undefined === ueRootToNpc.map)\r\n return box; // invalid frustum\r\n\r\n // get the root corners of the unexpanded box\r\n const ueRootBox = new Frustum();\r\n ueRootToNpc.map.transform1.multiplyPoint3dArrayQuietNormalize(ueRootBox.points);\r\n\r\n // and convert them to npc coordinates of the expanded view\r\n this.worldToNpcArray(ueRootBox.points);\r\n box.setFrom(ueRootBox);\r\n }\r\n\r\n // now convert from NPC space to the specified coordinate system.\r\n switch (sys) {\r\n case CoordSystem.View:\r\n this.npcToViewArray(box.points);\r\n break;\r\n\r\n case CoordSystem.World:\r\n this.npcToWorldArray(box.points);\r\n break;\r\n }\r\n return box;\r\n }\r\n\r\n /** @internal */\r\n public getPixelSizeAtPoint(inPoint?: Point3d) {\r\n const viewPt = !!inPoint ? this.worldToView(inPoint) : this.npcToView(new Point3d(0.5, 0.5, 0.5));\r\n const viewPt2 = new Point3d(viewPt.x + 1.0, viewPt.y, viewPt.z);\r\n return this.viewToWorld(viewPt).distance(this.viewToWorld(viewPt2));\r\n }\r\n\r\n /** @internal */\r\n public getPreloadFrustum(transformOrScale?: Transform | number, result?: Frustum) {\r\n const viewFrustum = this.getFrustum(CoordSystem.World, true);\r\n\r\n if (transformOrScale && transformOrScale instanceof Transform) {\r\n return viewFrustum.transformBy(transformOrScale, result);\r\n } else {\r\n const scale = transformOrScale === undefined ? 2 : transformOrScale;\r\n const expandedFrustum = viewFrustum.clone(result);\r\n expandedFrustum.scaleXYAboutCenter(scale);\r\n return expandedFrustum;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ViewingSpace.js","sourceRoot":"","sources":["../../src/ViewingSpace.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EACL,SAAS,EAAE,oBAAoB,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,4BAA4B,EAAE,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,GAC3J,MAAM,s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EAAqE","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Views\r\n */\r\n\r\nimport {\r\n AxisOrder, ClipPlaneContainment, Constant, Map4d, Matrix3d, Plane3dByOriginAndUnitNormal, Point3d, Point4d, Range1d, Range2d, Range3d, Transform, Vector3d, XYAndZ, XYZ,\r\n} from \"@itwin/core-geometry\";\r\nimport { AxisAlignedBox3d, Frustum, GridOrientationType, Npc, NpcCorners } from \"@itwin/core-common\";\r\nimport { ApproximateTerrainHeights } from \"./ApproximateTerrainHeights\";\r\nimport { CoordSystem } from \"./CoordSystem\";\r\nimport { Viewport } from \"./Viewport\";\r\nimport { ViewRect } from \"./common/ViewRect\";\r\nimport { ViewState } from \"./ViewState\";\r\nimport { Frustum2d } from \"./Frustum2d\";\r\nimport { getFrustumPlaneIntersectionDepthRange } from \"./BackgroundMapGeometry\";\r\n\r\n/** Describes a [[Viewport]]'s viewing volume, plus its size on the screen. A new\r\n * instance of ViewingSpace is created every time the Viewport's frustum changes.\r\n * @see [[Viewport.viewingSpace]].\r\n * @public\r\n * @extensions\r\n */\r\nexport class ViewingSpace {\r\n private readonly _viewRange = new ViewRect(); // scratch variable\r\n private readonly _viewCorners = new Range3d(); // scratch variable\r\n\r\n /** @internal */\r\n public frustFraction = 1.0;\r\n /** Maximum ratio of frontplane to backplane distance for 24 bit non-logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleNonLog24 = 0.0003;\r\n /** Maximum fraction of frontplane to backplane distance for 24 bit logarithmic zbuffer\r\n * @internal\r\n */\r\n public static nearScaleLog24 = 1.0E-8;\r\n /** View origin, potentially expanded */\r\n public readonly viewOrigin = new Point3d();\r\n /** View delta, potentially expanded */\r\n public readonly viewDelta = new Vector3d();\r\n /** View origin (from ViewState, unexpanded) */\r\n public readonly viewOriginUnexpanded = new Point3d();\r\n /** View delta (from ViewState, unexpanded) */\r\n public readonly viewDeltaUnexpanded = new Vector3d();\r\n /** View rotation matrix (copied from ViewState) */\r\n public readonly rotation = new Matrix3d();\r\n /** Provides conversions between world and view coordinates. */\r\n public readonly worldToViewMap = Map4d.createIdentity();\r\n /** Providers conversions between world and Npc (non-dimensional perspective) coordinates. */\r\n public readonly worldToNpcMap = Map4d.createIdentity();\r\n /** @internal */\r\n public readonly zClipAdjusted: boolean = false; // were the view z clip planes adjusted due to front/back clipping off?\r\n /** Eye point - undefined if not a perspective projection. */\r\n public readonly eyePoint: Point3d | undefined;\r\n\r\n private _view: ViewState;\r\n\r\n /** The ViewState for this Viewport */\r\n public get view(): ViewState { return this._view; }\r\n public set view(view: ViewState) { this._view = view; }\r\n\r\n private readonly _clientWidth: number;\r\n private readonly _clientHeight: number;\r\n\r\n /** Get the rectangle of this Viewport in ViewCoordinates. */\r\n private get _viewRect(): ViewRect {\r\n this._viewRange.init(0, 0, this._clientWidth, this._clientHeight);\r\n return this._viewRange;\r\n }\r\n\r\n private static _copyOutput(from: XYZ, to?: XYZ) {\r\n let pt = from;\r\n if (to) {\r\n to.setFrom(from);\r\n pt = to;\r\n }\r\n\r\n return pt;\r\n }\r\n\r\n /** @internal */\r\n public toViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n /** @internal */\r\n public fromViewOrientation(from: XYZ, to?: XYZ) { this.rotation.multiplyTransposeVectorInPlace(ViewingSpace._copyOutput(from, to)); }\r\n\r\n /** Ensure the rotation matrix for this view is aligns the root z with the view out (i.e. a \"2d view\"). */\r\n private alignWithRootZ() {\r\n const zUp = Vector3d.unitZ();\r\n if (zUp.isAlmostEqual(this.rotation.rowZ()))\r\n return;\r\n const r = this.rotation.transpose();\r\n r.setColumn(2, zUp);\r\n Matrix3d.createRigidFromMatrix3d(r, AxisOrder.ZXY, r);\r\n r.transpose(this.rotation);\r\n this.view.setRotation(this.rotation); // Don't let viewState and viewport rotation be different.\r\n }\r\n\r\n private validateCamera() {\r\n const view = this.view;\r\n if (!view.is3d())\r\n return;\r\n\r\n const camera = view.camera;\r\n camera.validateLens();\r\n if (camera.isFocusValid)\r\n return;\r\n\r\n const vDelta = view.getExtents();\r\n const maxDelta = vDelta.x > vDelta.y ? vDelta.x : vDelta.y;\r\n let focusDistance = maxDelta / (2.0 * Math.tan(camera.getLensAngle().radians / 2.0));\r\n\r\n if (focusDistance < vDelta.z / 2.0)\r\n focusDistance = vDelta.z / 2.0;\r\n\r\n const eyePoint = new Point3d(vDelta.x / 2.0, vDelta.y / 2.0, (vDelta.z / 2.0) + focusDistance);\r\n\r\n this.fromViewOrientation(eyePoint);\r\n eyePoint.plus(view.getOrigin(), eyePoint);\r\n camera.setEyePoint(eyePoint);\r\n camera.setFocusDistance(focusDistance);\r\n }\r\n\r\n /** @internal */\r\n public getTerrainHeightRange(): Range1d | undefined {\r\n const frustum = this.getFrustum();\r\n const cartoRange = Range2d.createNull();\r\n for (let i = 0; i < 8; i++) {\r\n const corner = frustum.getCorner(i);\r\n const carto = this.view.iModel.spatialToCartographicFromEcef(corner);\r\n cartoRange.extendXY(carto.longitude, carto.latitude);\r\n }\r\n\r\n return ApproximateTerrainHeights.instance.getMinimumMaximumHeights(cartoRange);\r\n }\r\n\r\n private static _minDepth = 1; // Allowing very small depth will cause frustum calculations to fail.\r\n\r\n /** Compute the bounding box of this viewing space in [[CoordSystem.World]] coordinates, including the extents of any [[TiledGraphicsProvider]]s registered with the [[Viewport]]. */\r\n public readonly getViewedExtents: () => AxisAlignedBox3d;\r\n\r\n /** Adjust the front and back planes to encompass the entire viewed volume */\r\n private adjustZPlanes(origin: Point3d, delta: Vector3d): void {\r\n const view = this.view;\r\n if (!view.is3d()) // only necessary for 3d views\r\n return;\r\n\r\n delta.z = Math.max(delta.z, ViewingSpace._minDepth);\r\n\r\n const extents = this.getViewedExtents();\r\n const frustum = new Frustum();\r\n const worldToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOrigin, this.viewDelta, false).map as Map4d;\r\n\r\n if (worldToNpc === undefined)\r\n return;\r\n\r\n worldToNpc.transform1.multiplyPoint3dArrayQuietNormalize(frustum.points);\r\n const clipPlanes = frustum.getRangePlanes(false, false, 0);\r\n const viewedExtentCorners = extents.corners();\r\n\r\n // Only extend depth to include viewed geometry if it is within the frustum. (if viewing global locations).\r\n if (clipPlanes.classifyPointContainment(viewedExtentCorners, false) === ClipPlaneContainment.StronglyOutside)\r\n extents.setNull();\r\n\r\n let depthRange;\r\n let gridPlane;\r\n if (this.view.viewFlags.grid) {\r\n const gridOrigin = this.view.isSpatialView() ? this.view.iModel.globalOrigin : Point3d.create();\r\n switch(this.view.getGridOrientation()) {\r\n case GridOrientationType.WorldXY:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 0, 1));\r\n break;\r\n case GridOrientationType.WorldYZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(1, 0, 0));\r\n break;\r\n case GridOrientationType.WorldXZ:\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, Vector3d.create(0, 1, 0));\r\n break;\r\n\r\n case GridOrientationType.AuxCoord:\r\n if (this.view.auxiliaryCoordinateSystem)\r\n gridPlane = Plane3dByOriginAndUnitNormal.create(gridOrigin, this.view.auxiliaryCoordinateSystem.getRotation().rowZ());\r\n\r\n break;\r\n }\r\n }\r\n const globalGeometry = this.view.displayStyle.getGlobalGeometryAndHeightRange();\r\n if (undefined !== globalGeometry) {\r\n const viewZ = this.rotation.getRow(2);\r\n const eyeDepth = this.eyePoint ? viewZ.dotProduct(this.eyePoint) : undefined;\r\n\r\n depthRange = globalGeometry.geometry.getFrustumIntersectionDepthRange(frustum, extents, globalGeometry.heightRange, gridPlane, this.view.maxGlobalScopeFactor > 1);\r\n\r\n if (eyeDepth !== undefined) {\r\n const maxBackgroundFrontBackRatio = 1.0E6;\r\n const frontDist = Math.max(.1, eyeDepth - depthRange.high);\r\n const backDist = eyeDepth - depthRange.low;\r\n if (backDist / frontDist > maxBackgroundFrontBackRatio)\r\n depthRange.high = eyeDepth - backDist / maxBackgroundFrontBackRatio;\r\n }\r\n } else\r\n depthRange = gridPlane ? getFrustumPlaneIntersectionDepthRange(frustum, gridPlane) : Range1d.createNull();\r\n\r\n if (!extents.isNull) {\r\n const viewZ = this.rotation.getRow(2);\r\n const corners = extents.corners();\r\n for (const corner of corners)\r\n depthRange.extendX(viewZ.dotProduct(corner));\r\n }\r\n\r\n if (depthRange.isNull)\r\n return;\r\n\r\n this.rotation.multiplyVectorInPlace(origin); // put origin in view coordinates\r\n origin.z = depthRange.low; // set origin to back of viewed extents\r\n delta.z = Math.max(depthRange.high - depthRange.low, ViewingSpace._minDepth); // and delta to front of viewed extents\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n\r\n if (!view.isCameraOn)\r\n return;\r\n\r\n // if the camera is on, we need to make sure that the viewed volume is not behind the eye\r\n const eyeOrg = this.eyePoint!.minus(origin);\r\n this.rotation.multiplyVectorInPlace(eyeOrg);\r\n\r\n // if the distance from the eye to origin in less than 1 meter, move the origin away from the eye. Usually, this means\r\n // that the camera is outside the viewed extents and pointed away from it. There's nothing to see anyway.\r\n if (eyeOrg.z < 1.0) {\r\n this.rotation.multiplyVectorInPlace(origin);\r\n origin.z -= (2.0 - eyeOrg.z);\r\n this.rotation.multiplyTransposeVectorInPlace(origin);\r\n delta.z = 1.0;\r\n return;\r\n }\r\n\r\n // if part of the viewed extents are behind the eye, don't include that.\r\n if (delta.z > eyeOrg.z)\r\n delta.z = eyeOrg.z;\r\n }\r\n\r\n /* get the mapping from NPC to view\r\n * @internal\r\n */\r\n public calcNpcToView(): Map4d {\r\n const corners = this.getViewCorners();\r\n const map = Map4d.createBoxMap(NpcCorners[Npc._000], NpcCorners[Npc._111], corners.low, corners.high);\r\n\r\n // The map may be undefined if the view rect's width or height is zero.\r\n return undefined === map ? Map4d.createIdentity() : map;\r\n }\r\n\r\n /* Get the extents of this view, in ViewCoordinates, as a Range3d */\r\n public getViewCorners(): Range3d {\r\n const corners = this._viewCorners;\r\n const viewRect = this._viewRect;\r\n corners.high.x = viewRect.right;\r\n corners.low.y = viewRect.bottom; // y's are swapped on the screen!\r\n corners.low.x = 0;\r\n corners.high.y = 0;\r\n corners.low.z = -32767;\r\n corners.high.z = 32767;\r\n return corners;\r\n }\r\n\r\n private constructor(vp: Viewport) {\r\n const view = this._view = vp.view;\r\n const viewRect = vp.viewRect;\r\n this._clientWidth = viewRect.width;\r\n this._clientHeight = viewRect.height;\r\n const origin = view.getOrigin().clone();\r\n const delta = view.getExtents().clone();\r\n this.rotation.setFrom(view.getRotation());\r\n\r\n this.getViewedExtents = () => {\r\n const extents = this._view.getViewedExtents();\r\n vp.forEachTiledGraphicsProvider((provider) => {\r\n provider.forEachTileTreeRef(vp, (ref) => {\r\n ref.unionFitRange(extents);\r\n });\r\n });\r\n\r\n return extents;\r\n };\r\n\r\n // first, make sure none of the deltas are negative\r\n delta.x = Math.abs(delta.x);\r\n delta.y = Math.abs(delta.y);\r\n delta.z = Math.abs(delta.z);\r\n\r\n this.viewOriginUnexpanded.setFrom(origin);\r\n this.viewDeltaUnexpanded.setFrom(delta);\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n this.zClipAdjusted = false;\r\n this.eyePoint = undefined;\r\n\r\n if (view.is3d()) {\r\n if (!view.allow3dManipulations()) {\r\n // we're in a \"2d\" view of a physical model. That means that we must have our orientation with z out of the screen with z=0 at the center.\r\n this.alignWithRootZ(); // make sure we're in a z Up view\r\n\r\n const extents = this.getViewedExtents();\r\n if (extents.isNull) {\r\n extents.low.z = Frustum2d.minimumZExtents.low;\r\n extents.high.z = Frustum2d.minimumZExtents.high;\r\n }\r\n\r\n let zMax = Math.max(Math.abs(extents.low.z), Math.abs(extents.high.z));\r\n zMax = Math.max(zMax, 1.0); // make sure we have at least +-1m. Data may be purely planar\r\n delta.z = 2.0 * zMax;\r\n origin.z = -zMax;\r\n const ds = this.view.displayStyle;\r\n if (ds.getIsBackgroundMapVisible() && undefined !== ds.getBackgroundMapGeometry())\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes background map\r\n } else {\r\n if (view.isCameraOn)\r\n this.validateCamera();\r\n\r\n if (view.isCameraOn)\r\n this.eyePoint = view.camera.getEyePoint().clone();\r\n\r\n this.adjustZPlanes(origin, delta); // make sure view volume includes entire volume of view\r\n\r\n // if the camera is on, don't allow front plane behind camera\r\n if (this.eyePoint) {\r\n const eyeOrg = this.eyePoint.minus(origin); // vector from eye to origin\r\n this.toViewOrientation(eyeOrg);\r\n\r\n const frontDist = eyeOrg.z - delta.z; // front distance is backDist - delta.z\r\n\r\n // allow ViewState to specify a minimum front dist, but in no case less than 6 inches\r\n const minFrontDist = Math.max(15.2 * Constant.oneCentimeter, view.forceMinFrontDist);\r\n if (frontDist < minFrontDist) {\r\n // camera is too close to front plane, move origin away from eye to maintain a minimum front distance.\r\n this.toViewOrientation(origin);\r\n origin.z -= (minFrontDist - frontDist);\r\n this.fromViewOrientation(origin);\r\n }\r\n }\r\n\r\n // if we moved the z planes, set the \"zClipAdjusted\" flag.\r\n if (!origin.isExactEqual(this.viewOriginUnexpanded) || !delta.isExactEqual(this.viewDeltaUnexpanded))\r\n this.zClipAdjusted = true;\r\n }\r\n } else { // 2d viewport\r\n this.alignWithRootZ();\r\n }\r\n\r\n this.viewOrigin.setFrom(origin);\r\n this.viewDelta.setFrom(delta);\r\n\r\n const newRootToNpc = this.view.computeWorldToNpc(this.rotation, origin, delta, !this.view.displayStyle.getIsBackgroundMapVisible() /* if displaying background map, don't enforce front/back ratio as no Z-Buffer */);\r\n if (newRootToNpc.map === undefined) {\r\n this.frustFraction = 0; // invalid frustum\r\n return;\r\n }\r\n\r\n this.worldToNpcMap.setFrom(newRootToNpc.map);\r\n this.frustFraction = newRootToNpc.frustFraction;\r\n this.worldToViewMap.setFrom(this.calcNpcToView().multiplyMapMap(this.worldToNpcMap));\r\n }\r\n\r\n /** Create from a Viewport. */\r\n public static createFromViewport(vp: Viewport): ViewingSpace | undefined {\r\n return new ViewingSpace(vp);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.Npc */\r\n public viewToNpcArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n scrToNpcTran.multiplyPoint3dArrayInPlace(pts);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.View */\r\n public npcToViewArray(pts: Point3d[]): void {\r\n const corners = this.getViewCorners();\r\n for (const p of pts)\r\n corners.fractionToPoint(p.x, p.y, p.z, p);\r\n }\r\n\r\n /** Convert a point from CoordSystem.View to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToNpc(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n const scrToNpcTran = Transform.createIdentity();\r\n Transform.initFromRange(corners.low, corners.high, undefined, scrToNpcTran);\r\n return scrToNpcTran.multiplyPoint3d(pt, out);\r\n }\r\n\r\n /** Convert a point from CoordSystem.Npc to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToView(pt: Point3d, out?: Point3d): Point3d {\r\n const corners = this.getViewCorners();\r\n return corners.fractionToPoint(pt.x, pt.y, pt.z, out);\r\n }\r\n\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.Npc */\r\n public worldToNpcArray(pts: Point3d[]): void { this.worldToNpcMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.Npc to CoordSystem.World */\r\n public npcToWorldArray(pts: Point3d[]): void { this.worldToNpcMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View */\r\n public worldToViewArray(pts: Point3d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.World to CoordSystem.View, as Point4ds */\r\n public worldToView4dArray(worldPts: Point3d[], viewPts: Point4d[]): void { this.worldToViewMap.transform0.multiplyPoint3dArray(worldPts, viewPts); }\r\n /** Convert an array of points from CoordSystem.View to CoordSystem.World */\r\n public viewToWorldArray(pts: Point3d[]) { this.worldToViewMap.transform1.multiplyPoint3dArrayQuietNormalize(pts); }\r\n /** Convert an array of points from CoordSystem.View as Point4ds to CoordSystem.World */\r\n public view4dToWorldArray(viewPts: Point4d[], worldPts: Point3d[]): void { this.worldToViewMap.transform1.multiplyPoint4dArrayQuietRenormalize(viewPts, worldPts); }\r\n\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.Npc\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToNpc(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform0.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.Npc to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public npcToWorld(pt: XYAndZ, out?: Point3d): Point3d { return this.worldToNpcMap.transform1.multiplyPoint3dQuietNormalize(pt, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public worldToView(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform0.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.World to CoordSystem.View as Point4d\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point4d is created.\r\n */\r\n public worldToView4d(input: XYAndZ, out?: Point4d): Point4d { return this.worldToViewMap.transform0.multiplyPoint3d(input, 1.0, out); }\r\n /**\r\n * Convert a point from CoordSystem.View to CoordSystem.World\r\n * @param pt the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public viewToWorld(input: XYAndZ, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyPoint3dQuietNormalize(input, out); }\r\n /**\r\n * Convert a point from CoordSystem.View as a Point4d to CoordSystem.View\r\n * @param input the point to convert\r\n * @param out optional location for result. If undefined, a new Point3d is created.\r\n */\r\n public view4dToWorld(input: Point4d, out?: Point3d): Point3d { return this.worldToViewMap.transform1.multiplyXYZWQuietRenormalize(input.x, input.y, input.z, input.w, out); }\r\n\r\n /** Get an 8-point Frustum corresponding to the 8 corners of the Viewport in the specified coordinate system.\r\n *\r\n * There are two sets of corners that may be of interest.\r\n * The \"adjusted\" box is the one that is computed by examining the \"viewed extents\" and moving\r\n * the front and back planes to enclose everything in the view.\r\n * The \"unadjusted\" box is the one that is stored in the ViewState.\r\n * @param sys Coordinate system for points\r\n * @param adjustedBox If true, retrieve the adjusted box. Otherwise retrieve the box that came from the view definition.\r\n * @param box optional Frustum for return value\r\n * @return the view frustum\r\n * @note The \"adjusted\" box may be either larger or smaller than the \"unadjusted\" box.\r\n */\r\n public getFrustum(sys: CoordSystem = CoordSystem.World, adjustedBox: boolean = true, box?: Frustum): Frustum {\r\n box = box ? box.initNpc() : new Frustum();\r\n\r\n // if they are looking for the \"unexpanded\" (that is before f/b clipping expansion) box, we need to get the npc\r\n // coordinates that correspond to the unexpanded box in the npc space of the Expanded view (that's the basis for all\r\n // of the root-based maps.)\r\n if (!adjustedBox && this.zClipAdjusted) {\r\n // to get unexpanded box, we have to go recompute rootToNpc from original View.\r\n const ueRootToNpc = this.view.computeWorldToNpc(this.rotation, this.viewOriginUnexpanded, this.viewDeltaUnexpanded);\r\n if (undefined === ueRootToNpc.map)\r\n return box; // invalid frustum\r\n\r\n // get the root corners of the unexpanded box\r\n const ueRootBox = new Frustum();\r\n ueRootToNpc.map.transform1.multiplyPoint3dArrayQuietNormalize(ueRootBox.points);\r\n\r\n // and convert them to npc coordinates of the expanded view\r\n this.worldToNpcArray(ueRootBox.points);\r\n box.setFrom(ueRootBox);\r\n }\r\n\r\n // now convert from NPC space to the specified coordinate system.\r\n switch (sys) {\r\n case CoordSystem.View:\r\n this.npcToViewArray(box.points);\r\n break;\r\n\r\n case CoordSystem.World:\r\n this.npcToWorldArray(box.points);\r\n break;\r\n }\r\n return box;\r\n }\r\n\r\n /** @internal */\r\n public getPixelSizeAtPoint(inPoint?: Point3d) {\r\n const viewPt = !!inPoint ? this.worldToView(inPoint) : this.npcToView(new Point3d(0.5, 0.5, 0.5));\r\n const viewPt2 = new Point3d(viewPt.x + 1.0, viewPt.y, viewPt.z);\r\n return this.viewToWorld(viewPt).distance(this.viewToWorld(viewPt2));\r\n }\r\n\r\n /** @internal */\r\n public getPreloadFrustum(transformOrScale?: Transform | number, result?: Frustum) {\r\n const viewFrustum = this.getFrustum(CoordSystem.World, true);\r\n\r\n if (transformOrScale && transformOrScale instanceof Transform) {\r\n return viewFrustum.transformBy(transformOrScale, result);\r\n } else {\r\n const scale = transformOrScale === undefined ? 2 : transformOrScale;\r\n const expandedFrustum = viewFrustum.clone(result);\r\n expandedFrustum.scaleXYAboutCenter(scale);\r\n return expandedFrustum;\r\n }\r\n }\r\n}\r\n"]}
|