Explorar o código

Adds scale factor to the HMD absolute positioning

Diego Marcos %!s(int64=10) %!d(string=hai) anos
pai
achega
28dce00126
Modificáronse 1 ficheiros con 8 adicións e 1 borrados
  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 );
 
 		}