Jump to content

camera.zoomOn invoked from createScene does not zoom


Borjan
 Share

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 ...  
Link to comment
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.

Link to comment
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 ...  

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...