setMorphTargetWeights method

  1. @override
Future setMorphTargetWeights(
  1. ThermionEntity entity,
  2. List<double> weights
)
override

Implementation

@override
Future setMorphTargetWeights(
    ThermionEntity entity, List<double> weights) async {
  if (weights.isEmpty) {
    throw Exception("Weights must not be empty");
  }
  var weightsPtr = allocator<Float>(weights.length);

  for (int i = 0; i < weights.length; i++) {
    weightsPtr[i] = weights[i];
  }
  var success = await withBoolCallback((cb) {
    set_morph_target_weights_ffi(
        _sceneManager!, entity, weightsPtr, weights.length, cb);
  });
  allocator.free(weightsPtr);

  if (!success) {
    throw Exception(
        "Failed to set morph target weights, check logs for details");
  }
}