用于承载ARViewContext,实现AR场景可视化呈现。
需要与arViewController配合一起使用,完成AR场景的可视化呈现。
模型约束: 此接口仅可在Stage模型下使用。
系统能力: SystemCapability.AREngine.Core
起始版本: 5.1.0(18)
该类为AR场景可视化呈现组件。
装饰器类型: @Component
模型约束: 此接口仅可在Stage模型下使用。
系统能力: SystemCapability.AREngine.Core
起始版本: 5.1.0(18)
参数:
| 名称 | 类型 | 必填 | 装饰器类型 | 说明 |
|---|---|---|---|---|
| context | arViewController.ARViewContext | 是 | @Require @State | ARView上下文、AR会话和场景的状态管理。 |
build(): void
用于构建ARView组件的UI结构。
模型约束: 此接口仅可在Stage模型下使用。
系统能力: SystemCapability.AREngine.Core
设备行为差异: 该接口在部分Phone、部分Tablet、TV中可正常调用,在不支持的设备中无法正常调用。可使用arViewController.isARTypeSupported接口查询能力是否支持。
起始版本: 5.1.0(18)
示例:
import { ARView, arViewController } from '@kit.AREngine';
let arContext: arViewController.ARViewContext = new arViewController.ARViewContext();
@Entry
@Component
struct ARWorld {
// context配置及初始化
build() {
RelativeContainer() {
let ret :boolean = arViewController.isARTypeSupported(arEngine.ARFeatureType.ARENGINE_FEATURE_TYPE_SLAM);
if (arContext && ret) {
ARView({ context: arContext })
.height('100%')
.width('100%')
}
}
}
}