Skip to content

Commit aa0531d

Browse files
committed
More tweaks to webvr_cubes.
1 parent abb4bc2 commit aa0531d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

examples/webvr_cubes.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<script src="js/WebVR.js"></script>
2525
<script src="js/effects/VREffect.js"></script>
2626
<script src="js/controls/VRControls.js"></script>
27-
<script src="js/libs/stats.min.js"></script>
2827

2928
<script>
3029

@@ -36,7 +35,7 @@
3635

3736
//
3837

39-
var container, stats;
38+
var container;
4039
var camera, scene, raycaster, renderer;
4140
var effect, controls;
4241

@@ -83,7 +82,7 @@
8382
);
8483
scene.add( mesh );
8584

86-
scene.add( new THREE.AmbientLight( 0x202040 ) );
85+
scene.add( new THREE.HemisphereLight( 0x404020, 0x202040, 0.5 ) );
8786

8887
var light = new THREE.DirectionalLight( 0xffffff );
8988
light.position.set( 1, 1, 1 ).normalize();
@@ -108,9 +107,9 @@
108107
object.scale.z = Math.random() + 0.5;
109108

110109
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;
114113

115114
scene.add( object );
116115
cubes.push( object );
@@ -135,11 +134,6 @@
135134

136135
}
137136

138-
stats = new Stats();
139-
stats.domElement.style.position = 'absolute';
140-
stats.domElement.style.top = '0';
141-
container.appendChild( stats.domElement );
142-
143137
//
144138

145139
window.addEventListener( 'resize', onWindowResize, false );
@@ -160,9 +154,7 @@
160154
function animate() {
161155

162156
requestAnimationFrame( animate );
163-
164157
render();
165-
stats.update();
166158

167159
}
168160

@@ -204,18 +196,21 @@
204196

205197
if ( cube.position.x < - 100 || cube.position.x > 100 ) {
206198

199+
cube.position.x = THREE.Math.clamp( cube.position.x, - 100, 100 );
207200
cube.userData.velocity.x = - cube.userData.velocity.x;
208201

209202
}
210203

211204
if ( cube.position.y < - 100 || cube.position.y > 100 ) {
212205

206+
cube.position.y = THREE.Math.clamp( cube.position.y, - 100, 100 );
213207
cube.userData.velocity.y = - cube.userData.velocity.y;
214208

215209
}
216210

217211
if ( cube.position.z < - 100 || cube.position.z > 100 ) {
218212

213+
cube.position.z = THREE.Math.clamp( cube.position.z, - 100, 100 );
219214
cube.userData.velocity.z = - cube.userData.velocity.z;
220215

221216
}

0 commit comments

Comments
 (0)