ngl icon indicating copy to clipboard operation
ngl copied to clipboard

Is it possible to use the Three.js OrbitController in NGL?

Open garyo opened this issue 6 years ago • 3 comments

I'd like to be able to swap out the Trackball controller for a different one, e.g. Three.OrbitController. Is that possible? I'd be willing to work on a PR if that's considered useful.

garyo avatar Mar 11 '19 17:03 garyo

Hmm - one for @arose but I'll have a go at answering:

I guess so - the main difference between the two seems to be how you translate from mouse movements to rotation matrices and that's in the TrackballControls class currently (which incidentally doesn't look very much like the one in three.js!)

So... you could pull it out into a base class CameraControls? and TrackballControls and OrbitControls which implement the pan/rotation methods differently?

Sounds doable, what's your use-case? (playing with the threejs example it seems to keep one axis always pointing "up" - ie. you can't turn the scene upside down)

fredludlow avatar Mar 14 '19 21:03 fredludlow

Thanks @fredludlow; I may take a crack at that. Breaking out controls as a separate class makes sense (the way three.js does it). You can go upside down with OrbitControls if you set things up properly, but yes, it does a much better job of preventing accidental tilt (camera Z axis rotation). I think my users will find orbit-style controls more intuitive. There are other things I'd like to do to improve the camera control UX -- so breaking it out into a substitutable class seems like a good first step. Glad I'm not missing something that's already there.

garyo avatar Mar 14 '19 21:03 garyo

I concur with @fredludlow assessment.

arose avatar Mar 22 '19 20:03 arose