Skip to content

Instantly share code, notes, and snippets.

@lassemt
Created April 1, 2020 16:38
Show Gist options
  • Save lassemt/d330d794a6b021cad2f30eebba197fd5 to your computer and use it in GitHub Desktop.
Save lassemt/d330d794a6b021cad2f30eebba197fd5 to your computer and use it in GitHub Desktop.
// 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