Browse Source

Examples: Improve BPCEM demo. (#32172)

Michael Herzog 3 months ago
parent
commit
6588408524
1 changed files with 9 additions and 5 deletions
  1. 9 5
      examples/webgpu_materials_envmaps_bpcem.html

+ 9 - 5
examples/webgpu_materials_envmaps_bpcem.html

@@ -50,7 +50,7 @@
 
 			init();
 
-			function init() {
+			async function init() {
 
 				THREE.RectAreaLightNode.setLTC( RectAreaLightTexturesLib.init() );
 
@@ -102,9 +102,11 @@
 
 				// walls
 			
-				const diffuseTex = loader.load( 'textures/brick_diffuse.jpg' );
+				const [ diffuseTex, bumpTex ] = await Promise.all( [
+					loader.loadAsync( 'textures/brick_diffuse.jpg' ),
+					loader.loadAsync( 'textures/brick_bump.jpg' )
+				] );
 				diffuseTex.colorSpace = THREE.SRGBColorSpace;
-				const bumpTex = loader.load( 'textures/brick_bump.jpg' );
 
 				wallMat = new THREE.MeshStandardNodeMaterial();
 
@@ -176,6 +178,10 @@
 				renderer.inspector = new Inspector();
 				document.body.appendChild( renderer.domElement );
 
+				await renderer.init();
+
+				updateCubeMap();
+
 				window.addEventListener( 'resize', onWindowResize );
 
 				// controls
@@ -224,8 +230,6 @@
 
 			function animate() {
 
-				updateCubeMap();
-
 				renderer.render( scene, camera );
 
 			}

粤ICP备19079148号