def __export(export_settings): exporter = GlTF2Exporter(export_settings) __gather_gltf(exporter, export_settings) buffer = __create_buffer(exporter, export_settings) exporter.finalize_images() json = __fix_json(exporter.glTF.to_dict()) return json, buffer
def __export(export_settings): exporter = GlTF2Exporter(__get_copyright(export_settings)) __gather_gltf(exporter, export_settings) buffer = __create_buffer(exporter, export_settings) exporter.finalize_images(export_settings[gltf2_blender_export_keys.FILE_DIRECTORY]) json = __fix_json(exporter.glTF.to_dict()) return json, buffer
def __export(export_settings): export_settings['gltf_channelcache'] = dict() exporter = GlTF2Exporter(__get_copyright(export_settings)) __add_root_objects(exporter, export_settings) buffer = __create_buffer(exporter, export_settings) exporter.finalize_images(export_settings[gltf2_blender_export_keys.FILE_DIRECTORY]) json = __fix_json(exporter.glTF.to_dict()) return json, buffer
def __export(export_settings): exporter = GlTF2Exporter(export_settings) __gather_gltf(exporter, export_settings) buffer = __create_buffer(exporter, export_settings) exporter.finalize_images() json = __fix_json(exporter.glTF.to_dict()) export_user_extensions('gather_gltf_hook', export_settings, exporter.glTF) exporter.traverse_extensions() return json, buffer
def __export(export_settings): exporter = GlTF2Exporter(export_settings) __gather_gltf(exporter, export_settings) buffer = __create_buffer(exporter, export_settings) exporter.finalize_images() export_user_extensions('gather_gltf_hook', export_settings, exporter.glTF) exporter.traverse_extensions() # now that addons possibly add some fields in json, we can fix in needed json = __fix_json(exporter.glTF.to_dict()) return json, buffer
def export(blender_scene, selected, hubs_config, registered_hubs_components): if bpy.data.filepath == '': raise RuntimeError("Save project before exporting") filepath = bpy.data.filepath.replace('.blend', '') filename_ext = '.glb' export_settings = {} export_settings['timestamp'] = datetime.datetime.now() export_settings['gltf_filepath'] = bpy.path.ensure_ext( filepath, filename_ext) if os.path.exists(export_settings['gltf_filepath']): os.remove(export_settings['gltf_filepath']) export_settings['gltf_filedirectory'] = os.path.dirname( export_settings['gltf_filepath']) + '/' export_settings['gltf_format'] = 'GLB' export_settings['gltf_image_format'] = 'NAME' export_settings['gltf_copyright'] = '' export_settings['gltf_texcoords'] = True export_settings['gltf_normals'] = True export_settings['gltf_tangents'] = False export_settings['gltf_draco_mesh_compression'] = False export_settings['gltf_materials'] = True export_settings['gltf_colors'] = True export_settings['gltf_cameras'] = False export_settings['gltf_selected'] = selected export_settings['gltf_layers'] = True export_settings['gltf_extras'] = False export_settings['gltf_yup'] = True export_settings['gltf_apply'] = False export_settings['gltf_current_frame'] = False export_settings['gltf_animations'] = False export_settings['gltf_frame_range'] = False export_settings['gltf_move_keyframes'] = False export_settings['gltf_force_sampling'] = False export_settings['gltf_skins'] = False export_settings['gltf_all_vertex_influences'] = False export_settings['gltf_frame_step'] = 1 export_settings['gltf_morph'] = False export_settings['gltf_morph_normal'] = False export_settings['gltf_morph_tangent'] = False export_settings['gltf_lights'] = False export_settings['gltf_displacement'] = False export_settings['gltf_binary'] = bytearray() export_settings['gltf_binaryfilename'] = os.path.splitext( os.path.basename(bpy.path.ensure_ext(filepath, filename_ext)))[0] + '.bin' export_settings['hubs_config'] = hubs_config export_settings['registered_hubs_components'] = registered_hubs_components gltf2_blender_gather_nodes.__gather_extensions = patched_gather_extensions gltf2_blender_gather_materials.__gather_extensions = patched_gather_extensions # In most recent version this function will return active_scene # as the first value for a total of 3 return values scenes, _animations = gltf2_blender_gather.gather_gltf2(export_settings) for gltf_scene in scenes: gltf_scene.extensions = patched_gather_extensions( blender_scene, export_settings) exporter = GlTF2Exporter(export_settings['gltf_copyright']) exporter.add_scene(scenes[0], True) buffer = exporter.finalize_buffer(export_settings['gltf_filedirectory'], is_glb=True) exporter.finalize_images(export_settings['gltf_filedirectory']) gltf_json = fix_json(exporter.glTF.to_dict()) extension_name = hubs_config["gltfExtensionName"] if 'extensionsRequired' in gltf_json: gltf_json['extensionsRequired'].remove(extension_name) if not gltf_json['extensionsRequired']: del gltf_json['extensionsRequired'] if 'extensionsUsed' not in gltf_json: gltf_json['extensionsUsed'] = [extension_name] elif extension_name not in gltf_json['extensionsUsed']: gltf_json['extensionsUsed'].append(extension_name) if 'extensions' not in gltf_json: gltf_json['extensions'] = {} gltf_json['extensions'][extension_name] = { "version": hubs_config["gltfExtensionVersion"] } gltf2_io_export.save_gltf(gltf_json, export_settings, gltf2_blender_json.BlenderJSONEncoder, buffer) gltf2_blender_gather_nodes.__gather_extensions = original_gather_extensions return export_settings['gltf_filepath']