Skip to main content

Webview.open

Webview.open(options) creates a new webview and returns a Webview instance.

static async open(options: WebviewOpenOptions): Promise<Webview>

Parameters

ParameterTypeDescription
optionsWebviewOpenOptionsConfiguration for the webview

WebviewOpenOptions

FieldTypeDefaultDescription
sourceWebviewSource--What to display (required)
sizeVec2--Dimensions in 3D world space (e.g., [0.7, 0.7])
viewportSizeVec2--HTML pixel dimensions (e.g., [800, 600])
offsetVec2--Position relative to linked VRM or world origin
linkedVrmnumber--Entity ID of the VRM to attach to

Returns

A Promise that resolves to a new Webview instance.

Examples

Open a webview displaying a mod's local HTML asset:

const webview = await Webview.open({
source: webviewSource.local("my-mod:ui"),
size: [0.7, 0.7],
viewportSize: [800, 600],
offset: [0, 0.5],
});

Link a webview to a VRM character so it follows the character's position:

const vrm = await Vrm.findByName("MyAvatar");
const webview = await Webview.open({
source: webviewSource.local("my-mod:ui"),
size: [1, 0.9],
viewportSize: [900, 700],
offset: [1.1, 0],
linkedVrm: vrm.entity,
});