VrRemotePoseFrame constructor

VrRemotePoseFrame({
  1. required int sequence,
  2. required int senderTimestampMicroseconds,
  3. required Quaternion orientation,
  4. Vector3? angularVelocity,
  5. Vector3? accelerometer,
  6. int buttonsBitset = 0,
  7. double? touchX,
  8. double? touchY,
  9. double? rangeMeters,
  10. VrRangeSource? rangeSource,
  11. double? rangeConfidence,
})

Implementation

factory VrRemotePoseFrame({
  required int sequence,
  required int senderTimestampMicroseconds,
  required Quaternion orientation,
  Vector3? angularVelocity,
  Vector3? accelerometer,
  int buttonsBitset = 0,
  double? touchX,
  double? touchY,
  double? rangeMeters,
  VrRangeSource? rangeSource,
  double? rangeConfidence,
}) {
  if (sequence < 0) {
    throw RangeError.value(sequence, 'sequence', 'Must not be negative.');
  }
  if (senderTimestampMicroseconds < 0) {
    throw RangeError.value(
      senderTimestampMicroseconds,
      'senderTimestampMicroseconds',
      'Must not be negative.',
    );
  }
  if (buttonsBitset < 0) {
    throw RangeError.value(
      buttonsBitset,
      'buttonsBitset',
      'Must not be negative.',
    );
  }
  final orientationLength2 = orientation.length2;
  if (!orientationLength2.isFinite || orientationLength2 <= 1e-12) {
    throw ArgumentError.value(
      orientation,
      'orientation',
      'Must be a finite non-zero quaternion.',
    );
  }
  final normalized = orientation.normalized();
  final velocity = angularVelocity ?? Vector3.zero();
  if (!velocity.x.isFinite || !velocity.y.isFinite || !velocity.z.isFinite) {
    throw ArgumentError.value(
      velocity,
      'angularVelocity',
      'Components must be finite.',
    );
  }
  final acceleration = accelerometer ?? Vector3.zero();
  if (!acceleration.x.isFinite ||
      !acceleration.y.isFinite ||
      !acceleration.z.isFinite) {
    throw ArgumentError.value(
      acceleration,
      'accelerometer',
      'Components must be finite.',
    );
  }
  if ((touchX == null) != (touchY == null)) {
    throw ArgumentError('touchX and touchY must both be present or absent.');
  }
  if (touchX != null) {
    _requireUnit(touchX, 'touchX');
    _requireUnit(touchY!, 'touchY');
  }
  if (rangeMeters != null) _requirePositive(rangeMeters, 'rangeMeters');
  if ((rangeMeters == null) != (rangeSource == null)) {
    throw ArgumentError(
      'rangeMeters and rangeSource must both be present or absent.',
    );
  }
  if (rangeConfidence != null) {
    if (rangeMeters == null) {
      throw ArgumentError('rangeConfidence requires rangeMeters.');
    }
    _requireUnit(rangeConfidence, 'rangeConfidence');
  }
  return VrRemotePoseFrame._(
    sequence: sequence,
    senderTimestampMicroseconds: senderTimestampMicroseconds,
    qx: normalized.x,
    qy: normalized.y,
    qz: normalized.z,
    qw: normalized.w,
    angularVelocityX: velocity.x,
    angularVelocityY: velocity.y,
    angularVelocityZ: velocity.z,
    accelerometerX: acceleration.x,
    accelerometerY: acceleration.y,
    accelerometerZ: acceleration.z,
    buttonsBitset: buttonsBitset,
    touchX: touchX,
    touchY: touchY,
    rangeMeters: rangeMeters,
    rangeSource: rangeSource,
    rangeConfidence: rangeConfidence,
  );
}