/*---------------------------------------------------------------------------------------------
* 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 { Atmosphere } from "./Atmosphere";
import { GroundPlane } from "./GroundPlane";
import { SkyBox } from "./SkyBox";
/** As part of a [[DisplayStyle3dSettings]], controls the display of a [[SkyBox]] and [[GroundPlane]] to simulate the
 * outdoor environment.
 * @see [[DisplayStyle3dSettings.environment]].
 * @public
 */
export class Environment {
    constructor(props) {
        this.displaySky = props?.displaySky ?? false;
        this.displayGround = props?.displayGround ?? false;
        this.displayAtmosphere = props?.displayAtmosphere ?? false;
        this.sky = props?.sky ?? SkyBox.defaults;
        this.ground = props?.ground ?? GroundPlane.defaults;
        this.atmosphere = props?.atmosphere ?? Atmosphere.Settings.defaults;
    }
    /** Create a new Environment. 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 environment, changing the `displayGround`, `displaySky` and/or `displayAtmosphere` flags. */
    withDisplay(display) {
        const displaySky = display.sky ?? this.displaySky;
        const displayGround = display.ground ?? this.displayGround;
        const displayAtmosphere = display.atmosphere ?? this.displayAtmosphere;
        if (displaySky === this.displaySky && displayGround === this.displayGround && displayAtmosphere === this.displayAtmosphere)
            return this;
        return Environment.create({
            ...this,
            displaySky: displaySky ?? this.displaySky,
            displayGround: displayGround ?? this.displayGround,
            displayAtmosphere: displayAtmosphere ?? this.displayAtmosphere,
        });
    }
    /** Convert to JSON representation. */
    toJSON() {
        return {
            sky: this.sky.toJSON(this.displaySky),
            ground: this.ground.toJSON(this.displayGround),
            atmosphere: this.atmosphere.toJSON(this.displayAtmosphere),
        };
    }
    /** Create from JSON representation. */
    static fromJSON(props) {
        if (!props)
            return this.defaults;
        return new this({
            displaySky: props?.sky?.display,
            displayGround: props?.ground?.display,
            displayAtmosphere: props?.atmosphere?.display,
            sky: props?.sky ? SkyBox.fromJSON(props.sky) : undefined,
            ground: props?.ground ? GroundPlane.fromJSON(props.ground) : undefined,
            atmosphere: props?.atmosphere ? Atmosphere.Settings.fromJSON(props.atmosphere) : undefined,
        });
    }
    /** Create a copy of this environment, identical except for any properties specified by `changedProps`.
     * Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.
     */
    clone(changedProps) {
        if (!changedProps)
            return this;
        return Environment.create({ ...this, ...changedProps });
    }
}
/** Default settings without a ground plane, sky box, or atmosphere displayed. */
Environment.defaults = new Environment();
//# sourceMappingURL=Environment.js.map