Jump to content

(Solved) CreatePolygon DoubleSide No Longer Works


Recommended Posts

After I first pushed the CreatePolygon function and it went live the following this PG http://playground.babylonjs.com/#4G18GY#2 was giving doublesided polygons, now it is only showing one side. Have had a look at my original code in javascript in a preview version of 3.0 and the current version of 3.0 in Javascript. Other than the additions Jerome did for frontUVs etc I cannot see where any changes would affect the doublesidedness. What is worse is that running the current version of 3.0 with a local example and now on a PG  https://www.babylonjs-playground.com/#12X68C I get no mesh at all, but running against the preview version of 3.0 it still works OK.

The preview version I changed to add the polygon code was downloaded on 27 June 2017.

Probably a lot changed since then but hopefully what it was that did it could be found.

Link to comment
Share on other sites

mmhh... very weird, because I didn't touch anything since the frontUVs and backUVs addition, so since a big while

here : https://github.com/BabylonJS/Babylon.js/pull/2212/files   on 1st june

Weirder : I can't see anything in the code of  VertexData._ComputeSides() that would be different for the the Polygon mesh than for the others ... since it's the same called by any double sided mesh.

Link to comment
Share on other sites

Still investigating, now here : https://github.com/BabylonJS/Babylon.js/pull/2232/files

btw, like we can't be sure the normalization computation approximation will give integer numbers, I would rather have written ">0" or "<0" instead of "==1" and "==-1" here :


and here :



or used something like EqualsWithEpsilon()

Link to comment
Share on other sites

10 hours ago, jerome said:

we can't be sure the normalization computation approximation will give integer numbers

Not too worried about this as the PolygonMeshBuilder Build process set integer values for the normals. Though if you tell me it is still better to make the changes to <0 and >0 then I will do so.

Back to original problem

The problem seems to have arisen due to some changes in vertexData. After some time I tracked the discrepancy to the line vertexData.appyToMesh(polygon, options.updatable) up to this point everything is exactly the same, all positions, normals, indices and uvs. It seems that there is a problem using applyToMesh if the mesh already exists.

If I add these lines

polygon = new BABYLON.Mesh(name, scene);


vertexData.applyToMesh(polygon, options.updatable);

then everything works as before.

Checking out what's new I found

New BABYLON.VertexData.ExtractFromMesh function

New BABYLON.VertexData object to easily manipulates vertex attributes

Added mesh.markVerticesDataAsUpdatable() to allow a specific vertexbuffer to become updatable

So the question now is do I simply add the two lines above or should I be doing something with the new vetexData object.

I will wait for an answer to this before marking the topic as solved.

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