如何在Json中为顶点添加颜色并为Threejs

时间:2016-12-16 19:47:05

标签: json three.js aframe

我想知道。我如何将顶点颜色添加到我的几何体。我有一个Box.json文件绞盘,我将在晚些时候加载到Threejs场景。

我试图在几何图形中添加颜色属性。但我是新的json,我不能恶魔在哪里我必须添加颜色顶点列表



{
  "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 个答案:

没有答案