xeokit / xeokit-sdk

Open source JavaScript SDK for viewing high-detail, full-precision 3D BIM and AEC models in the Web browser.
https://xeokit.io
Other
715 stars 286 forks source link

CameraControl tweak - orbit Camera#look when click-dragging on empty canvas in "orbit" mode #503

Closed xeolabs closed 3 years ago

xeolabs commented 3 years ago

When myViewer.cameraControl.navMode == "orbit" and we click-drag on empty space, then orbit us about Camera#look, instead of about Scene#center.

This change helps the following navigation use case.

When myViewer.cameraControl.navMode == "orbit", dollying moves Camera#eye and Camera#look forwards and backwards, in unison. Dollying is therefore able to move us all the way through a model, and then out the other side.

If we dolly through a model and pop out the other side, then being able to click and drag on the empty space in front of us, to orbit us about Camera#look, will allow us to turn around and face the model again.

The previous behaviour for click-dragging empty canvas, in which we orbit Scene#center by default, would be disorienting, because that center could be anywhere, resulting in objects whizzing past and disappearing as we orbit.

Demo: https://xeokit.github.io/xeokit-sdk/examples/#BIMOffline_XKT_DoublePrecision_MAP

Amoki commented 3 years ago

If we translate the model, the pivot point is not centered anymore. Is it intended? output

We're also thinking of something else. Currently, the user shouldn't click outside the model. We're trying not to lose users when they do this rather than providing a smart behavior when clicking outside the model.

pivot

We draw a virtual sphere between the center of the model and the camera. If the user clicks on the model, the pivot point is where they clicked (the current behavior). (2.) If the user clicks outside the model, the intersection between the ray and the sphere is used as the pivot point. If we click outside the model on the right, the behavior is different if we click outside the model on the left. (1.)

There are many variants we'd like to try (eg: same with the AABB diagonal as the sphere diameter). Unfortunately, we're not able to test our ideas because of our lack of math.

What do you think? A live coding session to try stuff may be interesting too

Amoki commented 3 years ago

Hi Lindsay! Do you want me to create an issue to talk about this?

xeolabs commented 3 years ago

Hi @Amoki , yes please