Dad72 Posted May 6, 2014 Share Posted May 6, 2014 Hi, it happens to me a strange thing. my editor is composed of several tab and in I'm on the ground tab and I charge the ground, my camera moves correctly with the keyboard. But if I change tab and I returned to the ground tab, the camera won't move with the keyboard. Have you any ideas of what could be the cause of this behavior ? Thank you Quote Link to comment Share on other sites More sharing options...
Nico Posted May 6, 2014 Share Posted May 6, 2014 Hi, I think you could try attachControl on your camera to your canvas, it can solve the problem Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2014 Author Share Posted May 6, 2014 Yes I already have a attachControl. but it seems to be disabled when I change tab. what is strange. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2014 Author Share Posted May 6, 2014 I find the problem, keep the focus tab. if I click something, the camera is reactivate. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2014 Author Share Posted May 6, 2014 when I click on the "ground" tab remains active tab and deactivate the handling of the camera (with the keyboard). I'm forced to click in an empty space (any div) so that the camera can be handle.If I click in the canvas with a loaded scene, it does not give focus to the page. the tab remains active . Do you have ideas to solve this ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 6, 2014 Share Posted May 6, 2014 Could you share a link. I definitely need to see that ! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2014 Author Share Posted May 6, 2014 I'll try to reproduce the problem on another project tomorrow Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 6, 2014 Share Posted May 6, 2014 Hmm, maybe put a onclick="getfocus()" in your canvas element? Or maybe onclick="this.focus()"? Or maybe onclick="focus(this)" Ok, I am out of ideas. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2014 Author Share Posted May 6, 2014 I have try this kind of thing.I think it's because each tab I have an iframe and when I select a tab that is on the index, I have to click on an element of the iframe to get the focus, but if I click on on the canvas with a loaded scene, it does not work. The camera won't move with the keyboard, just with the mouse. This is very strange. but I'll try to make a little example tomorrow. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 6, 2014 Share Posted May 6, 2014 Are you using ie11? I already noticed this bug with IE Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 No, i use Google Chrome. Tomorrow I'll see if it does the same thing with Firefox and IE Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 7, 2014 Share Posted May 7, 2014 If you can, that could be better not to use iframes. Nico 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 It was a choice I made there 1 year and 6 months. I can not go back in the current state of the project which is around 3000 files. it's not as if I was at the beginning of the project. and I had no choice.I have 8 tabs, each tab, iframe, because each tab is a editor that needs its own css, its own scripts, its own php functions ...If I had done without Iframe my project would unmanageable. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 For Deltakosh. Here, I done you an example scene to reproduce this bug with the information in the right margin to understand. Scene exemple with Tabs and Iframe If you want to download the sources I can make you a zip also. Thank you Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 7, 2014 Share Posted May 7, 2014 Could the bug be relative to the fact that in FreeCamera.prototype.attachControl, the global variable window is used and iframes are used (different behaviors with global variable window)? Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 7, 2014 Share Posted May 7, 2014 Check the value of window.document.location.href. You'll notice that it changes when you click on a tab. That could explain the bug. Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 7, 2014 Share Posted May 7, 2014 Quick fix for you: replace window by window.parent in FreeCamera.prototype.attachControl for all calls to addEventListener. It works for me on chrome. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 Quick fix for you: replace window by window.parent in FreeCamera.prototype.attachControl for all calls to addEventListener. It works for me on chrome. Sorry gwenael, I not understand what you would me propose to make Quote Link to comment Share on other sites More sharing options...
gwenael Posted May 7, 2014 Share Posted May 7, 2014 In babylon.1.12-beta.js, in method 'FreeCamera.prototype.attachControl', replace all 'window.addEventListener' by 'window.parent.addEventListener'. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 ah, ok. There have not possibility to integrate it directly into Babylon by a function :FreeCamera.prototype.parentAttachControlThis could be useful for others. I do not use custom version of Babylon, just one official version. If it pais you Deltakosh, you can add this fix Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 7, 2014 Share Posted May 7, 2014 window.parent only works for you alas (because of iframe) Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 Yes, for the moment, but it may later there have also user with Iframe. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 I can not create a function apart. it is just 3 extra line of code that fixes this problem for me but may be for others in the future.It remains a lack Babylon the specific uses. it mean that with babylon can not know the users specific application ? Without adding new function, I simply proposes to amend the attachControl function for specific cases by adding signature "parent".Please Deltakosh. This would help me and maybe others too. that would exist in babylon well. Fonction complete : FreeCamera.prototype.attachControl = function (element, noPreventDefault, parent) { //---- //you code no modified //---- element.addEventListener("mousedown", this._onMouseDown, false); element.addEventListener("mouseup", this._onMouseUp, false); element.addEventListener("mouseout", this._onMouseOut, false); element.addEventListener("mousemove", this._onMouseMove, false); if(parent) { window.parent.addEventListener("keydown", this._onKeyDown, false); window.parent.addEventListener("keyup", this._onKeyUp, false); window.parent.addEventListener("blur", this._onLostFocus, false); } else { window.addEventListener("keydown", this._onKeyDown, false); window.addEventListener("keyup", this._onKeyUp, false); window.addEventListener("blur", this._onLostFocus, false); } }; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 7, 2014 Share Posted May 7, 2014 I updated camera to: var root = window.parent || window; root.addEventListener("keydown", this._onKeyDown, false); root.addEventListener("keyup", this._onKeyUp, false); root.addEventListener("blur", this._onLostFocus, false); Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2014 Author Share Posted May 7, 2014 Thank you Deltakosh. your solution is even better. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.