PropertyMixer constructor

PropertyMixer(
  1. PropertyBinding binding,
  2. String typeName,
  3. int valueSize
)

Implementation

PropertyMixer(this.binding, String typeName, this.valueSize) {
  dynamic mixFunction, mixFunctionAdditive, setIdentity;

  // buffer layout: [ incoming | accu0 | accu1 | orig | addAccu | (optional work) ]
  //
  // interpolators can use .buffer as their .result
  // the data then goes to 'incoming'
  //
  // 'accu0' and 'accu1' are used frame-interleaved for
  // the cumulative result and are compared to detect
  // changes
  //
  // 'orig' stores the original state of the property
  //
  // 'add' is used for additive cumulative results
  //
  // 'work' is optional and is only present for quaternion types. It is used
  // to store intermediate quaternion multiplication results

  switch (typeName) {
    case 'quaternion':
      mixFunction = _slerp;
      mixFunctionAdditive = _slerpAdditive;
      setIdentity = _setAdditiveIdentityQuaternion;

      buffer = List<num>.filled(valueSize * 6, 0);
      _workIndex = 5;

      break;

    case 'string':
    case 'bool':
      mixFunction = _select;

      // Use the regular mix function and for additive on these types,
      // additive is not relevant for non-numeric types
      mixFunctionAdditive = _select;

      setIdentity = _setAdditiveIdentityOther;

      print("PropertyMixer  todo  typeName: $typeName");
      buffer = List<String?>.filled(valueSize * 5, null);
      // this.buffer = new Array( valueSize * 5 );

      break;

    default:
      mixFunction = _lerp;
      mixFunctionAdditive = _lerpAdditive;
      setIdentity = _setAdditiveIdentityNumeric;

      buffer = List<num>.filled(valueSize * 5, 0);
  }

  _mixBufferRegion = mixFunction;
  _mixBufferRegionAdditive = mixFunctionAdditive;
  _setIdentity = setIdentity;
  _origIndex = 3;
  _addIndex = 4;

  cumulativeWeight = 0;
  cumulativeWeightAdditive = 0;

  useCount = 0;
  referenceCount = 0;
}