mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 15:28: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=
|