UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

66 lines 3.05 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module DisplayStyles */ import { ColorByName } from "./ColorByName"; import { ColorDef } from "./ColorDef"; const defaultAboveColor = ColorDef.fromTbgr(ColorByName.darkGreen); const defaultBelowColor = ColorDef.fromTbgr(ColorByName.darkBrown); /** A circle drawn at a Z elevation, whose diameter is the the XY diagonal of the project extents, used to represent the ground as a reference point within a spatial view. * @see [[Environment.ground]]. * @public */ export class GroundPlane { /** The Z height in meters at which to draw the plane. */ elevation; /** The color in which to draw the ground plane when viewed from above. */ aboveColor; /** The color in which to draw the ground plane when viewed from below. */ belowColor; constructor(props) { this.elevation = props.elevation ?? -0.01; this.aboveColor = props.aboveColor ?? defaultAboveColor; this.belowColor = props.belowColor ?? defaultBelowColor; } /** Default settings with a dark green "above" color, dark brown "below" color, and elevation of -0.01 meters. */ static defaults = new GroundPlane({}); /** Create a new GroundPlane. Any properties not specified by `props` will be initialized to their default values. */ static create(props) { return props ? new this(props) : this.defaults; } /** Create a copy of this ground plane, identical except for any properties explicitly specified by `changedProps`. * Any properties of `changedProps` explicitly set to `undefined` will be initialized to their default values. */ clone(changedProps) { if (!changedProps) return this; return GroundPlane.create({ ...this, ...changedProps }); } /** Create from JSON representation. */ static fromJSON(props) { if (!props) return this.defaults; return new this({ elevation: props.elevation, aboveColor: undefined !== props.aboveColor ? ColorDef.fromJSON(props.aboveColor) : undefined, belowColor: undefined !== props.belowColor ? ColorDef.fromJSON(props.belowColor) : undefined, }); } /** Convert to JSON representation. * @param display If defined, the value to use for [[GroundPlaneProps.display]]; otherwise, that property will be left undefined. */ toJSON(display) { const props = { elevation: this.elevation, aboveColor: this.aboveColor.toJSON(), belowColor: this.belowColor.toJSON(), }; if (undefined !== display) props.display = display; return props; } } //# sourceMappingURL=GroundPlane.js.map