MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / CheckAndInstallARCoreAsync

Function CheckAndInstallARCoreAsync

Dependencies/xr/Source/ARCore/XR.cpp:241–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239 }
240
241 arcana::task<void, std::exception_ptr> CheckAndInstallARCoreAsync()
242 {
243 auto task = arcana::task_from_result<std::exception_ptr>();
244
245 // Check if ARCore is already installed.
246 if (!CheckARCoreInstallStatus(false))
247 {
248 arcana::task_completion_source<void, std::exception_ptr> installTcs{};
249
250 // Add a resume callback, which will check if ARCore has been successfully installed upon app resume.
251 auto resumeTicket{AddResumeCallback([installTcs]() mutable {
252 if (!CheckARCoreInstallStatus(false))
253 {
254 // ARCore not installed, throw an error.
255 std::ostringstream message;
256 message << "ARCore not installed.";
257 installTcs.complete(arcana::make_unexpected(make_exception_ptr(std::runtime_error{message.str()})));
258 }
259 else
260 {
261 // ARCore installed successfully, complete the promise.
262 installTcs.complete();
263 }
264 })};
265
266 // Kick off the install request, and set the task for our caller to wait on.
267 CheckARCoreInstallStatus(true);
268 task = installTcs.as_task().then(arcana::inline_scheduler, arcana::cancellation::none(), [resumeTicket = std::move(resumeTicket)](){
269 return;
270 });
271 }
272
273 return task;
274 }
275
276 arcana::task<void, std::exception_ptr> CheckCameraPermissionAsync()
277 {

Callers 1

CreateAsyncMethod · 0.85

Calls 2

CheckARCoreInstallStatusFunction · 0.85
AddResumeCallbackFunction · 0.85

Tested by

no test coverage detected