Separating geometries from a mesh

Hello, I am starting to work with Babylon since three js doesnt provide features that I need. The main problem I had is streching decals which I saw is working better in babylon, so I have some questions.

1.Is there a way to separate mesh into geometries which were made in blender?
In react drei I would insert a mesh and take nodes from it which contains all geometries from blender then I would use map on nodes, then I would wrap it with and the mesh would look normally but behind the scene it will be separated on geometries.
The main thing I am doing this is to make only one geometry active at the time because of it’s hardcoded dimensions. I want to match geometries.name with selectedGeometry

2.How to get material object from the mesh?
In three js in mesh object there is a material object wich contains all data about the material I provided. I am doing that because when I change decals property I find it by id and I clone it with existing properties and add changed ones, then I copy material object and set it to the new cloned mesh. So I get the new decal wich seems the same as previous one. I saw in playground diffuseTexture but I dont see a way to get it since it returns undefined, but I am not sure would I be able to set material property from decal to diffuseTexture.

Your question is a little hard to understand. You want to import submeshes into babylon from blender?

Your second question confuses me as well, it sounds like if the diffuseTexuture is coming up undefined then one you are pointing to the wrong material or two that material does not have a diffuseTexture defined. Im not sure about the decals or what process you are actually trying to do tbh.

Can you make a playground demonstrating what it is you are trying to do?


This is the final look of the whole mesh. I just went through all the geometries from nodes.
Here is how it is written:

const { nodes } = useGLTF(subProd.model);
const nodesArray = Object.values(nodes);

<group dispose={null}>
      {nodesArray.map((e) => {
        return (
          <>
            {e.type === 'Mesh' && (
              <mesh
                ref={product.selectedFace === e.name ? shirt : null}
                geometry={e.geometry}
                material={e.material}
                scale={[0.5, 0.5, 0.5]}
                position={[0, -10, 0]}
                onClick={({ point, face }) => {
                  if (product.selectedFace === e.name) {
                    if (files.length > 0) {
                      addDecal(point, face, decalMaterial, size);
                    }
                  }
                }}
              />
            )}
          </>
        );
      })}
    </group>

I want to achieve the same thing, but since I dont have these elements in babylon my question was how to achieve it.

Ahhh ok, yeah we dont have decals uuuum, what you could do a Custom Material that has an extra sampler for a decal and some uniforms for where to draw it on the UV.

Give me a second.

Oh wait we do have decals!

I think the custom material would probably work better, but here is the decal method.

I was experimenting, I saw decals. But I still dont know how to separate the mesh. I need a mesh which will have separated parts, which I could target by it’s name and manipulate only with active one. On the image above I wraped all the geometries into group so I was able to target each of them. I want to achieve the same thing in babylon. I could place a mesh and separate it or place all geometries and group it toghether. How could I do that in babylon?

Merge Mesh operation?

2 Likes

I did it. Thanks you.

1 Like