Przeglądaj źródła

Add validation and change the initialization

customisations
alemart 11 miesięcy temu
rodzic
commit
005702ad33
1 zmienionych plików z 14 dodań i 6 usunięć
  1. 14
    6
      demos/hello-three/demo.js

+ 14
- 6
demos/hello-three/demo.js Wyświetl plik

@@ -1,9 +1,16 @@
1 1
 /**
2
- * Augmented Reality demo with three.js and encantar.js
2
+ * Augmented Reality demo using the three.js plugin for encantar.js
3
+ * https://alemart.github.io/encantar-js/
3 4
  */
4 5
 
5 6
 (function() {
6 7
 
8
+// Validate
9
+if(typeof encantar === 'undefined')
10
+    throw new Error(`Can't find the three.js plugin for encantar.js`);
11
+
12
+
13
+
7 14
 /**
8 15
  * Utilities for the Demo scene
9 16
  */
@@ -229,14 +236,15 @@ class DemoScene extends ARScene
229 236
 
230 237
 
231 238
 /**
232
- * Enchant the Demo scene
239
+ * Enchant the scene
240
+ * @returns {void}
233 241
  */
234
-window.addEventListener('load', () => {
235
-
242
+function main()
243
+{
236 244
     const scene = new DemoScene();
237
-
238 245
     encantar(scene);
246
+}
239 247
 
240
-});
248
+document.addEventListener('DOMContentLoaded', main);
241 249
 
242 250
 })();

Ładowanie…
Anuluj
Zapisz