gl-engine icon indicating copy to clipboard operation
gl-engine copied to clipboard

Camera stuff

Open mattdesl opened this issue 9 years ago • 9 comments

What is the best way to manipulate a glam camera? Looking for a simple "orbit style" controls example.

It might help to integrate some of these modules and/or their dependencies: https://github.com/Jam3/perspective-camera https://github.com/Jam3/ray-3d https://github.com/Jam3/orbit-controls (WIP)

mattdesl avatar Dec 23 '15 16:12 mattdesl

:+1:

Yeah I was going through those the other day. I haven't focused on API ergonomics of the cameras at all. The code as it exists has mainly been about getting the matrices computed and in place. I think ultimately the controls like orbit need to be first class citizens, and easy to use.

I like the idea of keeping the transform property in place as a clear API practice, but in practice the camera is going to have different needs on what's computed, and it won't use a scale property.

I need to read through the source code of the existing camera modules and get a better handle on them.

gregtatum avatar Dec 23 '15 17:12 gregtatum

I just reviewed all of this and it's great stuff. I'm thinking about cannibalizing the perspective-camera code to make it more in-line with some of the existing glam conventions, but it feels a ton better than what I have now.

gregtatum avatar Dec 26 '15 16:12 gregtatum

Cool 👍 if there's anything that could be shared we can split into its own module. Ideally orbit-controls could be cleaned up so that it works with a variety of frameworks.

Sent from my iPhone

On Dec 26, 2015, at 11:00 AM, Greg Tatum [email protected] wrote:

I just reviewed all of this and it's great stuff. I'm thinking about cannibalizing the perspective-camera code to make it more in-line with some of the existing glam conventions, but it feels a ton better than what I have now.

— Reply to this email directly or view it on GitHub.

mattdesl avatar Dec 26 '15 16:12 mattdesl

camera-look-at.js seems to be the only thing in perspective camera that might fit the bill in an initial look.

I think orbit controls should be able to plopped in with just a little bit of glue.

gregtatum avatar Dec 26 '15 17:12 gregtatum

fwiw, I've found that having camera input modules operate on a ray (i.e. origin + direction) makes things modularise really well. camera-spin does this, albeit with a bunch of extra sugar, and it means that while you can use mat4.lookAt to generate a view matrix, you can also do stuff like plug it into a raymarching shader with hardly any extra effort :)

hughsk avatar Dec 27 '15 00:12 hughsk

Is it important for the camera to behave inside of the scene hierarchy? If I don't have to add the matrix parent/child calculation the camera will be a much simpler thing. I'm thinking of just glueing perspective-camera in now that I'm looking at implementing it. Plus adding the camera to the scene is kind of an awkward step when you're already passing it into the render() call already.

gregtatum avatar Jan 10 '16 15:01 gregtatum

I ended up using the straight modules with some glue. I really like the idea of offloading the internals of how these things work to modules. It was fairly painless to get it integrated.

gregtatum avatar Jan 14 '16 05:01 gregtatum

Also, can it be renamed a Glamera?

marklundin avatar Feb 08 '16 20:02 marklundin

Yes! Until I rename this project (again) tonight.

gregtatum avatar Feb 08 '16 22:02 gregtatum