开发文档

快速开始

只需一行代码,即可将 AR 试戴功能集成到你的网站中。

<!-- 引入 AR SDK -->
<script src="https://ar.smmxys.com/sdk/v1.js"></script>

<!-- 初始化 AR 组件 -->
<script>
  SmartAR.init({
    container: '#ar-container',
    apiKey: 'YOUR_API_KEY',
    products: [
      { id: 'ring-001', model: '/models/ring.glb' },
      { id: 'necklace-001', model: '/models/necklace.glb' }
    ]
  });
</script>

配置选项

SmartAR.init() 方法支持以下配置参数:

container: string - AR 容器元素的选择器
apiKey: string - 你的 API Key
products: Array - 产品配置数组
autoStart: boolean - 是否自动启动摄像头
defaultProduct: string - 默认显示的产品ID

API 方法

初始化后,可以通过以下方法控制 AR 组件:

// 切换产品
SmartAR.switchProduct('ring-001');

// 截图
SmartAR.screenshot();

// 销毁实例
SmartAR.destroy();