-
Notifications
You must be signed in to change notification settings - Fork 208
/
Decorations.ts
77 lines (67 loc) · 3.42 KB
/
Decorations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Rendering
*/
import { dispose, disposeArray, IDisposable } from "@itwin/core-bentley";
import { CanvasDecorationList } from "./CanvasDecoration";
import { GraphicList, RenderGraphic } from "./RenderGraphic";
/** A set of [[RenderGraphic]]s and [[CanvasDecoration]]s produced by [[Tool]]s and [[Decorator]]s, used to decorate the contents of a [[Viewport]].
* @public
* @extensions
*/
export class Decorations implements IDisposable {
private _skyBox?: RenderGraphic;
private _viewBackground?: RenderGraphic; // drawn first, view units, with no zbuffer, smooth shading, default lighting. e.g., a skybox
private _normal?: GraphicList; // drawn with zbuffer, with scene lighting
private _world?: GraphicList; // drawn with zbuffer, with default lighting, smooth shading
private _worldOverlay?: GraphicList; // drawn in overlay mode, world units
private _viewOverlay?: GraphicList; // drawn in overlay mode, view units
public canvasDecorations?: CanvasDecorationList;
/** A view decoration created from a [[SkyBox]] rendered behind all other geometry to provide environmental context. */
public get skyBox(): RenderGraphic | undefined { return this._skyBox; }
public set skyBox(skyBox: RenderGraphic | undefined) {
dispose(this._skyBox);
this._skyBox = skyBox;
}
/** A view decoration drawn as the background of the view. @see [[GraphicType.ViewBackground]]. */
public get viewBackground(): RenderGraphic | undefined { return this._viewBackground; }
public set viewBackground(viewBackground: RenderGraphic | undefined) {
dispose(this._viewBackground);
this._viewBackground = viewBackground;
}
/** Decorations drawn as if they were part of the scene. @see [[GraphicType.Scene]]. */
public get normal(): GraphicList | undefined { return this._normal; }
public set normal(normal: GraphicList | undefined) {
disposeArray(this._normal);
this._normal = normal;
}
/** Decorations drawn as if they were part of the world, but ignoring the view's [[ViewFlags]]. @see [[GraphicType.WorldDecoration]]. */
public get world(): GraphicList | undefined { return this._world; }
public set world(world: GraphicList | undefined) {
disposeArray(this._world);
this._world = world;
}
/** Overlay decorations drawn in world coordinates. @see [[GraphicType.WorldOverlay]]. */
public get worldOverlay(): GraphicList | undefined { return this._worldOverlay; }
public set worldOverlay(worldOverlay: GraphicList | undefined) {
disposeArray(this._worldOverlay);
this._worldOverlay = worldOverlay;
}
/** Overlay decorations drawn in view coordinates. @see [[GraphicType.ViewOverlay]]. */
public get viewOverlay(): GraphicList | undefined { return this._viewOverlay; }
public set viewOverlay(viewOverlay: GraphicList | undefined) {
disposeArray(this._viewOverlay);
this._viewOverlay = viewOverlay;
}
public dispose() {
this.skyBox = undefined;
this.viewBackground = undefined;
this.world = undefined;
this.worldOverlay = undefined;
this.viewOverlay = undefined;
this.normal = undefined;
}
}