Engine class for creating the singleton on window. It's a singleton proxy to the Loader class for initializing Container instances, and for Plugins class responsible for every external feature

Hierarchy

  • Engine

Constructors

Properties

_domArray: Container[]

Contains all the Container instances of the current engine instance

_eventDispatcher: EventDispatcher
_initialized: boolean

Checks if the engine instance is initialized

_loader: Loader

Contains the Loader engine instance

plugins: Plugins

Contains the Plugins engine instance

Methods

  • addPreset adds preset to tsParticles, it will be available to all future instances created

    Parameters

    • preset: string

      the preset name

    • options: RecursivePartial<IOptions>

      the options to add to the preset

    • override: boolean = false

      if true, the preset will override any existing with the same name

    Returns Promise<void>

  • Retrieves a Container from all the objects loaded

    Returns

    The Container object at specified index, if present or not destroyed, otherwise undefined

    Parameters

    • index: number

      The object index

    Returns undefined | Container

  • Loads an options object from the provided array to create a Container object.

    Returns

    A Promise with the Container object created

    Parameters

    • tagId: string

      The particles container element id

    • options: RecursivePartial<IOptions>[]

      The options array to get the item from

    • Optional index: number

      If provided gets the corresponding item from the array

    Returns Promise<undefined | Container>

  • Loads the provided json with a GET request. The content will be used to create a Container object. This method is async, so if you need a callback refer to JavaScript function fetch

    Returns

    A Promise with the Container object created

    Parameters

    • tagId: SingleOrMultiple<string>

      the particles container element id

    • Optional pathConfigJson: number | SingleOrMultiple<string>

      the json path (or paths array) to use in the GET request

    • Optional index: number

      the index of the paths array, if a single path is passed this value is ignored

    Returns Promise<undefined | Container>

  • Adds an additional click handler to all the loaded Container objects.

    Parameters

    • callback: ((e: Event, particles?: Particle[]) => void)

      The function called after the click event is fired

        • (e: Event, particles?: Particle[]): void
        • Parameters

          • e: Event
          • Optional particles: Particle[]

          Returns void

    Returns void