A function that's called once to load assets before the sketch runs.
Declaring the function preload()
sets a code block to run once automatically before setup() or draw(). It's used to load assets including multimedia files, fonts, data, and 3D models:
function preload() {
// Code to run before the rest of the sketch.
}
Functions such as loadImage(), loadFont(), loadJSON(), and loadModel() are guaranteed to either finish loading or raise an error if they're called within preload()
. Doing so ensures that assets are available when the sketch begins running.
उदाहरण
This page is generated from the comments in src/core/main.js . Please feel free to edit it and submit a pull request!