You need to enable JavaScript to run this app.
导航

初始化Web AR SDK

最近更新时间2023.11.21 14:50:49

首次发布时间2023.11.21 14:50:49

这里需要填写「授权证书文件」和「授权服务地址」,如有疑问请联系我们的商务或技术支持。
通过调用 ARSDK.createSession 即可创建一个 ARSession,Web AR SDK 的大部分功能都可以通过操作 ARSession 来实现。

import {
    ARSession,
    ARSDK,
} from "@volcengine/webar";

// 获取之前创建的 canvas.
// Get get canvas element created in the previous step.
const canvas = document.getElementById("preview")! as HTMLCanvasElement;

// 创建 ARSession
// Create an ARSession
const session = ARSDK.createSession({
    canvas,
    authorization: {
        // 你的「授权证书文件」地址或内容:「https 文件链接」或「文件的 Base64 内容」。
        // Your authorization file url or content.
        file: "",
        // 授权服务地址
        // The authorization service endpoint.
        serviceEndpoint: "https://webar.volces.com/api/v2/webardeliver/verify",
    },
});