addBoneAnimation method

  1. @JSExport()
JSPromise<JSAny?> addBoneAnimation(
  1. ThermionEntity entity,
  2. JSArray<JSString> bones,
  3. JSArray<JSArray<JSArray<JSNumber>>> frameData,
  4. JSNumber frameLengthInMs,
  5. JSNumber spaceEnum,
  6. JSNumber skinIndex,
  7. JSNumber fadeInInSecs,
  8. JSNumber fadeOutInSecs,
  9. JSNumber maxDelta,
)

Implementation

@JSExport()
JSPromise addBoneAnimation(
    ThermionEntity entity,
    JSArray<JSString> bones,
    JSArray<JSArray<JSArray<JSNumber>>> frameData,
    JSNumber frameLengthInMs,
    JSNumber spaceEnum,
    JSNumber skinIndex,
    JSNumber fadeInInSecs,
    JSNumber fadeOutInSecs,
    JSNumber maxDelta) {
  var frameDataDart = frameData.toDart
      .map((frame) => frame.toDart
          .map((v) {
            var values = v.toDart;
            var trans = v64.Vector3(values[0].toDartDouble,
                values[1].toDartDouble, values[2].toDartDouble);
            var rot = v64.Quaternion(
                values[3].toDartDouble,
                values[4].toDartDouble,
                values[5].toDartDouble,
                values[6].toDartDouble);
            return (rotation: rot, translation: trans);
          })
          .cast<BoneAnimationFrame>()
          .toList())
      .toList();

  var data = BoneAnimationData(
      bones.toDart.map((n) => n.toDart).toList(), frameDataDart,
      frameLengthInMs: frameLengthInMs.toDartDouble,
      space: Space.values[spaceEnum.toDartInt]);

  return viewer
      .addBoneAnimation(entity, data,
          skinIndex: skinIndex.toDartInt,
          fadeInInSecs: fadeInInSecs.toDartDouble,
          fadeOutInSecs: fadeOutInSecs.toDartDouble)
      .toJS;
}