@kitware/vtk.js 34.16.1 → 34.16.2

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.
@@ -1,3 +1,5 @@
1
+ import { vec3, mat4, quat } from 'gl-matrix';
2
+
1
3
  function computeCoordShiftAndScale(points) {
2
4
  // Find out if shift scale should be used
3
5
  // Compute squares of diagonal size and distance from the origin
@@ -38,8 +40,16 @@ function computeCoordShiftAndScale(points) {
38
40
  coordScale: new Float32Array([1, 1, 1])
39
41
  };
40
42
  }
43
+ function computeInverseShiftAndScaleMatrix(coordShift, coordScale) {
44
+ const inverseScale = new Float64Array(3);
45
+ vec3.inverse(inverseScale, coordScale);
46
+ const matrix = new Float64Array(16);
47
+ mat4.fromRotationTranslationScale(matrix, quat.create(), coordShift, inverseScale);
48
+ return matrix;
49
+ }
41
50
  var helpers = {
42
- computeCoordShiftAndScale
51
+ computeCoordShiftAndScale,
52
+ computeInverseShiftAndScaleMatrix
43
53
  };
44
54
 
45
- export { computeCoordShiftAndScale, helpers as default };
55
+ export { computeCoordShiftAndScale, computeInverseShiftAndScaleMatrix, helpers as default };
@@ -1,9 +1,9 @@
1
- import { vec3, mat4, quat } from 'gl-matrix';
1
+ import { vec3 } from 'gl-matrix';
2
2
  import { m as macro } from '../../macros2.js';
3
3
  import vtkBufferObject from './BufferObject.js';
4
4
  import { ObjectType } from './BufferObject/Constants.js';
5
5
  import { Representation } from '../Core/Property/Constants.js';
6
- import { computeCoordShiftAndScale } from './CellArrayBufferObject/helpers.js';
6
+ import { computeCoordShiftAndScale, computeInverseShiftAndScaleMatrix } from './CellArrayBufferObject/helpers.js';
7
7
 
8
8
  const {
9
9
  vtkErrorMacro
@@ -13,13 +13,6 @@ const {
13
13
  // Static functions
14
14
  // ----------------------------------------------------------------------------
15
15
 
16
- function computeInverseShiftAndScaleMatrix(coordShift, coordScale) {
17
- const inverseScale = new Float64Array(3);
18
- vec3.inverse(inverseScale, coordScale);
19
- const matrix = new Float64Array(16);
20
- mat4.fromRotationTranslationScale(matrix, quat.create(), coordShift, inverseScale);
21
- return matrix;
22
- }
23
16
  function shouldApplyCoordShiftAndScale(coordShift, coordScale) {
24
17
  if (coordShift === null || coordScale === null) {
25
18
  return false;
@@ -5,7 +5,7 @@ import vtkHardwareSelector from './HardwareSelector.js';
5
5
  import vtkProperty from '../Core/Property.js';
6
6
  import vtkOpenGLPolyDataMapper from './PolyDataMapper.js';
7
7
  import vtkShaderProgram from './ShaderProgram.js';
8
- import { computeCoordShiftAndScale } from './CellArrayBufferObject/helpers.js';
8
+ import { computeCoordShiftAndScale, computeInverseShiftAndScaleMatrix } from './CellArrayBufferObject/helpers.js';
9
9
  import { registerOverride } from './ViewNodeFactory.js';
10
10
  import { primTypes } from './Helper.js';
11
11
 
@@ -29,15 +29,6 @@ const EndEvent = {
29
29
  };
30
30
  const MAT4_BYTE_SIZE = 64;
31
31
  const MAT4_ELEMENT_COUNT = 16;
32
- function applyShiftScaleToMat(mat, shift, scale) {
33
- // the translation component of a 4x4 column-major matrix
34
- mat[12] = (mat[12] - shift[0]) * scale[0];
35
- mat[13] = (mat[13] - shift[1]) * scale[1];
36
- mat[14] = (mat[14] - shift[2]) * scale[2];
37
- mat[0] *= scale[0];
38
- mat[5] *= scale[1];
39
- mat[10] *= scale[2];
40
- }
41
32
 
42
33
  // ----------------------------------------------------------------------------
43
34
  // vtkOpenGLSphereMapper methods
@@ -441,9 +432,11 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
441
432
  }
442
433
  if (useShiftAndScale) {
443
434
  const buf = garray.buffer;
435
+ const shiftScaleMat = computeInverseShiftAndScaleMatrix(coordShift, coordScale);
436
+ mat4.invert(shiftScaleMat, shiftScaleMat);
444
437
  for (let ptIdx = 0; ptIdx < garray.byteLength; ptIdx += MAT4_BYTE_SIZE) {
445
438
  const mat = new Float32Array(buf, ptIdx, MAT4_ELEMENT_COUNT);
446
- applyShiftScaleToMat(mat, coordShift, coordScale);
439
+ mat4.multiply(mat, shiftScaleMat, mat);
447
440
  }
448
441
  }
449
442
  if (model.renderable.getBuildTime().getMTime() > model.glyphBOBuildTime.getMTime()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "34.16.1",
3
+ "version": "34.16.2",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",