validate method

dynamic validate()

Implementation

validate() {
  var valid = true;

  var valueSize = getValueSize();
  if (valueSize - Math.floor(valueSize) != 0) {
    print('THREE.KeyframeTrack: Invalid value size in track. ${this}');
    valid = false;
  }

  var times = this.times, values = this.values, nKeys = times.length;

  if (nKeys == 0) {
    print('THREE.KeyframeTrack: Track is empty. ${this}');
    valid = false;
  }

  num? prevTime;

  for (var i = 0; i != nKeys; i++) {
    var currTime = times[i];

    if (currTime.runtimeType.toString() == 'num' && currTime == null) {
      print(
          'THREE.KeyframeTrack: Time is not a valid number. ${this} i: $i $currTime');
      valid = false;
      break;
    }

    if (prevTime != null && prevTime > currTime) {
      print(
          'THREE.KeyframeTrack: Out of order keys.${this} i: $i currTime: $currTime prevTime: $prevTime');
      valid = false;
      break;
    }
    prevTime = currTime;
  }

  if (AnimationUtils.isTypedArray(values)) {
    for (var i = 0, n = values.length; i != n; ++i) {
      var value = values[i];

      if (value == null) {
        print(
            'THREE.KeyframeTrack: Value is not a valid number. ${this} i: $i value: $value');
        valid = false;
        break;
      }
    }
  }

  return valid;
}