2017-11-24 03:32:28 +00:00
|
|
|
import {vec4} from '../tsm/vec4';
|
|
|
|
|
|
|
|
|
|
export class Vector4 extends vec4
|
|
|
|
|
{
|
2017-11-24 17:45:34 +00:00
|
|
|
static getZero(): Vector4
|
|
|
|
|
{
|
|
|
|
|
return new Vector4();
|
|
|
|
|
}
|
2017-11-24 03:32:28 +00:00
|
|
|
|
2017-11-24 17:45:34 +00:00
|
|
|
constructor(buf?: Buffer | number[], pos?: number)
|
|
|
|
|
{
|
|
|
|
|
if (buf !== undefined && pos !== undefined && buf instanceof Buffer)
|
|
|
|
|
{
|
|
|
|
|
const x = buf.readFloatLE(pos);
|
|
|
|
|
const y = buf.readFloatLE(pos + 4);
|
|
|
|
|
const z = buf.readFloatLE(pos + 8);
|
|
|
|
|
const w = buf.readFloatLE(pos + 12);
|
|
|
|
|
super([x, y, z, w]);
|
|
|
|
|
}
|
|
|
|
|
else if (buf !== undefined && Array.isArray(buf))
|
|
|
|
|
{
|
|
|
|
|
super(buf);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
writeToBuffer(buf: Buffer, pos: number)
|
|
|
|
|
{
|
|
|
|
|
buf.writeFloatLE(this.x, pos);
|
|
|
|
|
buf.writeFloatLE(this.y, pos + 4);
|
2017-11-30 04:11:59 +00:00
|
|
|
buf.writeFloatLE(this.z, pos + 8);
|
2017-11-24 17:45:34 +00:00
|
|
|
buf.writeFloatLE(this.w, pos + 12);
|
|
|
|
|
}
|
2017-11-24 03:32:28 +00:00
|
|
|
}
|