@@ -7,7 +7,10 @@ import vtkHardwareSelector from 'vtk.js/Sources/Rendering/OpenGL/HardwareSelecto
77import vtkProperty from 'vtk.js/Sources/Rendering/Core/Property' ;
88import vtkOpenGLPolyDataMapper from 'vtk.js/Sources/Rendering/OpenGL/PolyDataMapper' ;
99import vtkShaderProgram from 'vtk.js/Sources/Rendering/OpenGL/ShaderProgram' ;
10- import { computeCoordShiftAndScale } from 'vtk.js/Sources/Rendering/OpenGL/CellArrayBufferObject/helpers' ;
10+ import {
11+ computeCoordShiftAndScale ,
12+ computeInverseShiftAndScaleMatrix ,
13+ } from 'vtk.js/Sources/Rendering/OpenGL/CellArrayBufferObject/helpers' ;
1114
1215import { registerOverride } from 'vtk.js/Sources/Rendering/OpenGL/ViewNodeFactory' ;
1316import { primTypes } from '../Helper' ;
@@ -23,16 +26,6 @@ const EndEvent = { type: 'EndEvent' };
2326const MAT4_BYTE_SIZE = 64 ;
2427const MAT4_ELEMENT_COUNT = 16 ;
2528
26- function applyShiftScaleToMat ( mat , shift , scale ) {
27- // the translation component of a 4x4 column-major matrix
28- mat [ 12 ] = ( mat [ 12 ] - shift [ 0 ] ) * scale [ 0 ] ;
29- mat [ 13 ] = ( mat [ 13 ] - shift [ 1 ] ) * scale [ 1 ] ;
30- mat [ 14 ] = ( mat [ 14 ] - shift [ 2 ] ) * scale [ 2 ] ;
31- mat [ 0 ] *= scale [ 0 ] ;
32- mat [ 5 ] *= scale [ 1 ] ;
33- mat [ 10 ] *= scale [ 2 ] ;
34- }
35-
3629// ----------------------------------------------------------------------------
3730// vtkOpenGLSphereMapper methods
3831// ----------------------------------------------------------------------------
@@ -714,13 +707,18 @@ function vtkOpenGLGlyph3DMapper(publicAPI, model) {
714707
715708 if ( useShiftAndScale ) {
716709 const buf = garray . buffer ;
710+ const shiftScaleMat = computeInverseShiftAndScaleMatrix (
711+ coordShift ,
712+ coordScale
713+ ) ;
714+ mat4 . invert ( shiftScaleMat , shiftScaleMat ) ;
717715 for (
718716 let ptIdx = 0 ;
719717 ptIdx < garray . byteLength ;
720718 ptIdx += MAT4_BYTE_SIZE
721719 ) {
722720 const mat = new Float32Array ( buf , ptIdx , MAT4_ELEMENT_COUNT ) ;
723- applyShiftScaleToMat ( mat , coordShift , coordScale ) ;
721+ mat4 . multiply ( mat , shiftScaleMat , mat ) ;
724722 }
725723 }
726724
0 commit comments