|
1 | 1 | import macro from 'vtk.js/Sources/macros';
|
2 | 2 | import vtkCellArray from 'vtk.js/Sources/Common/Core/CellArray';
|
3 | 3 | import vtkDataArray from 'vtk.js/Sources/Common/Core/DataArray';
|
4 |
| -import { IDENTITY } from 'vtk.js/Sources/Common/Core/Math/Constants'; |
5 | 4 | import vtkPolyData from 'vtk.js/Sources/Common/DataModel/PolyData';
|
6 | 5 | import vtkMatrixBuilder from 'vtk.js/Sources/Common/Core/MatrixBuilder';
|
7 | 6 |
|
@@ -204,31 +203,37 @@ function vtkCubeSource(publicAPI, model) {
|
204 | 203 | }
|
205 | 204 |
|
206 | 205 | // 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 | + } |
214 | 215 |
|
215 | 216 | // 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 | + } |
220 | 223 |
|
221 | 224 | // 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 | + } |
232 | 237 |
|
233 | 238 | // Lastly, generate the necessary cell arrays.
|
234 | 239 | if (model.generateFaces) {
|
@@ -283,9 +288,6 @@ const DEFAULT_VALUES = {
|
283 | 288 | xLength: 1.0,
|
284 | 289 | yLength: 1.0,
|
285 | 290 | zLength: 1.0,
|
286 |
| - center: [0.0, 0.0, 0.0], |
287 |
| - rotations: [0.0, 0.0, 0.0], |
288 |
| - matrix: [...IDENTITY], |
289 | 291 | pointType: 'Float64Array',
|
290 | 292 | generate3DTextureCoordinates: false,
|
291 | 293 | generateFaces: true,
|
|
0 commit comments