Gyroscope.js 1.4 KB

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