Jump to content

problem with canvas.style resizing and actionManager


Recommended Posts

Hi !

I have an issue that I can't reproduce in the PG ...

In order to optimize performance, I use this bit of code at engine declaration :

    canvas.style.width = "50%"; canvas.style.height =  "50%";

    var engine = new BABYLON.Engine(canvas, true, { stencil: true });

    canvas.style.width = '100%'; canvas.style.height = '100%';

I have a clickable mesh in the middle of the screen set with actionManager, but when I use this canvas resizing trick, the mesh becomes unclickable :/ as if resizing the canvas would make clickable areas inconsistent...
Anybody has a clue ?

Thx in advance !!!

Link to comment
Share on other sites


I understand what you are trying to do, and have a different approach.

Try setting the hardware scale of the engine to a different number than it is. This will achieve the same result (for example, making it 50% of what it is, like what you are trying to do), but will still keep everything clickable and nice and dandy.

A quick playground - http://www.babylonjs-playground.com/#1YZ7M3 , line 6 is where the magic happens.

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.

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.


  • Recently Browsing   0 members

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