The Assets Editor API

Hierarchy

  • Events
    • Assets

Internal

  • Loads all assets in the current project / branch. Does not subscribe to realtime changes.

    Parameters

    • options: {
          view: string;
      } = {}

      Options

      • view: string

        The desired view for the REST API e.g 'designer', 'shader-editor'. This might limit the assets returned to a smaller subset depending on the view.

    Returns Promise<void>

  • Loads all assets in the current project / branch and subscribes to changes.

    Parameters

    • options: {
          view: string;
      } = {}

      Options

      • view: string

        The desired view for the REST API e.g 'designer', 'shader-editor'. This might limit the assets returned to a smaller subset depending on the view.

    Returns Promise<void>

Other

  • Constructor

    Parameters

    • options: {
          autoSubscribe: boolean;
      } = {}

      Options

      • autoSubscribe: boolean

        Whether to auto subscribe to asset changes when assets are loaded.

    Returns Assets

  • get defaultUploadCompletedCallback(): Function
  • Gets the default callback called when on asset upload succeeds.

    Returns Function

  • set defaultUploadCompletedCallback(value): void
  • Sets the default callback called when on asset upload succeeds. The function takes 2 arguments: the upload id, and the new asset.

    Parameters

    Returns void

  • get defaultUploadErrorCallback(): Function
  • Gets the default callback called when on asset upload fails.

    Returns Function

  • set defaultUploadErrorCallback(value): void
  • Sets the default callback called when on asset upload progress. The function takes 2 arguments: the upload id, and the error.

    Parameters

    Returns void

  • get defaultUploadProgressCallback(): Function
  • Gets the default callback called when on asset upload progress.

    Returns Function

  • set defaultUploadProgressCallback(value): void
  • Sets the default callback called when on asset upload progress. The function takes 2 arguments: the upload id and the progress.

    Parameters

    Returns void

  • get parseScriptCallback(): Function
  • Gets the callback which parses script assets.

    Returns Function

  • set parseScriptCallback(value): void
  • Sets the callback which parses script assets. When this callback is set, new script assets will be parsed after they are created. The function takes the asset as a parameter and returns a promise with a list of script names when it is done parsing.

    Parameters

    Returns void

  • Creates new anim state graph asset.

    Parameters

    • options: {
          data: object;
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
      } = {}

      Options

      • data: object

        The asset data. See Asset for Animstategraph data.

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

    Returns Promise<Asset>

    The new asset

  • Creates new bundle asset

    Parameters

    • options: {
          assets: Asset[];
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
      } = {}

      Options

      • assets: Asset[]

        The assets that the bundle will contain

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

    Returns Promise<Asset>

    The new asset

  • Creates new CSS asset

    Parameters

    • options: {
          folder: string;
          name: string;
          onProgress: Function;
          preload: boolean;
          text: string;
      } = {}

      Options

      • folder: string

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • text: string

        The CSS

    Returns Promise<Asset>

    The new asset

  • Creates new cubemap asset

    Parameters

    • options: {
          anisotropy: number;
          folder: Asset;
          magFilter: number;
          minFilter: number;
          name: string;
          onProgress: Function;
          preload: boolean;
          textures: Asset[];
      } = {}

      Options

      • anisotropy: number

        Cubemap anisotropy value. Defaults to 1.

      • folder: Asset

        The parent folder asset

      • magFilter: number

        Cubemap magFilter value. Defaults to pc.FILTER_LINEAR.

      • minFilter: number

        Cubemap minFilter value. Defaults to pc.FILTER_LINEAR_MIPMAP_LINEAR.

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • textures: Asset[]

        The textures for each cubemap face in this order: right, left, up, down, front, back

    Returns Promise<Asset>

    The new asset

  • Creates new HTML asset

    Parameters

    • options: {
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
          text: string;
      } = {}

      Options

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • text: string

        The HTML

    Returns Promise<Asset>

    The new asset

  • Creates new localization JSON asset

    Parameters

    • options: {
          folder: Asset;
          localizationData: object;
          name: string;
          onProgress: Function;
          preload: boolean;
      } = {}

      The options

      • folder: Asset

        The parent folder asset

      • localizationData: object

        The localization data. If null then default data will be used.

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

    Returns Promise<Asset>

    The new asset

  • Creates new JSON asset

    Parameters

    • options: {
          folder: Asset;
          json: object;
          name: string;
          onProgress: Function;
          preload: boolean;
          spaces: number;
      } = {}

      Options

      • folder: Asset

        The parent folder asset

      • json: object

        The JSON

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • spaces: number

        The number of spaces used for indentation. Defaults to 0 (tightly packed output).

    Returns Promise<Asset>

    The new asset

  • Creates new material asset

    Parameters

    • options: {
          data: object;
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
      } = {}

      Options

      • data: object

        The material data. Default values will be used for missing fields. See Asset for material data.

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

    Returns Promise<Asset>

    The new asset

  • Creates new script asset

    Parameters

    • options: {
          data: object;
          filename: string;
          folder: Asset;
          onProgress: Function;
          preload: boolean;
          text: string;
      } = {}

      Options

      • data: object

        The script data. See Asset for Script data.

      • filename: string

        The filename of the script. This will also be the name of the script asset. If not defined it will be generated from the name of the script.

      • folder: Asset

        The parent folder asset

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • text: string

        The contents of the script. If none then boilerplate code will be used.

    Returns Promise<Asset>

    The new asset

  • Creates new shader asset

    Parameters

    • options: {
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
          text: string;
      } = {}

      Options

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • text: string

        The GLSL

    Returns Promise<Asset>

    The new asset

  • Creates new sprite asset

    Parameters

    • options: {
          folder: Asset;
          frameKeys: number[];
          name: string;
          onProgress: Function;
          pixelsPerUnit: number;
          preload: boolean;
          renderMode: number;
          textureAtlas: Asset;
      } = {}

      Options

      • folder: Asset

        The parent folder asset

      • frameKeys: number[]

        The sprite's frame keys

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • pixelsPerUnit: number

        The sprite's pixels per unit value. Defaults to 100.

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • renderMode: number

        The sprite's render mode. Defaults to pc.SPRITE_RENDERMODE_SIMPLE.

      • textureAtlas: Asset

        The sprite's texture atlas asset

    Returns Promise<Asset>

    The new asset

  • Creates new template asset

    Parameters

    • options: {
          entity: Entity;
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
      } = {}

      Options

      • entity: Entity

        The entity to create the template from

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

    Returns Promise<Asset>

    The new asset

  • Creates new text asset

    Parameters

    • options: {
          folder: Asset;
          name: string;
          onProgress: Function;
          preload: boolean;
          text: string;
      } = {}

      Options

      • folder: Asset

        The parent folder asset

      • name: string

        The asset name

      • onProgress: Function

        Function to report progress

      • preload: boolean

        Whether to preload the asset. Defaults to true.

      • text: string

        The text

    Returns Promise<Asset>

    The new asset

  • Gets the first script asset that contains the specified script

    Parameters

    • script: string

      The script name

    Returns Asset

    The script asset

  • Instantiates the specified template assets under the specified parent entity.

    Parameters

    • assets: Asset[]

      The template assets.

    • parent: Entity

      The parent entity

    • options: {
          extraData: object;
          history: boolean;
          index: number;
          select: boolean;
      } = {}

      Options

      • extraData: object

        Extra data passed to the backend. Used by the Editor on specific cases.

      • history: boolean

        Whether to record a history action.

      • index: number

        The desired index under the parent to instantiate the templates.

      • select: boolean

        Whether to select the new entities.

    Returns Promise<Entity[]>

    The new entities

  • Finds all assets with specified tags

    Parameters

    • Rest ...tags: any[]

      The tags. If multiple tags are specified then assets that contain ANY of the specified tags will be included. If an argument is an array of tags then assets that contain ALL of the tags in the array will be included.

    Returns Asset[]

    The assets