RTSDK
    Preparing search index...

    Class DroppedAssetFactory

    Factory for creating and retrieving DroppedAsset instances. Use this factory to work with assets that have been placed in a Topia world.

    This factory should be instantiated once per application and reused across your codebase.

    dropped asset, factory, create, get, retrieve, instantiate, topia

    // In your initialization file (e.g., utils/topiaInit.ts)
    import { Topia, DroppedAssetFactory } from "@rtsdk/topia";
    const topia = new Topia({ config });
    export const DroppedAsset = new DroppedAssetFactory(topia);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    credentials: undefined | InteractiveCredentials
    jwt?: string
    requestOptions: object
    topia: Topia

    Methods

    • Instantiate a new instance of DroppedAsset class for an existing dropped asset in a world.

      Parameters

      Returns DroppedAsset

      Returns a new DroppedAsset object without fetching its properties.

      This method creates a controller instance for an existing dropped asset but does not fetch its properties. Use this when you need a lightweight instance and will fetch properties separately if needed or when you already have the properties.

      create, instantiate, dropped asset, initialize, instance

      // Import the pre-initialized factory from your app's initialization file
      import { DroppedAsset } from "utils/topiaInit.ts";

      // Create a DroppedAsset instance with credentials
      const droppedAssetInstance = DroppedAsset.create(
      assetId,
      urlSlug,
      {
      credentials: {
      interactiveNonce,
      interactivePublicKey,
      assetId,
      urlSlug,
      visitorId
      }
      }
      );

      // Later fetch its properties if needed
      await droppedAssetInstance.fetchDroppedAssetById();
    • Drops an asset in a world and returns a new instance of DroppedAsset class with all properties.

      Parameters

      • asset: Asset
      • __namedParameters: {
            assetScale?: number;
            clickableDisplayTextDescription?: string;
            clickableDisplayTextHeadline?: string;
            clickableLink?: string;
            clickableLinkTitle?: string;
            clickType?: string;
            flipped?: boolean;
            interactivePublicKey?: string;
            isForceLinkInIframe?: boolean;
            isInteractive?: boolean;
            isOpenLinkInDrawer?: boolean;
            isTextTopLayer?: boolean;
            layer0?: string;
            layer1?: string;
            position: { x: number; y: number };
            sceneDropId?: string;
            text?: string;
            textColor?: string;
            textFontFamily?: string;
            textSize?: number;
            textWeight?: string;
            textWidth?: number;
            uniqueName?: string;
            urlSlug: string;
            yOrderAdjust?: number;
        }

      Returns Promise<DroppedAsset>

      Returns a new DroppedAsset object representing the placed asset in the world.

      This method places an existing Asset into a world at specified coordinates, effectively "dropping" it into the environment. You can customize various properties of the dropped asset during placement, such as scale, position, interactive settings, and visual layers.

      drop, place, add, create, position, asset, deploy

      // Import the pre-initialized factories from your app's initialization file
      import { Asset, DroppedAsset } from "utils/topiaInit.ts";

      // First get an asset instance
      const assetInstance = Asset.create("asset-id-123", {
      credentials: {
      interactiveNonce,
      interactivePublicKey,
      assetId,
      urlSlug,
      visitorId
      }
      });

      // Then drop (place) the asset in a world
      const droppedAssetInstance = await DroppedAsset.drop(
      assetInstance,
      {
      // Basic positioning and appearance
      position: { x: 250, y: 350 },
      assetScale: 1.5,
      flipped: true,
      uniqueName: "welcome-sign",
      urlSlug: "my-world-slug",

      // For web images (optional)
      layer0: "https://example.com/background.png",
      layer1: "https://example.com/foreground.png",

      // For interactive assets (optional)
      interactivePublicKey: "your-public-key",
      isInteractive: true,

      // For clickable assets (optional)
      clickType: "link",
      clickableLink: "https://example.com",
      clickableLinkTitle: "Visit Example"
      }
      );

      // The dropped asset is ready to use
      console.log(droppedAssetInstance.id);
    • Standardized error handler for all SDK operations.

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

      Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url

      This method processes errors from API calls and formats them consistently across the SDK. It extracts relevant error information including:

      • HTTP status codes and response data
      • Error messages from API responses
      • Stack traces for debugging
      • Request details (URL, method, parameters)

      All errors thrown by SDK methods flow through this handler to ensure consistent error format.

      error, exception, handler, debugging, api error, http error

    • Instantiate a new instance of DroppedAsset class and automatically fetch all its properties.

      Parameters

      Returns Promise<DroppedAsset>

      Returns a new DroppedAsset object with all properties already fetched.

      This method creates a controller instance and immediately fetches all properties of the dropped asset. It's a convenience method that combines creating an instance and calling fetchDroppedAssetById().

      get, fetch, retrieve, dropped asset, load, instance

      // Import the pre-initialized factory from your app's initialization file
      import { DroppedAsset } from "utils/topiaInit.ts";

      // Get a fully populated DroppedAsset instance
      const droppedAssetInstance = await DroppedAsset.get(
      assetId,
      urlSlug,
      {
      credentials: {
      interactiveNonce,
      interactivePublicKey,
      assetId,
      urlSlug,
      visitorId
      }
      }
      );

      // The properties are already loaded, so you can use them immediately
      console.log(droppedAssetInstance.position);
    • Searches for and retrieves a dropped asset by its unique name within a world.

      Parameters

      Returns Promise<DroppedAsset>

      Returns a new DroppedAsset object with all properties already fetched.

      This method leverages the handleGetDroppedAssetByUniqueName endpoint in the Public API and assumes there is exactly one dropped asset with the matching uniqueName for the given urlSlug. Use this when you need to find a dropped asset by its uniqueName rather than its id.

      find, search, unique name, retrieve, locate, lookup, dropped asset

      // Import the pre-initialized factory from your app's initialization file
      import { DroppedAsset } from "utils/topiaInit.ts";

      // Find and retrieve a dropped asset by its unique name
      const droppedAssetInstance = await DroppedAsset.getWithUniqueName(
      "banner-sign-northeast",
      "my-world-slug",
      "your-interactive-secret",
      {
      apiKey: "your-api-key",
      interactivePublicKey: "your-public-key",
      // other credentials...
      }
      );

      // The properties are already loaded, so you can use them immediately
      console.log(droppedAssetInstance.position);
    • Returns the configured Axios instance for making API calls to Topia's Public API.

      Returns AxiosInstance

      The configured Axios client instance with authentication headers.

      All HTTP requests to the Topia API should use this method to ensure proper authentication headers and base URL configuration are applied.

      api, axios, http, request, client, public api