/
NodeAppearance.ts
149 lines (136 loc) · 3.94 KB
/
NodeAppearance.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*!
* Copyright 2021 Cognite AS
*/
import { Color } from 'three';
export enum NodeOutlineColor {
NoOutline = 0,
White,
Black,
Cyan,
Blue,
Green,
Red,
Orange
}
/**
* Type for defining node appearance profiles to style a 3D CAD model.
* @see {@link DefaultNodeAppearance}
*/
export type NodeAppearance = {
/**
* Overrides the default color of the node in RGB. Black,
* or `new Color(0, 0, 0)` means no override.
*/
readonly color?: Color;
/**
* Overrides the visibility of the node.
*/
readonly visible?: boolean;
/**
* When set to true, the node is rendered in front
* of all other nodes even if it's occluded.
* Note that this take precedence over {@link NodeAppearance.renderGhosted}.
*/
readonly renderInFront?: boolean;
/**
* When set to true, the node is rendered ghosted, i.e.
* transparent with a fixed color. This has no effect if {@link NodeAppearance.renderInFront}
* is `true`.
*/
readonly renderGhosted?: boolean;
/**
* When set, an outline is drawn around the
* node to make it stand out.
*/
readonly outlineColor?: NodeOutlineColor;
/**
* When provided, this value can be used to prioritize certain areas of the
* 3D model to be loaded. This can be useful to prioritize key objects in the
* 3D model to always be loaded.
*
* When non-zero, sectors containing geometry in the vicinity of the prioritized
* sectors are given an *extra* priority. Recommended values are in range 1 (somewhat
* higher priority to be loaded) to 10 (very likely to be loaded). Usually values around 4-5
* is recommended.
*
* Prioritized nodes are loaded at the expense of non-prioritized areas. There are no
* guarantees that the nodes are actually loaded, and the more prioritized areas/nodes
* provided, the less likely it is that the hint is obeyed.
*
* Extra priority doesn't accumulate when sectors are prioritized because they intersect/contain
* several nodes.
*
* **This is an advanced feature and not recommended for most users**
*
* @version Only works with 3D models converted later than Q4 2021.
*/
readonly prioritizedForLoadingHint?: number;
};
/**
* Type that represents a {@link NodeAppearance} in a serializable format
*/
export type SerializableNodeAppearance = {
/**
* Color as an RGB number tuple, with values in the range [0, 255]
*/
readonly color?: [number, number, number];
/**
* Visibility, @see {@link NodeAppearance}
*/
readonly visible?: boolean;
/**
* Whether to render in front, @see {@link NodeAppearance}
*/
readonly renderInFront?: boolean;
/**
* Whether to render ghosted, @see {@link NodeAppearance}
*/
readonly renderGhosted?: boolean;
/**
* Outline color, @see {@link NodeAppearance}
*/
readonly outlineColor?: NodeOutlineColor;
/**
* Prioritized loading hint, @see {@link NodeAppearance}
*/
readonly prioritizedForLoadingHint?: number;
};
const OutlinedAppearance: NodeAppearance = {
visible: true,
outlineColor: NodeOutlineColor.White
};
const HiddenAppearance: NodeAppearance = {
visible: false
};
const InFrontAppearance: NodeAppearance = {
visible: true,
renderInFront: true
};
const HighlightedColorAppearance: NodeAppearance = {
visible: true,
renderGhosted: false,
color: new Color(0.392, 0.392, 1.0)
};
const GhostedAppearance: NodeAppearance = {
visible: true,
renderGhosted: true
};
const DefaultAppearance: NodeAppearance = {
visible: true,
renderGhosted: false,
renderInFront: false,
outlineColor: NodeOutlineColor.NoOutline,
color: new Color('black'),
prioritizedForLoadingHint: 0
};
/**
* A set of default node appearances used in Reveal.
*/
export const DefaultNodeAppearance = {
Default: DefaultAppearance,
Outlined: OutlinedAppearance,
Hidden: HiddenAppearance,
InFront: InFrontAppearance,
Ghosted: GhostedAppearance,
Highlighted: { ...InFrontAppearance, ...HighlightedColorAppearance, ...OutlinedAppearance }
};