We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

How to generate and assign new material?

Home Forums Programming How to generate and assign new material?

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33364
    derekwang0605
    Customer

    var color = new v3d.Color(‘#0000FF’);
    color.convertSRGBToLinear();
    var mymat = new v3d.MeshStandardMaterial({ color: color, emissive: color, emissiveIntensity: 0.4, toneMapped: false });

    assignMat([‘GROUP’, ‘L100’], mymat);

    But it did not change the material. Not sure why? Thanks!

    #33383

    Hi,

    does it print any errors in the browser console?

    Chief 3D Verger | LinkedIn | Twitter

    #33406
    derekwang0605
    Customer

    No errors and no color has been changed to new color.
    setMaterialColor(‘Verge3D_Environment_World’, ‘Principled Color’, 0.1, 0.5, 0.05, ”);
    assignMat([‘GROUP’, ‘L100’], ‘Verge3D_Environment_World’);
    Instead if I use ‘Verge3D_Environment_World’, it works and color will be changed.

    #33441

    the function assignMat takes material name (a String value). Try to name your material first.

    Chief 3D Verger | LinkedIn | Twitter

    #33448
    derekwang0605
    Customer

    I have already generated a new material but did not work. And I have to add a new color in Blender and then it can work in runCode().
    var color = new v3d.Color(‘#0000FF’);
    color.convertSRGBToLinear();
    var mymat = new v3d.MeshStandardMaterial({ color: color, emissive: color, emissiveIntensity: 0.4, toneMapped: false });

    assignMat([‘GROUP’, ‘L100’], mymat);

    #33476

    assignMat only works with materials that are already assigned to some object

    Chief 3D Verger | LinkedIn | Twitter

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.