我正在构建一个折纸模拟器,我希望能够使用 dat.gui slider “折叠”纸张。我还想包括轨道控制。
但是,当我单击 slider 并随后将鼠标移出 dat.gui 窗口时,轨道控件已被触发,导致模型跳转到不同的方向。
有什么方法可以防止在单击 dat.gui 窗口时触发轨道控制?
最佳答案
引用 the docs :
Constructor OrbitControls( object : Camera, domElement : HTMLDOMElement ) object: (required) The camera to be controlled.
domElement: (optional) The HTML element used for event listeners. By default this is the whole document, however if you only want to the controls to work over a specific element (e.g. the canvas) you can specify that here.
换句话说,要限制 OrbitControl,使其在您单击 GUI 时不启用,您必须提供对 Canvas (renderer.domElement) 或容器(包含 Canvas 的 div)的引用作为第二个构造函数的参数。编码愉快! (还有折叠!)
关于dat.gui - 使用 dat.gui slider 触发轨道控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46105033/