@itwin/core-common
Version:
iTwin.js components common to frontend and backend
218 lines • 9.07 kB
TypeScript
/** @packageDocumentation
* @module DisplayStyles
*/
import { Id64String, NonFunctionPropertiesOf } from "@itwin/core-bentley";
import { ColorDef, ColorDefProps } from "./ColorDef";
import { TextureImageSpec } from "./RenderTexture";
/** Supported types of [[SkyBox]] images.
* @see [[SkyBoxImageProps]].
* @public
* @extensions
*/
export declare enum SkyBoxImageType {
/** No image, indicating a [[SkyGradient]] should be displayed. */
None = 0,
/** A single image mapped to the surface of a sphere.
* @see [[SkySphere]].
*/
Spherical = 1,
/** @internal not yet supported */
Cylindrical = 2,
/** Six images mapped to the faces of a cube.
* @see [[SkyCube]].
*/
Cube = 3
}
/** JSON representation of the six images used by a [[SkyCube]].
* Each property specifies the image for a face of the cube as either an image URL, or the Id of a [Texture]($backend) element.
* Each image must be square and have the same dimensions as all the other images.
* @public
* @extensions
*/
export interface SkyCubeProps {
front: TextureImageSpec;
back: TextureImageSpec;
top: TextureImageSpec;
bottom: TextureImageSpec;
right: TextureImageSpec;
left: TextureImageSpec;
}
/** JSON representation of the image used for a [[SkySphere]].
* @see [[SkyBoxProps.image]].
* @public
*/
export interface SkySphereImageProps {
type: SkyBoxImageType.Spherical;
texture: TextureImageSpec;
/** @internal */
textures?: never;
}
/** JSON representation of the images used for a [[SkyCube]].
* @see [[SkyBoxProps.image]].
* @public
*/
export interface SkyCubeImageProps {
type: SkyBoxImageType.Cube;
textures: SkyCubeProps;
/** @internal */
texture?: never;
}
/** JSON representation of the image(s) to be mapped to the surfaces of a [[SkyBox]].
* @see [[SkyBoxProps.image]].
* @public
* @extensions
*/
export type SkyBoxImageProps = SkySphereImageProps | SkyCubeImageProps | {
type?: SkyBoxImageType;
texture?: never;
textures?: never;
};
/** JSON representation of a [[SkyBox]] that can be drawn as the background of a [ViewState3d]($frontend).
* An object of this type can describe one of several types of sky box:
* - A cube with a texture image mapped to each face; or
* - A sphere with a single texture image mapped to its surface; or
* - A sphere with a two- or four-color vertical [[Gradient]] mapped to its surface.
*
* Whether cuboid or spherical, the skybox is drawn as if the viewer and the contents of the view are contained within its interior.
*
* For a two-color gradient, the gradient transitions smoothly from the nadir color at the bottom of the sphere to the zenith color at the top of the sphere.
* The sky and ground colors are unused, as are the sky and ground exponents.
*
* For a four-color gradient, a "horizon" is produced on the equator of the sphere, where the ground color and sky color meet. The lower half of the sphere transitions
* smoothly from the ground color at the equator to the nadir color at the bottom, and the upper half transitions from the sky color at the equator to the zenith color at
* the top of the sphere.
*
* The color and exponent properties are unused if one or more texture images are supplied.
*
* The skybox is ignored entirely when an atmosphere is displayed.
*
* @see [[DisplayStyle3dSettings.environment]] to define the skybox for a display style.
* @public
* @extensions
*/
export interface SkyBoxProps {
/** Whether or not the skybox should be displayed.
* Default: false.
*/
display?: boolean;
/** For a [[SkyGradient]], if true, a 2-color gradient skybox is used instead of a 4-color.
* Default: false.
*/
twoColor?: boolean;
/** The color of the sky at the horizon. Unused unless this is a four-color [[SkyGradient]].
* Default: (143, 205, 255).
*/
skyColor?: ColorDefProps;
/** The color of the ground at the horizon. Unused unless this is a four-color [[SkyGradient]].
* Default: (120, 143, 125).
*/
groundColor?: ColorDefProps;
/** The color of the top of the sphere.
* Default: (54, 117, 255).
*/
zenithColor?: ColorDefProps;
/** The color of the bottom of the sphere.
* Default: (40, 15, 0).
*/
nadirColor?: ColorDefProps;
/** For a 4-color [[SkyGradient]], controls speed of change from sky color to zenith color; otherwise unused.
* Default: 4.0.
*/
skyExponent?: number;
/** For a 4-color [[SkyGradient]], controls speed of change from ground color to nadir color; otherwise unused.
* Default: 4.0.
*/
groundExponent?: number;
/** The image(s), if any, to be mapped to the surfaces of the sphere or cube. If undefined, the skybox will be displayed as a gradient instead.
* Default: undefined.
*/
image?: SkyBoxImageProps;
}
/** A type containing all of the properties and none of the methods of [[SkyGradient]] with `readonly` modifiers removed.
* @see [[SkyGradient.create]] and [[SkyGradient.clone]].
* @public
*/
export type SkyGradientProperties = NonFunctionPropertiesOf<SkyGradient>;
/** Describes how to map a two- or four-color [[Gradient]] to the interior of a sphere to produce a [[SkyBox]].
* @see [[SkyBox.gradient]].
* @public
*/
export declare class SkyGradient {
readonly twoColor: boolean;
readonly skyColor: ColorDef;
readonly groundColor: ColorDef;
readonly zenithColor: ColorDef;
readonly nadirColor: ColorDef;
readonly skyExponent: number;
readonly groundExponent: number;
private constructor();
/** Default settings for a four-color gradient. */
static readonly defaults: SkyGradient;
/** Create a new gradient. Any properties not specified by `props` are initialized to their default values. */
static create(props?: Partial<SkyGradientProperties>): SkyGradient;
/** Create from JSON representation. */
static fromJSON(props?: SkyBoxProps): SkyGradient;
/** Create ea copy of this gradient, identical except for any properties explicitly specified by `changedProps`.
* Any properties of `changedProps` explicitly set to `undefined` will be reset to their default values.
*/
clone(changedProps: SkyGradientProperties): SkyGradient;
/** Convert to JSON representation. */
toJSON(): SkyBoxProps;
/** Returns true if this gradient is equivalent to the supplied gradient. */
equals(other: SkyGradient): boolean;
}
/** Describes how to draw a representation of a sky, as part of an [[Environment]].
* @see [[SkyBoxProps]].
* @public
*/
export declare class SkyBox {
/** The gradient settings, used if no cube or sphere images are supplied, or if the images cannot be loaded. */
readonly gradient: SkyGradient;
protected constructor(gradient: SkyGradient);
/** Default settings for a four-color gradient. */
static readonly defaults: SkyBox;
/** Create a skybox that displays the specified gradient, or the default gradient if none is supplied. */
static createGradient(gradient?: SkyGradient): SkyBox;
/** Create from JSON representation. */
static fromJSON(props?: SkyBoxProps): SkyBox;
/** Convert to JSON representation.
* @param display If defined, the value to use for [[SkyBoxProps.display]]; otherwise, that property will be left undefined.
*/
toJSON(display?: boolean): SkyBoxProps;
/** @internal */
get textureIds(): Iterable<Id64String>;
}
/** Describes how to draw a representation of a sky by mapping a single image to the interior of a sphere.
* @public
*/
export declare class SkySphere extends SkyBox {
/** The image to map to the interior of the sphere. */
readonly image: TextureImageSpec;
/** Create a new sky sphere using the specified image.
* @param image The image to map to the interior of the sphere.
* @param gradient Optionally overrides the default gradient settings used if the image cannot be obtained.
*/
constructor(image: TextureImageSpec, gradient?: SkyGradient);
/** See [[SkyBox.toJSON]]. */
toJSON(display?: boolean): SkyBoxProps;
/** @internal */
get textureIds(): Iterable<Id64String>;
}
/** Describes how to draw a representation of a sky by mapping images to the interior faces of a cube.
* The images are required to be *square*, and each image must have the same dimensions as the other images.
* @public
*/
export declare class SkyCube extends SkyBox {
/** The images to map to each face of the cube. */
readonly images: SkyCubeProps;
/** Create a new sky cube using the specified images.
* @param images The images to map to each face of the cube.
* @param gradient Optionally overrides the default gradient settings used if the images cannot be obtained.
*/
constructor(images: SkyCubeProps, gradient?: SkyGradient);
/** See [[SkyBox.toJSON]]. */
toJSON(display?: boolean): SkyBoxProps;
/** @internal */
get textureIds(): Iterable<Id64String>;
}
//# sourceMappingURL=SkyBox.d.ts.map