@@ -94,7 +94,7 @@ class Texture {
94
94
* @param {string } [options.name] - The name of the texture. Defaults to null.
95
95
* @param {number } [options.width] - The width of the texture in pixels. Defaults to 4.
96
96
* @param {number } [options.height] - The height of the texture in pixels. Defaults to 4.
97
- * @param {number } [options.slices ] - The number of depth slices in a 3D texture, the number of textures
97
+ * @param {number } [options.layers ] - The number of depth layers in a 3D texture, the number of textures
98
98
* in a texture array or the number of faces for a cubemap.
99
99
* @param {string } [options.dimension] - The texture dimension type. Can be:
100
100
* - {@link TEXTUREDIMENSION_2D}
@@ -221,7 +221,7 @@ class Texture {
221
221
Debug . assert ( this . device , "Texture constructor requires a graphicsDevice to be valid" ) ;
222
222
Debug . assert ( ! options . width || Number . isInteger ( options . width ) , "Texture width must be an integer number, got" , options ) ;
223
223
Debug . assert ( ! options . height || Number . isInteger ( options . height ) , "Texture height must be an integer number, got" , options ) ;
224
- Debug . assert ( ! options . slices || Number . isInteger ( options . slices ) , "Texture slices must be an integer number, got" , options ) ;
224
+ Debug . assert ( ! options . layers || Number . isInteger ( options . layers ) , "Texture layers must be an integer number, got" , options ) ;
225
225
226
226
this . name = options . name ?? '' ;
227
227
@@ -233,9 +233,9 @@ class Texture {
233
233
this . _width = Math . floor ( options . width ?? 4 ) ;
234
234
this . _height = Math . floor ( options . height ?? 4 ) ;
235
235
236
- this . _slices = Math . floor ( options . slices ?? ( this . _dimension === TEXTUREDIMENSION_CUBE ? 6 : 1 ) ) ;
236
+ this . _layers = Math . floor ( options . layers ?? ( this . _dimension === TEXTUREDIMENSION_CUBE ? 6 : 1 ) ) ;
237
237
238
- Debug . assert ( ( this . _dimension === TEXTUREDIMENSION_CUBE ? this . _slices === 6 : true ) , "Texture cube map must have 6 slices " ) ;
238
+ Debug . assert ( ( this . _dimension === TEXTUREDIMENSION_CUBE ? this . _layers === 6 : true ) , "Texture cube map must have 6 layers " ) ;
239
239
240
240
this . _format = options . format ?? PIXELFORMAT_RGBA8 ;
241
241
this . _compressed = isCompressedPixelFormat ( this . _format ) ;
@@ -284,7 +284,7 @@ class Texture {
284
284
if ( this . _levels ) {
285
285
this . upload ( options . immediate ?? false ) ;
286
286
} else {
287
- this . _levels = ( this . cubemap || this . array ) ? [ Array ( this . _slices ) . fill ( null ) ] : [ null ] ;
287
+ this . _levels = ( this . cubemap || this . array ) ? [ Array ( this . _layers ) . fill ( null ) ] : [ null ] ;
288
288
}
289
289
290
290
// track the texture
@@ -332,10 +332,10 @@ class Texture {
332
332
*
333
333
* @param {number } width - The new width of the texture.
334
334
* @param {number } height - The new height of the texture.
335
- * @param {number } [slices ] - The new number of slices for the texture. Defaults to 1.
335
+ * @param {number } [layers ] - The new number of layers for the texture. Defaults to 1.
336
336
* @ignore
337
337
*/
338
- resize ( width , height , slices = 1 ) {
338
+ resize ( width , height , layers = 1 ) {
339
339
340
340
// destroy texture impl
341
341
const device = this . device ;
@@ -344,7 +344,7 @@ class Texture {
344
344
345
345
this . _width = Math . floor ( width ) ;
346
346
this . _height = Math . floor ( height ) ;
347
- this . _slices = Math . floor ( slices ) ;
347
+ this . _layers = Math . floor ( layers ) ;
348
348
349
349
// re-create the implementation
350
350
this . impl = device . createTextureImpl ( this ) ;
@@ -681,21 +681,21 @@ class Texture {
681
681
}
682
682
683
683
/**
684
- * The number of depth slices in a 3D texture.
684
+ * The number of depth layers in a 3D texture.
685
685
*
686
686
* @type {number }
687
687
*/
688
688
get depth ( ) {
689
- return this . _dimension === TEXTUREDIMENSION_3D ? this . _slices : 1 ;
689
+ return this . _dimension === TEXTUREDIMENSION_3D ? this . _layers : 1 ;
690
690
}
691
691
692
692
/**
693
693
* The number of textures in a texture array or the number of faces for a cubemap.
694
694
*
695
695
* @type {number }
696
696
*/
697
- get slices ( ) {
698
- return this . _slices ;
697
+ get layers ( ) {
698
+ return this . _layers ;
699
699
}
700
700
701
701
/**
@@ -742,7 +742,7 @@ class Texture {
742
742
743
743
get gpuSize ( ) {
744
744
const mips = this . pot && this . _mipmaps && ! ( this . _compressed && this . _levels . length === 1 ) ;
745
- return TextureUtils . calcGpuSize ( this . _width , this . _height , this . _slices , this . _format , this . volume , mips ) ;
745
+ return TextureUtils . calcGpuSize ( this . _width , this . _height , this . _layers , this . _format , this . volume , mips ) ;
746
746
}
747
747
748
748
/**
@@ -823,7 +823,7 @@ class Texture {
823
823
824
824
// Force a full resubmission of the texture to the GPU (used on a context restore event)
825
825
dirtyAll ( ) {
826
- this . _levelsUpdated = ( this . cubemap || this . array ) ? [ Array ( this . _slices ) . fill ( true ) ] : [ true ] ;
826
+ this . _levelsUpdated = ( this . cubemap || this . array ) ? [ Array ( this . _layers ) . fill ( true ) ] : [ true ] ;
827
827
828
828
this . _needsUpload = true ;
829
829
this . _needsMipmapsUpload = this . _mipmaps ;
@@ -840,8 +840,8 @@ class Texture {
840
840
* to 0.
841
841
* @param {number } [options.face] - If the texture is a cubemap, this is the index of the face
842
842
* to lock.
843
- * @param {number } [options.slice ] - If the texture is a texture array, this is the index of the
844
- * slice to lock.
843
+ * @param {number } [options.layer ] - If the texture is a texture array, this is the index of the
844
+ * layer to lock.
845
845
* @param {number } [options.mode] - The lock mode. Can be:
846
846
* - {@link TEXTURELOCK_READ}
847
847
* - {@link TEXTURELOCK_WRITE}
@@ -853,7 +853,7 @@ class Texture {
853
853
// Initialize options to some sensible defaults
854
854
options . level ??= 0 ;
855
855
options . face ??= 0 ;
856
- options . slice ??= 0 ;
856
+ options . layer ??= 0 ;
857
857
options . mode ??= TEXTURELOCK_WRITE ;
858
858
859
859
Debug . assert (
@@ -882,7 +882,7 @@ class Texture {
882
882
883
883
this . _lockedMode = options . mode ;
884
884
885
- const levels = this . cubemap ? this . _levels [ options . face ] : this . array ? this . _levels [ options . slice ] : this . _levels ;
885
+ const levels = this . cubemap ? this . _levels [ options . face ] : this . array ? this . _levels [ options . layer ] : this . _levels ;
886
886
if ( levels [ options . level ] === null ) {
887
887
// allocate storage for this mip level
888
888
const width = Math . max ( 1 , this . _width >> options . level ) ;
@@ -894,7 +894,7 @@ class Texture {
894
894
895
895
if ( this . _lockedMode === TEXTURELOCK_WRITE ) {
896
896
if ( this . cubemap || this . array ) {
897
- this . _levelsUpdated [ 0 ] [ options . face ?? options . slice ] = true ;
897
+ this . _levelsUpdated [ 0 ] [ options . face ?? options . layer ] = true ;
898
898
} else {
899
899
this . _levelsUpdated [ 0 ] = true ;
900
900
}
@@ -923,7 +923,7 @@ class Texture {
923
923
width = source [ 0 ] . width || 0 ;
924
924
height = source [ 0 ] . height || 0 ;
925
925
926
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
926
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
927
927
const face = source [ i ] ;
928
928
// cubemap becomes invalid if any condition is not satisfied
929
929
if ( ! face || // face is missing
@@ -941,7 +941,7 @@ class Texture {
941
941
942
942
if ( ! invalid ) {
943
943
// mark levels as updated
944
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
944
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
945
945
if ( this . _levels [ 0 ] [ i ] !== source [ i ] )
946
946
this . _levelsUpdated [ 0 ] [ i ] = true ;
947
947
}
@@ -971,7 +971,7 @@ class Texture {
971
971
972
972
// remove levels
973
973
if ( this . cubemap || this . array ) {
974
- for ( let i = 0 ; i < this . _slices ; i ++ ) {
974
+ for ( let i = 0 ; i < this . _layers ; i ++ ) {
975
975
this . _levels [ 0 ] [ i ] = null ;
976
976
this . _levelsUpdated [ 0 ] [ i ] = true ;
977
977
}
0 commit comments