Skip to content

Instantly share code, notes, and snippets.

@fernandojsg
Last active September 1, 2017 13:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fernandojsg/d4cb7bfff2fda506e3c81f5797f4303a to your computer and use it in GitHub Desktop.
Save fernandojsg/d4cb7bfff2fda506e3c81f5797f4303a to your computer and use it in GitHub Desktop.
THREE.js and AFRAME glTF exporter bookmarklet
javascript:(function(){
var link = document.createElement( 'a' ); link.style.display = 'none'; document.body.appendChild( link );
function save( blob, filename ) { link.href = URL.createObjectURL( blob ); link.download = filename; link.click(); }
function saveString( text, filename ) { save( new Blob( [ text ], { type: 'application/json' } ), filename );}
var script=document.createElement('script');
script.src='https://threejs.org/examples/js/exporters/GLTFExporter.js';
script.onload = function () {
var exporter = new THREE.GLTFExporter();
var sceneToExport = window.AFRAME ? AFRAME.scenes[0].object3D : scene;
exporter.parse(sceneToExport, function (result) {
var output = JSON.stringify( result, null, 2 );
console.log( output );
saveString( output, 'scene.gltf' );
});
};
document.head.appendChild(script);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment