Interface IWorldNavigationService

Define WorldNavigationService interface.

interface IWorldNavigationService {
    currentSceneId: string;
    currentSceneName: string;
    currentWorldId: string;
    previousSceneId: string;
    previousSceneName: string;
    previousWorldId: string;
    getWorldConfig(worldId: string): Promise<null | {
        preload: boolean;
        sceneList: {
            id: string;
            name: string;
            url: string;
        }[];
        worldId: string;
    }>;
    loadWorld(worldId: string, onProgressing: (() => {})): Promise<void>;
    switchScene(sceneName: string, options?: {
        onComplete: (() => {});
        switchChannel: boolean;
        worldId: string;
    }): Promise<void>;
}

Implemented by

Properties

currentSceneId: string

Current scene id

currentSceneName: string

Current scene name

currentWorldId: string

Current World id

previousSceneId: string

Previous scene id

previousSceneName: string

Previous scene name

previousWorldId: string

Previous World id

Methods

  • Get the World configuration.

    Parameters

    • worldId: string

      The id of the world.

    Returns Promise<null | {
        preload: boolean;
        sceneList: {
            id: string;
            name: string;
            url: string;
        }[];
        worldId: string;
    }>

    • The configuration of the world. If the world is not found, the promise will return null.
  • Preload the World.

    Parameters

    • worldId: string

      The id of the world.

    • onProgressing: (() => {})

      Callback function triggered when the world is loading. Useful for displaying a loading progress.

        • (): {}
        • Returns {}

      Returns Promise<void>

    • Switch to a new scene.

      Parameters

      • sceneName: string

        The name of the scene.

      • Optionaloptions: {
            onComplete: (() => {});
            switchChannel: boolean;
            worldId: string;
        }

        Optional parameters.

        • onComplete: (() => {})

          Callback function triggered when the scene is switched.

            • (): {}
            • Returns {}

          • switchChannel: boolean

            Whether to switch the channel. Default is true.

          • worldId: string

            The id of the world. If not provided, the current world will be used.

        Returns Promise<void>