1
1
define ( [
2
- '../Core/Check' ,
3
- '../Core/defaultValue' ,
4
- '../Core/defined' ,
5
- '../Core/defineProperties' ,
6
- '../Core/destroyObject' ,
7
- '../Core/DeveloperError' ,
8
- '../Core/Math' ,
9
- '../Core/PixelFormat' ,
10
- './ContextLimits' ,
11
- './CubeMapFace' ,
12
- './MipmapHint' ,
13
- './PixelDatatype' ,
14
- './Sampler' ,
15
- './TextureMagnificationFilter' ,
16
- './TextureMinificationFilter'
17
- ] , function (
18
- Check ,
19
- defaultValue ,
20
- defined ,
21
- defineProperties ,
22
- destroyObject ,
23
- DeveloperError ,
24
- CesiumMath ,
25
- PixelFormat ,
26
- ContextLimits ,
27
- CubeMapFace ,
28
- MipmapHint ,
29
- PixelDatatype ,
30
- Sampler ,
31
- TextureMagnificationFilter ,
32
- TextureMinificationFilter ) {
2
+ '../Core/Check' ,
3
+ '../Core/defaultValue' ,
4
+ '../Core/defined' ,
5
+ '../Core/defineProperties' ,
6
+ '../Core/destroyObject' ,
7
+ '../Core/DeveloperError' ,
8
+ '../Core/Math' ,
9
+ '../Core/PixelFormat' ,
10
+ './ContextLimits' ,
11
+ './CubeMapFace' ,
12
+ './MipmapHint' ,
13
+ './PixelDatatype' ,
14
+ './Sampler' ,
15
+ './TextureMagnificationFilter' ,
16
+ './TextureMinificationFilter'
17
+ ] , function (
18
+ Check ,
19
+ defaultValue ,
20
+ defined ,
21
+ defineProperties ,
22
+ destroyObject ,
23
+ DeveloperError ,
24
+ CesiumMath ,
25
+ PixelFormat ,
26
+ ContextLimits ,
27
+ CubeMapFace ,
28
+ MipmapHint ,
29
+ PixelDatatype ,
30
+ Sampler ,
31
+ TextureMagnificationFilter ,
32
+ TextureMinificationFilter ) {
33
33
'use strict' ;
34
34
35
35
function CubeMap ( options ) {
36
+
36
37
options = defaultValue ( options , defaultValue . EMPTY_OBJECT ) ;
37
38
38
39
//>>includeStart('debug', pragmas.debug);
@@ -120,29 +121,25 @@ define([
120
121
gl . activeTexture ( gl . TEXTURE0 ) ;
121
122
gl . bindTexture ( textureTarget , texture ) ;
122
123
123
- function createFace ( target , sourceFace , preMultiplyAlpha , flipY ) {
124
- // TODO: gl.pixelStorei(gl._UNPACK_ALIGNMENT, 4);
124
+ function createFace ( target , sourceFace ) {
125
125
if ( sourceFace . arrayBufferView ) {
126
- gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , false ) ;
127
- gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , false ) ;
128
126
gl . texImage2D ( target , 0 , pixelFormat , size , size , 0 , pixelFormat , pixelDatatype , sourceFace . arrayBufferView ) ;
129
127
} else {
130
- // Only valid for DOM-Element uploads
131
- gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , preMultiplyAlpha ) ;
132
- gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , flipY ) ;
133
-
134
- // Source: ImageData, HTMLImageElement, HTMLCanvasElement, or HTMLVideoElement
135
128
gl . texImage2D ( target , 0 , pixelFormat , pixelFormat , pixelDatatype , sourceFace ) ;
136
129
}
137
130
}
138
131
139
132
if ( defined ( source ) ) {
140
- createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_X , source . positiveX , preMultiplyAlpha , flipY ) ;
141
- createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_X , source . negativeX , preMultiplyAlpha , flipY ) ;
142
- createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_Y , source . positiveY , preMultiplyAlpha , flipY ) ;
143
- createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_Y , source . negativeY , preMultiplyAlpha , flipY ) ;
144
- createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_Z , source . positiveZ , preMultiplyAlpha , flipY ) ;
145
- createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_Z , source . negativeZ , preMultiplyAlpha , flipY ) ;
133
+ // TODO: _gl.pixelStorei(_gl._UNPACK_ALIGNMENT, 4);
134
+ gl . pixelStorei ( gl . UNPACK_PREMULTIPLY_ALPHA_WEBGL , preMultiplyAlpha ) ;
135
+ gl . pixelStorei ( gl . UNPACK_FLIP_Y_WEBGL , flipY ) ;
136
+
137
+ createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_X , source . positiveX ) ;
138
+ createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_X , source . negativeX ) ;
139
+ createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_Y , source . positiveY ) ;
140
+ createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_Y , source . negativeY ) ;
141
+ createFace ( gl . TEXTURE_CUBE_MAP_POSITIVE_Z , source . positiveZ ) ;
142
+ createFace ( gl . TEXTURE_CUBE_MAP_NEGATIVE_Z , source . negativeZ ) ;
146
143
} else {
147
144
gl . texImage2D ( gl . TEXTURE_CUBE_MAP_POSITIVE_X , 0 , pixelFormat , size , size , 0 , pixelFormat , pixelDatatype , null ) ;
148
145
gl . texImage2D ( gl . TEXTURE_CUBE_MAP_NEGATIVE_X , 0 , pixelFormat , size , size , 0 , pixelFormat , pixelDatatype , null ) ;
@@ -166,13 +163,12 @@ define([
166
163
this . _flipY = flipY ;
167
164
this . _sampler = undefined ;
168
165
169
- var initialized = defined ( source ) ;
170
- this . _positiveX = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_X , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
171
- this . _negativeX = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_X , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
172
- this . _positiveY = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_Y , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
173
- this . _negativeY = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_Y , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
174
- this . _positiveZ = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_Z , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
175
- this . _negativeZ = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_Z , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY , initialized ) ;
166
+ this . _positiveX = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_X , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
167
+ this . _negativeX = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_X , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
168
+ this . _positiveY = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_Y , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
169
+ this . _negativeY = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_Y , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
170
+ this . _positiveZ = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_POSITIVE_Z , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
171
+ this . _negativeZ = new CubeMapFace ( gl , texture , textureTarget , gl . TEXTURE_CUBE_MAP_NEGATIVE_Z , pixelFormat , pixelDatatype , size , preMultiplyAlpha , flipY ) ;
176
172
177
173
this . sampler = defined ( options . sampler ) ? options . sampler : new Sampler ( ) ;
178
174
}
0 commit comments