Commit 58564e71 authored by amandaghassaei's avatar amandaghassaei

rendering

parent e3e1c192
......@@ -53,8 +53,10 @@ function initDynamicModel(globals){
geometry.computeBoundingSphere();
var bounds = geometry.boundingBox;
var avg = (bounds.min.add(bounds.max)).multiplyScalar(0.5);
object3D.position.set(-avg.x, 0, -avg.z);
var avg = (bounds.min.add(bounds.max)).multiplyScalar(-0.5);
object3D.position.set(avg.x, 0, avg.z);
globals.threeView.centerModel(avg);
initTypedArrays();
if (firstTime === undefined) firstTime = false;
......
......@@ -34,7 +34,6 @@ function initModel(globals){
for (var i=0;i<_vertices.length;i++){
_nodes.push(new Node(_vertices[i].clone(), _nodes.length));
}
console.log(_faces[0]);
_nodes[_faces[0].a].setFixed(true);
_nodes[_faces[0].b].setFixed(true);
_nodes[_faces[0].c].setFixed(true);
......
......@@ -26,6 +26,7 @@ function initThreeView(globals) {
scene.background = new THREE.Color(0xe6e6e6);
scene.add(wrapper);
scene.add(patternWrapper);
patternWrapper.visible = false;
scene.add(modelWrapper);
var directionalLight1 = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight1.position.set(0, 100, 0);
......@@ -42,7 +43,7 @@ function initThreeView(globals) {
//scene.fog = new THREE.FogExp2(0xf4f4f4, 1.7);
//renderer.setClearColor(scene.fog.color);
camera.zoom = 15;
camera.zoom = 1;
camera.updateProjectionMatrix();
camera.position.x = 40;
camera.position.y = 40;
......@@ -143,6 +144,10 @@ function initThreeView(globals) {
controls.enableRotate = state;
}
function centerModel(position){
modelWrapper.position.set(position.x, 0, position.z);
}
return {
sceneAddPattern: sceneAddPattern,
......@@ -150,6 +155,7 @@ function initThreeView(globals) {
sceneClearPattern: sceneClearPattern,
sceneAddModel: sceneAddModel,
sceneClearModel: sceneClearModel,
centerModel: centerModel,
sceneAdd: sceneAdd,
sceneRemove: sceneRemove,
render: render,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment