-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathargon-aframe.js
3020 lines (2344 loc) · 85.3 KB
/
argon-aframe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
__webpack_require__(1);
__webpack_require__(6);
__webpack_require__(7);
__webpack_require__(8);
__webpack_require__(9);
__webpack_require__(10);
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var AEntity = AFRAME.AEntity;
var ANode = AFRAME.ANode;
var constants = __webpack_require__(2);
var AR_CAMERA_ATTR = "data-aframe-argon-camera";
var style = document.createElement("style");
style.type = 'text/css';
document.head.insertBefore(style, document.head.firstChild);
var sheet = style.sheet;
sheet.insertRule('ar-scene {\n' +
' display: block;\n' +
' overflow: hidden;\n' +
' position: relative;\n' +
' height: 100%;\n' +
' width: 100%;\n' +
'}\n', 0);
sheet.insertRule('\n' +
'ar-scene video,\n' +
'ar-scene img,\n' +
'ar-scene audio {\n' +
' display: none;\n' +
'}\n', 1);
// want to know when the document is loaded
document.DOMReady = function () {
return new Promise(function(resolve, reject) {
if (document.readyState != 'loading') {
resolve(document);
} else {
document.addEventListener('DOMContentLoaded', function() {
resolve(document);
});
}
});
};
var camEntityInv = new THREE.Matrix4();
AFRAME.registerElement('ar-scene', {
prototype: Object.create(AEntity.prototype, {
defaultComponents: {
value: {
'canvas': '',
'inspector': '',
'keyboard-shortcuts': ''
}
},
createdCallback: {
value: function () {
this.isMobile = AFRAME.utils.isMobile();
this.isIOS = AFRAME.utils.isIOS();
this.isScene = true;
this.isArgon = true;
this.object3D = new THREE.Scene();
this.systems = {};
this.time = 0;
this.argonApp = null;
this.renderer = null;
this.canvas = null;
this.session = null;
// finish initializing
this.init();
}
},
init: {
value: function () {
this.behaviors = [];
this.hasLoaded = false;
this.isPlaying = false;
this.originalHTML = this.innerHTML;
// let's initialize argon immediately, but wait till the document is
// loaded to set up the DOM parts.
//
// Check if Argon is already initialized, don't call init() again if so
if (!Argon.ArgonSystem.instance) {
this.argonApp = Argon.init(this);
} else {
this.argonApp = Argon.ArgonSystem.instance;
}
this.enableHighAccuracy = false;
//this.argonApp.context.defaultReferenceFrame = this.argonApp.context.localOriginEastUpSouth;
this.argonRender = this.argonRender.bind(this);
this.argonUpdate = this.argonUpdate.bind(this);
this.argonPresentChange = this.argonPresentChange.bind(this);
this.argonChangeReality = this.argonChangeReality.bind(this);
this.argonSessionChange = this.argonSessionChange.bind(this);
this.argonApp.reality.changeEvent.addEventListener(this.argonChangeReality);
this.argonApp.reality.connectEvent.addEventListener(this.argonSessionChange);
this.initializeArgonView = this.initializeArgonView.bind(this);
this.argonPresentChange();
this.addEventListener('render-target-loaded', function () {
this.setupRenderer();
// run this whenever the document is loaded, which might be now
document.DOMReady().then(this.initializeArgonView);
});
},
writable: true
},
setupRenderer: {
value: function () {
var canvas = this.canvas;
// Set at startup. To enable/disable antialias and logarithmicdepthbuffer
// at runttime we would have to recreate the whole context
var antialias = this.getAttribute('antialias') === 'true';
var logarithmicDepthBuffer = this.getAttribute('logarithmicdepth') === 'true';
if (THREE.CSS3DArgonRenderer) {
this.cssRenderer = new THREE.CSS3DArgonRenderer();
} else {
this.cssRenderer = null;
}
if (THREE.CSS3DArgonHUD) {
this.hud = new THREE.CSS3DArgonHUD();
} else {
this.hud = null;
}
this.renderer = new THREE.WebGLRenderer({
canvas: canvas,
alpha: true,
antialias: antialias || window.hasNativeWebVRImplementation,
logarithmicDepthBuffer: logarithmicDepthBuffer
});
this.renderer.setPixelRatio(window.devicePixelRatio);
},
writable: true
},
initializeArgonView: {
value: function () {
// need to do this AFTER the DOM is initialized because
// the argon div may not be created yet, which will pull these
// elements out of the DOM, when they might be needed
var layers = [ { source: this.renderer.domElement }];
if (this.cssRenderer) {
layers.push( { source: this.cssRenderer.domElement })
}
if (this.hud) {
layers.push( { source: this.hud.domElement })
}
// set the layers of our view
this.argonApp.view.setLayers(layers);
this.argonPresentChange();
this.emit('argon-initialized', {
target: this.argonApp
});
},
writable: true
},
subscribeGeolocation: {
value: function () {
this.argonApp.context.subscribeGeolocation({enableHighAccuracy: this.enableHighAccuracy});
}
},
/**
* Handler attached to elements to help scene know when to kick off.
* Scene waits for all entities to load.
*/
attachedCallback: {
value: function () {
this.initSystems();
this.play();
// Add to scene index.
AFRAME.scenes.push(this);
},
writable: window.debug
},
addEventListeners: {
value: function () {
this.argonApp.renderEvent.addEventListener(this.argonRender);
this.argonApp.updateEvent.addEventListener(this.argonUpdate);
this.argonApp.device.presentHMDChangeEvent.addEventListener(this.argonPresentChange);
},
writable: true
},
argonSessionChange: {
value: function (session) {
this.session = session;
},
writable: true
},
setStageGeolocation: {
value: function(place) {
if (this.session) {
return this.argonApp.reality.setStageGeolocation(this.session, place);
}
return undefined;
},
writable: true
},
resetStageGeolocation: {
value: function() {
if (this.session) {
return this.argonApp.reality.resetStageGeolocation(this.session);
}
return undefined;
},
writable: true
},
argonChangeReality: {
value: function () {
// for now, we just revisit the presentation setup
this.argonPresentChange();
},
writable: true
},
argonPresentChange: {
value: function () {
var device = this.argonApp.device;
var reality = this.argonApp.reality;
var visible = false;
// AFrame already uses "vr-mode" to mean "isPresenting()" in WebVR, which means either
// presenting on an HMD in WebVR, or on mobile w/ cardboard and the WebVR Polyfill
//
// While this isn't exactly what we want, we'll assume that this means "presenting in an HMD"
// We'll add "AR" to signify that there is a version of Reality showing behind the content.
// Again, while not precisely correct, it is ok.
console.log("-- checking presentation mode: " + (this.is('vr-mode')? "vr": "-") + (this.is('ar-mode')? " ar": " "))
if (device.isPresentingHMD) {
if (!this.is('vr-mode')) {
this.addState('vr-mode');
console.log('>> enter vr-mode');
this.emit('enter-vr', {target: this});
}
// if we're in HMD mode, we determine AR mode from isPresentingRealityHMD
if (device.isPresentingRealityHMD) {
if (!this.is('ar-mode')) {
this.addState('ar-mode');
console.log('>> enter ar-mode');
this.emit('enter-ar', {target: this});
}
} else {
if (this.is('ar-mode')) {
this.removeState('ar-mode');
console.log('<< exit ar-mode');
this.emit('exit-ar', {target: this});
}
}
} else {
if (this.is('vr-mode')) {
this.removeState('vr-mode');
console.log('<< exit vr-mode');
this.emit('exit-vr', {target: this});
}
// if we're not in HMD mode, we determine AR mode based on the current reality.
// the "empty" reality is not considered AR, which is the default reality on a
// browser than isn't see-through or can't display live video
if (reality.current != Argon.RealityViewer.EMPTY) {
if (!this.is('ar-mode')) {
this.addState('ar-mode');
console.log('>> enter ar-mode');
this.emit('enter-ar', {target: this});
}
} else {
if (this.is('ar-mode')) {
this.removeState('ar-mode');
console.log('<< exit ar-mode');
this.emit('exit-ar', {target: this});
}
}
}
},
writable: true
},
removeEventListeners: {
value: function () {
this.argonApp.updateEvent.removeEventListener(this.argonUpdate);
this.argonApp.renderEvent.removeEventListener(this.argonRender);
this.argonApp.device.presentChangeEvent.removeEventListener(this.argonPresentChange);
},
writable: true
},
play: {
value: function () {
var self = this;
if (this.renderStarted) {
AEntity.prototype.play.call(this);
return;
}
this.addEventListener('loaded', function () {
if (this.renderStarted) { return; }
// only do this once!
this.renderStarted = true;
var fixCamera = function () {
var arCameraEl = null;
var cameraEls = self.querySelectorAll('[camera]');
for (i = 0; i < cameraEls.length; i++) {
cameraEl = cameraEls[i];
if (cameraEl.tagName === "AR-CAMERA") {
arCameraEl = cameraEl;
continue;
}
// work around the issue where if this entity was added during
// this sequence of loaded listeners, it will not yet have had
// it's attachedCallback called, which means sceneEl won't yet
// have been added in a-node.js. When it's eventually added,
// a-node will fire nodeready.
if (cameraEl.sceneEl) {
cameraEl.setAttribute('camera', 'active', false);
cameraEl.pause();
} else {
// wrap cameraToDeactivate so it's a separate variable each time
// through this loop
var listener = (function () {
var cameraToDeactivate = cameraEl;
return function() {
cameraToDeactivate.setAttribute('camera', 'active', false);
cameraToDeactivate.pause();
}})();
cameraEl.addEventListener('nodeready', listener);
}
}
if (arCameraEl == null) {
var defaultCameraEl = document.createElement('ar-camera');
defaultCameraEl.setAttribute(AR_CAMERA_ATTR, '');
defaultCameraEl.setAttribute(constants.AFRAME_INJECTED, '');
self.appendChild(defaultCameraEl);
}
}
// if there are any cameras aside from the AR-CAMERA loaded,
// make them inactive.
this.addEventListener('camera-set-active', fixCamera);
fixCamera();
if (this.argonApp) {
self.addEventListeners();
} else {
this.addEventListener('argon-initialized', function() {
self.addEventListeners();
});
}
AEntity.prototype.play.call(this);
if (window.performance) {
window.performance.mark('render-started');
}
this.emit('renderstart');
});
// setTimeout to wait for all nodes to attach and run their callbacks.
setTimeout(function () {
AEntity.prototype.load.call(self);
});
}
},
/**
* Shuts down scene on detach.
*/
detachedCallback: {
value: function () {
var sceneIndex;
if (this.animationFrameID) {
cancelAnimationFrame(this.animationFrameID);
this.animationFrameID = null;
}
this.argonApp.reality.changeEvent.removeEventListener(this.argonChangeReality);
this.argonApp.reality.connectEvent.removeEventListener(this.argonSessionChange);
this.removeEventListeners();
// Remove from scene index.
sceneIndex = scenes.indexOf(this);
scenes.splice(sceneIndex, 1);
}
},
/**
* Reload the scene to the original DOM content.
*
* @param {bool} doPause - Whether to reload the scene with all dynamic behavior paused.
*/
reload: {
value: function (doPause) {
var self = this;
if (doPause) { this.pause(); }
this.innerHTML = this.originalHTML;
this.init();
ANode.prototype.load.call(this, play);
function play () {
if (!self.isPlaying) { return; }
AEntity.prototype.play.call(self);
}
}
},
/**
* Behavior-updater meant to be called from scene render.
* Abstracted to a different function to facilitate unit testing (`scene.tick()`) without
* needing to render.
*/
argonUpdate: {
value: function (frame) {
var time = frame.timestamp;
var timeDelta = frame.deltaTime;
if (this.isPlaying) {
this.tick(time, timeDelta);
}
this.time = time;
},
writable: true
},
tick: {
value: function (time, timeDelta) {
var systems = this.systems;
// Animations.
TWEEN.update(time);
// Components.
this.behaviors.forEach(function (component) {
if (!component.el.isPlaying) { return; }
component.tick(time, timeDelta);
});
// Systems.
Object.keys(systems).forEach(function (key) {
if (!systems[key].tick) { return; }
systems[key].tick(time, timeDelta);
});
}
},
enterVR: {
value: function (event) {
var self = this;
// Don't enter VR if already in VR.
if (this.is('vr-mode')) { return Promise.resolve('Already in VR.'); }
// why would this get called before init? Dunno, but there was an instance
if (this.argonApp) {
return this.argonApp.device.requestEnterHMD(enterVRSuccess, enterVRFailure);
}
function enterVRSuccess () {
self.addState('vr-mode');
self.emit('enter-vr', event);
}
function enterVRFailure (err) {
if (err && err.message) {
throw new Error('Failed to enter VR mode (`argonApp.device.requestEnterHMD`): ' + err.message);
} else {
throw new Error('Failed to enter VR mode (`argonApp.device.requestEnterHMD`).');
}
}
}
},
exitVR: {
value: function () {
var self = this;
// Don't exit VR if not in VR.
if (!this.is('vr-mode')) { return Promise.resolve('Not in VR.'); }
// why would this get called before init? Dunno, but there was an instance
if (this.argonApp) {
return this.argonApp.device.requestEnterHMD(exitVRSuccess, exitVRFailure);
}
function exitVRSuccess () {
self.removeState('vr-mode');
self.emit('exit-vr', {target: self});
}
function exitVRFailure (err) {
if (err && err.message) {
throw new Error('Failed to exit VR mode (`exitPresent`): ' + err.message);
} else {
throw new Error('Failed to exit VR mode (`exitPresent`).');
}
}
}
},
/**
* The render loop.
*
* Updates animations.
* Updates behaviors.
* Renders with request animation frame.
*/
argonRender: {
value: function (frame) {
var camera = this.camera;
var renderer = this.renderer;
if (!renderer || !camera) {
// renderer hasn't been setup yet
this.animationFrameID = null;
return;
}
var app = this.argonApp;
var scene = this.object3D;
var cssRenderer = this.cssRenderer;
var hud = this.hud;
// the camera object is created from a camera property on an entity. This should be
// an ar-camera, which will have the entity position and orientation set to the pose
// of the user. We want to make the camera pose
//var camEntityPos = null;
//var camEntityRot = null;
//var camEntityInv = new THREE.Matrix4();
if (camera.parent) {
camera.parent.updateMatrixWorld();
camEntityInv.getInverse(camera.parent.matrixWorld);
// camEntityPos = camera.parent.position.clone().negate();
// camEntityRot = camera.parent.quaternion.clone().inverse();
}
const view = app.view;
renderer.setSize(view.renderWidth, view.renderHeight, false);
var viewport = view.viewport;
if (this.cssRenderer) {
cssRenderer.setSize(viewport.width, viewport.height);
}
if (this.hud) {
hud.setSize(viewport.width, viewport.height);
}
// leverage vr-mode. Question: perhaps we shouldn't, perhaps we should use ar-mode?
// unclear right now how much of the components that use vr-mode are re-purposable
//var _a = app.view.getSubviews();
var _a = app.view.subviews;
// if (this.is('vr-mode')) {
// if (_a.length == 1 && this.is('vr-mode')) {
// this.removeState('vr-mode');
// this.emit('exit-vr', {target: this});
// }
// } else {
// if (_a.length > 1 && !this.is('vr-mode')) {
// this.addState('vr-mode');
// this.emit('enter-vr', {target: this});
// }
// }
if (this.is('vr-mode')) {
if (_a.length == 1) {
console.log("calling presentChange from render, because vr-mode is set and view is mono");
this.argonPresentChange();
}
} else {
if (_a.length > 1) {
console.log("calling presentChange from render, because vr-mode not set and view is stereo");
this.argonPresentChange();
}
}
// set the camera properties to the values of the 1st subview.
// While this is arbitrary, it's likely many of these will be the same
// across all subviews, and it's better than leaving them at the
// defaults, which are almost certainly incorrect
camera.near = _a[0].frustum.near;
camera.far = _a[0].frustum.far;
camera.aspect = _a[0].frustum.aspect;
// if the viewport width and the renderwidth are different
// we assume we are rendering on a different surface than
// the main display, so we reset the pixel ratio to 1
if (viewport.width != view.renderWidth) {
renderer.setPixelRatio(1);
} else {
renderer.setPixelRatio(window.devicePixelRatio);
}
// there is 1 subview in monocular mode, 2 in stereo mode
for (var _i = 0; _i < _a.length; _i++) {
var subview = _a[_i];
var frustum = subview.frustum;
// set the position and orientation of the camera for
// this subview
camera.position.copy(subview.pose.position);
//if (camEntityPos) { camera.position.add(camEntityPos); }
camera.quaternion.copy(subview.pose.orientation);
//if (camEntityRot) { camera.quaternion.multiply(camEntityRot); }
camera.updateMatrix();
camera.matrix.premultiply(camEntityInv);
camera.matrix.decompose(camera.position, camera.quaternion, camera.scale );
// the underlying system provide a full projection matrix
// for the camera.
camera.projectionMatrix.fromArray(subview.projectionMatrix);
// set the viewport for this view
var _b = subview.viewport, x = _b.x, y = _b.y, width = _b.width, height = _b.height;
// set the CSS rendering up, by computing the FOV, and render this view
if (this.cssRenderer) {
//cssRenderer.updateCameraFOVFromProjection(camera);
camera.fov = THREE.Math.radToDeg(frustum.fovy);
cssRenderer.setViewport(x, y, width, height, subview.index);
cssRenderer.render(scene, camera, subview.index);
}
if (this.hud) {
// adjust the hud
hud.setViewport(x, y, width, height, subview.index);
hud.render(subview.index);
}
// set the webGL rendering parameters and render this view
// set the viewport for this view
var _c = subview.renderViewport, x = _c.x, y = _c.y, width = _c.width, height = _c.height;
renderer.setViewport(x, y, width, height);
renderer.setScissor(x, y, width, height);
renderer.setScissorTest(true);
renderer.render(scene, camera);
}
this.animationFrameID = null;
},
writable: true
},
/**
* Some mundane functions below here
*/
initSystems: {
value: function () {
var systemsKeys = Object.keys(AFRAME.systems);
systemsKeys.forEach(this.initSystem.bind(this));
}
},
initSystem: {
value: function (name) {
var system;
if (this.systems[name]) { return; }
system = this.systems[name] = new AFRAME.systems[name](this);
system.init();
}
},
/**
* @param {object} behavior - Generally a component. Must implement a .update() method to
* be called on every tick.
*/
addBehavior: {
value: function (behavior) {
var behaviors = this.behaviors;
if (behaviors.indexOf(behavior) !== -1) { return; }
behaviors.push(behavior);
}
},
/**
* Wraps Entity.getAttribute to take into account for systems.
* If system exists, then return system data rather than possible component data.
*/
getAttribute: {
value: function (attr) {
var system = this.systems[attr];
if (system) { return system.data; }
return AEntity.prototype.getAttribute.call(this, attr);
}
},
/**
* `getAttribute` used to be `getDOMAttribute` and `getComputedAttribute` used to be
* what `getAttribute` is now. Now legacy code.
*/
getComputedAttribute: {
value: function (attr) {
warn('`getComputedAttribute` is deprecated. Use `getAttribute` instead.');
this.getAttribute(attr);
}
},
/**
* Wraps Entity.getDOMAttribute to take into account for systems.
* If system exists, then return system data rather than possible component data.
*/
getDOMAttribute: {
value: function (attr) {
var system = this.systems[attr];
if (system) { return system.data; }
return AEntity.prototype.getDOMAttribute.call(this, attr);
}
},
/**
* Wraps Entity.setAttribute to take into account for systems.
* If system exists, then skip component initialization checks and do a normal
* setAttribute.
*/
setAttribute: {
value: function (attr, value, componentPropValue) {
var system = this.systems[attr];
if (system) {
ANode.prototype.setAttribute.call(this, attr, value);
return;
}
AEntity.prototype.setAttribute.call(this, attr, value, componentPropValue);
}
},
/**
* @param {object} behavior - Generally a component. Has registered itself to behaviors.
*/
removeBehavior: {
value: function (behavior) {
var behaviors = this.behaviors;
var index = behaviors.indexOf(behavior);
if (index === -1) { return; }
behaviors.splice(index, 1);
}
},
resize: {
value: function () {
// don't need to do anything, just don't want components who call this to fail
},
writable: window.debug
}
})
});
AFRAME.registerPrimitive('ar-camera', {
defaultComponents: {
camera: {active: true},
referenceframe: {parent: 'ar.user'}
}
});
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
AFRAME_INJECTED: 'aframe-injected',
DEFAULT_CAMERA_HEIGHT: 1.6,
animation: __webpack_require__(3),
keyboardevent: __webpack_require__(5)
};
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Animation configuration options for TWEEN.js animations.
* Used by `<a-animation>`.
*/
var TWEEN = __webpack_require__(4);
var DIRECTIONS = {
alternate: 'alternate',
alternateReverse: 'alternate-reverse',
normal: 'normal',
reverse: 'reverse'
};
var EASING_FUNCTIONS = {
'linear': TWEEN.Easing.Linear.None,
'ease': TWEEN.Easing.Cubic.InOut,
'ease-in': TWEEN.Easing.Cubic.In,
'ease-out': TWEEN.Easing.Cubic.Out,
'ease-in-out': TWEEN.Easing.Cubic.InOut,
'ease-cubic': TWEEN.Easing.Cubic.In,
'ease-in-cubic': TWEEN.Easing.Cubic.In,
'ease-out-cubic': TWEEN.Easing.Cubic.Out,
'ease-in-out-cubic': TWEEN.Easing.Cubic.InOut,
'ease-quad': TWEEN.Easing.Quadratic.InOut,
'ease-in-quad': TWEEN.Easing.Quadratic.In,
'ease-out-quad': TWEEN.Easing.Quadratic.Out,
'ease-in-out-quad': TWEEN.Easing.Quadratic.InOut,
'ease-quart': TWEEN.Easing.Quartic.InOut,
'ease-in-quart': TWEEN.Easing.Quartic.In,
'ease-out-quart': TWEEN.Easing.Quartic.Out,
'ease-in-out-quart': TWEEN.Easing.Quartic.InOut,
'ease-quint': TWEEN.Easing.Quintic.InOut,
'ease-in-quint': TWEEN.Easing.Quintic.In,
'ease-out-quint': TWEEN.Easing.Quintic.Out,
'ease-in-out-quint': TWEEN.Easing.Quintic.InOut,
'ease-sine': TWEEN.Easing.Sinusoidal.InOut,
'ease-in-sine': TWEEN.Easing.Sinusoidal.In,
'ease-out-sine': TWEEN.Easing.Sinusoidal.Out,
'ease-in-out-sine': TWEEN.Easing.Sinusoidal.InOut,
'ease-expo': TWEEN.Easing.Exponential.InOut,
'ease-in-expo': TWEEN.Easing.Exponential.In,
'ease-out-expo': TWEEN.Easing.Exponential.Out,
'ease-in-out-expo': TWEEN.Easing.Exponential.InOut,
'ease-circ': TWEEN.Easing.Circular.InOut,
'ease-in-circ': TWEEN.Easing.Circular.In,
'ease-out-circ': TWEEN.Easing.Circular.Out,
'ease-in-out-circ': TWEEN.Easing.Circular.InOut,
'ease-elastic': TWEEN.Easing.Elastic.InOut,
'ease-in-elastic': TWEEN.Easing.Elastic.In,
'ease-out-elastic': TWEEN.Easing.Elastic.Out,
'ease-in-out-elastic': TWEEN.Easing.Elastic.InOut,
'ease-back': TWEEN.Easing.Back.InOut,
'ease-in-back': TWEEN.Easing.Back.In,
'ease-out-back': TWEEN.Easing.Back.Out,
'ease-in-out-back': TWEEN.Easing.Back.InOut,
'ease-bounce': TWEEN.Easing.Bounce.InOut,
'ease-in-bounce': TWEEN.Easing.Bounce.In,
'ease-out-bounce': TWEEN.Easing.Bounce.Out,
'ease-in-out-bounce': TWEEN.Easing.Bounce.InOut
};
var FILLS = {
backwards: 'backwards',
both: 'both',
forwards: 'forwards',
none: 'none'
};
var REPEATS = {
indefinite: 'indefinite'
};
var DEFAULTS = {
attribute: 'rotation',
begin: '',
end: '',
delay: 0,
dur: 1000,
easing: 'ease',
direction: DIRECTIONS.normal,
fill: FILLS.forwards,
from: undefined,
repeat: 0,
to: undefined
};
module.exports.defaults = DEFAULTS;
module.exports.directions = DIRECTIONS;
module.exports.easingFunctions = EASING_FUNCTIONS;
module.exports.fills = FILLS;
module.exports.repeats = REPEATS;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/**
* Tween.js - Licensed under the MIT license
* https://github.com/sole/tween.js
* ----------------------------------------------
*
* See https://github.com/sole/tween.js/graphs/contributors for the full list of contributors.
* Thank you all, you're awesome!
*/
// performance.now polyfill
( function ( root ) {
if ( 'performance' in root === false ) {
root.performance = {};
}
// IE 8
Date.now = ( Date.now || function () {
return new Date().getTime();
} );
if ( 'now' in root.performance === false ) {
var offset = root.performance.timing && root.performance.timing.navigationStart ? performance.timing.navigationStart
: Date.now();
root.performance.now = function () {
return Date.now() - offset;
};
}
} )( this );
var TWEEN = TWEEN || ( function () {
var _tweens = [];
return {
REVISION: '14',
getAll: function () {
return _tweens;
},
removeAll: function () {