From 4c7c6eee483da3311ff95a8fab706eb30d7cbe3a Mon Sep 17 00:00:00 2001 From: nicolalandro Date: Sun, 14 Nov 2021 15:04:31 +0100 Subject: [PATCH] add light options --- obj2html/index.html | 8 ++++---- obj2html/obj2html.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/obj2html/index.html b/obj2html/index.html index 327d3bf..6ef88c3 100644 --- a/obj2html/index.html +++ b/obj2html/index.html @@ -37,11 +37,11 @@ } { - const color = 0xFFFFFF; - const intensity = 1; + const color = {{light.color}}; + const intensity = {{light.intensity}}; const light = new THREE.DirectionalLight(color, intensity); - light.position.set(0, 10, 0); - light.target.position.set(-5, 0, 0); + light.position.set({{light.pos_x}}, {{light.pos_y}}, {{light.pos_z}}); + light.target.position.set({{light.target_x}}, {{light.target_y}}, {{light.target_z}}); scene.add(light); scene.add(light.target); } diff --git a/obj2html/obj2html.py b/obj2html/obj2html.py index 6ba90c7..7f775af 100644 --- a/obj2html/obj2html.py +++ b/obj2html/obj2html.py @@ -33,6 +33,16 @@ def obj2html( "orbit_y": 5, "orbit_z": 0, }, + light={ + "color": "0xFFFFFF", + "intensity": 1, + "pos_x": 0, + "pos_y": 10, + "pos_z": 0, + "target_x": -5, + "target_y": 0, + "target_z": 0, + } ): with open(obj_path, "r") as f: content = f.readlines() @@ -46,6 +56,7 @@ def obj2html( data_dict = { "obj_3d": js_string, "camera": camera, + "light": light, } html_string = simple_mustache(html_template, data_dict)