Gyroscope.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. console.warn( "THREE.Gyroscope: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/index.html#manual/en/introduction/Import-via-modules." );
  2. /**
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Gyroscope = function () {
  6. THREE.Object3D.call( this );
  7. };
  8. THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
  9. THREE.Gyroscope.prototype.constructor = THREE.Gyroscope;
  10. THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
  11. var translationObject = new THREE.Vector3();
  12. var quaternionObject = new THREE.Quaternion();
  13. var scaleObject = new THREE.Vector3();
  14. var translationWorld = new THREE.Vector3();
  15. var quaternionWorld = new THREE.Quaternion();
  16. var scaleWorld = new THREE.Vector3();
  17. return function updateMatrixWorld( force ) {
  18. this.matrixAutoUpdate && this.updateMatrix();
  19. // update matrixWorld
  20. if ( this.matrixWorldNeedsUpdate || force ) {
  21. if ( this.parent !== null ) {
  22. this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );
  23. this.matrixWorld.decompose( translationWorld, quaternionWorld, scaleWorld );
  24. this.matrix.decompose( translationObject, quaternionObject, scaleObject );
  25. this.matrixWorld.compose( translationWorld, quaternionObject, scaleWorld );
  26. } else {
  27. this.matrixWorld.copy( this.matrix );
  28. }
  29. this.matrixWorldNeedsUpdate = false;
  30. force = true;
  31. }
  32. // update children
  33. for ( var i = 0, l = this.children.length; i < l; i ++ ) {
  34. this.children[ i ].updateMatrixWorld( force );
  35. }
  36. };
  37. }() );