Search the Community
Showing results for tags 'doubleside'.
-
solved Is there a way to make custom mesh doublesided?
logunov posted a topic in Questions & Answers
Good day everyone. I am now works on my own huge project, which uses a lot of mathematical models. So, the problem is ,I have mathematical model of hexasphere from there https://github.com/arscan/hexasphere.js/blob/master/src/face.js And I need to create meshes from vertex data of this model. I'm using this: //hexaSphere - is object, created with library upper for (let i = 0; i < hexaSphere.tiles.length; i++) { let centerpoint = data.centerPoint; let x = centerpoint.x; let y = centerpoint.y; let z = centerpoint.z; let spawnVec = new BABYLON.Vector3(x, y, z); //here I should instantiace center of vector let buildPoints = []; for (let j = 0; j<data.boundary.length; j++){ let x = data.boundary[j].x; let y = data.boundary[j].y; let z = data.boundary[j].z; let point = new BABYLON.Vector3(parseFloat(x), parseFloat(y), parseFloat(z)); buildPoints.push(point); } let polygonalMesh = new BABYLON.MeshBuilder.CreatePolygon(""+i, {shape:buildPoints}, scene); } So, the result of this is (please, do not look on colored spheres and sticks, It was hard to remove from my project because of bad architecture, they are do not touching this part of code, it is isolated): It is not 3D, but 2D projections of each hexagon or pentagon to the XoZ BABYLON plane. I started to think about position, as "How to" said, but polygonalMesh.position = spawnVec; give me that result: How can I create meshes from vertices data in 3D space? I just can not test rotation, because if it's correct, it can be visible to match each other borders of morphed meshes. There is no way to use loaded mesh, because each of hexagon is different. This mathematical model do not use right hexagons, because it is hard co connect (mathematical theorem). And I am sure this library is correct, because I tested it with right hexagon (imported mesh with babylon-loaders.js, created it on blender) and tried to match each other rotation, so I got next result (green dots is rotation co-surface normales, do not look on them): And everything with math was fine: blue dots is 2 of 6 or 5 border points, red is centerPoints. I do not have right now screen of whole sphere, but it was sphere, not was MeshBuilder created. I just putted a copy of IMPORTED model on each center and rotated it with some linear algebra to check everything, before post here. So, my question is: how can I create polygonal mesh in 3D space, not his 2D projection, using BABYLON.MeshBuilder (or other BABYLON solution), because displacement of right hexagons and this mathematical model is too huge for acceptance (impossible to play, looks ugle and other), so I need dynamical creation. p.s There is impossible to create lovely playground example, because of library, but http://playground.babylonjs.com/#4G18GY#67 have the same problem. In arguments of array have all 3D spaces, but it is creating just 2D projection.- 13 replies
-
- dynamically creating mesh
- doubleside
- (and 6 more)
-
solved (Solved) CreatePolygon DoubleSide No Longer Works
JohnK posted a topic in Questions & Answers
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. -
In trying to create a PG to solve another topic I came across the strange phenomenon (well it might not be strange just not what I expected) Having used MeshBuilder to create some small boxes and big box to fit them in I decided to make the box lidless by making the top transparent. Did this by setting a faceColor for the top face as faceColors[4] = new BABYLON.Color4(0,0,0,0); and realised that I then needed to set hasVertexAlpha to be true for the bigbox. http://www.babylonjs-playground.com/#1KH9RY#6 but the the rear and side faces disappear depending on camera angle. Ahah a moment of inspiration, I needed to make the sideOrientation DOUBLESIDE but then the front side disappeared. To check what was happening I made the rear face red faceColors[0] = new BABYLON.Color4(1,0,0,1); As you rotate the box so that you can view towards the rear red face, the red face disappears but the redness is applied to the inner small boxes (or so it appears) STRANGE http://www.babylonjs-playground.com/#1KH9RY#4 Any explanations, corrections, advice very welcome perhaps one for @jerome
- 2 replies
-
- meshbuilder
- hasvertexalpha
-
(and 1 more)
Tagged with: