Gyroscope.js 1.3 KB

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