github: add script and action for getting gltf assets (#9085)
- Script for getting models from glTF-Sample-Assets - Add support for reading gltf models from a file.
This commit is contained in:
@@ -22,6 +22,7 @@ GOLDEN_OUTPUT_DIR="$(pwd)/out/renderdiff/goldens"
|
||||
RENDERDIFF_TEST_DIR="$(pwd)/test/renderdiff"
|
||||
MESA_DIR="$(pwd)/mesa/out/"
|
||||
VENV_DIR="$(pwd)/venv"
|
||||
GLTF_DIR="$(pwd)/gltf/Models"
|
||||
BUILD_COMMON_DIR="$(pwd)/build/common"
|
||||
|
||||
os_name=$(uname -s)
|
||||
|
||||
@@ -44,11 +44,22 @@ class RenderingConfig():
|
||||
class PresetConfig(RenderingConfig):
|
||||
def __init__(self, data, existing_models):
|
||||
RenderingConfig.__init__(self, data)
|
||||
models = data.get('models')
|
||||
if models:
|
||||
self.models = []
|
||||
|
||||
def _check(models):
|
||||
assert _is_list_of_strings(models)
|
||||
assert all(m in existing_models for m in models)
|
||||
|
||||
models = data.get('models')
|
||||
if models:
|
||||
_check(models)
|
||||
self.models = models
|
||||
model_list_file = data.get('model_list_file')
|
||||
if model_list_file and os.path.exists(model_list_file):
|
||||
with open(model_list_file, 'r') as f:
|
||||
models = list(filter(lambda a: len(a) > 0, map(lambda a: a.strip(), f.read().split('\n'))))
|
||||
_check(models)
|
||||
self.models += models
|
||||
|
||||
class TestConfig(RenderingConfig):
|
||||
def __init__(self, data, existing_models, presets):
|
||||
@@ -105,7 +116,9 @@ class RenderTestConfig():
|
||||
assert all(path.isdir(p) for p in model_search_paths)
|
||||
|
||||
model_paths = list(
|
||||
chain(*(glob.glob(f'{d}/**/*.glb', recursive=True) for d in model_search_paths)))
|
||||
chain(*(glob.glob(f'{d}/**/*.glb', recursive=True) for d in model_search_paths))) + \
|
||||
list(
|
||||
chain(*(glob.glob(f'{d}/**/*.gltf', recursive=True) for d in model_search_paths)))
|
||||
# This flatten the output for glob.glob
|
||||
self.models = {path.splitext(path.basename(model))[0]: model for model in model_paths}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user