Class World

Summary

Create an instance of World class with a given url slug and optional attributes and session credentials.

Usage

await new World(topia, "exampleWorld", {
attributes: { name: "Example World" },
credentials: { apiKey: "exampleKey", interactiveNonce: "exampleNonce", urlSlug: "exampleWorld", visitorId: 1 }
});

Hierarchy

Implements

Constructors

Properties

credentials: undefined | InteractiveCredentials
dataObject?: null | object
jwt?: string
requestOptions: object
sceneDropIds?: null | [string]
scenes?: null | [string]
topia: Topia
urlSlug: string
webhooks?: null | WorldWebhooksInterface

Accessors

Methods

  • Summary

    Drops a scene in a world and returns sceneDropId.

    Usage

    await world.dropScene({
    "sceneId": "string",
    "position": {
    "x": 0,
    "y": 0
    },
    "assetSuffix": "string"
    });

    Result

    { sceneDropId: sceneId-timestamp, success: true }
    

    Parameters

    • __namedParameters: {
          allowNonAdmins?: boolean;
          assetSuffix?: string;
          position: object;
          sceneDropId?: string;
          sceneId: string;
      }
      • Optional allowNonAdmins?: boolean
      • Optional assetSuffix?: string
      • position: object
      • Optional sceneDropId?: string
      • sceneId: string

    Returns Promise<object | ResponseType>

  • Parameters

    • __namedParameters: {
          error?: unknown;
          message?: string;
          params?: object;
          sdkMethod?: string;
      }
      • Optional error?: unknown
      • Optional message?: string
      • Optional params?: object
      • Optional sdkMethod?: string

    Returns {
        data: {};
        message: string;
        method: string;
        params: object;
        sdkMethod: undefined | string;
        stack: string;
        stackTrace: Error;
        status: number;
        success: boolean;
        url: string;
    }

    • data: {}
      • message: string
      • method: string
      • params: object
      • sdkMethod: undefined | string
      • stack: string
      • stackTrace: Error
      • status: number
      • success: boolean
      • url: string
    • Summary

      Retrieves the data object for a world. Must have valid interactive credentials from a visitor in the world.

      Usage

      await world.fetchDataObject();
      const { dataObject } = world;

      Returns Promise<void | ResponseType>

    • Summary

      Retrieves details of a world.

      Usage

      await world.fetchDetails();
      const { name } = world;

      Returns Promise<void | ResponseType>

    • Summary

      Retrieve all assets dropped in a world.

      Usage

      await world.fetchDroppedAssets();
      const assets = world.droppedAssets;

      Returns Promise<void | ResponseType>

    • Summary

      Retrieve all assets dropped in a world matching sceneDropId.

      Usage

      await world.fetchDroppedAssetsBySceneDropId({
      sceneDropId: "sceneDropIdExample",
      uniqueName: "optionalUniqueNameExample",
      });
      const assets = world.droppedAssets;

      Parameters

      • __namedParameters: {
            sceneDropId: string;
            uniqueName?: string;
        }
        • sceneDropId: string
        • Optional uniqueName?: string

      Returns Promise<DroppedAsset[]>

    • Summary

      Retrieve all assets dropped in a world matching uniqueName.

      Usage

      await world.fetchDroppedAssetsWithUniqueName();
      const assets = world.droppedAssets;

      Parameters

      • __namedParameters: {
            isPartial?: boolean;
            isReversed?: boolean;
            uniqueName: string;
        }
        • Optional isPartial?: boolean
        • Optional isReversed?: boolean
        • uniqueName: string

      Returns Promise<DroppedAsset[]>

    • Summary

      Retrieve all landmark zone assets dropped in a world.

      Usage

      const zones = await world.fetchLandmarkZones("optionalLandmarkZoneName", "optionalSceneDropIdExample");
      

      Parameters

      • Optional landmarkZoneName: string
      • Optional sceneDropId: string

      Returns Promise<DroppedAsset[]>

    • Deprecated

      Use fetchScenes instead.

      Summary

      Fetch a list of all scene drop ids in a world that include at least one asset with an interactivePublicKey

      Usage

      await world.fetchSceneDropIds();
      

      Result

      { sceneDropIds: [] }
      

      Returns Promise<object | ResponseType>

    • Summary

      Fetch a list of all scene drop ids and dropped assets in a world

      Usage

      await world.fetchScenes();
      

      Result

      { "scenes": {
      "sceneDropId_1": {
      "droppedAssets": {
      "droppedAssetId_1": {
      "metaName": "hello"
      "metaNameReversed": "olleh"
      },
      "droppedAssetId_2": {
      "metaName": "world"
      "metaNameReversed": "dlorw"
      }
      }
      },
      }
      }

      Returns Promise<object | ResponseType>

    • Summary

      Retrieve all webhooks in a world.

      Usage

      await world.fetchWebhooks();
      const webhooks = world.webhooks;

      Returns Promise<void | ResponseType>

    • Summary

      Retrieve world analytics by day, week, month, quarter, or year

      Usage

      const analytics = await world.fetchWorldAnalytics({
      periodType: "week",
      dateValue: 40,
      year: 2023,
      });

      Parameters

      • __namedParameters: {
            dateValue: number;
            periodType: "week" | "month" | "quarter" | "year";
            year: number;
        }
        • dateValue: number
        • periodType: "week" | "month" | "quarter" | "year"
        • year: number

      Returns Promise<void | ResponseType>

    • Summary

      Get all particles available

      Usage

      await world.getAllParticles();
      

      Returns Promise<object | ResponseType>

    • Summary

      Increments a specific value in the data object for a world by the amount specified. Must have valid interactive credentials from a visitor in the world.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await world.incrementDataObjectValue("key", 1);
      

      Parameters

      • path: string
      • amount: number
      • options: {
            analytics?: AnalyticType[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: AnalyticType[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>

    • Summary

      Replace the current scene of a world.

      Usage

      const droppedAssetsToUpdate = [world.droppedAssets["6"], world.droppedAssets["12"]]
      const style = {
      "textColor": "#abc123",
      "textFontFamily": "Arial",
      "textSize": 40,
      "textWeight": "normal",
      "textWidth": 200
      }
      await world.replaceScene(SCENE_ID);

      Parameters

      • sceneId: string

      Returns Promise<void | ResponseType>

    • Summary

      Sets the data object for a user. Must have valid interactive credentials from a visitor in the world.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await world.setDataObject({
      "exampleKey": "exampleValue",
      });
      const { dataObject } = world;

      Parameters

      • dataObject: undefined | null | object
      • options: {
            analytics?: AnalyticType[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: AnalyticType[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>

    • Returns AxiosInstance

    • Summary

      Trigger a particle effect at a position in the world

      Usage

      await world.triggerParticle({ name: "Flame" });
      

      Parameters

      • __namedParameters: {
            duration?: number;
            id?: string;
            name?: string;
            position?: object;
        }
        • Optional duration?: number
        • Optional id?: string
        • Optional name?: string
        • Optional position?: object

      Returns Promise<string | object | ResponseType>

    • Summary

      Set close world settings

      Usage

      await world.updateCloseWorldSettings({
      controls: {
      allowMuteAll: true,
      disableHideVideo: true,
      isMobileDisabled: false,
      isShowingCurrentGuests: false,
      },
      description: 'Welcome to my world.',
      forceAuthOnLogin: false,
      height: 2000,
      name: 'Example',
      spawnPosition: { x: 100, y: 100 },
      width: 2000
      });

      Parameters

      • __namedParameters: {
            closeWorldDescription: string;
            isWorldClosed: boolean;
        }
        • closeWorldDescription: string
        • isWorldClosed: boolean

      Returns Promise<void | ResponseType>

    • Summary

      Update multiple custom text dropped assets with a single style while preserving text for specified dropped assets only.

      Usage

      const droppedAssetsToUpdate = [world.droppedAssets["6"], world.droppedAssets["12"]];
      const style = {
      "textColor": "#abc123",
      "textFontFamily": "Arial",
      "textSize": 40,
      "textWeight": "normal",
      "textWidth": 200
      };
      await world.updateCustomText(droppedAssetsToUpdate, style);

      Result

      Updates each DroppedAsset instance and world.droppedAssets map.

      Parameters

      Returns Promise<object>

    • Summary

      Updates the data object for a world. Must have valid interactive credentials from a visitor in the world.

      Optionally, a lock can be provided with this request to ensure only one update happens at a time between all updates that share the same lock id

      Usage

      await world.updateDataObject({
      "exampleKey": "exampleValue",
      });
      const { dataObject } = world;

      Parameters

      • dataObject: object
      • options: {
            analytics?: AnalyticType[];
            lock?: {
                lockId: string;
                releaseLock?: boolean;
            };
        } = {}
        • Optional analytics?: AnalyticType[]
        • Optional lock?: {
              lockId: string;
              releaseLock?: boolean;
          }
          • lockId: string
          • Optional releaseLock?: boolean

      Returns Promise<void | ResponseType>

    • Summary

      Update details of a world.

      Usage

      await world.updateDetails({
      controls: {
      allowMuteAll: true,
      disableHideVideo: true,
      isMobileDisabled: false,
      isShowingCurrentGuests: false,
      },
      description: 'Welcome to my world.',
      forceAuthOnLogin: false,
      height: 2000,
      name: 'Example',
      spawnPosition: { x: 100, y: 100 },
      width: 2000
      });

      Parameters

      Returns Promise<void | ResponseType>