import type { ObjectType, VoxelGroup, VoxelType } from "../../types"; export function getObjectVoxelGroups( object: ObjectType, voxelTypes: Record, ): VoxelGroup[] { const map = new Map(); for (const idx in object.voxels) { const v = object.voxels[idx]; const vt = voxelTypes[v.typeId]; const color = (v.color ?? vt?.color) ?? 'white'; const opacity = (v.opacity ?? vt?.opacity) ?? 1; const key = `${color}-${opacity}`; if (!map.has(key)) map.set(key, { id: key, color, opacity, positions: [] }); const p = v.position; map.get(key)!.positions.push(p); } return [...map.values()]; }