Jump to content

Lines2D not rendering correctly


Numa
 Share

Recommended Posts

Hello again, 

Have a look at this playground: http://babylonjs-playground.com/#1SASV5#2

It's a very simple cube with a label attached to it.

If you rotate the camera around slowly, you will notice that the line flickers, and sometimes even is drawn in the opposite direction:

 25fd32b79c.png

however if I print the value for the end point of the line, it is 100% correct every frame. On this screenshot, the end point values printed are 100, 100 when clearly the line is drawn to -100, -100.

Also, if I lock either x or y to a hard-coded value, the flickering is gone: see this playground line 67, I hardcoded a Y value of 100 instead of getting it from the mesh position: http://babylonjs-playground.com/#1SASV5#3

Any idea why?

 

Thanks

Link to comment
Share on other sites

7 hours ago, Numa said:

Hello again, 

Have a look at this playground: http://babylonjs-playground.com/#1SASV5#2

It's a very simple cube with a label attached to it.

If you rotate the camera around slowly, you will notice that the line flickers, and sometimes even is drawn in the opposite direction:

 25fd32b79c.png

however if I print the value for the end point of the line, it is 100% correct every frame. On this screenshot, the end point values printed are 100, 100 when clearly the line is drawn to -100, -100.

Also, if I lock either x or y to a hard-coded value, the flickering is gone: see this playground line 67, I hardcoded a Y value of 100 instead of getting it from the mesh position: http://babylonjs-playground.com/#1SASV5#3

Any idea why?

 

Thanks

Hello, I'm away from home on holidays, I'll check as soon as I can, worst case thursday morning. I'll keep you in touch.

Link to comment
Share on other sites

@Numa first thing I do when I come back from holidays is to make the settings of Lines2D changeable. Then we will see if the issue is solved this way. There's also a weird ZBuffer clipping effect against the cube, I'm very interested to understand what's going on there! Thank you for reporting. I can see the use case you're trying to develop and I think the best thing is to make the appropriate changes in Lines2D, then test again. The Trello card corresponding to the evol is here: https://trello.com/c/DQ4FC9KL

Link to comment
Share on other sites

  • 2 weeks later...

@Numa in the PG you shared at the first post you access the Canvas2D._v and _m objects, all underscored based objects are supposed to be private and you should not use them.

I actually don't event know what's supposed to be in there by the time your code is using it.

Anyways, that's not the main issue I agree, what you should ideally do is create only once your Lines2d object and then each beforeRender set a new array of points, this should work (but I've started to test it locally and looks like it's not).

Please try to provide a PG without the _v _m, thanks.

Link to comment
Share on other sites

Thanks Nockawa, I've had a look but I'm not really sure how what to replace _v and _m with, in the source code they're only set once, and they're set to:

Canvas2D._v = BABYLON.Vector3.Zero();
Canvas2D._m = BABYLON.Matrix.Identity();

I couldn't find anywhere else where those values are changed, yet the matrix one does change every frame if you rotate the camera hehe.

Is there a public function to access the canvas' matrix ?

I based my code on the Canvas2D.prototype._updateTrackedNodes function, which is of course accessing the private variables.

 

I tried using a single line and updating the array as you suggested and indeed it doesn't work, the points are never updated ^^. 

Link to comment
Share on other sites

7 hours ago, Numa said:

Thanks Nockawa, I've had a look but I'm not really sure how what to replace _v and _m with, in the source code they're only set once, and they're set to:

Canvas2D._v = BABYLON.Vector3.Zero();
Canvas2D._m = BABYLON.Matrix.Identity();

I couldn't find anywhere else where those values are changed, yet the matrix one does change every frame if you rotate the camera hehe.

Is there a public function to access the canvas' matrix ?

I based my code on the Canvas2D.prototype._updateTrackedNodes function, which is of course accessing the private variables.

 

I tried using a single line and updating the array as you suggested and indeed it doesn't work, the points are never updated ^^. 

Yep, the points are not updated and I'm working on it, but I actually have almost no time to code right now... Basically changing the points are changing the ModelKey of your instance (because it need a new set of 3D resources to be rendered) and this is not working well right now...

It's still on the top of my todo list, but I don't know when I'll be able to start working again, next Monday I hope.

What do you call the Canvas' Matrix? For a ScreenSpace canvas you have access to the globalTransformation matrix and for WorldSpace canvas you have to get the matrix from the mesh associated to the canvas (the property name is something like WorldSpaceCanvasNode)

Link to comment
Share on other sites

  • 2 weeks later...
11 hours ago, Numa said:

Hi @Nockawa, any news on this ? :) I tried having a look myself but got very lost in the depth of babylon ^^

If you're too busy is there anyone else around here that could take a look at it, maybe?

thanks so much!

Sorry but I didn't have the time to code since I moved in... :( Well, good news is I'm done with all the stuffs I had to do, bad news (for you) is I'm on a short holidays until next wednesday and I can't dev, but promise I get on this one next wednesday, I'll finally have time to resume my work on bjs and Canvas2D.

Link to comment
Share on other sites

1 minute ago, Nockawa said:

Your issue is the hardest to fix, I have several "simpler" one to deal first to unblock people, I'll try to manager yours asap, I won't wait more than a day to get back on it.

Thanks, no problem :) I'm able to do bunch of other things in the mean time now that I have the opacity property :)

Link to comment
Share on other sites

ooooooh! Beautiful!! I think it's fixed yes! Is it the correct way to get the line ID and dispose + recreate every frame or should I try to update the points dynamically?

Thanks so much man you're a legend! I can't wait to try it

Can I just pull the latest version of babylon off github?

Link to comment
Share on other sites

6 minutes ago, Numa said:

ooooooh! Beautiful!! I think it's fixed yes! Is it the correct way to get the line ID and dispose + recreate every frame or should I try to update the points dynamically?

Thanks so much man you're a legend! I can't wait to try it

Can I just pull the latest version of babylon off github?

I've modified your PG to make it looks like my local test: http://babylonjs-playground.com/#1SASV5#4

You will see that you don't need to dispose (and you shouldn't), just set the new array of Points and it's working.

Yep, the code is in the latest version of the official repo of babylon you can get it there, on the dist/preview folder I guess.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...

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...