threejs gltf alpha 模式混合选项在某些角度不起作用

threejs gltf alpha mode blend option does not work at some angles

我有一个 gltf,我在其中将 png 纹理应用于矩形网格。我有一个矩形 png 和圆形 png。矩形节点在 z = 0.01 处,圆在 z = 0.0 处。用于 materials 的 alpha 模式是 BLEND。 material是双面的。

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

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

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

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

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