VrRemotePoseFrame.fromJson constructor
VrRemotePoseFrame.fromJson(
- Map<String, dynamic> json
)
Implementation
factory VrRemotePoseFrame.fromJson(Map<String, dynamic> json) {
final orientation = _jsonNumberList(json, 'orientation', 4);
final velocity = _jsonNumberList(json, 'angularVelocity', 3);
final acceleration = json['accelerometer'] == null
? const <double>[0, 0, 0]
: _jsonNumberList(json, 'accelerometer', 3);
final touch = json['touch'] == null
? null
: _jsonNumberList(json, 'touch', 2);
final range = json['range'] == null
? null
: _jsonMapValue(json['range'], 'range');
return VrRemotePoseFrame(
sequence: _jsonInt(json, 'sequence'),
senderTimestampMicroseconds: _jsonInt(json, 'timestampUs'),
orientation: Quaternion(
orientation[0],
orientation[1],
orientation[2],
orientation[3],
),
angularVelocity: Vector3(velocity[0], velocity[1], velocity[2]),
accelerometer: Vector3(acceleration[0], acceleration[1], acceleration[2]),
buttonsBitset: _jsonInt(json, 'buttons'),
touchX: touch?[0],
touchY: touch?[1],
rangeMeters: range == null ? null : _jsonDouble(range, 'meters'),
rangeSource: range == null
? null
: _jsonEnum(VrRangeSource.values, range, 'source'),
rangeConfidence: range == null || range['confidence'] == null
? null
: _jsonDouble(range, 'confidence'),
);
}