目录

ARView (AR Scene Visualization)

Carries ARViewContext to implement AR scene visualization.

It must be used together with arViewController to implement AR scene visualization.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.AREngine.Core

Since: 5.1.0(18)

Modules to Import

import { ARView, arViewController } from '@kit.AREngine';

ARView

This class is a visual display component for AR scenes.

Decorator: @Component

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.AREngine.Core

Since: 5.1.0(18)

Parameters:

Name Type Mandatory Decorator Type Description
context arViewController.ARViewContext Yes

@Require

@State

Manages the ARView context, AR session, and scene status.

[h2]build

build(): void

Constructor used to create an ARView object.

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.AREngine.Core

Device behavior differences: This API can be properly called on some phones, tablets, and TVs, but cannot be called on devices that do not support this API. You can use the arViewController.isARTypeSupported API to check whether the capability is supported.

Since: 5.1.0(18)

Example:

import { ARView, arViewController } from '@kit.AREngine';

let arContext: arViewController.ARViewContext = new arViewController.ARViewContext();

@Entry
@Component
struct ARWorld {
  // Configure and initialize context.
  build() {
    RelativeContainer() {
      if (arContext) {
        ARView({ context: arContext })
          .height('100%')
          .width('100%')
      }
    }
  }
}