Change the 'config' attribute of an interactor for disabling some user events

≡放荡痞女 提交于 2020-02-07 05:36:10

问题


I'd like to display several views of the same scene, with 1 of them full interactive, and 2 others from top and right and which could only be zoomed. So my issue is to disable some user interactions on a render.

One alternative is to overload the other events handler methods with forcing the renderer's camera to keep the same view if the event isn't a mouse wheel. It works but it's not pretty (neither for a programmer nor a user).

So I want to change the 'config' attribute of my renderer. Here is my code and the explained issues :

var r1 = new X.renderer('r1'); // r1 is created, but its "interactor" attribute is null, see visualization>renderer.js
r1.interactor().config.MOUSEWHEEL_ENABLED = false; // DO NOT work cause the "interactor" attribute of r1 is null
r1.init(); // r1 is initialized : it creates a new interactor, calls interactor.init(), and puts the new interactor in the "interactor" attribute of r1, , see visualization>renderer.js
r1.interactor().config.MOUSEWHEEL_ENABLED = false; // DO NOT work because the interactor.init() has already generated all the event handler methods and associated them to the listeners, see io>interactor.js

I also tried the following but in consequence my renderer turns black/empty :

var r1 = new X.renderer('r1');
r1.init();
r1.interactor().config.MOUSEWHEEL_ENABLED = false;
r1.interactor().init();

Do you see the issue ? The 'config' change should be done between the creation of a new interactor and the initialization of it. But, if I'm not mistaken, you cannot create an interactor and set it to a renderer manualy like the "interactor" attribute is protected.

Did I something wrong ? Any idea to perform it ?


回答1:


This is the correct way to do it

var r1 = new X.renderer('r1');
r1.init();
r1.interactor().config.MOUSEWHEEL_ENABLED = false;
r1.interactor().init();

but you were right - it didn't work so far because of a typo and a missing exported symbol. This was fixed in https://github.com/xtk/X/commit/f1f80ebb26020f4b13b797993a9008ae07a50195 and is available in http://get.goxtk.com/xtk_edge.js now.



来源:https://stackoverflow.com/questions/10380269/change-the-config-attribute-of-an-interactor-for-disabling-some-user-events

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!