1、安装Blender
2、建立python文件
import sys
import bpy
import os
export_options = {
'export_format': 'GLB',
'export_apply': True,
'export_animations': True,
'export_image_format': 'AUTO',
'export_texture_dir': '',
#'export_embed_buffers': True,
#'export_embed_images': True,
#'export_emissive_strength': False,
}
path="G:\\TestConvert"
for i,j,k in os.walk(path):
print(i,j,k)
for a in k:
if a.endswith(".fbx"):
#clean out the scene
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
print("xxxx====="+a)
currentpsth=path+"\\"+a
bpy.ops.import_scene.fbx(filepath=currentpsth)
fname,ext = os.path.splitext(a)
outpath="G:\\ConvertGlb\\"+fname
bpy.ops.export_scene.gltf(filepath=outpath,**export_options)
#export_image_format='AUTO', export_texture_dir='', export_embed_buffers=True, export_image_format='AUTO')
3、运行:使用Blender安装目录下python.exe执行python脚本即可,比如Blender版本是3.6,那么python.exe位置是Blender/3.6/python/bin/python.exe