You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

78 lines
1.7 KiB

class gbxHeader {
has_magic = true
version = -1
format = -1
compressionofRefTable = -1
compressionOfrefBofy = -1
compressionTextFlag = ''
id = -1
userData = []
numNodes = 0
is_vaild = false
parse(buff)
{
let header_magic = buff.readString(3);
if (header_magic != 'GBX')
{
console.log("Header Magic Mismatch: " + header_magic);
return
}
this.has_magic = true
this.version = buff.readUInt16();
console.log(this.version)
if (this.version < 5 || this.version >7 )
{
console.log("Unsupported version")
return;
}
this.format = buff.readInt8();
if (this.format != 66)
{
console.log("Unsupported format")
return;
}
this.compressionofRefTable = buff.readInt8();
if (this.compressionofRefTable != 67 && this.compressionofRefTable != 85)
{
console.log("Unsupported compression format, Ref")
return;
}
this.compressionofRefBody = buff.readInt8();
if (this.compressionofRefBody != 67 && this.compressionofRefBody != 85)
{
console.log("Unsupported compression format, Body")
return;
}
this.compressionTextFlag = '';
if (this.version >= 4)
{
this.compressionTextFlag = buff.readString(1);
}
this.id = buff.readUInt32();
console.log(this.id)
if (this.version >=6)
{
this.userData = buff.readBytes();
}
this.numNodes = buff.readUInt32();
this.is_vaild = true
}
}
module.exports = gbxHeader;