AnimationLoader

优质
小牛编辑
126浏览
2023-12-01

以JSON格式来加载 AnimationClips 的一个类。 内部使用 FileLoader 来加载文件。

代码示例

// 初始化一个加载器
const loader = new THREE.AnimationLoader();
// 加载资源
loader.load(
  // 资源URL
  'animations/animation.js',
  // onLoad回调
  function ( animations ) {
    // animations时一个AnimationClips组数
  },
  // onProgress回调
  function ( xhr ) {
    console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  },
  // onError回调
  function ( err ) {
    console.log( 'An error happened' );
  }
);

构造函数

AnimationLoader( manager : LoadingManager )

manager — 加载器所使用的loadingManager。 默认为THREE.DefaultLoadingManager.

创建一个新的AnimationLoader.

属性

共有属性请参见其基类Loader

方法

共有方法请参见其基类Loader

.load ( url : String, onLoad : Function, onProgress : Function, onError : Function ) : null

url — 文件的URL或者路径,也可以为 Data URI.
onLoad — 加载完成时将调用。回调参数为将要加载的animation clips.
onProgress — 将在加载过程中进行调用。参数为XMLHttpRequest实例,实例包含totalloaded字节。
onError — 在加载错误时被调用。

从URL中进行加载并将动画传递给onLoad。

.parse ( json : JSON ) : Array

json — 请求

Parse the JSON object and return an array of animation clips. Individual clips in the object will be parsed with AnimationClip.parse.

源代码

src/loaders/AnimationLoader.js