Fix basic collada export
This commit is contained in:
parent
d0b4b502db
commit
8c644d9d96
@ -532,6 +532,7 @@ const MenuBar = {
|
||||
'export_optifine_part',
|
||||
'export_minecraft_skin',
|
||||
'export_obj',
|
||||
'export_collada',
|
||||
'export_gltf',
|
||||
'upload_sketchfab',
|
||||
'share_model',
|
||||
|
@ -4,7 +4,7 @@
|
||||
var codec = new Codec('collada', {
|
||||
name: 'Collada Model',
|
||||
extension: 'dae',
|
||||
compile(options = 0, callback) {
|
||||
async compile(options = 0) {
|
||||
let scope = this;
|
||||
let exporter = new THREE.ColladaExporter();
|
||||
let animations = [];
|
||||
@ -20,39 +20,39 @@ var codec = new Codec('collada', {
|
||||
Animator.showDefaultPose();
|
||||
}
|
||||
if (options.animations !== false) {
|
||||
animations = buildAnimationTracks();
|
||||
//animations = buildAnimationTracks();
|
||||
}
|
||||
exporter.parse(gl_scene, (json) => {
|
||||
|
||||
scope.dispatchEvent('compile', {model: json, options});
|
||||
callback(JSON.stringify(json));
|
||||
|
||||
gl_scene.children.forEachReverse(object => {
|
||||
if (object.isGroup || object.isElement) {
|
||||
scene.add(object);
|
||||
}
|
||||
let result = await new Promise((resolve, reject) => {
|
||||
exporter.parse(gl_scene, (result) => {
|
||||
resolve(result);
|
||||
}, {
|
||||
author: 'Blockbench User',
|
||||
textureDirectory: 'textures'
|
||||
});
|
||||
}, {
|
||||
animations,
|
||||
version: '1.5.0',
|
||||
author: 'Blockbench',
|
||||
textureDirectory: 'textures'
|
||||
})
|
||||
scope.dispatchEvent('compile', {model: result.data, options});
|
||||
console.log(result)
|
||||
|
||||
gl_scene.children.forEachReverse(object => {
|
||||
if (object.isGroup || object.isElement) {
|
||||
scene.add(object);
|
||||
}
|
||||
});
|
||||
|
||||
return result.data;
|
||||
},
|
||||
export() {
|
||||
var scope = codec;
|
||||
scope.compile(0, content => {
|
||||
setTimeout(_ => {
|
||||
Blockbench.export({
|
||||
resource_id: 'gltf',
|
||||
type: scope.name,
|
||||
extensions: [scope.extension],
|
||||
name: scope.fileName(),
|
||||
startpath: scope.startPath(),
|
||||
content,
|
||||
custom_writer: isApp ? (a, b) => scope.write(a, b) : null,
|
||||
}, path => scope.afterDownload(path))
|
||||
}, 20)
|
||||
scope.compile().then(content => {
|
||||
Blockbench.export({
|
||||
resource_id: 'gltf',
|
||||
type: scope.name,
|
||||
extensions: [scope.extension],
|
||||
name: scope.fileName(),
|
||||
startpath: scope.startPath(),
|
||||
content,
|
||||
custom_writer: isApp ? (a, b) => scope.write(a, b) : null,
|
||||
}, path => scope.afterDownload(path))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -752,6 +752,8 @@
|
||||
"action.export_minecraft_skin.desc": "Export the Minecraft skin as a PNG texture",
|
||||
"action.export_obj": "Export OBJ Model",
|
||||
"action.export_obj.desc": "Export a Wavefront OBJ model for rendering",
|
||||
"action.export_collada": "Export As Collada (dae)",
|
||||
"action.export_collada.desc": "Export model and animations as dae file to use in other 3D applications",
|
||||
"action.export_gltf": "Export As glTF",
|
||||
"action.export_gltf.desc": "Export model and animations as glTF file to use in other 3D applications",
|
||||
"action.upload_sketchfab": "Upload to Sketchfab",
|
||||
|
Loading…
x
Reference in New Issue
Block a user