Closed cekees closed 9 years ago
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)
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....
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.
(You'll have to pull the latest master to get that commit, of course)
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
Can you make a pull request?
@cekees - I think https://github.com/jasongrout/pythreejs/commit/f06441dd477ff00ec23dc691cb8105a4a8e3632f 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?
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?
@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.