Skip to content

Commit

Permalink
Use await with compileAsync examples
Browse files Browse the repository at this point in the history
  • Loading branch information
toji committed Jan 6, 2022
1 parent 70b22ee commit 72e8e86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 4 additions & 6 deletions examples/webgl_loader_gltf.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();

} );

Expand Down
8 changes: 3 additions & 5 deletions examples/webgl_loader_gltf_transmission.html
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 );

} );

Expand Down

0 comments on commit 72e8e86

Please sign in to comment.