@shapediver/viewer.features.attribute-visualization 1.15.7 → 2.0.2
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 +6 -5
- package/dist/implementation/AttributeVisualizationEngine.d.ts.map +1 -1
- package/dist/implementation/AttributeVisualizationEngine.js +24 -25
- package/dist/implementation/AttributeVisualizationEngine.js.map +1 -1
- package/dist/implementation/AttributeVisualizationUtils.d.ts +7 -0
- package/dist/implementation/AttributeVisualizationUtils.d.ts.map +1 -0
- package/dist/implementation/AttributeVisualizationUtils.js +189 -0
- package/dist/implementation/AttributeVisualizationUtils.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/IAttribute.d.ts +15 -4
- package/dist/interfaces/IAttribute.d.ts.map +1 -1
- package/dist/interfaces/IAttribute.js +13 -0
- package/dist/interfaces/IAttribute.js.map +1 -1
- package/dist/interfaces/IAttributeVisualizationEngine.d.ts +4 -4
- package/dist/interfaces/IAttributeVisualizationEngine.d.ts.map +1 -1
- package/package.json +14 -11
- package/src/implementation/AttributeVisualizationEngine.ts +248 -0
- package/src/implementation/AttributeVisualizationUtils.ts +196 -0
- package/src/index.ts +21 -0
- package/src/interfaces/IAttribute.ts +34 -0
- package/src/interfaces/IAttributeVisualizationEngine.ts +49 -0
- package/src/interfaces/ILayer.ts +11 -0
- package/tsconfig.json +17 -0
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { ILayer } from "../interfaces/ILayer";
|
|
2
|
-
import {
|
|
2
|
+
import { IViewportApi } from "@shapediver/viewer";
|
|
3
3
|
import { IAttribute } from "../interfaces/IAttribute";
|
|
4
4
|
import { IAttributeVisualizationEngine } from "../interfaces/IAttributeVisualizationEngine";
|
|
5
|
+
import { IMaterialAbstractData, ISDTFOverview } from "@shapediver/viewer.shared.types";
|
|
5
6
|
export declare class AttributeVisualizationEngine implements IAttributeVisualizationEngine {
|
|
6
7
|
#private;
|
|
7
|
-
constructor(
|
|
8
|
-
get defaultMaterial():
|
|
8
|
+
constructor(viewport: IViewportApi);
|
|
9
|
+
get defaultMaterial(): IMaterialAbstractData;
|
|
9
10
|
get defaultLayer(): ILayer;
|
|
10
11
|
get layers(): {
|
|
11
12
|
[key: string]: ILayer;
|
|
12
13
|
};
|
|
13
|
-
get overview():
|
|
14
|
+
get overview(): ISDTFOverview;
|
|
14
15
|
updateAttributes(attributes: IAttribute[]): void;
|
|
15
16
|
updateDefaultLayer(layer: ILayer): void;
|
|
16
|
-
updateDefaultMaterial(material:
|
|
17
|
+
updateDefaultMaterial(material: IMaterialAbstractData): void;
|
|
17
18
|
updateLayers(layers: {
|
|
18
19
|
[key: string]: ILayer;
|
|
19
20
|
}): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeVisualizationEngine.d.ts","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"AttributeVisualizationEngine.d.ts","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAe,YAAY,EAAa,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAA0E,MAAM,0BAA0B,CAAC;AAI9H,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAiB,aAAa,EAA6C,MAAM,iCAAiC,CAAC;AAGjJ,qBAAa,4BAA6B,YAAW,6BAA6B;;gBA0BlE,QAAQ,EAAE,YAAY;IAoBlC,IAAW,eAAe,IAAI,qBAAqB,CAElD;IAED,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED,IAAW,MAAM,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAE7C;IAED,IAAW,QAAQ,IAAI,aAAa,CAEnC;IAMM,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE;IAKzC,kBAAkB,CAAC,KAAK,EAAE,MAAM;IAKhC,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB;IAKrD,YAAY,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAK9C,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM;IAMnC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAU7C,OAAO,CAAC,+BAA+B;IAsHvC,OAAO,CAAC,YAAY;CAiBvB"}
|
|
@@ -10,25 +10,25 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
13
|
+
var _AttributeVisualizationEngine_converter, _AttributeVisualizationEngine_uuidGenerator, _AttributeVisualizationEngine_viewport, _AttributeVisualizationEngine_attributes, _AttributeVisualizationEngine_defaultMaterial, _AttributeVisualizationEngine_defaultLayer, _AttributeVisualizationEngine_layers, _AttributeVisualizationEngine_overview, _AttributeVisualizationEngine_listeners;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.AttributeVisualizationEngine = void 0;
|
|
16
16
|
const viewer_1 = require("@shapediver/viewer");
|
|
17
17
|
const gl_matrix_1 = require("gl-matrix");
|
|
18
18
|
const tsyringe_1 = require("tsyringe");
|
|
19
19
|
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
20
|
-
const
|
|
20
|
+
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
21
|
+
const AttributeVisualizationUtils_1 = require("./AttributeVisualizationUtils");
|
|
21
22
|
class AttributeVisualizationEngine {
|
|
22
23
|
// #endregion Properties (7)
|
|
23
24
|
// #region Constructors (1)
|
|
24
|
-
constructor(
|
|
25
|
+
constructor(viewport) {
|
|
25
26
|
// #region Properties (7)
|
|
26
|
-
_AttributeVisualizationEngine_api.set(this, void 0);
|
|
27
27
|
_AttributeVisualizationEngine_converter.set(this, tsyringe_1.container.resolve(viewer_shared_services_1.Converter));
|
|
28
28
|
_AttributeVisualizationEngine_uuidGenerator.set(this, tsyringe_1.container.resolve(viewer_shared_services_1.UuidGenerator));
|
|
29
|
-
|
|
29
|
+
_AttributeVisualizationEngine_viewport.set(this, void 0);
|
|
30
30
|
_AttributeVisualizationEngine_attributes.set(this, []);
|
|
31
|
-
_AttributeVisualizationEngine_defaultMaterial.set(this, new
|
|
31
|
+
_AttributeVisualizationEngine_defaultMaterial.set(this, new viewer_shared_types_1.MaterialUnlitData({ color: '#000000', opacity: 1 }));
|
|
32
32
|
_AttributeVisualizationEngine_defaultLayer.set(this, {
|
|
33
33
|
color: '#000000',
|
|
34
34
|
opacity: 1,
|
|
@@ -37,13 +37,12 @@ class AttributeVisualizationEngine {
|
|
|
37
37
|
_AttributeVisualizationEngine_layers.set(this, {});
|
|
38
38
|
_AttributeVisualizationEngine_overview.set(this, void 0);
|
|
39
39
|
_AttributeVisualizationEngine_listeners.set(this, {});
|
|
40
|
-
__classPrivateFieldSet(this,
|
|
41
|
-
__classPrivateFieldSet(this,
|
|
42
|
-
__classPrivateFieldSet(this, _AttributeVisualizationEngine_overview, __classPrivateFieldGet(this, _AttributeVisualizationEngine_api, "f").createSDTFOverview(__classPrivateFieldGet(this, _AttributeVisualizationEngine_api, "f").sceneTree.root), "f");
|
|
40
|
+
__classPrivateFieldSet(this, _AttributeVisualizationEngine_viewport, viewport, "f");
|
|
41
|
+
__classPrivateFieldSet(this, _AttributeVisualizationEngine_overview, __classPrivateFieldGet(this, _AttributeVisualizationEngine_viewport, "f").createSDTFOverview(viewer_1.sceneTree.root), "f");
|
|
43
42
|
this.createLayers();
|
|
44
43
|
this.constructAttributeVisualization();
|
|
45
|
-
|
|
46
|
-
__classPrivateFieldSet(this, _AttributeVisualizationEngine_overview, __classPrivateFieldGet(this,
|
|
44
|
+
(0, viewer_1.addListener)(viewer_shared_services_1.EVENTTYPE.SESSION.SESSION_CUSTOMIZED, () => {
|
|
45
|
+
__classPrivateFieldSet(this, _AttributeVisualizationEngine_overview, __classPrivateFieldGet(this, _AttributeVisualizationEngine_viewport, "f").createSDTFOverview(viewer_1.sceneTree.root), "f");
|
|
47
46
|
this.createLayers();
|
|
48
47
|
this.constructAttributeVisualization();
|
|
49
48
|
for (let l in __classPrivateFieldGet(this, _AttributeVisualizationEngine_listeners, "f"))
|
|
@@ -96,12 +95,12 @@ class AttributeVisualizationEngine {
|
|
|
96
95
|
// #endregion Public Methods (3)
|
|
97
96
|
// #region Private Methods (2)
|
|
98
97
|
constructAttributeVisualization() {
|
|
99
|
-
__classPrivateFieldGet(this,
|
|
98
|
+
__classPrivateFieldGet(this, _AttributeVisualizationEngine_viewport, "f").visualizeAttributes = (overview, itemData) => {
|
|
100
99
|
// early out if there are not attributes in this itemData
|
|
101
100
|
if (!itemData || !itemData.attributes) {
|
|
102
101
|
if (__classPrivateFieldGet(this, _AttributeVisualizationEngine_attributes, "f").length === 0) {
|
|
103
102
|
// return default layer material
|
|
104
|
-
const material = new
|
|
103
|
+
const material = new viewer_shared_types_1.MaterialUnlitData({
|
|
105
104
|
opacity: __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultLayer, "f").enabled ? __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultLayer, "f").opacity : 0,
|
|
106
105
|
color: __classPrivateFieldGet(this, _AttributeVisualizationEngine_converter, "f").toColor(__classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultLayer, "f").color)
|
|
107
106
|
});
|
|
@@ -112,7 +111,7 @@ class AttributeVisualizationEngine {
|
|
|
112
111
|
}
|
|
113
112
|
else {
|
|
114
113
|
// return default layer material
|
|
115
|
-
const material = new
|
|
114
|
+
const material = new viewer_shared_types_1.MaterialUnlitData({
|
|
116
115
|
opacity: __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultLayer, "f").enabled ? __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultLayer, "f").opacity * __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultMaterial, "f").opacity : 0,
|
|
117
116
|
color: __classPrivateFieldGet(this, _AttributeVisualizationEngine_converter, "f").toColor(__classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultMaterial, "f").color)
|
|
118
117
|
});
|
|
@@ -124,7 +123,7 @@ class AttributeVisualizationEngine {
|
|
|
124
123
|
}
|
|
125
124
|
// search for the responsible layer property, if none is found, default layer is assigned
|
|
126
125
|
let layer = this.defaultLayer;
|
|
127
|
-
if (itemData.attributes['layer'] &&
|
|
126
|
+
if (itemData.attributes['layer'] && viewer_shared_types_1.SdtfPrimitiveTypeGuard.isStringType(itemData.attributes['layer'].typeHint)) {
|
|
128
127
|
const layerAttributes = itemData.attributes['layer'];
|
|
129
128
|
layer = __classPrivateFieldGet(this, _AttributeVisualizationEngine_layers, "f")[layerAttributes.value];
|
|
130
129
|
}
|
|
@@ -139,7 +138,7 @@ class AttributeVisualizationEngine {
|
|
|
139
138
|
}
|
|
140
139
|
if (__classPrivateFieldGet(this, _AttributeVisualizationEngine_attributes, "f").length === 0) {
|
|
141
140
|
// no attributes are specified, we go into layer visualization mode
|
|
142
|
-
const material = new
|
|
141
|
+
const material = new viewer_shared_types_1.MaterialUnlitData({
|
|
143
142
|
opacity: layer.opacity,
|
|
144
143
|
color: __classPrivateFieldGet(this, _AttributeVisualizationEngine_converter, "f").toColor(layer.color)
|
|
145
144
|
});
|
|
@@ -150,28 +149,28 @@ class AttributeVisualizationEngine {
|
|
|
150
149
|
}
|
|
151
150
|
else {
|
|
152
151
|
// attributes are specified, we go into attribute visualization mode
|
|
153
|
-
const material = new
|
|
152
|
+
const material = new viewer_shared_types_1.MaterialUnlitData();
|
|
154
153
|
for (let i = 0; i < __classPrivateFieldGet(this, _AttributeVisualizationEngine_attributes, "f").length; i++) {
|
|
155
154
|
const a = __classPrivateFieldGet(this, _AttributeVisualizationEngine_attributes, "f")[i];
|
|
156
155
|
if (itemData.attributes[a.key] && itemData.attributes[a.key].typeHint === a.type) {
|
|
157
156
|
const itemDataAttribute = itemData.attributes[a.key];
|
|
158
157
|
const itemDataAttributeOverview = overview[a.key].filter(o => o.typeHint === a.type)[0];
|
|
159
158
|
switch (true) {
|
|
160
|
-
case
|
|
159
|
+
case viewer_shared_types_1.SdtfPrimitiveTypeGuard.isColorType(a.type):
|
|
161
160
|
material.color = __classPrivateFieldGet(this, _AttributeVisualizationEngine_converter, "f").toColor('rgb(' + itemDataAttribute.value + ')');
|
|
162
161
|
material.opacity *= layer.opacity;
|
|
163
162
|
return {
|
|
164
163
|
matrix: gl_matrix_1.mat4.create(),
|
|
165
164
|
material
|
|
166
165
|
};
|
|
167
|
-
case
|
|
166
|
+
case viewer_shared_types_1.SdtfPrimitiveTypeGuard.isNumberType(a.type):
|
|
168
167
|
const numberAttribute = a;
|
|
169
|
-
const numberVisualizationData =
|
|
168
|
+
const numberVisualizationData = AttributeVisualizationUtils_1.AttributeVisualizationUtils.numberVisualization(itemDataAttribute.value, (numberAttribute.min !== undefined ? numberAttribute.min : itemDataAttributeOverview.min), (numberAttribute.max !== undefined ? numberAttribute.max : itemDataAttributeOverview.max), numberAttribute.visualization, __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultMaterial, "f"));
|
|
170
169
|
numberVisualizationData.material.opacity *= layer.opacity;
|
|
171
170
|
return numberVisualizationData;
|
|
172
|
-
case
|
|
171
|
+
case viewer_shared_types_1.SdtfPrimitiveTypeGuard.isStringType(a.type):
|
|
173
172
|
const stringAttribute = a;
|
|
174
|
-
const stringVisualizationData =
|
|
173
|
+
const stringVisualizationData = AttributeVisualizationUtils_1.AttributeVisualizationUtils.stringVisualization(itemDataAttribute.value, stringAttribute.values || itemDataAttributeOverview.values, stringAttribute.visualization, __classPrivateFieldGet(this, _AttributeVisualizationEngine_defaultMaterial, "f"));
|
|
175
174
|
stringVisualizationData.material.opacity *= layer.opacity;
|
|
176
175
|
return stringVisualizationData;
|
|
177
176
|
default:
|
|
@@ -194,8 +193,8 @@ class AttributeVisualizationEngine {
|
|
|
194
193
|
};
|
|
195
194
|
}
|
|
196
195
|
};
|
|
197
|
-
|
|
198
|
-
__classPrivateFieldGet(this,
|
|
196
|
+
viewer_1.sceneTree.root.updateVersion();
|
|
197
|
+
__classPrivateFieldGet(this, _AttributeVisualizationEngine_viewport, "f").update();
|
|
199
198
|
}
|
|
200
199
|
createLayers() {
|
|
201
200
|
__classPrivateFieldSet(this, _AttributeVisualizationEngine_layers, {}, "f");
|
|
@@ -214,5 +213,5 @@ class AttributeVisualizationEngine {
|
|
|
214
213
|
}
|
|
215
214
|
}
|
|
216
215
|
exports.AttributeVisualizationEngine = AttributeVisualizationEngine;
|
|
217
|
-
|
|
216
|
+
_AttributeVisualizationEngine_converter = new WeakMap(), _AttributeVisualizationEngine_uuidGenerator = new WeakMap(), _AttributeVisualizationEngine_viewport = new WeakMap(), _AttributeVisualizationEngine_attributes = new WeakMap(), _AttributeVisualizationEngine_defaultMaterial = new WeakMap(), _AttributeVisualizationEngine_defaultLayer = new WeakMap(), _AttributeVisualizationEngine_layers = new WeakMap(), _AttributeVisualizationEngine_overview = new WeakMap(), _AttributeVisualizationEngine_listeners = new WeakMap();
|
|
218
217
|
//# sourceMappingURL=AttributeVisualizationEngine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeVisualizationEngine.js","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+
|
|
1
|
+
{"version":3,"file":"AttributeVisualizationEngine.js","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationEngine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAA0E;AAE1E,yCAAiC;AACjC,uCAAqC;AACrC,+EAAyF;AAEzF,yEAAiJ;AACjJ,+EAA4E;AAE5E,MAAa,4BAA4B;IAsBrC,4BAA4B;IAE5B,2BAA2B;IAE3B,YAAY,QAAsB;QAzBlC,yBAAyB;QAEzB,kDAA4C,oBAAS,CAAC,OAAO,CAAC,kCAAS,CAAC,EAAC;QACzE,sDAAwD,oBAAS,CAAC,OAAO,CAAC,sCAAa,CAAC,EAAC;QACzF,yDAAiC;QAEjC,mDAA4B,EAAE,EAAC;QAC/B,wDAA0C,IAAI,uCAAiB,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,EAAC;QAClG,qDAAwB;YACpB,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,IAAI;SAChB,EAAC;QACF,+CAEI,EAAE,EAAC;QACP,yDAAyB;QACzB,kDAEI,EAAE,EAAC;QAOH,uBAAA,IAAI,0CAAa,QAAQ,MAAA,CAAC;QAE1B,uBAAA,IAAI,0CAAa,uBAAA,IAAI,8CAAU,CAAC,kBAAkB,CAAC,kBAAS,CAAC,IAAI,CAAC,MAAA,CAAC;QACnE,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,+BAA+B,EAAE,CAAC;QACvC,IAAA,oBAAW,EAAC,kCAAS,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,EAAE;YACnD,uBAAA,IAAI,0CAAa,uBAAA,IAAI,8CAAU,CAAC,kBAAkB,CAAC,kBAAS,CAAC,IAAI,CAAC,MAAA,CAAC;YACnE,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,+BAA+B,EAAE,CAAC;YAEvC,KAAK,IA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,EAAE,CAAC;IAC5B,CAAC;IAEO,YAAY;QAChB,uBAAA,IAAI,wCAAW,EAAE,MAAA,CAAC;QAClB,IAAI,uBAAA,IAAI,8CAAU,CAAC,OAAO,CAAC,EAAE;YACzB,MAAM,4BAA4B,GAAG,uBAAA,IAAI,8CAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;YAChG,IAAI,4BAA4B,IAAI,4BAA4B,CAAC,MAAM,EAAE;gBACrE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,4BAA4B,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACjE,uBAAA,IAAI,4CAAQ,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG;wBACnD,OAAO,EAAE,IAAI;wBACb,OAAO,EAAE,CAAC;wBACV,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK;qBACpC,CAAA;iBACJ;aACJ;SACJ;IACL,CAAC;CAGJ;AA7OD,oEA6OC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IMaterialAbstractData, ISDTFAttributeVisualizationData } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { ATTRIBUTE_VISUALIZATION } from "../interfaces/IAttribute";
|
|
3
|
+
export declare const AttributeVisualizationUtils: {
|
|
4
|
+
numberVisualization: (value: number, min: number, max: number, type: ATTRIBUTE_VISUALIZATION, defaultMaterial?: IMaterialAbstractData | undefined) => ISDTFAttributeVisualizationData;
|
|
5
|
+
stringVisualization: (value: string, values: string[], type: ATTRIBUTE_VISUALIZATION, defaultMaterial?: IMaterialAbstractData | undefined) => ISDTFAttributeVisualizationData;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=AttributeVisualizationUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributeVisualizationUtils.d.ts","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,+BAA+B,EAAqB,MAAM,iCAAiC,CAAC;AAE5H,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AA8LnE,eAAO,MAAM,2BAA2B;iCAnDJ,MAAM,OAAO,MAAM,OAAO,MAAM,QAAQ,uBAAuB,0DAA4C,+BAA+B;iCA0B1I,MAAM,UAAU,MAAM,EAAE,QAAQ,uBAAuB,0DAA4C,+BAA+B;CA4BrK,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AttributeVisualizationUtils = void 0;
|
|
4
|
+
const viewer_shared_types_1 = require("@shapediver/viewer.shared.types");
|
|
5
|
+
const gl_matrix_1 = require("gl-matrix");
|
|
6
|
+
const IAttribute_1 = require("../interfaces/IAttribute");
|
|
7
|
+
const grayscaleVisualization = (factor) => {
|
|
8
|
+
const color = Math.floor(factor * 255.0);
|
|
9
|
+
return {
|
|
10
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + color + ', ' + color + ', ' + color + ')', opacity: 1 }),
|
|
11
|
+
matrix: gl_matrix_1.mat4.create()
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
const opacityVisualization = (factor, defaultMaterial) => {
|
|
15
|
+
return {
|
|
16
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: (defaultMaterial === null || defaultMaterial === void 0 ? void 0 : defaultMaterial.color) || '#00fff7', opacity: factor }),
|
|
17
|
+
matrix: gl_matrix_1.mat4.create()
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const blueRedVisualization = (factor) => {
|
|
21
|
+
const red = factor * 255.0;
|
|
22
|
+
const blue = (1 - factor) * 255.0;
|
|
23
|
+
return {
|
|
24
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(0) + ', ' + Math.floor(blue) + ')', opacity: 1 }),
|
|
25
|
+
matrix: gl_matrix_1.mat4.create()
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const blueWhiteRedVisualization = (factor) => {
|
|
29
|
+
let red = 255, green = 255, blue = 255;
|
|
30
|
+
if (factor < 0.5) {
|
|
31
|
+
const remappedFactor = factor / 0.5;
|
|
32
|
+
red = 255.0 * remappedFactor;
|
|
33
|
+
green = 255.0 * remappedFactor;
|
|
34
|
+
blue = 255.0;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
38
|
+
red = 255.0;
|
|
39
|
+
green = 255.0 * (1 - remappedFactor);
|
|
40
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1 }),
|
|
44
|
+
matrix: gl_matrix_1.mat4.create()
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const greenRedVisualization = (factor) => {
|
|
48
|
+
const red = factor * 255.0;
|
|
49
|
+
const green = (1 - factor) * 255.0;
|
|
50
|
+
return {
|
|
51
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(0) + ')', opacity: 1 }),
|
|
52
|
+
matrix: gl_matrix_1.mat4.create()
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const greenWhiteRedVisualization = (factor) => {
|
|
56
|
+
let red = 255, green = 255, blue = 255;
|
|
57
|
+
if (factor < 0.5) {
|
|
58
|
+
const remappedFactor = factor / 0.5;
|
|
59
|
+
red = 255.0 * remappedFactor;
|
|
60
|
+
green = 255.0;
|
|
61
|
+
blue = 255.0 * remappedFactor;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
65
|
+
red = 255.0;
|
|
66
|
+
green = 255.0 * (1 - remappedFactor);
|
|
67
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1 }),
|
|
71
|
+
matrix: gl_matrix_1.mat4.create()
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const blueGreenRedVisualization = (factor) => {
|
|
75
|
+
let red = 255, green = 255, blue = 255;
|
|
76
|
+
if (factor < 0.5) {
|
|
77
|
+
const remappedFactor = factor / 0.5;
|
|
78
|
+
red = 0;
|
|
79
|
+
green = 255.0 * remappedFactor;
|
|
80
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
84
|
+
red = 255.0 * remappedFactor;
|
|
85
|
+
green = 255.0 * (1 - remappedFactor);
|
|
86
|
+
blue = 0;
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1 }),
|
|
90
|
+
matrix: gl_matrix_1.mat4.create()
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const blueGreenYellowRedPurpleWhiteVisualization = (factor) => {
|
|
94
|
+
let red = 255, green = 255, blue = 255;
|
|
95
|
+
if (factor < 0.2) {
|
|
96
|
+
const remappedFactor = factor / 0.2;
|
|
97
|
+
red = 0;
|
|
98
|
+
green = 255.0 * remappedFactor;
|
|
99
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
100
|
+
}
|
|
101
|
+
else if (factor < 0.4) {
|
|
102
|
+
const remappedFactor = (factor - 0.2) / 0.2;
|
|
103
|
+
red = 255.0 * remappedFactor;
|
|
104
|
+
green = 255.0;
|
|
105
|
+
blue = 0.0;
|
|
106
|
+
}
|
|
107
|
+
else if (factor < 0.6) {
|
|
108
|
+
const remappedFactor = (factor - 0.4) / 0.2;
|
|
109
|
+
red = 255.0;
|
|
110
|
+
green = 255.0 * (1 - remappedFactor);
|
|
111
|
+
blue = 0.0;
|
|
112
|
+
}
|
|
113
|
+
else if (factor < 0.8) {
|
|
114
|
+
const remappedFactor = (factor - 0.6) / 0.2;
|
|
115
|
+
red = 255.0;
|
|
116
|
+
green = 0.0;
|
|
117
|
+
blue = 255.0 * remappedFactor;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
const remappedFactor = (factor - 0.8) / 0.2;
|
|
121
|
+
red = 255.0;
|
|
122
|
+
green = 255.0 * remappedFactor;
|
|
123
|
+
blue = 255.0;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1 }),
|
|
127
|
+
matrix: gl_matrix_1.mat4.create()
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
const hslVisualization = (factor) => {
|
|
131
|
+
const hue = factor * 359.99;
|
|
132
|
+
return {
|
|
133
|
+
material: new viewer_shared_types_1.MaterialUnlitData({ color: 'hsl(' + Math.floor(hue) + ', 100%, 50%)', opacity: 1 }),
|
|
134
|
+
matrix: gl_matrix_1.mat4.create()
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const numberVisualization = (value, min, max, type, defaultMaterial) => {
|
|
138
|
+
let factor = (value - min) / (max - min);
|
|
139
|
+
factor = Math.min(1, Math.max(0, factor));
|
|
140
|
+
switch (type) {
|
|
141
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
142
|
+
return grayscaleVisualization(factor);
|
|
143
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.OPACITY:
|
|
144
|
+
return opacityVisualization(factor, defaultMaterial);
|
|
145
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
146
|
+
return blueRedVisualization(factor);
|
|
147
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
148
|
+
return blueWhiteRedVisualization(factor);
|
|
149
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
150
|
+
return greenRedVisualization(factor);
|
|
151
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
152
|
+
return greenWhiteRedVisualization(factor);
|
|
153
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
154
|
+
return blueGreenRedVisualization(factor);
|
|
155
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
156
|
+
return blueGreenYellowRedPurpleWhiteVisualization(factor);
|
|
157
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.HSL:
|
|
158
|
+
return hslVisualization(factor);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const stringVisualization = (value, values, type, defaultMaterial) => {
|
|
162
|
+
let factor = values.indexOf(value) / (values.length - 1);
|
|
163
|
+
factor = Math.min(1, Math.max(0, factor));
|
|
164
|
+
switch (type) {
|
|
165
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
166
|
+
return grayscaleVisualization(factor);
|
|
167
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.OPACITY:
|
|
168
|
+
return opacityVisualization(factor, defaultMaterial);
|
|
169
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
170
|
+
return blueRedVisualization(factor);
|
|
171
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
172
|
+
return blueWhiteRedVisualization(factor);
|
|
173
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
174
|
+
return greenRedVisualization(factor);
|
|
175
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
176
|
+
return greenWhiteRedVisualization(factor);
|
|
177
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
178
|
+
return blueGreenRedVisualization(factor);
|
|
179
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
180
|
+
return blueGreenYellowRedPurpleWhiteVisualization(factor);
|
|
181
|
+
case IAttribute_1.ATTRIBUTE_VISUALIZATION.HSL:
|
|
182
|
+
return hslVisualization(factor);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
exports.AttributeVisualizationUtils = {
|
|
186
|
+
numberVisualization,
|
|
187
|
+
stringVisualization
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=AttributeVisualizationUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttributeVisualizationUtils.js","sourceRoot":"","sources":["../../src/implementation/AttributeVisualizationUtils.ts"],"names":[],"mappings":";;;AAAA,yEAA4H;AAC5H,yCAAiC;AACjC,yDAAmE;AAGnE,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAmC,EAAE;IAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC;IACzC,OAAO;QACH,QAAQ,EAAE,IAAI,uCAAiB,CAAC,EAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,GAAI,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,GAAG,EAAE,OAAO,EAAE,CAAC,EAAC,CAAC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AC,CAAC;IACzD,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,QAAO,IAAI,EAAE;QACT,KAAK,oCAAuB,CAAC,SAAS;YAClC,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC1C,KAAK,oCAAuB,CAAC,OAAO;YAChC,OAAO,oBAAoB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QACzD,KAAK,oCAAuB,CAAC,QAAQ;YACjC,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;QACxC,KAAK,oCAAuB,CAAC,cAAc;YACvC,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC7C,KAAK,oCAAuB,CAAC,SAAS;YAClC,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;QACzC,KAAK,oCAAuB,CAAC,eAAe;YACxC,OAAO,0BAA0B,CAAC,MAAM,CAAC,CAAC;QAC9C,KAAK,oCAAuB,CAAC,cAAc;YACvC,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;QAC7C,KAAK,oCAAuB,CAAC,kCAAkC;YAC3D,OAAO,0CAA0C,CAAC,MAAM,CAAC,CAAC;QAC9D,KAAK,oCAAuB,CAAC,GAAG;YAC5B,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;KACvC;AACL,CAAC,CAAA;AAEY,QAAA,2BAA2B,GAAG;IACvC,mBAAmB;IACnB,mBAAmB;CACtB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AttributeVisualizationEngine } from "./implementation/AttributeVisualizationEngine";
|
|
2
|
-
import { IAttribute, IColorAttribute, IStringAttribute, INumberAttribute, IDefaultAttribute } from "./interfaces/IAttribute";
|
|
2
|
+
import { IAttribute, IColorAttribute, IStringAttribute, INumberAttribute, IDefaultAttribute, ATTRIBUTE_VISUALIZATION } from "./interfaces/IAttribute";
|
|
3
3
|
import { IAttributeVisualizationEngine } from "./interfaces/IAttributeVisualizationEngine";
|
|
4
4
|
import { ILayer } from "./interfaces/ILayer";
|
|
5
5
|
export { IAttributeVisualizationEngine, AttributeVisualizationEngine };
|
|
6
6
|
export { ILayer, IAttribute, IColorAttribute, IStringAttribute, INumberAttribute, IDefaultAttribute };
|
|
7
|
+
export { ATTRIBUTE_VISUALIZATION };
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACtJ,OAAO,EAAE,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EACH,6BAA6B,EAAE,4BAA4B,EAC9D,CAAA;AAED,OAAO,EACH,MAAM,EACN,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACpB,CAAA;AAED,OAAO,EACH,uBAAuB,EAC1B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AttributeVisualizationEngine = void 0;
|
|
3
|
+
exports.ATTRIBUTE_VISUALIZATION = exports.AttributeVisualizationEngine = void 0;
|
|
4
4
|
const AttributeVisualizationEngine_1 = require("./implementation/AttributeVisualizationEngine");
|
|
5
5
|
Object.defineProperty(exports, "AttributeVisualizationEngine", { enumerable: true, get: function () { return AttributeVisualizationEngine_1.AttributeVisualizationEngine; } });
|
|
6
|
+
const IAttribute_1 = require("./interfaces/IAttribute");
|
|
7
|
+
Object.defineProperty(exports, "ATTRIBUTE_VISUALIZATION", { enumerable: true, get: function () { return IAttribute_1.ATTRIBUTE_VISUALIZATION; } });
|
|
6
8
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gGAA6F;AAM1D,6GAN1B,2DAA4B,OAM0B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,gGAA6F;AAM1D,6GAN1B,2DAA4B,OAM0B;AAL/D,wDAAsJ;AAkBlJ,wGAlByF,oCAAuB,OAkBzF"}
|
|
@@ -1,19 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SDTF_TYPEHINT } from "@shapediver/viewer.shared.types";
|
|
2
2
|
import { vec3 } from "gl-matrix";
|
|
3
|
+
export declare enum ATTRIBUTE_VISUALIZATION {
|
|
4
|
+
GRAYSCALE = "grayscale",
|
|
5
|
+
OPACITY = "opacity",
|
|
6
|
+
BLUE_RED = "blue_red",
|
|
7
|
+
BLUE_WHITE_RED = "blue_white_red",
|
|
8
|
+
GREEN_RED = "green_red",
|
|
9
|
+
GREEN_WHITE_RED = "green_white_red",
|
|
10
|
+
BLUE_GREEN_RED = "blue_green_red",
|
|
11
|
+
BLUE_GREEN_YELLOW_RED_PURPLE_WHITE = "blue_green_yellow_red_purple_white",
|
|
12
|
+
HSL = "hsl"
|
|
13
|
+
}
|
|
3
14
|
export interface IAttribute {
|
|
4
15
|
key: string;
|
|
5
|
-
type:
|
|
16
|
+
type: SDTF_TYPEHINT;
|
|
6
17
|
}
|
|
7
18
|
export interface IColorAttribute extends IAttribute {
|
|
8
19
|
}
|
|
9
20
|
export interface INumberAttribute extends IAttribute {
|
|
10
21
|
min: number;
|
|
11
22
|
max: number;
|
|
12
|
-
visualization:
|
|
23
|
+
visualization: ATTRIBUTE_VISUALIZATION;
|
|
13
24
|
}
|
|
14
25
|
export interface IStringAttribute extends IAttribute {
|
|
15
26
|
values: string[];
|
|
16
|
-
visualization:
|
|
27
|
+
visualization: ATTRIBUTE_VISUALIZATION;
|
|
17
28
|
}
|
|
18
29
|
export interface IDefaultAttribute extends IAttribute {
|
|
19
30
|
color: string | vec3 | number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAttribute.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IAttribute.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAttribute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,oBAAY,uBAAuB;IAC/B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,kCAAkC,uCAAuC;IACzE,GAAG,QAAQ;CACd;AACD,MAAM,WAAW,UAAU;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,eAAgB,SAAQ,UAAU;CAAG;AAEtD,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,uBAAuB,CAAA;CACzC;AAED,MAAM,WAAW,gBAAiB,SAAQ,UAAU;IAChD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,uBAAuB,CAAA;CACzC;AACD,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACjD,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,EAAE,CAAA;CAClC"}
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ATTRIBUTE_VISUALIZATION = void 0;
|
|
4
|
+
var ATTRIBUTE_VISUALIZATION;
|
|
5
|
+
(function (ATTRIBUTE_VISUALIZATION) {
|
|
6
|
+
ATTRIBUTE_VISUALIZATION["GRAYSCALE"] = "grayscale";
|
|
7
|
+
ATTRIBUTE_VISUALIZATION["OPACITY"] = "opacity";
|
|
8
|
+
ATTRIBUTE_VISUALIZATION["BLUE_RED"] = "blue_red";
|
|
9
|
+
ATTRIBUTE_VISUALIZATION["BLUE_WHITE_RED"] = "blue_white_red";
|
|
10
|
+
ATTRIBUTE_VISUALIZATION["GREEN_RED"] = "green_red";
|
|
11
|
+
ATTRIBUTE_VISUALIZATION["GREEN_WHITE_RED"] = "green_white_red";
|
|
12
|
+
ATTRIBUTE_VISUALIZATION["BLUE_GREEN_RED"] = "blue_green_red";
|
|
13
|
+
ATTRIBUTE_VISUALIZATION["BLUE_GREEN_YELLOW_RED_PURPLE_WHITE"] = "blue_green_yellow_red_purple_white";
|
|
14
|
+
ATTRIBUTE_VISUALIZATION["HSL"] = "hsl";
|
|
15
|
+
})(ATTRIBUTE_VISUALIZATION = exports.ATTRIBUTE_VISUALIZATION || (exports.ATTRIBUTE_VISUALIZATION = {}));
|
|
3
16
|
;
|
|
4
17
|
;
|
|
5
18
|
//# sourceMappingURL=IAttribute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAttribute.js","sourceRoot":"","sources":["../../src/interfaces/IAttribute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IAttribute.js","sourceRoot":"","sources":["../../src/interfaces/IAttribute.ts"],"names":[],"mappings":";;;AAGA,IAAY,uBAUX;AAVD,WAAY,uBAAuB;IAC/B,kDAAuB,CAAA;IACvB,8CAAmB,CAAA;IACnB,gDAAqB,CAAA;IACrB,4DAAiC,CAAA;IACjC,kDAAuB,CAAA;IACvB,8DAAmC,CAAA;IACnC,4DAAiC,CAAA;IACjC,oGAAyE,CAAA;IACzE,sCAAW,CAAA;AACf,CAAC,EAVW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAUlC;AAIA,CAAC;AAEoD,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IMaterialAbstractData, ISDTFOverview } from "@shapediver/viewer.shared.types";
|
|
2
2
|
import { IAttribute } from "./IAttribute";
|
|
3
3
|
import { ILayer } from "./ILayer";
|
|
4
4
|
export interface IAttributeVisualizationEngine {
|
|
5
|
-
readonly defaultMaterial:
|
|
5
|
+
readonly defaultMaterial: IMaterialAbstractData;
|
|
6
6
|
readonly layers: {
|
|
7
7
|
[key: string]: ILayer;
|
|
8
8
|
};
|
|
9
|
-
readonly overview:
|
|
9
|
+
readonly overview: ISDTFOverview;
|
|
10
10
|
/**
|
|
11
11
|
* Add a listener that will be called whenever there was an update to the attributes.
|
|
12
12
|
* Use this listener to update your menu.
|
|
@@ -28,7 +28,7 @@ export interface IAttributeVisualizationEngine {
|
|
|
28
28
|
* Update the default material that is used to visualize objects without attributes.
|
|
29
29
|
* @param material
|
|
30
30
|
*/
|
|
31
|
-
updateDefaultMaterial(material:
|
|
31
|
+
updateDefaultMaterial(material: IMaterialAbstractData): void;
|
|
32
32
|
/**
|
|
33
33
|
* Update the layers, the opacity is multiplied with the attribute visualization opacity.
|
|
34
34
|
* @param layers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IAttributeVisualizationEngine.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAttributeVisualizationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IAttributeVisualizationEngine.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAttributeVisualizationEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,6BAA6B;IAG1C,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC;IAChD,QAAQ,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IAMjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,CAAC;IAEpC;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvC;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;IAEjD;;;OAGG;IACH,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAE7D;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAGzD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.features.attribute-visualization",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"src",
|
|
15
|
+
"package.json",
|
|
16
|
+
"README.md",
|
|
17
|
+
"tsconfig.json"
|
|
14
18
|
],
|
|
15
19
|
"publishConfig": {
|
|
16
20
|
"access": "public"
|
|
@@ -20,11 +24,11 @@
|
|
|
20
24
|
"url": "git+https://github.com/shapediver/Viewer.git"
|
|
21
25
|
},
|
|
22
26
|
"scripts": {
|
|
23
|
-
"test": "bash ../../scripts/test.sh",
|
|
24
27
|
"check": "tsc --noEmit",
|
|
25
|
-
"build": "bash ../../scripts/build.sh",
|
|
26
|
-
"build-watch": "bash ../../scripts/build-watch.sh",
|
|
27
|
-
"build-dep": "bash ../../scripts/build-dep.sh"
|
|
28
|
+
"build": "bash ../../scripts/building/build.sh",
|
|
29
|
+
"build-watch": "bash ../../scripts/building/build-watch.sh",
|
|
30
|
+
"build-dep": "bash ../../scripts/building/build-dep.sh",
|
|
31
|
+
"build-current": "npm run build-dep"
|
|
28
32
|
},
|
|
29
33
|
"bugs": {
|
|
30
34
|
"url": "https://github.com/shapediver/Viewer/issues"
|
|
@@ -36,15 +40,14 @@
|
|
|
36
40
|
"testEnvironment": "node"
|
|
37
41
|
},
|
|
38
42
|
"devDependencies": {
|
|
39
|
-
"@shapediver/
|
|
40
|
-
"@shapediver/viewer": "
|
|
41
|
-
"@shapediver/viewer.shared.
|
|
42
|
-
"@shapediver/viewer.shared.types": "1.15.7"
|
|
43
|
+
"@shapediver/viewer": "2.0.2",
|
|
44
|
+
"@shapediver/viewer.shared.services": "2.0.2",
|
|
45
|
+
"@shapediver/viewer.shared.types": "2.0.2"
|
|
43
46
|
},
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"detect-it": "4.0.1",
|
|
46
49
|
"gl-matrix": "3.3.0",
|
|
47
50
|
"tsyringe": "^4.5.0"
|
|
48
51
|
},
|
|
49
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "1655aca09350a0a27686512bcac140df47c8a0ec"
|
|
50
53
|
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { ILayer } from "../interfaces/ILayer";
|
|
2
|
+
import { addListener, IViewportApi, sceneTree } from "@shapediver/viewer";
|
|
3
|
+
import { IAttribute, IColorAttribute, IDefaultAttribute, INumberAttribute, IStringAttribute } from "../interfaces/IAttribute";
|
|
4
|
+
import { mat4 } from "gl-matrix";
|
|
5
|
+
import { container } from "tsyringe";
|
|
6
|
+
import { Converter, EVENTTYPE, UuidGenerator } from "@shapediver/viewer.shared.services";
|
|
7
|
+
import { IAttributeVisualizationEngine } from "../interfaces/IAttributeVisualizationEngine";
|
|
8
|
+
import { IMaterialAbstractData, ISDTFItemData, ISDTFOverview, MaterialUnlitData, SdtfPrimitiveTypeGuard } from "@shapediver/viewer.shared.types";
|
|
9
|
+
import { AttributeVisualizationUtils } from "./AttributeVisualizationUtils";
|
|
10
|
+
|
|
11
|
+
export class AttributeVisualizationEngine implements IAttributeVisualizationEngine {
|
|
12
|
+
// #region Properties (7)
|
|
13
|
+
|
|
14
|
+
readonly #converter: Converter = <Converter>container.resolve(Converter);
|
|
15
|
+
readonly #uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
|
|
16
|
+
readonly #viewport: IViewportApi;
|
|
17
|
+
|
|
18
|
+
#attributes: IAttribute[] = [];
|
|
19
|
+
#defaultMaterial: IMaterialAbstractData = new MaterialUnlitData({ color: '#000000', opacity: 1 });
|
|
20
|
+
#defaultLayer: ILayer = {
|
|
21
|
+
color: '#000000',
|
|
22
|
+
opacity: 1,
|
|
23
|
+
enabled: true
|
|
24
|
+
};
|
|
25
|
+
#layers: {
|
|
26
|
+
[key: string]: ILayer
|
|
27
|
+
} = {};
|
|
28
|
+
#overview: ISDTFOverview;
|
|
29
|
+
#listeners: {
|
|
30
|
+
[key: string]: () => void
|
|
31
|
+
} = {};
|
|
32
|
+
|
|
33
|
+
// #endregion Properties (7)
|
|
34
|
+
|
|
35
|
+
// #region Constructors (1)
|
|
36
|
+
|
|
37
|
+
constructor(viewport: IViewportApi) {
|
|
38
|
+
this.#viewport = viewport;
|
|
39
|
+
|
|
40
|
+
this.#overview = this.#viewport.createSDTFOverview(sceneTree.root);
|
|
41
|
+
this.createLayers();
|
|
42
|
+
this.constructAttributeVisualization();
|
|
43
|
+
addListener(EVENTTYPE.SESSION.SESSION_CUSTOMIZED, () => {
|
|
44
|
+
this.#overview = this.#viewport.createSDTFOverview(sceneTree.root);
|
|
45
|
+
this.createLayers();
|
|
46
|
+
this.constructAttributeVisualization();
|
|
47
|
+
|
|
48
|
+
for (let l in this.#listeners)
|
|
49
|
+
this.#listeners[l]();
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// #endregion Constructors (1)
|
|
54
|
+
|
|
55
|
+
// #region Public Accessors (3)
|
|
56
|
+
|
|
57
|
+
public get defaultMaterial(): IMaterialAbstractData {
|
|
58
|
+
return this.#defaultMaterial;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public get defaultLayer(): ILayer {
|
|
62
|
+
return this.#defaultLayer;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public get layers(): { [key: string]: ILayer } {
|
|
66
|
+
return this.#layers;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public get overview(): ISDTFOverview {
|
|
70
|
+
return this.#overview;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// #endregion Public Accessors (3)
|
|
74
|
+
|
|
75
|
+
// #region Public Methods (3)
|
|
76
|
+
|
|
77
|
+
public updateAttributes(attributes: IAttribute[]) {
|
|
78
|
+
this.#attributes = attributes;
|
|
79
|
+
this.constructAttributeVisualization();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public updateDefaultLayer(layer: ILayer) {
|
|
83
|
+
this.#defaultLayer = layer;
|
|
84
|
+
this.constructAttributeVisualization();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public updateDefaultMaterial(material: IMaterialAbstractData) {
|
|
88
|
+
this.#defaultMaterial = material;
|
|
89
|
+
this.constructAttributeVisualization();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public updateLayers(layers: { [key: string]: ILayer }) {
|
|
93
|
+
this.#layers = layers;
|
|
94
|
+
this.constructAttributeVisualization();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public addListener(cb: () => void): string {
|
|
98
|
+
const token = this.#uuidGenerator.create();
|
|
99
|
+
this.#listeners[token] = cb;
|
|
100
|
+
return token;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public removeListener(token: string): boolean {
|
|
104
|
+
if (!this.#listeners[token]) return false;
|
|
105
|
+
delete this.#listeners[token];
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// #endregion Public Methods (3)
|
|
110
|
+
|
|
111
|
+
// #region Private Methods (2)
|
|
112
|
+
|
|
113
|
+
private constructAttributeVisualization() {
|
|
114
|
+
this.#viewport.visualizeAttributes = (overview: ISDTFOverview, itemData?: ISDTFItemData) => {
|
|
115
|
+
// early out if there are not attributes in this itemData
|
|
116
|
+
if (!itemData || !itemData.attributes) {
|
|
117
|
+
if (this.#attributes.length === 0) {
|
|
118
|
+
// return default layer material
|
|
119
|
+
const material = new MaterialUnlitData({
|
|
120
|
+
opacity: this.#defaultLayer.enabled ? this.#defaultLayer.opacity : 0,
|
|
121
|
+
color: this.#converter.toColor(this.#defaultLayer.color)
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
matrix: mat4.create(),
|
|
125
|
+
material
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
// return default layer material
|
|
129
|
+
const material = new MaterialUnlitData({
|
|
130
|
+
opacity: this.#defaultLayer.enabled ? this.#defaultLayer.opacity * this.#defaultMaterial.opacity : 0,
|
|
131
|
+
color: this.#converter.toColor(this.#defaultMaterial.color)
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
matrix: mat4.create(),
|
|
135
|
+
material
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// search for the responsible layer property, if none is found, default layer is assigned
|
|
141
|
+
let layer: ILayer = this.defaultLayer;
|
|
142
|
+
if (itemData.attributes['layer'] && SdtfPrimitiveTypeGuard.isStringType(itemData.attributes['layer'].typeHint)) {
|
|
143
|
+
const layerAttributes = itemData.attributes['layer'];
|
|
144
|
+
layer = this.#layers[layerAttributes.value];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// early out, layer is not enabled
|
|
148
|
+
if (layer.enabled === false) {
|
|
149
|
+
const mat = <IMaterialAbstractData>this.#defaultMaterial.clone();
|
|
150
|
+
mat.opacity = 0;
|
|
151
|
+
return {
|
|
152
|
+
matrix: mat4.create(),
|
|
153
|
+
material: mat
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (this.#attributes.length === 0) {
|
|
158
|
+
// no attributes are specified, we go into layer visualization mode
|
|
159
|
+
const material = new MaterialUnlitData({
|
|
160
|
+
opacity: layer.opacity,
|
|
161
|
+
color: this.#converter.toColor(layer.color)
|
|
162
|
+
});
|
|
163
|
+
return {
|
|
164
|
+
matrix: mat4.create(),
|
|
165
|
+
material
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
// attributes are specified, we go into attribute visualization mode
|
|
169
|
+
const material = new MaterialUnlitData();
|
|
170
|
+
for (let i = 0; i < this.#attributes.length; i++) {
|
|
171
|
+
const a = this.#attributes[i];
|
|
172
|
+
if (itemData.attributes[a.key] && itemData.attributes[a.key].typeHint === a.type) {
|
|
173
|
+
const itemDataAttribute = itemData.attributes[a.key];
|
|
174
|
+
const itemDataAttributeOverview = overview[a.key].filter(o => o.typeHint === a.type)[0];
|
|
175
|
+
|
|
176
|
+
switch (true) {
|
|
177
|
+
case SdtfPrimitiveTypeGuard.isColorType(a.type):
|
|
178
|
+
material.color = this.#converter.toColor('rgb(' + itemDataAttribute.value + ')');
|
|
179
|
+
material.opacity *= layer.opacity;
|
|
180
|
+
return {
|
|
181
|
+
matrix: mat4.create(),
|
|
182
|
+
material
|
|
183
|
+
};
|
|
184
|
+
case SdtfPrimitiveTypeGuard.isNumberType(a.type):
|
|
185
|
+
const numberAttribute = <INumberAttribute>a;
|
|
186
|
+
const numberVisualizationData = AttributeVisualizationUtils.numberVisualization(
|
|
187
|
+
itemDataAttribute.value,
|
|
188
|
+
(numberAttribute.min !== undefined ? numberAttribute.min : itemDataAttributeOverview.min)!,
|
|
189
|
+
(numberAttribute.max !== undefined ? numberAttribute.max : itemDataAttributeOverview.max)!,
|
|
190
|
+
numberAttribute.visualization,
|
|
191
|
+
this.#defaultMaterial
|
|
192
|
+
);
|
|
193
|
+
numberVisualizationData.material.opacity *= layer.opacity;
|
|
194
|
+
return numberVisualizationData;
|
|
195
|
+
case SdtfPrimitiveTypeGuard.isStringType(a.type):
|
|
196
|
+
const stringAttribute = <IStringAttribute>a;
|
|
197
|
+
const stringVisualizationData = AttributeVisualizationUtils.stringVisualization(
|
|
198
|
+
itemDataAttribute.value,
|
|
199
|
+
stringAttribute.values || itemDataAttributeOverview.values,
|
|
200
|
+
stringAttribute.visualization,
|
|
201
|
+
this.#defaultMaterial);
|
|
202
|
+
|
|
203
|
+
stringVisualizationData.material.opacity *= layer.opacity;
|
|
204
|
+
return stringVisualizationData;
|
|
205
|
+
default:
|
|
206
|
+
const defaultAttribute = <IDefaultAttribute>a;
|
|
207
|
+
material.color = this.#converter.toColor(defaultAttribute.color);
|
|
208
|
+
material.opacity *= layer.opacity;
|
|
209
|
+
return {
|
|
210
|
+
matrix: mat4.create(),
|
|
211
|
+
material
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// no attributes were found, return the default material adjusted by the layer opacity
|
|
218
|
+
const mat = <IMaterialAbstractData>this.#defaultMaterial.clone();
|
|
219
|
+
mat.opacity *= layer.opacity;
|
|
220
|
+
return {
|
|
221
|
+
matrix: mat4.create(),
|
|
222
|
+
material: mat
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
sceneTree.root.updateVersion();
|
|
228
|
+
this.#viewport.update();
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private createLayers() {
|
|
232
|
+
this.#layers = {};
|
|
233
|
+
if (this.#overview['layer']) {
|
|
234
|
+
const layerStringAttributeOverview = this.#overview['layer'].find(a => a.typeHint === 'string');
|
|
235
|
+
if (layerStringAttributeOverview && layerStringAttributeOverview.values) {
|
|
236
|
+
for (let i = 0; i < layerStringAttributeOverview.values.length; i++) {
|
|
237
|
+
this.#layers[layerStringAttributeOverview.values[i]] = {
|
|
238
|
+
enabled: true,
|
|
239
|
+
opacity: 1,
|
|
240
|
+
color: this.defaultMaterial.color
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// #endregion Private Methods (2)
|
|
248
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { IMaterialAbstractData, ISDTFAttributeVisualizationData, MaterialUnlitData } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { mat4 } from "gl-matrix";
|
|
3
|
+
import { ATTRIBUTE_VISUALIZATION } from "../interfaces/IAttribute";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const grayscaleVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
7
|
+
const color = Math.floor(factor * 255.0);
|
|
8
|
+
return {
|
|
9
|
+
material: new MaterialUnlitData({color: 'rgb(' + color + ', ' + color + ', ' + color + ')', opacity: 1}),
|
|
10
|
+
matrix: mat4.create()
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const opacityVisualization = (factor: number, defaultMaterial?: IMaterialAbstractData): ISDTFAttributeVisualizationData => {
|
|
15
|
+
return {
|
|
16
|
+
material: new MaterialUnlitData({color: defaultMaterial?.color || '#00fff7', opacity: factor}),
|
|
17
|
+
matrix: mat4.create()
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const blueRedVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
22
|
+
const red = factor * 255.0;
|
|
23
|
+
const blue = (1 - factor) * 255.0;
|
|
24
|
+
return {
|
|
25
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(0) + ', ' + Math.floor(blue) + ')', opacity: 1}),
|
|
26
|
+
matrix: mat4.create()
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const blueWhiteRedVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
31
|
+
let red = 255, green = 255, blue = 255;
|
|
32
|
+
|
|
33
|
+
if(factor < 0.5) {
|
|
34
|
+
const remappedFactor = factor / 0.5;
|
|
35
|
+
red = 255.0 * remappedFactor;
|
|
36
|
+
green = 255.0 * remappedFactor;
|
|
37
|
+
blue = 255.0;
|
|
38
|
+
} else {
|
|
39
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
40
|
+
red = 255.0;
|
|
41
|
+
green = 255.0 * (1 - remappedFactor);
|
|
42
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1}),
|
|
46
|
+
matrix: mat4.create()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const greenRedVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
51
|
+
const red = factor * 255.0;
|
|
52
|
+
const green = (1 - factor) * 255.0;
|
|
53
|
+
return {
|
|
54
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(0) + ')', opacity: 1}),
|
|
55
|
+
matrix: mat4.create()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const greenWhiteRedVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
60
|
+
let red = 255, green = 255, blue = 255;
|
|
61
|
+
|
|
62
|
+
if(factor < 0.5) {
|
|
63
|
+
const remappedFactor = factor / 0.5;
|
|
64
|
+
red = 255.0 * remappedFactor;
|
|
65
|
+
green = 255.0;
|
|
66
|
+
blue = 255.0 * remappedFactor;
|
|
67
|
+
} else {
|
|
68
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
69
|
+
red = 255.0;
|
|
70
|
+
green = 255.0 * (1 - remappedFactor);
|
|
71
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1}),
|
|
75
|
+
matrix: mat4.create()
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const blueGreenRedVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
80
|
+
let red = 255, green = 255, blue = 255;
|
|
81
|
+
|
|
82
|
+
if(factor < 0.5) {
|
|
83
|
+
const remappedFactor = factor / 0.5;
|
|
84
|
+
red = 0;
|
|
85
|
+
green = 255.0 * remappedFactor;
|
|
86
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
87
|
+
} else {
|
|
88
|
+
const remappedFactor = (factor - 0.5) / 0.5;
|
|
89
|
+
red = 255.0 * remappedFactor;
|
|
90
|
+
green = 255.0 * (1 - remappedFactor);
|
|
91
|
+
blue = 0;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1}),
|
|
95
|
+
matrix: mat4.create()
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const blueGreenYellowRedPurpleWhiteVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
100
|
+
let red = 255, green = 255, blue = 255;
|
|
101
|
+
|
|
102
|
+
if(factor < 0.2) {
|
|
103
|
+
const remappedFactor = factor / 0.2;
|
|
104
|
+
red = 0;
|
|
105
|
+
green = 255.0 * remappedFactor;
|
|
106
|
+
blue = 255.0 * (1 - remappedFactor);
|
|
107
|
+
} else if(factor < 0.4) {
|
|
108
|
+
const remappedFactor = (factor - 0.2) / 0.2;
|
|
109
|
+
red = 255.0 * remappedFactor;
|
|
110
|
+
green = 255.0;
|
|
111
|
+
blue = 0.0;
|
|
112
|
+
} else if(factor < 0.6) {
|
|
113
|
+
const remappedFactor = (factor - 0.4) / 0.2;
|
|
114
|
+
red = 255.0;
|
|
115
|
+
green = 255.0 * (1 - remappedFactor)
|
|
116
|
+
blue = 0.0;
|
|
117
|
+
} else if(factor < 0.8) {
|
|
118
|
+
const remappedFactor = (factor - 0.6) / 0.2;
|
|
119
|
+
red = 255.0;
|
|
120
|
+
green = 0.0;
|
|
121
|
+
blue = 255.0 * remappedFactor;
|
|
122
|
+
} else {
|
|
123
|
+
const remappedFactor = (factor - 0.8) / 0.2;
|
|
124
|
+
red = 255.0;
|
|
125
|
+
green = 255.0 * remappedFactor;
|
|
126
|
+
blue = 255.0;
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
material: new MaterialUnlitData({color: 'rgb(' + Math.floor(red) + ', ' + Math.floor(green) + ', ' + Math.floor(blue) + ')', opacity: 1}),
|
|
130
|
+
matrix: mat4.create()
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const hslVisualization = (factor: number): ISDTFAttributeVisualizationData => {
|
|
135
|
+
const hue = factor * 359.99;
|
|
136
|
+
return {
|
|
137
|
+
material: new MaterialUnlitData({color: 'hsl(' + Math.floor(hue) + ', 100%, 50%)', opacity: 1}),
|
|
138
|
+
matrix: mat4.create()
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const numberVisualization = (value: number, min: number, max: number, type: ATTRIBUTE_VISUALIZATION, defaultMaterial?: IMaterialAbstractData): ISDTFAttributeVisualizationData => {
|
|
143
|
+
let factor = (value - min) / (max - min);
|
|
144
|
+
factor = Math.min(1, Math.max(0, factor))
|
|
145
|
+
|
|
146
|
+
switch(type) {
|
|
147
|
+
case ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
148
|
+
return grayscaleVisualization(factor);
|
|
149
|
+
case ATTRIBUTE_VISUALIZATION.OPACITY:
|
|
150
|
+
return opacityVisualization(factor, defaultMaterial);
|
|
151
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
152
|
+
return blueRedVisualization(factor);
|
|
153
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
154
|
+
return blueWhiteRedVisualization(factor);
|
|
155
|
+
case ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
156
|
+
return greenRedVisualization(factor);
|
|
157
|
+
case ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
158
|
+
return greenWhiteRedVisualization(factor);
|
|
159
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
160
|
+
return blueGreenRedVisualization(factor);
|
|
161
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
162
|
+
return blueGreenYellowRedPurpleWhiteVisualization(factor);
|
|
163
|
+
case ATTRIBUTE_VISUALIZATION.HSL:
|
|
164
|
+
return hslVisualization(factor);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const stringVisualization = (value: string, values: string[], type: ATTRIBUTE_VISUALIZATION, defaultMaterial?: IMaterialAbstractData): ISDTFAttributeVisualizationData => {
|
|
169
|
+
let factor = values.indexOf(value) / (values.length - 1);
|
|
170
|
+
factor = Math.min(1, Math.max(0, factor))
|
|
171
|
+
switch(type) {
|
|
172
|
+
case ATTRIBUTE_VISUALIZATION.GRAYSCALE:
|
|
173
|
+
return grayscaleVisualization(factor);
|
|
174
|
+
case ATTRIBUTE_VISUALIZATION.OPACITY:
|
|
175
|
+
return opacityVisualization(factor, defaultMaterial);
|
|
176
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_RED:
|
|
177
|
+
return blueRedVisualization(factor);
|
|
178
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_WHITE_RED:
|
|
179
|
+
return blueWhiteRedVisualization(factor);
|
|
180
|
+
case ATTRIBUTE_VISUALIZATION.GREEN_RED:
|
|
181
|
+
return greenRedVisualization(factor);
|
|
182
|
+
case ATTRIBUTE_VISUALIZATION.GREEN_WHITE_RED:
|
|
183
|
+
return greenWhiteRedVisualization(factor);
|
|
184
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_GREEN_RED:
|
|
185
|
+
return blueGreenRedVisualization(factor);
|
|
186
|
+
case ATTRIBUTE_VISUALIZATION.BLUE_GREEN_YELLOW_RED_PURPLE_WHITE:
|
|
187
|
+
return blueGreenYellowRedPurpleWhiteVisualization(factor);
|
|
188
|
+
case ATTRIBUTE_VISUALIZATION.HSL:
|
|
189
|
+
return hslVisualization(factor);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const AttributeVisualizationUtils = {
|
|
194
|
+
numberVisualization,
|
|
195
|
+
stringVisualization
|
|
196
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AttributeVisualizationEngine } from "./implementation/AttributeVisualizationEngine";
|
|
2
|
+
import { IAttribute, IColorAttribute, IStringAttribute, INumberAttribute, IDefaultAttribute, ATTRIBUTE_VISUALIZATION } from "./interfaces/IAttribute";
|
|
3
|
+
import { IAttributeVisualizationEngine } from "./interfaces/IAttributeVisualizationEngine";
|
|
4
|
+
import { ILayer } from "./interfaces/ILayer";
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
IAttributeVisualizationEngine, AttributeVisualizationEngine
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
ILayer,
|
|
12
|
+
IAttribute,
|
|
13
|
+
IColorAttribute,
|
|
14
|
+
IStringAttribute,
|
|
15
|
+
INumberAttribute,
|
|
16
|
+
IDefaultAttribute
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
ATTRIBUTE_VISUALIZATION
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SDTF_TYPEHINT } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { vec3 } from "gl-matrix";
|
|
3
|
+
|
|
4
|
+
export enum ATTRIBUTE_VISUALIZATION {
|
|
5
|
+
GRAYSCALE = 'grayscale',
|
|
6
|
+
OPACITY = 'opacity',
|
|
7
|
+
BLUE_RED = 'blue_red',
|
|
8
|
+
BLUE_WHITE_RED = 'blue_white_red',
|
|
9
|
+
GREEN_RED = 'green_red',
|
|
10
|
+
GREEN_WHITE_RED = 'green_white_red',
|
|
11
|
+
BLUE_GREEN_RED = 'blue_green_red',
|
|
12
|
+
BLUE_GREEN_YELLOW_RED_PURPLE_WHITE = 'blue_green_yellow_red_purple_white',
|
|
13
|
+
HSL = 'hsl'
|
|
14
|
+
}
|
|
15
|
+
export interface IAttribute {
|
|
16
|
+
key: string,
|
|
17
|
+
type: SDTF_TYPEHINT,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export interface IColorAttribute extends IAttribute {};
|
|
21
|
+
|
|
22
|
+
export interface INumberAttribute extends IAttribute {
|
|
23
|
+
min: number,
|
|
24
|
+
max: number,
|
|
25
|
+
visualization: ATTRIBUTE_VISUALIZATION
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IStringAttribute extends IAttribute {
|
|
29
|
+
values: string[],
|
|
30
|
+
visualization: ATTRIBUTE_VISUALIZATION
|
|
31
|
+
}
|
|
32
|
+
export interface IDefaultAttribute extends IAttribute {
|
|
33
|
+
color: string | vec3 | number[]
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IMaterialAbstractData, ISDTFOverview } from "@shapediver/viewer.shared.types";
|
|
2
|
+
import { IAttribute } from "./IAttribute";
|
|
3
|
+
import { ILayer } from "./ILayer";
|
|
4
|
+
|
|
5
|
+
export interface IAttributeVisualizationEngine {
|
|
6
|
+
// #region Properties (3)
|
|
7
|
+
|
|
8
|
+
readonly defaultMaterial: IMaterialAbstractData;
|
|
9
|
+
readonly layers: { [key: string]: ILayer };
|
|
10
|
+
readonly overview: ISDTFOverview;
|
|
11
|
+
|
|
12
|
+
// #endregion Properties (3)
|
|
13
|
+
|
|
14
|
+
// #region Public Methods (5)
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Add a listener that will be called whenever there was an update to the attributes.
|
|
18
|
+
* Use this listener to update your menu.
|
|
19
|
+
* @param cb
|
|
20
|
+
*/
|
|
21
|
+
addListener(cb: () => void): string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Remove a listener.
|
|
25
|
+
* @param token
|
|
26
|
+
*/
|
|
27
|
+
removeListener(token: string): boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Update the attributes that are used to visualize the geometry.
|
|
31
|
+
* If an object is present in multiple of the attributes, only the first one will be used.
|
|
32
|
+
* @param attributes
|
|
33
|
+
*/
|
|
34
|
+
updateAttributes(attributes: IAttribute[]): void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Update the default material that is used to visualize objects without attributes.
|
|
38
|
+
* @param material
|
|
39
|
+
*/
|
|
40
|
+
updateDefaultMaterial(material: IMaterialAbstractData): void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Update the layers, the opacity is multiplied with the attribute visualization opacity.
|
|
44
|
+
* @param layers
|
|
45
|
+
*/
|
|
46
|
+
updateLayers(layers: { [key: string]: ILayer }): void;
|
|
47
|
+
|
|
48
|
+
// #endregion Public Methods (5)
|
|
49
|
+
}
|
package/tsconfig.json
ADDED