ThreeDDice Class

Hierarchy

  • ThreeDDice

Constructors

  • Construct and initialize the object

    Parameters

    • Optional canvas: HTMLCanvasElement

      Canvas element

    • Optional apiKey: string

      Required if connecting to the dddice API

    • Optional config: Partial<IEngineConfig>

      Optional configuration to change the look and feel of the renderer

    Returns ThreeDDice

Properties

DefaultConfig: IEngineConfig = ...

Default Config

API Connection

Available after calling connect

apiKey?: string

API Key

canvas?: HTMLCanvasElement

Canvas

Accessors

  • get controlsEnabled(): boolean
  • Get mouse/pointer controls enabled

    Returns boolean

  • set controlsEnabled(enabled): void
  • Set mouse/pointer controls enabled

    Parameters

    • enabled: boolean

    Returns void

  • get height(): number
  • Canvas Height

    Returns number

  • get isDiceThrowing(): boolean
  • Get if a roll is currently animating

    Returns boolean

  • get version(): string
  • Get the current version of dddice

    Returns string

  • get width(): number
  • Canvas width

    Returns number

Methods

  • Check if WebGL is available

    Returns boolean

  • Add document/canvas event callback

    Parameters

    • eventName: string
    • callback: ((...params) => void)
        • (...params): void
        • Parameters

          • Rest ...params: any[]

          Returns void

    Returns void

  • Clear all dice from canvas

    Returns void

  • Connect to the live server and begin listening to room events.

    Note: Your user must be a participant in a room in order to listen to events, otherwise an error is thrown.

    Parameters

    • roomSlug: string

      Room slug to listen on

    • Optional roomPasscode: string

      Private passcode to access room

    • Optional userUuid: string

      Personal User UUID to listen to whispers

    Returns ThreeDDice

  • Connect to the live server and begin listening to room events.

    Note: Your user must be a participant in a room in order to listen to events, otherwise an error is thrown.

    Returns ThreeDDice

  • Return a loaded theme

    Parameters

    • themeId: string

    Returns ITheme

  • Return all loaded themes

    Returns ITheme[]

  • Initialize object if the default constructor had been called

    Parameters

    • Optional canvas: HTMLCanvasElement

      Canvas element

    • Optional apiKey: string

      Required if connecting to the dddice API

    • Optional config: Partial<IEngineConfig>

      Optional configuration to change the look and feel of the renderer

    • Optional appName: string

      Optional name to identify which application is connecting to dddice

    Returns ThreeDDice

  • Limit which participant events are executed This is useful for filtering dice rolls to a select group of players per instance (i.e. creating dice trays)

    Parameters

    • participantIds: number[]

      The participant IDs of the room

    Returns ThreeDDice

  • Load a theme, including shaders, into the engine

    Parameters

    • theme: ITheme
    • overwriteTheme: boolean = false
    • fetchPreviews: boolean = true

    Returns ThreeDDice

  • Pause camera controls

    Returns void

  • Pick up dice belonging to a particular user

    This clears all dice rolled by the specified from the board and uses the API to notify clear those dice from the board's of all connected users

    Parameters

    • uuid: string

      uuid of the user whose dice to clear

    Returns Promise<void>

    void

    Throws

    APIError if connect not called previously

  • Pick up dice

    This clears certain dice from the board and updates the API

    Parameters

    • roll: Partial<IRoll> | Partial<IRoll>[]

      single roll or array of rolls

    • uuids: string[] = []

      Optional array of dice uuids

    Returns Promise<IApiResponse<"roll[]", IRoll[]>>

    void

    Throws

    APIError if connect not called previously

  • Load assets for a loaded theme

    This loads all meshes, textures, and sounds for a dice theme. Calling this multiple times will debounce the loading processing for 50ms

    Returns a list of items to be queued

    Parameters

    • id: string
    • processQueue: boolean = true

    Returns string[]

  • Reset camera frame

    After disabling camera controls, this can be used to reset the camera view to a top-down angle

    Returns void

  • Resize canvas

    Parameters

    • width: number

      Width of canvas in pixels

    • height: number

      Height of canvas in pixels

    Returns ThreeDDice

  • Resume camera controls

    Returns void

  • Screenshot the canvas

    Parameters

    • mimeType: string

      image format mime type of the generated screenshot.

    Returns undefined | string

    screenshot as a DataURI

  • Set configuration

    Parameters

    Returns void

  • Change the hidden state of a roll

    Optionally pass the uuids of specific dice to only unhide those dice, otherwise all dice in the roll will be revealed.

    Parameters

    • roll: IRoll

      IRoll Roll to unhide

    • uuids: string[] = []

      Optional array of dice uuids

    Returns Promise<IApiResponse<"roll", IRoll>>

    void

    Throws

    APIError if connect not called previously

Generated using TypeDoc