add light options

This commit is contained in:
nicolalandro 2021-11-14 15:04:31 +01:00
parent be06a55f18
commit 4c7c6eee48
2 changed files with 15 additions and 4 deletions

View File

@ -37,11 +37,11 @@
} }
{ {
const color = 0xFFFFFF; const color = {{light.color}};
const intensity = 1; const intensity = {{light.intensity}};
const light = new THREE.DirectionalLight(color, intensity); const light = new THREE.DirectionalLight(color, intensity);
light.position.set(0, 10, 0); light.position.set({{light.pos_x}}, {{light.pos_y}}, {{light.pos_z}});
light.target.position.set(-5, 0, 0); light.target.position.set({{light.target_x}}, {{light.target_y}}, {{light.target_z}});
scene.add(light); scene.add(light);
scene.add(light.target); scene.add(light.target);
} }

View File

@ -33,6 +33,16 @@ def obj2html(
"orbit_y": 5, "orbit_y": 5,
"orbit_z": 0, "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: with open(obj_path, "r") as f:
content = f.readlines() content = f.readlines()
@ -46,6 +56,7 @@ def obj2html(
data_dict = { data_dict = {
"obj_3d": js_string, "obj_3d": js_string,
"camera": camera, "camera": camera,
"light": light,
} }
html_string = simple_mustache(html_template, data_dict) html_string = simple_mustache(html_template, data_dict)