AR session concepts and processes on the Mega WeChat Mini Program plugin
This document introduces the concepts and processes 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 functionalities. It manages runtime processes and states: including acquiring data from VisionKit and sensors APIs provided by WeChat, fusing cloud localization with local AR tracker results, driving the movement and rendering of cameras and other objects in the scene, etc.
flowchart LR
Pose(VisionKit camera pose) -- per-frame synchronization --> Session[Session]
Image(Camera image used for pose calculation) -. only sent during Mega localization .-> Session
Sensor(WeChat sensor data) -. asynchronous .-> Session
Session -- Transform --> Camera(xr-frame camera)
AR session flow
flowchart LR
Start((" "))
End((" "))
Init[Initializing]
Run[Running]
Check{Success?}
Start -->|call start| Init
Init --> Check
Check -->|Yes| Run
Check -->|No / Retries exceeded| End
Run -->|call stop| End
Start: session state transitions to Initializing. Includes environment checks, resource loading, and waiting for WeChat xr-frame's AR system readiness.
Running: session state transitions to Running. During this phase, the session outputs tracking results per frame and updates the xr-frame camera's Transform.
Stop: session state transitions to None. Includes resource release, state reset, and destruction of the MegaTracker.
Warning
AR features can only be used after the session successfully starts.
AR session states:
| State | Description |
|---|---|
| None | Initial state, session not started or initialization failed |
| Initializing | During initialization |
| Running | Running state, session started and initialization completed |
[Optional] AR session on WeChat Mini Program plugin vs. AR session in 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 in Unity. Since it does not support simultaneous use of other algorithmic components, the session on the WeChat Mini Program uses pre-integrated data source components and algorithmic components. Users cannot choose data sources and/or assemble algorithmic components.
Additionally, it can be considered that the Mega WeChat Mini Program plugin only supports Blocks as targets and uses target-centric mode.