Integrate live 3D dice rolling into your own projects by leveraging the power of dddice.
Add to your project's dependencies using your favorite package manager.
npm install dddice-js --save
# or
yarn add dddice-js
Import and initialize the dddice instance.
import { ThreeDDice } from 'dddice-js'
const canvasElement = document.getElementById('dddice'); // get the canvas element to roll dice into
const dddice = new window.ThreeDDice(canvasElement, '<YOUR_API_KEY>');
dddice.start(); // start the renderer
dddice.connect('<YOUR_ROOM_SLUG>'); // connect and listen for room events
// Roll dice
dddice.roll([{
theme: 'dddice-standard',
type: 'd20',
}]);
Read the official documentation for usage information.
MIT