dddice JavaScript SDK

The dddice JavaScript SDK allows developers to render and roll custom digital dice using the dddice API.

This can be useful for building external applications such as:

  • Browser Extensions
  • Custom Game Integrations
  • OBS Plugins
  • VTT Modules & Plugins

API

In order to utilize the dddice JavaScript SDK, you will need to generate an API Key. More information can be found on the API Documentation site.

Usage

To utilize dddice in your own project, include the library via our CDN.

<script src="https://cdn.dddice.com/js/dddice-latest.js"></script>

Initialize the library to establish a connection and begin rendering.

<canvas id="dddice" />

<script>
const dddice = new window.ThreeDDice(document.getElementById('dddice'), '<YOUR_API_KEY>');

dddice.start(); // start the renderer
dddice.connect('<YOUR_ROOM_SLUG>'); // connect and listen for room events
</script>

Roll dice using the dddice API. Themes are automatically loaded and rendered using the given canvas.

dddice.roll([{
theme: 'dddice-standard',
type: 'd20',
}]);

To learn more, dive into the ThreeDDice and ThreeDDiceAPI classes.

Generated using TypeDoc