xtk / X

The X Toolkit
http://www.goXTK.com
Other
793 stars 265 forks source link

Camera Set Focus not changing anything #156

Open pricedb opened 10 years ago

pricedb commented 10 years ago

Hi. I am trying to include several X.mesh objects in my view, where one is the focus of all rotation and focus. For whatever reason, I cannot switch the camera focus from the center of mass to the point I desire.

var obj = new X.mesh();
obj.file = 'my/file/location.stl';
obj.transform.translateX(10);
r.add(obj);

var obj2 = new X.mesh();
obj2.file = 'my/other/file/location.stl';
obj2.transform.translateY(10);
r.add(obj2);

r.resetBoundingBox();
console.log("Camera Focus",r.camera.focus);
r.camera.focus = [10,0,0];
console.log("Camera Focus",r.camera.focus);
r.camera.position = [10,10,10];
r.render();

I would expect this to make my camera focus on and rotate about the first object, as I'm setting the camera to focus at the same point as I translated the object to, but instead it is still pointing at the center of mass. My console outputs: "Camera Focus" Array [ -0, 1, -0 ] "Camera Focus" Array [ -0.09950371902099892, 0.995037190209989, -0 ]

Does anyone know how to fix the focus to not be the center of mass? Is this a common problem or am I just doing something stupid?

Thanks in advance!