THREEJS json模型 - 紫外线地图问题

时间:2018-04-12 14:48:25

标签: javascript json three.js uv-mapping

查看3d模型的json文件,我看到了这一行

 "uvs": [[-3.21834,-1.65399,-3.21834,-2.57657,4.21834,-2.57657,4.21834,-1.65399,4.21834,-1.85233,4.21834,-2.7749,-3.21834,-2.7749,-3.21834,-1.85233,4.21834,0.961286,-3.21834,0.961286,-3.21834,0.038714,4.21834,0.038714]]

有小于0且大于1的数字。我认为uv测量值不应小于0或大于1.误差在哪里?他们应该转换?

几何json数据就是这个

{
    "type": "Geometry",
    "materials": [{
        "visible": true,
        "colorAmbient": [0.690196,0.690196,0.690196],
        "depthWrite": true,
        "DbgIndex": 0,
        "mapDiffuseAnisotropy": 1,
        "doubleSided": true,
        "blending": "NormalBlending",
        "wireframe": false,
        "depthTest": true,
        "specularCoef": 50,
        "mapDiffuse": "roof.png",
        "colorSpecular": [0.1,0.1,0.1],
        "opacity": 1,
        "shading": "phong",
        "colorDiffuse": [0.690196,0.690196,0.690196],
        "mapDiffuseRepeat": [1,1],
        "transparent": false,
        "DbgColor": 15658734,
        "mapDiffuseWrap": ["RepeatWrapping","RepeatWrapping"],
        "colorEmissive": [0,0,0],
        "DbgName": "roof_png_material"
    }],
    "data": {
        "skinIndices": [],
        "skinWeights": [],
        "name": "RoofGeometry",
        "normals": [0.64452,-0.593982,0.481368,0.494247,-0.563707,-0.661733,0.494247,0.563707,-0.661733,0.64452,0.593982,0.481368,-0.656606,0.597949,0.459639,-0.474654,0.561144,-0.67806,-0.474654,-0.561144,-0.67806,-0.656606,-0.597949,0.459639,-0.02356,0.642933,0.765526,-0.02356,-0.642933,0.765526,0.019044,-0.784814,-0.619373,0.019044,0.784814,-0.619373],
        "metadata": {
            "uvs": 1,
            "bones": 0,
            "materials": 1,
            "normals": 12,
            "generator": "io_three",
            "morphTargets": 0,
            "version": 3,
            "vertices": 12,
            "faces": 10
        },
        "morphTargets": [],
        "vertices": [3.43784,-3.71834,-0.861598,3.43784,3.71834,-0.861598,3.43784,-3.71834,-1.23063,3.43784,3.71834,-1.23063,-0.096621,3.71834,0.184514,-0.096621,-3.71834,0.184514,-0.096621,3.71834,-0.184514,-0.096621,-3.71834,-0.184514,-3.18641,3.71834,-0.940931,-3.18641,3.71834,-1.30996,-3.18641,-3.71834,-1.30996,-3.18641,-3.71834,-0.940931],
        "uvs": [[-3.21834,-1.65399,-3.21834,-2.57657,4.21834,-2.57657,4.21834,-1.65399,4.21834,-1.85233,4.21834,-2.7749,-3.21834,-2.7749,-3.21834,-1.85233,4.21834,0.961286,-3.21834,0.961286,-3.21834,0.038714,4.21834,0.038714]],
        "animations": [],
        "faces": [43,0,2,3,1,0,0,1,2,3,0,1,2,3,43,8,9,10,11,0,4,5,6,7,4,5,6,7,43,0,1,4,5,0,0,3,8,9,0,3,8,9,43,7,6,3,2,0,10,11,2,1,10,11,2,1,43,2,0,5,7,0,1,0,9,10,1,0,9,10,43,1,3,6,4,0,3,2,11,8,3,2,11,8,43,4,6,9,8,0,8,11,5,4,8,11,5,4,43,6,7,10,9,0,11,10,6,5,11,10,6,5,43,7,5,11,10,0,10,9,7,6,10,9,7,6,43,5,4,8,11,0,9,8,4,7,9,8,4,7],
        "bones": [],
        "influencesPerVertex": 2
    },
    "uuid": "2F93879C-96CB-3936-AEFC-CE9840D3057D"
}

我怎样才能得到确切的分数?

1 个答案:

答案 0 :(得分:0)

  

有小于0且大于1的数字。我认为uv测量值不应小于0或大于1.

这不是全部真相。 UV坐标可以是任意数字,最后由着色器来正确解释它们。在three.js中,参数texture.repeattexture.offsettexture.centertexture.rotation(请参阅https://threejs.org/docs/#api/textures/Texture)将用于转换uv属性中的值到用于纹理查找的值。默认情况下,这些值按原样使用。

值< 0和> 1最终会发生什么取决于wrapS和wrapT的设置(也在https://threejs.org/docs/#api/textures/Texture中记录)。例如,如果wrapS / T是reaeat类型之一,那么超出范围的值将用于纹理平铺。

  

错误在哪里?他们应该转换?

因此在这种情况下甚至可能没有错误。这些数字只能表明预期的平铺。但要改变它,你需要去模型的来源。

相关问题