three.js: Blender exporter is very slow
I’m trying to convert a Collada file to three.js JSON using your Blender exporter. Conversion seems to be awfully slow. For example, I have a ~50MB Collada file that takes 2–3 hours to convert. Seems a bit much, doesn’t it?
It has been a while since I have looked at the console window while converting, but from what I remember, it’s the “last phase” where nothing is printed to the console that takes most of the time.
Here’s the export script that I’m running (blender_dae2json.py
):
"""
Collada to three.js (.dae to .json)
usage: blender.exe --background --python blender_dae2json.py -- in.dae out.json
"""
import sys
import bpy # Blender Python API
# enable Three.js exporter
bpy.ops.wm.addon_enable(module='io_three')
# Get filename arguments
args = sys.argv[sys.argv.index('--')+1:]
fdae = args[0]
fthree = args[1]
# Delete the default objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Import Collada file
bpy.ops.wm.collada_import(filepath=fdae)
# Export three.js file
bpy.ops.export.three(
filepath=fthree,
option_export_scene=True,
option_materials=True,
option_indent=False,
)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (8 by maintainers)
I’ve downloaded and attempted to export the files you posted. I see what you mean. The large file contains about 5700 objects, and about 3.8 million triangles altogether. By watching the logging output, it seems like a lot of the export time comes from triangulating each object… applying edge split modifiers, and recomputing normals. Every object in the scene contains unique vertices. There is no instancing, even though the objects appear to have been instanced at one time… so if you need to move forward with meshes like this, I’d look into getting the models before the hierarchy has been flattened, or do a preprocess to re-combine the instanced parts.
So I agree with your assessment that exporting this is too slow to be practical, but there are steps that could be taken to make it more amenable to fast exporting… and those steps will also translate to more efficient and higher performance rendering, since there wont be 57000 unique geometries being rendered.
I don’t want to register anywhere just to upload these files, but you are welcome to do whatever you want with them (they’re simply Collada versions of a couple of the files from this site, converted using IfcOpenShell).
I can’t find the original, but I’ve found two other files. Download here (available for 7 days).
One file is just 7 MB. On my machine, the exporter spits out log messages for 4 seconds, and then nothing is output until it finishes after a total of 1 minute 20 seconds. This is of course not terribly long in itself, but a processing time of over a minute for a 7 MB file seems a bit much, and the exporter seems to scale horribly for larger input sizes. It may help in debugging for quicker turnaround times.
The other Collada file is 267 MB. On my machine, the exporter outputs log messages for 40 seconds. I canceled it after that; I expect it would take the better part of a day to finish, if not more (significantly longer than a linear extrapolation of the small file, which would put it at a bit less than an hour).