@shapediver/viewer.features.attribute-visualization 3.16.8 → 3.16.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/implementation/AttributeVisualizationEngine.d.ts +42 -42
- package/dist/implementation/AttributeVisualizationEngine.js +358 -358
- package/dist/implementation/AttributeVisualizationEngine.js.map +1 -1
- package/dist/implementation/AttributeVisualizationUtils.d.ts +11 -11
- package/dist/implementation/AttributeVisualizationUtils.d.ts.map +1 -1
- package/dist/implementation/AttributeVisualizationUtils.js +805 -805
- package/dist/implementation/AttributeVisualizationUtils.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +15 -15
- package/dist/interfaces/IAttribute.d.ts +20 -20
- package/dist/interfaces/IAttribute.d.ts.map +1 -1
- package/dist/interfaces/IAttribute.js +2 -2
- package/dist/interfaces/IAttributeVisualizationEngine.d.ts +39 -39
- package/dist/interfaces/IAttributeVisualizationEngine.js +2 -2
- package/dist/interfaces/IGradient.d.ts +5 -5
- package/dist/interfaces/IGradient.d.ts.map +1 -1
- package/dist/interfaces/IGradient.js +13 -13
- package/dist/interfaces/ILayer.d.ts +6 -6
- package/dist/interfaces/ILayer.js +2 -2
- package/package.json +7 -7
|
@@ -1,806 +1,806 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AttributeVisualizationUtils = exports.getColorAt = exports.getColorSteps = void 0;
|
|
4
|
-
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
5
|
-
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
6
|
-
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
7
|
-
const gl_matrix_1 = require("gl-matrix");
|
|
8
|
-
const IGradient_1 = require("../interfaces/IGradient");
|
|
9
|
-
/** Shared identity matrix — never mutate this. */
|
|
10
|
-
const IDENTITY_MATRIX = gl_matrix_1.mat4.create();
|
|
11
|
-
/** Singleton converter reference, resolved once. */
|
|
12
|
-
let _converter;
|
|
13
|
-
const getConverter = () => _converter || (_converter = viewer_shared_services_1.Converter.instance);
|
|
14
|
-
/** Cache for getColorSteps — gradient arrays are immutable, only create once. */
|
|
15
|
-
const colorStepsCache = new Map();
|
|
16
|
-
const getColorSteps = (gradient) => {
|
|
17
|
-
const cached = colorStepsCache.get(gradient);
|
|
18
|
-
if (cached !== undefined)
|
|
19
|
-
return cached;
|
|
20
|
-
const result = computeColorSteps(gradient);
|
|
21
|
-
colorStepsCache.set(gradient, result);
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
exports.getColorSteps = getColorSteps;
|
|
25
|
-
const computeColorSteps = (gradient) => {
|
|
26
|
-
switch (gradient) {
|
|
27
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
28
|
-
return [
|
|
29
|
-
{
|
|
30
|
-
value: 0,
|
|
31
|
-
colorBefore: "rgb(0, 0, 0)",
|
|
32
|
-
colorAfter: "rgb(0, 0, 0)",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
value: 1,
|
|
36
|
-
colorBefore: "rgb(255, 255, 255)",
|
|
37
|
-
colorAfter: "rgb(255, 255, 255)",
|
|
38
|
-
},
|
|
39
|
-
];
|
|
40
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
41
|
-
return [
|
|
42
|
-
{
|
|
43
|
-
value: 0,
|
|
44
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
45
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
value: 1,
|
|
49
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
50
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
value: 0,
|
|
57
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
58
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
value: 0.5,
|
|
62
|
-
colorBefore: "rgb(255, 255, 255)",
|
|
63
|
-
colorAfter: "rgb(255, 255, 255)",
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
value: 1,
|
|
67
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
68
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
72
|
-
return [
|
|
73
|
-
{
|
|
74
|
-
value: 0,
|
|
75
|
-
colorBefore: "rgb(0, 255, 0)",
|
|
76
|
-
colorAfter: "rgb(0, 255, 0)",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
value: 1,
|
|
80
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
81
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
85
|
-
return [
|
|
86
|
-
{
|
|
87
|
-
value: 0,
|
|
88
|
-
colorBefore: "rgb(0, 255, 0)",
|
|
89
|
-
colorAfter: "rgb(0, 255, 0)",
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
value: 0.5,
|
|
93
|
-
colorBefore: "rgb(255, 255, 255)",
|
|
94
|
-
colorAfter: "rgb(255, 255, 255)",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
value: 1,
|
|
98
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
99
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
100
|
-
},
|
|
101
|
-
];
|
|
102
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_YELLOW_RED:
|
|
103
|
-
return [
|
|
104
|
-
{
|
|
105
|
-
value: 0,
|
|
106
|
-
colorBefore: "rgb(0, 255, 0)",
|
|
107
|
-
colorAfter: "rgb(0, 255, 0)",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
value: 0.5,
|
|
111
|
-
colorBefore: "rgb(255, 255, 0)",
|
|
112
|
-
colorAfter: "rgb(255, 255, 0)",
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
value: 1,
|
|
116
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
117
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
118
|
-
},
|
|
119
|
-
];
|
|
120
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_YELLOW_RED:
|
|
121
|
-
return [
|
|
122
|
-
{
|
|
123
|
-
value: 0,
|
|
124
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
125
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
value: 0.5,
|
|
129
|
-
colorBefore: "rgb(255, 255, 0)",
|
|
130
|
-
colorAfter: "rgb(255, 255, 0)",
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
value: 1,
|
|
134
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
135
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
136
|
-
},
|
|
137
|
-
];
|
|
138
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
139
|
-
return [
|
|
140
|
-
{
|
|
141
|
-
value: 0,
|
|
142
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
143
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
value: 0.5,
|
|
147
|
-
colorBefore: "rgb(0, 255, 0)",
|
|
148
|
-
colorAfter: "rgb(0, 255, 0)",
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
value: 1,
|
|
152
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
153
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
157
|
-
return [
|
|
158
|
-
{
|
|
159
|
-
value: 0,
|
|
160
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
161
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
value: 0.2,
|
|
165
|
-
colorBefore: "rgb(0, 255, 0)",
|
|
166
|
-
colorAfter: "rgb(0, 255, 0)",
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
value: 0.4,
|
|
170
|
-
colorBefore: "rgb(255, 255, 0)",
|
|
171
|
-
colorAfter: "rgb(255, 255, 0)",
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
value: 0.6,
|
|
175
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
176
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
value: 0.8,
|
|
180
|
-
colorBefore: "rgb(255, 0, 255)",
|
|
181
|
-
colorAfter: "rgb(255, 0, 255)",
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
value: 1,
|
|
185
|
-
colorBefore: "rgb(255, 255, 255)",
|
|
186
|
-
colorAfter: "rgb(255, 255, 255)",
|
|
187
|
-
},
|
|
188
|
-
];
|
|
189
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.VIRIDIS:
|
|
190
|
-
return [
|
|
191
|
-
{
|
|
192
|
-
value: 0.0,
|
|
193
|
-
colorBefore: "rgb(68, 1, 84)",
|
|
194
|
-
colorAfter: "rgb(68, 1, 84)",
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
value: 0.1,
|
|
198
|
-
colorBefore: "rgb(65, 44, 123)",
|
|
199
|
-
colorAfter: "rgb(65, 44, 123)",
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
value: 0.2,
|
|
203
|
-
colorBefore: "rgb(52, 83, 138)",
|
|
204
|
-
colorAfter: "rgb(52, 83, 138)",
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
value: 0.3,
|
|
208
|
-
colorBefore: "rgb(38, 119, 140)",
|
|
209
|
-
colorAfter: "rgb(38, 119, 140)",
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
value: 0.4,
|
|
213
|
-
colorBefore: "rgb(31, 144, 137)",
|
|
214
|
-
colorAfter: "rgb(31, 144, 137)",
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
value: 0.5,
|
|
218
|
-
colorBefore: "rgb(37, 170, 121)",
|
|
219
|
-
colorAfter: "rgb(37, 170, 121)",
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
value: 0.6,
|
|
223
|
-
colorBefore: "rgb(86, 193, 90)",
|
|
224
|
-
colorAfter: "rgb(86, 193, 90)",
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
value: 0.7,
|
|
228
|
-
colorBefore: "rgb(150, 211, 45)",
|
|
229
|
-
colorAfter: "rgb(150, 211, 45)",
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
value: 0.8,
|
|
233
|
-
colorBefore: "rgb(218, 230, 35)",
|
|
234
|
-
colorAfter: "rgb(218, 230, 35)",
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
value: 0.9,
|
|
238
|
-
colorBefore: "rgb(253, 231, 36)",
|
|
239
|
-
colorAfter: "rgb(253, 231, 36)",
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
value: 1.0,
|
|
243
|
-
colorBefore: "rgb(252, 254, 178)",
|
|
244
|
-
colorAfter: "rgb(252, 254, 178)",
|
|
245
|
-
},
|
|
246
|
-
];
|
|
247
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.PLASMA:
|
|
248
|
-
return [
|
|
249
|
-
{
|
|
250
|
-
value: 0.0,
|
|
251
|
-
colorBefore: "rgb(13, 8, 135)",
|
|
252
|
-
colorAfter: "rgb(13, 8, 135)",
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
value: 0.1,
|
|
256
|
-
colorBefore: "rgb(75, 3, 161)",
|
|
257
|
-
colorAfter: "rgb(75, 3, 161)",
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
value: 0.2,
|
|
261
|
-
colorBefore: "rgb(125, 3, 168)",
|
|
262
|
-
colorAfter: "rgb(125, 3, 168)",
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
value: 0.3,
|
|
266
|
-
colorBefore: "rgb(168, 34, 150)",
|
|
267
|
-
colorAfter: "rgb(168, 34, 150)",
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
value: 0.4,
|
|
271
|
-
colorBefore: "rgb(203, 70, 121)",
|
|
272
|
-
colorAfter: "rgb(203, 70, 121)",
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
value: 0.5,
|
|
276
|
-
colorBefore: "rgb(229, 107, 93)",
|
|
277
|
-
colorAfter: "rgb(229, 107, 93)",
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
value: 0.6,
|
|
281
|
-
colorBefore: "rgb(248, 148, 65)",
|
|
282
|
-
colorAfter: "rgb(248, 148, 65)",
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
value: 0.7,
|
|
286
|
-
colorBefore: "rgb(253, 195, 40)",
|
|
287
|
-
colorAfter: "rgb(253, 195, 40)",
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
value: 0.8,
|
|
291
|
-
colorBefore: "rgb(240, 242, 51)",
|
|
292
|
-
colorAfter: "rgb(240, 242, 51)",
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
value: 0.9,
|
|
296
|
-
colorBefore: "rgb(210, 252, 98)",
|
|
297
|
-
colorAfter: "rgb(210, 252, 98)",
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
value: 1.0,
|
|
301
|
-
colorBefore: "rgb(254, 255, 178)",
|
|
302
|
-
colorAfter: "rgb(254, 255, 178)",
|
|
303
|
-
},
|
|
304
|
-
];
|
|
305
|
-
return [
|
|
306
|
-
{
|
|
307
|
-
value: 0.0,
|
|
308
|
-
colorBefore: "rgb(0, 0, 127)",
|
|
309
|
-
colorAfter: "rgb(0, 0, 127)",
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
value: 0.1,
|
|
313
|
-
colorBefore: "rgb(0, 0, 191)",
|
|
314
|
-
colorAfter: "rgb(0, 0, 191)",
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
value: 0.2,
|
|
318
|
-
colorBefore: "rgb(0, 0, 255)",
|
|
319
|
-
colorAfter: "rgb(0, 0, 255)",
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
value: 0.3,
|
|
323
|
-
colorBefore: "rgb(63, 63, 255)",
|
|
324
|
-
colorAfter: "rgb(63, 63, 255)",
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
value: 0.4,
|
|
328
|
-
colorBefore: "rgb(127, 127, 255)",
|
|
329
|
-
colorAfter: "rgb(127, 127, 255)",
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
value: 0.5,
|
|
333
|
-
colorBefore: "rgb(255, 255, 255)",
|
|
334
|
-
colorAfter: "rgb(255, 255, 255)",
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
value: 0.6,
|
|
338
|
-
colorBefore: "rgb(255, 127, 127)",
|
|
339
|
-
colorAfter: "rgb(255, 127, 127)",
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
value: 0.7,
|
|
343
|
-
colorBefore: "rgb(255, 63, 63)",
|
|
344
|
-
colorAfter: "rgb(255, 63, 63)",
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
value: 0.8,
|
|
348
|
-
colorBefore: "rgb(255, 0, 0)",
|
|
349
|
-
colorAfter: "rgb(255, 0, 0)",
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
value: 0.9,
|
|
353
|
-
colorBefore: "rgb(191, 0, 0)",
|
|
354
|
-
colorAfter: "rgb(191, 0, 0)",
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
value: 1.0,
|
|
358
|
-
colorBefore: "rgb(127, 0, 0)",
|
|
359
|
-
colorAfter: "rgb(127, 0, 0)",
|
|
360
|
-
},
|
|
361
|
-
];
|
|
362
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.TURBO:
|
|
363
|
-
return [
|
|
364
|
-
{
|
|
365
|
-
value: 0.0,
|
|
366
|
-
colorBefore: "rgb(48, 18, 59)",
|
|
367
|
-
colorAfter: "rgb(48, 18, 59)",
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
value: 0.1,
|
|
371
|
-
colorBefore: "rgb(55, 47, 122)",
|
|
372
|
-
colorAfter: "rgb(55, 47, 122)",
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
value: 0.2,
|
|
376
|
-
colorBefore: "rgb(23, 111, 171)",
|
|
377
|
-
colorAfter: "rgb(23, 111, 171)",
|
|
378
|
-
},
|
|
379
|
-
{
|
|
380
|
-
value: 0.3,
|
|
381
|
-
colorBefore: "rgb(16, 153, 142)",
|
|
382
|
-
colorAfter: "rgb(16, 153, 142)",
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
value: 0.4,
|
|
386
|
-
colorBefore: "rgb(69, 186, 99)",
|
|
387
|
-
colorAfter: "rgb(69, 186, 99)",
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
value: 0.5,
|
|
391
|
-
colorBefore: "rgb(165, 202, 65)",
|
|
392
|
-
colorAfter: "rgb(165, 202, 65)",
|
|
393
|
-
},
|
|
394
|
-
{
|
|
395
|
-
value: 0.6,
|
|
396
|
-
colorBefore: "rgb(234, 190, 70)",
|
|
397
|
-
colorAfter: "rgb(234, 190, 70)",
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
value: 0.7,
|
|
401
|
-
colorBefore: "rgb(251, 142, 79)",
|
|
402
|
-
colorAfter: "rgb(251, 142, 79)",
|
|
403
|
-
},
|
|
404
|
-
{
|
|
405
|
-
value: 0.8,
|
|
406
|
-
colorBefore: "rgb(243, 87, 65)",
|
|
407
|
-
colorAfter: "rgb(243, 87, 65)",
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
value: 0.9,
|
|
411
|
-
colorBefore: "rgb(224, 37, 77)",
|
|
412
|
-
colorAfter: "rgb(224, 37, 77)",
|
|
413
|
-
},
|
|
414
|
-
{
|
|
415
|
-
value: 1.0,
|
|
416
|
-
colorBefore: "rgb(127, 0, 45)",
|
|
417
|
-
colorAfter: "rgb(127, 0, 45)",
|
|
418
|
-
},
|
|
419
|
-
];
|
|
420
|
-
return [
|
|
421
|
-
{
|
|
422
|
-
value: 0.0,
|
|
423
|
-
colorBefore: "rgb(0, 0, 3)",
|
|
424
|
-
colorAfter: "rgb(0, 0, 3)",
|
|
425
|
-
},
|
|
426
|
-
{
|
|
427
|
-
value: 0.1,
|
|
428
|
-
colorBefore: "rgb(31, 12, 72)",
|
|
429
|
-
colorAfter: "rgb(31, 12, 72)",
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
value: 0.2,
|
|
433
|
-
colorBefore: "rgb(85, 15, 109)",
|
|
434
|
-
colorAfter: "rgb(85, 15, 109)",
|
|
435
|
-
},
|
|
436
|
-
{
|
|
437
|
-
value: 0.3,
|
|
438
|
-
colorBefore: "rgb(136, 34, 106)",
|
|
439
|
-
colorAfter: "rgb(136, 34, 106)",
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
value: 0.4,
|
|
443
|
-
colorBefore: "rgb(186, 54, 85)",
|
|
444
|
-
colorAfter: "rgb(186, 54, 85)",
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
value: 0.5,
|
|
448
|
-
colorBefore: "rgb(227, 89, 51)",
|
|
449
|
-
colorAfter: "rgb(227, 89, 51)",
|
|
450
|
-
},
|
|
451
|
-
{
|
|
452
|
-
value: 0.6,
|
|
453
|
-
colorBefore: "rgb(249, 140, 10)",
|
|
454
|
-
colorAfter: "rgb(249, 140, 10)",
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
value: 0.7,
|
|
458
|
-
colorBefore: "rgb(252, 190, 57)",
|
|
459
|
-
colorAfter: "rgb(252, 190, 57)",
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
value: 0.8,
|
|
463
|
-
colorBefore: "rgb(241, 237, 105)",
|
|
464
|
-
colorAfter: "rgb(241, 237, 105)",
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
value: 0.9,
|
|
468
|
-
colorBefore: "rgb(252, 253, 191)",
|
|
469
|
-
colorAfter: "rgb(252, 253, 191)",
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
value: 1.0,
|
|
473
|
-
colorBefore: "rgb(252, 254, 164)",
|
|
474
|
-
colorAfter: "rgb(252, 254, 164)",
|
|
475
|
-
},
|
|
476
|
-
];
|
|
477
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.MAGMA:
|
|
478
|
-
return [
|
|
479
|
-
{
|
|
480
|
-
value: 0.0,
|
|
481
|
-
colorBefore: "rgb(0, 0, 4)",
|
|
482
|
-
colorAfter: "rgb(0, 0, 4)",
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
value: 0.1,
|
|
486
|
-
colorBefore: "rgb(28, 16, 68)",
|
|
487
|
-
colorAfter: "rgb(28, 16, 68)",
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
value: 0.2,
|
|
491
|
-
colorBefore: "rgb(79, 18, 123)",
|
|
492
|
-
colorAfter: "rgb(79, 18, 123)",
|
|
493
|
-
},
|
|
494
|
-
{
|
|
495
|
-
value: 0.3,
|
|
496
|
-
colorBefore: "rgb(129, 37, 129)",
|
|
497
|
-
colorAfter: "rgb(129, 37, 129)",
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
value: 0.4,
|
|
501
|
-
colorBefore: "rgb(178, 65, 114)",
|
|
502
|
-
colorAfter: "rgb(178, 65, 114)",
|
|
503
|
-
},
|
|
504
|
-
{
|
|
505
|
-
value: 0.5,
|
|
506
|
-
colorBefore: "rgb(221, 104, 89)",
|
|
507
|
-
colorAfter: "rgb(221, 104, 89)",
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
value: 0.6,
|
|
511
|
-
colorBefore: "rgb(251, 150, 62)",
|
|
512
|
-
colorAfter: "rgb(251, 150, 62)",
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
value: 0.7,
|
|
516
|
-
colorBefore: "rgb(254, 198, 83)",
|
|
517
|
-
colorAfter: "rgb(254, 198, 83)",
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
value: 0.8,
|
|
521
|
-
colorBefore: "rgb(237, 243, 129)",
|
|
522
|
-
colorAfter: "rgb(237, 243, 129)",
|
|
523
|
-
},
|
|
524
|
-
{
|
|
525
|
-
value: 0.9,
|
|
526
|
-
colorBefore: "rgb(252, 254, 191)",
|
|
527
|
-
colorAfter: "rgb(252, 254, 191)",
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
value: 1.0,
|
|
531
|
-
colorBefore: "rgb(252, 254, 164)",
|
|
532
|
-
colorAfter: "rgb(252, 254, 164)",
|
|
533
|
-
},
|
|
534
|
-
];
|
|
535
|
-
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.CIVIDIS:
|
|
536
|
-
return [
|
|
537
|
-
{
|
|
538
|
-
value: 0.0,
|
|
539
|
-
colorBefore: "rgb(0, 32, 76)",
|
|
540
|
-
colorAfter: "rgb(0, 32, 76)",
|
|
541
|
-
},
|
|
542
|
-
{
|
|
543
|
-
value: 0.1,
|
|
544
|
-
colorBefore: "rgb(20, 53, 96)",
|
|
545
|
-
colorAfter: "rgb(20, 53, 96)",
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
value: 0.2,
|
|
549
|
-
colorBefore: "rgb(48, 75, 108)",
|
|
550
|
-
colorAfter: "rgb(48, 75, 108)",
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
value: 0.3,
|
|
554
|
-
colorBefore: "rgb(82, 95, 115)",
|
|
555
|
-
colorAfter: "rgb(82, 95, 115)",
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
value: 0.4,
|
|
559
|
-
colorBefore: "rgb(120, 113, 114)",
|
|
560
|
-
colorAfter: "rgb(120, 113, 114)",
|
|
561
|
-
},
|
|
562
|
-
{
|
|
563
|
-
value: 0.5,
|
|
564
|
-
colorBefore: "rgb(159, 130, 109)",
|
|
565
|
-
colorAfter: "rgb(159, 130, 109)",
|
|
566
|
-
},
|
|
567
|
-
{
|
|
568
|
-
value: 0.6,
|
|
569
|
-
colorBefore: "rgb(195, 145, 99)",
|
|
570
|
-
colorAfter: "rgb(195, 145, 99)",
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
value: 0.7,
|
|
574
|
-
colorBefore: "rgb(227, 158, 85)",
|
|
575
|
-
colorAfter: "rgb(227, 158, 85)",
|
|
576
|
-
},
|
|
577
|
-
{
|
|
578
|
-
value: 0.8,
|
|
579
|
-
colorBefore: "rgb(251, 171, 71)",
|
|
580
|
-
colorAfter: "rgb(251, 171, 71)",
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
value: 0.9,
|
|
584
|
-
colorBefore: "rgb(254, 200, 116)",
|
|
585
|
-
colorAfter: "rgb(254, 200, 116)",
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
value: 1.0,
|
|
589
|
-
colorBefore: "rgb(252, 255, 164)",
|
|
590
|
-
colorAfter: "rgb(252, 255, 164)",
|
|
591
|
-
},
|
|
592
|
-
];
|
|
593
|
-
default:
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
};
|
|
597
|
-
const getColorAt = (gradient, factor) => {
|
|
598
|
-
const steps = (0, exports.getColorSteps)(gradient);
|
|
599
|
-
if (!steps)
|
|
600
|
-
return;
|
|
601
|
-
for (let i = 0; i < steps.length; i++) {
|
|
602
|
-
if (steps[i].value >= factor) {
|
|
603
|
-
// check if the value is the first step
|
|
604
|
-
if (i === 0) {
|
|
605
|
-
return steps[i].colorBefore;
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
// get the previous color
|
|
609
|
-
const previousColor = steps[i - 1].colorAfter;
|
|
610
|
-
// get the current color
|
|
611
|
-
const currentColor = steps[i].colorBefore;
|
|
612
|
-
// calculate where the factor is between the two colors
|
|
613
|
-
const stepFactor = (factor - steps[i - 1].value) /
|
|
614
|
-
(steps[i].value - steps[i - 1].value);
|
|
615
|
-
// return interpolated color
|
|
616
|
-
return interpolateColors(previousColor, currentColor, stepFactor);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
// return the after color of the last step
|
|
621
|
-
return steps[steps.length - 1].colorAfter;
|
|
622
|
-
};
|
|
623
|
-
exports.getColorAt = getColorAt;
|
|
624
|
-
const opacityVisualization = (factor, materialType, defaultMaterial) => {
|
|
625
|
-
// factor clamped to [0, 1]
|
|
626
|
-
factor = Math.max(0, Math.min(1, factor));
|
|
627
|
-
return {
|
|
628
|
-
material: materialType === "unlit"
|
|
629
|
-
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
630
|
-
color: defaultMaterial.color,
|
|
631
|
-
opacity: factor,
|
|
632
|
-
})
|
|
633
|
-
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
634
|
-
color: defaultMaterial.color,
|
|
635
|
-
opacity: factor,
|
|
636
|
-
}),
|
|
637
|
-
matrix: IDENTITY_MATRIX,
|
|
638
|
-
};
|
|
639
|
-
};
|
|
640
|
-
const hslVisualization = (factor, materialType) => {
|
|
641
|
-
// factor clamped to [0, 1]
|
|
642
|
-
factor = Math.max(0, Math.min(1, factor));
|
|
643
|
-
const hue = factor * 359.99;
|
|
644
|
-
return {
|
|
645
|
-
material: materialType === "unlit"
|
|
646
|
-
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
647
|
-
color: "hsl(" + Math.floor(hue) + ", 100%, 50%)",
|
|
648
|
-
opacity: 1,
|
|
649
|
-
})
|
|
650
|
-
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
651
|
-
color: "hsl(" + Math.floor(hue) + ", 100%, 50%)",
|
|
652
|
-
opacity: 1,
|
|
653
|
-
}),
|
|
654
|
-
matrix: IDENTITY_MATRIX,
|
|
655
|
-
};
|
|
656
|
-
};
|
|
657
|
-
const interpolateColors = (color1, color2, factor) => {
|
|
658
|
-
const converter = getConverter();
|
|
659
|
-
const colorArray1 = converter.toColorArray(color1);
|
|
660
|
-
const colorArray2 = converter.toColorArray(color2);
|
|
661
|
-
// Interpolate the colors
|
|
662
|
-
const r = colorArray1[0] + factor * (colorArray2[0] - colorArray1[0]);
|
|
663
|
-
const g = colorArray1[1] + factor * (colorArray2[1] - colorArray1[1]);
|
|
664
|
-
const b = colorArray1[2] + factor * (colorArray2[2] - colorArray1[2]);
|
|
665
|
-
// Convert the interpolated color back to a hex string
|
|
666
|
-
return converter.toHexColor([r * 256, g * 256, b * 256]);
|
|
667
|
-
};
|
|
668
|
-
const numberGradientVisualization = (factor, gradient) => {
|
|
669
|
-
if (typeof gradient.steps === "string")
|
|
670
|
-
return;
|
|
671
|
-
for (let i = 0; i < gradient.steps.length; i++) {
|
|
672
|
-
if (gradient.steps[i].value >= factor) {
|
|
673
|
-
// check if the value is the first step
|
|
674
|
-
if (i === 0) {
|
|
675
|
-
return {
|
|
676
|
-
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
677
|
-
color: gradient.steps[i].colorBefore,
|
|
678
|
-
opacity: 1,
|
|
679
|
-
}),
|
|
680
|
-
matrix: IDENTITY_MATRIX,
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
else {
|
|
684
|
-
// get the previous color
|
|
685
|
-
const previousColor = gradient.steps[i - 1].colorAfter;
|
|
686
|
-
// get the current color
|
|
687
|
-
const currentColor = gradient.steps[i].colorBefore;
|
|
688
|
-
// calculate where the factor is between the two colors
|
|
689
|
-
const stepFactor = (factor - gradient.steps[i - 1].value) /
|
|
690
|
-
(gradient.steps[i].value - gradient.steps[i - 1].value);
|
|
691
|
-
// return interpolated color
|
|
692
|
-
return {
|
|
693
|
-
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
694
|
-
color: interpolateColors(previousColor, currentColor, stepFactor),
|
|
695
|
-
opacity: 1,
|
|
696
|
-
}),
|
|
697
|
-
matrix: IDENTITY_MATRIX,
|
|
698
|
-
};
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
// return the after color of the last step
|
|
703
|
-
return {
|
|
704
|
-
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
705
|
-
color: gradient.steps[gradient.steps.length - 1].colorAfter,
|
|
706
|
-
opacity: 1,
|
|
707
|
-
}),
|
|
708
|
-
matrix: IDENTITY_MATRIX,
|
|
709
|
-
};
|
|
710
|
-
};
|
|
711
|
-
const stringGradientVisualization = (value, gradient) => {
|
|
712
|
-
const steps = gradient.labelColors;
|
|
713
|
-
const stepCount = steps.length;
|
|
714
|
-
let color = gradient.defaultColor || "rgb(128, 128, 128)";
|
|
715
|
-
for (let i = 0; i < stepCount; i++) {
|
|
716
|
-
if (steps[i].values.includes(value)) {
|
|
717
|
-
color = steps[i].color;
|
|
718
|
-
break;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
return {
|
|
722
|
-
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
723
|
-
color: color,
|
|
724
|
-
opacity: 1,
|
|
725
|
-
}),
|
|
726
|
-
matrix: IDENTITY_MATRIX,
|
|
727
|
-
};
|
|
728
|
-
};
|
|
729
|
-
const numberVisualization = (value, min, max, type, materialType, defaultMaterial) => {
|
|
730
|
-
let factor = (value - min) / (max - min);
|
|
731
|
-
if (isNaN(factor))
|
|
732
|
-
factor = 0.5;
|
|
733
|
-
// check if the type is part of the enum
|
|
734
|
-
if (typeof type === "string") {
|
|
735
|
-
const color = (0, exports.getColorAt)(type, factor);
|
|
736
|
-
if (color) {
|
|
737
|
-
return {
|
|
738
|
-
material: materialType === "unlit"
|
|
739
|
-
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
740
|
-
color: color,
|
|
741
|
-
opacity: 1,
|
|
742
|
-
})
|
|
743
|
-
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
744
|
-
color: color,
|
|
745
|
-
opacity: 1,
|
|
746
|
-
}),
|
|
747
|
-
matrix: IDENTITY_MATRIX,
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.OPACITY) {
|
|
751
|
-
return opacityVisualization(factor, materialType, defaultMaterial);
|
|
752
|
-
}
|
|
753
|
-
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.HSL) {
|
|
754
|
-
return hslVisualization(factor, materialType);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
if ((0, IGradient_1.isNumberGradient)(type)) {
|
|
759
|
-
// check if the steps are a string
|
|
760
|
-
if (typeof type.steps === "string") {
|
|
761
|
-
// if so, we use the default gradient visualization
|
|
762
|
-
return numberVisualization(value, min, max, type.steps, materialType, defaultMaterial);
|
|
763
|
-
}
|
|
764
|
-
return numberGradientVisualization(factor, type);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
const stringVisualization = (value, values, type, materialType, defaultMaterial) => {
|
|
769
|
-
let factor = values.indexOf(value) / (values.length - 1);
|
|
770
|
-
if (isNaN(factor))
|
|
771
|
-
factor = 0.5;
|
|
772
|
-
// check if the type is part of the enum
|
|
773
|
-
if (typeof type === "string") {
|
|
774
|
-
const color = (0, exports.getColorAt)(type, factor);
|
|
775
|
-
if (color) {
|
|
776
|
-
return {
|
|
777
|
-
material: materialType === "unlit"
|
|
778
|
-
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
779
|
-
color: color,
|
|
780
|
-
opacity: 1,
|
|
781
|
-
})
|
|
782
|
-
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
783
|
-
color: color,
|
|
784
|
-
opacity: 1,
|
|
785
|
-
}),
|
|
786
|
-
matrix: IDENTITY_MATRIX,
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.OPACITY) {
|
|
790
|
-
return opacityVisualization(factor, materialType, defaultMaterial);
|
|
791
|
-
}
|
|
792
|
-
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.HSL) {
|
|
793
|
-
return hslVisualization(factor, materialType);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
else {
|
|
797
|
-
if ((0, IGradient_1.isStringGradient)(type)) {
|
|
798
|
-
return stringGradientVisualization(value, type);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
exports.AttributeVisualizationUtils = {
|
|
803
|
-
numberVisualization,
|
|
804
|
-
stringVisualization,
|
|
805
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttributeVisualizationUtils = exports.getColorAt = exports.getColorSteps = void 0;
|
|
4
|
+
const viewer_shared_node_tree_1 = require("@shapediver/viewer.shared.node-tree");
|
|
5
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
6
|
+
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
7
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
8
|
+
const IGradient_1 = require("../interfaces/IGradient");
|
|
9
|
+
/** Shared identity matrix — never mutate this. */
|
|
10
|
+
const IDENTITY_MATRIX = gl_matrix_1.mat4.create();
|
|
11
|
+
/** Singleton converter reference, resolved once. */
|
|
12
|
+
let _converter;
|
|
13
|
+
const getConverter = () => _converter || (_converter = viewer_shared_services_1.Converter.instance);
|
|
14
|
+
/** Cache for getColorSteps — gradient arrays are immutable, only create once. */
|
|
15
|
+
const colorStepsCache = new Map();
|
|
16
|
+
const getColorSteps = (gradient) => {
|
|
17
|
+
const cached = colorStepsCache.get(gradient);
|
|
18
|
+
if (cached !== undefined)
|
|
19
|
+
return cached;
|
|
20
|
+
const result = computeColorSteps(gradient);
|
|
21
|
+
colorStepsCache.set(gradient, result);
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
exports.getColorSteps = getColorSteps;
|
|
25
|
+
const computeColorSteps = (gradient) => {
|
|
26
|
+
switch (gradient) {
|
|
27
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
value: 0,
|
|
31
|
+
colorBefore: "rgb(0, 0, 0)",
|
|
32
|
+
colorAfter: "rgb(0, 0, 0)",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
value: 1,
|
|
36
|
+
colorBefore: "rgb(255, 255, 255)",
|
|
37
|
+
colorAfter: "rgb(255, 255, 255)",
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
value: 0,
|
|
44
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
45
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: 1,
|
|
49
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
50
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
value: 0,
|
|
57
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
58
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: 0.5,
|
|
62
|
+
colorBefore: "rgb(255, 255, 255)",
|
|
63
|
+
colorAfter: "rgb(255, 255, 255)",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 1,
|
|
67
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
68
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
value: 0,
|
|
75
|
+
colorBefore: "rgb(0, 255, 0)",
|
|
76
|
+
colorAfter: "rgb(0, 255, 0)",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: 1,
|
|
80
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
81
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
value: 0,
|
|
88
|
+
colorBefore: "rgb(0, 255, 0)",
|
|
89
|
+
colorAfter: "rgb(0, 255, 0)",
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: 0.5,
|
|
93
|
+
colorBefore: "rgb(255, 255, 255)",
|
|
94
|
+
colorAfter: "rgb(255, 255, 255)",
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
value: 1,
|
|
98
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
99
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.GREEN_YELLOW_RED:
|
|
103
|
+
return [
|
|
104
|
+
{
|
|
105
|
+
value: 0,
|
|
106
|
+
colorBefore: "rgb(0, 255, 0)",
|
|
107
|
+
colorAfter: "rgb(0, 255, 0)",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
value: 0.5,
|
|
111
|
+
colorBefore: "rgb(255, 255, 0)",
|
|
112
|
+
colorAfter: "rgb(255, 255, 0)",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: 1,
|
|
116
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
117
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
118
|
+
},
|
|
119
|
+
];
|
|
120
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_YELLOW_RED:
|
|
121
|
+
return [
|
|
122
|
+
{
|
|
123
|
+
value: 0,
|
|
124
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
125
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
value: 0.5,
|
|
129
|
+
colorBefore: "rgb(255, 255, 0)",
|
|
130
|
+
colorAfter: "rgb(255, 255, 0)",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
value: 1,
|
|
134
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
135
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
139
|
+
return [
|
|
140
|
+
{
|
|
141
|
+
value: 0,
|
|
142
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
143
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
value: 0.5,
|
|
147
|
+
colorBefore: "rgb(0, 255, 0)",
|
|
148
|
+
colorAfter: "rgb(0, 255, 0)",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
value: 1,
|
|
152
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
153
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
154
|
+
},
|
|
155
|
+
];
|
|
156
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
157
|
+
return [
|
|
158
|
+
{
|
|
159
|
+
value: 0,
|
|
160
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
161
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
value: 0.2,
|
|
165
|
+
colorBefore: "rgb(0, 255, 0)",
|
|
166
|
+
colorAfter: "rgb(0, 255, 0)",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: 0.4,
|
|
170
|
+
colorBefore: "rgb(255, 255, 0)",
|
|
171
|
+
colorAfter: "rgb(255, 255, 0)",
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
value: 0.6,
|
|
175
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
176
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
value: 0.8,
|
|
180
|
+
colorBefore: "rgb(255, 0, 255)",
|
|
181
|
+
colorAfter: "rgb(255, 0, 255)",
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
value: 1,
|
|
185
|
+
colorBefore: "rgb(255, 255, 255)",
|
|
186
|
+
colorAfter: "rgb(255, 255, 255)",
|
|
187
|
+
},
|
|
188
|
+
];
|
|
189
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.VIRIDIS:
|
|
190
|
+
return [
|
|
191
|
+
{
|
|
192
|
+
value: 0.0,
|
|
193
|
+
colorBefore: "rgb(68, 1, 84)",
|
|
194
|
+
colorAfter: "rgb(68, 1, 84)",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: 0.1,
|
|
198
|
+
colorBefore: "rgb(65, 44, 123)",
|
|
199
|
+
colorAfter: "rgb(65, 44, 123)",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
value: 0.2,
|
|
203
|
+
colorBefore: "rgb(52, 83, 138)",
|
|
204
|
+
colorAfter: "rgb(52, 83, 138)",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
value: 0.3,
|
|
208
|
+
colorBefore: "rgb(38, 119, 140)",
|
|
209
|
+
colorAfter: "rgb(38, 119, 140)",
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
value: 0.4,
|
|
213
|
+
colorBefore: "rgb(31, 144, 137)",
|
|
214
|
+
colorAfter: "rgb(31, 144, 137)",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
value: 0.5,
|
|
218
|
+
colorBefore: "rgb(37, 170, 121)",
|
|
219
|
+
colorAfter: "rgb(37, 170, 121)",
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
value: 0.6,
|
|
223
|
+
colorBefore: "rgb(86, 193, 90)",
|
|
224
|
+
colorAfter: "rgb(86, 193, 90)",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
value: 0.7,
|
|
228
|
+
colorBefore: "rgb(150, 211, 45)",
|
|
229
|
+
colorAfter: "rgb(150, 211, 45)",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
value: 0.8,
|
|
233
|
+
colorBefore: "rgb(218, 230, 35)",
|
|
234
|
+
colorAfter: "rgb(218, 230, 35)",
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
value: 0.9,
|
|
238
|
+
colorBefore: "rgb(253, 231, 36)",
|
|
239
|
+
colorAfter: "rgb(253, 231, 36)",
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
value: 1.0,
|
|
243
|
+
colorBefore: "rgb(252, 254, 178)",
|
|
244
|
+
colorAfter: "rgb(252, 254, 178)",
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.PLASMA:
|
|
248
|
+
return [
|
|
249
|
+
{
|
|
250
|
+
value: 0.0,
|
|
251
|
+
colorBefore: "rgb(13, 8, 135)",
|
|
252
|
+
colorAfter: "rgb(13, 8, 135)",
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
value: 0.1,
|
|
256
|
+
colorBefore: "rgb(75, 3, 161)",
|
|
257
|
+
colorAfter: "rgb(75, 3, 161)",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
value: 0.2,
|
|
261
|
+
colorBefore: "rgb(125, 3, 168)",
|
|
262
|
+
colorAfter: "rgb(125, 3, 168)",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
value: 0.3,
|
|
266
|
+
colorBefore: "rgb(168, 34, 150)",
|
|
267
|
+
colorAfter: "rgb(168, 34, 150)",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
value: 0.4,
|
|
271
|
+
colorBefore: "rgb(203, 70, 121)",
|
|
272
|
+
colorAfter: "rgb(203, 70, 121)",
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
value: 0.5,
|
|
276
|
+
colorBefore: "rgb(229, 107, 93)",
|
|
277
|
+
colorAfter: "rgb(229, 107, 93)",
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
value: 0.6,
|
|
281
|
+
colorBefore: "rgb(248, 148, 65)",
|
|
282
|
+
colorAfter: "rgb(248, 148, 65)",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
value: 0.7,
|
|
286
|
+
colorBefore: "rgb(253, 195, 40)",
|
|
287
|
+
colorAfter: "rgb(253, 195, 40)",
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
value: 0.8,
|
|
291
|
+
colorBefore: "rgb(240, 242, 51)",
|
|
292
|
+
colorAfter: "rgb(240, 242, 51)",
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
value: 0.9,
|
|
296
|
+
colorBefore: "rgb(210, 252, 98)",
|
|
297
|
+
colorAfter: "rgb(210, 252, 98)",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
value: 1.0,
|
|
301
|
+
colorBefore: "rgb(254, 255, 178)",
|
|
302
|
+
colorAfter: "rgb(254, 255, 178)",
|
|
303
|
+
},
|
|
304
|
+
];
|
|
305
|
+
return [
|
|
306
|
+
{
|
|
307
|
+
value: 0.0,
|
|
308
|
+
colorBefore: "rgb(0, 0, 127)",
|
|
309
|
+
colorAfter: "rgb(0, 0, 127)",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
value: 0.1,
|
|
313
|
+
colorBefore: "rgb(0, 0, 191)",
|
|
314
|
+
colorAfter: "rgb(0, 0, 191)",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
value: 0.2,
|
|
318
|
+
colorBefore: "rgb(0, 0, 255)",
|
|
319
|
+
colorAfter: "rgb(0, 0, 255)",
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
value: 0.3,
|
|
323
|
+
colorBefore: "rgb(63, 63, 255)",
|
|
324
|
+
colorAfter: "rgb(63, 63, 255)",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
value: 0.4,
|
|
328
|
+
colorBefore: "rgb(127, 127, 255)",
|
|
329
|
+
colorAfter: "rgb(127, 127, 255)",
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
value: 0.5,
|
|
333
|
+
colorBefore: "rgb(255, 255, 255)",
|
|
334
|
+
colorAfter: "rgb(255, 255, 255)",
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
value: 0.6,
|
|
338
|
+
colorBefore: "rgb(255, 127, 127)",
|
|
339
|
+
colorAfter: "rgb(255, 127, 127)",
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
value: 0.7,
|
|
343
|
+
colorBefore: "rgb(255, 63, 63)",
|
|
344
|
+
colorAfter: "rgb(255, 63, 63)",
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
value: 0.8,
|
|
348
|
+
colorBefore: "rgb(255, 0, 0)",
|
|
349
|
+
colorAfter: "rgb(255, 0, 0)",
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
value: 0.9,
|
|
353
|
+
colorBefore: "rgb(191, 0, 0)",
|
|
354
|
+
colorAfter: "rgb(191, 0, 0)",
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
value: 1.0,
|
|
358
|
+
colorBefore: "rgb(127, 0, 0)",
|
|
359
|
+
colorAfter: "rgb(127, 0, 0)",
|
|
360
|
+
},
|
|
361
|
+
];
|
|
362
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.TURBO:
|
|
363
|
+
return [
|
|
364
|
+
{
|
|
365
|
+
value: 0.0,
|
|
366
|
+
colorBefore: "rgb(48, 18, 59)",
|
|
367
|
+
colorAfter: "rgb(48, 18, 59)",
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
value: 0.1,
|
|
371
|
+
colorBefore: "rgb(55, 47, 122)",
|
|
372
|
+
colorAfter: "rgb(55, 47, 122)",
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
value: 0.2,
|
|
376
|
+
colorBefore: "rgb(23, 111, 171)",
|
|
377
|
+
colorAfter: "rgb(23, 111, 171)",
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
value: 0.3,
|
|
381
|
+
colorBefore: "rgb(16, 153, 142)",
|
|
382
|
+
colorAfter: "rgb(16, 153, 142)",
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
value: 0.4,
|
|
386
|
+
colorBefore: "rgb(69, 186, 99)",
|
|
387
|
+
colorAfter: "rgb(69, 186, 99)",
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
value: 0.5,
|
|
391
|
+
colorBefore: "rgb(165, 202, 65)",
|
|
392
|
+
colorAfter: "rgb(165, 202, 65)",
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
value: 0.6,
|
|
396
|
+
colorBefore: "rgb(234, 190, 70)",
|
|
397
|
+
colorAfter: "rgb(234, 190, 70)",
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
value: 0.7,
|
|
401
|
+
colorBefore: "rgb(251, 142, 79)",
|
|
402
|
+
colorAfter: "rgb(251, 142, 79)",
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
value: 0.8,
|
|
406
|
+
colorBefore: "rgb(243, 87, 65)",
|
|
407
|
+
colorAfter: "rgb(243, 87, 65)",
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
value: 0.9,
|
|
411
|
+
colorBefore: "rgb(224, 37, 77)",
|
|
412
|
+
colorAfter: "rgb(224, 37, 77)",
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
value: 1.0,
|
|
416
|
+
colorBefore: "rgb(127, 0, 45)",
|
|
417
|
+
colorAfter: "rgb(127, 0, 45)",
|
|
418
|
+
},
|
|
419
|
+
];
|
|
420
|
+
return [
|
|
421
|
+
{
|
|
422
|
+
value: 0.0,
|
|
423
|
+
colorBefore: "rgb(0, 0, 3)",
|
|
424
|
+
colorAfter: "rgb(0, 0, 3)",
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
value: 0.1,
|
|
428
|
+
colorBefore: "rgb(31, 12, 72)",
|
|
429
|
+
colorAfter: "rgb(31, 12, 72)",
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
value: 0.2,
|
|
433
|
+
colorBefore: "rgb(85, 15, 109)",
|
|
434
|
+
colorAfter: "rgb(85, 15, 109)",
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
value: 0.3,
|
|
438
|
+
colorBefore: "rgb(136, 34, 106)",
|
|
439
|
+
colorAfter: "rgb(136, 34, 106)",
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
value: 0.4,
|
|
443
|
+
colorBefore: "rgb(186, 54, 85)",
|
|
444
|
+
colorAfter: "rgb(186, 54, 85)",
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
value: 0.5,
|
|
448
|
+
colorBefore: "rgb(227, 89, 51)",
|
|
449
|
+
colorAfter: "rgb(227, 89, 51)",
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
value: 0.6,
|
|
453
|
+
colorBefore: "rgb(249, 140, 10)",
|
|
454
|
+
colorAfter: "rgb(249, 140, 10)",
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
value: 0.7,
|
|
458
|
+
colorBefore: "rgb(252, 190, 57)",
|
|
459
|
+
colorAfter: "rgb(252, 190, 57)",
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
value: 0.8,
|
|
463
|
+
colorBefore: "rgb(241, 237, 105)",
|
|
464
|
+
colorAfter: "rgb(241, 237, 105)",
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
value: 0.9,
|
|
468
|
+
colorBefore: "rgb(252, 253, 191)",
|
|
469
|
+
colorAfter: "rgb(252, 253, 191)",
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
value: 1.0,
|
|
473
|
+
colorBefore: "rgb(252, 254, 164)",
|
|
474
|
+
colorAfter: "rgb(252, 254, 164)",
|
|
475
|
+
},
|
|
476
|
+
];
|
|
477
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.MAGMA:
|
|
478
|
+
return [
|
|
479
|
+
{
|
|
480
|
+
value: 0.0,
|
|
481
|
+
colorBefore: "rgb(0, 0, 4)",
|
|
482
|
+
colorAfter: "rgb(0, 0, 4)",
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
value: 0.1,
|
|
486
|
+
colorBefore: "rgb(28, 16, 68)",
|
|
487
|
+
colorAfter: "rgb(28, 16, 68)",
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
value: 0.2,
|
|
491
|
+
colorBefore: "rgb(79, 18, 123)",
|
|
492
|
+
colorAfter: "rgb(79, 18, 123)",
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
value: 0.3,
|
|
496
|
+
colorBefore: "rgb(129, 37, 129)",
|
|
497
|
+
colorAfter: "rgb(129, 37, 129)",
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
value: 0.4,
|
|
501
|
+
colorBefore: "rgb(178, 65, 114)",
|
|
502
|
+
colorAfter: "rgb(178, 65, 114)",
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
value: 0.5,
|
|
506
|
+
colorBefore: "rgb(221, 104, 89)",
|
|
507
|
+
colorAfter: "rgb(221, 104, 89)",
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
value: 0.6,
|
|
511
|
+
colorBefore: "rgb(251, 150, 62)",
|
|
512
|
+
colorAfter: "rgb(251, 150, 62)",
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
value: 0.7,
|
|
516
|
+
colorBefore: "rgb(254, 198, 83)",
|
|
517
|
+
colorAfter: "rgb(254, 198, 83)",
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
value: 0.8,
|
|
521
|
+
colorBefore: "rgb(237, 243, 129)",
|
|
522
|
+
colorAfter: "rgb(237, 243, 129)",
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
value: 0.9,
|
|
526
|
+
colorBefore: "rgb(252, 254, 191)",
|
|
527
|
+
colorAfter: "rgb(252, 254, 191)",
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
value: 1.0,
|
|
531
|
+
colorBefore: "rgb(252, 254, 164)",
|
|
532
|
+
colorAfter: "rgb(252, 254, 164)",
|
|
533
|
+
},
|
|
534
|
+
];
|
|
535
|
+
case viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.CIVIDIS:
|
|
536
|
+
return [
|
|
537
|
+
{
|
|
538
|
+
value: 0.0,
|
|
539
|
+
colorBefore: "rgb(0, 32, 76)",
|
|
540
|
+
colorAfter: "rgb(0, 32, 76)",
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
value: 0.1,
|
|
544
|
+
colorBefore: "rgb(20, 53, 96)",
|
|
545
|
+
colorAfter: "rgb(20, 53, 96)",
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
value: 0.2,
|
|
549
|
+
colorBefore: "rgb(48, 75, 108)",
|
|
550
|
+
colorAfter: "rgb(48, 75, 108)",
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
value: 0.3,
|
|
554
|
+
colorBefore: "rgb(82, 95, 115)",
|
|
555
|
+
colorAfter: "rgb(82, 95, 115)",
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
value: 0.4,
|
|
559
|
+
colorBefore: "rgb(120, 113, 114)",
|
|
560
|
+
colorAfter: "rgb(120, 113, 114)",
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
value: 0.5,
|
|
564
|
+
colorBefore: "rgb(159, 130, 109)",
|
|
565
|
+
colorAfter: "rgb(159, 130, 109)",
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
value: 0.6,
|
|
569
|
+
colorBefore: "rgb(195, 145, 99)",
|
|
570
|
+
colorAfter: "rgb(195, 145, 99)",
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
value: 0.7,
|
|
574
|
+
colorBefore: "rgb(227, 158, 85)",
|
|
575
|
+
colorAfter: "rgb(227, 158, 85)",
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
value: 0.8,
|
|
579
|
+
colorBefore: "rgb(251, 171, 71)",
|
|
580
|
+
colorAfter: "rgb(251, 171, 71)",
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
value: 0.9,
|
|
584
|
+
colorBefore: "rgb(254, 200, 116)",
|
|
585
|
+
colorAfter: "rgb(254, 200, 116)",
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
value: 1.0,
|
|
589
|
+
colorBefore: "rgb(252, 255, 164)",
|
|
590
|
+
colorAfter: "rgb(252, 255, 164)",
|
|
591
|
+
},
|
|
592
|
+
];
|
|
593
|
+
default:
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
const getColorAt = (gradient, factor) => {
|
|
598
|
+
const steps = (0, exports.getColorSteps)(gradient);
|
|
599
|
+
if (!steps)
|
|
600
|
+
return;
|
|
601
|
+
for (let i = 0; i < steps.length; i++) {
|
|
602
|
+
if (steps[i].value >= factor) {
|
|
603
|
+
// check if the value is the first step
|
|
604
|
+
if (i === 0) {
|
|
605
|
+
return steps[i].colorBefore;
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
// get the previous color
|
|
609
|
+
const previousColor = steps[i - 1].colorAfter;
|
|
610
|
+
// get the current color
|
|
611
|
+
const currentColor = steps[i].colorBefore;
|
|
612
|
+
// calculate where the factor is between the two colors
|
|
613
|
+
const stepFactor = (factor - steps[i - 1].value) /
|
|
614
|
+
(steps[i].value - steps[i - 1].value);
|
|
615
|
+
// return interpolated color
|
|
616
|
+
return interpolateColors(previousColor, currentColor, stepFactor);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
// return the after color of the last step
|
|
621
|
+
return steps[steps.length - 1].colorAfter;
|
|
622
|
+
};
|
|
623
|
+
exports.getColorAt = getColorAt;
|
|
624
|
+
const opacityVisualization = (factor, materialType, defaultMaterial) => {
|
|
625
|
+
// factor clamped to [0, 1]
|
|
626
|
+
factor = Math.max(0, Math.min(1, factor));
|
|
627
|
+
return {
|
|
628
|
+
material: materialType === "unlit"
|
|
629
|
+
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
630
|
+
color: defaultMaterial.color,
|
|
631
|
+
opacity: factor,
|
|
632
|
+
})
|
|
633
|
+
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
634
|
+
color: defaultMaterial.color,
|
|
635
|
+
opacity: factor,
|
|
636
|
+
}),
|
|
637
|
+
matrix: IDENTITY_MATRIX,
|
|
638
|
+
};
|
|
639
|
+
};
|
|
640
|
+
const hslVisualization = (factor, materialType) => {
|
|
641
|
+
// factor clamped to [0, 1]
|
|
642
|
+
factor = Math.max(0, Math.min(1, factor));
|
|
643
|
+
const hue = factor * 359.99;
|
|
644
|
+
return {
|
|
645
|
+
material: materialType === "unlit"
|
|
646
|
+
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
647
|
+
color: "hsl(" + Math.floor(hue) + ", 100%, 50%)",
|
|
648
|
+
opacity: 1,
|
|
649
|
+
})
|
|
650
|
+
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
651
|
+
color: "hsl(" + Math.floor(hue) + ", 100%, 50%)",
|
|
652
|
+
opacity: 1,
|
|
653
|
+
}),
|
|
654
|
+
matrix: IDENTITY_MATRIX,
|
|
655
|
+
};
|
|
656
|
+
};
|
|
657
|
+
const interpolateColors = (color1, color2, factor) => {
|
|
658
|
+
const converter = getConverter();
|
|
659
|
+
const colorArray1 = converter.toColorArray(color1);
|
|
660
|
+
const colorArray2 = converter.toColorArray(color2);
|
|
661
|
+
// Interpolate the colors
|
|
662
|
+
const r = colorArray1[0] + factor * (colorArray2[0] - colorArray1[0]);
|
|
663
|
+
const g = colorArray1[1] + factor * (colorArray2[1] - colorArray1[1]);
|
|
664
|
+
const b = colorArray1[2] + factor * (colorArray2[2] - colorArray1[2]);
|
|
665
|
+
// Convert the interpolated color back to a hex string
|
|
666
|
+
return converter.toHexColor([r * 256, g * 256, b * 256]);
|
|
667
|
+
};
|
|
668
|
+
const numberGradientVisualization = (factor, gradient) => {
|
|
669
|
+
if (typeof gradient.steps === "string")
|
|
670
|
+
return;
|
|
671
|
+
for (let i = 0; i < gradient.steps.length; i++) {
|
|
672
|
+
if (gradient.steps[i].value >= factor) {
|
|
673
|
+
// check if the value is the first step
|
|
674
|
+
if (i === 0) {
|
|
675
|
+
return {
|
|
676
|
+
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
677
|
+
color: gradient.steps[i].colorBefore,
|
|
678
|
+
opacity: 1,
|
|
679
|
+
}),
|
|
680
|
+
matrix: IDENTITY_MATRIX,
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
// get the previous color
|
|
685
|
+
const previousColor = gradient.steps[i - 1].colorAfter;
|
|
686
|
+
// get the current color
|
|
687
|
+
const currentColor = gradient.steps[i].colorBefore;
|
|
688
|
+
// calculate where the factor is between the two colors
|
|
689
|
+
const stepFactor = (factor - gradient.steps[i - 1].value) /
|
|
690
|
+
(gradient.steps[i].value - gradient.steps[i - 1].value);
|
|
691
|
+
// return interpolated color
|
|
692
|
+
return {
|
|
693
|
+
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
694
|
+
color: interpolateColors(previousColor, currentColor, stepFactor),
|
|
695
|
+
opacity: 1,
|
|
696
|
+
}),
|
|
697
|
+
matrix: IDENTITY_MATRIX,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
// return the after color of the last step
|
|
703
|
+
return {
|
|
704
|
+
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
705
|
+
color: gradient.steps[gradient.steps.length - 1].colorAfter,
|
|
706
|
+
opacity: 1,
|
|
707
|
+
}),
|
|
708
|
+
matrix: IDENTITY_MATRIX,
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
const stringGradientVisualization = (value, gradient) => {
|
|
712
|
+
const steps = gradient.labelColors;
|
|
713
|
+
const stepCount = steps.length;
|
|
714
|
+
let color = gradient.defaultColor || "rgb(128, 128, 128)";
|
|
715
|
+
for (let i = 0; i < stepCount; i++) {
|
|
716
|
+
if (steps[i].values.includes(value)) {
|
|
717
|
+
color = steps[i].color;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return {
|
|
722
|
+
material: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
723
|
+
color: color,
|
|
724
|
+
opacity: 1,
|
|
725
|
+
}),
|
|
726
|
+
matrix: IDENTITY_MATRIX,
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
const numberVisualization = (value, min, max, type, materialType, defaultMaterial) => {
|
|
730
|
+
let factor = (value - min) / (max - min);
|
|
731
|
+
if (isNaN(factor))
|
|
732
|
+
factor = 0.5;
|
|
733
|
+
// check if the type is part of the enum
|
|
734
|
+
if (typeof type === "string") {
|
|
735
|
+
const color = (0, exports.getColorAt)(type, factor);
|
|
736
|
+
if (color) {
|
|
737
|
+
return {
|
|
738
|
+
material: materialType === "unlit"
|
|
739
|
+
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
740
|
+
color: color,
|
|
741
|
+
opacity: 1,
|
|
742
|
+
})
|
|
743
|
+
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
744
|
+
color: color,
|
|
745
|
+
opacity: 1,
|
|
746
|
+
}),
|
|
747
|
+
matrix: IDENTITY_MATRIX,
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.OPACITY) {
|
|
751
|
+
return opacityVisualization(factor, materialType, defaultMaterial);
|
|
752
|
+
}
|
|
753
|
+
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.HSL) {
|
|
754
|
+
return hslVisualization(factor, materialType);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
if ((0, IGradient_1.isNumberGradient)(type)) {
|
|
759
|
+
// check if the steps are a string
|
|
760
|
+
if (typeof type.steps === "string") {
|
|
761
|
+
// if so, we use the default gradient visualization
|
|
762
|
+
return numberVisualization(value, min, max, type.steps, materialType, defaultMaterial);
|
|
763
|
+
}
|
|
764
|
+
return numberGradientVisualization(factor, type);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
const stringVisualization = (value, values, type, materialType, defaultMaterial) => {
|
|
769
|
+
let factor = values.indexOf(value) / (values.length - 1);
|
|
770
|
+
if (isNaN(factor))
|
|
771
|
+
factor = 0.5;
|
|
772
|
+
// check if the type is part of the enum
|
|
773
|
+
if (typeof type === "string") {
|
|
774
|
+
const color = (0, exports.getColorAt)(type, factor);
|
|
775
|
+
if (color) {
|
|
776
|
+
return {
|
|
777
|
+
material: materialType === "unlit"
|
|
778
|
+
? new viewer_shared_node_tree_1.MaterialUnlitData({
|
|
779
|
+
color: color,
|
|
780
|
+
opacity: 1,
|
|
781
|
+
})
|
|
782
|
+
: new viewer_shared_node_tree_1.MaterialStandardData({
|
|
783
|
+
color: color,
|
|
784
|
+
opacity: 1,
|
|
785
|
+
}),
|
|
786
|
+
matrix: IDENTITY_MATRIX,
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.OPACITY) {
|
|
790
|
+
return opacityVisualization(factor, materialType, defaultMaterial);
|
|
791
|
+
}
|
|
792
|
+
else if (type === viewer_shared_types_1.ATTRIBUTE_VISUALIZATION.HSL) {
|
|
793
|
+
return hslVisualization(factor, materialType);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
if ((0, IGradient_1.isStringGradient)(type)) {
|
|
798
|
+
return stringGradientVisualization(value, type);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
exports.AttributeVisualizationUtils = {
|
|
803
|
+
numberVisualization,
|
|
804
|
+
stringVisualization,
|
|
805
|
+
};
|
|
806
806
|
//# sourceMappingURL=AttributeVisualizationUtils.js.map
|