diff --git a/static/assets/equirectangular.png b/static/assets/equirectangular.png deleted file mode 100644 index 3e44cfb..0000000 Binary files a/static/assets/equirectangular.png and /dev/null differ diff --git a/utils/utils.py b/utils/utils.py index c27d8c8..e4738f5 100644 --- a/utils/utils.py +++ b/utils/utils.py @@ -46,10 +46,20 @@ def get_directory_content(dir_path): return content +def find_skybox_image(dir): + print("find_skybox_image(dir): ", dir) + for p in Path(dir).iterdir(): + extension = Path(p).suffix + print(f"sky-box{extension}") + if str(Path(p)).endswith(f"sky-box{extension}"): + print("return str(p): ", str(p)) + return str(p) + return None + def find_file_with_extension(dir, extension): for p in Path(dir).iterdir(): if Path(p).suffix.lstrip('.').lower() == extension: - return str(p) + return str(p).replace(OBJECT_DIR, "") return None @@ -71,15 +81,22 @@ def get_object(file_path, result={}): extension = Path(file_name).suffix.lstrip('.').lower() print('get_object(extension):', extension) - if extension == "gltf": - result['type']="gltf" + if extension == "gltf" or extension == 'glb': + if extension == "gltf": + result['type']="gltf" + if extension == 'glb': + result['type'] = "glb" object_path = str(file_path).replace(OBJECT_DIR, "") result['urls'].append(f"/objects/{object_path}") + skybox_path = find_skybox_image(file_dir) + if skybox_path: + skybox_path = str(skybox_path).replace(OBJECT_DIR, '') + result['skybox'] = f"/objects{skybox_path}" return result if extension == "obj": result['type']="obj" object_path = str(file_path).replace(OBJECT_DIR, "") - result['urls'].append(f"/objects/{object_path}") + result['urls'].append(f"/objects{object_path}") mtl_file = find_file_with_extension(file_dir, 'mtl') if mtl_file: result = get_object(mtl_file.replace(OBJECT_DIR, ""), result) @@ -104,11 +121,6 @@ def get_object(file_path, result={}): object_path = str(file_path).replace(OBJECT_DIR, "") result['urls'].append(f"/objects/{object_path}") return result - if extension == 'glb': - result['type'] = "glb" - object_path = str(file_path).replace(OBJECT_DIR, "") - result['urls'].append(f"/objects/{object_path}") - return result if extension == 'json': result['type'] = "json" object_path = str(file_path).replace(OBJECT_DIR, "") diff --git a/views/google.tpl b/views/google.tpl index 472654b..e8ff1a9 100644 --- a/views/google.tpl +++ b/views/google.tpl @@ -27,7 +27,9 @@ model-viewer { auto-rotate="" camera-controls="" background-color="#455A64" - skybox-image="/static/assets/equirectangular.png" + %if 'skybox' in object: + skybox-image="{{ object['skybox']}}" + %end >