|
@@ -98,7 +98,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- exportString( output, 'geometry.json' );
|
|
|
+ saveString( output, 'geometry.json' );
|
|
|
|
|
|
} );
|
|
|
options.add( option );
|
|
@@ -132,7 +132,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- exportString( output, 'model.json' );
|
|
|
+ saveString( output, 'model.json' );
|
|
|
|
|
|
} );
|
|
|
options.add( option );
|
|
@@ -157,7 +157,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- exportString( output, 'scene.json' );
|
|
|
+ saveString( output, 'scene.json' );
|
|
|
|
|
|
} );
|
|
|
options.add( option );
|
|
@@ -180,7 +180,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
var exporter = new THREE.OBJExporter();
|
|
|
|
|
|
- exportString( exporter.parse( object ), 'model.obj' );
|
|
|
+ saveString( exporter.parse( object ), 'model.obj' );
|
|
|
|
|
|
} );
|
|
|
options.add( option );
|
|
@@ -194,7 +194,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
var exporter = new THREE.STLExporter();
|
|
|
|
|
|
- exportString( exporter.parse( editor.scene ), 'model.stl' );
|
|
|
+ saveString( exporter.parse( editor.scene ), 'model.stl' );
|
|
|
|
|
|
} );
|
|
|
options.add( option );
|
|
@@ -271,7 +271,7 @@ Menubar.File = function ( editor ) {
|
|
|
|
|
|
var manager = new THREE.LoadingManager( function () {
|
|
|
|
|
|
- location.href = 'data:application/zip;base64,' + zip.generate();
|
|
|
+ save( zip.generate( { type: 'blob' } ), 'download.zip' );
|
|
|
|
|
|
} );
|
|
|
|
|
@@ -297,23 +297,21 @@ Menubar.File = function ( editor ) {
|
|
|
link.style.display = 'none';
|
|
|
document.body.appendChild( link ); // Firefox workaround, see #6594
|
|
|
|
|
|
- var exportString = function ( output, filename ) {
|
|
|
+ function save( blob, filename ) {
|
|
|
|
|
|
- var blob = new Blob( [ output ], { type: 'text/plain' } );
|
|
|
- var objectURL = URL.createObjectURL( blob );
|
|
|
-
|
|
|
- link.href = objectURL;
|
|
|
+ link.href = URL.createObjectURL( blob );
|
|
|
link.download = filename || 'data.json';
|
|
|
- link.target = '_blank';
|
|
|
+ link.click();
|
|
|
+
|
|
|
+ // URL.revokeObjectURL( url ); breaks Firefox...
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function saveString( text, filename ) {
|
|
|
|
|
|
- var event = document.createEvent( 'MouseEvents' );
|
|
|
- event.initMouseEvent(
|
|
|
- 'click', true, false, window, 0, 0, 0, 0, 0,
|
|
|
- false, false, false, false, 0, null
|
|
|
- );
|
|
|
- link.dispatchEvent( event );
|
|
|
+ save( new Blob( [ text ], { type: 'text/plain' } ), filename );
|
|
|
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
return container;
|
|
|
|