JSAPI Three API Reference
    正在准备搜索索引...

    类 AnimationModel

    动画模型,支持GLTF/GLB等格式的骨骼动画播放与控制。 继承自 SimpleModel,可用于加载带有动画的3D模型,并提供动画的播放、停止、速度、循环等控制接口。

    // 加载带动画的模型
    let model = engine.add(new mapvthree.AnimationModel({
    url: 'assets/models/animated.glb',
    autoPlay: true
    }));
    // 播放第1个动画
    model.play(0);
    // 停止所有动画
    model.stopAll();
    // 设置动画速度为2倍
    model.setSpeed(2);

    层级 (查看层级一览)

    索引

    构造函数

    方法

    • 释放动画相关资源

      返回 void

    • 播放指定索引的动画

      参数

      • 可选actionIndex: number

        动画索引,默认播放第一个

      返回 void

      model.play(1); // 播放第2个动画
      
    • 播放所有动画

      返回 void

      model.playAll();
      
    • 设置动画循环模式

      参数

      • loop: boolean

        是否循环,true为循环,false为只播放一次

      • 可选actionIndex: number

        动画索引,若不传则设置所有动画

      返回 void

      model.setLoop(true); // 所有动画循环
      model.setLoop(false, 0); // 第1个动画只播放一次
    • 设置动画播放速度

      参数

      • speed: number

        播放速度,1为正常速度

      • 可选actionIndex: number

        动画索引,若不传则设置所有动画

      返回 void

      model.setSpeed(2); // 所有动画2倍速
      model.setSpeed(0.5, 0); // 第1个动画0.5倍速
    • 设置模型的变换参数

      参数

      • transform: { point?: any; rotation?: any; scale?: any } = {}

        变换参数对象

        • 可选point?: any

          位置坐标[经度,纬度,高度]

        • 可选rotation?: any

          旋转角度,x,y,z三个分量分别代表roll,pitch,heading (单位为弧度)

        • 可选scale?: any

          缩放比例

      返回 void

      // 设置位置、旋转和缩放
      model.setTransform({
      point: [116.404, 39.915, 100],
      rotation: [Math.PI/2, 0, 0],
      scale: [2, 2, 2]
      });

      // 只设置位置
      model.setTransform({
      point: [116.404, 39.915, 100]
      });

      // 使用Vector3设置
      model.setTransform({
      point: new Vector3(116.404, 39.915, 100),
      scale: new Vector3(2, 2, 2)
      });
    • 停止指定索引的动画

      参数

      • 可选actionIndex: number

        动画索引,默认停止第一个

      返回 void

      model.stop(0); // 停止第1个动画
      
    • 停止所有动画

      返回 void

      model.stopAll();
      

    访问器

    • get autoYUpToZUp(): boolean

      是否自动将Y轴向上转换为Z轴向上,仅对通过URL加载的模型有效

      返回 boolean

    • set point(value: any): void

      设置模型位置

      参数

      • value: any

        位置坐标[经度,纬度,高度]

      返回 void

      model.point = [116.404, 39.915, 100];