Is there subMesh like unity engine in three.js?

s there subMesh like unity engine in three.js?

//unity code

                    mesh.vertices = meshVertices;
			mesh.subMeshCount = 2;//what's related to  three.js ?
			mesh.SetTriangles( meshTriangles, 0 );//what's related to  three.js ?
			mesh.SetTriangles( meshJoinsTriangles, 1 );//what's related to  three.js ?
			mesh.SetUVs( 0, meshUv0 );
			mesh.SetUVs( 1, meshUv1Prevs );
			mesh.SetUVs( 2, meshUv2Nexts );

is there some funjction like that ?

I can’t really tell what this unity code is doing, but probably the closest thing in three.js is BufferGeometry .groups. The idea is that you assign different ranges of your vertices or indices to different groups. Each group can be associated with a different material.

Note that each group is still a different draw call, so this isn’t a performance optimization — it’s similar to using separate meshes.

I disagree, you can toggle visibility of the groups when not needed. Doing so, will result in much higher performance gain than worrying about a few Draw Calls.

Sure, but you can toggle the visibility of different meshes in the same way. What I mean here is that using 1 geometry with 10 groups, or 10 meshes, is not particularly different in terms of performance. If your total draw call count is OK then it doesn’t matter; if you need to reduce draw calls then setting up geometry groups are not a means to do so. I think people sometimes misunderstand that.

1 Like