We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

ARView (AR Scene Visualization)

Phone5.1.0(18)+Tablet5.1.0(18)+TV6.1.0(23)+

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

Phone5.1.0(18)+Tablet5.1.0(18)+TV6.1.0(23)+

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:

Expand
Name Type Mandatory Decorator Type Description
context arViewController.ARViewContext Yes

@Require

@State

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

build

Phone5.1.0(18)+Tablet5.1.0(18)+TV6.1.0(23)+

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%')
      }
    }
  }
}
Search in References
Enter a keyword.