orbit and camera params

This commit is contained in:
nicolalandro 2021-11-14 14:59:41 +01:00
parent ab31d8bb7e
commit be06a55f18
2 changed files with 17 additions and 7 deletions

View File

@ -15,14 +15,14 @@
const renderer = new THREE.WebGLRenderer({canvas}); const renderer = new THREE.WebGLRenderer({canvas});
const fov = {{camera.fov}}; const fov = {{camera.fov}};
const aspect = 2; // the canvas default const aspect = {{camera.aspect}}; // the canvas default
const near = 0.1; const near = {{camera.near}};
const far = 100; const far = {{camera.far}};
const camera = new THREE.PerspectiveCamera(fov, aspect, near, 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); 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(); controls.update();
const scene = new THREE.Scene(); const scene = new THREE.Scene();

View File

@ -7,7 +7,8 @@ TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'index.
def simple_mustache(input_string, value_dict): def simple_mustache(input_string, value_dict):
output_string = copy.deepcopy(input_string) 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: for v_text in mustache_variables:
v_name = v_text[2:-2] v_name = v_text[2:-2]
if '.' in v_name: if '.' in v_name:
@ -21,7 +22,16 @@ def simple_mustache(input_string, value_dict):
def obj2html( def obj2html(
obj_path, output_html_path=None, obj_path, output_html_path=None,
camera={ 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: with open(obj_path, "r") as f: