English
Appearance
English
Appearance
Image AR collections correspond to the image2d-tracking type.
The biggest difference from a single Image AR scene is:
ready first, along with collectionInfo and CollectionApisceneReadytracked / lostTracklostTrack, the collection turns cloud recognition back on to find the next scene to openA typical Image AR collection flow is:
ready and receive collection informationsceneReady and receive the current scene info and its SceneApitracked after the target image is recognizedlostTrack when the target image is lost, and the collection starts cloud recognition again to find the next scene to openIf your host page supports switching to another scene, you will later see another round of:
sceneDestroysceneReadyThe most commonly used events in an Image AR collection exist on two layers:
readysceneReadysceneDestroydownloadAssetProgressloadSceneEndsceneStarttrackedlostTrackYou can think about them like this:
ready means "the collection is ready"sceneReady means "the current concrete scene is ready"tracked / lostTrack describe the recognition state of the current Image AR scenelet collectionApi = null;
let sceneApi = null;
iframe.addEventListener('ready', (event) => {
collectionApi = event.detail.api;
console.log('collection ready', event.detail.collectionInfo);
});
iframe.addEventListener('sceneReady', (event) => {
sceneApi = event.detail.api;
console.log('scene ready', event.detail.sceneInfo);
});
iframe.addEventListener('tracked', () => {
hideScanHint();
});
iframe.addEventListener('lostTrack', () => {
showScanHint();
});An Image AR collection actually contains two layers of "scanning":
trackedSo Image AR collections still show the default scan UI when the current scene needs recognition.
If you use:
hideScan: truethat means the host layer takes over scan guidance completely.
A common pattern is:
ready or loadSceneEndtrackedlostTracklostTrack, the collection usually restarts cloud recognition to search for the next scene that can be openedIf different scenes in the collection use different target images, the host layer should update the guidance based on the current sceneInfo instead of reusing the same copy forever.
Compared with opening a single Image AR scene directly, an Image AR collection is better suited for:
At the same time, keep these extra considerations in mind:
ready fired onceSceneApi every time sceneReady fireslostTrack inside the current scene does not only mean "this scene is temporarily not recognized"; it may also trigger the collection to re-enter the "find the next scene" flowCommon pairings for Image AR collections include:
If you want to control models, images, videos, and other content inside the current scene, obtain the SceneApi in sceneReady and operate on that instead of calling those methods on CollectionApi.
collectionInfo.sceneList in ready to build a clear mental model of which scenes exist in the collection.SceneApi in sceneReady, and do not reuse object handles from the previous scene.lostTrack, both times to find the next scene to open.tracked / lostTrack, and distinguish between "current scene recognition state" and "the collection is searching for the next scene".