diff --git a/editor/sw.js b/editor/sw.js index 434d9131024c27..636932e657c904 100644 --- a/editor/sw.js +++ b/editor/sw.js @@ -14,7 +14,6 @@ const assets = [ '../examples/jsm/libs/chevrotain.module.min.js', '../examples/jsm/libs/fflate.module.min.js', - '../examples/jsm/libs/inflate.module.min.js', '../examples/jsm/libs/jszip.module.min.js', '../examples/js/libs/draco/draco_decoder.js', diff --git a/examples/js/libs/fflate.min.js b/examples/js/libs/fflate.min.js index c52254a0e48381..d2e3694c3f8f1f 100644 --- a/examples/js/libs/fflate.min.js +++ b/examples/js/libs/fflate.min.js @@ -1 +1,7 @@ +/*! +fflate - fast JavaScript compression/decompression + +Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE +Subset included: synchronous unzip, gunzip, and unzlib +*/ !function(f){typeof exports=="object"&&typeof module!="undefined"?module.exports=f():typeof define=='function'&&define.amd?define([],f):(typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"&&self).fflate=f()}(function(_e){"use strict";var _e={},r=Uint8Array,n=Uint16Array,e=Uint32Array,t=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),i=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=function(r,t){for(var a=new n(31),i=0;i<31;++i)a[i]=t+=1<>>1|(21845&h)<<1;s=(61680&(s=(52428&s)>>>2|(13107&s)<<2))>>>4|(3855&s)<<4,w[h]=((65280&s)>>>8|(255&s)<<8)>>>1}var d=function(r,e){for(var t=r.length,a=0,i=new n(e);a>>u]=v;return f},p=new r(288);for(h=0;h<144;++h)p[h]=8;for(h=144;h<256;++h)p[h]=9;for(h=256;h<280;++h)p[h]=7;for(h=280;h<288;++h)p[h]=8;var g=new r(32);for(h=0;h<32;++h)g[h]=5;var y=d(p,9),b=d(g,5),x=function(r){for(var n=r[0],e=1;en&&(n=r[e]);return n},z=function(r,n,e){var t=n/8>>0;return(r[t]|r[t+1]<<8)>>>(7&n)&e},C=function(r,n){var e=n/8>>0;return(r[e]|r[e+1]<<8|r[e+2]<<16)>>>(7&n)},m=function(r){return(r/8>>0)+(7&r&&1)},S=function(t,a,i){(null==a||a<0)&&(a=0),(null==i||i>t.length)&&(i=t.length);var o=new(t instanceof n?n:t instanceof e?e:r)(i-a);return o.set(t.subarray(a,i)),o},F=function(n,e){var o=n.length,f=!e;e||(e=new r(3*o));var v,c,w,h,s=function(n){var t=e.length;if(n>t){var a=new r(Math.max(2*t,n));a.set(e),e=a}},p=0,g=0,F=0;if(p&&!v)return e;var E=8*o;do{p=z(n,g,1);var O=z(n,g+1,3);if(g+=3,O){if(1==O)v=y,c=b,w=9,h=5;else{if(2!=O)throw"invalid block type";var U=z(n,g,31)+257,k=z(n,g+10,15)+4,A=U+z(n,g+5,31)+1;g+=14;for(var D=new r(A),T=new r(19),M=0;M>>4)<16)D[M++]=Y;else{var H=0,I=0;for(16==Y?(I=3+z(n,g,3),g+=2,H=D[M-1]):17==Y?(I=3+z(n,g,7),g+=3):18==Y&&(I=11+z(n,g,127),g+=7);I--;)D[M++]=H}}var J=D.subarray(0,U),K=D.subarray(U);w=x(J),h=x(K),v=d(J,w),c=d(K,h)}if(g>E)throw"unexpected EOF";f&&s(F+131072);for(var L=(1<>>4;if((g+=15&H)>E)throw"unexpected EOF";if(!H)throw"invalid length/literal";if(P<256)e[F++]=P;else{if(256==P)break;var Q=P-254;if(P>264){var R=t[M=P-257];Q=z(n,g,(1<>>4;if(!V)throw"invalid distance";g+=15&V;K=l[W];if(W>3){R=a[W];K+=C(n,g)&(1<E)throw"unexpected EOF";f&&s(F+131072);for(var X=F+Q;Fo)throw"unexpected EOF";f&&s(F+Z),e.set(n.subarray(Y,$),F),F+=Z,g=8*$}}while(!p);return F==e.length?e:S(e,0,F)},E=function(r,n){return r[n]|r[n+1]<<8},O=function(r,n){return(r[n]|r[n+1]<<8|r[n+2]<<16)+2*(r[n+3]<<23)},U=function(r){if(31!=r[0]||139!=r[1]||8!=r[2])throw"invalid gzip data";var n=r[3],e=10;4&n&&(e+=r[10]|2+(r[11]<<8));for(var t=(n>>3&1)+(n>>4&1);t>0;t-=!r[e++]);return e+(2&n)},k=function(r){var n=r.length;return(r[n-4]|r[n-3]<<8|r[n-2]<<16)+2*(r[n-1]<<23)},A=function(r){if(8!=(15&r[0])||r[0]>>>4>7||(r[0]<<8|r[1])%31)throw"invalid zlib data";if(32&r[1])throw"invalid zlib data: preset dictionaries not supported"};function D(r,n){return F(r,n)}function T(n,e){return F(n.subarray(U(n),-8),e||new r(k(n)))}_e.gunzipSync=T;function M(r,n){return F((A(r),r.subarray(2,-4)),n)}_e.unzlibSync=M;function j(r,n){var e="";if(!n&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);for(var t=0;t>10,56320|1023&a))}return e}_e.strFromU8=j;var q=function(r,n){return n+30+E(r,n+26)+E(r,n+28)},B=function(r,n,e){var t=E(r,n+28),a=j(r.subarray(n+46,n+46+t),!(2048&E(r,n+8))),i=n+46+t,o=e?G(r,i):[O(r,n+20),O(r,n+24),O(r,n+42)],f=o[0],u=o[1],v=o[2];return[E(r,n+10),f,u,a,i+E(r,n+30)+E(r,n+32),v]},G=function(r,n){for(;1!=E(r,n);n+=4+E(r,n+2));return[O(r,n+12),O(r,n+4),O(r,n+20)]};_e.unzipSync=function(n){for(var e={},t=n.length-22;101010256!=O(n,t);--t)if(!t||n.length-t>65558)throw"invalid zip file";var a=E(n,t+8);if(!a)return{};var i=O(n,t+16),o=4294967295==i;if(o){if(t=O(n,t-12),101075792!=O(n,t))throw"invalid zip file";a=O(n,t+32),i=O(n,t+48)}for(var f=0;fa&&(a=c[p]),c[p]>=1;x=g<<16|p;for(s=m;s>>=1;switch(c){case 0:var d=this.input,a=this.a,b=this.c,e=this.b,f=d.length,g=l,h=l,k=b.length,m=l;this.d=this.f=0;if(a+1>=f)throw Error("invalid uncompressed block header: LEN");g=d[a++]|d[a++]<<8;if(a+1>=f)throw Error("invalid uncompressed block header: NLEN");h=d[a++]|d[a++]<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case A:for(;e+ -g>b.length;){m=k-e;g-=m;if(t)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.b=e;b=this.e();e=this.b}break;case y:for(;e+g>b.length;)b=this.e({p:2});break;default:throw Error("invalid inflate mode");}if(t)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.a=a;this.b=e;this.c=b;break;case 1:this.j(ba,ca);break;case 2:for(var n=C(this,5)+257,p=C(this,5)+1,s=C(this,4)+4,x=new (t?Uint8Array:Array)(D.length),S=l,T=l,U=l,u=l,M=l,F=l,z=l,q=l,V=l,q=0;q=P?8:255>=P?9:279>=P?7:8;var ba=v(O),Q=new (t?Uint8Array:Array)(30),R,ga;R=0;for(ga=Q.length;R=g)throw Error("input buffer is broken");a|=e[f++]<>>d;c.d=b-d;c.a=f;return h} -function E(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h=d[0],k=d[1],m,n;b=g);)a|=e[f++]<>>16;if(n>b)throw Error("invalid code length: "+n);c.f=a>>n;c.d=b-n;c.a=f;return m&65535} -w.prototype.j=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length-258,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(this.b=b,a=this.e(),b=this.b),a[b++]=f;else{g=f-257;k=I[g];0=e&&(this.b=b,a=this.e(),b=this.b);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; -w.prototype.w=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=I[g];0e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; -w.prototype.e=function(){var c=new (t?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,b,e=this.c;if(t)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;aa;++a)e[a]=e[d+a];this.b=32768;return e}; -w.prototype.z=function(c){var d,a=this.input.length/this.a+1|0,b,e,f,g=this.input,h=this.c;c&&("number"===typeof c.p&&(a=c.p),"number"===typeof c.u&&(a+=c.u));2>a?(b=(g.length-this.a)/this.o[2],f=258*(b/2)|0,e=fd&&(this.c.length=d),c=this.c);return this.buffer=c};function W(c,d){var a,b;this.input=c;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=c[this.a++];b=c[this.a++];switch(a&15){case ha:this.method=ha;break;default:throw Error("unsupported compression method");}if(0!==((a<<8)+b)%31)throw Error("invalid fcheck flag:"+((a<<8)+b)%31);if(b&32)throw Error("fdict flag is not supported");this.q=new w(c,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})} -W.prototype.k=function(){var c=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(c[this.a++]<<24|c[this.a++]<<16|c[this.a++]<<8|c[this.a++])>>>0;var b=d;if("string"===typeof b){var e=b.split(""),f,g;f=0;for(g=e.length;f>>0;b=e}for(var h=1,k=0,m=b.length,n,p=0;0>>0)throw Error("invalid adler-32 checksum");}return d};var ha=8;r("Zlib.Inflate",W);r("Zlib.Inflate.prototype.decompress",W.prototype.k);var X={ADAPTIVE:B.s,BLOCK:B.t},Y,Z,$,ia;if(Object.keys)Y=Object.keys(X);else for(Z in Y=[],$=0,X)Y[$++]=Z;$=0;for(ia=Y.length;$ 0 ) { var compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize ); - var inflate = new Inflate( compressed, { resize: true, verify: true } ); // eslint-disable-line no-undef - var rleBuffer = decodeRunLength( inflate.decompress().buffer ); + var data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef + var rleBuffer = decodeRunLength( data.buffer ); inOffset.value += dwaHeader.rleCompressedSize; diff --git a/examples/js/loaders/FBXLoader.js b/examples/js/loaders/FBXLoader.js index 3f9a31d4141b06..520b8c402373dd 100644 --- a/examples/js/loaders/FBXLoader.js +++ b/examples/js/loaders/FBXLoader.js @@ -3563,14 +3563,14 @@ THREE.FBXLoader = ( function () { } - if ( typeof Inflate === 'undefined' ) { + if ( typeof fflate === 'undefined' ) { - console.error( 'THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js' ); + console.error( 'THREE.FBXLoader: External library fflate.min.js required.' ); } - var inflate = new Inflate( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef - var reader2 = new BinaryReader( inflate.decompress().buffer ); + var data = fflate.unzlibSync( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef + var reader2 = new BinaryReader( data.buffer ); switch ( type ) { diff --git a/examples/js/loaders/VTKLoader.js b/examples/js/loaders/VTKLoader.js index 476d23e9482c92..790f0cade93aaf 100644 --- a/examples/js/loaders/VTKLoader.js +++ b/examples/js/loaders/VTKLoader.js @@ -785,9 +785,8 @@ THREE.VTKLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype for ( var i = 0; i < dataOffsets.length - 1; i ++ ) { - var inflate = new Inflate( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ), { resize: true, verify: true } ); // eslint-disable-line no-undef - content = inflate.decompress(); - content = content.buffer; + var data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef + content = data.buffer; if ( ele.attributes.type === 'Float32' ) { diff --git a/examples/jsm/libs/fflate.module.min.js b/examples/jsm/libs/fflate.module.min.js index 5900239f5edccc..60235560eac3f4 100644 --- a/examples/jsm/libs/fflate.module.min.js +++ b/examples/jsm/libs/fflate.module.min.js @@ -1 +1,7 @@ +/*! +fflate - fast JavaScript compression/decompression + +Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE +Subset included: synchronous unzip, gunzip, and unzlib +*/ "use strict";var r=Uint8Array,n=Uint16Array,e=Uint32Array,t=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),a=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),i=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=function(r,t){for(var a=new n(31),i=0;i<31;++i)a[i]=t+=1<>>1|(21845&h)<<1;s=(61680&(s=(52428&s)>>>2|(13107&s)<<2))>>>4|(3855&s)<<4,w[h]=((65280&s)>>>8|(255&s)<<8)>>>1}var d=function(r,e){for(var t=r.length,a=0,i=new n(e);a>>u]=v;return f},p=new r(288);for(h=0;h<144;++h)p[h]=8;for(h=144;h<256;++h)p[h]=9;for(h=256;h<280;++h)p[h]=7;for(h=280;h<288;++h)p[h]=8;var g=new r(32);for(h=0;h<32;++h)g[h]=5;var y=d(p,9),b=d(g,5),x=function(r){for(var n=r[0],e=1;en&&(n=r[e]);return n},z=function(r,n,e){var t=n/8>>0;return(r[t]|r[t+1]<<8)>>>(7&n)&e},C=function(r,n){var e=n/8>>0;return(r[e]|r[e+1]<<8|r[e+2]<<16)>>>(7&n)},m=function(r){return(r/8>>0)+(7&r&&1)},S=function(t,a,i){(null==a||a<0)&&(a=0),(null==i||i>t.length)&&(i=t.length);var o=new(t instanceof n?n:t instanceof e?e:r)(i-a);return o.set(t.subarray(a,i)),o},F=function(n,e){var o=n.length,f=!e;e||(e=new r(3*o));var v,c,w,h,s=function(n){var t=e.length;if(n>t){var a=new r(Math.max(2*t,n));a.set(e),e=a}},p=0,g=0,F=0;if(p&&!v)return e;var E=8*o;do{p=z(n,g,1);var O=z(n,g+1,3);if(g+=3,O){if(1==O)v=y,c=b,w=9,h=5;else{if(2!=O)throw"invalid block type";var U=z(n,g,31)+257,k=z(n,g+10,15)+4,A=U+z(n,g+5,31)+1;g+=14;for(var D=new r(A),T=new r(19),M=0;M>>4)<16)D[M++]=Y;else{var H=0,I=0;for(16==Y?(I=3+z(n,g,3),g+=2,H=D[M-1]):17==Y?(I=3+z(n,g,7),g+=3):18==Y&&(I=11+z(n,g,127),g+=7);I--;)D[M++]=H}}var J=D.subarray(0,U),K=D.subarray(U);w=x(J),h=x(K),v=d(J,w),c=d(K,h)}if(g>E)throw"unexpected EOF";f&&s(F+131072);for(var L=(1<>>4;if((g+=15&H)>E)throw"unexpected EOF";if(!H)throw"invalid length/literal";if(P<256)e[F++]=P;else{if(256==P)break;var Q=P-254;if(P>264){var R=t[M=P-257];Q=z(n,g,(1<>>4;if(!V)throw"invalid distance";g+=15&V;K=l[W];if(W>3){R=a[W];K+=C(n,g)&(1<E)throw"unexpected EOF";f&&s(F+131072);for(var X=F+Q;Fo)throw"unexpected EOF";f&&s(F+Z),e.set(n.subarray(Y,$),F),F+=Z,g=8*$}}while(!p);return F==e.length?e:S(e,0,F)},E=function(r,n){return r[n]|r[n+1]<<8},O=function(r,n){return(r[n]|r[n+1]<<8|r[n+2]<<16)+2*(r[n+3]<<23)},U=function(r){if(31!=r[0]||139!=r[1]||8!=r[2])throw"invalid gzip data";var n=r[3],e=10;4&n&&(e+=r[10]|2+(r[11]<<8));for(var t=(n>>3&1)+(n>>4&1);t>0;t-=!r[e++]);return e+(2&n)},k=function(r){var n=r.length;return(r[n-4]|r[n-3]<<8|r[n-2]<<16)+2*(r[n-1]<<23)},A=function(r){if(8!=(15&r[0])||r[0]>>>4>7||(r[0]<<8|r[1])%31)throw"invalid zlib data";if(32&r[1])throw"invalid zlib data: preset dictionaries not supported"};function D(r,n){return F(r,n)}function T(n,e){return F(n.subarray(U(n),-8),e||new r(k(n)))};export var gunzipSync=T;function M(r,n){return F((A(r),r.subarray(2,-4)),n)};export var unzlibSync=M;function j(r,n){var e="";if(!n&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(r);for(var t=0;t>10,56320|1023&a))}return e};export var strFromU8=j;var q=function(r,n){return n+30+E(r,n+26)+E(r,n+28)},B=function(r,n,e){var t=E(r,n+28),a=j(r.subarray(n+46,n+46+t),!(2048&E(r,n+8))),i=n+46+t,o=e?G(r,i):[O(r,n+20),O(r,n+24),O(r,n+42)],f=o[0],u=o[1],v=o[2];return[E(r,n+10),f,u,a,i+E(r,n+30)+E(r,n+32),v]},G=function(r,n){for(;1!=E(r,n);n+=4+E(r,n+2));return[O(r,n+12),O(r,n+4),O(r,n+20)]};export var unzipSync=function(n){for(var e={},t=n.length-22;101010256!=O(n,t);--t)if(!t||n.length-t>65558)throw"invalid zip file";var a=E(n,t+8);if(!a)return{};var i=O(n,t+16),o=4294967295==i;if(o){if(t=O(n,t-12),101075792!=O(n,t))throw"invalid zip file";a=O(n,t+32),i=O(n,t+48)}for(var f=0;fa&&(a=c[p]),c[p]>=1;x=g<<16|p;for(s=m;s>>=1;switch(c){case 0:var d=this.input,a=this.a,b=this.c,e=this.b,f=d.length,g=l,h=l,k=b.length,m=l;this.d=this.f=0;if(a+1>=f)throw Error("invalid uncompressed block header: LEN");g=d[a++]|d[a++]<<8;if(a+1>=f)throw Error("invalid uncompressed block header: NLEN");h=d[a++]|d[a++]<<8;if(g===~h)throw Error("invalid uncompressed block header: length verify");if(a+g>d.length)throw Error("input buffer is broken");switch(this.i){case A:for(;e+ -g>b.length;){m=k-e;g-=m;if(t)b.set(d.subarray(a,a+m),e),e+=m,a+=m;else for(;m--;)b[e++]=d[a++];this.b=e;b=this.e();e=this.b}break;case y:for(;e+g>b.length;)b=this.e({p:2});break;default:throw Error("invalid inflate mode");}if(t)b.set(d.subarray(a,a+g),e),e+=g,a+=g;else for(;g--;)b[e++]=d[a++];this.a=a;this.b=e;this.c=b;break;case 1:this.j(ba,ca);break;case 2:for(var n=C(this,5)+257,p=C(this,5)+1,s=C(this,4)+4,x=new (t?Uint8Array:Array)(D.length),S=l,T=l,U=l,u=l,M=l,F=l,z=l,q=l,V=l,q=0;q=P?8:255>=P?9:279>=P?7:8;var ba=v(O),Q=new (t?Uint8Array:Array)(30),R,ga;R=0;for(ga=Q.length;R=g)throw Error("input buffer is broken");a|=e[f++]<>>d;c.d=b-d;c.a=f;return h} -function E(c,d){for(var a=c.f,b=c.d,e=c.input,f=c.a,g=e.length,h=d[0],k=d[1],m,n;b=g);)a|=e[f++]<>>16;if(n>b)throw Error("invalid code length: "+n);c.f=a>>n;c.d=b-n;c.a=f;return m&65535} -w.prototype.j=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length-258,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(this.b=b,a=this.e(),b=this.b),a[b++]=f;else{g=f-257;k=I[g];0=e&&(this.b=b,a=this.e(),b=this.b);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; -w.prototype.w=function(c,d){var a=this.c,b=this.b;this.o=c;for(var e=a.length,f,g,h,k;256!==(f=E(this,c));)if(256>f)b>=e&&(a=this.e(),e=a.length),a[b++]=f;else{g=f-257;k=I[g];0e&&(a=this.e(),e=a.length);for(;k--;)a[b]=a[b++-h]}for(;8<=this.d;)this.d-=8,this.a--;this.b=b}; -w.prototype.e=function(){var c=new (t?Uint8Array:Array)(this.b-32768),d=this.b-32768,a,b,e=this.c;if(t)c.set(e.subarray(32768,c.length));else{a=0;for(b=c.length;aa;++a)e[a]=e[d+a];this.b=32768;return e}; -w.prototype.z=function(c){var d,a=this.input.length/this.a+1|0,b,e,f,g=this.input,h=this.c;c&&("number"===typeof c.p&&(a=c.p),"number"===typeof c.u&&(a+=c.u));2>a?(b=(g.length-this.a)/this.o[2],f=258*(b/2)|0,e=fd&&(this.c.length=d),c=this.c);return this.buffer=c};function W(c,d){var a,b;this.input=c;this.a=0;if(d||!(d={}))d.index&&(this.a=d.index),d.verify&&(this.A=d.verify);a=c[this.a++];b=c[this.a++];switch(a&15){case ha:this.method=ha;break;default:throw Error("unsupported compression method");}if(0!==((a<<8)+b)%31)throw Error("invalid fcheck flag:"+((a<<8)+b)%31);if(b&32)throw Error("fdict flag is not supported");this.q=new w(c,{index:this.a,bufferSize:d.bufferSize,bufferType:d.bufferType,resize:d.resize})} -W.prototype.k=function(){var c=this.input,d,a;d=this.q.k();this.a=this.q.a;if(this.A){a=(c[this.a++]<<24|c[this.a++]<<16|c[this.a++]<<8|c[this.a++])>>>0;var b=d;if("string"===typeof b){var e=b.split(""),f,g;f=0;for(g=e.length;f>>0;b=e}for(var h=1,k=0,m=b.length,n,p=0;0>>0)throw Error("invalid adler-32 checksum");}return d};var ha=8;r("Zlib.Inflate",W);r("Zlib.Inflate.prototype.decompress",W.prototype.k);var X={ADAPTIVE:B.s,BLOCK:B.t},Y,Z,$,ia;if(Object.keys)Y=Object.keys(X);else for(Z in Y=[],$=0,X)Y[$++]=Z;$=0;for(ia=Y.length;$ 0 ) { var compressed = info.array.slice( inOffset.value, inOffset.value + dwaHeader.rleCompressedSize ); - var inflate = new Inflate( compressed, { resize: true, verify: true } ); // eslint-disable-line no-undef - var rleBuffer = decodeRunLength( inflate.decompress().buffer ); + var data = fflate.unzlibSync( compressed ); // eslint-disable-line no-undef + var rleBuffer = decodeRunLength( data.buffer ); inOffset.value += dwaHeader.rleCompressedSize; diff --git a/examples/jsm/loaders/FBXLoader.js b/examples/jsm/loaders/FBXLoader.js index 5b7a3dd1c5adaa..f976ef20f8551a 100644 --- a/examples/jsm/loaders/FBXLoader.js +++ b/examples/jsm/loaders/FBXLoader.js @@ -42,7 +42,7 @@ import { VectorKeyframeTrack, sRGBEncoding } from '../../../build/three.module.js'; -import { Inflate } from '../libs/inflate.module.min.js'; +import * as fflate from '../libs/fflate.module.min.js'; import { NURBSCurve } from '../curves/NURBSCurve.js'; /** @@ -3610,14 +3610,14 @@ var FBXLoader = ( function () { } - if ( typeof Inflate === 'undefined' ) { + if ( typeof fflate === 'undefined' ) { - console.error( 'THREE.FBXLoader: External library Inflate.min.js required, obtain or import from https://github.com/imaya/zlib.js' ); + console.error( 'THREE.FBXLoader: External library fflate.min.js required.' ); } - var inflate = new Inflate( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef - var reader2 = new BinaryReader( inflate.decompress().buffer ); + var data = fflate.unzlibSync( new Uint8Array( reader.getArrayBuffer( compressedLength ) ) ); // eslint-disable-line no-undef + var reader2 = new BinaryReader( data.buffer ); switch ( type ) { diff --git a/examples/jsm/loaders/VTKLoader.js b/examples/jsm/loaders/VTKLoader.js index 3f612c6ae5e5ae..6ebba6c9823020 100644 --- a/examples/jsm/loaders/VTKLoader.js +++ b/examples/jsm/loaders/VTKLoader.js @@ -6,7 +6,7 @@ import { Loader, LoaderUtils } from '../../../build/three.module.js'; -import { Inflate } from '../libs/inflate.module.min.js'; +import * as fflate from '../libs/fflate.module.min.js'; var VTKLoader = function ( manager ) { @@ -795,9 +795,8 @@ VTKLoader.prototype = Object.assign( Object.create( Loader.prototype ), { for ( var i = 0; i < dataOffsets.length - 1; i ++ ) { - var inflate = new Inflate( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ), { resize: true, verify: true } ); // eslint-disable-line no-undef - content = inflate.decompress(); - content = content.buffer; + var data = fflate.unzlibSync( byteData.slice( dataOffsets[ i ], dataOffsets[ i + 1 ] ) ); // eslint-disable-line no-undef + content = data.buffer; if ( ele.attributes.type === 'Float32' ) { diff --git a/utils/modularize.js b/utils/modularize.js index 20559465f9f6a7..a4b44fc6f1a300 100644 --- a/utils/modularize.js +++ b/utils/modularize.js @@ -71,8 +71,8 @@ var files = [ { path: 'loaders/ColladaLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' } ], ignoreList: [] }, { path: 'loaders/DDSLoader.js', dependencies: [], ignoreList: [] }, { path: 'loaders/DRACOLoader.js', dependencies: [], ignoreList: [ 'LoadingManager' ] }, - { path: 'loaders/EXRLoader.js', dependencies: [ { name: 'Inflate', path: 'libs/inflate.module.min.js' } ], ignoreList: [] }, - { path: 'loaders/FBXLoader.js', dependencies: [ { name: 'Inflate', path: 'libs/inflate.module.min.js' }, { name: 'NURBSCurve', path: 'curves/NURBSCurve.js' } ], ignoreList: [] }, + { path: 'loaders/EXRLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true } ], ignoreList: [] }, + { path: 'loaders/FBXLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true }, { name: 'NURBSCurve', path: 'curves/NURBSCurve.js' } ], ignoreList: [] }, { path: 'loaders/GCodeLoader.js', dependencies: [], ignoreList: [] }, { path: 'loaders/GLTFLoader.js', dependencies: [], ignoreList: [ 'NoSide', 'Matrix2', 'Camera', 'Texture' ] }, { path: 'loaders/HDRCubeTextureLoader.js', dependencies: [ { name: 'RGBELoader', path: 'loaders/RGBELoader.js' } ], ignoreList: [] }, @@ -97,7 +97,7 @@ var files = [ { path: 'loaders/TTFLoader.js', dependencies: [ { name: 'opentype', path: 'libs/opentype.module.min.js' } ], ignoreList: [ 'Font' ] }, { path: 'loaders/VRMLLoader.js', dependencies: [ { name: 'chevrotain', path: 'libs/chevrotain.module.min.js' } ], ignoreList: [] }, { path: 'loaders/VRMLoader.js', dependencies: [ { name: 'GLTFLoader', path: 'loaders/GLTFLoader.js' } ], ignoreList: [] }, - { path: 'loaders/VTKLoader.js', dependencies: [ { name: 'Inflate', path: 'libs/inflate.module.min.js' } ], ignoreList: [] }, + { path: 'loaders/VTKLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true } ], ignoreList: [] }, { path: 'loaders/XLoader.js', dependencies: [], ignoreList: [] }, { path: 'math/ColorConverter.js', dependencies: [], ignoreList: [] },