Dad72 Posted November 13, 2015 Share Posted November 13, 2015 Hi, I create a ViewCube to inform the view of the window (front, back, top, bottom, left, right). I apply a dynamic texture with a multimaterial. I used an orthographic camera to display the cube in the upper right hand corner with a layerMask. so far, all are well. But I have some difficulty for submeshes portion of the cube that I do not fully understand. this:viewcube.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 4, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 4, 8, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(2, 0, verticesCount, 8, 12, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(3, 0, verticesCount, 12, 16, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(4, 0, verticesCount, 16, 20, viewcube));viewcube.subMeshes.push(new BABYLON.SubMesh(5, 0, verticesCount, 20, 24, viewcube));Could you help me please you. I create the sample on the playground to reproduce what I have done so far. http://www.babylonjs-playground.com/#1Z5260 Thanks for help Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 13, 2015 Share Posted November 13, 2015 Hey dad, is that the expected result? http://www.babylonjs-playground.com/#1Z5260#1 I think the vertices count on each side is 6 instead of 4, because it uses triangles and they don't really share their vertices (not sure why they don't, though). viewcube.subMeshes.push(new BABYLON.SubMesh(0, 0, verticesCount, 0, 6, viewcube)); viewcube.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 6, 12, viewcube)); viewcube.subMeshes.push(new BABYLON.SubMesh(2, 0, verticesCount, 12, 18, viewcube)); viewcube.subMeshes.push(new BABYLON.SubMesh(3, 0, verticesCount, 18, 24, viewcube)); viewcube.subMeshes.push(new BABYLON.SubMesh(4, 0, verticesCount, 24, 30, viewcube)); viewcube.subMeshes.push(new BABYLON.SubMesh(5, 0, verticesCount, 30, 36, viewcube));Let me know if that was what you need or if I misunderstood you somehow Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 13, 2015 Author Share Posted November 13, 2015 Thank you iiceman. Yes it's almost that. - The textures is not well placed.- missing face bottom- some texture are upside down (upside down) I do not know how to reverse I made some arrangement but texture left is to right, left and above. http://www.babylonjs-playground.com/#1Z5260#4 Thank you for help. Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 14, 2015 Share Posted November 14, 2015 Hmm, I think I confused something there.... the 5th paramerter should always be the indexCount, so not the end index but the number of how many indices belong to that submesh... so in your case I assume it should always be 4. The stuff I said about 6 vertices is probably nonsense I figured I was imaginening something wrong when I looked at the total verticesCount, which is 24.... what makes total sense for a cube... 6 sides with 4 vertices each... but somehow I didn't get it to work yet... maybe it's too late and I just don't see what's going on anymore. Just for the sake of completeness my failed attempt: http://www.babylonjs-playground.com/#1Z5260#5 EDIT: There http://www.babylonjs-playground.com/#1Z5260#6 all faces... it is 6 vertices per side of the cube... and the 5th parameter in this case should always be 6 then. Now I just can't comprehend why the verciesCount is 24 :-" ... I guess I better go to sleep! Maybe as an alternative you can use this create box per face texture thing somehow?http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors EDIT2: About the positioning... if you leave the x coordinate for writing the text null it gets centered: http://www.babylonjs-playground.com/#1Z5260#7 But I fear I can't tell you how the avoid that upside down back face. Maybe somebody else has a hint. Dad72 and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 14, 2015 Author Share Posted November 14, 2015 Thank you very much for your time iiceman. your edit2 seems to me very well.I will try to seek to turn the textures in the right direction. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 14, 2015 Author Share Posted November 14, 2015 I managed to recover each texture in the right direction. http://www.babylonjs-playground.com/#1Z5260#9 But I still have one last problem, how to detect clicks on each side of the cube. for example, if I click on the left side, I want to present this as my camera to left.So we can know which side was click? Thank you Quote Link to comment Share on other sites More sharing options...
iiceman Posted November 14, 2015 Share Posted November 14, 2015 You can get the face id from the picking info. Each side of the cube consists of two faces, so you should be able to easily map the face id to a certain side, I think Quote Link to comment Share on other sites More sharing options...
Dad72 Posted November 14, 2015 Author Share Posted November 14, 2015 I'm going to try. thank you Iiceman 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.