Created
April 1, 2020 16:38
-
-
Save lassemt/d330d794a6b021cad2f30eebba197fd5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put everything that needs to be loaded | |
// into 1 promise. | |
Promise.all([ | |
Scene.root.findFirst('directionalLight01'), | |
Scene.root.findFirst('number'), | |
Patches.outputs.getScalar('score'), | |
]).then( (loadedItems) => { | |
// When everything is loaded | |
// this function will trigger | |
// Note how the loacded items are stored in the | |
// loadedItems and in the orderd the was added | |
// to the array above. Arrays always starts on 0; | |
const directionalLight = loadedItems[0]; | |
// Get the loaded items from Scene.root.findFirst('number'); | |
const counterNumber = loadedItems[1]; | |
// And the last added to the list | |
const scoreNumber = loadedItems[2]; | |
// Do your thing as normal | |
counterNumber.text = scoreNumber.toString(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment