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

import * as flatbuffers from 'flatbuffers';



/**
 * A [quaternion](https://eater.net/quaternions) representing a rotation in 3D space
 */
export class Quaternion {
  bb: flatbuffers.ByteBuffer|null = null;
  bb_pos = 0;
  __init(i:number, bb:flatbuffers.ByteBuffer):Quaternion {
  this.bb_pos = i;
  this.bb = bb;
  return this;
}

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

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

/**
 * x value
 */
x():number {
  const offset = this.bb!.__offset(this.bb_pos, 4);
  return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}

/**
 * y value
 */
y():number {
  const offset = this.bb!.__offset(this.bb_pos, 6);
  return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}

/**
 * z value
 */
z():number {
  const offset = this.bb!.__offset(this.bb_pos, 8);
  return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 0.0;
}

/**
 * w value
 */
w():number {
  const offset = this.bb!.__offset(this.bb_pos, 10);
  return offset ? this.bb!.readFloat64(this.bb_pos + offset) : 1.0;
}

static startQuaternion(builder:flatbuffers.Builder) {
  builder.startObject(4);
}

static addX(builder:flatbuffers.Builder, x:number) {
  builder.addFieldFloat64(0, x, 0.0);
}

static addY(builder:flatbuffers.Builder, y:number) {
  builder.addFieldFloat64(1, y, 0.0);
}

static addZ(builder:flatbuffers.Builder, z:number) {
  builder.addFieldFloat64(2, z, 0.0);
}

static addW(builder:flatbuffers.Builder, w:number) {
  builder.addFieldFloat64(3, w, 1.0);
}

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

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

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

static createQuaternion(builder:flatbuffers.Builder, x:number, y:number, z:number, w:number):flatbuffers.Offset {
  Quaternion.startQuaternion(builder);
  Quaternion.addX(builder, x);
  Quaternion.addY(builder, y);
  Quaternion.addZ(builder, z);
  Quaternion.addW(builder, w);
  return Quaternion.endQuaternion(builder);
}
}
