How to add color to vertex in Json and the load it for Threejs

316 views Asked by At

I want to know. how i can add vertex color to my geometry. I have a Box.json file winch i will the load to Threejs scene later.

I bbe trying to add in geometries the color attributes. But i am new with json and i cant fiend where do i have to add the list of color vertex

{
  "metadata": {
    "version": 4.3,
    "type": "Object",
    "generator": "ObjectExporter"
  },
  "geometries": [
    {
      "uuid": "5de46548-4b87-43aa-a7cb-6bb1e7ef3e0c",
      "type": "Geometry",
      "data": {
        "vertices": [
          10.0,
          -10.0,
          -10.0,
          10.0,
          -10.0,
          10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          -10.0,
          10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          -10.0,
          10.0,
          -10.0,
          10.0,
          -10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          10.0,
          -10.0,
          10.0,
          10.0,
          10.0,
          10.0,
          10.0,
          10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          -10.0,
          10.0,
          10.0,
          10.0,
          10.0,
          10.0,
          -10.0,
          10.0,
          10.0,
          -10.0,
          -10.0,
          10.0,
          -10.0,
          10.0,
          10.0,
          10.0,
          -10.0,
          10.0,
          10.0
        ],
        "normals": [],
        "uvs": [],
        "faces": [
          0,
          0,
          1,
          3,
          0,
          4,
          5,
          7,
          0,
          8,
          9,
          11,
          0,
          12,
          13,
          15,
          0,
          16,
          17,
          19,
          0,
          20,
          21,
          23,
          0,
          0,
          3,
          2,
          0,
          4,
          7,
          6,
          0,
          8,
          11,
          10,
          0,
          12,
          15,
          14,
          0,
          16,
          19,
          18,
          0,
          20,
          23,
          22
        ],
        "scale": 1,
        "visible": true,
        "castShadow": true,
        "receiveShadow": false,
        "doubleSided": true,
        "colors": [
          "#C5DC62",
          "#6793DE",
          "#2AF5A9",
          "#FBD60D",
          "#1CE95D",
          "#4ECDAC",
          "#CD980B",
          "#7273F3",
          "#39B8D7",
          "#037CDA",
          "#C3B673",
          "#0727EE",
          "#02C171",
          "#82971C",
          "#612EE1",
          "#47C667",
          "#B362CD",
          "#3CB656",
          "#BAD6DD",
          "#17A306",
          "#159DBE",
          "#565290",
          "#54022D",
          "#BA217A"
        ]
      }
    }
  ],
  "materials": [
    {
      "uuid": "72a70d14-e431-4d76-b88f-0bfdddf57b48",
      "type": "MeshPhongMaterial",
      "color": "0xFF0000",
      "ambient": "0xFF0000",
      "emissive": "0x000000",
      "specular": "0x808080",
      "shininess": 50.0,
      "opacity": 1.0,
      "transparent": false,
      "wireframe": false,
      "side": 2
    }
  ],
  "object": {
    "uuid": "7efea7bc-5a23-4df0-92ba-8cd899c14460",
    "type": "Scene",
    "matrix": [1, 0,  0, 0,  0, 1,  0, 0,  0, 0,  1, 0,  0, 0,  0, 1],
    "children": [
      {
        "uuid": "8b3f7795-e7f6-4147-8ec1-5271589cdf25",
        "name": "mesh0",
        "type": "Mesh",
        "geometry": "5de46548-4b87-43aa-a7cb-6bb1e7ef3e0c",
        "material": "72a70d14-e431-4d76-b88f-0bfdddf57b48",
        "matrix": [1, 0,  0, 0,  0, 1,  0, 0,  0, 0,  1, 0,  0, 0,  0, 1],
        "userData": {}
      }
    ]
  }
}

0

There are 0 answers