Browse Source

Adds scale factor to the HMD absolute positioning

Diego Marcos 10 years ago
parent
commit
28dce00126
1 changed files with 8 additions and 1 deletions
  1. 8 1
      examples/js/controls/VRControls.js

+ 8 - 1
examples/js/controls/VRControls.js

@@ -5,6 +5,8 @@
 
 THREE.VRControls = function ( object, callback ) {
 
+	var scope = this;
+
 	var vrInput;
 
 	var onVRDevices = function ( devices ) {
@@ -40,6 +42,11 @@ THREE.VRControls = function ( object, callback ) {
 
 	}
 
+	// the Rift SDK returns the position in meters
+	// this scale factor allows the user to define how meters
+	// are converted to scene units.
+	this.scale = 1;
+
 	this.update = function () {
 
 		if ( vrInput === undefined ) return;
@@ -54,7 +61,7 @@ THREE.VRControls = function ( object, callback ) {
 
 		if ( state.position !== null ) {
 
-			object.position.copy( state.position );
+			object.position.copy( state.position ).multiplyScalar( scope.scale );
 
 		}