|
1 | 1 | import { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, FloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping, NeverCompare, AlwaysCompare, LessCompare, LessEqualCompare, EqualCompare, GreaterEqualCompare, GreaterCompare, NotEqualCompare, NoColorSpace, LinearTransfer, SRGBTransfer } from '../../../constants.js'; |
2 | 2 | import { ColorManagement } from '../../../math/ColorManagement.js'; |
| 3 | +import { getByteLength } from '../../../extras/TextureUtils.js'; |
3 | 4 |
|
4 | 5 | let initialized = false, wrappingToGL, filterToGL, compareToGL; |
5 | 6 |
|
@@ -564,7 +565,27 @@ class WebGLTextureUtils { |
564 | 565 |
|
565 | 566 | const image = options.image; |
566 | 567 |
|
567 | | - gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); |
| 568 | + if ( texture.layerUpdates.size > 0 ) { |
| 569 | + |
| 570 | + const layerByteLength = getByteLength( image.width, image.height, texture.format, texture.type ); |
| 571 | + |
| 572 | + for ( const layerIndex of texture.layerUpdates ) { |
| 573 | + |
| 574 | + const layerData = image.data.subarray( |
| 575 | + layerIndex * layerByteLength / image.data.BYTES_PER_ELEMENT, |
| 576 | + ( layerIndex + 1 ) * layerByteLength / image.data.BYTES_PER_ELEMENT |
| 577 | + ); |
| 578 | + gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, layerIndex, image.width, image.height, 1, glFormat, glType, layerData ); |
| 579 | + |
| 580 | + } |
| 581 | + |
| 582 | + texture.clearLayerUpdates(); |
| 583 | + |
| 584 | + } else { |
| 585 | + |
| 586 | + gl.texSubImage3D( gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data ); |
| 587 | + |
| 588 | + } |
568 | 589 |
|
569 | 590 | } else if ( texture.isData3DTexture ) { |
570 | 591 |
|
|
0 commit comments