adam-sdk
    Preparing search index...

    Class AvatarSDK

    The main class for interacting with the A.D.A.M. 3D avatar. This class provides methods for connecting to the avatar, making it speak, and controlling its animations and expressions.

    import { AvatarSDK } from 'adam-sdk';

    const iframe = document.getElementById('avatar-iframe');
    const sdk = new AvatarSDK(iframe);

    sdk.on('ready', () => {
    console.log('SDK is ready!');
    sdk.speak('Hello, world!');
    });

    sdk.connect();
    Index

    Constructors

    • Creates an instance of the AvatarSDK.

      Parameters

      • iframeElement: HTMLIFrameElement

        The HTMLIFrameElement that contains the avatar.

      • options: AvatarSDKOptions = {}

        Configuration options for the SDK.

      Returns AvatarSDK

    Methods

    • Establishes a connection with the avatar iframe. This method must be called before any other commands can be sent to the avatar. It returns a promise that resolves when the connection is established.

      Returns Promise<void>

      A promise that resolves when the connection is established.

      An error if the connection times out or the iframe fails to load.

    • Cleans up resources and removes event listeners. This should be called when the SDK is no longer needed to prevent memory leaks.

      Returns void

    • Interrupts the current speech or action.

      Returns Promise<any>

      A promise that resolves when the interrupt is complete.

    • Removes an event listener for a specific event.

      Parameters

      • eventName: AvatarEvent

        The name of the event to remove the listener from.

      • callback: EventCallback

        The callback function to remove.

      Returns void

    • Registers an event listener for a specific event.

      Parameters

      • eventName: AvatarEvent

        The name of the event to listen for.

      • callback: EventCallback

        The callback function to execute when the event is triggered.

      Returns void

      sdk.on('speech:start', (payload) => {
      console.log('Avatar started speaking:', payload.text);
      });
    • Triggers a specific animation by name.

      Parameters

      • name: string

        The name of the animation to play.

      • loop: boolean = false

        Whether the animation should loop.

      Returns Promise<any>

      A promise that resolves with the command result.

    • Sets the avatar's facial expression.

      Parameters

      • name: string

        The name of the expression to set.

      Returns Promise<any>

      A promise that resolves with the command result.

    • Makes the avatar speak the provided text.

      Parameters

      • text: string

        The text for the avatar to speak.

      • options: SpeakOptions = {}

        Additional options for speech, such as voice, rate, and pitch.

      Returns Promise<any>

      A promise that resolves when the command is acknowledged by the iframe.

      An error if the text is not a non-empty string.