Search the Community
Showing results for tags 'meshbuilder.createpolygon'.
-
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)