Kaynağa Gözat

ViveController: Exposed gamepad.

Mr.doob 9 yıl önce
ebeveyn
işleme
28cecf607d
1 değiştirilmiş dosya ile 4 ekleme ve 1 silme
  1. 4 1
      examples/js/ViveController.js

+ 4 - 1
examples/js/ViveController.js

@@ -2,6 +2,9 @@ THREE.ViveController = function ( id ) {
 
 	THREE.Object3D.call( this );
 
+	var gamepad;
+
+	this.getGamepad = function () { return gamepad; };
 	this.matrixAutoUpdate = false;
 	this.standingMatrix = new THREE.Matrix4();
 
@@ -11,7 +14,7 @@ THREE.ViveController = function ( id ) {
 
 		requestAnimationFrame( update );
 
-		var gamepad = navigator.getGamepads()[ id ];
+		gamepad = navigator.getGamepads()[ id ];
 
 		if ( gamepad !== undefined && gamepad.pose !== null ) {