The keyboard isn't the only piece of hardware we can get input from. Mouse-clicks also trigger events and we use the same methods to respond to them. The event names for the mouse buttons are:
"mouse1"
: Left mouse button"mouse2"
: Middle mouse button"mouse3"
: Right mouse button
Like keyboard keys, the mouse events also have versions that we can take advantage of.
In order to make use of the mouse, we first have to disable the default mouse camera control. For that, we turn back to our old friend base
. The method base.disableMouse()
has a deceptive name, because it doesn't actually turn off mouse input. Instead, it removes the camera control scheme that Panda3D uses by default, and allows us to use the mouse for other things, and to control the camera with our own code.
Once we've called the base.disableMouse()
method, we can access the camera by manipulating the NodePath
that points to it. For the default camera, that NodePath
is base.camera
.