AnimationLoader.js 741 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author bhouston / http://clara.io/
  3. */
  4. THREE.AnimationLoader = function ( manager ) {
  5. this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
  6. };
  7. THREE.AnimationLoader.prototype = {
  8. constructor: THREE.AnimationLoader,
  9. load: function ( url, onLoad, onProgress, onError ) {
  10. var scope = this;
  11. var loader = new THREE.XHRLoader( scope.manager );
  12. loader.load( url, function ( text ) {
  13. onLoad( scope.parse( JSON.parse( text ) ) );
  14. }, onProgress, onError );
  15. },
  16. parse: function ( json, onLoad ) {
  17. var animations = [];
  18. for ( var i = 0; i < json.length; i ++ ) {
  19. var clip = THREE.AnimationClip.parse( json[ i ] );
  20. animations.push( clip );
  21. }
  22. onLoad( animations );
  23. }
  24. };