Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. THREE.OrbitControls = function ( object, domElement ) {
  2. /*
  3. other variables
  4. */
  5. var scope = this;
  6. this.enabled = true;
  7. var lastBeta=0;
  8. var lastGamma=0;
  9. this.deviceOrientation = {};
  10.  
  11. window.addEventListener( 'deviceorientation', function(event){
  12.  
  13. if (!scope.enabled) return;
  14. scope.deviceOrientation = event;
  15.  
  16. var beta = scope.deviceOrientation.beta ? THREE.Math.degToRad( scope.deviceOrientation.beta ) : 0; // X' (Vertical rotation)
  17. var gamma = scope.deviceOrientation.gamma ? THREE.Math.degToRad( scope.deviceOrientation.gamma ) : 0; // Y'' (Horizontal rotation)
  18.  
  19. //rotate by previous angle and current angle difference only
  20. scope.rotateUp(lastBeta-beta);
  21. scope.rotateLeft(lastGamma-gamma);
  22.  
  23. lastBeta=beta;
  24. lastGamma=gamma;
  25. }), false );
  26. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement