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