Gyroscope.js 1.5 KB

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