|
24 | 24 | <script src="js/WebVR.js"></script>
|
25 | 25 | <script src="js/effects/VREffect.js"></script>
|
26 | 26 | <script src="js/controls/VRControls.js"></script>
|
27 |
| - <script src="js/libs/stats.min.js"></script> |
28 | 27 |
|
29 | 28 | <script>
|
30 | 29 |
|
|
36 | 35 |
|
37 | 36 | //
|
38 | 37 |
|
39 |
| - var container, stats; |
| 38 | + var container; |
40 | 39 | var camera, scene, raycaster, renderer;
|
41 | 40 | var effect, controls;
|
42 | 41 |
|
|
83 | 82 | );
|
84 | 83 | scene.add( mesh );
|
85 | 84 |
|
86 |
| - scene.add( new THREE.AmbientLight( 0x202040 ) ); |
| 85 | + scene.add( new THREE.HemisphereLight( 0x404020, 0x202040, 0.5 ) ); |
87 | 86 |
|
88 | 87 | var light = new THREE.DirectionalLight( 0xffffff );
|
89 | 88 | light.position.set( 1, 1, 1 ).normalize();
|
|
108 | 107 | object.scale.z = Math.random() + 0.5;
|
109 | 108 |
|
110 | 109 | object.userData.velocity = new THREE.Vector3();
|
111 |
| - object.userData.velocity.x = ( Math.random() - 0.5 ) * 0.1; |
112 |
| - object.userData.velocity.y = ( Math.random() - 0.5 ) * 0.1; |
113 |
| - object.userData.velocity.z = ( Math.random() - 0.5 ) * 0.1; |
| 110 | + object.userData.velocity.x = Math.random() * 0.4 - 0.2; |
| 111 | + object.userData.velocity.y = Math.random() * 0.4 - 0.2; |
| 112 | + object.userData.velocity.z = Math.random() * 0.4 - 0.2; |
114 | 113 |
|
115 | 114 | scene.add( object );
|
116 | 115 | cubes.push( object );
|
|
135 | 134 |
|
136 | 135 | }
|
137 | 136 |
|
138 |
| - stats = new Stats(); |
139 |
| - stats.domElement.style.position = 'absolute'; |
140 |
| - stats.domElement.style.top = '0'; |
141 |
| - container.appendChild( stats.domElement ); |
142 |
| - |
143 | 137 | //
|
144 | 138 |
|
145 | 139 | window.addEventListener( 'resize', onWindowResize, false );
|
|
160 | 154 | function animate() {
|
161 | 155 |
|
162 | 156 | requestAnimationFrame( animate );
|
163 |
| - |
164 | 157 | render();
|
165 |
| - stats.update(); |
166 | 158 |
|
167 | 159 | }
|
168 | 160 |
|
|
204 | 196 |
|
205 | 197 | if ( cube.position.x < - 100 || cube.position.x > 100 ) {
|
206 | 198 |
|
| 199 | + cube.position.x = THREE.Math.clamp( cube.position.x, - 100, 100 ); |
207 | 200 | cube.userData.velocity.x = - cube.userData.velocity.x;
|
208 | 201 |
|
209 | 202 | }
|
210 | 203 |
|
211 | 204 | if ( cube.position.y < - 100 || cube.position.y > 100 ) {
|
212 | 205 |
|
| 206 | + cube.position.y = THREE.Math.clamp( cube.position.y, - 100, 100 ); |
213 | 207 | cube.userData.velocity.y = - cube.userData.velocity.y;
|
214 | 208 |
|
215 | 209 | }
|
216 | 210 |
|
217 | 211 | if ( cube.position.z < - 100 || cube.position.z > 100 ) {
|
218 | 212 |
|
| 213 | + cube.position.z = THREE.Math.clamp( cube.position.z, - 100, 100 ); |
219 | 214 | cube.userData.velocity.z = - cube.userData.velocity.z;
|
220 | 215 |
|
221 | 216 | }
|
|
0 commit comments