Skip to content

Commit 3d085e6

Browse files
committed
fix(CubeSource): apply transforms only if corresponding properties are set
1 parent d1514dc commit 3d085e6

File tree

2 files changed

+32
-33
lines changed

2 files changed

+32
-33
lines changed

Sources/Filters/General/ImageDataOutlineFilter/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ function vtkImageDataOutlineFilter(publicAPI, model) {
1111
// Set our className
1212
model.classHierarchy.push('vtkImageDataOutlineFilter');
1313

14+
// Capture "parentClass" api for internal use
15+
const superClass = { ...publicAPI };
16+
1417
publicAPI.requestData = (inData, outData) => {
1518
// implement requestData
1619
const input = inData[0];
@@ -36,14 +39,8 @@ function vtkImageDataOutlineFilter(publicAPI, model) {
3639
outData[0] = model._cubeSource.getOutputData();
3740
};
3841

39-
// Capture "parentClass" api for internal use
40-
const superClass = { ...publicAPI };
41-
42-
publicAPI.getMTime = () => {
43-
let mTime = superClass.getMTime();
44-
mTime = Math.max(mTime, model._cubeSource.getMTime());
45-
return mTime;
46-
};
42+
publicAPI.getMTime = () =>
43+
Math.max(superClass.getMTime(), model._cubeSource.getMTime());
4744

4845
// Forward calls for [set/get]Generate[Faces/Lines] functions to cubeSource:
4946
publicAPI.setGenerateFaces = model._cubeSource.setGenerateFaces;

Sources/Filters/Sources/CubeSource/index.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import macro from 'vtk.js/Sources/macros';
22
import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray';
33
import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
4-
import { IDENTITY } from 'vtk.js/Sources/Common/Core/Math/Constants';
54
import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData';
65
import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
76

@@ -204,31 +203,37 @@ function vtkCubeSource(publicAPI, model) {
204203
}
205204

206205
// Apply rotation to the points coordinates and normals
207-
vtkMatrixBuilder
208-
.buildFromDegree()
209-
.rotateX(model.rotations[0])
210-
.rotateY(model.rotations[1])
211-
.rotateZ(model.rotations[2])
212-
.apply(points)
213-
.apply(normals);
206+
if (model.rotations) {
207+
vtkMatrixBuilder
208+
.buildFromDegree()
209+
.rotateX(model.rotations[0])
210+
.rotateY(model.rotations[1])
211+
.rotateZ(model.rotations[2])
212+
.apply(points)
213+
.apply(normals);
214+
}
214215

215216
// Apply transformation to the points coordinates
216-
vtkMatrixBuilder
217-
.buildFromRadian()
218-
.translate(...model.center)
219-
.apply(points);
217+
if (model.center) {
218+
vtkMatrixBuilder
219+
.buildFromRadian()
220+
.translate(...model.center)
221+
.apply(points);
222+
}
220223

221224
// Apply optional additionally specified matrix transformation
222-
vtkMatrixBuilder.buildFromRadian().setMatrix(model.matrix).apply(points);
223-
224-
// prettier-ignore
225-
const rotMatrix = [
226-
model.matrix[0], model.matrix[1], model.matrix[2], 0,
227-
model.matrix[4], model.matrix[5], model.matrix[6], 0,
228-
model.matrix[8], model.matrix[9], model.matrix[10], 0,
229-
0, 0, 0, 1
230-
];
231-
vtkMatrixBuilder.buildFromRadian().setMatrix(rotMatrix).apply(normals);
225+
if (model.matrix) {
226+
vtkMatrixBuilder.buildFromRadian().setMatrix(model.matrix).apply(points);
227+
228+
// prettier-ignore
229+
const rotMatrix = [
230+
model.matrix[0], model.matrix[1], model.matrix[2], 0,
231+
model.matrix[4], model.matrix[5], model.matrix[6], 0,
232+
model.matrix[8], model.matrix[9], model.matrix[10], 0,
233+
0, 0, 0, 1
234+
];
235+
vtkMatrixBuilder.buildFromRadian().setMatrix(rotMatrix).apply(normals);
236+
}
232237

233238
// Lastly, generate the necessary cell arrays.
234239
if (model.generateFaces) {
@@ -283,9 +288,6 @@ const DEFAULT_VALUES = {
283288
xLength: 1.0,
284289
yLength: 1.0,
285290
zLength: 1.0,
286-
center: [0.0, 0.0, 0.0],
287-
rotations: [0.0, 0.0, 0.0],
288-
matrix: [...IDENTITY],
289291
pointType: 'Float64Array',
290292
generate3DTextureCoordinates: false,
291293
generateFaces: true,

0 commit comments

Comments
 (0)