1 | (function(modules) {
|
2 |
|
3 | var installedModules = {};
|
4 |
|
5 |
|
6 | function __webpack_require__(moduleId) {
|
7 |
|
8 |
|
9 | if(installedModules[moduleId])
|
10 | return installedModules[moduleId].exports;
|
11 |
|
12 |
|
13 | var module = installedModules[moduleId] = {
|
14 | exports: {},
|
15 | id: moduleId,
|
16 | loaded: false
|
17 | };
|
18 |
|
19 |
|
20 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21 |
|
22 |
|
23 | module.loaded = true;
|
24 |
|
25 |
|
26 | return module.exports;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 | __webpack_require__.m = modules;
|
32 |
|
33 |
|
34 | __webpack_require__.c = installedModules;
|
35 |
|
36 |
|
37 | __webpack_require__.p = "";
|
38 |
|
39 |
|
40 | return __webpack_require__(0);
|
41 | })
|
42 |
|
43 | ([
|
44 |
|
45 | (function(module, exports) {
|
46 |
|
47 |
|
48 |
|
49 | if (typeof AFRAME === 'undefined') {
|
50 | throw new Error('Component attempted to register before AFRAME was available.');
|
51 | }
|
52 |
|
53 | |
54 |
|
55 |
|
56 | AFRAME.registerComponent('mirror', {
|
57 | schema: {
|
58 | resolution: { type:'number', default: 128},
|
59 | refraction: { type:'number', default: 0.95},
|
60 | color: {type:'color', default: 0xffffff},
|
61 | distance: {type:'number', default: 3000},
|
62 | interval: { type:'number', default: 1000},
|
63 | repeat: { type:'boolean', default: false}
|
64 | },
|
65 |
|
66 | |
67 |
|
68 |
|
69 | multiple: false,
|
70 |
|
71 | |
72 |
|
73 |
|
74 | init: function(){
|
75 | this.counter = this.data.interval;
|
76 |
|
77 | this.cam = new THREE.CubeCamera( 0.5, this.data.distance, this.data.resolution);
|
78 | this.el.object3D.add( this.cam );
|
79 | this.mirrorMaterial = new THREE.MeshBasicMaterial( { color: this.data.color, refractionRatio: this.data.refraction, envMap: this.cam.renderTarget.texture } );
|
80 | this.done = false;
|
81 | var mirrormat = this.mirrorMaterial;
|
82 | this.mesh = this.el.getObject3D('mesh');
|
83 | if(this.mesh){
|
84 | this.mesh.traverse( function( child ) {
|
85 | if ( child instanceof THREE.Mesh ) child.material = mirrormat;
|
86 | });
|
87 | }
|
88 | },
|
89 |
|
90 | tick: function(t,dt){
|
91 | if(!this.done){
|
92 | if( this.counter > 0){
|
93 | this.counter-=dt;
|
94 | }else{
|
95 | this.mesh = this.el.getObject3D('mesh');
|
96 |
|
97 | if(this.mesh){
|
98 | this.mesh.visible = false;
|
99 | AFRAME.scenes[0].renderer.autoClear = true;
|
100 | this.cam.position.copy(this.el.object3D.worldToLocal(this.el.object3D.getWorldPosition()));
|
101 | this.cam.updateCubeMap( AFRAME.scenes[0].renderer, this.el.sceneEl.object3D );
|
102 |
|
103 | var mirrormat = this.mirrorMaterial;
|
104 | this.mesh.traverse( function( child ) {
|
105 | if ( child instanceof THREE.Mesh ) child.material = mirrormat;
|
106 | });
|
107 | this.mesh.visible = true;
|
108 |
|
109 | if(!this.data.repeat){
|
110 | this.done = true;
|
111 | this.counter = this.data.interval;
|
112 | }
|
113 | }
|
114 | }
|
115 | }
|
116 | },
|
117 |
|
118 | |
119 |
|
120 |
|
121 |
|
122 | update: function (oldData) {},
|
123 |
|
124 | |
125 |
|
126 |
|
127 |
|
128 | remove: function () {},
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 | |
136 |
|
137 |
|
138 |
|
139 | pause: function () { },
|
140 |
|
141 | |
142 |
|
143 |
|
144 |
|
145 | play: function () { }
|
146 | });
|
147 |
|
148 |
|
149 | })
|
150 | ]); |
\ | No newline at end of file |