简体   繁体   English

THREEJS json模型-uv map问题

[英]THREEJS json model - uv map issue

looking at the json file of a 3d model i saw this line 看着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]]

there are numbers less than 0 and greater than 1. I thought uv measurements should not be less than 0 or bigger than 1. Where is the error? 有小于0且大于1的数字。我认为uv测量值不应小于0或大于1。错误在哪里? They should be converted? 他们应该转换吗?

the geometry json data is this 几何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"
}

how can i get exact points? 我如何获得确切积分?

there are numbers less than 0 and greater than 1. I thought uv measurements should not be less than 0 or bigger than 1. 有小于0且大于1的数字。我认为uv测量值不应小于0或大于1。

That is not the whole truth. 那不是全部事实。 UV-coordinates can be arbitrary numbers, in the end its up to the shaders to interpret them appropriately. UV坐标可以是任意数字,最后由着色器来适当地解释它们。 In three.js there are parameters texture.repeat , texture.offset , texture.center and texture.rotation (see https://threejs.org/docs/#api/textures/Texture ) that will be used to convert the values from the uv attribute to the values used for texture-lookups. 在three.js中,有参数texture.repeattexture.offsettexture.centertexture.rotation (请参阅https://threejs.org/docs/#api/textures/Texture )将用于从中转换值uv属性用于纹理查找的值。 By default, the values are used as they are. 默认情况下,将按原样使用这些值。

What finally happens for values <0 and >1 depends on the settings for wrapS and wrapT (also documented in https://threejs.org/docs/#api/textures/Texture ). 值<0和> 1的最终结果取决于wrapS和wrapT的设置(也记录在https://threejs.org/docs/#api/textures/Texture中 )。 For instance out of range values are used for texture-tiling if wrapS/T are one of the reaeat-types. 例如,如果wrapS / T是reaeat类型之一,则超出范围的值将用于纹理平铺。

Where is the error? 错误在哪里? They should be converted? 他们应该转换吗?

So there may not even be an error in this case. 因此,在这种情况下甚至可能没有错误。 The numbers could just indicate an intended tiling. 这些数字可能仅表示预期的平铺。 But to change it you need to go to where the model came from. 但是要更改它,您需要转到模型的来源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM