提交 ba27c858 编写于 作者: M Mugen87

Loaders: Replace JSZip and gunzip with fflate.

上级 6a05d603
......@@ -13,6 +13,7 @@ const assets = [
'../examples/jsm/controls/TransformControls.js',
'../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',
......
!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<<r[i-1];var o=new e(a[30]);for(i=1;i<30;++i)for(var f=a[i];f<a[i+1];++f)o[f]=f-a[i]<<5|i;return[a,o]},f=o(t,2),u=f[0],v=f[1];u[28]=258,v[258]=28;for(var c=o(a,0),l=c[0],w=(c[1],new n(32768)),h=0;h<32768;++h){var s=(43690&h)>>>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<t;++a)++i[r[a]-1];var o=new n(e);for(a=0;a<e;++a)o[a]=o[a-1]+i[a-1]<<1;var f=new n(1<<e),u=15-e;for(a=0;a<t;++a)if(r[a])for(var v=a<<4|r[a],c=e-r[a],l=o[r[a]-1]++<<c,h=l|(1<<c)-1;l<=h;++l)f[w[l]>>>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;e<r.length;++e)r[e]>n&&(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<k;++M)T[i[M]]=z(n,g+3*M,7);g+=3*k;var j=x(T),q=(1<<j)-1,B=d(T,j);for(M=0;M<A;){var G=B[z(n,g,q)];if(g+=15&G,(Y=G>>>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<<w)-1,N=(1<<h)-1;;){var P=(H=v[C(n,g)&L])>>>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<<R)-1)+u[M],g+=R}var V=c[C(n,g)&N],W=V>>>4;if(!V)throw"invalid distance";g+=15&V;K=l[W];if(W>3){R=a[W];K+=C(n,g)&(1<<R)-1,g+=R}if(g>E)throw"unexpected EOF";f&&s(F+131072);for(var X=F+Q;F<X;F+=4)e[F]=e[F-K],e[F+1]=e[F+1-K],e[F+2]=e[F+2-K],e[F+3]=e[F+3-K];F=X}}}else{var Y,Z=n[(Y=m(g)+4)-4]|n[Y-3]<<8,$=Y+Z;if($>o)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<r.length;){var a=r[t++];a<128||n?e+=String.fromCharCode(a):a<224?e+=String.fromCharCode((31&a)<<6|63&r[t++]):a<240?e+=String.fromCharCode((15&a)<<12|(63&r[t++])<<6|63&r[t++]):(a=((15&a)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,e+=String.fromCharCode(55296|a>>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;f<a;++f){var u=B(n,i,o),v=u[0],c=u[1],l=u[2],w=u[3],h=u[4],s=u[5],d=q(n,s);if(i=h,v){if(8!=v)throw"unknown compression type "+v;e[w]=D(n.subarray(d,d+c),new r(l))}else e[w]=S(n,d,d+c)}return e};return _e})
......@@ -88,20 +88,20 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
try {
zip = new JSZip( data ); // eslint-disable-line no-undef
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
} catch ( e ) {
if ( e instanceof ReferenceError ) {
console.error( 'THREE.3MFLoader: jszip missing and file is compressed.' );
console.error( 'THREE.3MFLoader: fflate missing and file is compressed.' );
return null;
}
}
for ( file in zip.files ) {
for ( file in zip ) {
if ( file.match( /\_rels\/.rels$/ ) ) {
......@@ -133,7 +133,7 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
//
var relsView = new Uint8Array( zip.file( relsName ).asArrayBuffer() );
var relsView = new Uint8Array( zip[ relsName ].buffer );
var relsFileText = THREE.LoaderUtils.decodeText( relsView );
rels = parseRelsXml( relsFileText );
......@@ -141,7 +141,7 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
if ( modelRelsName ) {
var relsView = new Uint8Array( zip.file( modelRelsName ).asArrayBuffer() );
var relsView = new Uint8Array( zip[ modelRelsName ].buffer );
var relsFileText = THREE.LoaderUtils.decodeText( relsView );
modelRels = parseRelsXml( relsFileText );
......@@ -152,7 +152,7 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
for ( var i = 0; i < modelPartNames.length; i ++ ) {
var modelPart = modelPartNames[ i ];
var view = new Uint8Array( zip.file( modelPart ).asArrayBuffer() );
var view = new Uint8Array( zip[ modelPart ].buffer );
var fileText = THREE.LoaderUtils.decodeText( view );
var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
......@@ -195,7 +195,7 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto
for ( var i = 0; i < texturesPartNames.length; i ++ ) {
var texturesPartName = texturesPartNames[ i ];
texturesParts[ texturesPartName ] = zip.file( texturesPartName ).asArrayBuffer();
texturesParts[ texturesPartName ] = zip[ texturesPartName ].buffer;
}
......
......@@ -11,7 +11,7 @@
* });
*
* Materials now supported, material colors supported
* Zip support, requires jszip
* Zip support, requires fflate
* No constellation support (yet)!
*
*/
......@@ -77,20 +77,20 @@ THREE.AMFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
try {
zip = new JSZip( data ); // eslint-disable-line no-undef
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
} catch ( e ) {
if ( e instanceof ReferenceError ) {
console.log( 'THREE.AMFLoader: jszip missing and file is compressed.' );
console.log( 'THREE.AMFLoader: fflate missing and file is compressed.' );
return null;
}
}
for ( file in zip.files ) {
for ( var file in zip ) {
if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
......@@ -101,7 +101,7 @@ THREE.AMFLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
}
console.log( 'THREE.AMFLoader: Trying to load file asset: ' + file );
view = new DataView( zip.file( file ).asArrayBuffer() );
view = new DataView( zip[ file ].buffer );
}
......
......@@ -47,11 +47,11 @@ THREE.KMZLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
function findFile( url ) {
for ( var path in zip.files ) {
for ( var path in zip ) {
if ( path.substr( - url.length ) === url ) {
return zip.files[ path ];
return zip[ path ];
}
......@@ -68,7 +68,7 @@ THREE.KMZLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
console.log( 'Loading', url );
var blob = new Blob( [ image.asArrayBuffer() ], { type: 'application/octet-stream' } );
var blob = new Blob( [ image.buffer ], { type: 'application/octet-stream' } );
return URL.createObjectURL( blob );
}
......@@ -79,18 +79,18 @@ THREE.KMZLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
//
var zip = new JSZip( data ); // eslint-disable-line no-undef
var zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
if ( zip.files[ 'doc.kml' ] ) {
if ( zip[ 'doc.kml' ] ) {
var xml = new DOMParser().parseFromString( zip.files[ 'doc.kml' ].asText(), 'application/xml' );
var xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
var model = xml.querySelector( 'Placemark Model Link href' );
if ( model ) {
var loader = new THREE.ColladaLoader( manager );
return loader.parse( zip.files[ model.textContent ].asText() );
return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); // eslint-disable-line no-undef
}
......@@ -98,14 +98,14 @@ THREE.KMZLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
console.warn( 'KMZLoader: Missing doc.kml file.' );
for ( var path in zip.files ) {
for ( var path in zip ) {
var extension = path.split( '.' ).pop().toLowerCase();
if ( extension === 'dae' ) {
var loader = new THREE.ColladaLoader( manager );
return loader.parse( zip.files[ path ].asText() );
return loader.parse( fflate.strFromU8( zip[ path ] ) ); // eslint-disable-line no-undef
}
......
......@@ -313,8 +313,7 @@ THREE.NRRDLoader.prototype = Object.assign( Object.create( THREE.Loader.prototyp
// we need to decompress the datastream
// here we start the unzipping and get a typed Uint8Array back
var inflate = new Zlib.Gunzip( new Uint8Array( _data ) ); // eslint-disable-line no-undef
_data = inflate.decompress();
_data = fflate.gunzipSync( new Uint8Array( _data ) );// eslint-disable-line no-undef
} else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) {
......
"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<<r[i-1];var o=new e(a[30]);for(i=1;i<30;++i)for(var f=a[i];f<a[i+1];++f)o[f]=f-a[i]<<5|i;return[a,o]},f=o(t,2),u=f[0],v=f[1];u[28]=258,v[258]=28;for(var c=o(a,0),l=c[0],w=(c[1],new n(32768)),h=0;h<32768;++h){var s=(43690&h)>>>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<t;++a)++i[r[a]-1];var o=new n(e);for(a=0;a<e;++a)o[a]=o[a-1]+i[a-1]<<1;var f=new n(1<<e),u=15-e;for(a=0;a<t;++a)if(r[a])for(var v=a<<4|r[a],c=e-r[a],l=o[r[a]-1]++<<c,h=l|(1<<c)-1;l<=h;++l)f[w[l]>>>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;e<r.length;++e)r[e]>n&&(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<k;++M)T[i[M]]=z(n,g+3*M,7);g+=3*k;var j=x(T),q=(1<<j)-1,B=d(T,j);for(M=0;M<A;){var G=B[z(n,g,q)];if(g+=15&G,(Y=G>>>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<<w)-1,N=(1<<h)-1;;){var P=(H=v[C(n,g)&L])>>>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<<R)-1)+u[M],g+=R}var V=c[C(n,g)&N],W=V>>>4;if(!V)throw"invalid distance";g+=15&V;K=l[W];if(W>3){R=a[W];K+=C(n,g)&(1<<R)-1,g+=R}if(g>E)throw"unexpected EOF";f&&s(F+131072);for(var X=F+Q;F<X;F+=4)e[F]=e[F-K],e[F+1]=e[F+1-K],e[F+2]=e[F+2-K],e[F+3]=e[F+3-K];F=X}}}else{var Y,Z=n[(Y=m(g)+4)-4]|n[Y-3]<<8,$=Y+Z;if($>o)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<r.length;){var a=r[t++];a<128||n?e+=String.fromCharCode(a):a<224?e+=String.fromCharCode((31&a)<<6|63&r[t++]):a<240?e+=String.fromCharCode((15&a)<<12|(63&r[t++])<<6|63&r[t++]):(a=((15&a)<<18|(63&r[t++])<<12|(63&r[t++])<<6|63&r[t++])-65536,e+=String.fromCharCode(55296|a>>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;f<a;++f){var u=B(n,i,o),v=u[0],c=u[1],l=u[2],w=u[3],h=u[4],s=u[5],d=q(n,s);if(i=h,v){if(8!=v)throw"unknown compression type "+v;e[w]=D(n.subarray(d,d+c),new r(l))}else e[w]=S(n,d,d+c)}return e}
/** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */function n(e){throw e;}var q=void 0,aa={};function r(e,c){var d=e.split("."),b=aa;!(d[0]in b)&&b.execScript&&b.execScript("var "+d[0]);for(var a;d.length&&(a=d.shift());)!d.length&&c!==q?b[a]=c:b=b[a]?b[a]:b[a]={}};var u="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;new (u?Uint8Array:Array)(256);var v;for(v=0;256>v;++v)for(var w=v,ba=7,w=w>>>1;w;w>>>=1)--ba;function x(e,c,d){var b,a="number"===typeof c?c:c=0,f="number"===typeof d?d:e.length;b=-1;for(a=f&7;a--;++c)b=b>>>8^z[(b^e[c])&255];for(a=f>>3;a--;c+=8)b=b>>>8^z[(b^e[c])&255],b=b>>>8^z[(b^e[c+1])&255],b=b>>>8^z[(b^e[c+2])&255],b=b>>>8^z[(b^e[c+3])&255],b=b>>>8^z[(b^e[c+4])&255],b=b>>>8^z[(b^e[c+5])&255],b=b>>>8^z[(b^e[c+6])&255],b=b>>>8^z[(b^e[c+7])&255];return(b^4294967295)>>>0}
var A=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,
2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,
2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,
2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,
3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,
936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],z=u?new Uint32Array(A):A;function B(){}B.prototype.getName=function(){return this.name};B.prototype.getData=function(){return this.data};B.prototype.H=function(){return this.I};r("Zlib.GunzipMember",B);r("Zlib.GunzipMember.prototype.getName",B.prototype.getName);r("Zlib.GunzipMember.prototype.getData",B.prototype.getData);r("Zlib.GunzipMember.prototype.getMtime",B.prototype.H);function D(e){var c=e.length,d=0,b=Number.POSITIVE_INFINITY,a,f,g,k,m,p,t,h,l,y;for(h=0;h<c;++h)e[h]>d&&(d=e[h]),e[h]<b&&(b=e[h]);a=1<<d;f=new (u?Uint32Array:Array)(a);g=1;k=0;for(m=2;g<=d;){for(h=0;h<c;++h)if(e[h]===g){p=0;t=k;for(l=0;l<g;++l)p=p<<1|t&1,t>>=1;y=g<<16|h;for(l=p;l<a;l+=m)f[l]=y;++k}++g;k<<=1;m<<=1}return[f,d,b]};var E=[],F;for(F=0;288>F;F++)switch(!0){case 143>=F:E.push([F+48,8]);break;case 255>=F:E.push([F-144+400,9]);break;case 279>=F:E.push([F-256+0,7]);break;case 287>=F:E.push([F-280+192,8]);break;default:n("invalid literal: "+F)}
var ca=function(){function e(a){switch(!0){case 3===a:return[257,a-3,0];case 4===a:return[258,a-4,0];case 5===a:return[259,a-5,0];case 6===a:return[260,a-6,0];case 7===a:return[261,a-7,0];case 8===a:return[262,a-8,0];case 9===a:return[263,a-9,0];case 10===a:return[264,a-10,0];case 12>=a:return[265,a-11,1];case 14>=a:return[266,a-13,1];case 16>=a:return[267,a-15,1];case 18>=a:return[268,a-17,1];case 22>=a:return[269,a-19,2];case 26>=a:return[270,a-23,2];case 30>=a:return[271,a-27,2];case 34>=a:return[272,
a-31,2];case 42>=a:return[273,a-35,3];case 50>=a:return[274,a-43,3];case 58>=a:return[275,a-51,3];case 66>=a:return[276,a-59,3];case 82>=a:return[277,a-67,4];case 98>=a:return[278,a-83,4];case 114>=a:return[279,a-99,4];case 130>=a:return[280,a-115,4];case 162>=a:return[281,a-131,5];case 194>=a:return[282,a-163,5];case 226>=a:return[283,a-195,5];case 257>=a:return[284,a-227,5];case 258===a:return[285,a-258,0];default:n("invalid length: "+a)}}var c=[],d,b;for(d=3;258>=d;d++)b=e(d),c[d]=b[2]<<24|b[1]<<
16|b[0];return c}();u&&new Uint32Array(ca);function G(e,c){this.i=[];this.j=32768;this.d=this.f=this.c=this.n=0;this.input=u?new Uint8Array(e):e;this.o=!1;this.k=H;this.z=!1;if(c||!(c={}))c.index&&(this.c=c.index),c.bufferSize&&(this.j=c.bufferSize),c.bufferType&&(this.k=c.bufferType),c.resize&&(this.z=c.resize);switch(this.k){case I:this.a=32768;this.b=new (u?Uint8Array:Array)(32768+this.j+258);break;case H:this.a=0;this.b=new (u?Uint8Array:Array)(this.j);this.e=this.F;this.q=this.B;this.l=this.D;break;default:n(Error("invalid inflate mode"))}}
var I=0,H=1;
G.prototype.g=function(){for(;!this.o;){var e=J(this,3);e&1&&(this.o=!0);e>>>=1;switch(e){case 0:var c=this.input,d=this.c,b=this.b,a=this.a,f=c.length,g=q,k=q,m=b.length,p=q;this.d=this.f=0;d+1>=f&&n(Error("invalid uncompressed block header: LEN"));g=c[d++]|c[d++]<<8;d+1>=f&&n(Error("invalid uncompressed block header: NLEN"));k=c[d++]|c[d++]<<8;g===~k&&n(Error("invalid uncompressed block header: length verify"));d+g>c.length&&n(Error("input buffer is broken"));switch(this.k){case I:for(;a+g>b.length;){p=
m-a;g-=p;if(u)b.set(c.subarray(d,d+p),a),a+=p,d+=p;else for(;p--;)b[a++]=c[d++];this.a=a;b=this.e();a=this.a}break;case H:for(;a+g>b.length;)b=this.e({t:2});break;default:n(Error("invalid inflate mode"))}if(u)b.set(c.subarray(d,d+g),a),a+=g,d+=g;else for(;g--;)b[a++]=c[d++];this.c=d;this.a=a;this.b=b;break;case 1:this.l(da,ea);break;case 2:fa(this);break;default:n(Error("unknown BTYPE: "+e))}}return this.q()};
var K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L=u?new Uint16Array(K):K,N=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],O=u?new Uint16Array(N):N,P=[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],Q=u?new Uint8Array(P):P,R=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],ga=u?new Uint16Array(R):R,ha=[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],U=u?new Uint8Array(ha):ha,V=new (u?Uint8Array:Array)(288),W,ia;W=0;for(ia=V.length;W<ia;++W)V[W]=143>=W?8:255>=W?9:279>=W?7:8;var da=D(V),X=new (u?Uint8Array:Array)(30),Y,ja;Y=0;for(ja=X.length;Y<ja;++Y)X[Y]=5;var ea=D(X);function J(e,c){for(var d=e.f,b=e.d,a=e.input,f=e.c,g=a.length,k;b<c;)f>=g&&n(Error("input buffer is broken")),d|=a[f++]<<b,b+=8;k=d&(1<<c)-1;e.f=d>>>c;e.d=b-c;e.c=f;return k}
function Z(e,c){for(var d=e.f,b=e.d,a=e.input,f=e.c,g=a.length,k=c[0],m=c[1],p,t;b<m&&!(f>=g);)d|=a[f++]<<b,b+=8;p=k[d&(1<<m)-1];t=p>>>16;e.f=d>>t;e.d=b-t;e.c=f;return p&65535}
function fa(e){function c(a,c,b){var d,e=this.w,f,g;for(g=0;g<a;)switch(d=Z(this,c),d){case 16:for(f=3+J(this,2);f--;)b[g++]=e;break;case 17:for(f=3+J(this,3);f--;)b[g++]=0;e=0;break;case 18:for(f=11+J(this,7);f--;)b[g++]=0;e=0;break;default:e=b[g++]=d}this.w=e;return b}var d=J(e,5)+257,b=J(e,5)+1,a=J(e,4)+4,f=new (u?Uint8Array:Array)(L.length),g,k,m,p;for(p=0;p<a;++p)f[L[p]]=J(e,3);if(!u){p=a;for(a=f.length;p<a;++p)f[L[p]]=0}g=D(f);k=new (u?Uint8Array:Array)(d);m=new (u?Uint8Array:Array)(b);e.w=
0;e.l(D(c.call(e,d,g,k)),D(c.call(e,b,g,m)))}G.prototype.l=function(e,c){var d=this.b,b=this.a;this.r=e;for(var a=d.length-258,f,g,k,m;256!==(f=Z(this,e));)if(256>f)b>=a&&(this.a=b,d=this.e(),b=this.a),d[b++]=f;else{g=f-257;m=O[g];0<Q[g]&&(m+=J(this,Q[g]));f=Z(this,c);k=ga[f];0<U[f]&&(k+=J(this,U[f]));b>=a&&(this.a=b,d=this.e(),b=this.a);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b};
G.prototype.D=function(e,c){var d=this.b,b=this.a;this.r=e;for(var a=d.length,f,g,k,m;256!==(f=Z(this,e));)if(256>f)b>=a&&(d=this.e(),a=d.length),d[b++]=f;else{g=f-257;m=O[g];0<Q[g]&&(m+=J(this,Q[g]));f=Z(this,c);k=ga[f];0<U[f]&&(k+=J(this,U[f]));b+m>a&&(d=this.e(),a=d.length);for(;m--;)d[b]=d[b++-k]}for(;8<=this.d;)this.d-=8,this.c--;this.a=b};
G.prototype.e=function(){var e=new (u?Uint8Array:Array)(this.a-32768),c=this.a-32768,d,b,a=this.b;if(u)e.set(a.subarray(32768,e.length));else{d=0;for(b=e.length;d<b;++d)e[d]=a[d+32768]}this.i.push(e);this.n+=e.length;if(u)a.set(a.subarray(c,c+32768));else for(d=0;32768>d;++d)a[d]=a[c+d];this.a=32768;return a};
G.prototype.F=function(e){var c,d=this.input.length/this.c+1|0,b,a,f,g=this.input,k=this.b;e&&("number"===typeof e.t&&(d=e.t),"number"===typeof e.A&&(d+=e.A));2>d?(b=(g.length-this.c)/this.r[2],f=258*(b/2)|0,a=f<k.length?k.length+f:k.length<<1):a=k.length*d;u?(c=new Uint8Array(a),c.set(k)):c=k;return this.b=c};
G.prototype.q=function(){var e=0,c=this.b,d=this.i,b,a=new (u?Uint8Array:Array)(this.n+(this.a-32768)),f,g,k,m;if(0===d.length)return u?this.b.subarray(32768,this.a):this.b.slice(32768,this.a);f=0;for(g=d.length;f<g;++f){b=d[f];k=0;for(m=b.length;k<m;++k)a[e++]=b[k]}f=32768;for(g=this.a;f<g;++f)a[e++]=c[f];this.i=[];return this.buffer=a};
G.prototype.B=function(){var e,c=this.a;u?this.z?(e=new Uint8Array(c),e.set(this.b.subarray(0,c))):e=this.b.subarray(0,c):(this.b.length>c&&(this.b.length=c),e=this.b);return this.buffer=e};function $(e){this.input=e;this.c=0;this.m=[];this.s=!1}$.prototype.G=function(){this.s||this.g();return this.m.slice()};
$.prototype.g=function(){for(var e=this.input.length;this.c<e;){var c=new B,d=q,b=q,a=q,f=q,g=q,k=q,m=q,p=q,t=q,h=this.input,l=this.c;c.u=h[l++];c.v=h[l++];(31!==c.u||139!==c.v)&&n(Error("invalid file signature:"+c.u+","+c.v));c.p=h[l++];switch(c.p){case 8:break;default:n(Error("unknown compression method: "+c.p))}c.h=h[l++];p=h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24;c.I=new Date(1E3*p);c.O=h[l++];c.N=h[l++];0<(c.h&4)&&(c.J=h[l++]|h[l++]<<8,l+=c.J);if(0<(c.h&8)){m=[];for(k=0;0<(g=h[l++]);)m[k++]=String.fromCharCode(g);
c.name=m.join("")}if(0<(c.h&16)){m=[];for(k=0;0<(g=h[l++]);)m[k++]=String.fromCharCode(g);c.K=m.join("")}0<(c.h&2)&&(c.C=x(h,0,l)&65535,c.C!==(h[l++]|h[l++]<<8)&&n(Error("invalid header crc16")));d=h[h.length-4]|h[h.length-3]<<8|h[h.length-2]<<16|h[h.length-1]<<24;h.length-l-4-4<512*d&&(f=d);b=new G(h,{index:l,bufferSize:f});c.data=a=b.g();l=b.c;c.L=t=(h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24)>>>0;x(a,q,q)!==t&&n(Error("invalid CRC-32 checksum: 0x"+x(a,q,q).toString(16)+" / 0x"+t.toString(16)));c.M=
d=(h[l++]|h[l++]<<8|h[l++]<<16|h[l++]<<24)>>>0;(a.length&4294967295)!==d&&n(Error("invalid input size: "+(a.length&4294967295)+" / "+d));this.m.push(c);this.c=l}this.s=!0;var y=this.m,s,M,S=0,T=0,C;s=0;for(M=y.length;s<M;++s)T+=y[s].data.length;if(u){C=new Uint8Array(T);for(s=0;s<M;++s)C.set(y[s].data,S),S+=y[s].data.length}else{C=[];for(s=0;s<M;++s)C[s]=y[s].data;C=Array.prototype.concat.apply([],C)}return C};r("Zlib.Gunzip",$);r("Zlib.Gunzip.prototype.decompress",$.prototype.g);r("Zlib.Gunzip.prototype.getMembers",$.prototype.G);
var Zlib=aa.Zlib;
export { Zlib }
......@@ -20,7 +20,7 @@ import {
TextureLoader,
sRGBEncoding
} from '../../../build/three.module.js';
import { JSZip } from '../libs/jszip.module.min.js';
import * as fflate from '../libs/fflate.module.min.js';
/**
*
......@@ -112,20 +112,20 @@ ThreeMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
try {
zip = new JSZip( data ); // eslint-disable-line no-undef
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
} catch ( e ) {
if ( e instanceof ReferenceError ) {
console.error( 'THREE.3MFLoader: jszip missing and file is compressed.' );
console.error( 'THREE.3MFLoader: fflate missing and file is compressed.' );
return null;
}
}
for ( file in zip.files ) {
for ( file in zip ) {
if ( file.match( /\_rels\/.rels$/ ) ) {
......@@ -157,7 +157,7 @@ ThreeMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
//
var relsView = new Uint8Array( zip.file( relsName ).asArrayBuffer() );
var relsView = new Uint8Array( zip[ relsName ].buffer );
var relsFileText = LoaderUtils.decodeText( relsView );
rels = parseRelsXml( relsFileText );
......@@ -165,7 +165,7 @@ ThreeMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
if ( modelRelsName ) {
var relsView = new Uint8Array( zip.file( modelRelsName ).asArrayBuffer() );
var relsView = new Uint8Array( zip[ modelRelsName ].buffer );
var relsFileText = LoaderUtils.decodeText( relsView );
modelRels = parseRelsXml( relsFileText );
......@@ -176,7 +176,7 @@ ThreeMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
for ( var i = 0; i < modelPartNames.length; i ++ ) {
var modelPart = modelPartNames[ i ];
var view = new Uint8Array( zip.file( modelPart ).asArrayBuffer() );
var view = new Uint8Array( zip[ modelPart ].buffer );
var fileText = LoaderUtils.decodeText( view );
var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
......@@ -219,7 +219,7 @@ ThreeMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
for ( var i = 0; i < texturesPartNames.length; i ++ ) {
var texturesPartName = texturesPartNames[ i ];
texturesParts[ texturesPartName ] = zip.file( texturesPartName ).asArrayBuffer();
texturesParts[ texturesPartName ] = zip[ texturesPartName ].buffer;
}
......
......@@ -9,7 +9,7 @@ import {
Mesh,
MeshPhongMaterial
} from '../../../build/three.module.js';
import { JSZip } from '../libs/jszip.module.min.js';
import * as fflate from '../libs/fflate.module.min.js';
/**
* Description: Early release of an AMF Loader following the pattern of the
......@@ -24,7 +24,7 @@ import { JSZip } from '../libs/jszip.module.min.js';
* });
*
* Materials now supported, material colors supported
* Zip support, requires jszip
* Zip support, requires fflate
* No constellation support (yet)!
*
*/
......@@ -90,20 +90,20 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
try {
zip = new JSZip( data ); // eslint-disable-line no-undef
zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
} catch ( e ) {
if ( e instanceof ReferenceError ) {
console.log( 'THREE.AMFLoader: jszip missing and file is compressed.' );
console.log( 'THREE.AMFLoader: fflate missing and file is compressed.' );
return null;
}
}
for ( file in zip.files ) {
for ( var file in zip ) {
if ( file.toLowerCase().substr( - 4 ) === '.amf' ) {
......@@ -114,7 +114,7 @@ AMFLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
}
console.log( 'THREE.AMFLoader: Trying to load file asset: ' + file );
view = new DataView( zip.file( file ).asArrayBuffer() );
view = new DataView( zip[ file ].buffer );
}
......
......@@ -5,7 +5,7 @@ import {
LoadingManager
} from '../../../build/three.module.js';
import { ColladaLoader } from '../loaders/ColladaLoader.js';
import { JSZip } from '../libs/jszip.module.min.js';
import * as fflate from '../libs/fflate.module.min.js';
var KMZLoader = function ( manager ) {
......@@ -56,11 +56,11 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
function findFile( url ) {
for ( var path in zip.files ) {
for ( var path in zip ) {
if ( path.substr( - url.length ) === url ) {
return zip.files[ path ];
return zip[ path ];
}
......@@ -77,7 +77,7 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
console.log( 'Loading', url );
var blob = new Blob( [ image.asArrayBuffer() ], { type: 'application/octet-stream' } );
var blob = new Blob( [ image.buffer ], { type: 'application/octet-stream' } );
return URL.createObjectURL( blob );
}
......@@ -88,18 +88,18 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
//
var zip = new JSZip( data ); // eslint-disable-line no-undef
var zip = fflate.unzipSync( new Uint8Array( data ) ); // eslint-disable-line no-undef
if ( zip.files[ 'doc.kml' ] ) {
if ( zip[ 'doc.kml' ] ) {
var xml = new DOMParser().parseFromString( zip.files[ 'doc.kml' ].asText(), 'application/xml' );
var xml = new DOMParser().parseFromString( fflate.strFromU8( zip[ 'doc.kml' ] ), 'application/xml' ); // eslint-disable-line no-undef
var model = xml.querySelector( 'Placemark Model Link href' );
if ( model ) {
var loader = new ColladaLoader( manager );
return loader.parse( zip.files[ model.textContent ].asText() );
return loader.parse( fflate.strFromU8( zip[ model.textContent ] ) ); // eslint-disable-line no-undef
}
......@@ -107,14 +107,14 @@ KMZLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
console.warn( 'KMZLoader: Missing doc.kml file.' );
for ( var path in zip.files ) {
for ( var path in zip ) {
var extension = path.split( '.' ).pop().toLowerCase();
if ( extension === 'dae' ) {
var loader = new ColladaLoader( manager );
return loader.parse( zip.files[ path ].asText() );
return loader.parse( fflate.strFromU8( zip[ path ] ) ); // eslint-disable-line no-undef
}
......
......@@ -4,7 +4,7 @@ import {
Matrix4,
Vector3
} from '../../../build/three.module.js';
import { Zlib } from '../libs/gunzip.module.min.js';
import * as fflate from '../libs/fflate.module.min.js';
import { Volume } from '../misc/Volume.js';
var NRRDLoader = function ( manager ) {
......@@ -322,8 +322,7 @@ NRRDLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
// we need to decompress the datastream
// here we start the unzipping and get a typed Uint8Array back
var inflate = new Zlib.Gunzip( new Uint8Array( _data ) ); // eslint-disable-line no-undef
_data = inflate.decompress();
_data = fflate.gunzipSync( new Uint8Array( _data ) );// eslint-disable-line no-undef
} else if ( headerObject.encoding === 'ascii' || headerObject.encoding === 'text' || headerObject.encoding === 'txt' || headerObject.encoding === 'hex' ) {
......
......@@ -12,7 +12,7 @@ import {
Quaternion,
Vector3
} from '../../../build/three.module.js';
import { JSZip } from '../libs/jszip.module.min.js';
import { unzipSync, strFromU8 } from '../libs/fflate.module.min.js';
class TiltLoader extends Loader {
......@@ -56,23 +56,23 @@ class TiltLoader extends Loader {
const group = new Group();
// https://docs.google.com/document/d/11ZsHozYn9FnWG7y3s3WAyKIACfbfwb4PbaS8cZ_xjvo/edit#
const zip = new JSZip( buffer.slice( 16 ) ); // eslint-disable-line no-undef
const zip = unzipSync( new Uint8Array( buffer.slice( 16 ) ) );
/*
const thumbnail = zip.files[ 'thumbnail.png' ].asArrayBuffer();
const thumbnail = zip[ 'thumbnail.png' ].buffer;
const img = document.createElement( 'img' );
img.src = URL.createObjectURL( new Blob( [ thumbnail ] ) );
document.body.appendChild( img );
*/
const metadata = JSON.parse( zip.files[ 'metadata.json' ].asText() );
const metadata = JSON.parse( strFromU8( zip[ 'metadata.json' ] ) );
/*
const blob = new Blob( [ zip.files[ 'data.sketch' ].asArrayBuffer() ], { type: 'application/octet-stream' } );
const blob = new Blob( [ zip[ 'data.sketch' ].buffer ], { type: 'application/octet-stream' } );
window.open( URL.createObjectURL( blob ) );
*/
const data = new DataView( zip.files[ 'data.sketch' ].asArrayBuffer() );
const data = new DataView( zip[ 'data.sketch' ].buffer );
const num_strokes = data.getInt32( 16, true );
......
......@@ -56,7 +56,7 @@
import * as THREE from '../build/three.module.js';
import Stats from './jsm/libs/stats.module.js';
import { JSZip } from './jsm/libs/jszip.module.min.js';
import { unzipSync } from './jsm/libs/fflate.module.min.js';
import { WEBGL } from './jsm/WebGL.js';
......@@ -92,8 +92,8 @@
.setResponseType( 'arraybuffer' )
.load( 'textures/3d/head256x256x109.zip', function ( data ) {
const zip = new JSZip( data );
const array = zip.files[ 'head256x256x109' ].asUint8Array();
const zip = unzipSync( new Uint8Array( data ) );
const array = new Uint8Array( zip[ 'head256x256x109' ].buffer );
const texture = new THREE.DataTexture2DArray( array, 256, 256, 109 );
texture.format = THREE.RedFormat;
......
......@@ -36,7 +36,7 @@ var files = [
{ path: 'exporters/ColladaExporter.js', dependencies: [], ignoreList: [] },
{ path: 'exporters/DRACOExporter.js', dependencies: [], ignoreList: [ 'Geometry' ] },
{ path: 'exporters/GLTFExporter.js', dependencies: [], ignoreList: [ 'AnimationClip', 'Camera', 'Geometry', 'Material', 'Mesh', 'Object3D', 'Scenes', 'ShaderMaterial'] },
{ path: 'exporters/GLTFExporter.js', dependencies: [], ignoreList: [ 'AnimationClip', 'Camera', 'Geometry', 'Material', 'Mesh', 'Object3D', 'Scenes', 'ShaderMaterial' ] },
{ path: 'exporters/MMDExporter.js', dependencies: [ { name: 'MMDParser', path: 'libs/mmdparser.module.js' } ], ignoreList: [] },
{ path: 'exporters/OBJExporter.js', dependencies: [], ignoreList: [] },
{ path: 'exporters/PLYExporter.js', dependencies: [], ignoreList: [] },
......@@ -63,8 +63,8 @@ var files = [
{ path: 'lines/Wireframe.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' }, { name: 'LineMaterial', path: 'lines/LineMaterial.js' } ], ignoreList: [] },
{ path: 'lines/WireframeGeometry2.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' } ], ignoreList: [] },
{ path: 'loaders/3MFLoader.js', dependencies: [ { name: 'JSZip', path: 'libs/jszip.module.min.js' } ], ignoreList: [] },
{ path: 'loaders/AMFLoader.js', dependencies: [ { name: 'JSZip', path: 'libs/jszip.module.min.js' } ], ignoreList: [] },
{ path: 'loaders/3MFLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true } ], ignoreList: [] },
{ path: 'loaders/AMFLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true } ], ignoreList: [] },
{ path: 'loaders/AssimpLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/BasisTextureLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/BVHLoader.js', dependencies: [], ignoreList: [ 'Bones' ] },
......@@ -76,13 +76,13 @@ var files = [
{ 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: [] },
{ path: 'loaders/KMZLoader.js', dependencies: [ { name: 'ColladaLoader', path: 'loaders/ColladaLoader.js' }, { name: 'JSZip', path: 'libs/jszip.module.min.js' } ], ignoreList: [] },
{ path: 'loaders/KMZLoader.js', dependencies: [ { name: 'ColladaLoader', path: 'loaders/ColladaLoader.js' }, { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true } ], ignoreList: [] },
{ path: 'loaders/LDrawLoader.js', dependencies: [], ignoreList: [ 'Cache', 'Material', 'Object3D' ] },
{ path: 'loaders/KTXLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/MD2Loader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/MMDLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' }, { name: 'MMDParser', path: 'libs/mmdparser.module.js' } ], ignoreList: [ 'Camera', 'LoadingManager' ] },
{ path: 'loaders/MTLLoader.js', dependencies: [], ignoreList: [ 'BackSide', 'DoubleSide', 'ClampToEdgeWrapping', 'MirroredRepeatWrapping' ] },
{ path: 'loaders/NRRDLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/gunzip.module.min.js' }, { name: 'Volume', path: 'misc/Volume.js' } ], ignoreList: [] },
{ path: 'loaders/NRRDLoader.js', dependencies: [ { name: 'fflate', path: 'libs/fflate.module.min.js', importAll: true }, { name: 'Volume', path: 'misc/Volume.js' } ], ignoreList: [] },
{ path: 'loaders/OBJLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/PCDLoader.js', dependencies: [], ignoreList: [] },
{ path: 'loaders/PDBLoader.js', dependencies: [], ignoreList: [] },
......@@ -314,7 +314,15 @@ function convert( path, exampleDependencies, ignoreList ) {
for ( var dependency of exampleDependencies ) {
imports.push( `import { ${dependency.name} } from '${pathPrefix}${dependency.path}';` );
if ( dependency.importAll === true ) {
imports.push( `import * as ${dependency.name} from '${pathPrefix}${dependency.path}';` );
} else {
imports.push( `import { ${dependency.name} } from '${pathPrefix}${dependency.path}';` );
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册