Gyroscope.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. THREE.Gyroscope = function () {
  2. THREE.Object3D.call( this );
  3. };
  4. THREE.Gyroscope.prototype = Object.create( THREE.Object3D.prototype );
  5. THREE.Gyroscope.prototype.constructor = THREE.Gyroscope;
  6. THREE.Gyroscope.prototype.updateMatrixWorld = ( function () {
  7. var translationObject = new THREE.Vector3();
  8. var quaternionObject = new THREE.Quaternion();
  9. var scaleObject = new THREE.Vector3();
  10. var translationWorld = new THREE.Vector3();
  11. var quaternionWorld = new THREE.Quaternion();
  12. var scaleWorld = new THREE.Vector3();
  13. return function updateMatrixWorld( force ) {
  14. this.matrixAutoUpdate && this.updateMatrix();
  15. // 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. }
  28. // update children
  29. for ( var i = 0, l = this.children.length; i < l; i ++ ) {
  30. this.children[ i ].updateMatrixWorld( force );
  31. }
  32. };
  33. }() );