Преглед изворни кода

Add position tracking to VRControls

Peter Ehrlich пре 10 година
родитељ
комит
5f6b04a584
1 измењених фајлова са 9 додато и 3 уклоњено
  1. 9 3
      examples/js/controls/VRControls.js

+ 9 - 3
examples/js/controls/VRControls.js

@@ -44,11 +44,17 @@ THREE.VRControls = function ( object, callback ) {
 
 
 		if ( vrInput === undefined ) return;
 		if ( vrInput === undefined ) return;
 
 
-		var orientation = vrInput.getState().orientation;
+		var state = vrInput.getState();
 
 
-		if ( orientation !== null ) {
+		if ( state.orientation !== null ) {
 
 
-			object.quaternion.set( orientation.x, orientation.y, orientation.z, orientation.w );
+			object.quaternion.copy( state.orientation );
+
+		}
+
+		if ( state.position !== null ) {
+
+			object.position.copy( state.position );
 
 
 		}
 		}