@kitware/vtk.js 29.10.0 → 29.11.1
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.
|
@@ -52,7 +52,8 @@ function vtkStringArray(publicAPI, model) {
|
|
|
52
52
|
/* eslint-disable no-use-before-define */
|
|
53
53
|
publicAPI.newClone = () => newInstance({
|
|
54
54
|
name: model.name,
|
|
55
|
-
numberOfComponents: model.numberOfComponents
|
|
55
|
+
numberOfComponents: model.numberOfComponents,
|
|
56
|
+
empty: true
|
|
56
57
|
});
|
|
57
58
|
/* eslint-enable no-use-before-define */
|
|
58
59
|
|
|
@@ -15,32 +15,32 @@ export interface vtkAxesActor extends vtkActor {
|
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
getXConfig(): object;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
*
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
getYConfig(): object;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
*
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
getZConfig(): object;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
getXAxisColor(): number[];
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
getYAxisColor(): number[];
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
*
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
getZAxisColor(): number[];
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
*
|
|
@@ -49,32 +49,38 @@ export interface vtkAxesActor extends vtkActor {
|
|
|
49
49
|
setConfig(config: object): boolean;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param {Number} g Defines the green component (between 0 and 1).
|
|
55
|
-
* @param {Number} b Defines the blue component (between 0 and 1).
|
|
52
|
+
*
|
|
53
|
+
* @param config
|
|
56
54
|
*/
|
|
57
|
-
|
|
55
|
+
setXConfig(config: object): boolean;
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @param
|
|
58
|
+
*
|
|
59
|
+
* @param config
|
|
62
60
|
*/
|
|
63
|
-
|
|
61
|
+
setYConfig(config: object): boolean;
|
|
64
62
|
|
|
65
63
|
/**
|
|
66
|
-
*
|
|
64
|
+
*
|
|
65
|
+
* @param config
|
|
66
|
+
*/
|
|
67
|
+
setZConfig(config: object): boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Set X axis color.
|
|
67
71
|
* @param {Number} r Defines the red component (between 0 and 1).
|
|
68
72
|
* @param {Number} g Defines the green component (between 0 and 1).
|
|
69
73
|
* @param {Number} b Defines the blue component (between 0 and 1).
|
|
70
74
|
*/
|
|
71
|
-
|
|
75
|
+
setXAxisColor(r: number, g: number, b: number): boolean;
|
|
72
76
|
|
|
73
77
|
/**
|
|
74
78
|
* Set Y axis color.
|
|
75
|
-
* @param
|
|
79
|
+
* @param {Number} r Defines the red component (between 0 and 1).
|
|
80
|
+
* @param {Number} g Defines the green component (between 0 and 1).
|
|
81
|
+
* @param {Number} b Defines the blue component (between 0 and 1).
|
|
76
82
|
*/
|
|
77
|
-
|
|
83
|
+
setYAxisColor(r: number, g: number, b: number): boolean;
|
|
78
84
|
|
|
79
85
|
/**
|
|
80
86
|
* Set Z axis color.
|
|
@@ -84,12 +90,6 @@ export interface vtkAxesActor extends vtkActor {
|
|
|
84
90
|
*/
|
|
85
91
|
setZAxisColor(r: number, g: number, b: number): boolean;
|
|
86
92
|
|
|
87
|
-
/**
|
|
88
|
-
* Set E axis color.
|
|
89
|
-
* @param ZAxisColor
|
|
90
|
-
*/
|
|
91
|
-
setZAxisColorFrom(ZAxisColor: number[]): boolean;
|
|
92
|
-
|
|
93
93
|
/**
|
|
94
94
|
*
|
|
95
95
|
*/
|
|
@@ -14,9 +14,14 @@ function centerDataSet(ds) {
|
|
|
14
14
|
vtkMatrixBuilder.buildFromDegree().translate(...center).apply(ds.getPoints().getData());
|
|
15
15
|
}
|
|
16
16
|
function shiftDataset(ds, axis) {
|
|
17
|
+
let invert = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
17
18
|
const bounds = ds.getPoints().getBounds();
|
|
18
19
|
const center = [0, 0, 0];
|
|
19
|
-
|
|
20
|
+
if (invert) {
|
|
21
|
+
center[axis] = -bounds[axis * 2 + 1];
|
|
22
|
+
} else {
|
|
23
|
+
center[axis] = -bounds[axis * 2];
|
|
24
|
+
}
|
|
20
25
|
vtkMatrixBuilder.buildFromDegree().translate(...center).apply(ds.getPoints().getData());
|
|
21
26
|
}
|
|
22
27
|
|
|
@@ -48,36 +53,48 @@ function vtkAxesActor(publicAPI, model) {
|
|
|
48
53
|
const _mapper = vtkMapper.newInstance();
|
|
49
54
|
publicAPI.setMapper(_mapper);
|
|
50
55
|
publicAPI.update = () => {
|
|
56
|
+
let currentConfig = {
|
|
57
|
+
...model.config,
|
|
58
|
+
...model.xConfig
|
|
59
|
+
};
|
|
51
60
|
const xAxis = vtkArrowSource.newInstance({
|
|
52
61
|
direction: [1, 0, 0],
|
|
53
|
-
...
|
|
62
|
+
...currentConfig
|
|
54
63
|
}).getOutputData();
|
|
55
64
|
if (model.config.recenter) {
|
|
56
65
|
centerDataSet(xAxis);
|
|
57
66
|
} else {
|
|
58
|
-
shiftDataset(xAxis, 0);
|
|
67
|
+
shiftDataset(xAxis, 0, currentConfig.invert);
|
|
59
68
|
}
|
|
60
|
-
addColor(xAxis, ...
|
|
69
|
+
addColor(xAxis, ...currentConfig.color);
|
|
70
|
+
currentConfig = {
|
|
71
|
+
...model.config,
|
|
72
|
+
...model.yConfig
|
|
73
|
+
};
|
|
61
74
|
const yAxis = vtkArrowSource.newInstance({
|
|
62
75
|
direction: [0, 1, 0],
|
|
63
|
-
...
|
|
76
|
+
...currentConfig
|
|
64
77
|
}).getOutputData();
|
|
65
78
|
if (model.config.recenter) {
|
|
66
79
|
centerDataSet(yAxis);
|
|
67
80
|
} else {
|
|
68
|
-
shiftDataset(yAxis, 1);
|
|
81
|
+
shiftDataset(yAxis, 1, currentConfig.invert);
|
|
69
82
|
}
|
|
70
|
-
addColor(yAxis, ...
|
|
83
|
+
addColor(yAxis, ...currentConfig.color);
|
|
84
|
+
currentConfig = {
|
|
85
|
+
...model.config,
|
|
86
|
+
...model.zConfig
|
|
87
|
+
};
|
|
71
88
|
const zAxis = vtkArrowSource.newInstance({
|
|
72
89
|
direction: [0, 0, 1],
|
|
73
|
-
...
|
|
90
|
+
...currentConfig
|
|
74
91
|
}).getOutputData();
|
|
75
92
|
if (model.config.recenter) {
|
|
76
93
|
centerDataSet(zAxis);
|
|
77
94
|
} else {
|
|
78
|
-
shiftDataset(zAxis, 2);
|
|
95
|
+
shiftDataset(zAxis, 2, currentConfig.invert);
|
|
79
96
|
}
|
|
80
|
-
addColor(zAxis, ...
|
|
97
|
+
addColor(zAxis, ...currentConfig.color);
|
|
81
98
|
const source = vtkAppendPolyData.newInstance();
|
|
82
99
|
source.setInputData(xAxis);
|
|
83
100
|
source.addInputData(yAxis);
|
|
@@ -86,71 +103,68 @@ function vtkAxesActor(publicAPI, model) {
|
|
|
86
103
|
};
|
|
87
104
|
publicAPI.update();
|
|
88
105
|
const _debouncedUpdate = macro.debounce(publicAPI.update, 0);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
publicAPI.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
};
|
|
109
|
-
publicAPI.setYAxisColor = c => {
|
|
110
|
-
if (setYAxisColor(c)) {
|
|
111
|
-
_debouncedUpdate();
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
return false;
|
|
115
|
-
};
|
|
116
|
-
publicAPI.setZAxisColor = c => {
|
|
117
|
-
if (setZAxisColor(c)) {
|
|
118
|
-
_debouncedUpdate();
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
return false;
|
|
122
|
-
};
|
|
106
|
+
publicAPI.setXAxisColor = color => publicAPI.setXConfig({
|
|
107
|
+
...publicAPI.getXConfig(),
|
|
108
|
+
color
|
|
109
|
+
});
|
|
110
|
+
publicAPI.setYAxisColor = color => publicAPI.setYConfig({
|
|
111
|
+
...publicAPI.getYConfig(),
|
|
112
|
+
color
|
|
113
|
+
});
|
|
114
|
+
publicAPI.setZAxisColor = color => publicAPI.setZConfig({
|
|
115
|
+
...publicAPI.getZConfig(),
|
|
116
|
+
color
|
|
117
|
+
});
|
|
118
|
+
publicAPI.getXAxisColor = () => model.getXConfig().color;
|
|
119
|
+
publicAPI.getYAxisColor = () => model.getYConfig().color;
|
|
120
|
+
publicAPI.getZAxisColor = () => model.getZConfig().color;
|
|
121
|
+
model._onConfigChanged = _debouncedUpdate;
|
|
122
|
+
model._onXConfigChanged = _debouncedUpdate;
|
|
123
|
+
model._onYConfigChanged = _debouncedUpdate;
|
|
124
|
+
model._onZConfigChanged = _debouncedUpdate;
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
// ----------------------------------------------------------------------------
|
|
126
128
|
// Object factory
|
|
127
129
|
// ----------------------------------------------------------------------------
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
function defaultValues(initialValues) {
|
|
132
|
+
return {
|
|
133
|
+
config: {
|
|
134
|
+
recenter: true,
|
|
135
|
+
tipResolution: 60,
|
|
136
|
+
tipRadius: 0.1,
|
|
137
|
+
tipLength: 0.2,
|
|
138
|
+
shaftResolution: 60,
|
|
139
|
+
shaftRadius: 0.03,
|
|
140
|
+
invert: false,
|
|
141
|
+
...initialValues?.config
|
|
142
|
+
},
|
|
143
|
+
xConfig: {
|
|
144
|
+
color: [255, 0, 0],
|
|
145
|
+
invert: false,
|
|
146
|
+
...initialValues?.xConfig
|
|
147
|
+
},
|
|
148
|
+
yConfig: {
|
|
149
|
+
color: [255, 255, 0],
|
|
150
|
+
invert: false,
|
|
151
|
+
...initialValues?.yConfig
|
|
152
|
+
},
|
|
153
|
+
zConfig: {
|
|
154
|
+
color: [0, 128, 0],
|
|
155
|
+
invert: false,
|
|
156
|
+
...initialValues?.zConfig
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
143
160
|
|
|
144
161
|
// ----------------------------------------------------------------------------
|
|
145
162
|
|
|
146
163
|
function extend(publicAPI, model) {
|
|
147
164
|
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
148
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
149
|
-
|
|
150
165
|
// Inheritance
|
|
151
|
-
vtkActor.extend(publicAPI, model, initialValues);
|
|
152
|
-
macro.setGet(publicAPI, model, ['config']);
|
|
153
|
-
macro.setGetArray(publicAPI, model, ['xAxisColor', 'yAxisColor', 'zAxisColor'], 3, 255);
|
|
166
|
+
vtkActor.extend(publicAPI, model, defaultValues(initialValues));
|
|
167
|
+
macro.setGet(publicAPI, model, ['config', 'xConfig', 'yConfig', 'zConfig']);
|
|
154
168
|
|
|
155
169
|
// Object methods
|
|
156
170
|
vtkAxesActor(publicAPI, model);
|
|
@@ -167,4 +181,4 @@ var vtkAxesActor$1 = {
|
|
|
167
181
|
extend
|
|
168
182
|
};
|
|
169
183
|
|
|
170
|
-
export {
|
|
184
|
+
export { vtkAxesActor$1 as default, extend, newInstance };
|