Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Mar 15, 2023
1 parent 51afab3 commit bf7606c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
- [`hash`](#hash)
- [`chunkify()`](#chunkify)
- [`assets`](#assets)
- [Examples](#examples)
- [Complete Example with `loadFont()`](#complete-example-with-loadfont)
- [`random`](#random)
- [`window`](#window)
- [Methods](#methods)
Expand Down Expand Up @@ -195,13 +197,20 @@ The functions for loading data files from the Meraki CDN are:
- `Meraki.assets.loadJSON()`
- `Meraki.assets.loadXML()`

Additionally, the following functions are provided for loading font, image and shader assets from the Meraki CDN:
Additionally, the following functions are provided for loading font, image, shader and other assets from the Meraki CDN:

- `Meraki.assets.loadBytes()`
- `Meraki.assets.loadFont()`
- `Meraki.assets.loadImage()`
- `Meraki.assets.loadShader()`

These functions are used to load assets from the Meraki CDN. For example, to load a JSON file from the CDN:
These functions are used to load assets from the Meraki CDN, and MUST be used in place of the original p5 functions.

For information on how to use the functions, see the [p5.js documentation](https://p5js.org/reference/#/p5/).

###### Examples

To load a JSON file from the CDN:

```js
const data = await Meraki.assets.loadJSON('your-project-identifier/data.json');
Expand All @@ -228,6 +237,8 @@ const data = await Meraki.assets.loadJSON(`${Meraki.project.identifier}/data.jso
Note the use of `await` in the example above. The above functions are asynchronous and must be used with `await` or `then()` and should be placed in the `initialization` method of the `MerakiScript` class.

###### Complete Example with `loadFont()`

Complete example using `Meraki.assets.loadFont()`:

```js
Expand Down Expand Up @@ -275,6 +286,9 @@ class Script extends MerakiScript {
}
```

> When using `Meraki.assets.loadFont()`, `Meraki.assets.loadImage()`, or `Meraki.assets.loadShader()`, access the correct filename
> for the asset from the "Digital Assets" tab in the Meraki Artist dashboard.
##### `random`

The `Meraki.random` property provides access to random value generation functions using a `Random` class.
Expand Down

0 comments on commit bf7606c

Please sign in to comment.