如何在javascript中更新createControls的函数输入变量? [英] How to update createControls's function input variables at javascript?
问题描述
我有一个
function createControls(){ return new THREE.TrackballControls( camera,domElement );}
由
THREE.TrackballControls=function(object, domElement){.....}
controls = createControls(camera, renderer.domElement);
restoreView(controls, vars);
addDefaultKeyEventListener();
在调整webgl容器的大小后,控件无法正常工作..确切地说,有一个事件当用户单击屏幕时,一个黄色的球将移动到3d空间上平原上的确切位置。在调整大小事件之后,球会移动到一个位置,该位置的偏移量与我认为与调整大小的比例有关。当我尝试重新定义控件变量时,它崩溃。.
and after resizing the webgl container the controls dont work correct..to be precise there is an event where when the user clicks on the screen a yellow ball moves to the exact place on a plain at the 3d space. After the resize event the ball moves at a spot which has a offset of that place i suppose related with the resized scale. When i try to redefine controls variable it crashes..
如何更新具有新camera和renderer.domElement输入变量的控件?
How can i update the controls having new camera and renderer.domElement input variables?
推荐答案
TrackballControls
为此提供了一种方法: handleResize()
。因此,如果您使用
TrackballControls
have a method for that : handleResize()
. So if you create your controls with
controls=new THREE.TrackballControls(...);
您只需添加
controls.handleResize();
进入 resize
事件调用的函数
这篇关于如何在javascript中更新createControls的函数输入变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!