mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 07:18:29 +08:00
1 line
10 KiB
JavaScript
1 line
10 KiB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{457:function(e,t,n){"use strict";function s(e,t){return{success:!0,value:e,problems:null!=t?t:[]}}function r(e){return{success:!1,problems:null!=e?e:[]}}function i(e){if(e.success)return e.value;throw new Error(e.problems.join("\n"))}function o(e){return new u(e)}n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return r})),n.d(t,"d",(function(){return i})),n.d(t,"b",(function(){return o}));class u{constructor(e){this.logger=e,this.problems=[]}add_problem(e,t,n,s){return this.logger.log(e,n,s),this.problems.push({severity:e,ui_message:t}),this}add_result(e){return this.problems.push(...e.problems),this}success(e){return s(e,this.problems)}failure(){return r(this.problems)}}},480:function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return a}));var s=n(457),r=n(23),i=n(26);const o=r.a.get("core/data_formats/parsing/iff");function u(e,t=!1){return c(e,t,[],(e,t,n)=>({type:t,data:e.take(n)}))}function a(e,t=!1){return c(e,t,[],(e,t,n)=>({type:t,size:n}))}function c(e,t,n,r){const u=Object(s.b)(o);let a=!1;for(;e.bytes_left>=8;){const s=e.u32(),o=e.position,c=e.u32();if(c>e.bytes_left){a=!0,t||u.add_problem(0===n.length?i.b.Error:i.b.Warning,"Invalid IFF format.",`Size ${c} was too large (only ${e.bytes_left} bytes left) at position ${o}.`);break}n.push(r(e,s,c))}return a&&0===n.length?u.failure():u.success(n)}},485:function(e,t,n){"use strict";var s=n(480),r=n(23);const i=r.a.get("core/data_formats/parsing/ninja/njcm");var o;function u(e,t){const n=e.u32(),s=e.u32(),r=e.vec3_f32(),i=e.f32(),u=[],c=[];if(n){e.seek_start(n);for(const n of a(e,t,!0))if(n.type===o.Vertex)for(const e of n.vertices)u[e.index]={position:e.position,normal:e.normal,bone_weight:e.bone_weight,bone_weight_status:e.bone_weight_status,calc_continue:e.calc_continue}}if(s){e.seek_start(s);let n=void 0,r=void 0,i=void 0;for(const s of a(e,t,!1))switch(s.type){case o.Bits:r=s.src_alpha,i=s.dst_alpha;break;case o.Tiny:n=s.texture_id;break;case o.Material:r=s.src_alpha,i=s.dst_alpha;break;case o.Strip:for(const e of s.triangle_strips)e.texture_id=n,e.src_alpha=r,e.dst_alpha=i;c.push(...s.triangle_strips)}}return{type:"njcm",vertices:u,meshes:c,collision_sphere_center:r,collision_sphere_radius:i}}function a(e,t,n){const s=[];let r=!0;for(;r;){const u=e.u8(),f=e.u8(),_=e.position;let p=0;if(0===u)s.push({type:o.Null,type_id:u});else if(1<=u&&u<=3)s.push({type:o.Bits,type_id:u,src_alpha:f>>>3&7,dst_alpha:7&f});else if(4===u){const n=f,i=e.position;s.push({type:o.CachePolygonList,type_id:u,cache_index:n,offset:i}),t[n]=i,r=!1}else if(5===u){const r=f,i=t[r];null!=i&&(e.seek_start(i),s.push(...a(e,t,n))),s.push({type:o.DrawPolygonList,type_id:u,cache_index:r})}else if(8<=u&&u<=9){p=2;const t=e.u16();s.push({type:o.Tiny,type_id:u,flip_u:0!=(128&u),flip_v:0!=(64&u),clamp_u:0!=(32&u),clamp_v:0!=(16&u),mipmap_d_adjust:15&u,filter_mode:t>>>14,super_sample:0!=(64&t),texture_id:8191&t})}else if(17<=u&&u<=31){let t,n,r;p=2+2*e.u16(),0!=(1&f)&&(t={b:e.u8()/255,g:e.u8()/255,r:e.u8()/255,a:e.u8()/255}),0!=(2&f)&&(n={b:e.u8()/255,g:e.u8()/255,r:e.u8()/255,a:e.u8()/255}),0!=(4&f)&&(r={b:e.u8(),g:e.u8(),r:e.u8(),e:e.u8()}),s.push({type:o.Material,type_id:u,src_alpha:f>>>3&7,dst_alpha:7&f,diffuse:t,ambient:n,specular:r})}else 32<=u&&u<=50?(p=2+4*e.u16(),s.push({type:o.Vertex,type_id:u,vertices:c(e,u,f)})):56<=u&&u<=58?(p=2+2*e.u16(),s.push({type:o.Volume,type_id:u})):64<=u&&u<=75?(p=2+2*e.u16(),s.push({type:o.Strip,type_id:u,triangle_strips:l(e,u,f)})):255===u?(p=n?2:0,s.push({type:o.End,type_id:u}),r=!1):(p=2+2*e.u16(),s.push({type:o.Unknown,type_id:u}),i.warn(`Unknown chunk type ${u} at offset ${_}.`));e.seek_start(_+p)}return s}function c(e,t,n){if(t<32||t>50)return i.warn(`Unknown vertex chunk type ${t}.`),[];const s=3&n,r=0!=(128&n),o=e.u16(),u=e.u16(),a=[];for(let n=0;n<u;++n){const i={index:o+n,position:e.vec3_f32(),bone_weight:1,bone_weight_status:s,calc_continue:r};if(32===t)e.seek(4);else if(33===t)e.seek(4),i.normal=e.vec3_f32(),e.seek(4);else if(35<=t&&t<=40)37===t?(i.index=o+e.u16(),i.bone_weight=e.u16()/255):e.seek(4);else if(41<=t&&t<=47)i.normal=e.vec3_f32(),t>=42&&(44===t?(i.index=o+e.u16(),i.bone_weight=e.u16()/255):e.seek(4));else if(48<=t&&t<=50){const n=e.u32();i.normal={x:(n>>20&1023)/1023,y:(n>>10&1023)/1023,z:(1023&n)/1023},t>=49&&e.seek(4)}a.push(i)}return a}function l(e,t,n){const s={ignore_light:0!=(1&n),ignore_specular:0!=(2&n),ignore_ambient:0!=(4&n),use_alpha:0!=(8&n),double_side:0!=(16&n),flat_shading:0!=(32&n),environment_mapping:0!=(64&n)},r=e.u16(),i=r>>>14,o=16383&r;let u=!1,a=!1,c=!1,l=!1;switch(t){case 64:break;case 65:case 66:u=!0;break;case 67:c=!0;break;case 68:case 69:u=!0,c=!0;break;case 70:a=!0;break;case 71:case 72:u=!0,a=!0;break;case 73:break;case 74:case 75:l=!0;break;default:throw new Error(`Unexpected chunk type ID: ${t}.`)}const f=[];for(let t=0;t<o;++t){const t=e.i16(),n=t<1,r=Math.abs(t),o=[];for(let t=0;t<r;++t){const n={index:e.u16()};o.push(n),u&&(n.tex_coords={x:e.u16()/255,y:e.u16()/255}),a&&e.seek(4),c&&(n.normal={x:e.u16()/255,y:e.u16()/255,z:e.u16()/255}),l&&e.seek(8),t>=2&&e.seek(2*i)}f.push(Object.assign(Object.assign({},s),{clockwise_winding:n,has_tex_coords:u,has_normal:c,vertices:o}))}return f}!function(e){e[e.Unknown=0]="Unknown",e[e.Null=1]="Null",e[e.Bits=2]="Bits",e[e.CachePolygonList=3]="CachePolygonList",e[e.DrawPolygonList=4]="DrawPolygonList",e[e.Tiny=5]="Tiny",e[e.Material=6]="Material",e[e.Vertex=7]="Vertex",e[e.Volume=8]="Volume",e[e.Strip=9]="Strip",e[e.End=10]="End"}(o||(o={}));const f=r.a.get("core/data_formats/parsing/ninja/xj");function _(e){e.seek(4);const t=e.u32(),n=e.u32(),s=e.u32(),r=e.u32(),i=e.u32(),o=e.u32(),u={type:"xj",vertices:[],meshes:[],collision_sphere_position:e.vec3_f32(),collision_sphere_radius:e.f32()};return n>=1&&(n>1&&f.warn(`Vertex info count of ${n} was larger than expected.`),u.vertices.push(...function(e,t){e.seek_start(t);const n=e.u16();e.seek(2);const s=e.u32(),r=e.u32(),i=e.u32(),o=[];for(let t=0;t<i;++t){e.seek_start(s+t*r);const i=e.vec3_f32();let u,a;switch(n){case 3:u=e.vec3_f32(),a=e.vec2_f32();break;case 4:break;case 5:e.seek(4),a=e.vec2_f32();break;case 6:u=e.vec3_f32();break;case 7:u=e.vec3_f32(),a=e.vec2_f32();break;default:f.warn(`Unknown vertex type ${n} with size ${r}.`)}o.push({position:i,normal:u,uv:a})}return o}(e,t))),u.meshes.push(...p(e,s,r)),u.meshes.push(...p(e,i,o)),u}function p(e,t,n){const s=[];for(let r=0;r<n;++r){e.seek_start(t+20*r);const n=e.u32(),i=e.u32(),o=e.u32(),u=e.u32(),a=h(e,n,i);e.seek_start(o);const c=e.u16_array(u);s.push({material_properties:a,indices:c})}return s}function h(e,t,n){const s={};for(let r=0;r<n;++r){switch(e.seek_start(t+16*r),e.u32()){case 2:s.src_alpha=e.u32(),s.dst_alpha=e.u32();break;case 3:s.texture_id=e.u32();break;case 5:s.diffuse_r=e.u8(),s.diffuse_g=e.u8(),s.diffuse_b=e.u8(),s.diffuse_a=e.u8()}}return s}var d=n(457);n.d(t,"a",(function(){return b})),n.d(t,"b",(function(){return y})),n.d(t,"c",(function(){return g})),n.d(t,"d",(function(){return v})),n.d(t,"e",(function(){return w}));const b=2*Math.PI/65535,k=1296255566;function y(e){return"njcm"===e.type}class m{constructor(e,t,n,s,r,i){this.bone_cache=new Map,this._bone_count=-1,this.evaluation_flags=e,this.model=t,this.position=n,this.rotation=s,this.scale=r,this._children=i,this.children=this._children}bone_count(){if(-1===this._bone_count){const e=[0];this.get_bone_internal(this,Number.MAX_SAFE_INTEGER,e),this._bone_count=e[0]}return this._bone_count}get_bone(e){let t=this.bone_cache.get(e);return void 0===t&&(t=this.get_bone_internal(this,e,[0]),this.bone_cache.set(e,t||null)),t||void 0}add_child(e){this._bone_count=-1,this.bone_cache.clear(),this._children.push(e)}get_bone_internal(e,t,n){if(!e.evaluation_flags.skip){const s=n[0]++;if(this.bone_cache.set(s,e),s===t)return e}if(!e.evaluation_flags.break_child_trace)for(const s of e.children){const e=this.get_bone_internal(s,t,n);if(e)return e}}}function g(e){return x(e,u,[])}function v(e){return x(e,_,void 0)}function w(e){return j(e,_,void 0)}function x(e,t,n){const r=Object(s.a)(e);if(!r.success)return r;const i=r.value.filter(e=>e.type===k),o=[];for(const e of i)o.push(...j(e.data,t,n));return Object(d.c)(o,r.problems)}function j(e,t,n){const s=e.u32(),r=0!=(1&s),i=0!=(2&s),o=0!=(4&s),u=0!=(8&s),a=0!=(16&s),c=0!=(32&s),l=0!=(64&s),f=0!=(128&s),_=e.u32(),p=e.vec3_f32(),h={x:e.i32()*b,y:e.i32()*b,z:e.i32()*b},d=e.vec3_f32(),k=e.u32(),y=e.u32();let g,v,w;return _&&(e.seek_start(_),g=t(e,n)),k?(e.seek_start(k),v=j(e,t,n)):v=[],y?(e.seek_start(y),w=j(e,t,n)):w=[],[new m({no_translate:r,no_rotate:i,no_scale:o,hidden:u,break_child_trace:a,zxy_rotation_order:c,skip:l,shape_skip:f},g,p,h,d,v),...w]}},545:function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return u}));var s=n(485);const r=1296321870;var i,o;function u(e,t){return e.u32()===r?function(e,t){const n=e.u32();return a(e.take(n),t)}(e,t):(e.seek_start(0),function(e,t){e.seek_end(16);const n=e.u32();e.seek_start(n);const s=e.u32();return e.seek_start(s),function(e,t){e.seek(4);const n=e.u32();return e.seek_start(n),a(e,t)}(e,t)}(e,t))}function a(e,t){let n=e.u32();const s=e.u32(),r=e.u16(),i=e.u16(),u=(192&i)>>6,a=15&i,f=[];for(let i=0;i<t;i++){e.seek_start(n),n=n+=8*a;const t={tracks:[]};f.push(t);const i=[],u=[];for(let t=0;t<a;t++)i.push(e.u32());for(let t=0;t<a;t++){const t=e.u32();u.push(t)}if(1&r){e.seek_start(i.shift());const n=u.shift();n&&t.tracks.push({type:o.Position,keyframes:c(e,n)})}if(2&r){e.seek_start(i.shift());const n=u.shift();n&&t.tracks.push({type:o.Rotation,keyframes:l(e,n,s)})}if(4&r){e.seek_start(i.shift());const n=u.shift();n&&t.tracks.push({type:o.Scale,keyframes:c(e,n)})}}return{motion_data:f,frame_count:s,type:r,interpolation:u,element_count:a}}function c(e,t){const n=[];for(let s=0;s<t;++s)n.push({frame:e.u32(),value:e.vec3_f32()});return n}function l(e,t,n){const r=[],i=e.position;for(let n=0;n<t;++n)r.push({frame:e.u16(),value:{x:e.u16()*s.a,y:e.u16()*s.a,z:e.u16()*s.a}});let o=-1;for(const{frame:s}of r){if(s<o||s>=n)return e.seek_start(i),f(e,t);o=s}return r}function f(e,t){const n=[];for(let r=0;r<t;++r)n.push({frame:e.u32(),value:{x:e.i32()*s.a,y:e.i32()*s.a,z:e.i32()*s.a}});return n}!function(e){e[e.Linear=0]="Linear",e[e.Spline=1]="Spline",e[e.UserFunction=2]="UserFunction"}(i||(i={})),function(e){e[e.Position=0]="Position",e[e.Rotation=1]="Rotation",e[e.Scale=2]="Scale"}(o||(o={}))}}]); |