RTSDK
    Preparing search index...

    Class World

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

    const world = await new World(topia, "exampleWorld", {
    attributes: { name: "Example World" },
    credentials: { interactiveNonce: "exampleNonce", assetId: "droppedAssetId", visitorId: 1, urlSlug: "exampleWorld" }
    });

    Hierarchy (View Summary)

    Implements

    Index

    Analytics

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

      Parameters

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

      Returns Promise<void | ResponseType>

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

    Data Objects

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

      Parameters

      • OptionalappPublicKey: string
      • OptionalappJWT: string
      • OptionalsharedAppPublicKey: string
      • OptionalsharedAppJWT: string

      Returns Promise<void | ResponseType>

      await world.fetchDataObject();
      const { dataObject } = world;
    • 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.

      Parameters

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

      Returns Promise<void | ResponseType>

      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

      await world.incrementDataObjectValue([`keyAssets.${keyAssetId}.totalItemsCollected.count`], 1);
      
    • Sets the data object for a user. Must have valid interactive credentials from a visitor in the world.

      Parameters

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

      Returns Promise<void | ResponseType>

      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

       await world.setDataObject(
      {
      ...defaultGameData,
      keyAssetId: droppedAsset.id,
      },
      { lock: { lock: { lockId: `${keyAssetId}-${new Date(Math.round(new Date().getTime() / 10000) * 10000)}` }, releaseLock: true } },
      );
      const { profileMapper } = world.dataObject;
    • Updates the data object for a world. Must have valid interactive credentials from a visitor in the world.

      Parameters

      • dataObject: object
      • options: {
            analytics?: AnalyticType[];
            appJWT?: string;
            appPublicKey?: string;
            lock?: { lockId: string; releaseLock?: boolean };
            sharedAppJWT?: string;
            sharedAppPublicKey?: string;
        } = {}

      Returns Promise<void | ResponseType>

      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

      await world.updateDataObject({
      [`keyAssets.${keyAssetId}.itemsCollectedByUser.${profileId}`]: { [dateKey]: { count: 1 }, total: 1 },
      [`profileMapper.${profileId}`]: username,
      });
      const { profileMapper } = world.dataObject;

    Dropped Assets

    • Retrieve all assets dropped in a world.

      Returns Promise<void | ResponseType>

      await world.fetchDroppedAssets();
      const assets = world.droppedAssets;
    • Retrieve all assets dropped in a world matching sceneDropId.

      Parameters

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

      Returns Promise<DroppedAsset[]>

      Returns an array of DroppedAsset instances.

      const droppedAssets = await world.fetchDroppedAssetsBySceneDropId({
      sceneDropId: "sceneDropIdExample",
      uniqueName: "optionalUniqueNameExample",
      });
    • Retrieve all assets dropped in a world matching uniqueName.

      Parameters

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

      Returns Promise<DroppedAsset[]>

      Returns an array of DroppedAsset instances.

      const droppedAssets = await world.fetchDroppedAssetsWithUniqueName({ uniqueName: "exampleUniqueName", isPartial: true });
      
    • Retrieve all landmark zone assets dropped in a world.

      Parameters

      • OptionallandmarkZoneName: string
      • OptionalsceneDropId: string

      Returns Promise<DroppedAsset[]>

      Returns an array of DroppedAsset instances.

      const zones = await world.fetchLandmarkZones("optionalLandmarkZoneName", "optionalSceneDropIdExample");
      
    • Update multiple custom text dropped assets with a single style while preserving text for specified dropped assets only.

      Parameters

      Returns Promise<object>

      Updates each DroppedAsset instance and world.droppedAssets map.

      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);

    Other

    credentials: undefined | InteractiveCredentials
    dataObject?: null | object
    jwt?: string
    requestOptions: object
    sceneDropIds?: null | [string]
    scenes?: null | [string]
    topia: Topia
    urlSlug: string
    webhooks?: null | WorldWebhooksInterface
    • get droppedAssets(): { [key: string]: DroppedAsset }

      Returns { [key: string]: DroppedAsset }

    • Parameters

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

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

    • Retrieves details of a world.

      Returns Promise<void | ResponseType>

      await world.fetchDetails();
      const { name } = world;
    • Returns Promise<object | ResponseType>

      { sceneDropIds: [] }
      

      Use fetchScenes instead.

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

      await world.fetchSceneDropIds();
      
    • Display a message via a toast to all visitors currently in a world.

      Parameters

      Returns Promise<void | ResponseType>

      Returns { success: true } or an error.

      await world.fireToast({
      groupId: "custom-message",
      title: "Hello World",
      text: "Thank you for participating!",
      });
    • Returns AxiosInstance

    • Add an activity to a world excludeFromNotification is an array of visitorIds to exclude from the notification

      Parameters

      • __namedParameters: {
            assetId: string;
            excludeFromNotification?: (string | number)[];
            type: WorldActivityType;
        }

      Returns Promise<string | ResponseType>

      Returns the activityId or an error response.

      await world.triggerActivity({ type: "GAME_ON", assetId: "abc123" });
      
    • Set close world settings

      Parameters

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

      Returns Promise<void | ResponseType>

      Returns { success: true } or an error.

      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
      });
    • Update details of a world.

      Parameters

      Returns Promise<void | ResponseType>

      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
      });

      const { name, description } = world;

    Particles

    • Get all particles available

      Returns Promise<object | ResponseType>

      await world.getAllParticles();

      @returns {Promise<ResponseType>} Returns an array of particles or an error response.
    • Trigger a particle effect at a position in the world

      Parameters

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

      Returns Promise<string | ResponseType>

      Returns { success: true } or a message if no particleId is found.

      const droppedAsset = await DroppedAsset.get(assetId, urlSlug, { credentials });

      await world.triggerParticle({ name: "Flame", duration: 5, position: droppedAsset.position });

    Scenes

    • Drops a scene in a world and returns sceneDropId.

      Parameters

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

      Returns Promise<ResponseType>

      { sceneDropId: sceneId-timestamp, success: true }
      
      await world.dropScene({
      "sceneId": "string",
      "position": {
      "x": 0,
      "y": 0
      },
      "assetSuffix": "string"
      });
    • Fetch a list of all scene drop ids and dropped assets in a world

      Returns Promise<object | ResponseType>

      { "scenes": {
      "sceneDropId_1": {
      "droppedAssets": {
      "droppedAssetId_1": {
      "metaName": "hello"
      "metaNameReversed": "olleh"
      },
      "droppedAssetId_2": {
      "metaName": "world"
      "metaNameReversed": "dlorw"
      }
      }
      },
      }
      }
      await world.fetchScenes();
      
    • Replace the current scene of a world.

      Parameters

      • sceneId: string

      Returns Promise<void | ResponseType>

      Returns { success: true } or an error.

      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);

    Webhooks

    • Retrieve all webhooks in a world.

      Returns Promise<void | ResponseType>

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