瀏覽代碼

Update plugin

customisations
alemart 10 月之前
父節點
當前提交
64e195e73a
共有 1 個文件被更改,包括 14 次插入8 次删除
  1. 14
    8
      plugins/aframe-with-encantar.js

+ 14
- 8
plugins/aframe-with-encantar.js 查看文件

110
     {
110
     {
111
         const scene = this.el;
111
         const scene = this.el;
112
 
112
 
113
-        // read trackable pointers
114
-        this.pointers.length = 0;
115
-        if(this.frame) {
116
-            const newPointers = this._utils.getTrackablePointers(this.frame);
117
-            if(newPointers.length > 0)
118
-                this.pointers.push.apply(this.pointers, newPointers);
119
-        }
120
-
121
         // we take control of the rendering
113
         // we take control of the rendering
122
         scene.renderer.setAnimationLoop(null);
114
         scene.renderer.setAnimationLoop(null);
123
 
115
 
216
 
208
 
217
         session.addEventListener('end', () => {
209
         session.addEventListener('end', () => {
218
             this.frame = null;
210
             this.frame = null;
211
+            this.pointers.length = 0;
219
         });
212
         });
220
 
213
 
221
         session.viewport.addEventListener('resize', () => {
214
         session.viewport.addEventListener('resize', () => {
234
 
227
 
235
         scene.object3D.background = null;
228
         scene.object3D.background = null;
236
 
229
 
230
+        // animation loop
237
         const animate = (time, frame) => {
231
         const animate = (time, frame) => {
238
             this.frame = frame;
232
             this.frame = frame;
233
+            this._updateTrackablePointers();
234
+
239
             scene.render();
235
             scene.render();
236
+
240
             session.requestAnimationFrame(animate);
237
             session.requestAnimationFrame(animate);
241
         };
238
         };
242
 
239
 
311
         return sessionComponent.preferences();
308
         return sessionComponent.preferences();
312
     },
309
     },
313
 
310
 
311
+    _updateTrackablePointers()
312
+    {
313
+        this.pointers.length = 0;
314
+
315
+        const newPointers = this._utils.getTrackablePointers(this.frame);
316
+        if(newPointers.length > 0)
317
+            this.pointers.push.apply(this.pointers, newPointers);
318
+    },
319
+
314
 });
320
 });
315
 
321
 
316
 /**
322
 /**

Loading…
取消
儲存