Last active
September 1, 2017 13:54
-
-
Save fernandojsg/d4cb7bfff2fda506e3c81f5797f4303a to your computer and use it in GitHub Desktop.
THREE.js and AFRAME glTF exporter bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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