From de5d67b2cf44bc93ea05585e658e12b8efbfe4dc Mon Sep 17 00:00:00 2001 From: nicolalandro Date: Sun, 14 Nov 2021 09:18:49 +0100 Subject: [PATCH] refactor wit dot notation --- obj2html/index.html | 2 +- obj2html/obj2html.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/obj2html/index.html b/obj2html/index.html index 0217668..ea17b6e 100644 --- a/obj2html/index.html +++ b/obj2html/index.html @@ -14,7 +14,7 @@ const canvas = document.querySelector('#c'); const renderer = new THREE.WebGLRenderer({canvas}); - const fov = {{fov}}; + const fov = {{camera.fov}}; const aspect = 2; // the canvas default const near = 0.1; const far = 100; diff --git a/obj2html/obj2html.py b/obj2html/obj2html.py index 9a3d15b..4ff34eb 100644 --- a/obj2html/obj2html.py +++ b/obj2html/obj2html.py @@ -4,7 +4,12 @@ import json TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'index.html') -def obj2html(obj_path, output_html_path=None, fov=45): +def obj2html( + obj_path, output_html_path=None, + camera={ + "fov": 45 + }, + ): with open(obj_path, "r") as f: content = f.readlines() content = '\n'.join(content) @@ -14,7 +19,7 @@ def obj2html(obj_path, output_html_path=None, fov=45): with open(TEMPLATE_PATH, "r") as f: html_template = f.read() html_string = html_template.replace("{{obj_3d}}", js_string) - html_string = html_string.replace("{{fov}}", str(fov)) + html_string = html_string.replace("{{camera.fov}}", str(camera['fov'])) if output_html_path != None: with open(output_html_path, "w") as f: