Add "Trackpad Friendly" camera control setting inspired by Blender (#431)

* Refactor: rename CADProgram to CameraSystem

* Fix buttonDownInStream always set to 0
This is problematic because the left mouse
button ID is actually 0. If no button is
pressed we should set back to undefined.

* Fix: middle mouse button ID is 1, not 3

* Add "Trackpad Friendly" camera system setting

Signed off by Frank Noirot <frank@kittycad.io>

* Allow camera configs to be lenient on first click
This commit is contained in:
Frank Noirot
2023-09-11 16:21:23 -04:00
committed by GitHub
parent 9e2a94fcd9
commit c5cb0e2fd4
6 changed files with 67 additions and 32 deletions

View File

@ -66,11 +66,20 @@ export const Stream = ({ className = '' }) => {
const interactionGuards = cameraMouseDragGuards[cameraControls]
let interaction: CameraDragInteractionType_type
if (interactionGuards.pan.callback(e)) {
if (
interactionGuards.pan.callback(e) ||
interactionGuards.pan.lenientDragStartButton === e.button
) {
interaction = 'pan'
} else if (interactionGuards.rotate.callback(e)) {
} else if (
interactionGuards.rotate.callback(e) ||
interactionGuards.rotate.lenientDragStartButton === e.button
) {
interaction = 'rotate'
} else if (interactionGuards.zoom.dragCallback(e)) {
} else if (
interactionGuards.zoom.dragCallback(e) ||
interactionGuards.zoom.lenientDragStartButton === e.button
) {
interaction = 'zoom'
} else {
return
@ -93,7 +102,6 @@ export const Stream = ({ className = '' }) => {
const handleScroll: WheelEventHandler<HTMLVideoElement> = (e) => {
if (!cameraMouseDragGuards[cameraControls].zoom.scrollCallback(e)) return
e.preventDefault()
engineCommandManager?.sendSceneCommand({
type: 'modeling_cmd_req',
cmd: {
@ -130,7 +138,7 @@ export const Stream = ({ className = '' }) => {
cmd_id: newCmdId,
})
setButtonDownInStream(0)
setButtonDownInStream(undefined)
if (!didDragInStream) {
engineCommandManager?.sendSceneCommand({
type: 'modeling_cmd_req',