소스 검색

Add validation and change the initialization

customisations
alemart 11 달 전
부모
커밋
005702ad33
1개의 변경된 파일14개의 추가작업 그리고 6개의 파일을 삭제
  1. 14
    6
      demos/hello-three/demo.js

+ 14
- 6
demos/hello-three/demo.js 파일 보기

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
 (function() {
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
  * Utilities for the Demo scene
15
  * Utilities for the Demo scene
9
  */
16
  */
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
     const scene = new DemoScene();
244
     const scene = new DemoScene();
237
-
238
     encantar(scene);
245
     encantar(scene);
246
+}
239
 
247
 
240
-});
248
+document.addEventListener('DOMContentLoaded', main);
241
 
249
 
242
 })();
250
 })();

Loading…
취소
저장