__init__.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:gltf-blender-importer 作者: ksons 项目源码 文件源码
def get_accessor(self, idx):
        accessor = self.root['accessors'][idx]
        buffer_view = self.get_buffer_view(accessor['bufferView'])
        component_type = accessor["componentType"]
        type_size = accessor["type"]

        if component_type == 5126:
            fmt = "<f"
        elif component_type == 5123:
            fmt = "<H"
        elif component_type == 5125:
            fmt = "<I"
        else:
            raise ValueError("Unknown component type: %s" % component_type)

        values = [i[0] for i in struct.iter_unpack(fmt, buffer_view)]

        result = values

        if type_size == "VEC3":
            result = [Vector(values[i:i+3]) for i in range(0, len(values), 3)]
        elif type_size == "VEC2":
            result = [tuple(values[i:i+2]) for i in range(0, len(values), 2)]

        return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号