ExperimentalReadonly ExperimentalcanCheck if there is any back history on the web stack.
Readonly ExperimentalcanCheck if there is any forward history on the web stack.
Readonly ExperimentalonThis 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.
ExperimentalReturns a Promise that resolves once this Provider has finished loading its resource.
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.
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());
ExperimentalReturns the texture's aspect ratio, which is calculated as width / height.
ExperimentalReturns the height of the texture in pixels.
ExperimentalStaticgetExperimentalReturns the name of this object's type.
ExperimentalReturns the width of the texture in pixels.
ExperimentalReturns true if the object matches or derives from the passed in type.
ExperimentalReturns true if this object is the same as other. Useful for checking if two references point to the same thing.
ExperimentalTouch will allow the lens creator to pass input events from the Lens to the WebView.
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.
WebPageTextureProvider is the associated texture control that can be accessed from the
texture.controlproperty. This allows you to call functions such asloadUrl(“https://snap.com”)or to pass input events to.Note: Most functionality will require the
onReadyevent to have been called. Any calls before this event may cause an exception.See
RemoteServiceModule#createWebView
Snap OS
Example