Table of Contents

AR Session Concept and Process on the Mega WeChat Mini Program Plugin

This document introduces the concept and process of the AR Session on the Mega WeChat Mini Program Plugin.

What Is an AR Session

The AR Session provided by the Mega WeChat Mini Program Plugin is the entry point for all AR features. It manages the execution process and state, including obtaining data from VisionKit and the sensor APIs provided by WeChat, fusing cloud positioning with local AR tracker results, driving the movement and rendering of the camera and other objects in the scene, etc.

flowchart LR  
    Pose(VisionKit camera pose) -- Synchronized per frame --> Session[Session]  
    Image(Camera image used for calculating the frame's camera pose) -. Only sent during Mega positioning .-> Session  
    Sensor(WeChat sensor data) -. Asynchronous .-> Session  
    Session -- Transform --> Camera(xr-frame camera)  

AR Session Process

flowchart LR  
    Start((" "))  
    End((" "))  

    Init[Initializing]  
    Run[Running]  

    Check{Success?}  

    Start -->|Call start| Init  
    Init --> Check  

    Check -->|Yes| Run  
    Check -->|No / Retry limit exceeded| End  

    Run -->|Call stop| End  

Start: The session state changes to Initializing. This includes environment checks, resource loading, and waiting for the WeChat xr-frame AR system to be ready.

Running: The session state changes to Running. During this phase, the session outputs tracking results per frame and updates the xr-frame camera's Transform.

Stop: The session state changes to None. This includes releasing resources, resetting the state, and destroying the MegaTracker.

Warning

AR features can only be used after the session has successfully started.

AR Session States:

State Description
None Initial state, session not started or initialization failed
Initializing Initialization in progress
Running Running state, session started and initialization completed

[Optional] AR Session on the WeChat Mini Program Plugin vs. AR Session on Unity

Note

For developers migrating Unity projects only.

The AR Session on the Mega WeChat Mini Program Plugin is a simplified version of the AR Session on Unity. Since other algorithm components cannot be used simultaneously, the AR Session on the WeChat Mini Program uses pre-integrated data source components and algorithm components. Users cannot choose data sources and/or assemble algorithm components.

Additionally, it can be considered that the Mega WeChat Mini Program Plugin only supports using Block as the target and employs a target-centric center mode.

Next Steps