File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -512,13 +512,13 @@ export default class Car {
512512 */
513513 _createEngineNoise ( ) {
514514 // Create a player for engine noise
515- this . engine = new Tone . Player ( "sfx/engine.mp3" ) . toDestination ( ) ;
516- // Set volume
517- this . engine . volume . value = - 12 ;
518- this . engine . loop = true ;
519- // Connect to gain node to control proximity audio
520- this . engine . connect ( this . gainNode ) ;
521- this . engine . start ( ) ;
515+ this . engine = new Tone . Player ( "sfx/engine.mp3" , ( ) => {
516+ // Set volume
517+ this . engine . volume . value = - 12 ;
518+ this . engine . loop = true ;
519+ // Connect to gain node to control proximity audio
520+ this . engine . connect ( this . gainNode ) ;
521+ } ) . toDestination ( ) ;
522522 }
523523
524524 /**
Original file line number Diff line number Diff line change @@ -140,6 +140,8 @@ export default class LivingRoom extends World {
140140 // Wait for assets to load before proceeding
141141 const checkLoaded = ( ) => {
142142 if ( ( this . radio && this . radio . isLoaded ) && ( this . tv && this . tv . isLoaded ) ) {
143+ // Start car engine
144+ this . car . engine . start ( ) ;
143145 this . isLoaded = true ;
144146 } else {
145147 requestAnimationFrame ( checkLoaded ) ; // Check again in the next frame
Original file line number Diff line number Diff line change @@ -282,6 +282,7 @@ export default class World {
282282 */
283283 _start ( ) {
284284 this . isLoaded = true ;
285+ this . car . engine . start ( ) ;
285286 }
286287
287288 /**
You can’t perform that action at this time.
0 commit comments