AndyBeaulieu Posted June 4, 2017 Share Posted June 4, 2017 Hello, it's been awhile since I've posted here but it's great to be back on a little babylon project! Short version: In this playground test, I would like to have the TOP side of any PolygonMesh to be colored Red, and the other sides Blue (as you can see, it is not correct yet) http://www.babylonjs-playground.com/index2_5.html#Y4KHN8 Longer version: I am using PolygonMeshBuilder to create a Mesh from a set of 2D Vertices. The number of vertices is not known until runtime. I would like to set the TOP side of the extruded mesh to a different material, so I am creating a Multimaterial. But I am struggling with getting the parameters correct when applying the multimaterial to the subMeshes polygonMesh.subMeshes.push(new BABYLON.SubMesh(1, 0, verticesCount, 0, lastTopVertex, polygonMesh)); polygonMesh.subMeshes.push(new BABYLON.SubMesh(0, 1, verticesCount, lastTopVertex, verticesCount + lastTopVertex, polygonMesh)); My fallback plan is to just create a separate Mesh for the Top, but this is bugging me Thanks for any ideas. Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 4, 2017 Share Posted June 4, 2017 A new feature that uses polygonmeshbuilder has just been added called ExtrudePolygon A PR has just been submitted that will allow the top sides and bottom to have different colors or textures using code such as faceColors = []; faceColors[0] = new BABYLON.Color4(1, 0, 0); faceColors[1] = new BABYLON.Color4(0, 0, 1); faceColors[2] = new BABYLON.Color4(0, 1, 0); var polygonMesh = BABYLON.MeshBuilder.ExtrudePolygon("poly", {shape:shape, depth: height, faceColors: faceColors}, scene); Adapting this to your PG gives Unfortunately it might be a couple of days or so before PR goes live in the playground and I can give you working code in the PG. Quote Link to comment Share on other sites More sharing options...
AndyBeaulieu Posted June 4, 2017 Author Share Posted June 4, 2017 Nice! Thanks for the quick reply. For now I'll use a second mesh, and revisit this when the PR is in. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 4, 2017 Share Posted June 4, 2017 It's goo to see you back!! PR is merged and deployed (thanks @JohnK) Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 5, 2017 Share Posted June 5, 2017 Thanks to quick action by DK here is the PG http://www.babylonjs-playground.com/index.html#Y4KHN8#2 Note it is using version 3.0 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.