Просмотр исходного кода

Introduce ARDemo.preload()

customisations
alemart 9 месяцев назад
Родитель
Сommit
18086578f6
2 измененных файлов: 24 добавлений и 6 удалений
  1. 12
    3
      plugins/babylon-with-encantar.js
  2. 12
    3
      plugins/three-with-encantar.js

+ 12
- 3
plugins/babylon-with-encantar.js Просмотреть файл

@@ -56,6 +56,16 @@ class ARDemo
56 56
     {
57 57
         // optional implementation
58 58
     }
59
+
60
+    /**
61
+     * Preload resources before starting the AR session
62
+     * @returns {Promise<void> | SpeedyPromise<void>}
63
+     */
64
+    preload()
65
+    {
66
+        // optional implementation
67
+        return Promise.resolve();
68
+    }
59 69
 }
60 70
 
61 71
 /**
@@ -291,9 +301,8 @@ function encantar(demo)
291 301
     }
292 302
 
293 303
     return Promise.resolve()
294
-    .then(() => {
295
-        return demo.startSession(); // Promise or SpeedyPromise
296
-    })
304
+    .then(() => demo.preload())
305
+    .then(() => demo.startSession()) // Promise or SpeedyPromise
297 306
     .then(session => {
298 307
 
299 308
         ar._session = session;

+ 12
- 3
plugins/three-with-encantar.js Просмотреть файл

@@ -56,6 +56,16 @@ class ARDemo
56 56
     {
57 57
         // optional implementation
58 58
     }
59
+
60
+    /**
61
+     * Preload resources before starting the AR session
62
+     * @returns {Promise<void> | SpeedyPromise<void>}
63
+     */
64
+    preload()
65
+    {
66
+        // optional implementation
67
+        return Promise.resolve();
68
+    }
59 69
 }
60 70
 
61 71
 /**
@@ -275,9 +285,8 @@ function encantar(demo)
275 285
     }
276 286
 
277 287
     return Promise.resolve()
278
-    .then(() => {
279
-        return demo.startSession(); // Promise or SpeedyPromise
280
-    })
288
+    .then(() => demo.preload())
289
+    .then(() => demo.startSession()) // Promise or SpeedyPromise
281 290
     .then(session => {
282 291
 
283 292
         ar._session = session;

Загрузка…
Отмена
Сохранить