Code Monkey home page Code Monkey logo

assetfetch-blender's Introduction

AssetFetch for Blender

This addon is a client for the AssetFetch protocol, an open system for 3D asset discovery and automated imports.

image

Installation

  1. Visit the Releases page
  2. Choose the latest version and click on "Assets" below the informative text
  3. Download af_blender_X_Y_Z.zip from this page (not "Source code")
  4. Go into Blender and select Edit -> Preferences -> Addons.
  5. Then click on the Install button in the top right corner and navigate to the ZIP file (no need to unpack it).
  6. The AssetFetch panel will be added in the right-side menu in the 3D-window.

Development Setup

This is the setup for developing the addon.

  1. Create a symlink in your filesystem that connects the /src folder in this repository with blender's addon directory, for example on Windows this would be C:\Users\<User>\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\src.
  2. Download the required python-dependencies:
# Make sure that you are in the root of this repository (same directory as this readme file)
# Download the required packages into the src/lib directory
pip install --target ./src/lib/ -r ./requirements.txt
  1. Download the JSON-Schema for AssetFetch
# Download the latest json schema version for AssetFetch
# Change the -b parameter to use a different branch/tag
mkdir ./tmp
git -C ./tmp/ clone -b '0.2' --single-branch https://github.com/AssetFetch/spec.git 
cp -r ./tmp/spec/json-schema/ ./src/
rm -rf ./tmp
  1. I recommend developing in VS Code with the Blender Development Extension by Jacques Lucke

Code overview

The addon is split into multiple modules:

  • operator contains all the bpy operators, meaning all the distinct actions this addon can perform.
  • property contains all the bpy properties that are used to store and handle the incoming data from the provider. AF stores all its data in bpy.context.window_manager.af.
  • ui contains the code for the individual panels, all of which are in the VIEW_3D section (meaning the window that you get by opening the right-side panel in the 3D view).
  • util is for miscellaneous functionality.

Every module's __init__.py imports all relevant classes and stores them in a registration_targets array from where the register() and unregister() functions read them when the addon is (un)loaded inside Blender.

The global __init__.py for the entire addon does the same pattern again by loading the registration functions from all the other modules.

Required dependencies are loaded from the /src/lib directory.

YAPF style

The following YAPF style configuration is recommended:

{based_on_style: pep8, indent_width:4, continuation_indent_width:4, continuation_align_style = fixed, column_limit: 180, use_tabs: true}

When using VSCode you can install the YAPF extension (eeyore.yapf) and add the following to your settings.json:

"yapf.args": ["--style", "{based_on_style: pep8, indent_width:4, continuation_indent_width:4, continuation_align_style = fixed, column_limit: 180, use_tabs: true}"]

assetfetch-blender's People

Contributors

struffel avatar a-python-script avatar

Stargazers

 avatar Francisco das Chagas Dantas Filho avatar  avatar Nazir avatar Riccardo Giovanetti avatar

Watchers

 avatar

Forkers

a-python-script

assetfetch-blender's Issues

Maintain same implementation settings when switching between assets (if possible)

When switching between different asset, the addon currently resets the implementations settings back to their default value.
This is because implementation settings might be different between assets and are therefore reloaded entirely.
However, a lot of the time they aren't actually different which makes this constant return to default values very annoying.
It would be better to store the preferred values somewhere (for example addon prefs) and apply them, if the name of the parameter is the same.
image

HDRI/Environment support

The plugin can't handle the loose_environment_* datablocks at all.
In order to load raw .exr or .hdr files without any surrounding supportfiles, this datablock needs to be handled.

Proper arrangement of shader nodes when importing loose materials

Currently, when importing loose materials from a loose_material_apply datablock, all material nodes get placed at (0,0) which creates a working, completely unreadable graph. Some algorithm for neatly placing all the shader nodes needs to be found and implemented.

Checkbox parameter type not yet supported

The spec allows the types text, boolean, select and fixed for parameters of variable queries.
Out of those, the boolean one is not yet supported, meaning that it does not get drawn in the GUI.

Add proper User-Agent header

The spec demands proper user agent headers on all requests, but the Plugin currently does not send them. The http.py module needs to be extended for compliance with the spec.

Properly display import progress

There is currently no way to check the progress of an ongoing import without checking the system console.
One solution to this would be to display which steps have been completed in the "Implementation Details" section of the addon.

Thumbnail handling is extremely slow and blocking the main thread

Currently, when an asset query is run the addon pull all thumbnails for all assets in advance and then loads them to be displayed in blender.

This method has several huge issues:

  • Thumbnails get reloaded constantly, there is no caching
  • Loading a large asset list with high-res thumbnails has the potential to freeze the GUI for MINUTES

A better approach would be to load the images dynamically once they get used in the GUI, maybe on another thread if that's doable.
In addition, some kind of caching should be introduced.

Better loading indicator for long HTTP queries

Searching for an asset or for implementations currently freezes the entire GUI until the server has responed or the request has timed out. This is obviously annoying when interacting with slow providers.

Add support for `.blend` files

The addon, rather ironically, does not support .blend files at this point. This is an obvious problem for a blender addon.

Bookmarks for provider initialization URLs and headers

At the moment, the provider URL and any credentials need to be typed in manually after every restart of Blender.
It would be much better to move this configuration to the addon preferences and have a proper bookmarking system with the option to also store the credentials.

Changeable & dynamic download directory for assets

At the moment, all assets get downloaded into the user's home directory (~/AssetFetch).
This path should be adjustable and it should also be possible to set it in relation to the curently opened file (if applicable).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.