Gyroscope.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. */
  4. THREE.Gyroscope = function () {
  5. THREE.Object3D.call( this );
  6. };
  7. THREE.Gyroscope.prototype = new THREE.Object3D();
  8. THREE.Gyroscope.prototype.constructor = THREE.Gyroscope;
  9. THREE.Gyroscope.prototype.updateMatrixWorld = function ( force ) {
  10. this.matrixAutoUpdate && this.updateMatrix();
  11. // update matrixWorld
  12. if ( this.matrixWorldNeedsUpdate || force ) {
  13. if ( this.parent ) {
  14. this.matrixWorld.multiply( this.parent.matrixWorld, this.matrix );
  15. this.matrixWorld.decompose( this.translationWorld, this.rotationWorld, this.scaleWorld );
  16. this.matrix.decompose( this.translationObject, this.rotationObject, this.scaleObject );
  17. this.matrixWorld.compose( this.translationWorld, this.rotationObject, this.scaleWorld );
  18. } else {
  19. this.matrixWorld.copy( this.matrix );
  20. }
  21. this.matrixWorldNeedsUpdate = false;
  22. force = true;
  23. }
  24. // update children
  25. for ( var i = 0, l = this.children.length; i < l; i ++ ) {
  26. this.children[ i ].updateMatrixWorld( force );
  27. }
  28. };
  29. THREE.Gyroscope.prototype.translationWorld = new THREE.Vector3();
  30. THREE.Gyroscope.prototype.translationObject = new THREE.Vector3();
  31. THREE.Gyroscope.prototype.rotationWorld = new THREE.Quaternion();
  32. THREE.Gyroscope.prototype.rotationObject = new THREE.Quaternion();
  33. THREE.Gyroscope.prototype.scaleWorld = new THREE.Vector3();
  34. THREE.Gyroscope.prototype.scaleObject = new THREE.Vector3();