// automatically generated by the FlatBuffers compiler, do not modify

import * as flatbuffers from 'flatbuffers';

import { Quaternion } from '../foxglove/quaternion.ts';
import { Time } from '../foxglove/time.ts';
import { Vector3 } from '../foxglove/vector3.ts';


/**
 * A transform between two reference frames in 3D space
 */
export class FrameTransform {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):FrameTransform {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

static getRootAsFrameTransform(bb:flatbuffers.ByteBuffer, obj?:FrameTransform):FrameTransform {
  return (obj || new FrameTransform()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

static getSizePrefixedRootAsFrameTransform(bb:flatbuffers.ByteBuffer, obj?:FrameTransform):FrameTransform {
  bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
  return (obj || new FrameTransform()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

/**
 * Timestamp of transform
 */
timestamp(obj?:Time):Time|null {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? (obj || new Time()).__init(this.bb_pos + offset, this.bb!) : null;
}

/**
 * Name of the parent frame
 */
parentFrameId():string|null
parentFrameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
parentFrameId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

/**
 * Name of the child frame
 */
childFrameId():string|null
childFrameId(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null
childFrameId(optionalEncoding?:any):string|Uint8Array|null {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null;
}

/**
 * Translation component of the transform
 */
translation(obj?:Vector3):Vector3|null {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? (obj || new Vector3()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

/**
 * Rotation component of the transform
 */
rotation(obj?:Quaternion):Quaternion|null {
  const offset = this.bb!.__offset(this.bb_pos, 12);
  return offset ? (obj || new Quaternion()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null;
}

static startFrameTransform(builder:flatbuffers.Builder) {
  builder.startObject(5);
}

static addTimestamp(builder:flatbuffers.Builder, timestampOffset:flatbuffers.Offset) {
  builder.addFieldStruct(0, timestampOffset, 0);
}

static addParentFrameId(builder:flatbuffers.Builder, parentFrameIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(1, parentFrameIdOffset, 0);
}

static addChildFrameId(builder:flatbuffers.Builder, childFrameIdOffset:flatbuffers.Offset) {
  builder.addFieldOffset(2, childFrameIdOffset, 0);
}

static addTranslation(builder:flatbuffers.Builder, translationOffset:flatbuffers.Offset) {
  builder.addFieldOffset(3, translationOffset, 0);
}

static addRotation(builder:flatbuffers.Builder, rotationOffset:flatbuffers.Offset) {
  builder.addFieldOffset(4, rotationOffset, 0);
}

static endFrameTransform(builder:flatbuffers.Builder):flatbuffers.Offset {
  const offset = builder.endObject();
  return offset;
}

static finishFrameTransformBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
  builder.finish(offset);
}

static finishSizePrefixedFrameTransformBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) {
  builder.finish(offset, undefined, true);
}

}
