File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed
Sources/Rendering/OpenGL/Texture Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -610,11 +610,11 @@ function vtkOpenGLTexture(publicAPI, model) {
610
610
) {
611
611
for ( let idx = 0 ; idx < data . length ; idx ++ ) {
612
612
if ( data [ idx ] ) {
613
- const newArray = new Float32Array ( pixCount ) ;
614
- for ( let i = 0 ; i < pixCount ; i ++ ) {
615
- newArray [ i ] = data [ idx ] [ i ] ;
616
- }
617
- pixData . push ( newArray ) ;
613
+ const dataArrayToCopy =
614
+ data [ idx ] . length > pixCount
615
+ ? data [ idx ] . subarray ( 0 , pixCount )
616
+ : data [ idx ] ;
617
+ pixData . push ( new Float32Array ( dataArrayToCopy ) ) ;
618
618
} else {
619
619
pixData . push ( null ) ;
620
620
}
@@ -629,11 +629,11 @@ function vtkOpenGLTexture(publicAPI, model) {
629
629
) {
630
630
for ( let idx = 0 ; idx < data . length ; idx ++ ) {
631
631
if ( data [ idx ] ) {
632
- const newArray = new Uint8Array ( pixCount ) ;
633
- for ( let i = 0 ; i < pixCount ; i ++ ) {
634
- newArray [ i ] = data [ idx ] [ i ] ;
635
- }
636
- pixData . push ( newArray ) ;
632
+ const dataArrayToCopy =
633
+ data [ idx ] . length > pixCount
634
+ ? data [ idx ] . subarray ( 0 , pixCount )
635
+ : data [ idx ] ;
636
+ pixData . push ( new Uint8Array ( dataArrayToCopy ) ) ;
637
637
} else {
638
638
pixData . push ( null ) ;
639
639
}
You can’t perform that action at this time.
0 commit comments