phantasmal-world/18.0095dd498f2856f76534.js

1 line
16 KiB
JavaScript
Raw Normal View History

2020-04-26 04:20:20 +08:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{459:function(t,e,i){"use strict";var s;i.d(e,"a",(function(){return s})),function(t){t[t.Little=0]="Little",t[t.Big=1]="Big"}(s||(s={}))},468:function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var s=i(488);class n extends s.a{constructor(t,e,i=0,s=t.byteLength-i){super(e,i),this._size=s,this.backing_buffer=t,this.dv=new DataView(t,0,t.byteLength)}get size(){return this._size}set size(t){if(t>this.backing_buffer.byteLength-this.offset)throw new Error(`Size ${t} is out of bounds.`);this._size=t}take(t){const e=this.offset+this.position,i=new n(this.backing_buffer,this.endianness,e,t);return this._position+=t,i}}},488:function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var s=i(459);class n{constructor(t,e){this._position=0,this.endianness=t,this.offset=e}get position(){return this._position}get endianness(){return this.little_endian?s.a.Little:s.a.Big}set endianness(t){this.little_endian=t===s.a.Little}get bytes_left(){return this.size-this.position}seek(t){return this.seek_start(this.position+t)}seek_start(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=t,this}seek_end(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=this.size-t,this}u8(){return this.u8_at(this._position++)}u8_at(t){return this.check_offset(t,1),this.dv.getUint8(this.offset+t)}u16(){const t=this.u16_at(this.position);return this._position+=2,t}u16_at(t){return this.check_offset(t,2),this.dv.getUint16(this.offset+t,this.little_endian)}u32(){const t=this.u32_at(this.position);return this._position+=4,t}u32_at(t){return this.check_offset(t,4),this.dv.getUint32(this.offset+t,this.little_endian)}i8(){return this.i8_at(this._position++)}i8_at(t){return this.check_offset(t,1),this.dv.getInt8(this.offset+t)}i16(){const t=this.i16_at(this.position);return this._position+=2,t}i16_at(t){return this.check_offset(t,2),this.dv.getInt16(this.offset+t,this.little_endian)}i32(){const t=this.i32_at(this.position);return this._position+=4,t}i32_at(t){return this.check_offset(t,4),this.dv.getInt32(this.offset+t,this.little_endian)}f32(){const t=this.f32_at(this.position);return this._position+=4,t}f32_at(t){return this.check_offset(t,4),this.dv.getFloat32(this.offset+t,this.little_endian)}u8_array(t){this.check_size("n",t,t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint8(this.offset+this._position++));return e}u16_array(t){this.check_size("n",t,2*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint16(this.offset+this.position,this.little_endian)),this._position+=2;return e}u32_array(t){this.check_size("n",t,4*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getUint32(this.offset+this.position,this.little_endian)),this._position+=4;return e}i32_array(t){this.check_size("n",t,4*t);const e=[];for(let i=0;i<t;++i)e.push(this.dv.getInt32(this.offset+this.position,this.little_endian)),this._position+=4;return e}vec2_f32(){return{x:this.f32(),y:this.f32()}}vec3_f32(){return{x:this.f32(),y:this.f32(),z:this.f32()}}string_ascii(t,e,i){const s=[];for(let n=0;n<t;n++){const r=this.u8();if(e&&0===r){i&&this.seek(t-n-1);break}s.push(r)}return String.fromCodePoint(...s)}string_utf16(t,e,i){const s=[],n=Math.floor(t/2);for(let t=0;t<n;t++){const r=this.u16();if(e&&0===r){i&&this.seek(2*(n-t-1));break}s.push(r)}return String.fromCodePoint(...s)}string_ascii_at(t,e,i){const s=[];for(let n=0;n<e;n++){const e=this.u8_at(t+n);if(i&&0===e)break;s.push(e)}return String.fromCodePoint(...s)}string_utf16_at(t,e,i){const s=[],n=Math.floor(e/2);for(let e=0;e<n;e++){const n=this.u16_at(t+2*e);if(i&&0===n)break;s.push(n)}return String.fromCodePoint(...s)}array_buffer(t=this.size-this.position){this.check_size("size",t,t);const e=this.backing_buffer.slice(this.offset+this.position,this.offset+this.position+t);return this._position+=t,e}copy_to_uint8_array(t,e=this.size-this.position){return this.check_size("size",e,e),t.set(new Uint8Array(this.backing_buffer,this.offset+this.position,e)),this._position+=e,this}check_size(t,