I am trying to convert some isolated elements on forge viewer to GLTF I have included this script
<script src="https://unpkg.com/three@0.126.0/examples/js/exporters/GLTFExporter.js"></script>
I am using this code to export to GLTF
const exporter=new THREE.GLTFExporter()
const exportGLTF = () => {
var scene = viewer.impl.scene
exporter.parse( scene, function ( gltf ) {
const output = JSON.stringify( gltf, null, 2 );
console.log(output)
//saveString( output, 'scene.gltf' );
}, {trs: true} );
}
but unfortunately I receive empty GLTF output like this
{
"asset": {
"version": "2.0",
"generator": "THREE.GLTFExporter"
},
"scenes": [
{}
],
"scene": 0
}
I am not sure it's possible to extract the Forge scene with ThreeJS exporters.
If you want to extract your Forge
model into glTF
format, one of the best way (as of today) is to use the Forge Convert Utils package.