浏览代码

Adds scale factor to the HMD absolute positioning

Diego Marcos 10 年之前
父节点
当前提交
28dce00126
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      examples/js/controls/VRControls.js

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

@@ -5,6 +5,8 @@
 
 
 THREE.VRControls = function ( object, callback ) {
 THREE.VRControls = function ( object, callback ) {
 
 
+	var scope = this;
+
 	var vrInput;
 	var vrInput;
 
 
 	var onVRDevices = function ( devices ) {
 	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 () {
 	this.update = function () {
 
 
 		if ( vrInput === undefined ) return;
 		if ( vrInput === undefined ) return;
@@ -54,7 +61,7 @@ THREE.VRControls = function ( object, callback ) {
 
 
 		if ( state.position !== null ) {
 		if ( state.position !== null ) {
 
 
-			object.position.copy( state.position );
+			object.position.copy( state.position ).multiplyScalar( scope.scale );
 
 
 		}
 		}