Przeglądaj źródła

Editor: Added option to export GLB

Mr.doob 7 lat temu
rodzic
commit
919bbd4a36
1 zmienionych plików z 25 dodań i 0 usunięć
  1. 25 0
      editor/js/Menubar.File.js

+ 25 - 0
editor/js/Menubar.File.js

@@ -184,6 +184,25 @@ Menubar.File = function ( editor ) {
 
 	options.add( new UI.HorizontalRule() );
 
+	// Export GLB
+
+	var option = new UI.Row();
+	option.setClass( 'option' );
+	option.setTextContent( 'Export GLB' );
+	option.onClick( function () {
+
+		var exporter = new THREE.GLTFExporter();
+
+		exporter.parse( editor.scene, function ( result ) {
+
+			saveArrayBuffer( result, 'scene.glb' );
+
+		}, { binary: true } );
+
+
+	} );
+	options.add( option );
+
 	// Export GLTF
 
 	var option = new UI.Row();
@@ -352,6 +371,12 @@ Menubar.File = function ( editor ) {
 
 	}
 
+	function saveArrayBuffer( buffer, filename ) {
+
+		save( new Blob( [ buffer ], { type: 'application/octet-stream' } ), filename );
+
+	}
+
 	function saveString( text, filename ) {
 
 		save( new Blob( [ text ], { type: 'text/plain' } ), filename );