Przeglądaj źródła

feature/upload-cubetexture-with-mipmaps

tangyuan 6 lat temu
rodzic
commit
e48d7cf75d

+ 1 - 1
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "three",
-  "version": "0.105.1",
+  "version": "0.106.2",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 13 - 9
src/renderers/webgl/WebGLTextures.js

@@ -397,6 +397,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 				setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );
 
+				var mipmaps = texture.mipmaps;
+
 				for ( var i = 0; i < 6; i ++ ) {
 
 					if ( ! isCompressed ) {
@@ -409,6 +411,16 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 							state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );
 
+							var mipmap;
+
+							for ( var j = 1; j < mipmaps.length; ++ j ) {
+
+								mipmap = mipmaps[ j ];
+
+								state.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, glFormat, glType, mipmap.image[ i ] );
+
+							}
+
 						}
 
 					} else {
@@ -443,15 +455,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 				}
 
-				if ( ! isCompressed ) {
-
-					textureProperties.__maxMipLevel = 0;
-
-				} else {
-
-					textureProperties.__maxMipLevel = mipmaps.length - 1;
-
-				}
+				textureProperties.__maxMipLevel = mipmaps.length - 1;
 
 				if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
 

+ 2 - 1
src/textures/CubeTexture.d.ts

@@ -20,7 +20,8 @@ export class CubeTexture extends Texture {
 		format?: PixelFormat,
 		type?: TextureDataType,
 		anisotropy?: number,
-		encoding?: TextureEncoding
+		encoding?: TextureEncoding,
+		mipmaps?: CubeTexture[]
 	);
 
 	images: any; // returns and sets the value of Texture.image in the codde ?

+ 3 - 1
src/textures/CubeTexture.js

@@ -5,14 +5,16 @@
 import { Texture } from './Texture.js';
 import { CubeReflectionMapping, RGBFormat } from '../constants.js';
 
-function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {
+function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding, mipmaps ) {
 
 	images = images !== undefined ? images : [];
 	mapping = mapping !== undefined ? mapping : CubeReflectionMapping;
 	format = format !== undefined ? format : RGBFormat;
+	mipmaps = mipmaps !== undefined ? mipmaps : [];
 
 	Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
 
+	this.mipmaps = mipmaps;
 	this.flipY = false;
 
 }