kovacsv / Online3DViewer

A solution to visualize and explore 3D models in your browser.
https://3dviewer.net
MIT License
2.57k stars 548 forks source link

Importer doesn't carry material name over Three.js Material #492

Open EnsarErayAkkaya opened 3 months ago

EnsarErayAkkaya commented 3 months ago

Hello, I was testing the engine importer in my personal project, and I noticed that while importing models, it doesn't carry over material names to the converted Three.js objects. I needed to show material names in UI so I made following small changes. I think this small improvement can be useful for others as well.

// /engine/threejs/threeconverter.js

CreateThreeFaceMaterial (materialIndex)
{
        //...

      let materialParams = {
          name : material.name, // add this line to carry material name over three.js object
          color : baseColor,
          vertexColors : material.vertexColors,
          opacity : material.opacity,
          transparent : material.transparent,
          alphaTest : material.alphaTest,
          side : THREE.DoubleSide
        };

        //...
}
// /engine/threejs/threeconverter.js

CreateThreeLineMaterial (materialIndex)
{
      //...
    let materialParams = {
        name : material.name, // add this line to carry material name over three.js object
        color : baseColor,
        opacity : material.opacity
    };

    //...
}