File size: 602 Bytes
8a28bb6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from numpy import ndarray

import numpy as np

from src.rig_package.info.asset import Asset
from src.rig_package.parser.bpy import BpyParser

data = np.load("mobjaverse/004444/raw_data.npz", allow_pickle=True)

# unwrap None object to None
def unwrap(x):
    if isinstance(x, ndarray) and x.shape==() and x.dtype==object:
        return x.item()
    return x
data = {k: unwrap(v) for k, v in data.items()}
asset = Asset(**data)
assert asset.matrix_basis is not None

asset.matrix_basis[:, 0, :3, 3] = 0 # remove root translation
asset.normalize_vertices((-1.0, 1.0))

BpyParser.export(asset, "res.glb")