Browse Source

load cubemap mipmaps with level

angus 6 years ago
parent
commit
f4e2c7936d
1 changed files with 9 additions and 4 deletions
  1. 9 4
      examples/webgl_materials_cubemap_mipmaps.html

+ 9 - 4
examples/webgl_materials_cubemap_mipmaps.html

@@ -34,15 +34,18 @@
 				var path = 'textures/cube/angus/';
 				var format = '.jpg';
 				var mipmaps = [];
+				var maxLevel = 8;
 
-				async function loadCubeTexture( urls ) {
+				async function loadCubeTexture( urls, width ) {
 
 					return new Promise( function ( resolve, reject) {
 
-						new THREE.CubeTextureLoader().load( urls, function ( cubeTexture ) {
+						new THREE.CubeTextureLoader().load( urls,function ( cubeTexture ) {
 
 							resolve( cubeTexture );
 
+						}, function ( error ) {
+
 						} );
 
 
@@ -53,7 +56,7 @@
 				// load mipmaps
 				var pendings = [];
 
-				for ( var level = 0; level < 9; ++ level ) {
+				for ( var level = 0; level <= maxLevel; ++ level ) {
 
 					var urls = [];
 
@@ -63,9 +66,11 @@
 
 					}
 
+					let mipmapLevel = level;
+
 					pendings.push( loadCubeTexture( urls ).then( function ( cubeTexture ) {
 
-						mipmaps.push( cubeTexture );
+						mipmaps[ mipmapLevel ] = cubeTexture;
 
 					} ) );