@things-factory/scene-visualizer 4.3.755 → 4.3.764
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/package.json +2 -2
- package/src/stock.js +55 -37
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/scene-visualizer",
|
|
3
3
|
"description": "The visualizer component for things-scene.",
|
|
4
|
-
"version": "4.3.
|
|
4
|
+
"version": "4.3.764",
|
|
5
5
|
"things-scene": true,
|
|
6
6
|
"browser": "src/index.js",
|
|
7
7
|
"author": "heartyoh",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"lit": "^2.2.0",
|
|
20
20
|
"three": "^0.122.0"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "4dd8055a25e773814603c4be21fc70930d0cfb13"
|
|
23
23
|
}
|
package/src/stock.js
CHANGED
|
@@ -29,7 +29,8 @@ export default class Stock extends Mesh {
|
|
|
29
29
|
this._visualizer.legendTarget &&
|
|
30
30
|
this._visualizer.legendTarget.get('status')
|
|
31
31
|
)
|
|
32
|
-
)
|
|
32
|
+
)
|
|
33
|
+
return this.userDefineDefaultMaterial
|
|
33
34
|
|
|
34
35
|
var stockStatus = this._visualizer.legendTarget.get('status')
|
|
35
36
|
var range = stockStatus.ranges[index]
|
|
@@ -42,9 +43,9 @@ export default class Stock extends Mesh {
|
|
|
42
43
|
roughness: 0.7
|
|
43
44
|
})
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
-
var alpha=range.color.replace(/^.*,(.+)\)/,'$1')
|
|
47
|
-
if(alpha>0 && alpha<1){
|
|
46
|
+
|
|
47
|
+
var alpha = range.color.replace(/^.*,(.+)\)/, '$1')
|
|
48
|
+
if (alpha > 0 && alpha < 1) {
|
|
48
49
|
this.stockMaterials[index].opacity = alpha
|
|
49
50
|
this.stockMaterials[index].transparent = true
|
|
50
51
|
}
|
|
@@ -86,8 +87,8 @@ export default class Stock extends Mesh {
|
|
|
86
87
|
side: THREE.FrontSide,
|
|
87
88
|
roughness: 0.7
|
|
88
89
|
})
|
|
89
|
-
var alpha=defaultColor.replace(/^.*,(.+)\)/,'$1')
|
|
90
|
-
if(alpha>0 && alpha<1){
|
|
90
|
+
var alpha = defaultColor.replace(/^.*,(.+)\)/, '$1')
|
|
91
|
+
if (alpha > 0 && alpha < 1) {
|
|
91
92
|
this._visualizer._default_material.opacity = alpha
|
|
92
93
|
this._visualizer._default_material.transparent = true
|
|
93
94
|
}
|
|
@@ -111,11 +112,11 @@ export default class Stock extends Mesh {
|
|
|
111
112
|
this._visualizer._empty_material = new THREE.MeshStandardMaterial({
|
|
112
113
|
color: defaultColor
|
|
113
114
|
})
|
|
114
|
-
var alpha=defaultColor.replace(/^.*,(.+)\)/,'$1')
|
|
115
|
-
if(alpha>0 && alpha<1){
|
|
115
|
+
var alpha = defaultColor.replace(/^.*,(.+)\)/, '$1')
|
|
116
|
+
if (alpha > 0 && alpha < 1) {
|
|
116
117
|
this._visualizer._empty_material.opacity = alpha
|
|
117
118
|
this._visualizer._empty_material.transparent = true
|
|
118
|
-
}else{
|
|
119
|
+
} else {
|
|
119
120
|
this._visualizer._empty_material.opacity = 0.33
|
|
120
121
|
this._visualizer._empty_material.transparent = true
|
|
121
122
|
}
|
|
@@ -176,41 +177,58 @@ export default class Stock extends Mesh {
|
|
|
176
177
|
|
|
177
178
|
if (!(statusField && ranges)) return
|
|
178
179
|
|
|
179
|
-
var data =
|
|
180
|
-
|
|
181
|
-
for (let i in data) {
|
|
182
|
-
let d = data[i]
|
|
180
|
+
var data = this.userData.items ? this.userData.items : [this.userData]
|
|
183
181
|
|
|
184
|
-
|
|
182
|
+
// statusField 값들을 수집하고 유효한 값만 필터링
|
|
183
|
+
var statusValues = data
|
|
184
|
+
.map(d => d[statusField])
|
|
185
|
+
.filter(value => value !== undefined && value !== null && !isNaN(value))
|
|
185
186
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
// 유효한 값이 없으면 기본 material 사용
|
|
188
|
+
if (statusValues.length === 0) {
|
|
189
|
+
this.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
190
|
+
return
|
|
191
|
+
}
|
|
191
192
|
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
// aggregation 방법으로 계산 (기본값: sum)
|
|
194
|
+
var aggregation = stockStatus.aggregation || 'sum'
|
|
195
|
+
var calculatedStatus = this.calculateAggregation(statusValues, aggregation)
|
|
194
196
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
+
// 계산된 값으로 range 매칭
|
|
198
|
+
var isInRanges = ranges.some((range, index) => {
|
|
199
|
+
let { min, max } = range
|
|
197
200
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (min <= status) {
|
|
201
|
-
this.material = this.getMaterial(index)
|
|
202
|
-
} else return false
|
|
203
|
-
} else this.material = this.getMaterial(index)
|
|
201
|
+
min = min !== undefined ? Number(min) : -Infinity
|
|
202
|
+
max = max !== undefined ? Number(max) : Infinity
|
|
204
203
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
209
|
-
}
|
|
210
|
-
})
|
|
211
|
-
if(!isInRanges){
|
|
212
|
-
this.material = this.userDefineDefaultMaterial
|
|
204
|
+
if (min <= calculatedStatus && calculatedStatus < max) {
|
|
205
|
+
this.material = this.getMaterial(index)
|
|
206
|
+
return true
|
|
213
207
|
}
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
if (!isInRanges) {
|
|
211
|
+
this.material = this._hideEmptyStock ? this.emptyMaterial : this.userDefineDefaultMaterial
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
calculateAggregation(values, method) {
|
|
216
|
+
if (!values || values.length === 0) return 0
|
|
217
|
+
|
|
218
|
+
var numericValues = values.map(v => Number(v)).filter(v => !isNaN(v))
|
|
219
|
+
|
|
220
|
+
switch (method) {
|
|
221
|
+
case 'sum':
|
|
222
|
+
return numericValues.reduce((sum, val) => sum + val, 0)
|
|
223
|
+
case 'min':
|
|
224
|
+
return Math.min(...numericValues)
|
|
225
|
+
case 'max':
|
|
226
|
+
return Math.max(...numericValues)
|
|
227
|
+
case 'avg':
|
|
228
|
+
return numericValues.reduce((sum, val) => sum + val, 0) / numericValues.length
|
|
229
|
+
default:
|
|
230
|
+
// 기본값은 sum
|
|
231
|
+
return numericValues.reduce((sum, val) => sum + val, 0)
|
|
214
232
|
}
|
|
215
233
|
}
|
|
216
234
|
|