Table of Contents

Plane AR tracker exception handling

This article describes how to handle exceptions of the WeChat plane AR tracker by registering callbacks.

Before you begin

Why plane detection exceptions occur

In specific cases, such as a large white wall appearing in the view or the camera being blocked for a long time, the WeChat plane AR tracker may enter an abnormal state.

At this time, the plane AR tracker cannot normally output the camera pose for each frame, namely 6DoF data, which causes MegaTracker to stop working.

After the view returns to normal, with rich texture and the camera not blocked, for a period of time, the plane AR tracker will resume working, and MegaTracker will also resume working.

Set behavior when plane detection is abnormal

Register an exception handling callback through setPlaneDetectionErrorBehavior(behavior). When an exception is detected, this callback will be triggered, and developers can implement custom prompts, hide 3D content, or perform other handling logic in it.

session.setPlaneDetectionErrorBehavior(() => {
    wx.showToast({
        icon: 'none',
        title: `微信平面检测结果异常,请将相机对着平面来回移动以恢复跟踪`,
        duration: 2000,
    });
});

In this example, the setPlaneDetectionErrorBehavior(behavior) interface of session is used to register a callback that pops up a Toast window, which is triggered when plane detection is abnormal.