Browse Source

Fixed webvr_gearvr cubes animation.

Mr.doob 7 năm trước cách đây
mục cha
commit
15a081478d
1 tập tin đã thay đổi với 7 bổ sung3 xóa
  1. 7 3
      examples/webvr_gearvr.html

+ 7 - 3
examples/webvr_gearvr.html

@@ -178,6 +178,8 @@
 
 			function render() {
 
+				var delta = clock.getDelta() * 60;
+
 				controller.update();
 
 				if ( controller.getTouchpadState() === true ) {
@@ -194,13 +196,13 @@
 
 				}
 
-				var delta = clock.getDelta() * 60;
+				// keep cubes inside room
 
 				for ( var i = 0; i < room.children.length; i ++ ) {
 
 					var cube = room.children[ i ];
 
-					if ( cube.geometry instanceof THREE.BoxGeometry === false ) continue;
+					cube.position.add( cube.userData.velocity );
 
 					if ( cube.position.x < - 3 || cube.position.x > 3 ) {
 
@@ -223,7 +225,9 @@
 
 					}
 
-					cube.rotation.x += 0.01 * delta;
+					cube.rotation.x += cube.userData.velocity.x * 2 * delta;
+					cube.rotation.y += cube.userData.velocity.y * 2 * delta;
+					cube.rotation.z += cube.userData.velocity.z * 2 * delta;
 
 				}