0

我有一个 gltf,我在矩形网格上应用 png 纹理。我有一个矩形png和圆形png。矩形节点在 z = 0.01 处,圆在 z = 0.0 处。用于材质的 alpha 模式是 BLEND。材料是双面的。

GLTF

{
"scenes" : [
    {
        "nodes" : [
            0
        ]
    }
],
"nodes" : [
    {
        "name" : "Node_0",
        "children" : [
            1,
            3
        ]
    },
    {
        "name" : "Symbol 2",
        "children" : [
            2
        ],
        "translation" : [
            240.25,
            -126.300003,
            0
        ]
    },
    {
        "name" : "Node_2",
        "mesh" : 0,
        "scale" : [
            0.656657,
            0.656657,
            1
        ]
    },
    {
        "name" : "Symbol 1",
        "children" : [
            4
        ],
        "translation" : [
            170,
            -89.050003,
            0
        ]
    },
    {
        "name" : "Node_4",
        "mesh" : 1,
        "translation" : [
            0,
            0,
            -0.01
        ],
        "scale" : [
            2.059968,
            1.399979,
            1
        ]
    }
],
"meshes" : [
    {
        "primitives" : [
            {
                "attributes" : {
                    "POSITION" : 1,
                    "TEXCOORD_0" : 2
                },
                "indices" : 0,
                "material" : 0
            }
        ]
    },
    {
        "primitives" : [
            {
                "attributes" : {
                    "POSITION" : 1,
                    "TEXCOORD_0" : 2
                },
                "indices" : 0,
                "material" : 1
            }
        ]
    }
],
"buffers" : [
    {
        "uri" : "data:application/octet-stream;base64,AQAAAAAAAAADAAAAAwAAAAIAAAABAAAAAAAAAAAAAIAAAAAAAAAAAAAAyMIAAAAAAADIQgAAyMIAAAAAAADIQgAAAIAAAAAAAAAAAAAAAAAAAAAAAACAPwAAgD8AAIA/AACAPwAAAAAAAAAAq6oqPacaKD+nGig/AACAP6caKD+nGig/AACAPwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAACAAACAPwAAAACrqio9AACAPwAAgD8AAIA/AACAPwAAgD8AAIA/AAAAAABAcEOamfzCAAAAAAAAAAAAAAAAAAAAAAAAAIAAAIA/AAAAAKuqKj2G1gNAfzKzPwAAgD+G1gNAfzKzPwAAgD8AAAAAAAAAAAAAAIAK1yO8AAAAAAAAAAAAAAAAAAAAgAAAgD8AAAAAq6oqPQAAgD8AAIA/AACAPwAAgD8AAIA/AACAPwAAAAAAACpDmhmywgAAAAAAAAAAAAAAAAAAAAAAAACAAACAPw==",
        "byteLength" : 376
    }
],
"bufferViews" : [
    {
        "buffer" : 0,
        "byteOffset" : 0,
        "byteLength" : 24,
        "target" : 34963
    },
    {
        "buffer" : 0,
        "byteOffset" : 24,
        "byteLength" : 48,
        "target" : 34962
    },
    {
        "buffer" : 0,
        "byteOffset" : 72,
        "byteLength" : 32,
        "target" : 34962
    }
],
"accessors" : [
    {
        "name" : "accessor_0",
        "bufferView" : 0,
        "byteOffset" : 0,
        "componentType" : 5125,
        "count" : 6,
        "type" : "SCALAR",
        "max" : [
            3
        ],
        "min" : [
            0
        ]
    },
    {
        "name" : "accessor_1",
        "bufferView" : 1,
        "byteOffset" : 0,
        "componentType" : 5126,
        "count" : 4,
        "type" : "VEC3",
        "max" : [
            100,
            0,
            0
        ],
        "min" : [
            0,
            -100,
            0
        ]
    },
    {
        "name" : "accessor_2",
        "bufferView" : 2,
        "byteOffset" : 0,
        "componentType" : 5126,
        "count" : 4,
        "type" : "VEC2",
        "max" : [
            1,
            1
        ],
        "min" : [
            0,
            0
        ]
    }
],
"materials" : [
    {
        "pbrMetallicRoughness" : {
            "baseColorTexture" : {
                "index" : 0
            }
        },
        "alphaMode" : "BLEND",
        "doubleSided" : true
    },
    {
        "pbrMetallicRoughness" : {
            "baseColorTexture" : {
                "index" : 1
            }
        },
        "alphaMode" : "BLEND",
        "doubleSided" : true
    }
],
"samplers" : [
    {
        "magFilter" : 9729,
        "minFilter" : 9987,
        "wrapS" : 33071,
        "wrapT" : 33071
    }
],
"textures" : [
    {
        "sampler" : 0,
        "source" : 0
    },
    {
        "sampler" : 0,
        "source" : 1
    }
],
"images" : [
    {
        "uri" : "Image0.png"
    },
    {
        "uri" : "Image1.png"
    }
],
"asset" : {
    "version" : "2.0"
}

}

PNG 圆形 PNG

矩形 PNG

我正在使用 ThreeJs gltf 查看器。https://gltf-viewer.donmccurdy.com/ 混合在某些角度可以正常工作,但是当我围绕某些角度旋转时,混合不起作用。截图 混合工作的角度 混合不起作用的角度

有人可以向我解释这种行为吗?我怎样才能在各个角度实现正确的混合。

4

1 回答 1

1

如果这些是三个独立的节点,并且它们都存在于0,0,0您可能会遇到排序问题。GLTF 是可读的,但我不熟悉规范来说明发生了什么。文件中提到的没有翻译字段的节点可能都位于0,0,0

无论哪种方式,如果您想继续排序,解决此类问题的方法是分配一个不同的yourMesh.renderOrder = yourDesiredOrder. 因此,对于这些元素,您可以设置 1,2,3,4... 并控制您希望它们何时绘制/告诉排序考虑这些权重。

于 2018-05-03T05:18:24.197 回答