From cb9f5ca1c1189bb6d0042fbc303a3a9f02989674 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Wed, 21 Feb 2018 12:08:02 -0800 Subject: [PATCH] Editor: Added option to export GLB --- editor/js/Menubar.File.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/editor/js/Menubar.File.js b/editor/js/Menubar.File.js index 5c44fa3b53..24de35d2de 100644 --- a/editor/js/Menubar.File.js +++ b/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(); @@ -373,6 +392,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 ); -- GitLab