text: [{"Owner":"JohnK","Date":"2015-10-06T14:14:47Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_This is probably one for @Jerome but others will have more idea than I do anyway._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Have been playing with the Rhombicuboctahedron and trying to place the same image on each face. (Starting with one image rather than an image atlas as thought it would be easier)._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Pinching bits and pieces from here and there from BABYLON.js max I created this _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C_qt_ rel_eq__qt_external nofollow_qt__gt_playground_lt_/a_gt_._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_As you can see I got in a bit of a mess - something to do with having the uvs in the wrong order probably._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Any help gratefully received._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Jerome should you want to answer this one then I know you have a long backlog of things to do so no rush - just interested nothing vital._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-06T14:40:46Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Well_lt_/p_gt__lt_p_gt_This polyhedron has different polygonal shapes for faces (triangles and squares_co_ if I_t_m not wrong)_co_ so you can_t_t have only one _qt_rule_qt_ (ie uvs declaration) working for all these polygons._lt_/p_gt__lt_p_gt_Moreover you had to convert the mesh to a flat shaded one_co_ what is a good thing to add vertices (*) if you want the same image on each face (it can_t_t really be the same as we have squares and triangles !) and this conversion applied after you set the uvs. I guess the new vertices don_t_t hold any uvs at all._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_(*) you can_t_t _qt_copy_qt_ the same image on different faces if the vertices are common to several faces._lt_/p_gt__lt_p_gt_1 vertex &lt_sm__eq_&gt_sm_ 1 uv_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So if the vertex belongs to 2 facets_co_ it can_t_t hold the image coordinates for facet1 and the image coordinates for facet2 in the same time._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_It_t_s really hard to do._lt_/p_gt__lt_p_gt_You would have to _dd__lt_/p_gt__lt_p_gt_- define the uvs for the facet composing a triangle_lt_/p_gt__lt_p_gt_- define the uvs for the pair of facets composing a square_lt_/p_gt__lt_p_gt_- iterate on every vertex and guessing if it is a part of a triangle or a square (to choose what definition to use) and where it is on the square or the triangle_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C%231_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1H7L5C#1_lt_/a_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-07T08:45:20Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_@Jerome in my simple minded way I thought I had some of the points you mentioned covered_co_ though obviously not because it didn_t_t work. I_t_ll describe my thinking and perhaps if you have time you could pinpoint my errors and then I can have another go._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I did try to deal with the fact that there are triangular and square faces and expected the triangular ones possibly not to work but was going to deal with that later provided the square faces worked (but didn_t_t)._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I looked at your Babylon.js/src/Mesh/babylon.mesh.vertexData.ts file and saw on lines 6387 to 657 that for each face a uv pair was pushed for each vertex of the face._lt_strong_gt_ _lt_/strong_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So with one image my Vector4 of uvs would be [0_co_0_co_1_co_1] equivalent to you faceUV[index] with index always 0._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So in the playground  I set up my uv pairs as (line 33)_lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_var face_uvs_eq_[[0_co_0]_co_[1_co_0]_co_[1_co_1]_co_[0_co_1]]_sm__lt_/pre_gt__lt_p_gt_then in lines 42 - 44 for each of the faces in the Rhombicuboctahedron the length of data.face[f] gives the number of vertices so_lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_for(var j _eq_ 0_sm_ j &lt_sm_ data.face[f].length_sm_ j++) {    uvs_eq_uvs.concat(face_uvs[j])_sm_}_lt_/pre_gt__lt_p_gt_pushes a uv pair in order to uvs  -- uvs_eq_uvs.concat(face_uvs[j]) being I hope the same as uvs.push(face_uvs[j][0]_co_face_uvs[j][1])_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_This appears to set the uv for each vertex of each face whether the face has 3 sides or 4 sides_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_As much as I want it to and it looks like it should it obviously does not cover your points_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_blockquote data-ipsquote_eq__qt__qt_ class_eq__qt_ipsQuote_qt__gt__lt_div_gt_1 vertex &lt_sm__eq_&gt_sm_ 1 uv_lt_/div_gt__lt_/blockquote_gt__lt_p_gt_ _lt_/p_gt__lt_blockquote data-ipsquote_eq__qt__qt_ class_eq__qt_ipsQuote_qt__gt__lt_div_gt__lt_p_gt_- define the uvs for the facet composing a triangle_lt_/p_gt__lt_p_gt_- define the uvs for the pair of facets composing a square_lt_/p_gt__lt_p_gt_- iterate on every vertex and guessing if it is a part of a triangle or a square (to choose what definition to use) and where it is on the square or the triangle_lt_/p_gt__lt_/div_gt__lt_/blockquote_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_What is wrong with my reasoning?_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Does either of BABYLON.VertexData.ComputeNormals or  BABYLON.VertexData._ComputeSides change the order in which vertices are considered and so throw out the match I created between face vertices and the uvs?_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Am I just completely wrong?_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-07T09:28:46Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt__lt_em_gt_computeNormals_lt_/em_gt_ only sets the _lt_em_gt_normals_lt_/em_gt_ array_lt_/p_gt__lt_p_gt__lt_em_gt_computeSides_lt_/em_gt_ can change the number of vertices (so the number of indices and uvs also) and/or the indices order... unless if you choose FRONTSIDE or DEFAULTSIDE _dd_ these don_t_t change anything._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So for your case_co_ you can forget these two functions_co_ they don_t_t modify anything._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_em_gt_convertToFlatShaded_lt_/em_gt_ can/will add vertices to your geometry !_lt_/p_gt__lt_p_gt_So you set uvs to the initial polyhedron vertices and then add new ones. The problem is that we don_t_t know where they are added unless we hack this method seriously._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Let_t_s imagine we don_t_t use it now._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_As I can remember the array _lt_em_gt_data.face_lt_/em_gt__lt_em_gt_ is filled with the indices of the _lt_/em_gt__lt_em_gt__lt_em_gt_i-th_lt_/em_gt__lt_/em_gt__lt_em_gt_ facet_co_ so 3 vertices per array. This means you should assign 3 pairs of uvs par _lt_/em_gt__lt_em_gt__lt_em_gt_data.face_lt_/em_gt__lt_/em_gt__lt_em_gt__co_ not 4._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_This is the principle _dd_ a UV pair per vertex only_lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_Note well you won_t_t achieve the goal you want because we have here quite all vertices that are common to many faces. (not easy to explain this in english for me_co_ sorry)_lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_ _lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_It was easy for me to set the uvs on a box because a box has exactly 6 similar faces in term of geometry (2 facets by face_co_ always ordered the same known way) and no vertex was common to two different box faces._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_In short _dd_ I knew the geometry and the faces were all independant._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_ _lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_It_t_s really hard to do with these polyhedrons if you want the same image on each face._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_ _lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_We should first make sure that each facet doesn_t_t share its vertice with another one (what convertToFladShaded seems to do)_co_ else impossible to apply the same image on each face._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_Then we should understand the geometry _dd_ where are the vertices of each face_co_ in this face _dd_ the ones related to the others. No way to set correct uvs without this piece of information._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_Finally we would code the algo to assign the right uvs to the right vertices regarding the former two points._lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_ _lt_/em_gt__lt_/p_gt__lt_p_gt__lt_em_gt_I guess it_t_s easier to fold an image around the whole polyhedron_lt_/em_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"dbawel","Date":"2015-10-07T23:15:54Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Hi John K_co__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I didn_t_t thoroughly read every line in this post_co_ but I get the gest of what you_t_re trying to do.  If it were me_co_ I might try using multi materials_co_ as you will be able to assign a different material to each set of UVs representing a face on your _lt_span style_eq__qt_color_dd_rgb(40_co_40_co_40)_sm_font-family_dd_helvetica_co_ arial_co_ sans-serif_sm__qt__gt_Rhombicuboctahedron.  And this could be done proceedurally so that a different material is automatically pushed to the UVs which define each face on the mesh limiting (optimizing) the amount of lines of code required._lt_/span_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_span style_eq__qt_color_dd_rgb(40_co_40_co_40)_sm_font-family_dd_helvetica_co_ arial_co_ sans-serif_sm__qt__gt_But are you simply trying to torture yourself_co_ or do you actually have a scene in mind where this might be used.  For me_co_ it would be a method of torture.  It almost is just thinking about it.  _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_blink.png_qt_ alt_eq__qt__dd_blink_dd__qt__gt__lt_/span_gt__lt_span style_eq__qt_color_dd_rgb(40_co_40_co_40)_sm_font-family_dd_helvetica_co_ arial_co_ sans-serif_sm__qt__gt_ _lt_/span_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_span style_eq__qt_color_dd_rgb(40_co_40_co_40)_sm_font-family_dd_helvetica_co_ arial_co_ sans-serif_sm__qt__gt_DB_lt_/span_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-08T08:27:15Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_DB as a retired maths teacher occasionally I like to give my maths brain a workout - torture for some pleasure for others_co_ currently this is a mixture of both._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"dbawel","Date":"2015-10-08T11:02:44Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Check out this blog 9tutorial) written by DeltaKosh on applying Multi-Materials.  You might find this useful._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_a href_eq__qt_http_dd_//blogs.msdn.com/b/eternalcoding/archive/2013/07/10/babylon-js-using-multi-materials.aspx_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//blogs.msdn.com/b/eternalcoding/archive/2013/07/10/babylon-js-using-multi-materials.aspx_lt_/a_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_DB_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-08T11:52:21Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_\n\tDB I just like the way Jerome applied texture in the new Createxxx method applied to CreateBox. Will get round to multi-materials when I am exhausted from this method. Thank you for the support.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\t@Jerome understanding is growing. I used the playground to create two Cubes_co_ one uses your CreatePolyhedron method and one the new CreateBox method. Checking the VertexData for both shows the difference.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tIn the CreateBox method there are 24 positions and 24 normals_co_ since each of the 8 vertices is listed 3 times_sm_ once for each face it belongs to and each of the 6 normals (one per face) is listed 4 times once for each vertex on that face. The UVs are also listed 24 times each one matched in 1-1 correspondence with the positions.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tIn the CreatePolyhedron method there are 8 positions and 8 normals one for each of the 8 vertices. The normals are now not normal to a face but are formed from the 3 face normals at each vertex. This method of storing the VertexData is more efficient since it uses a third less memory but does not contain sufficient data for the uvs to be applied.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\t_lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C%2329_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1H7L5C#29_lt_/a_gt_ shows the two cubes and the normals at the vertices. The lower one is made using the CreateBox method and all faces contain the image in a proper way.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tInterestingly the use of .convertToFlatShadedMesh()_sm_ produces 36 positions since it creates two facets per face and then 4 vertices belong to 6 facets and 4 vertices belong to 4 facets and there are 36 normals. The UV array also has 36 entries but I presume they do not now match correctly the positions.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tRemove the comment from line 70 in the playground above and see the difference.\n_lt_/p_gt_\n\n_lt_p_gt_\n\t \n_lt_/p_gt_\n\n_lt_p_gt_\n\tSo perhaps if I can just work out which uv goes with which position I might get somewhere.\n_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-08T12:32:15Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Waaoww... When I said it was hard for me to explain all of this in english !_lt_/p_gt__lt_p_gt_You found out everything I wanted to tell you by yourself _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt_  Very good study !_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So you understand now why you can_t_t reproduce the same image on each box side if its vertices belong to many faces at the same time._lt_/p_gt__lt_p_gt_And why you can_t_t set all the UV at mesh creation if you convert it to a flat shaded one just after (vertices added after)._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Actually_co_ you need to have these extra vertices to hold the image-per-face uvs._lt_/p_gt__lt_p_gt_So_co_ two options _dd__lt_/p_gt__lt_p_gt_#1 _dd_ you create the mesh as you did formerly_co_ you convert it to a flat shaded one_co_ then you try to retrieve all the new vertices and how they are related in order to the initial to set the UVs. Not that simple._lt_/p_gt__lt_p_gt_#2 _dd_ you change the way the mesh is created _dd_ instead of re-using some vertices_co_ you add new ones when building the _lt_em_gt_positions_lt_/em_gt_ and _lt_em_gt_indices_lt_/em_gt_ array._lt_/p_gt__lt_p_gt_In this case_co_ you know exactly where all your vertices are and how they are linked._lt_/p_gt__lt_p_gt_And it_t_s quite easy to do _dd_ when a vertex is yet used in the _lt_em_gt_faces_lt_/em_gt_ array_co_ just create a new one with the same values and reference it instead._lt_/p_gt__lt_p_gt_In brief_co_ to construct the geometry of each polyhedron like the current BJS box._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I personally prefer the second method._lt_/p_gt__lt_p_gt_I think I will implement it in the future _lt_em_gt_CreatePolyhedron_lt_/em_gt_ method because the way the normals are computed with _lt_em_gt_computeNormals()_lt_/em_gt_ on common vertices will get to many light artifacts on these kinds of meshes _dd_ many edges_co_ many vertices_co_ many flat planar sides_co_ angles lower than 120° ... so many bad candidates for the magic normal computation._lt_/p_gt__lt_p_gt_That_t_s also why I converted all of them into flat shaded ones in the PG example._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-10T09:04:29Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Managed it at last._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Rhombicuboctahedron  with one image used on each face _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C%2313_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1H7L5C#13_lt_/a_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Rhombicuboctahedron  with spriteatlas and one sprite used per face _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C%2312_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1H7L5C#12_lt_/a_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-10T10:31:24Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Waaaaowww  _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt__lt_p_gt_Excellent work._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I guess you did (so fast) what I intended to do for the upcoming _lt_em_gt_CreatePolyhedron(_lt_/em_gt_) method._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Congratulations !  _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_really really good work._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-10T11:00:28Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Still needs some work will fail if any polyhedra has a face with more than 4 sides and faceUV not consistent with yours_co_ is array of array not array of Vector4. So still some way to go for a general CreatePolyhedron_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-11T06:33:51Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_I had a look at your code._lt_/p_gt__lt_p_gt_So you don_t_t re-use the vertices and create new positions what is_co_ imho_co_ the right thing to do._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I can see also that you compute your own normals and check on what plane side they should be set for each facet. Usually_co_ the vertices are rightly ordered in the _lt_em_gt_face_lt_/em_gt_ array by the developer to create all the facets oriented the same way_co_ so this check isn_t_t necessary. Maybe it_t_s not the case with this JSON file... I don_t_t know._lt_/p_gt__lt_p_gt_If they are_co_ you don_t_t need to reimplement your own normal computation in this case_co_ _lt_em_gt_ComputeNormals()_lt_/em_gt_ will do the job as expected because you only create independant planar polygons._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Your algo may work with any polyhedrons imho for the positions/indices aspect. I would have done the same_co_ with _lt_em_gt_ComputeNormals() _lt_/em_gt_so far._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_For the UV per side_co_ my lead is _dd__lt_/p_gt__lt_p_gt_A texture is a rectangle_co_ ok ?  or a square... it is to say a 4-side polygon_lt_/p_gt__lt_p_gt_The sides of a polyhedron are polygons. We can even assume they are quite regular polygons _dd_triangles_co_ rectangles/squares_co_ pentagons_co_ hexagons_co_ etc_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So except for a triangle or a rectangle polygon (polyhedron sides) which can directly fit into a rectangle texture_co_ I would consider the circle _lt_strong_gt_within_lt_/strong_gt_ the square texture and set the (face) polygon on this circle (circumcircle) to compute the UV._lt_/p_gt__lt_p_gt_Not easy to explain in english once more ..._lt_/p_gt__lt_p_gt_But have a look please at how the UVs are set in _lt_em_gt_CreateDisc()_lt_/em_gt_ (this is actually a createPolygon) _dd_ _lt_a href_eq__qt_https_dd_//github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L1288_qt_ rel_eq__qt_external nofollow_qt__gt_https_dd_//github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L1288_lt_/a_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-11T08:48:31Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_I guess I will try next week to implement in BJS something  like _dd__lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_CreatePolyhedron(name_co_ {type_dd_ polyhedronType_co_ size_dd_ number_co_ custom_dd_ polygonObject}_co_ scene)_sm__lt_/pre_gt__lt_p_gt__lt_em_gt_polyhedronType_lt_/em_gt_ will be one of the few polyhedrons provided in the core. Few only (tatrehedrons_co_ etc) because we don_t_t want too much code in the core._lt_/p_gt__lt_p_gt_If _lt_em_gt_polyhedronType_lt_/em_gt_ is undefined_co_ then a custom polyhedron object will be expected. These objects will be provided in an extension library_co_ easy to use _dd_ just copy/paste the needed variable in your code._lt_/p_gt__lt_p_gt_Example _dd__lt_/p_gt__lt_p_gt_copy this line from the lib your code _dd__lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_var cubo _eq_ {_qt_name_qt__dd__qt_Cuboctahedron_qt__co__qt_category_qt__dd_[_qt_Archimedean Solid_qt_]_co__qt_vertex_qt__dd_[[0_co_0_co_1.154701]_co_[1_co_0_co_0.5773503]_co_[0.3333333_co_0.942809_co_0.5773503]_co_[-1_co_0_co_0.5773503]_co_[-0.3333333_co_-0.942809_co_0.5773503]_co_[1_co_0_co_-0.5773503]_co_[0.6666667_co_-0.942809_co_0]_co_[-0.6666667_co_0.942809_co_0]_co_[0.3333333_co_0.942809_co_-0.5773503]_co_[-1_co_0_co_-0.5773503]_co_[-0.3333333_co_-0.942809_co_-0.5773503]_co_[0_co_0_co_-1.154701]]_co__qt_edge_qt__dd_[[0_co_1]_co_[1_co_2]_co_[2_co_0]_co_[0_co_3]_co_[3_co_4]_co_[4_co_0]_co_[1_co_6]_co_[6_co_5]_co_[5_co_1]_co_[2_co_8]_co_[8_co_7]_co_[7_co_2]_co_[3_co_7]_co_[7_co_9]_co_[9_co_3]_co_[4_co_10]_co_[10_co_6]_co_[6_co_4]_co_[5_co_11]_co_[11_co_8]_co_[8_co_5]_co_[9_co_11]_co_[11_co_10]_co_[10_co_9]]_co__qt_face_qt__dd_[[0_co_1_co_2]_co_[0_co_3_co_4]_co_[1_co_6_co_5]_co_[2_co_8_co_7]_co_[3_co_7_co_9]_co_[4_co_10_co_6]_co_[5_co_11_co_8]_co_[9_co_11_co_10]_co_[0_co_2_co_7_co_3]_co_[0_co_4_co_6_co_1]_co_[1_co_5_co_8_co_2]_co_[3_co_9_co_10_co_4]_co_[5_co_6_co_10_co_11]_co_[7_co_8_co_11_co_9]]}_sm__lt_/pre_gt__lt_p_gt_then _dd__lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_CreatePolyhedron(name_co_ {custom_dd_ cubo}_co_ scene)_sm__lt_/pre_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-11T18:22:40Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Thanks for you advice_co_ have replaced my normals code with _lt_em_gt_computeNormals. _lt_/em_gt_In the end I did not use the _lt_em_gt_CreateDisc_lt_/em_gt_ idea for the uvs since I needed to find the middle for each face and it gave one more position per face._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_My triangles for the uvs all start from one vertex of the polygon face and go to the non-adjacent ones in turn. Having calculated the first vertex I rotate this round the polygon to get the positions of the others and then translate and scale._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Results_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#1H7L5C%2318_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#1H7L5C#18_lt_/a_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt__lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#21QRSK%233_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#21QRSK#3_lt_/a_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_What I am considering next is setting up an array spriteNum _eq_[] and then put face numbers in the array and use something like_lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_spriteRow _eq_ spriteNum[f] % hSpriteNb_sm_spriteColumn _eq_ Math.floor(spriteNum[f] / hSpriteNb)_sm_ _lt_/pre_gt__lt_p_gt_I_t_ll look forward to your _lt_span_gt_CreatePolyhedron_lt_/span_gt__lt_/p_gt__lt_p_gt_                  _lt_br_gt_  _lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-11T18:59:55Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Really nice  _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_The middle of each face is quite easy to compute _dd_ barycenter._lt_/p_gt__lt_p_gt_You just need the middle _lt_u_gt_location_lt_/u_gt_ to compute then the location of each vertex of the polygon_co_ as you need with your own rotation._lt_/p_gt__lt_p_gt_I don_t_t think that you need to add this middle point to the _lt_em_gt_positions_lt_/em_gt_ array _dd_ all you want to get is the 2D coordinates of your (face) polygon vertices on your texture._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_The circumcircle method is easy (probably not the most optimized in terms of texture surface cropping) if you have to deal with polygons with more than 4 sides_co_ what is not your case if you want to keep indeed your code dedicated to this kind of polyhedrons having only triangular and squared faces._lt_/p_gt__lt_p_gt_This was just a suggestion in order to generalize the code to any polyhedron types._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I like a lot the 126 samples with the sprites  _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_wink.png_qt_ alt_eq__qt__sm_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/wink@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-12T09:53:44Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Please forget what I said about the barycenter. Your technique works obviously by rotating in turn from a starting point !_lt_/p_gt__lt_p_gt_I didn_t_t read it well yesterday._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_Actually_co_ I just did the same in _lt_em_gt_CreateDisc()_lt_/em_gt_ but with another rotation because of a different _lt_em_gt_indices_lt_/em_gt_ order._lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_I like yours_co_ I will borrow (steal) it for the CreatePolygon implementation _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_wink.png_qt_ alt_eq__qt__sm_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/wink@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-12T12:51:02Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Steal away. _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_biggrin.png_qt_ alt_eq__qt__dd_D_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/biggrin@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-12T13:25:20Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_thank you_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_So I borrowed a part of you code_co_ injected it in my original code (which was yet a port from Stemkosky_t_s one in threejs) and cleaned up everything._lt_/p_gt__lt_p_gt__lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#21QRSK%234_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#21QRSK#4_lt_/a_gt__lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_(switch the editor off to display the names)_lt_/p_gt__lt_p_gt_ _lt_/p_gt__lt_p_gt_The main program starts from the line 126._lt_/p_gt__lt_p_gt_It_t_s not TS for now (ported very soon)_co_ but a quite achieved JS draft._lt_/p_gt__lt_p_gt_The signature is _dd__lt_/p_gt__lt_pre class_eq__qt_ipsCode prettyprint_qt__gt_CreatePolyhedron(_qt_name_qt__co_ options_co_ scene)_sm__lt_/pre_gt__lt_p_gt_details of the option properties (all optional) _dd__lt_/p_gt__lt_ul_gt__lt_li_gt_type _dd_ not implemented yet_co_ will be one of the polyhedron type provided in the core. This will be documented._lt_/li_gt__lt_li_gt_custom_dd_ an expected polyhedron object if you want another type than the core ones_co_ a copied/pasted variable from a extension file that will be online_lt_/li_gt__lt_li_gt_size_dd_ no need to explain_lt_/li_gt__lt_li_gt_sizeX_dd_ the same only on X_lt_/li_gt__lt_li_gt_sizeY_dd_ only on Y_lt_/li_gt__lt_li_gt_sizeZ_dd_ only on Z_lt_/li_gt__lt_li_gt_faceUV_dd_ array(nbfaces) the same as for CreateBox _eq_&gt_sm_ set your own image per face_lt_/li_gt__lt_li_gt_faceColors_dd_ array(nbfaces) the same as for CreateBox _eq_&gt_sm_ set your own color per face_co_ as you can see in the example_lt_/li_gt__lt_/ul_gt__lt_p_gt_Same example with faceUV _dd_ _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#21QRSK%235_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#21QRSK#5_lt_/a_gt__lt_/p_gt__lt_p_gt_Both (colors and faceUV) _dd_ _lt_a href_eq__qt_http_dd_//www.babylonjs-playground.com/#21QRSK%236_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//www.babylonjs-playground.com/#21QRSK#6_lt_/a_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JohnK","Date":"2015-10-12T13:51:40Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_Brilliant piece of tidying up and consistantising (new word just made it up - hope it doesn_t_t catch on _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt_ )  Go Team JJ_lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-12T14:09:36Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_ _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_biggrin.png_qt_ alt_eq__qt__dd_D_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/biggrin@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt__lt_p_gt_Now_co_ I still have to make the (hard) choice of what polyhedron type to include in the core and what type to keep apart._lt_/p_gt__lt_p_gt_I will lighten the big JSON file also by removing all the data relative to the edges as we don_t_t need them._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"Deltakosh","Date":"2015-10-12T15:30:49Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_I_t_m only for those with a name like tyranosodron or toolongnamedron _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_smile.png_qt_ alt_eq__qt__dd_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/smile@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"JCPalmer","Date":"2015-10-12T15:35:46Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_The ones that you break out into the extension_co_ I really hope that they are their _lt_strong_gt_OWN _lt_/strong_gt_mesh subclass.  BTW_co_ do you have one that sort of looks like it could be a mesh proxy for a bone?  See_co_ _lt_a href_eq__qt_http_dd_//wiki.blender.org/uploads/7/73/Manual-Part-I-Quick51.2.56.png_qt_ rel_eq__qt_external nofollow_qt__gt_http_dd_//wiki.blender.org/uploads/7/73/Manual-Part-I-Quick51.2.56.png_lt_/a_gt_  I know bones do not have a length_co_ well in BJS anyway _lt_img src_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/default_wink.png_qt_ alt_eq__qt__sm_)_qt_ srcset_eq__qt_http_dd_//www.html5gamedevs.com/uploads/emoticons/wink@2x.png 2x_qt_ width_eq__qt_20_qt_ height_eq__qt_20_qt__gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-13T07:43:58Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_started to port it to the core ..._lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"},{"Owner":"jerome","Date":"2015-10-13T09:35:03Z","Content":"_lt_div class_eq__qt_mages_qt__gt_\n\t\t\t\n_lt_p_gt_here is it _dd_ _lt_a href_eq__qt_http_dd_//www.html5gamedevs.com/topic/17342-polyhedrons-first-attemp/?p_eq_100654_qt__gt_http_dd_//www.html5gamedevs.com/topic/17342-polyhedrons-first-attemp/?p_eq_100654_lt_/a_gt__lt_/p_gt_\n\n\n\t\t\t\n\t\t_lt_/div_gt_\n\n\t\t_lt_div class_eq__qt_ipsI_qt__gt__lt_/div_gt__lt_/div_gt_"}]