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

Custom camera orientation does not seem to work #207

Open
moorepants opened this issue Jun 8, 2015 · 19 comments
Open

Custom camera orientation does not seem to work #207

moorepants opened this issue Jun 8, 2015 · 19 comments

Comments

@moorepants
Copy link
Member

If you run the mass_spring_damper example there is a custom camera that used to rotate the scene properly. See the first screenshot in this PR #97. But for some reason only the location of the camera seems correctly adjusted and not the orientation.

@sahilshekhawat
Copy link
Member

This issue must be fixed in #183.

@moorepants
Copy link
Member Author

It does not seemed to be fixed in #183 for me. The orientation of the camera in the mass_spring_damper should be such that the mass bobs up and down.

moorepants added a commit to moorepants/pydy that referenced this issue Jun 10, 2015
This was a test for issue pydy#207, but it ended up uncovering a bug in the
OrthoGraphicCamera. PR pydy#210 needs to be merged before this one.
moorepants added a commit to moorepants/pydy that referenced this issue Jun 11, 2015
This was a test for issue pydy#207, but it ended up uncovering a bug in the
OrthoGraphicCamera. PR pydy#210 needs to be merged before this one.
@moorepants
Copy link
Member Author

@sahilshekhawat Would you mind looking into this issue. I don't think it is on the Python side. I haven't been able to find the bug yet in the JS.

@sahilshekhawat
Copy link
Member

I am currently working on fixing issues with camera including this one.

@sahilshekhawat
Copy link
Member

Okay, So I spent about one and a half day figuring out the reason and i still don't know.
camera.applyMatrix() must work as it sets the value of position, quaternions and scale but it doesn't changes quaternions only. Position is changed. Moreover, When I manually set those values e.g.

var position = new THREE.Vector3();
var quaternion = new THREE.Quaternion();
var scale = new THREE.Vector3(1, 1, 1);
initMatrix.decompose(position, quaternion, scale);
_camera.position = position;
_camera.quaternion = quaternion;
_camera.scale = scale;

then again quaternion's value is not changed.
Correct orientation works when we do

_camera.matrixAutoUpdate = false;

which doesn't changes the value of transformation matrix from incorrect quaternions but then again trackballcontrols are not working due to that.
Whenever we run camera.updateMatrix() it changes the orientation which makes it sure that the bug is in setting the value of camera.quaternions
I am leaving it until the end and moving on to fix other bugs. Will look into it later.

@moorepants
Copy link
Member Author

@tarzzz Do you have any idea why this is not working? It used to work just fine (at least at the end of last summer).

Sahil is going to file an issue on threejs about this.

@sahilshekhawat
Copy link
Member

@tarzzz
Copy link
Contributor

tarzzz commented Jun 15, 2015

When the frame is rotated 90degrees with ceiling.y as the Axis, it behaves as per the expectation.

camera_frame = ceiling.orientnew('Camera Frame','Axis', [-pi / 2, ceiling.y])

but rotating w.r.t to ceiling.z (which is desired here) does nothing. That somehow rules out the bug on the JS side (Since the initial matrix updates are working fine for ceiling.y).

@moorepants
Copy link
Member Author

@sahilshekhawat What is the status here? Has the SO question and Tarun's observation helped figure out anything?

If we can't get this into the release, we may need to disable the ability to orient cameras.

@sahilshekhawat
Copy link
Member

@tarzzz but if we do camera.matrixAutoUpdate = false it works, thus, I don't think that its on the Python side. Something is overriding our matrix and I don't know what.

@moorepants
Copy link
Member Author

One way to help eliminate the python side possibility is to complete the unit tests for the cameras, see #212.

@moorepants
Copy link
Member Author

@sahilshekhawat For this one, maybe we should issue a warning if the user passes in a custom camera referencing this issue. Will just have the warning for the release.

@sahilshekhawat
Copy link
Member

Okay, I am raising a PR for the same.

@sahilshekhawat
Copy link
Member

After #239 is merged, I am going to remove this from the milestone.

@moorepants moorepants removed this from the 0.3.0 Release milestone Jun 17, 2015
@oliverlee
Copy link
Contributor

This is not a Python issue. You can change the rotation portion of the camera initial orientation transformation matrix and the rotation is not changed when displaying the scene.

@moorepants
Copy link
Member Author

Yes, I agree. I'm pretty sure it is in the JS code.

@moorepants moorepants modified the milestone: 0.3.1 Release Dec 26, 2015
@moorepants
Copy link
Member Author

This bug is nasty. I spent a number of hours today trying to track it down. First off, here is a minimum example that shows camera initialization working with three.js r58 (the version we ship with PyDy):

http://jsfiddle.net/nd8q6qug/5/

Some findings:

I have also tried updating three.js to the newest version, r73, but it fails to load THREE in the notebook and I haven't been able to figure out why. We are likely using the incorrect way to load custom js into the notebook.

@moorepants
Copy link
Member Author

I've found something that could be part of the problem. The parser.js file has two AJAX calls that aren't necessarily completed before the animation function is called. It would be good to ensure that those complete before running subsequent commands.

@moorepants moorepants removed this from the 0.3.1 milestone Jan 6, 2016
@moorepants
Copy link
Member Author

Moved this out of the 0.3.1 milestone since we haven't fixed it in time.

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

No branches or pull requests

4 participants