Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Owner

@mrdoob mrdoob Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need inflate and jszip there?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just saw #20941 (comment)


Expand Down
1 change: 1 addition & 0 deletions examples/js/libs/fflate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions examples/js/loaders/3MFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$/ ) ) {

Expand Down Expand Up @@ -133,15 +133,15 @@ THREE.ThreeMFLoader.prototype = Object.assign( Object.create( THREE.Loader.proto

//

var relsView = new Uint8Array( zip.file( relsName ).asArrayBuffer() );
var relsView = zip[ relsName ];
var relsFileText = THREE.LoaderUtils.decodeText( relsView );
rels = parseRelsXml( relsFileText );

//

if ( modelRelsName ) {

var relsView = new Uint8Array( zip.file( modelRelsName ).asArrayBuffer() );
var relsView = zip[ modelRelsName ];
var relsFileText = THREE.LoaderUtils.decodeText( relsView );
modelRels = parseRelsXml( relsFileText );

Expand All @@ -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 = zip[ modelPart ];

var fileText = THREE.LoaderUtils.decodeText( view );
var xmlData = new DOMParser().parseFromString( fileText, 'application/xml' );
Expand Down Expand Up @@ -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;

}

Expand Down
10 changes: 5 additions & 5 deletions examples/js/loaders/AMFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* });
*
* Materials now supported, material colors supported
* Zip support, requires jszip
* Zip support, requires fflate
* No constellation support (yet)!
*
*/
Expand Down Expand Up @@ -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' ) {

Expand All @@ -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 );

}

Expand Down
18 changes: 9 additions & 9 deletions examples/js/loaders/KMZLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];

}

Expand All @@ -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 );

}
Expand All @@ -79,33 +79,33 @@ 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

}

} else {

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

}

Expand Down
3 changes: 1 addition & 2 deletions examples/js/loaders/NRRDLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {

Expand Down
1 change: 1 addition & 0 deletions examples/jsm/libs/fflate.module.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading