Statics Posted August 25, 2015 Share Posted August 25, 2015 Hi, I'm trying to build a project to show internal forces in a truss. However, after I click the box, if I zoom in or change view points the lines will disappear as soon as all the cylinders are no longer shown. http://www.babylonjs-playground.com/#PDWUQ#1 I'm not quite sure why this is happening, any ideas? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 26, 2015 Share Posted August 26, 2015 Hi Statics, good to see you again. I think this is caused by a type of z-fighting between inactive/null Lines (Lines set to draw from 0,0,0 to 0,0,0)... and active Lines. You actually have 10 Lines in the scene after the button press (box click). You have 3 active Lines and 7 null-Lines. Keep in mind that BJS adds mesh to the scene as soon as it is created. So... lines 70-77 put five null-LINES into the scene... even if you DO re-define their variable names in the executeCodeAction. Those 5 null-Lines are in the scene, even if they are set to draw from origin to origin (from 0,0,0 to 0,0,0). It makes no sense that they are z-fighting because the null-lines are not in the same position as the active lines. All z-fighting I have seen... was due to one mesh being atop another, position-wise. Your null-Lines are not positioned atop your active Lines (Or maybe the are! See my retarded theory further below). All in all, removing the null-Lines seems to have improved things. http://www.babylonjs-playground.com/#PDWUQ#2 - Here I have remarked-out the code-lines 70-77, and it seems to be working much better. Now your box click produces 5 Lines, 3 are positioned and 2 are null. Generally speaking, I would avoid making null Lines (Lines between 0,0,0 and 0,0,0). They seem to be getting in the way of the active Lines. Speaking-of "getting in the way", here is a theory. ALL Lines... are probably positioned at 0,0,0... no matter where they stride FROM/TO. They probably use vertexData to set the positioning of the Line. This same-positioning could cause a z-fighting phenomena, regarding null-Lines. But, more likely, there is an issue with depthRendering, here. The null-Lines are actually blocking the active Lines... from view. No z-fighting. Actually, z-ordering. The world famous hidden line algorithm (determining what is visible in a scene and what is hidden)... has come to haunt you. Avoid null-Lines is my advice. Hope this helps. If not, we'll keep experimenting and talking about it... because you made us this cool playground where we could easily see the issue. Well done. You have a good looking truss, an interesting subject-matter, and a fine start to your structural stress visualizer. Keep us posted. Statics 1 Quote Link to comment Share on other sites More sharing options...
Statics Posted August 26, 2015 Author Share Posted August 26, 2015 Thanks for the help, and for the nice comments. I'm going to continue experimenting with this today and hopefully complete it. I'll keep in mind what you said about null-Lines and I'll let you know how everything goes. I may just predefine the lines and have them change visibility like I do for all of the trusses, unfortunately this will just mean more lines of code Quote Link to comment Share on other sites More sharing options...
Statics Posted August 26, 2015 Author Share Posted August 26, 2015 here is the finished product, a bit more lines of code than I wanted, but there are some ways I can slim it down if I want. http://www.babylonjs-playground.com/#PDWUQ#4 iiceman, GameMonetize and Wingnut 3 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.