2
0

Gyroscope.js 1.3 KB

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