@@ -18,6 +18,7 @@ module.exports.Component = registerComponent('tracked-controls', {
1818 } ,
1919
2020 init : function ( ) {
21+ this . previousControllerPosition = new THREE . Vector3 ( ) ;
2122 this . buttonStates = { } ;
2223 this . previousAxis = [ ] ;
2324 } ,
@@ -43,6 +44,7 @@ module.exports.Component = registerComponent('tracked-controls', {
4344 var controllerEuler = new THREE . Euler ( ) ;
4445 var controllerPosition = new THREE . Vector3 ( ) ;
4546 var controllerQuaternion = new THREE . Quaternion ( ) ;
47+ var deltaControllerPosition = new THREE . Vector3 ( ) ;
4648 var dolly = new THREE . Object3D ( ) ;
4749 var standingMatrix = new THREE . Matrix4 ( ) ;
4850 controllerEuler . order = 'YXZ' ;
@@ -74,10 +76,15 @@ module.exports.Component = registerComponent('tracked-controls', {
7476 y : THREE . Math . radToDeg ( controllerEuler . y ) ,
7577 z : THREE . Math . radToDeg ( controllerEuler . z )
7678 } ) ;
79+
80+ deltaControllerPosition . copy ( controllerPosition ) . sub ( this . previousControllerPosition ) ;
81+ this . previousControllerPosition . copy ( controllerPosition ) ;
82+ var currentPosition = el . getAttribute ( 'position' ) ;
83+
7784 el . setAttribute ( 'position' , {
78- x : controllerPosition . x ,
79- y : controllerPosition . y ,
80- z : controllerPosition . z
85+ x : currentPosition . x + deltaControllerPosition . x ,
86+ y : currentPosition . x + deltaControllerPosition . y ,
87+ z : currentPosition . x + deltaControllerPosition . z
8188 } ) ;
8289 } ;
8390 } ) ( ) ,
0 commit comments