Please be aware there is a known issue with images on the Community. We are working to resolve this issue as quickly as possible. We apologize for the inconvenience. If you need urgent help in the meantime, please reach out to technical support or your Threekit representative.

Asset Json Configuration

Comments

6 comments

  • William  Thompson
    William Thompson

    You can specify each segment of the color:

    {BaseColor: {r: 176, g: 18, b: 31}}

    You can also write code to convert RGB to hex if you can only get RGB.

    function componentToHex(c) {
      var hex = c.toString(16);
      return hex.length == 1 ? "0" + hex : hex;
    }
    
    function rgbToHex(r, g, b) {
      return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
    }
    
    rgbToHex(176,18,31) // "#b0121f"
    
    0
  • Prashant
    Prashant

    Hello Will,
    I am trying to setup the configuration in the catlogue item,
    We have created a Material with Color as Attribute.
    now we have to create multiple catalogue items for the different colors. I am able to do so if I pass the configuration in Hex code. But the client has given RGB code. so need to code sample, I am using the following for Hex Code and its working fine.
    {"BaseColor”:"#547A54"}

    0
  • William  Thompson
    William Thompson

    Hi @Prashant I’m not sure I understand, I apologize. Are you having trouble converting colors from RGB as provided by your client to Hex? Or would you like to set the colors with RGB colors on the platform?

    0
  • Prashant
    Prashant

    I am not having issues converting color from RGB to Hex.
    i am not sure how to set color on platform with RGB colors.

    1. We have created a Generic Material which has baseColor as attribute.
      https://preview.threekit.com/o/rimadesio/assets/596166d6-0a7a-498d-b668-c6d621ba97f7
    2. We are creating multiple Catalogue items by setting the "Asset Json Configuration”. I am passing {"BaseColor”:"#3a4352"} in the Asset Json Configuration and it works fine. I was passing Hex code so far. Now i need to set the color by passing RGB value in "Asset Json Configuration”.
      https://preview.threekit.com/o/rimadesio/items/aec10fea-51eb-4d99-b8bb-1993e86ee177

    So i need help in the syntax to pass the RGB color in Asset JSON configuration to create multiple colors[catalouge item] using same material.

    0
  • William  Thompson
    William Thompson

    I cloned the material you linked to test, you can find it here.

    On the Asset JSON Configuration you will have to divide each RGB value by 255 before entering it in the form, the JSON syntax like this works:
    {"BaseColor": {"r": 0.48235294117,"g": 0.12156862745, "b": 0.12156862745}}

    RGB are 8 bit each. The range for each individual color is 0-255. The combination range is 256x256x256. By dividing by 255, the 0-255 range can be described with a 0.0-1.0 range where 0.0 means 0 (0x00) and 1.0 means 255 (0xFF).

    I hope this helps!

    0
  • Prashant
    Prashant

    thanks Will… it is working fine.

    0

Please sign in to leave a comment.

Powered by Zendesk