From 72e8e866229382be3583f1d6d48d7b65104b5717 Mon Sep 17 00:00:00 2001 From: Brandon Jones Date: Thu, 6 Jan 2022 08:53:39 -0800 Subject: [PATCH] Use await with compileAsync examples --- examples/webgl_loader_gltf.html | 10 ++++------ examples/webgl_loader_gltf_transmission.html | 8 +++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/examples/webgl_loader_gltf.html b/examples/webgl_loader_gltf.html index 09ed1ad21ce75f..353a2198238753 100644 --- a/examples/webgl_loader_gltf.html +++ b/examples/webgl_loader_gltf.html @@ -52,19 +52,17 @@ // model const loader = new GLTFLoader().setPath( 'models/gltf/DamagedHelmet/glTF/' ); - loader.load( 'DamagedHelmet.gltf', function ( gltf ) { + loader.load( 'DamagedHelmet.gltf', async function ( gltf ) { // Calling compileAsync returns a promise that resolves when gltf.scene can be added // to scene without unnecessary stalling on shader compiation. This helps the page // stay responsive during startup. - renderer.compileAsync( gltf.scene, scene ).then( () => { + await renderer.compileAsync( gltf.scene, scene ); - scene.add( gltf.scene ); + scene.add( gltf.scene ); - render(); - - } ); + render(); } ); diff --git a/examples/webgl_loader_gltf_transmission.html b/examples/webgl_loader_gltf_transmission.html index d30d8196a9e272..f9f4121af95966 100644 --- a/examples/webgl_loader_gltf_transmission.html +++ b/examples/webgl_loader_gltf_transmission.html @@ -55,7 +55,7 @@ new GLTFLoader() .setPath( 'models/gltf/' ) .setDRACOLoader( new DRACOLoader().setDecoderPath( 'js/libs/draco/gltf/' ) ) - .load( 'IridescentDishWithOlives.glb', function ( gltf ) { + .load( 'IridescentDishWithOlives.glb', async function ( gltf ) { mixer = new THREE.AnimationMixer( gltf.scene ); mixer.clipAction( gltf.animations[ 0 ] ).play(); @@ -64,11 +64,9 @@ // to scene without unnecessary stalling on shader compiation. This helps the page // stay responsive during startup. - renderer.compileAsync( gltf.scene, scene ).then( () => { + await renderer.compileAsync( gltf.scene, scene ); - scene.add( gltf.scene ); - - } ); + scene.add( gltf.scene ); } );