@@ -102,7 +102,7 @@ class Texture {
102
102
* @param {string } [options.name] - The name of the texture. Defaults to null.
103
103
* @param {number } [options.width] - The width of the texture in pixels. Defaults to 4.
104
104
* @param {number } [options.height] - The height of the texture in pixels. Defaults to 4.
105
- * @param {number } [options.slices ] - The number of depth slices in a 3D texture, the number of textures
105
+ * @param {number } [options.layers ] - The number of depth layers in a 3D texture, the number of textures
106
106
* in a texture array or the number of faces for a cubemap.
107
107
* @param {string } [options.dimension] - The texture dimension type. Can be:
108
108
* - {@link TEXTUREDIMENSION_2D}
@@ -229,7 +229,7 @@ class Texture {
229
229
Debug . assert ( this . device , "Texture constructor requires a graphicsDevice to be valid" ) ;
230
230
Debug . assert ( ! options . width || Number . isInteger ( options . width ) , "Texture width must be an integer number, got" , options ) ;
231
231
Debug . assert ( ! options . height || Number . isInteger ( options . height ) , "Texture height must be an integer number, got" , options ) ;
232
- Debug . assert ( ! options . slices || Number . isInteger ( options . slices ) , "Texture slices must be an integer number, got" , options ) ;
232
+ Debug . assert ( ! options . layers || Number . isInteger ( options . layers ) , "Texture layers must be an integer number, got" , options ) ;
233
233
234
234
this . name = options . name ?? '' ;
235
235
@@ -241,9 +241,9 @@ class Texture {
241
241
this . _width = Math . floor ( options . width ?? 4 ) ;
242
242
this . _height = Math . floor ( options . height ?? 4 ) ;
243
243
244
- this . _slices = Math . floor ( options . slices ?? ( this . _dimension === TEXTUREDIMENSION_CUBE ? 6 : 1 ) ) ;
244
+ this . _layers = Math . floor ( options . layers ?? ( this . _dimension === TEXTUREDIMENSION_CUBE ? 6 : 1 ) ) ;
245
245
246
- Debug . assert ( ( this . _dimension === TEXTUREDIMENSION_CUBE ? this . _slices === 6 : true ) , "Texture cube map must have 6 slices " ) ;
246
+ Debug . assert ( ( this . _dimension === TEXTUREDIMENSION_CUBE ? this . _layers === 6 : true ) , "Texture cube map must have 6 layers " ) ;
247
247
248
248
this . _format = options . format ?? PIXELFORMAT_RGBA8 ;
249
249
this . _compressed = isCompressedPixelFormat ( this . _format ) ;
@@ -292,7 +292,7 @@ class Texture {
292
292
if ( this . _levels ) {
293
293
this . upload ( options . immediate ?? false ) ;
294
294
} else {
295
- this . _levels = ( this . cubemap || this . array ) ? [ Array ( this . _slices ) . fill ( null ) ] : [ null ] ;
295
+ this . _levels = ( this . cubemap || this . array ) ? [ Array ( this . _layers ) . fill ( null ) ] : [ null ] ;
296
296
}
297
297
298
298
// track the texture
@@ -340,10 +340,10 @@ class Texture {
340
340
*
341
341
* @param {number } width - The new width of the texture.
342
342
* @param {number } height - The new height of the texture.
343
- * @param {number } [slices ] - The new number of slices for the texture. Defaults to 1.
343
+ * @param {number } [layers ] - The new number of layers for the texture. Defaults to 1.
344
344
* @ignore
345
345
*/
346
- resize ( width , height , slices = 1 ) {
346
+ resize ( width , height , layers = 1 ) {
347
347
348
348
// destroy texture impl
349
349
const device = this . device ;
@@ -352,7 +352,7 @@ class Texture {
352
352
353
353
this . _width = Math . floor ( width ) ;
354
354
this . _height = Math . floor ( height ) ;
355
- this . _slices = Math . floor ( slices ) ;
355
+ this . _layers = Math . floor ( layers ) ;
356
356
357
357
// re-create the implementation
358
358
this . impl = device . createTextureImpl ( this ) ;
@@ -689,21 +689,21 @@ class Texture {
689
689
}
690
690
691
691
/**
692
- * The number of depth slices in a 3D texture.
692
+ * The number of depth layers in a 3D texture.
693
693
*
694
694
* @type {number }
695
695
*/
696
696
get depth ( ) {
697
- return this . _dimension === TEXTUREDIMENSION_3D ? this . _slices : 1 ;
697
+ return this . _dimension === TEXTUREDIMENSION_3D ? this . _layers : 1 ;
698
698
}
699
699
700
700
/**
701
701
* The number of textures in a texture array or the number of faces for a cubemap.
702
702
*
703
703
* @type {number }
704
704
*/
705
- get slices ( ) {
706
- return this . _slices ;
705
+ get layers ( ) {
706
+ return this . _layers ;
707
707
}
708
708
709
709
/**
@@ -750,7 +750,7 @@ class Texture {
750
750
751
751
get gpuSize ( ) {
752
752
const mips = this . pot && this . _mipmaps && ! ( this . _compressed && this . _levels . length === 1 ) ;
753
- return TextureUtils . calcGpuSize ( this . _width , this . _height , this . _slices , this . _format , this . volume , mips ) ;
753
+ return TextureUtils . calcGpuSize ( this . _width , this . _height , this . _layers , this . _format , this . volume , mips ) ;
754
754
}
755
755
756
756
/**
@@ -831,7 +831,7 @@ class Texture {
831
831
832
832
// Force a full resubmission of the texture to the GPU (used on a context restore event)
833
833
dirtyAll ( ) {
834
- this . _levelsUpdated = ( this . cubemap || this . array ) ? [ Array ( this . _slices ) . fill ( true ) ] : [ true ] ;
834
+ this . _levelsUpdated = ( this . cubemap || this . array ) ? [ Array ( this . _layers ) . fill ( true ) ] : [ true ] ;
835
835
836
836
this . _needsUpload = true ;
837
837
this . _needsMipmapsUpload = this . _mipmaps ;
@@ -848,8 +848,8 @@ class Texture {
848
848
* to 0.
849
849
* @param {number } [options.face] - If the texture is a cubemap, this is the index of the face
850
850
* to lock.
851
- * @param {number } [options.slice ] - If the texture is a texture array, this is the index of the
852
- * slice to lock.
851
+ * @param {number } [options.layer ] - If the texture is a texture array, this is the index of the
852
+ * layer to lock.
853
853
* @param {number } [options.mode] - The lock mode. Can be:
854
854
* - {@link TEXTURELOCK_READ}
855
855
* - {@link TEXTURELOCK_WRITE}
@@ -861,7 +861,7 @@ class Texture {
861
861
// Initialize options to some sensible defaults
862
862
options . level ??= 0 ;
863
863
options . face ??= 0 ;
864
- options . slice ??= 0 ;
864
+ options . layer ??= 0 ;
865
865
options . mode ??= TEXTURELOCK_WRITE ;
866
866
867
867
Debug . assert (
@@ -890,7 +890,7 @@ class Texture {
890
890
891
891
this . _lockedMode = options . mode ;
892
892
893
- const levels = this . cubemap ? this . _levels [ options . face ] : this . array ? this . _levels [ options . slice ] : this . _levels ;
893
+ const levels = this . cubemap ? this . _levels [ options . face ] : this . array ? this . _levels [ options . layer ] : this . _levels ;
894
894
if ( levels [ options . level ] === null ) {
895
895
// allocate storage for this mip level
896
896
const width = Math . max ( 1 , this . _width >> options . level ) ;
@@ -902,7 +902,7 @@ class Texture {
902
902
903
903
if ( this . _lockedMode === TEXTURELOCK_WRITE ) {
904
904
if ( this . cubemap || this . array ) {
905
- this . _levelsUpdated [ 0 ] [ options . face ?? options . slice ] = true ;
905
+ this . _levelsUpdated [ 0 ] [ options . face ?? options . layer ] = true ;
906
906
} else {
907
907
this . _levelsUpdated [ 0 ] = true ;
908
908
}
@@ -931,7 +931,7 @@ class Texture {
931
931
width = source [ 0 ] . width || 0 ;
932
932
height = source [ 0 ] . height || 0 ;
933
933
934
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
934
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
935
935
const face = source [ i ] ;
936
936
// cubemap becomes invalid if any condition is not satisfied
937
937
if ( ! face || // face is missing
@@ -949,7 +949,7 @@ class Texture {
949
949
950
950
if ( ! invalid ) {
951
951
// mark levels as updated
952
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
952
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
953
953
if ( this . _levels [ 0 ] [ i ] !== source [ i ] )
954
954
this . _levelsUpdated [ 0 ] [ i ] = true ;
955
955
}
@@ -978,7 +978,7 @@ class Texture {
978
978
979
979
// remove levels
980
980
if ( this . cubemap || this . array ) {
981
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
981
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
982
982
this . _levels [ 0 ] [ i ] = null ;
983
983
this . _levelsUpdated [ 0 ] [ i ] = true ;
984
984
}
0 commit comments