Spaces:
Sleeping
Sleeping
import numpy as np | |
from typing import Dict, Tuple | |
from utils.geometry import vector3_to_numpy | |
def create_subject_mesh(subject: Dict) -> Tuple[np.ndarray, np.ndarray]: | |
position = vector3_to_numpy(subject['position']) | |
size = vector3_to_numpy(subject['size']) | |
# Create cube vertices | |
vertices = np.array([ | |
[-0.5, -0.5, -0.5], [0.5, -0.5, -0.5], [0.5, 0.5, -0.5], [-0.5, 0.5, -0.5], | |
[-0.5, -0.5, 0.5], [0.5, -0.5, 0.5], [0.5, 0.5, 0.5], [-0.5, 0.5, 0.5] | |
]) * size.reshape(1, 3) + position.reshape(1, 3) | |
# Create cube faces (updated to use vertex_indices instead of indices) | |
faces = np.array([ | |
[0, 1, 2], [0, 2, 3], # front | |
[1, 5, 6], [1, 6, 2], # right | |
[5, 4, 7], [5, 7, 6], # back | |
[4, 0, 3], [4, 3, 7], # left | |
[3, 2, 6], [3, 6, 7], # top | |
[4, 5, 1], [4, 1, 0] # bottom | |
]) | |
return vertices, faces | |