@kitware/vtk.js 34.17.0 → 35.0.0

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.
@@ -128,24 +128,20 @@ function vtkProp3D(publicAPI, model) {
128
128
  model.matrixMTime.modified();
129
129
  }
130
130
  };
131
- publicAPI.getBoundsByReference = () => {
131
+ publicAPI.computeBounds = () => {
132
132
  if (model.mapper === null) {
133
- return model.bounds;
133
+ vtkBoundingBox.reset(model.bounds);
134
+ return;
134
135
  }
135
136
 
136
- // Check for the special case when the mapper's bounds are unknown
137
+ // Check for the special case when the mapper's bounds are invalid
137
138
  const bds = model.mapper.getBounds();
138
- if (!bds || bds.length !== 6) {
139
- return bds;
140
- }
141
-
142
- // Check for the special case when the actor is empty.
143
- if (bds[0] > bds[1]) {
139
+ if (!bds || bds.length !== 6 || !vtkBoundingBox.isValid(bds)) {
144
140
  // No need to copy bds, a new array is created when calling getBounds()
145
141
  model.mapperBounds = bds;
146
- model.bounds = [...vtkBoundingBox.INIT_BOUNDS];
142
+ vtkBoundingBox.reset(model.bounds);
147
143
  model.boundsMTime.modified();
148
- return bds;
144
+ return;
149
145
  }
150
146
 
151
147
  // Check if we have cached values for these bounds - we cache the
@@ -165,22 +161,22 @@ function vtkProp3D(publicAPI, model) {
165
161
  vtkBoundingBox.transformBounds(bds, transposedMatrix, model.bounds);
166
162
  model.boundsMTime.modified();
167
163
  }
168
- return model.bounds;
169
164
  };
165
+ const superGetBounds = publicAPI.getBounds;
170
166
  publicAPI.getBounds = () => {
171
- const bounds = publicAPI.getBoundsByReference();
172
- // Handle case when bounds are not iterable (for example null or undefined)
173
- try {
174
- return [...bounds];
175
- } catch {
176
- return bounds;
177
- }
167
+ publicAPI.computeBounds();
168
+ return superGetBounds();
169
+ };
170
+ const superGetBoundsByReference = publicAPI.getBoundsByReference;
171
+ publicAPI.getBoundsByReference = () => {
172
+ publicAPI.computeBounds();
173
+ return superGetBoundsByReference();
178
174
  };
179
- publicAPI.getCenter = () => vtkBoundingBox.getCenter(model.bounds);
180
- publicAPI.getLength = () => vtkBoundingBox.getLength(model.bounds);
181
- publicAPI.getXRange = () => vtkBoundingBox.getXRange(model.bounds);
182
- publicAPI.getYRange = () => vtkBoundingBox.getYRange(model.bounds);
183
- publicAPI.getZRange = () => vtkBoundingBox.getZRange(model.bounds);
175
+ publicAPI.getCenter = () => vtkBoundingBox.getCenter(publicAPI.getBoundsByReference());
176
+ publicAPI.getLength = () => vtkBoundingBox.getLength(publicAPI.getBoundsByReference());
177
+ publicAPI.getXRange = () => vtkBoundingBox.getXRange(publicAPI.getBoundsByReference());
178
+ publicAPI.getYRange = () => vtkBoundingBox.getYRange(publicAPI.getBoundsByReference());
179
+ publicAPI.getZRange = () => vtkBoundingBox.getZRange(publicAPI.getBoundsByReference());
184
180
  publicAPI.getUserMatrix = () => model.userMatrix;
185
181
  function updateIdentityFlag() {
186
182
  publicAPI.computeMatrix();
@@ -227,12 +223,12 @@ function vtkProp3D(publicAPI, model) {
227
223
  // ----------------------------------------------------------------------------
228
224
 
229
225
  const DEFAULT_VALUES = {
226
+ bounds: [...vtkBoundingBox.INIT_BOUNDS],
230
227
  origin: [0, 0, 0],
231
228
  position: [0, 0, 0],
232
229
  orientation: [0, 0, 0],
233
230
  rotation: null,
234
231
  scale: [1, 1, 1],
235
- bounds: [...vtkBoundingBox.INIT_BOUNDS],
236
232
  properties: [],
237
233
  userMatrix: null,
238
234
  userMatrixMTime: null,
@@ -256,6 +252,7 @@ function extend(publicAPI, model, initialValues = {}) {
256
252
  macro.getArray(publicAPI, model, ['orientation']);
257
253
  macro.setGetArray(publicAPI, model, ['origin', 'position', 'scale'], 3);
258
254
  macro.setGet(publicAPI, model, ['properties']);
255
+ macro.getArray(publicAPI, model, ['bounds'], 6);
259
256
 
260
257
  // Object internal instance
261
258
  model.matrix = mat4.identity(new Float64Array(16));
@@ -40,12 +40,16 @@ function vtkVolumeMapper(publicAPI, model) {
40
40
  const superClass = {
41
41
  ...publicAPI
42
42
  };
43
- publicAPI.getBounds = () => {
43
+ publicAPI.computeBounds = () => {
44
+ const input = publicAPI.getInputData();
45
+ if (!input) {
46
+ vtkBoundingBox.reset(model.bounds);
47
+ return;
48
+ }
44
49
  if (!model.static) {
45
50
  publicAPI.update();
46
51
  }
47
- model.bounds = [...publicAPI.getInputData().getBounds()];
48
- return model.bounds;
52
+ vtkBoundingBox.setBounds(model.bounds, input.getBounds());
49
53
  };
50
54
  publicAPI.setBlendModeToComposite = () => {
51
55
  publicAPI.setBlendMode(BlendMode.COMPOSITE_BLEND);