From be06a55f184b77d0321b1a9909ca6ed65d80bc99 Mon Sep 17 00:00:00 2001 From: nicolalandro Date: Sun, 14 Nov 2021 14:59:41 +0100 Subject: [PATCH] orbit and camera params --- obj2html/index.html | 10 +++++----- obj2html/obj2html.py | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/obj2html/index.html b/obj2html/index.html index ea17b6e..327d3bf 100644 --- a/obj2html/index.html +++ b/obj2html/index.html @@ -15,14 +15,14 @@ const renderer = new THREE.WebGLRenderer({canvas}); const fov = {{camera.fov}}; - const aspect = 2; // the canvas default - const near = 0.1; - const far = 100; + const aspect = {{camera.aspect}}; // the canvas default + const near = {{camera.near}}; + const far = {{camera.far}}; const camera = new THREE.PerspectiveCamera(fov, aspect, near, far); - camera.position.set(0, 10, 20); + camera.position.set({{camera.pos_x}}, {{camera.pos_y}}, {{camera.pos_z}}); const controls = new OrbitControls(camera, canvas); - controls.target.set(0, 5, 0); + controls.target.set({{camera.orbit_x}}, {{camera.orbit_y}}, {{camera.orbit_z}}); controls.update(); const scene = new THREE.Scene(); diff --git a/obj2html/obj2html.py b/obj2html/obj2html.py index d298d2b..6ba90c7 100644 --- a/obj2html/obj2html.py +++ b/obj2html/obj2html.py @@ -7,7 +7,8 @@ TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'index. def simple_mustache(input_string, value_dict): output_string = copy.deepcopy(input_string) - mustache_variables = re.findall(r"{{.*}}",output_string) + mustache_variables = re.findall(r"{{.*?}}",output_string) + for v_text in mustache_variables: v_name = v_text[2:-2] if '.' in v_name: @@ -21,7 +22,16 @@ def simple_mustache(input_string, value_dict): def obj2html( obj_path, output_html_path=None, camera={ - "fov": 45 + "fov": 45, + "aspect": 2, + "near": 0.1, + "far": 100, + "pos_x": 0, + "pos_y": 10, + "pos_z": 20, + "orbit_x": 0, + "orbit_y": 5, + "orbit_z": 0, }, ): with open(obj_path, "r") as f: