Banuba WebAR JavaScript API Reference
    Preparing search index...

    Class Module

    Auxiliary SDK module that enhances the Player with a feature like:

    Index

    Constructors

    Methods

    Constructors

    • Creates a module from Url

      Parameters

      • source: string

      Returns Module

      const frx = new Module("/path/to/face_tracker.zip.zip")
      
    • Creates a module from Request

      Parameters

      • source: Request

      Returns Module

      const frx = new Module(new Request(
      "/path/to/face_tracker.zip",
      { headers: { etag: "\"a610ceb58d4fa6b8b13dff520339ba88\"" } },
      ))
    • Creates a module from Blob

      Parameters

      • source: Blob

      Returns Module

      const file = $("#file-upload").files[0] // File is subclass of Blob
      const frx = new Module(file)

    Methods

    • Creates a module by preloading it from Url

      Parameters

      Returns Promise<Module>

      const frx = await Module.preload("/path/to/face_tracker.zip")
      
      // with a progress listener
      const onProgress = ({ total, transferred }) => {
      console.log(`Module is loaded on ${100 * transferred / total}%`)
      }
      const frx = await Module.preload("/path/to/face_tracker.zip", { onProgress })
    • Creates an array of modules by preloading them from a list of Urls

      Parameters

      Returns Promise<Module[]>

      const [frx, background] = await Module.preload(["modules/face_tracker.zip", "modules/background.zip"])
      
      // with a progress listener
      const onProgress = (effectIndex, { total, transferred }) => {
      console.log(`Module #${effectIndex} is loaded on ${100 * transferred / total}%`)
      }
      const [frx, background] = await Module.preload(
      ["effects/face_tracker.zip", "effects/background.zip"],
      { onProgress },
      )