Borjan Posted July 11, 2017 Share Posted July 11, 2017 I'm invoking the camera.zoomOn function in two ways: a) at the end of the function createScene on mouse double-click see the playground https://www.babylonjs-playground.com/index2_5.html#TXNNZH My questions are: Invoking from createScene does not zoom (check the playground). What should I do differently? Zooming on mouse-double-click works fine. However, when doble-clicking in Microsoft Edge or Google Chrome, the mouse focus moves away from the canvas. Consequently, when I try to rotate immediately after double-clicking I'm moving the complete canvas element instead. If I just single-click immediately after the double-click, there is no problem, the mouse control is back. Thus, this is not a serious issue, however I know that it can be solved easily ... BTW, this cannot be recreated in the playground ... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 11, 2017 Share Posted July 11, 2017 Hi Borjan... and welcome. For #1... https://www.babylonjs-playground.com/index2_5.html#TXNNZH#1 In lines 125-129, I did some hacking... and now the ZoomAll after scene loading... seems to work. I'm not sure WHY that 1/2 second delay is needed. Wrapping the call in scene.executeWhenReady should have been ALL that was necessary... but I'm still learning. Also, if you see a " Loading assets...Please wait " displaying constantly... that's "classic" for playground scenes with scene.executeWhenReady() in them. I'm not sure why it does that. It is a playground-only thing, I suspect. #2 - That is really odd, eh? Can those issues be avoided by adding canvas.focus() as the last line in the doubleclick event handler? hmm. What a strange thing. Doubleclick on canvas, and canvas loses focus() in Edge and G-Chrome. That just makes no sense at all. Very puzzling. Thanks for reporting BOTH of these issues. I'm going to do more research on this stuff. Stay tuned, others will surely comment soon. Quote Link to comment Share on other sites More sharing options...
Borjan Posted July 11, 2017 Author Share Posted July 11, 2017 Thanks Wingnut, #1 I've tried that in my page and it didn't do any zoom - it behaves differently from playground. Also tried to change timeout values (2-1000), but that was of no help. #2 invoking focus didn't help. I believe it is a problem how the mouse events are being processed. In Windows (if I recall it correctly), the event handlers are cascaded. It looks like my own handler (defined in BABYLON) is invoked first, and subsequently the handler of Edge is invoked next. I guess, a double click means for the browser that the user wants to drag a HTML element around. There should be a way to stop the event propagating further than BABYLON. 4 hours ago, Borjan said: see the playground https://www.babylonjs-playground.com/index2_5.html#TXNNZH My questions are: Invoking from createScene does not zoom (check the playground). What should I do differently? Zooming on mouse-double-click works fine. However, when doble-clicking in Microsoft Edge or Google Chrome, the mouse focus moves away from the canvas. Consequently, when I try to rotate immediately after double-clicking I'm moving the complete canvas element instead. If I just single-click immediately after the double-click, there is no problem, the mouse control is back. Thus, this is not a serious issue, however I know that it can be solved easily ... BTW, this cannot be recreated in the playground ... 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.