I have a program with a subroutine that allows you to orbit an object by holding down a mouse button and moving the mouse - similar to how OrbitControls works. In order to listen for mouse events, the program includes the following three lines - which I believe are fairly standard:
renderer.domElement.addEventListener("mousedown", onMouseDown, false);
renderer.domElement.addEventListener("mouseup", onMouseUp, false);
renderer.domElement.addEventListener("mousemove", onMouseMove, false);
I am attempting to add some basic GUI inputs to the program and everything looks okay. However, the GUI does not appear to be receiving input. I suspect that my mouse event listeners are the problem.
If there a way to make these compatible?
From what I have read, OrbitControls was modified in recent years so that it does not interfere with GUI input.
Some older programs appeared to have a variation of the following for GUI:
document.getElementById('gui').appendChild(gui.domElement);
But that doesnât seem to work.
So it appears that there are 3 possible solutions:
- Make my mouse event listeners inoperative when the pointer is over the GUI control panel area,
- Make GUI inputs take precedence over my mouse events.
- Give GUI a separate input (as above) - but that seems less helpful since GUI inputs would also cause orbit changes.
I have checked other questions posted on this board and they are not quite the same. One involved a âfakeâ GUI and others involve OrbitControls, TrackBallControls and Raycasting, none of which I am using.
The test GUI code that I am using is this:
var gcontrols = {
Month: 6,
DayMo: 15,
Viewpoint: "Level"};
var gui = new dat.GUI();
var folder = gui.addFolder("Date");
folder.add(gcontrols, "Month").min(1).max(12).step(1).name("Month").listen();
folder.add(gcontrols, "DayMo").min(1).max(31).step(1).name("Day").listen();
folder.add(gcontrols, "Viewpoint", ["Level", "Earth", "Fixed"] ).name("View").listen();
folder.open();
EDIT
Here is a link to the Program.