Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set lookAt vector #16

Closed
cekees opened this issue May 20, 2015 · 8 comments
Closed

how to set lookAt vector #16

cekees opened this issue May 20, 2015 · 8 comments

Comments

@cekees
Copy link

cekees commented May 20, 2015

@jasongrout, I'm having trouble pointing the camera to the centroid of my scene, so I get clunky behavior from the orbital controls. Is there a direct way I can set it? I believe it's the lookAt vector in three.js, but I don't see it exposed by pythreejs.

@jasongrout
Copy link
Member

Did you try the look_at method on the camera object? The three.js lookAt function is a function that calculates the correct rotation (https://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js#L284). We tried to duplicate this in python in the look_at function (https://github.com/jasongrout/pythreejs/blob/master/pythreejs/pythreejs.py#L197)

@jasongrout
Copy link
Member

Curiously, I'm not getting a look_at call to the camera to work. It does seem to work with normal objects in the scene, however. Investigating....

@jasongrout
Copy link
Member

Okay, turns out the camera look_at function is overridden by the OrbitControls target. So I just exposed the OrbitControls target value. So do something like:

OrbitControls(target=(1,1,1), controlling = ...)

or if you instead do something like c = OrbitControls(controlling=...), just update it with c.target=(1,1,1).

Let me know if this works for you.

@jasongrout
Copy link
Member

(You'll have to pull the latest master to get that commit, of course)

@cekees
Copy link
Author

cekees commented May 22, 2015

That works, thanks! I backported to a branch for IPython 3.1.0 and pushed it here: https://github.com/erdc-cm/pythreejs/tree/ipy3.1.0

@jasongrout
Copy link
Member

Can you make a pull request?

@jasongrout
Copy link
Member

@cekees - I think jasongrout@f06441d may make the master branch compatible with IPython 3.1. If you have time, can you check to see if master now works with IPython 3.1?

@ivmi
Copy link

ivmi commented Dec 11, 2015

I am still not able to change camera angle from python. I have orbitcontroller and change its target position.
It works when orbitcontroller is not used.

Can anyone confirm it works or provide working example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants