Borjan

camera.zoomOn invoked from createScene does not zoom

Recommended Posts

I'm invoking the camera.zoomOn function in two ways:

a) at the end of the function createScene

B) on mouse double-click

see the playground https://www.babylonjs-playground.com/index2_5.html#TXNNZH

My questions are:

  1. Invoking from createScene does not zoom (check the playground). What should I do differently? 
  2. 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 ...  

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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:

  1. Invoking from createScene does not zoom (check the playground). What should I do differently? 
  2. 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 ...  

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.