guanglei Posted November 14, 2017 Share Posted November 14, 2017 I'm reading the source code, and I'm a bit confused about the difference between mesh and submesh. So when I call `Mesh.createGround` I created a Mesh(with transform matrix, geometry and material), right? But what is submesh for? Is that when I set the parent mesh (`groundMesh.parent = sphereMesh`, eg), the groundMesh became a submesh? I'm not sure. Quote Link to comment Share on other sites More sharing options...
brianzinn Posted November 14, 2017 Share Posted November 14, 2017 3 hours ago, guanglei said: Is that when I set the parent mesh (`groundMesh.parent = sphereMesh`, eg), the groundMesh became a submesh? I would say no - by setting the sphereMesh as the parent groundMesh of you have linked the two meshes as parent-child. Now when the parent moves/rotates the child will also move/rotate. In this case, if you move the sphere (ie: sphere.position.x += 2) then the child mesh (ground) will move with it. Since you are asking about creating ground - submesh can be used for multi materials. Here are good links to show what submeshes are:https://www.eternalcoding.com/?p=283https://doc.babylonjs.com/features/materials (scroll down to "More Than One Material on a Mesh" for Playground samples)https://makina-corpus.com/blog/metier/2014/how-to-use-multimaterials-with-a-tiled-ground-in-babylonjs guanglei 1 Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 14, 2017 Share Posted November 14, 2017 A mesh has 1 to n submeshes, which divide its vertex data to n parts. This is useful for many cases (from collision to Octree, to MultiMatrials and co). When you create a ground mesh, a mesh is being created, and inside of this mesh, a new submesh is created. You can see from the signature: constructor(public materialIndex: number, public verticesStart: number, public verticesCount: number, public indexStart: number, public indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox: boolean = true); It is receiving information (index-data) of existing vertex data, but has no internal information of its own. guanglei 1 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.