Preparing search index...

    Class WebPageTextureProviderExperimental

    WebPageTextureProvider is the associated texture control that can be accessed from the texture.control property. This allows you to call functions such as loadUrl(“https://snap.com”) or to pass input events to.

    Note: Most functionality will require the onReady event to have been called. Any calls before this event may cause an exception.

    // Create the options
    var resolution = new vec2(512, 512);
    var options = RemoteServiceModule.createWebViewOptions(resolution);
    const resolution = new vec2(512, 512)
    const options = RemoteServiceModule.createWebViewOptions(resolution)

    this.remoteServiceModule.createWebView(
    options,
    (texture: Asset.Texutre) => {
    this.image.mainPass.baseTex = texture
    this.webViewControl = texture.control
    this.webViewControl.onReady.add(() => {
    print("onReady")
    this.webViewControl.loadUrl("https://snap.com")
    })
    },
    (msg: string) => {
    print(`Error: ${msg}`)
    }
    )

    Hierarchy (View Summary)

    Index

    Properties

    canGoBack: boolean

    Check if there is any back history on the web stack.

    canGoForward: boolean

    Check if there is any forward history on the web stack.

    onReady: event0<void>

    This event signals that the webview is ready for performing actions such as loadUrl, etc. This also is when the WebView should be visible on the Texture that was originally provided.

    Methods

    • Experimental

      Returns a Promise that resolves once this Provider has finished loading its resource.

      Returns Promise<void>

      If the Provider is already loaded when ensureLoaded() is called, the returned Promise resolves immediately. Otherwise it resolves once loading completes.

      Completion is determined by the Provider's load status (see Provider.getLoadStatus). Some Providers only become loaded once supporting runtime data is available — for example, a Provider whose resource depends on tracking will not report loaded until the relevant tracking data has arrived — so the returned Promise stays pending until that data is produced.

      This method is useful when Lens script needs to await a Provider before reading its data — for example, waiting for a remote-asset Provider to finish downloading before sampling it.

      Lens Scripting Version 370

      Fetch a Texture at runtime via RemoteMediaModule and wait for its Provider to finish loading before using it:

      const internetModule = require("LensStudio:InternetModule");
      const remoteMediaModule = require("LensStudio:RemoteMediaModule");

      function loadImageTexture(url) {
      const resource = internetModule.makeResourceFromUrl(url);
      return new Promise((resolve, reject) => {
      remoteMediaModule.loadResourceAsImageTexture(resource, resolve, reject);
      });
      }

      const texture = await loadImageTexture("https://example.com/image.png");

      // Wait until the fetched Texture's Provider has finished loading before using it.
      await texture.control.ensureLoaded();
      print("Texture ready, loadStatus: " + texture.control.getLoadStatus());
    • Experimental

      Returns the texture's aspect ratio, which is calculated as width / height.

      Returns number

    • Experimental

      Returns the height of the texture in pixels.

      Returns number

    • Experimental

      Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

      Returns string

    • Experimental

      Get the current user-agent for the webview.

      Returns string

    • Experimental

      Returns the width of the texture in pixels.

      Returns number

    • Experimental

      Navigate back in the web history.

      Returns void

    • Experimental

      Navigate forward in the web history.

      Returns void

    • Experimental

      Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Experimental

      Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Experimental

      Request a url to be loaded.

      Parameters

      • url: string

      Returns void

    • Experimental

      Request the current page to be reloaded.

      Returns void

    • Experimental

      Set a custom user-agent for the webview.

      Note: By default all webview’s will have the same user-agent set by the platform. This can be used to target Spectacles specific websites.

      Parameters

      • userAgent: string

      Returns void

    • Experimental

      Request the current page loading to stop.

      Note: Has no effect if the page is already loaded.

      Note: Does not stop scripts on the webpage.

      Returns void

    • Experimental

      Touch will allow the lens creator to pass input events from the Lens to the WebView.

      • id: of the touch (in the case of multi-finger, etc), for continuous interactions it is required they share the same id.
      • state: What type of action is preformed.
      • x: the x coordinate of the touch, in WebView space (2d).
      • y: the Y coordinate of the touch, in WebView space (2d).

      Note: Using the WebView from the Asset Library will have already implemented this logic with SIK and Hand Tracking and Mobile Controller and it is not expected for creators to re-implement this handling unless they wish to provide further customization and options.

      Parameters

      Returns void