mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 07:18:29 +08:00
1 line
26 KiB
JavaScript
1 line
26 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{"/UnV":function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));const s=i("rwco").c.get("core/data_formats/parsing/afs"),n=5457473;function r(t){if(t.u32()!==n)return s.error("Not an AFS archive."),[];const e=t.u16();t.seek(2);const i=[];for(let s=0;s<e;s++){const e=t.u32(),s=t.u32();i.push({offset:e,size:s})}const r=[];for(const{offset:e,size:s}of i)t.seek_start(e),r.push(t.array_buffer(s));return r}},"7CyS":function(t,e,i){"use strict";i.d(e,"a",(function(){return r})),i.d(e,"b",(function(){return o}));var s=i("Womt"),n=i("VwSi");const r=30;function o(t,e){const i=e.interpolation===n.a.Spline?s.InterpolateSmooth:s.InterpolateLinear,o=[];return e.motion_data.forEach((e,_)=>{const a=t.get_bone(_);a&&e.tracks.forEach(({type:t,keyframes:e})=>{const h=[],u=[];for(const i of e)if(h.push(i.frame/r),t===n.b.Rotation){const t=a.evaluation_flags.zxy_rotation_order?"ZXY":"ZYX",e=(new s.Quaternion).setFromEuler(new s.Euler(i.value.x,i.value.y,i.value.z,t));u.push(e.x,e.y,e.z,e.w)}else u.push(i.value.x,i.value.y,i.value.z);if(t===n.b.Rotation)o.push(new s.QuaternionKeyframeTrack(`.bones[${_}].quaternion`,h,u,i));else{const e=t===n.b.Position?`.bones[${_}].position`:`.bones[${_}].scale`;o.push(new s.VectorKeyframeTrack(e,h,u,i))}})}),new s.AnimationClip("Animation",(e.frame_count-1)/r,o).optimize()}},"9Ykw":function(t,e,i){"use strict";function s(t){const e=[];for(;t.bytes_left;){const i=t.u32(),s=t.u32();if(s>t.bytes_left)break;e.push({type:i,data:t.take(s)})}return e}i.d(e,"a",(function(){return s}))},"9dYx":function(t,e,i){"use strict";var s=i("bcBH");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,e,i){if(i<0||i>this.size-this.position)throw new Error(`${t} ${e} is out of bounds.`)}check_offset(t,e){if(t<0||t+e>this.size)throw new Error(`Offset ${t} is out of bounds.`)}}i.d(e,"a",(function(){return r}));class r extends n{write_u8(t){return this.write_u8_at(this.position,t),this._position+=1,this}write_u16(t){return this.write_u16_at(this.position,t),this._position+=2,this}write_u32(t){return this.write_u32_at(this.position,t),this._position+=4,this}write_i8(t){return this.write_i8_at(this.position,t),this._position+=1,this}write_i16(t){return this.write_i16_at(this.position,t),this._position+=2,this}write_i32(t){return this.write_i32_at(this.position,t),this._position+=4,this}write_f32(t){return this.write_f32_at(this.position,t),this._position+=4,this}write_u8_array(t){return this.write_u8_array_at(this.position,t),this._position+=t.length,this}write_u16_array(t){return this.write_u16_array_at(this.position,t),this._position+=2*t.length,this}write_u32_array(t){return this.write_u32_array_at(this.position,t),this._position+=4*t.length,this}write_i32_array(t){return this.write_i32_array_at(this.position,t),this._position+=4*t.length,this}write_vec2_f32(t){return this.write_vec2_f32_at(this.position,t),this._position+=8,this}write_vec3_f32(t){return this.write_vec3_f32_at(this.position,t),this._position+=12,this}write_cursor(t){const e=t.size-t.position;return this.ensure_size(e),t.copy_to_uint8_array(new Uint8Array(this.backing_buffer,this.offset+this.position,e),e),this._position+=e,this}write_string_ascii(t,e){return this.write_string_ascii_at(this.position,t,e),this._position+=e,this}write_string_utf16(t,e){return this.write_string_utf16_at(this.position,t,e),this._position+=e,this}write_u8_at(t,e){return this.ensure_size(1,t),this.dv.setUint8(t,e),this}write_u16_at(t,e){return this.ensure_size(2,t),this.dv.setUint16(t,e,this.little_endian),this}write_u32_at(t,e){return this.ensure_size(4,t),this.dv.setUint32(t,e,this.little_endian),this}write_i8_at(t,e){return this.ensure_size(1,t),this.dv.setInt8(t,e),this}write_i16_at(t,e){return this.ensure_size(2,t),this.dv.setInt16(t,e,this.little_endian),this}write_i32_at(t,e){return this.ensure_size(4,t),this.dv.setInt32(t,e,this.little_endian),this}write_f32_at(t,e){return this.ensure_size(4,t),this.dv.setFloat32(t,e,this.little_endian),this}write_u8_array_at(t,e){return this.ensure_size(e.length,t),new Uint8Array(this.backing_buffer,this.offset+t).set(new Uint8Array(e)),this}write_u16_array_at(t,e){this.ensure_size(2*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_u16_at(t+2*s,e[s]);return this}write_u32_array_at(t,e){this.ensure_size(4*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_u32_at(t+4*s,e[s]);return this}write_i32_array_at(t,e){this.ensure_size(4*e.length,t);const i=e.length;for(let s=0;s<i;s++)this.write_i32_at(t+4*s,e[s]);return this}write_vec2_f32_at(t,e){return this.ensure_size(8,t),this.dv.setFloat32(t,e.x,this.little_endian),this.dv.setFloat32(t+4,e.y,this.little_endian),this}write_vec3_f32_at(t,e){return this.ensure_size(12,t),this.dv.setFloat32(t,e.x,this.little_endian),this.dv.setFloat32(t+4,e.y,this.little_endian),this.dv.setFloat32(t+8,e.z,this.little_endian),this}write_string_ascii_at(t,e,i){this.ensure_size(i,t);const s=Math.min(i,e.length);for(let i=0;i<s;i++)this.write_u8_at(t+i,e.codePointAt(i));const n=i-s;for(let e=0;e<n;e++)this.write_u8_at(t+s+e,0);return this}write_string_utf16_at(t,e,i){this.ensure_size(i,t);const s=Math.floor(i/2),n=Math.min(s,e.length);for(let i=0;i<n;i++)this.write_u16_at(t+2*i,e.codePointAt(i));const r=s-n;for(let e=0;e<r;e++)this.write_u16_at(t+2*n+2*e,0);return this}ensure_size(t,e=this.position){const i=this.size-e;if(t>i)throw new Error(`${t} Bytes required but only ${i} available.`)}}},NRxM:function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var s=i("9dYx");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}}},"Sa3/":function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var s=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function _(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,_)}a((s=s.apply(t,e||[])).next())}))};function n(t){return s(this,void 0,void 0,(function*(){return new Promise((e,i)=>{const s=new FileReader;s.addEventListener("loadend",()=>{s.result instanceof ArrayBuffer?e(s.result):i(new Error("Couldn't read file."))}),s.readAsArrayBuffer(t)})}))}},VwSi:function(t,e,i){"use strict";i.d(e,"a",(function(){return r})),i.d(e,"b",(function(){return o})),i.d(e,"c",(function(){return _}));var s=i("kwt4");const n=1296321870;var r,o;function _(t,e){return t.u32()===n?function(t,e){const i=t.u32();return a(t.take(i),e)}(t,e):(t.seek_start(0),function(t,e){t.seek_end(16);const i=t.u32();t.seek_start(i);const s=t.u32();return t.seek_start(s),function(t,e){t.seek(4);const i=t.u32();return t.seek_start(i),a(t,e)}(t,e)}(t,e))}function a(t,e){let i=t.u32();const s=t.u32(),n=t.u16(),r=t.u16(),_=(192&r)>>6,a=15&r,c=[];for(let r=0;r<e;r++){t.seek_start(i),i=i+=8*a;const e={tracks:[]};c.push(e);const r=[],_=[];for(let e=0;e<a;e++)r.push(t.u32());for(let e=0;e<a;e++){const e=t.u32();_.push(e)}if(1&n){t.seek_start(r.shift());const i=_.shift();i&&e.tracks.push({type:o.Position,keyframes:h(t,i)})}if(2&n){t.seek_start(r.shift());const i=_.shift();i&&e.tracks.push({type:o.Rotation,keyframes:u(t,i,s)})}if(4&n){t.seek_start(r.shift());const i=_.shift();i&&e.tracks.push({type:o.Scale,keyframes:h(t,i)})}}return{motion_data:c,frame_count:s,type:n,interpolation:_,element_count:a}}function h(t,e){const i=[];for(let s=0;s<e;++s)i.push({frame:t.u32(),value:t.vec3_f32()});return i}function u(t,e,i){const n=[],r=t.position;for(let i=0;i<e;++i)n.push({frame:t.u16(),value:{x:t.u16()*s.a,y:t.u16()*s.a,z:t.u16()*s.a}});let o=-1;for(const{frame:s}of n){if(s<o||s>=i)return t.seek_start(r),c(t,e);o=s}return n}function c(t,e){const i=[];for(let n=0;n<e;++n)i.push({frame:t.u32(),value:{x:t.i32()*s.a,y:t.i32()*s.a,z:t.i32()*s.a}});return i}!function(t){t[t.Linear=0]="Linear",t[t.Spline=1]="Spline",t[t.UserFunction=2]="UserFunction"}(r||(r={})),function(t){t[t.Position=0]="Position",t[t.Rotation=1]="Rotation",t[t.Scale=2]="Scale"}(o||(o={}))},bcBH: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={}))},kwt4:function(t,e,i){"use strict";var s=i("9Ykw"),n=i("rwco");const r=n.c.get("core/data_formats/parsing/ninja/njcm");var o;function _(t,e){const i=t.u32(),s=t.u32(),n=t.vec3_f32(),r=t.f32(),_=[],h=[];if(i){t.seek_start(i);for(const i of a(t,e,!0))if(i.type===o.Vertex)for(const t of i.vertices)_[t.index]={position:t.position,normal:t.normal,bone_weight:t.bone_weight,bone_weight_status:t.bone_weight_status,calc_continue:t.calc_continue}}if(s){t.seek_start(s);let i=void 0;for(const s of a(t,e,!1))if(s.type===o.Tiny)i=s.texture_id;else if(s.type===o.Strip){for(const t of s.triangle_strips)t.texture_id=i;h.push(...s.triangle_strips)}}return{type:"njcm",vertices:_,meshes:h,collision_sphere_center:n,collision_sphere_radius:r}}function a(t,e,i){const s=[];let n=!0;for(;n;){const _=t.u8(),c=t.u8(),l=t.position;let f=0;if(0===_)s.push({type:o.Null,type_id:_});else if(1<=_&&_<=3)s.push({type:o.Bits,type_id:_});else if(4===_){const i=c,r=t.position;s.push({type:o.CachePolygonList,type_id:_,cache_index:i,offset:r}),e[i]=r,n=!1}else if(5===_){const n=c,r=e[n];null!=r&&(t.seek_start(r),s.push(...a(t,e,i))),s.push({type:o.DrawPolygonList,type_id:_,cache_index:n})}else if(8<=_&&_<=9){f=2;const e=t.u16();s.push({type:o.Tiny,type_id:_,flip_u:0!=(128&_),flip_v:0!=(64&_),clamp_u:0!=(32&_),clamp_v:0!=(16&_),mipmap_d_adjust:15&_,filter_mode:e>>>14,super_sample:0!=(64&e),texture_id:8191&e})}else 17<=_&&_<=31?(f=2+2*t.u16(),s.push({type:o.Material,type_id:_})):32<=_&&_<=50?(f=2+4*t.u16(),s.push({type:o.Vertex,type_id:_,vertices:h(t,_,c)})):56<=_&&_<=58?(f=2+2*t.u16(),s.push({type:o.Volume,type_id:_})):64<=_&&_<=75?(f=2+2*t.u16(),s.push({type:o.Strip,type_id:_,triangle_strips:u(t,_,c)})):255===_?(f=i?2:0,s.push({type:o.End,type_id:_}),n=!1):(f=2+2*t.u16(),s.push({type:o.Unknown,type_id:_}),r.warn(`Unknown chunk type ${_} at offset ${l}.`));t.seek_start(l+f)}return s}function h(t,e,i){if(e<32||e>50)return r.warn(`Unknown vertex chunk type ${e}.`),[];const s=3&i,n=0!=(128&i),o=t.u16(),_=t.u16(),a=[];for(let i=0;i<_;++i){const r={index:o+i,position:t.vec3_f32(),bone_weight:1,bone_weight_status:s,calc_continue:n};if(32===e)t.seek(4);else if(33===e)t.seek(4),r.normal=t.vec3_f32(),t.seek(4);else if(35<=e&&e<=40)37===e?(r.index=o+t.u16(),r.bone_weight=t.u16()/255):t.seek(4);else if(41<=e&&e<=47)r.normal=t.vec3_f32(),e>=42&&(44===e?(r.index=o+t.u16(),r.bone_weight=t.u16()/255):t.seek(4));else if(48<=e&&e<=50){const i=t.u32();r.normal={x:(i>>20&1023)/1023,y:(i>>10&1023)/1023,z:(1023&i)/1023},e>=49&&t.seek(4)}a.push(r)}return a}function u(t,e,i){const s={ignore_light:0!=(1&i),ignore_specular:0!=(2&i),ignore_ambient:0!=(4&i),use_alpha:0!=(8&i),double_side:0!=(16&i),flat_shading:0!=(32&i),environment_mapping:0!=(64&i)},n=t.u16(),r=n>>>14,o=16383&n;let _=!1,a=!1,h=!1,u=!1;switch(e){case 64:break;case 65:case 66:_=!0;break;case 67:h=!0;break;case 68:case 69:_=!0,h=!0;break;case 70:a=!0;break;case 71:case 72:_=!0,a=!0;break;case 73:break;case 74:case 75:u=!0;break;default:throw new Error(`Unexpected chunk type ID: ${e}.`)}const c=[];for(let e=0;e<o;++e){const e=t.i16(),i=e<1,n=Math.abs(e),o=[];for(let e=0;e<n;++e){const i={index:t.u16()};o.push(i),_&&(i.tex_coords={x:t.u16()/255,y:t.u16()/255}),a&&t.seek(4),h&&(i.normal={x:t.u16()/255,y:t.u16()/255,z:t.u16()/255}),u&&t.seek(8),e>=2&&t.seek(2*r)}c.push(Object.assign(Object.assign({},s),{clockwise_winding:i,has_tex_coords:_,has_normal:h,vertices:o}))}return c}!function(t){t[t.Unknown=0]="Unknown",t[t.Null=1]="Null",t[t.Bits=2]="Bits",t[t.CachePolygonList=3]="CachePolygonList",t[t.DrawPolygonList=4]="DrawPolygonList",t[t.Tiny=5]="Tiny",t[t.Material=6]="Material",t[t.Vertex=7]="Vertex",t[t.Volume=8]="Volume",t[t.Strip=9]="Strip",t[t.End=10]="End"}(o||(o={}));const c=n.c.get("core/data_formats/parsing/ninja/xj");function l(t){t.seek(4);const e=t.u32(),i=t.u32(),s=t.u32(),n=t.u32(),r=t.u32(),o=t.u32(),_={type:"xj",vertices:[],meshes:[],collision_sphere_position:t.vec3_f32(),collision_sphere_radius:t.f32()};return i>=1&&(i>1&&c.warn(`Vertex info count of ${i} was larger than expected.`),_.vertices.push(...function(t,e){t.seek_start(e);const i=t.u16();t.seek(2);const s=t.u32(),n=t.u32(),r=t.u32(),o=[];for(let e=0;e<r;++e){t.seek_start(s+e*n);const r=t.vec3_f32();let _,a;switch(i){case 3:_=t.vec3_f32(),a=t.vec2_f32();break;case 4:break;case 5:t.seek(4),a=t.vec2_f32();break;case 6:_=t.vec3_f32();break;case 7:_=t.vec3_f32(),a=t.vec2_f32();break;default:c.warn(`Unknown vertex type ${i} with size ${n}.`)}o.push({position:r,normal:_,uv:a})}return o}(t,e))),_.meshes.push(...f(t,s,n)),_.meshes.push(...f(t,r,o)),_}function f(t,e,i){const s=[];for(let n=0;n<i;++n){t.seek_start(e+20*n);const i=t.u32(),r=t.u32(),o=t.u32(),_=t.u32(),a=d(t,i,r);t.seek_start(o);const h=t.u16_array(_);s.push({material_properties:a,indices:h})}return s}function d(t,e,i){const s={};for(let n=0;n<i;++n){switch(t.seek_start(e+16*n),t.u32()){case 2:s.alpha_src=t.u32(),s.alpha_dst=t.u32();break;case 3:s.texture_id=t.u32();break;case 5:s.diffuse_r=t.u8(),s.diffuse_g=t.u8(),s.diffuse_b=t.u8(),s.diffuse_a=t.u8()}}return s}i.d(e,"a",(function(){return p})),i.d(e,"b",(function(){return w})),i.d(e,"c",(function(){return v})),i.d(e,"d",(function(){return b})),i.d(e,"e",(function(){return k}));const p=2*Math.PI/65535,y=1296255566;function w(t){return"njcm"===t.type}class m{constructor(t,e,i,s,n,r){this.bone_cache=new Map,this._bone_count=-1,this.evaluation_flags=t,this.model=e,this.position=i,this.rotation=s,this.scale=n,this._children=r,this.children=this._children}bone_count(){if(-1===this._bone_count){const t=[0];this.get_bone_internal(this,Number.MAX_SAFE_INTEGER,t),this._bone_count=t[0]}return this._bone_count}get_bone(t){let e=this.bone_cache.get(t);return void 0===e&&(e=this.get_bone_internal(this,t,[0]),this.bone_cache.set(t,e||null)),e||void 0}add_child(t){this._bone_count=-1,this.bone_cache.clear(),this._children.push(t)}get_bone_internal(t,e,i){if(!t.evaluation_flags.skip){const s=i[0]++;if(this.bone_cache.set(s,t),s===e)return t}if(!t.evaluation_flags.break_child_trace)for(const s of t.children){const t=this.get_bone_internal(s,e,i);if(t)return t}}}function v(t){return x(t,_,[])}function b(t){return x(t,l,void 0)}function k(t){return g(t,l,void 0)}function x(t,e,i){const n=Object(s.a)(t).filter(t=>t.type===y),r=[];for(const t of n)r.push(...g(t.data,e,i));return r}function g(t,e,i){const s=t.u32(),n=0!=(1&s),r=0!=(2&s),o=0!=(4&s),_=0!=(8&s),a=0!=(16&s),h=0!=(32&s),u=0!=(64&s),c=0!=(128&s),l=t.u32(),f=t.vec3_f32(),d={x:t.i32()*p,y:t.i32()*p,z:t.i32()*p},y=t.vec3_f32(),w=t.u32(),v=t.u32();let b,k,x;return l&&(t.seek_start(l),b=e(t,i)),w?(t.seek_start(w),k=g(t,e,i)):k=[],v?(t.seek_start(v),x=g(t,e,i)):x=[],[new m({no_translate:n,no_rotate:r,no_scale:o,hidden:_,break_child_trace:a,zxy_rotation_order:h,skip:u,shape_skip:c},b,f,d,y,k),...x]}},tyuj:function(t,e,i){"use strict";i.r(e);var s=i("NRxM"),n=i("bcBH"),r=i("VwSi"),o=i("kwt4"),_=i("nsCy"),a=i("wtpc");class h{constructor(t){var e,i,s;this.name=t.name,this.head_style_count=t.head_style_count,this.hair_style_count=t.hair_style_count,this.hair_styles_with_accessory=t.hair_styles_with_accessory,this.section_id_tex_ids=Object(a.e)(_.f.length,e=>t.section_id_tex_id+e),this.body_tex_ids=t.body_tex_ids,this.head_tex_ids=null!=(e=t.head_tex_ids)?e:[],this.hair_tex_ids=null!=(i=t.hair_tex_ids)?i:[],this.accessory_tex_ids=null!=(s=t.accessory_tex_ids)?s:[]}}class u{constructor(t,e){this.id=t,this.name=e}}var c=i("Sa3/"),l=i("ouMO"),f=i("7CyS"),d=i("yub1"),p=i("kcKQ"),y=i("rwco"),w=i("/UnV");i.d(e,"Model3DStore",(function(){return b}));var m=function(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function _(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,_)}a((s=s.apply(t,e||[])).next())}))};const v=y.c.get("viewer/stores/ModelStore");class b extends p.a{constructor(t){super(),this.asset_loader=t,this._current_model=Object(l.e)(void 0),this._current_nj_data=Object(l.e)(void 0),this._current_textures=Object(l.c)(),this._show_skeleton=Object(l.e)(!1),this._current_animation=Object(l.e)(void 0),this._current_nj_motion=Object(l.e)(void 0),this._animation_playing=Object(l.e)(!0),this._animation_frame_rate=Object(l.e)(f.a),this._animation_frame=Object(l.e)(0),this.models=[new h({name:"HUmar",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([6]),section_id_tex_id:126,body_tex_ids:[0,1,2,108],head_tex_ids:[54,55],hair_tex_ids:[94,95]}),new h({name:"HUnewearl",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set,section_id_tex_id:299,body_tex_ids:[]}),new h({name:"HUcast",head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set,section_id_tex_id:275,body_tex_ids:[]}),new h({name:"HUcaseal",head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set,section_id_tex_id:375,body_tex_ids:[0,1,2],head_tex_ids:[3,4]}),new h({name:"RAmar",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:197,body_tex_ids:[]}),new h({name:"RAmarl",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:322,body_tex_ids:[15,1,0],head_tex_ids:[288],hair_tex_ids:[308,309],accessory_tex_ids:[void 0,void 0,8]}),new h({name:"RAcast",head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set,section_id_tex_id:300,body_tex_ids:[0,1,2,3,275],head_tex_ids:[4]}),new h({name:"RAcaseal",head_style_count:5,hair_style_count:0,hair_styles_with_accessory:new Set,section_id_tex_id:375,body_tex_ids:[]}),new h({name:"FOmar",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:310,body_tex_ids:[12,13,14,0],head_tex_ids:[276,272],hair_tex_ids:[void 0,296,297],accessory_tex_ids:[4]}),new h({name:"FOmarl",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:326,body_tex_ids:[]}),new h({name:"FOnewm",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:344,body_tex_ids:[]}),new h({name:"FOnewearl",head_style_count:1,hair_style_count:10,hair_styles_with_accessory:new Set([0,1,2,3,4,5,6,7,8,9]),section_id_tex_id:505,body_tex_ids:[]})],this.animations=new Array(572).fill(void 0).map((t,e)=>new u(e,`Animation ${e+1}`)),this.current_model=this._current_model,this.current_nj_data=this._current_nj_data,this.current_textures=this._current_textures,this.show_skeleton=this._show_skeleton,this.current_animation=this._current_animation,this.current_nj_motion=this._current_nj_motion,this.animation_playing=this._animation_playing,this.animation_frame_rate=this._animation_frame_rate,this.animation_frame=this._animation_frame,this.animation_frame_count=this.current_nj_motion.map(t=>t?t.frame_count:0),this.set_current_model=t=>{this._current_model.val=t},this.clear_current_model=()=>{this._current_model.val=void 0},this.set_show_skeleton=t=>{this._show_skeleton.val=t},this.set_current_animation=t=>{this._current_animation.val=t},this.clear_current_animation=()=>{this._current_animation.val=void 0},this.set_animation_playing=t=>{this._animation_playing.val=t},this.set_animation_frame_rate=t=>{this._animation_frame_rate.val=t},this.set_animation_frame=t=>{this._animation_frame.val=t},this.load_file=t=>m(this,void 0,void 0,(function*(){try{const e=yield Object(c.a)(t),i=new s.a(e,n.a.Little);if(t.name.endsWith(".nj")){this.clear_current_model();const t=Object(o.c)(i)[0];this.set_current_nj_data({nj_object:t,bone_count:t.bone_count(),has_skeleton:!0})}else if(t.name.endsWith(".xj")){this.clear_current_model();const t=Object(o.d)(i)[0];this.set_current_nj_data({nj_object:t,bone_count:0,has_skeleton:!1})}else if(t.name.endsWith(".njm")){this.clear_current_animation(),this._current_nj_motion.val=void 0;const t=this.current_nj_data.val;t&&(this.set_animation_playing(!0),this._current_nj_motion.val=Object(r.c)(i,t.bone_count))}else if(t.name.endsWith(".xvm"))this.current_model&&(this._current_textures.val=Object(d.a)(i).textures);else if(t.name.endsWith(".afs")){if(this.current_model){const t=Object(w.a)(i),e=[];for(const i of t)e.push(...Object(d.a)(new s.a(i,n.a.Little)).textures);this._current_textures.val=e}}else v.error(`Unknown file extension in filename "${t.name}".`)}catch(t){v.error("Couldn't read file.",t)}})),this.load_model=t=>m(this,void 0,void 0,(function*(){if(this.clear_current_animation(),t)try{const e=yield this.asset_loader.load_geometry(t);this.set_current_nj_data({nj_object:e,bone_count:t?64:e.bone_count(),has_skeleton:!0});const i=yield this.asset_loader.load_textures(t);this._current_textures.val=[i[t.section_id_tex_ids[Math.floor(Math.random()*_.f.length)]],...[...t.body_tex_ids,...t.head_tex_ids,...t.hair_tex_ids,...t.accessory_tex_ids].map(t=>null==t?void 0:i[t])]}catch(e){v.error(`Couldn't load model for ${t.name}.`),this._current_nj_data.val=void 0}else this._current_nj_data.val=void 0})),this.load_animation=t=>m(this,void 0,void 0,(function*(){const e=this.current_nj_data.val;if(e&&t)try{this._current_nj_motion.val=yield this.asset_loader.load_animation(t.id,e.bone_count),this.set_animation_playing(!0)}catch(e){v.error(`Couldn't load animation "${t.name}".`),this._current_nj_motion.val=void 0}else this._current_nj_motion.val=void 0})),this.disposables(this.current_model.observe(({value:t})=>this.load_model(t)),this.current_animation.observe(({value:t})=>this.load_animation(t))),this.set_current_model(this.models[[3,5,6,8][Math.floor(4*Math.random())]])}set_current_nj_data(t){this._current_textures.clear(),this._current_nj_data.val=t}}},yub1:function(t,e,i){"use strict";i.d(e,"a",(function(){return _}));var s=i("9Ykw");const n=i("rwco").c.get("core/data_formats/parsing/ninja/texture"),r=1213027928,o=1414682200;function _(t){const e=Object(s.a)(t),i=e.find(t=>t.type===r),_=i&&function(t){return{texture_count:t.u16()}}(i.data),a=e.filter(t=>t.type===o).map(t=>(function(t){const e=t.u32(),i=t.u32(),s=t.u32(),n=t.u16(),r=t.u16(),o=t.u32();return t.seek(36),{id:s,format:[e,i],width:n,height:r,size:o,data:t.array_buffer(o)}})(t.data));return _&&_.texture_count!==a.length&&n.warn(`Found ${a.length} textures instead of ${_.texture_count} as defined in the header.`),{textures:a}}}}]); |