export works, todo: link/button-issue
This commit is contained in:
parent
24f1336c41
commit
49cb5e57df
|
@ -117,7 +117,7 @@ $editor = (el,opts) => new Proxy({
|
|||
}
|
||||
})
|
||||
|
||||
document.addEventListener('frontend.export', (e) => this.updateOriginalScene(e.detail) )
|
||||
xrf.addEventListener('export', (e) => this.updateOriginalScene(e) )
|
||||
xrf.addEventListener('href', (opts) => {
|
||||
if( this.selecting || this.editing ) return opts.promise().reject("$editor should block hrefs while editing") // never resolve (block hrefs from interfering)
|
||||
})
|
||||
|
|
|
@ -239,34 +239,37 @@ window.frontend = (opts) => new Proxy({
|
|||
},
|
||||
|
||||
download(){
|
||||
// setup exporters
|
||||
let defaultExporter = THREE.GLTFExporter
|
||||
xrf.loaders['gltf'].exporter = defaultExporter
|
||||
xrf.loaders['glb'].exporter = defaultExporter
|
||||
|
||||
function download(dataurl, filename) {
|
||||
var a = document.createElement("a");
|
||||
a.href = dataurl;
|
||||
a.href = URL.createObjectURL( new Blob([dataurl]) );
|
||||
a.setAttribute("download", filename);
|
||||
a.click();
|
||||
return false;
|
||||
}
|
||||
|
||||
function exportScene(model,ext){
|
||||
const exporter = new (xrf.loaders[ext].exporter || defaultExporter)
|
||||
function exportScene(model,ext,file){
|
||||
document.dispatchEvent( new CustomEvent('frontend.export',{detail:{ scene: model.scene,ext}}) )
|
||||
exporter.parse(
|
||||
model.scene,
|
||||
function ( glb ) { download(glb, `${file}`) }, // ready
|
||||
function ( error ) { console.error(error) }, // error
|
||||
{
|
||||
binary:true,
|
||||
onlyVisible: false,
|
||||
animations: model.animations,
|
||||
includeCustomExtensions: true,
|
||||
trs:true
|
||||
}
|
||||
);
|
||||
xrf.emit('export', {scene: model.scene, ext})
|
||||
.then( () => {
|
||||
// setup exporters
|
||||
let defaultExporter = THREE.GLTFExporter
|
||||
xrf.loaders['gltf'].exporter = defaultExporter
|
||||
xrf.loaders['glb'].exporter = defaultExporter
|
||||
const exporter = new THREE.GLTFExporter()
|
||||
exporter.parse(
|
||||
model.scene,
|
||||
function ( glb ) { download(glb, `${file}`) }, // ready
|
||||
function ( error ) { console.error(error) }, // error
|
||||
{
|
||||
binary:true,
|
||||
onlyVisible: false,
|
||||
animations: model.animations,
|
||||
includeCustomExtensions: true,
|
||||
trs:true
|
||||
}
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
// load original scene and overwrite with updates
|
||||
|
|
Loading…
Reference in New Issue