#![allow(missing_docs)]
use crate::math::f16;
use core::mem::MaybeUninit;
#[doc(hidden)]
pub const fn parse_u16(data: &[u8], idx: &mut usize) -> u16 {
let mut res = 0;
while data[*idx] >= b'0' && data[*idx] <= b'9' {
res *= 10;
res += (data[*idx] - b'0') as u16;
*idx += 1;
}
if *idx < data.len() {
*idx += 1;
}
res
}
#[doc(hidden)]
pub const fn parse_f16(data: &[u8], idx: &mut usize) -> f16 {
let neg = data[*idx] == b'-';
if neg {
*idx += 1;
}
let abs_int = (data[*idx] - b'0') as u16;
assert!(abs_int < 2u16.pow(f16::INT as u32));
*idx += 1;
assert!(data[*idx] == b'.');
*idx += 1;
let mut frac = 0;
let mut digits = 0;
while data[*idx] != b' ' && data[*idx] != b'\n' {
frac *= 10;
frac += (data[*idx] - b'0') as u64;
digits += 1;
*idx += 1;
}
*idx += 1;
let abs_frac = (frac * 2u64.pow(f16::FRAC as u32) / 10u64.pow(digits)) as u16;
let abs_fixed = (abs_int << f16::FRAC) | abs_frac;
let fixed = if neg {
-(abs_fixed as i16)
} else {
abs_fixed as i16
};
f16(fixed)
}
#[doc(hidden)]
pub const fn count_u16(data: &[u8], offset: usize) -> usize {
let mut i = offset;
assert!(data[i] == b'f');
assert!(data[i + 1] == b' ');
let mut count = 0;
while i < data.len() && data[i] != b'\n' {
if data[i] == b' ' {
count += 1;
}
i += 1;
}
count
}
#[doc(hidden)]
pub struct NumFaces {
pub quads: usize,
pub tris: usize,
}
#[doc(hidden)]
pub const fn count_faces(data: &[u8]) -> NumFaces {
let mut quads = 0;
let mut tris = 0;
let mut i = 0;
while i < data.len() {
if data[i] == b'f' && data[i + 1] == b' ' {
match count_u16(data, i) {
3 => tris += 1,
4 => quads += 1,
_ => panic!("Only tris and quads are currently supported"),
}
i += 1;
} else {
while i < data.len() && data[i] != b'\n' {
i += 1;
}
if i < data.len() && data[i] == b'\n' {
i += 1;
}
}
}
NumFaces { quads, tris }
}
#[doc(hidden)]
pub const fn count_vertices(data: &[u8]) -> usize {
let mut i = 0;
let mut count = 0;
while i < data.len() {
if data[i] == b'v' && data[i + 1] == b' ' {
count += 1;
}
while data[i] != b'\n' {
i += 1;
}
if data[i] == b'\n' {
i += 1;
}
}
count
}
#[doc(hidden)]
pub const fn count_normals(data: &[u8]) -> usize {
let mut i = 0;
let mut count = 0;
while i < data.len() {
if data[i] == b'v' && data[i + 1] == b'n' && data[i + 2] == b' ' {
count += 1;
}
while data[i] != b'\n' {
i += 1;
}
if data[i] == b'\n' {
i += 1;
}
}
count
}
#[derive(Debug)]
#[allow(missing_docs)]
pub struct Obj<
'a,
const VERTICES: usize,
const NORMALS: usize,
const QUADS: usize,
const TRIS: usize,
const FACES: usize,
> {
pub quads: &'a mut [[u16; 4]; QUADS],
pub tris: &'a mut [[u16; 3]; TRIS],
pub quad_norms: &'a mut [u16; QUADS],
pub tri_norms: &'a mut [u16; TRIS],
pub vertices: &'a mut [[f16; 3]; VERTICES],
pub normals: &'a mut [[f16; 3]; NORMALS],
}
#[derive(Debug)]
pub struct ObjRef<'a> {
pub quads: &'a [[u16; 4]],
pub tris: &'a [[u16; 3]],
pub quad_norms: &'a [u16],
pub tri_norms: &'a [u16],
pub vertices: &'a [[f16; 3]],
pub normals: &'a [[f16; 3]],
}
impl<
'a,
const VERTICES: usize,
const NORMALS: usize,
const QUADS: usize,
const TRIS: usize,
const FACES: usize,
> Obj<'a, VERTICES, NORMALS, QUADS, TRIS, FACES>
{
pub fn for_each_face<T, F>(&self, mut f: F) -> [T; FACES]
where F: FnMut() -> T {
let mut res = MaybeUninit::uninit_array();
for n in 0..QUADS + TRIS {
res[n].write(f());
}
unsafe { MaybeUninit::array_assume_init(res) }
}
pub fn map_faces<T, F, G>(&self, mut f_quad: F, mut f_tri: G) -> [T; FACES]
where
F: FnMut([u16; 4]) -> T,
G: FnMut([u16; 3]) -> T, {
let mut res = MaybeUninit::uninit_array();
for n in 0..QUADS + TRIS {
if n < QUADS {
res[n].write(f_quad(self.quads[n]));
} else {
res[n].write(f_tri(self.tris[n - QUADS]));
}
}
unsafe { MaybeUninit::array_assume_init(res) }
}
pub fn as_ref(&self) -> ObjRef {
ObjRef {
quads: self.quads,
tris: self.tris,
quad_norms: self.quad_norms,
tri_norms: self.tri_norms,
vertices: self.vertices,
normals: self.normals,
}
}
}
#[macro_export]
macro_rules! include_obj {
($file:literal) => {{
use $crate::format::obj::{count_faces, count_normals, count_u16, count_vertices,
parse_f16, parse_u16, NumFaces, Obj};
use $crate::math::f16;
const NUM_VERTICES: usize = count_vertices(include_bytes!($file));
const NUM_NORMALS: usize = count_normals(include_bytes!($file));
static mut VERTICES: [[f16; 3]; NUM_VERTICES] = {
let mut vertices = [[f16(0); 3]; NUM_VERTICES];
let mut n = 0;
let mut i = 0;
let obj = include_bytes!($file);
while i < obj.len() {
if obj[i] == b'v' && obj[i + 1] == b' ' {
i += 2;
let x = parse_f16(obj, &mut i);
let y = parse_f16(obj, &mut i);
let z = parse_f16(obj, &mut i);
vertices[n] = [x, y, z];
n += 1;
} else {
while i < obj.len() && obj[i] != b'\n' {
i += 1;
}
if i == obj.len() {
break
}
if obj[i] == b'\n' {
i += 1;
}
}
}
vertices
};
static mut NORMALS: [[f16; 3]; NUM_NORMALS] = {
let mut vertices = [[f16(0); 3]; NUM_NORMALS];
let mut n = 0;
let mut i = 0;
let obj = include_bytes!($file);
while i < obj.len() {
if obj[i] == b'v' && obj[i + 1] == b'n' && obj[i + 2] == b' ' {
i += 3;
let x = parse_f16(obj, &mut i);
let y = parse_f16(obj, &mut i);
let z = parse_f16(obj, &mut i);
vertices[n] = [x, y, z];
n += 1;
} else {
while i < obj.len() && obj[i] != b'\n' {
i += 1;
}
if i == obj.len() {
break
}
if obj[i] == b'\n' {
i += 1;
}
}
}
vertices
};
const FACE_COUNT: NumFaces = count_faces(include_bytes!($file));
const NUM_QUADS: usize = FACE_COUNT.quads;
const NUM_TRIS: usize = FACE_COUNT.tris;
const NUM_FACES: usize = NUM_QUADS + NUM_TRIS;
pub struct Faces<const QUADS: usize, const TRIS: usize> {
pub quads: [[u16; 4]; QUADS],
pub tris: [[u16; 3]; TRIS],
pub quad_norms: [u16; QUADS],
pub tri_norms: [u16; TRIS],
}
static mut FACES: Faces<NUM_QUADS, NUM_TRIS> = {
let mut quads = [[0; 4]; NUM_QUADS];
let mut tris = [[0; 3]; NUM_TRIS];
let mut quad_norms = [0; NUM_QUADS];
let mut tri_norms = [0; NUM_TRIS];
let mut n = 0;
let mut m = 0;
let mut i = 0;
let obj = include_bytes!($file);
while i < obj.len() {
if obj[i] == b'f' && obj[i + 1] == b' ' {
if count_u16(obj, i) == 4 {
i += 2;
let a = parse_u16(obj, &mut i);
while obj[i] != b'/' {
i += 1;
}
while obj[i] != b'/' {
i += 1;
}
let norm = parse_u16(obj, &mut i);
while obj[i] != b' ' {
i += 1;
}
i += 1;
let b = parse_u16(obj, &mut i);
while obj[i] != b' ' {
i += 1;
}
i += 1;
let c = parse_u16(obj, &mut i);
while obj[i] != b' ' {
i += 1;
}
i += 1;
let d = parse_u16(obj, &mut i);
while i < obj.len() && obj[i] != b'\n' {
i += 1;
}
quads[n] = [a - 1, b - 1, d - 1, c - 1];
quad_norms[n] = norm;
n += 1;
} else if count_u16(obj, i) == 3 {
i += 2;
let a = parse_u16(obj, &mut i);
while obj[i] != b'/' {
i += 1;
}
while obj[i] != b'/' {
i += 1;
}
let norm = parse_u16(obj, &mut i);
while obj[i] != b' ' {
i += 1;
}
i += 1;
let b = parse_u16(obj, &mut i);
while obj[i] != b' ' {
i += 1;
}
i += 1;
let c = parse_u16(obj, &mut i);
while i < obj.len() && obj[i] != b'\n' {
i += 1;
}
tris[m] = [a - 1, b - 1, c - 1];
tri_norms[m] = norm;
m += 1;
}
}
i += 1;
}
Faces {
quads,
tris,
quad_norms,
tri_norms,
}
};
Obj::<NUM_VERTICES, NUM_NORMALS, NUM_QUADS, NUM_TRIS, NUM_FACES> {
vertices: unsafe { &mut VERTICES },
normals: unsafe { &mut NORMALS },
tris: unsafe { &mut FACES.tris },
quads: unsafe { &mut FACES.quads },
tri_norms: unsafe { &mut FACES.tri_norms },
quad_norms: unsafe { &mut FACES.quad_norms },
}
}};
}
#[cfg(feature = "nonexistent_feature")]
mod tests {
use super::*;
#[test_case]
fn cube_obj() {
let cube = include_obj!("../../test_files/cube.obj");
assert!(cube.vertices.len() == 8);
assert!(cube.normals.len() == 6);
for v in cube.vertices {
for e in v {
assert!(e.abs() == f16::ONE);
}
}
let cube_faces = [
[1, 5, 3, 7],
[4, 3, 8, 7],
[8, 7, 6, 5],
[6, 2, 8, 4],
[2, 1, 4, 3],
[6, 5, 2, 1],
];
for i in 0..cube.faces.quads.len() {
assert!(cube.faces.quads[i] == cube_faces[i].map(|x| x - 1));
}
}
#[test_case]
fn cone_obj() {
let cone = include_obj!("../../test_files/cone.obj");
assert!(cone.vertices.len() == 33);
assert!(cone.normals.len() == 33);
for [_, y, _] in cone.vertices {
assert!(y.abs() == f16::ONE);
}
let cone_faces = [
[1, 33, 2],
[2, 33, 3],
[3, 33, 4],
[4, 33, 5],
[5, 33, 6],
[6, 33, 7],
[7, 33, 8],
[8, 33, 9],
[9, 33, 10],
[10, 33, 11],
[11, 33, 12],
[12, 33, 13],
[13, 33, 14],
[14, 33, 15],
[15, 33, 16],
[16, 33, 17],
[17, 33, 18],
[18, 33, 19],
[19, 33, 20],
[20, 33, 21],
[21, 33, 22],
[22, 33, 23],
[23, 33, 24],
[24, 33, 25],
[25, 33, 26],
[26, 33, 27],
[27, 33, 28],
[28, 33, 29],
[29, 33, 30],
[30, 33, 31],
[31, 33, 32],
[32, 33, 1],
[32, 1, 2],
[2, 3, 4],
[4, 5, 6],
[6, 7, 8],
[8, 9, 10],
[10, 11, 12],
[12, 13, 14],
[14, 15, 16],
[16, 17, 18],
[18, 19, 20],
[20, 21, 22],
[22, 23, 24],
[24, 25, 26],
[26, 27, 24],
[27, 28, 24],
[28, 29, 32],
[29, 30, 32],
[30, 31, 32],
[32, 2, 8],
[2, 4, 8],
[4, 6, 8],
[8, 10, 12],
[12, 14, 8],
[14, 16, 8],
[16, 18, 24],
[18, 20, 24],
[20, 22, 24],
[24, 28, 32],
];
for i in 0..cone.faces.tris.len() {
assert!(cone.faces.tris[i] == cone_faces[i].map(|x| x - 1));
}
assert!(cone.faces.quads[0] == [8, 16, 32, 24].map(|x| x - 1));
}
#[test_case]
fn torus_obj() {
let torus = include_obj!("../../test_files/torus.obj");
assert!(torus.vertices.len() == 576);
assert!(torus.normals.len() == 288);
let torus_faces = [
[1, 13, 2, 14],
[2, 14, 3, 15],
[3, 15, 4, 16],
[4, 16, 5, 17],
[5, 17, 6, 18],
[6, 18, 7, 19],
[7, 19, 8, 20],
[8, 20, 9, 21],
[9, 21, 10, 22],
[10, 22, 11, 23],
[11, 23, 12, 24],
[12, 24, 1, 13],
[13, 25, 14, 26],
[14, 26, 15, 27],
[15, 27, 16, 28],
[16, 28, 17, 29],
[17, 29, 18, 30],
[18, 30, 19, 31],
[19, 31, 20, 32],
[20, 32, 21, 33],
[21, 33, 22, 34],
[22, 34, 23, 35],
[23, 35, 24, 36],
[24, 36, 13, 25],
[25, 37, 26, 38],
[26, 38, 27, 39],
[27, 39, 28, 40],
[28, 40, 29, 41],
[29, 41, 30, 42],
[30, 42, 31, 43],
[31, 43, 32, 44],
[32, 44, 33, 45],
[33, 45, 34, 46],
[34, 46, 35, 47],
[35, 47, 36, 48],
[36, 48, 25, 37],
[37, 49, 38, 50],
[38, 50, 39, 51],
[39, 51, 40, 52],
[40, 52, 41, 53],
[41, 53, 42, 54],
[42, 54, 43, 55],
[43, 55, 44, 56],
[44, 56, 45, 57],
[45, 57, 46, 58],
[46, 58, 47, 59],
[47, 59, 48, 60],
[48, 60, 37, 49],
[49, 61, 50, 62],
[50, 62, 51, 63],
[51, 63, 52, 64],
[52, 64, 53, 65],
[53, 65, 54, 66],
[54, 66, 55, 67],
[55, 67, 56, 68],
[56, 68, 57, 69],
[57, 69, 58, 70],
[58, 70, 59, 71],
[59, 71, 60, 72],
[60, 72, 49, 61],
[61, 73, 62, 74],
[62, 74, 63, 75],
[63, 75, 64, 76],
[64, 76, 65, 77],
[65, 77, 66, 78],
[66, 78, 67, 79],
[67, 79, 68, 80],
[68, 80, 69, 81],
[69, 81, 70, 82],
[70, 82, 71, 83],
[71, 83, 72, 84],
[72, 84, 61, 73],
[73, 85, 74, 86],
[74, 86, 75, 87],
[75, 87, 76, 88],
[76, 88, 77, 89],
[77, 89, 78, 90],
[78, 90, 79, 91],
[79, 91, 80, 92],
[80, 92, 81, 93],
[81, 93, 82, 94],
[82, 94, 83, 95],
[83, 95, 84, 96],
[84, 96, 73, 85],
[85, 97, 86, 98],
[86, 98, 87, 99],
[87, 99, 88, 100],
[88, 100, 89, 101],
[89, 101, 90, 102],
[90, 102, 91, 103],
[91, 103, 92, 104],
[92, 104, 93, 105],
[93, 105, 94, 106],
[94, 106, 95, 107],
[95, 107, 96, 108],
[96, 108, 85, 97],
[97, 109, 98, 110],
[98, 110, 99, 111],
[99, 111, 100, 112],
[100, 112, 101, 113],
[101, 113, 102, 114],
[102, 114, 103, 115],
[103, 115, 104, 116],
[104, 116, 105, 117],
[105, 117, 106, 118],
[106, 118, 107, 119],
[107, 119, 108, 120],
[108, 120, 97, 109],
[109, 121, 110, 122],
[110, 122, 111, 123],
[111, 123, 112, 124],
[112, 124, 113, 125],
[113, 125, 114, 126],
[114, 126, 115, 127],
[115, 127, 116, 128],
[116, 128, 117, 129],
[117, 129, 118, 130],
[118, 130, 119, 131],
[119, 131, 120, 132],
[120, 132, 109, 121],
[121, 133, 122, 134],
[122, 134, 123, 135],
[123, 135, 124, 136],
[124, 136, 125, 137],
[125, 137, 126, 138],
[126, 138, 127, 139],
[127, 139, 128, 140],
[128, 140, 129, 141],
[129, 141, 130, 142],
[130, 142, 131, 143],
[131, 143, 132, 144],
[132, 144, 121, 133],
[133, 145, 134, 146],
[134, 146, 135, 147],
[135, 147, 136, 148],
[136, 148, 137, 149],
[137, 149, 138, 150],
[138, 150, 139, 151],
[139, 151, 140, 152],
[140, 152, 141, 153],
[141, 153, 142, 154],
[142, 154, 143, 155],
[143, 155, 144, 156],
[144, 156, 133, 145],
[145, 157, 146, 158],
[146, 158, 147, 159],
[147, 159, 148, 160],
[148, 160, 149, 161],
[149, 161, 150, 162],
[150, 162, 151, 163],
[151, 163, 152, 164],
[152, 164, 153, 165],
[153, 165, 154, 166],
[154, 166, 155, 167],
[155, 167, 156, 168],
[156, 168, 145, 157],
[157, 169, 158, 170],
[158, 170, 159, 171],
[159, 171, 160, 172],
[160, 172, 161, 173],
[161, 173, 162, 174],
[162, 174, 163, 175],
[163, 175, 164, 176],
[164, 176, 165, 177],
[165, 177, 166, 178],
[166, 178, 167, 179],
[167, 179, 168, 180],
[168, 180, 157, 169],
[169, 181, 170, 182],
[170, 182, 171, 183],
[171, 183, 172, 184],
[172, 184, 173, 185],
[173, 185, 174, 186],
[174, 186, 175, 187],
[175, 187, 176, 188],
[176, 188, 177, 189],
[177, 189, 178, 190],
[178, 190, 179, 191],
[179, 191, 180, 192],
[180, 192, 169, 181],
[181, 193, 182, 194],
[182, 194, 183, 195],
[183, 195, 184, 196],
[184, 196, 185, 197],
[185, 197, 186, 198],
[186, 198, 187, 199],
[187, 199, 188, 200],
[188, 200, 189, 201],
[189, 201, 190, 202],
[190, 202, 191, 203],
[191, 203, 192, 204],
[192, 204, 181, 193],
[193, 205, 194, 206],
[194, 206, 195, 207],
[195, 207, 196, 208],
[196, 208, 197, 209],
[197, 209, 198, 210],
[198, 210, 199, 211],
[199, 211, 200, 212],
[200, 212, 201, 213],
[201, 213, 202, 214],
[202, 214, 203, 215],
[203, 215, 204, 216],
[204, 216, 193, 205],
[205, 217, 206, 218],
[206, 218, 207, 219],
[207, 219, 208, 220],
[208, 220, 209, 221],
[209, 221, 210, 222],
[210, 222, 211, 223],
[211, 223, 212, 224],
[212, 224, 213, 225],
[213, 225, 214, 226],
[214, 226, 215, 227],
[215, 227, 216, 228],
[216, 228, 205, 217],
[217, 229, 218, 230],
[218, 230, 219, 231],
[219, 231, 220, 232],
[220, 232, 221, 233],
[221, 233, 222, 234],
[222, 234, 223, 235],
[223, 235, 224, 236],
[224, 236, 225, 237],
[225, 237, 226, 238],
[226, 238, 227, 239],
[227, 239, 228, 240],
[228, 240, 217, 229],
[229, 241, 230, 242],
[230, 242, 231, 243],
[231, 243, 232, 244],
[232, 244, 233, 245],
[233, 245, 234, 246],
[234, 246, 235, 247],
[235, 247, 236, 248],
[236, 248, 237, 249],
[237, 249, 238, 250],
[238, 250, 239, 251],
[239, 251, 240, 252],
[240, 252, 229, 241],
[241, 253, 242, 254],
[242, 254, 243, 255],
[243, 255, 244, 256],
[244, 256, 245, 257],
[245, 257, 246, 258],
[246, 258, 247, 259],
[247, 259, 248, 260],
[248, 260, 249, 261],
[249, 261, 250, 262],
[250, 262, 251, 263],
[251, 263, 252, 264],
[252, 264, 241, 253],
[253, 265, 254, 266],
[254, 266, 255, 267],
[255, 267, 256, 268],
[256, 268, 257, 269],
[257, 269, 258, 270],
[258, 270, 259, 271],
[259, 271, 260, 272],
[260, 272, 261, 273],
[261, 273, 262, 274],
[262, 274, 263, 275],
[263, 275, 264, 276],
[264, 276, 253, 265],
[265, 277, 266, 278],
[266, 278, 267, 279],
[267, 279, 268, 280],
[268, 280, 269, 281],
[269, 281, 270, 282],
[270, 282, 271, 283],
[271, 283, 272, 284],
[272, 284, 273, 285],
[273, 285, 274, 286],
[274, 286, 275, 287],
[275, 287, 276, 288],
[276, 288, 265, 277],
[277, 289, 278, 290],
[278, 290, 279, 291],
[279, 291, 280, 292],
[280, 292, 281, 293],
[281, 293, 282, 294],
[282, 294, 283, 295],
[283, 295, 284, 296],
[284, 296, 285, 297],
[285, 297, 286, 298],
[286, 298, 287, 299],
[287, 299, 288, 300],
[288, 300, 277, 289],
[289, 301, 290, 302],
[290, 302, 291, 303],
[291, 303, 292, 304],
[292, 304, 293, 305],
[293, 305, 294, 306],
[294, 306, 295, 307],
[295, 307, 296, 308],
[296, 308, 297, 309],
[297, 309, 298, 310],
[298, 310, 299, 311],
[299, 311, 300, 312],
[300, 312, 289, 301],
[301, 313, 302, 314],
[302, 314, 303, 315],
[303, 315, 304, 316],
[304, 316, 305, 317],
[305, 317, 306, 318],
[306, 318, 307, 319],
[307, 319, 308, 320],
[308, 320, 309, 321],
[309, 321, 310, 322],
[310, 322, 311, 323],
[311, 323, 312, 324],
[312, 324, 301, 313],
[313, 325, 314, 326],
[314, 326, 315, 327],
[315, 327, 316, 328],
[316, 328, 317, 329],
[317, 329, 318, 330],
[318, 330, 319, 331],
[319, 331, 320, 332],
[320, 332, 321, 333],
[321, 333, 322, 334],
[322, 334, 323, 335],
[323, 335, 324, 336],
[324, 336, 313, 325],
[325, 337, 326, 338],
[326, 338, 327, 339],
[327, 339, 328, 340],
[328, 340, 329, 341],
[329, 341, 330, 342],
[330, 342, 331, 343],
[331, 343, 332, 344],
[332, 344, 333, 345],
[333, 345, 334, 346],
[334, 346, 335, 347],
[335, 347, 336, 348],
[336, 348, 325, 337],
[337, 349, 338, 350],
[338, 350, 339, 351],
[339, 351, 340, 352],
[340, 352, 341, 353],
[341, 353, 342, 354],
[342, 354, 343, 355],
[343, 355, 344, 356],
[344, 356, 345, 357],
[345, 357, 346, 358],
[346, 358, 347, 359],
[347, 359, 348, 360],
[348, 360, 337, 349],
[349, 361, 350, 362],
[350, 362, 351, 363],
[351, 363, 352, 364],
[352, 364, 353, 365],
[353, 365, 354, 366],
[354, 366, 355, 367],
[355, 367, 356, 368],
[356, 368, 357, 369],
[357, 369, 358, 370],
[358, 370, 359, 371],
[359, 371, 360, 372],
[360, 372, 349, 361],
[361, 373, 362, 374],
[362, 374, 363, 375],
[363, 375, 364, 376],
[364, 376, 365, 377],
[365, 377, 366, 378],
[366, 378, 367, 379],
[367, 379, 368, 380],
[368, 380, 369, 381],
[369, 381, 370, 382],
[370, 382, 371, 383],
[371, 383, 372, 384],
[372, 384, 361, 373],
[373, 385, 374, 386],
[374, 386, 375, 387],
[375, 387, 376, 388],
[376, 388, 377, 389],
[377, 389, 378, 390],
[378, 390, 379, 391],
[379, 391, 380, 392],
[380, 392, 381, 393],
[381, 393, 382, 394],
[382, 394, 383, 395],
[383, 395, 384, 396],
[384, 396, 373, 385],
[385, 397, 386, 398],
[386, 398, 387, 399],
[387, 399, 388, 400],
[388, 400, 389, 401],
[389, 401, 390, 402],
[390, 402, 391, 403],
[391, 403, 392, 404],
[392, 404, 393, 405],
[393, 405, 394, 406],
[394, 406, 395, 407],
[395, 407, 396, 408],
[396, 408, 385, 397],
[397, 409, 398, 410],
[398, 410, 399, 411],
[399, 411, 400, 412],
[400, 412, 401, 413],
[401, 413, 402, 414],
[402, 414, 403, 415],
[403, 415, 404, 416],
[404, 416, 405, 417],
[405, 417, 406, 418],
[406, 418, 407, 419],
[407, 419, 408, 420],
[408, 420, 397, 409],
[409, 421, 410, 422],
[410, 422, 411, 423],
[411, 423, 412, 424],
[412, 424, 413, 425],
[413, 425, 414, 426],
[414, 426, 415, 427],
[415, 427, 416, 428],
[416, 428, 417, 429],
[417, 429, 418, 430],
[418, 430, 419, 431],
[419, 431, 420, 432],
[420, 432, 409, 421],
[421, 433, 422, 434],
[422, 434, 423, 435],
[423, 435, 424, 436],
[424, 436, 425, 437],
[425, 437, 426, 438],
[426, 438, 427, 439],
[427, 439, 428, 440],
[428, 440, 429, 441],
[429, 441, 430, 442],
[430, 442, 431, 443],
[431, 443, 432, 444],
[432, 444, 421, 433],
[433, 445, 434, 446],
[434, 446, 435, 447],
[435, 447, 436, 448],
[436, 448, 437, 449],
[437, 449, 438, 450],
[438, 450, 439, 451],
[439, 451, 440, 452],
[440, 452, 441, 453],
[441, 453, 442, 454],
[442, 454, 443, 455],
[443, 455, 444, 456],
[444, 456, 433, 445],
[445, 457, 446, 458],
[446, 458, 447, 459],
[447, 459, 448, 460],
[448, 460, 449, 461],
[449, 461, 450, 462],
[450, 462, 451, 463],
[451, 463, 452, 464],
[452, 464, 453, 465],
[453, 465, 454, 466],
[454, 466, 455, 467],
[455, 467, 456, 468],
[456, 468, 445, 457],
[457, 469, 458, 470],
[458, 470, 459, 471],
[459, 471, 460, 472],
[460, 472, 461, 473],
[461, 473, 462, 474],
[462, 474, 463, 475],
[463, 475, 464, 476],
[464, 476, 465, 477],
[465, 477, 466, 478],
[466, 478, 467, 479],
[467, 479, 468, 480],
[468, 480, 457, 469],
[469, 481, 470, 482],
[470, 482, 471, 483],
[471, 483, 472, 484],
[472, 484, 473, 485],
[473, 485, 474, 486],
[474, 486, 475, 487],
[475, 487, 476, 488],
[476, 488, 477, 489],
[477, 489, 478, 490],
[478, 490, 479, 491],
[479, 491, 480, 492],
[480, 492, 469, 481],
[481, 493, 482, 494],
[482, 494, 483, 495],
[483, 495, 484, 496],
[484, 496, 485, 497],
[485, 497, 486, 498],
[486, 498, 487, 499],
[487, 499, 488, 500],
[488, 500, 489, 501],
[489, 501, 490, 502],
[490, 502, 491, 503],
[491, 503, 492, 504],
[492, 504, 481, 493],
[493, 505, 494, 506],
[494, 506, 495, 507],
[495, 507, 496, 508],
[496, 508, 497, 509],
[497, 509, 498, 510],
[498, 510, 499, 511],
[499, 511, 500, 512],
[500, 512, 501, 513],
[501, 513, 502, 514],
[502, 514, 503, 515],
[503, 515, 504, 516],
[504, 516, 493, 505],
[505, 517, 506, 518],
[506, 518, 507, 519],
[507, 519, 508, 520],
[508, 520, 509, 521],
[509, 521, 510, 522],
[510, 522, 511, 523],
[511, 523, 512, 524],
[512, 524, 513, 525],
[513, 525, 514, 526],
[514, 526, 515, 527],
[515, 527, 516, 528],
[516, 528, 505, 517],
[517, 529, 518, 530],
[518, 530, 519, 531],
[519, 531, 520, 532],
[520, 532, 521, 533],
[521, 533, 522, 534],
[522, 534, 523, 535],
[523, 535, 524, 536],
[524, 536, 525, 537],
[525, 537, 526, 538],
[526, 538, 527, 539],
[527, 539, 528, 540],
[528, 540, 517, 529],
[529, 541, 530, 542],
[530, 542, 531, 543],
[531, 543, 532, 544],
[532, 544, 533, 545],
[533, 545, 534, 546],
[534, 546, 535, 547],
[535, 547, 536, 548],
[536, 548, 537, 549],
[537, 549, 538, 550],
[538, 550, 539, 551],
[539, 551, 540, 552],
[540, 552, 529, 541],
[541, 553, 542, 554],
[542, 554, 543, 555],
[543, 555, 544, 556],
[544, 556, 545, 557],
[545, 557, 546, 558],
[546, 558, 547, 559],
[547, 559, 548, 560],
[548, 560, 549, 561],
[549, 561, 550, 562],
[550, 562, 551, 563],
[551, 563, 552, 564],
[552, 564, 541, 553],
[553, 565, 554, 566],
[554, 566, 555, 567],
[555, 567, 556, 568],
[556, 568, 557, 569],
[557, 569, 558, 570],
[558, 570, 559, 571],
[559, 571, 560, 572],
[560, 572, 561, 573],
[561, 573, 562, 574],
[562, 574, 563, 575],
[563, 575, 564, 576],
[564, 576, 553, 565],
[565, 1, 566, 2],
[566, 2, 567, 3],
[567, 3, 568, 4],
[568, 4, 569, 5],
[569, 5, 570, 6],
[570, 6, 571, 7],
[571, 7, 572, 8],
[572, 8, 573, 9],
[573, 9, 574, 10],
[574, 10, 575, 11],
[575, 11, 576, 12],
[576, 12, 565, 1],
];
let torus_vertices = [
[1.250000f32, 0.000000, 0.000000],
[1.216506, 0.125000, 0.000000],
[1.125000, 0.216506, 0.000000],
[1.000000, 0.250000, 0.000000],
[0.875000, 0.216506, 0.000000],
[0.783494, 0.125000, 0.000000],
[0.750000, 0.000000, 0.000000],
[0.783494, -0.125000, 0.000000],
[0.875000, -0.216506, 0.000000],
[1.000000, -0.250000, 0.000000],
[1.125000, -0.216506, 0.000000],
[1.216506, -0.125000, 0.000000],
[1.239306, 0.000000, -0.163158],
[1.206099, 0.125000, -0.158786],
[1.115376, 0.216506, -0.146842],
[0.991445, 0.250000, -0.130526],
[0.867514, 0.216506, -0.114210],
[0.776791, 0.125000, -0.102266],
[0.743584, 0.000000, -0.097895],
[0.776791, -0.125000, -0.102266],
[0.867514, -0.216506, -0.114210],
[0.991445, -0.250000, -0.130526],
[1.115376, -0.216506, -0.146842],
[1.206099, -0.125000, -0.158786],
[1.207407, 0.000000, -0.323524],
[1.175055, 0.125000, -0.314855],
[1.086667, 0.216506, -0.291171],
[0.965926, 0.250000, -0.258819],
[0.845185, 0.216506, -0.226467],
[0.756797, 0.125000, -0.202783],
[0.724444, 0.000000, -0.194114],
[0.756797, -0.125000, -0.202783],
[0.845185, -0.216506, -0.226467],
[0.965926, -0.250000, -0.258819],
[1.086667, -0.216506, -0.291171],
[1.175055, -0.125000, -0.314855],
[1.154849, 0.000000, -0.478354],
[1.123905, 0.125000, -0.465537],
[1.039364, 0.216506, -0.430519],
[0.923880, 0.250000, -0.382683],
[0.808395, 0.216506, -0.334848],
[0.723854, 0.125000, -0.299830],
[0.692910, 0.000000, -0.287013],
[0.723854, -0.125000, -0.299830],
[0.808395, -0.216506, -0.334848],
[0.923880, -0.250000, -0.382683],
[1.039364, -0.216506, -0.430519],
[1.123905, -0.125000, -0.465537],
[1.082532, 0.000000, -0.625000],
[1.053525, 0.125000, -0.608253],
[0.974279, 0.216506, -0.562500],
[0.866025, 0.250000, -0.500000],
[0.757772, 0.216506, -0.437500],
[0.678525, 0.125000, -0.391747],
[0.649519, 0.000000, -0.375000],
[0.678525, -0.125000, -0.391747],
[0.757772, -0.216506, -0.437500],
[0.866025, -0.250000, -0.500000],
[0.974279, -0.216506, -0.562500],
[1.053525, -0.125000, -0.608253],
[0.991692, 0.000000, -0.760952],
[0.965119, 0.125000, -0.740562],
[0.892523, 0.216506, -0.684856],
[0.793353, 0.250000, -0.608761],
[0.694184, 0.216506, -0.532666],
[0.621587, 0.125000, -0.476961],
[0.595015, 0.000000, -0.456571],
[0.621587, -0.125000, -0.476961],
[0.694184, -0.216506, -0.532666],
[0.793353, -0.250000, -0.608761],
[0.892523, -0.216506, -0.684856],
[0.965119, -0.125000, -0.740562],
[0.883883, 0.000000, -0.883884],
[0.860200, 0.125000, -0.860200],
[0.795495, 0.216506, -0.795495],
[0.707107, 0.250000, -0.707107],
[0.618718, 0.216506, -0.618719],
[0.554014, 0.125000, -0.554014],
[0.530330, 0.000000, -0.530330],
[0.554014, -0.125000, -0.554014],
[0.618718, -0.216506, -0.618719],
[0.707107, -0.250000, -0.707107],
[0.795495, -0.216506, -0.795495],
[0.860200, -0.125000, -0.860200],
[0.760952, 0.000000, -0.991691],
[0.740562, 0.125000, -0.965119],
[0.684857, 0.216506, -0.892522],
[0.608762, 0.250000, -0.793353],
[0.532666, 0.216506, -0.694184],
[0.476961, 0.125000, -0.621587],
[0.456571, 0.000000, -0.595015],
[0.476961, -0.125000, -0.621587],
[0.532666, -0.216506, -0.694184],
[0.608762, -0.250000, -0.793353],
[0.684857, -0.216506, -0.892522],
[0.740562, -0.125000, -0.965119],
[0.625000, 0.000000, -1.082532],
[0.608253, 0.125000, -1.053525],
[0.562500, 0.216506, -0.974279],
[0.500000, 0.250000, -0.866025],
[0.437500, 0.216506, -0.757772],
[0.391747, 0.125000, -0.678525],
[0.375000, 0.000000, -0.649519],
[0.391747, -0.125000, -0.678525],
[0.437500, -0.216506, -0.757772],
[0.500000, -0.250000, -0.866025],
[0.562500, -0.216506, -0.974279],
[0.608253, -0.125000, -1.053525],
[0.478355, 0.000000, -1.154849],
[0.465537, 0.125000, -1.123905],
[0.430519, 0.216506, -1.039364],
[0.382684, 0.250000, -0.923879],
[0.334848, 0.216506, -0.808394],
[0.299830, 0.125000, -0.723854],
[0.287013, 0.000000, -0.692910],
[0.299830, -0.125000, -0.723854],
[0.334848, -0.216506, -0.808394],
[0.382684, -0.250000, -0.923879],
[0.430519, -0.216506, -1.039364],
[0.465537, -0.125000, -1.123905],
[0.323524, 0.000000, -1.207407],
[0.314855, 0.125000, -1.175055],
[0.291171, 0.216506, -1.086667],
[0.258819, 0.250000, -0.965926],
[0.226467, 0.216506, -0.845185],
[0.202783, 0.125000, -0.756797],
[0.194114, 0.000000, -0.724444],
[0.202783, -0.125000, -0.756797],
[0.226467, -0.216506, -0.845185],
[0.258819, -0.250000, -0.965926],
[0.291171, -0.216506, -1.086667],
[0.314855, -0.125000, -1.175055],
[0.163158, 0.000000, -1.239306],
[0.158786, 0.125000, -1.206099],
[0.146842, 0.216506, -1.115376],
[0.130526, 0.250000, -0.991445],
[0.114210, 0.216506, -0.867514],
[0.102266, 0.125000, -0.776791],
[0.097895, 0.000000, -0.743584],
[0.102266, -0.125000, -0.776791],
[0.114210, -0.216506, -0.867514],
[0.130526, -0.250000, -0.991445],
[0.146842, -0.216506, -1.115376],
[0.158786, -0.125000, -1.206099],
[0.000000, 0.000000, -1.250000],
[0.000000, 0.125000, -1.216506],
[0.000000, 0.216506, -1.125000],
[0.000000, 0.250000, -1.000000],
[0.000000, 0.216506, -0.875000],
[0.000000, 0.125000, -0.783494],
[0.000000, 0.000000, -0.750000],
[0.000000, -0.125000, -0.783494],
[0.000000, -0.216506, -0.875000],
[0.000000, -0.250000, -1.000000],
[0.000000, -0.216506, -1.125000],
[0.000000, -0.125000, -1.216506],
[-0.163158, 0.000000, -1.239306],
[-0.158786, 0.125000, -1.206099],
[-0.146842, 0.216506, -1.115375],
[-0.130526, 0.250000, -0.991445],
[-0.114211, 0.216506, -0.867514],
[-0.102267, 0.125000, -0.776791],
[-0.097895, 0.000000, -0.743584],
[-0.102267, -0.125000, -0.776791],
[-0.114211, -0.216506, -0.867514],
[-0.130526, -0.250000, -0.991445],
[-0.146842, -0.216506, -1.115375],
[-0.158786, -0.125000, -1.206099],
[-0.323524, 0.000000, -1.207407],
[-0.314855, 0.125000, -1.175055],
[-0.291171, 0.216506, -1.086667],
[-0.258819, 0.250000, -0.965926],
[-0.226467, 0.216506, -0.845185],
[-0.202783, 0.125000, -0.756797],
[-0.194114, 0.000000, -0.724444],
[-0.202783, -0.125000, -0.756797],
[-0.226467, -0.216506, -0.845185],
[-0.258819, -0.250000, -0.965926],
[-0.291171, -0.216506, -1.086667],
[-0.314855, -0.125000, -1.175055],
[-0.478354, 0.000000, -1.154849],
[-0.465537, 0.125000, -1.123905],
[-0.430519, 0.216506, -1.039364],
[-0.382684, 0.250000, -0.923880],
[-0.334848, 0.216506, -0.808395],
[-0.299830, 0.125000, -0.723854],
[-0.287013, 0.000000, -0.692910],
[-0.299830, -0.125000, -0.723854],
[-0.334848, -0.216506, -0.808395],
[-0.382684, -0.250000, -0.923880],
[-0.430519, -0.216506, -1.039364],
[-0.465537, -0.125000, -1.123905],
[-0.625000, 0.000000, -1.082532],
[-0.608253, 0.125000, -1.053526],
[-0.562500, 0.216506, -0.974279],
[-0.500000, 0.250000, -0.866026],
[-0.437500, 0.216506, -0.757772],
[-0.391747, 0.125000, -0.678525],
[-0.375000, 0.000000, -0.649519],
[-0.391747, -0.125000, -0.678525],
[-0.437500, -0.216506, -0.757772],
[-0.500000, -0.250000, -0.866026],
[-0.562500, -0.216506, -0.974279],
[-0.608253, -0.125000, -1.053526],
[-0.760952, 0.000000, -0.991692],
[-0.740562, 0.125000, -0.965119],
[-0.684857, 0.216506, -0.892522],
[-0.608761, 0.250000, -0.793353],
[-0.532666, 0.216506, -0.694184],
[-0.476961, 0.125000, -0.621587],
[-0.456571, 0.000000, -0.595015],
[-0.476961, -0.125000, -0.621587],
[-0.532666, -0.216506, -0.694184],
[-0.608761, -0.250000, -0.793353],
[-0.684857, -0.216506, -0.892522],
[-0.740562, -0.125000, -0.965119],
[-0.883884, 0.000000, -0.883883],
[-0.860200, 0.125000, -0.860200],
[-0.795495, 0.216506, -0.795495],
[-0.707107, 0.250000, -0.707107],
[-0.618719, 0.216506, -0.618718],
[-0.554014, 0.125000, -0.554013],
[-0.530330, 0.000000, -0.530330],
[-0.554014, -0.125000, -0.554013],
[-0.618719, -0.216506, -0.618718],
[-0.707107, -0.250000, -0.707107],
[-0.795495, -0.216506, -0.795495],
[-0.860200, -0.125000, -0.860200],
[-0.991692, 0.000000, -0.760952],
[-0.965119, 0.125000, -0.740562],
[-0.892522, 0.216506, -0.684857],
[-0.793353, 0.250000, -0.608761],
[-0.694184, 0.216506, -0.532666],
[-0.621587, 0.125000, -0.476961],
[-0.595015, 0.000000, -0.456571],
[-0.621587, -0.125000, -0.476961],
[-0.694184, -0.216506, -0.532666],
[-0.793353, -0.250000, -0.608761],
[-0.892522, -0.216506, -0.684857],
[-0.965119, -0.125000, -0.740562],
[-1.082532, 0.000000, -0.625000],
[-1.053525, 0.125000, -0.608253],
[-0.974278, 0.216506, -0.562500],
[-0.866025, 0.250000, -0.500000],
[-0.757772, 0.216506, -0.437500],
[-0.678525, 0.125000, -0.391747],
[-0.649519, 0.000000, -0.375000],
[-0.678525, -0.125000, -0.391747],
[-0.757772, -0.216506, -0.437500],
[-0.866025, -0.250000, -0.500000],
[-0.974278, -0.216506, -0.562500],
[-1.053525, -0.125000, -0.608253],
[-1.154849, 0.000000, -0.478354],
[-1.123905, 0.125000, -0.465537],
[-1.039364, 0.216506, -0.430519],
[-0.923880, 0.250000, -0.382683],
[-0.808395, 0.216506, -0.334848],
[-0.723854, 0.125000, -0.299830],
[-0.692910, 0.000000, -0.287013],
[-0.723854, -0.125000, -0.299830],
[-0.808395, -0.216506, -0.334848],
[-0.923880, -0.250000, -0.382683],
[-1.039364, -0.216506, -0.430519],
[-1.123905, -0.125000, -0.465537],
[-1.207407, 0.000000, -0.323524],
[-1.175055, 0.125000, -0.314855],
[-1.086667, 0.216506, -0.291171],
[-0.965926, 0.250000, -0.258819],
[-0.845185, 0.216506, -0.226467],
[-0.756797, 0.125000, -0.202783],
[-0.724444, 0.000000, -0.194114],
[-0.756797, -0.125000, -0.202783],
[-0.845185, -0.216506, -0.226467],
[-0.965926, -0.250000, -0.258819],
[-1.086667, -0.216506, -0.291171],
[-1.175055, -0.125000, -0.314855],
[-1.239306, 0.000000, -0.163158],
[-1.206099, 0.125000, -0.158786],
[-1.115375, 0.216506, -0.146842],
[-0.991445, 0.250000, -0.130526],
[-0.867514, 0.216506, -0.114211],
[-0.776791, 0.125000, -0.102267],
[-0.743584, 0.000000, -0.097895],
[-0.776791, -0.125000, -0.102267],
[-0.867514, -0.216506, -0.114211],
[-0.991445, -0.250000, -0.130526],
[-1.115375, -0.216506, -0.146842],
[-1.206099, -0.125000, -0.158786],
[-1.250000, 0.000000, -0.000000],
[-1.216506, 0.125000, -0.000000],
[-1.125000, 0.216506, -0.000000],
[-1.000000, 0.250000, -0.000000],
[-0.875000, 0.216506, -0.000000],
[-0.783494, 0.125000, -0.000000],
[-0.750000, 0.000000, -0.000000],
[-0.783494, -0.125000, -0.000000],
[-0.875000, -0.216506, -0.000000],
[-1.000000, -0.250000, -0.000000],
[-1.125000, -0.216506, -0.000000],
[-1.216506, -0.125000, -0.000000],
[-1.239306, 0.000000, 0.163158],
[-1.206099, 0.125000, 0.158786],
[-1.115375, 0.216506, 0.146842],
[-0.991445, 0.250000, 0.130526],
[-0.867514, 0.216506, 0.114211],
[-0.776791, 0.125000, 0.102267],
[-0.743584, 0.000000, 0.097895],
[-0.776791, -0.125000, 0.102267],
[-0.867514, -0.216506, 0.114211],
[-0.991445, -0.250000, 0.130526],
[-1.115375, -0.216506, 0.146842],
[-1.206099, -0.125000, 0.158786],
[-1.207407, 0.000000, 0.323524],
[-1.175055, 0.125000, 0.314855],
[-1.086667, 0.216506, 0.291171],
[-0.965926, 0.250000, 0.258819],
[-0.845185, 0.216506, 0.226467],
[-0.756797, 0.125000, 0.202783],
[-0.724444, 0.000000, 0.194114],
[-0.756797, -0.125000, 0.202783],
[-0.845185, -0.216506, 0.226467],
[-0.965926, -0.250000, 0.258819],
[-1.086667, -0.216506, 0.291171],
[-1.175055, -0.125000, 0.314855],
[-1.154850, 0.000000, 0.478354],
[-1.123906, 0.125000, 0.465536],
[-1.039365, 0.216506, 0.430518],
[-0.923880, 0.250000, 0.382683],
[-0.808395, 0.216506, 0.334848],
[-0.723854, 0.125000, 0.299830],
[-0.692910, 0.000000, 0.287012],
[-0.723854, -0.125000, 0.299830],
[-0.808395, -0.216506, 0.334848],
[-0.923880, -0.250000, 0.382683],
[-1.039365, -0.216506, 0.430518],
[-1.123906, -0.125000, 0.465536],
[-1.082532, 0.000000, 0.625000],
[-1.053526, 0.125000, 0.608253],
[-0.974279, 0.216506, 0.562500],
[-0.866026, 0.250000, 0.500000],
[-0.757772, 0.216506, 0.437500],
[-0.678525, 0.125000, 0.391747],
[-0.649519, 0.000000, 0.375000],
[-0.678525, -0.125000, 0.391747],
[-0.757772, -0.216506, 0.437500],
[-0.866026, -0.250000, 0.500000],
[-0.974279, -0.216506, 0.562500],
[-1.053526, -0.125000, 0.608253],
[-0.991692, 0.000000, 0.760952],
[-0.965119, 0.125000, 0.740562],
[-0.892522, 0.216506, 0.684857],
[-0.793353, 0.250000, 0.608761],
[-0.694184, 0.216506, 0.532666],
[-0.621587, 0.125000, 0.476961],
[-0.595015, 0.000000, 0.456571],
[-0.621587, -0.125000, 0.476961],
[-0.694184, -0.216506, 0.532666],
[-0.793353, -0.250000, 0.608761],
[-0.892522, -0.216506, 0.684857],
[-0.965119, -0.125000, 0.740562],
[-0.883884, 0.000000, 0.883883],
[-0.860200, 0.125000, 0.860200],
[-0.795495, 0.216506, 0.795495],
[-0.707107, 0.250000, 0.707107],
[-0.618719, 0.216506, 0.618718],
[-0.554014, 0.125000, 0.554013],
[-0.530330, 0.000000, 0.530330],
[-0.554014, -0.125000, 0.554013],
[-0.618719, -0.216506, 0.618718],
[-0.707107, -0.250000, 0.707107],
[-0.795495, -0.216506, 0.795495],
[-0.860200, -0.125000, 0.860200],
[-0.760952, 0.000000, 0.991691],
[-0.740563, 0.125000, 0.965119],
[-0.684857, 0.216506, 0.892522],
[-0.608762, 0.250000, 0.793353],
[-0.532667, 0.216506, 0.694184],
[-0.476961, 0.125000, 0.621587],
[-0.456571, 0.000000, 0.595015],
[-0.476961, -0.125000, 0.621587],
[-0.532667, -0.216506, 0.694184],
[-0.608762, -0.250000, 0.793353],
[-0.684857, -0.216506, 0.892522],
[-0.740563, -0.125000, 0.965119],
[-0.625000, 0.000000, 1.082532],
[-0.608253, 0.125000, 1.053526],
[-0.562500, 0.216506, 0.974279],
[-0.500000, 0.250000, 0.866026],
[-0.437500, 0.216506, 0.757772],
[-0.391747, 0.125000, 0.678525],
[-0.375000, 0.000000, 0.649519],
[-0.391747, -0.125000, 0.678525],
[-0.437500, -0.216506, 0.757772],
[-0.500000, -0.250000, 0.866026],
[-0.562500, -0.216506, 0.974279],
[-0.608253, -0.125000, 1.053526],
[-0.478354, 0.000000, 1.154849],
[-0.465537, 0.125000, 1.123905],
[-0.430519, 0.216506, 1.039364],
[-0.382684, 0.250000, 0.923880],
[-0.334848, 0.216506, 0.808395],
[-0.299830, 0.125000, 0.723854],
[-0.287013, 0.000000, 0.692910],
[-0.299830, -0.125000, 0.723854],
[-0.334848, -0.216506, 0.808395],
[-0.382684, -0.250000, 0.923880],
[-0.430519, -0.216506, 1.039364],
[-0.465537, -0.125000, 1.123905],
[-0.323524, 0.000000, 1.207407],
[-0.314855, 0.125000, 1.175055],
[-0.291172, 0.216506, 1.086666],
[-0.258819, 0.250000, 0.965926],
[-0.226467, 0.216506, 0.845185],
[-0.202783, 0.125000, 0.756797],
[-0.194115, 0.000000, 0.724444],
[-0.202783, -0.125000, 0.756797],
[-0.226467, -0.216506, 0.845185],
[-0.258819, -0.250000, 0.965926],
[-0.291172, -0.216506, 1.086666],
[-0.314855, -0.125000, 1.175055],
[-0.163158, 0.000000, 1.239306],
[-0.158787, 0.125000, 1.206099],
[-0.146843, 0.216506, 1.115375],
[-0.130527, 0.250000, 0.991445],
[-0.114211, 0.216506, 0.867514],
[-0.102267, 0.125000, 0.776791],
[-0.097895, 0.000000, 0.743584],
[-0.102267, -0.125000, 0.776791],
[-0.114211, -0.216506, 0.867514],
[-0.130527, -0.250000, 0.991445],
[-0.146843, -0.216506, 1.115375],
[-0.158787, -0.125000, 1.206099],
[0.000000, 0.000000, 1.250000],
[0.000000, 0.125000, 1.216506],
[0.000000, 0.216506, 1.125000],
[0.000000, 0.250000, 1.000000],
[0.000000, 0.216506, 0.875000],
[0.000000, 0.125000, 0.783494],
[0.000000, 0.000000, 0.750000],
[0.000000, -0.125000, 0.783494],
[0.000000, -0.216506, 0.875000],
[0.000000, -0.250000, 1.000000],
[0.000000, -0.216506, 1.125000],
[0.000000, -0.125000, 1.216506],
[0.163158, 0.000000, 1.239306],
[0.158786, 0.125000, 1.206099],
[0.146842, 0.216506, 1.115376],
[0.130526, 0.250000, 0.991445],
[0.114210, 0.216506, 0.867514],
[0.102266, 0.125000, 0.776791],
[0.097895, 0.000000, 0.743584],
[0.102266, -0.125000, 0.776791],
[0.114210, -0.216506, 0.867514],
[0.130526, -0.250000, 0.991445],
[0.146842, -0.216506, 1.115376],
[0.158786, -0.125000, 1.206099],
[0.323523, 0.000000, 1.207407],
[0.314854, 0.125000, 1.175055],
[0.291171, 0.216506, 1.086667],
[0.258819, 0.250000, 0.965926],
[0.226466, 0.216506, 0.845185],
[0.202783, 0.125000, 0.756797],
[0.194114, 0.000000, 0.724444],
[0.202783, -0.125000, 0.756797],
[0.226466, -0.216506, 0.845185],
[0.258819, -0.250000, 0.965926],
[0.291171, -0.216506, 1.086667],
[0.314854, -0.125000, 1.175055],
[0.478355, 0.000000, 1.154849],
[0.465537, 0.125000, 1.123905],
[0.430519, 0.216506, 1.039364],
[0.382684, 0.250000, 0.923879],
[0.334848, 0.216506, 0.808394],
[0.299830, 0.125000, 0.723854],
[0.287013, 0.000000, 0.692910],
[0.299830, -0.125000, 0.723854],
[0.334848, -0.216506, 0.808394],
[0.382684, -0.250000, 0.923879],
[0.430519, -0.216506, 1.039364],
[0.465537, -0.125000, 1.123905],
[0.625000, 0.000000, 1.082532],
[0.608253, 0.125000, 1.053525],
[0.562500, 0.216506, 0.974279],
[0.500000, 0.250000, 0.866025],
[0.437500, 0.216506, 0.757772],
[0.391747, 0.125000, 0.678525],
[0.375000, 0.000000, 0.649519],
[0.391747, -0.125000, 0.678525],
[0.437500, -0.216506, 0.757772],
[0.500000, -0.250000, 0.866025],
[0.562500, -0.216506, 0.974279],
[0.608253, -0.125000, 1.053525],
[0.760952, 0.000000, 0.991692],
[0.740562, 0.125000, 0.965120],
[0.684856, 0.216506, 0.892523],
[0.608761, 0.250000, 0.793353],
[0.532666, 0.216506, 0.694184],
[0.476961, 0.125000, 0.621587],
[0.456571, 0.000000, 0.595015],
[0.476961, -0.125000, 0.621587],
[0.532666, -0.216506, 0.694184],
[0.608761, -0.250000, 0.793353],
[0.684856, -0.216506, 0.892523],
[0.740562, -0.125000, 0.965120],
[0.883883, 0.000000, 0.883884],
[0.860199, 0.125000, 0.860200],
[0.795495, 0.216506, 0.795496],
[0.707106, 0.250000, 0.707107],
[0.618718, 0.216506, 0.618719],
[0.554013, 0.125000, 0.554014],
[0.530330, 0.000000, 0.530330],
[0.554013, -0.125000, 0.554014],
[0.618718, -0.216506, 0.618719],
[0.707106, -0.250000, 0.707107],
[0.795495, -0.216506, 0.795496],
[0.860199, -0.125000, 0.860200],
[0.991692, 0.000000, 0.760952],
[0.965119, 0.125000, 0.740562],
[0.892523, 0.216506, 0.684856],
[0.793353, 0.250000, 0.608761],
[0.694184, 0.216506, 0.532666],
[0.621587, 0.125000, 0.476961],
[0.595015, 0.000000, 0.456571],
[0.621587, -0.125000, 0.476961],
[0.694184, -0.216506, 0.532666],
[0.793353, -0.250000, 0.608761],
[0.892523, -0.216506, 0.684856],
[0.965119, -0.125000, 0.740562],
[1.082532, 0.000000, 0.625000],
[1.053525, 0.125000, 0.608253],
[0.974279, 0.216506, 0.562500],
[0.866025, 0.250000, 0.500000],
[0.757772, 0.216506, 0.437500],
[0.678525, 0.125000, 0.391747],
[0.649519, 0.000000, 0.375000],
[0.678525, -0.125000, 0.391747],
[0.757772, -0.216506, 0.437500],
[0.866025, -0.250000, 0.500000],
[0.974279, -0.216506, 0.562500],
[1.053525, -0.125000, 0.608253],
[1.154849, 0.000000, 0.478355],
[1.123905, 0.125000, 0.465537],
[1.039364, 0.216506, 0.430519],
[0.923879, 0.250000, 0.382684],
[0.808394, 0.216506, 0.334848],
[0.723854, 0.125000, 0.299830],
[0.692910, 0.000000, 0.287013],
[0.723854, -0.125000, 0.299830],
[0.808394, -0.216506, 0.334848],
[0.923879, -0.250000, 0.382684],
[1.039364, -0.216506, 0.430519],
[1.123905, -0.125000, 0.465537],
[1.207407, 0.000000, 0.323523],
[1.175055, 0.125000, 0.314855],
[1.086667, 0.216506, 0.291171],
[0.965926, 0.250000, 0.258819],
[0.845185, 0.216506, 0.226466],
[0.756797, 0.125000, 0.202783],
[0.724444, 0.000000, 0.194114],
[0.756797, -0.125000, 0.202783],
[0.845185, -0.216506, 0.226466],
[0.965926, -0.250000, 0.258819],
[1.086667, -0.216506, 0.291171],
[1.175055, -0.125000, 0.314855],
[1.239306, 0.000000, 0.163158],
[1.206099, 0.125000, 0.158786],
[1.115376, 0.216506, 0.146842],
[0.991445, 0.250000, 0.130526],
[0.867514, 0.216506, 0.114210],
[0.776791, 0.125000, 0.102266],
[0.743584, 0.000000, 0.097895],
[0.776791, -0.125000, 0.102266],
[0.867514, -0.216506, 0.114210],
[0.991445, -0.250000, 0.130526],
[1.115376, -0.216506, 0.146842],
[1.206099, -0.125000, 0.158786],
];
for i in 0..torus.vertices.len() {
if torus_vertices[i].iter().all(|&f| f != 0.0) {
assert!(torus.vertices[i] == torus_vertices[i].map(|f| f16((f * 256.) as i16)));
}
}
for i in 0..torus.faces.quads.len() {
assert!(torus.faces.quads[i] == torus_faces[i].map(|x| x - 1));
}
}
#[test_case]
fn monkey_obj() {
let monkey = include_obj!("../../test_files/monkey.obj");
assert!(monkey.vertices.len() == 507);
assert!(monkey.normals.len() == 499);
for v in monkey.vertices {
for e in v {
assert!(e.abs() < f16(0x1_80));
}
}
let monkey_tris = [
[61, 65, 49],
[50, 66, 62],
[63, 65, 61],
[62, 66, 64],
[61, 59, 63],
[64, 60, 62],
[61, 57, 59],
[60, 58, 62],
[61, 55, 57],
[58, 56, 62],
[61, 53, 55],
[56, 54, 62],
[61, 51, 53],
[54, 52, 62],
[61, 49, 51],
[52, 50, 62],
[225, 229, 227],
[228, 230, 226],
[73, 284, 74],
[74, 285, 73],
[342, 348, 384],
[385, 349, 343],
[300, 346, 344],
[345, 347, 301],
[324, 380, 352],
[353, 381, 325],
[442, 444, 446],
[447, 445, 443],
[464, 492, 466],
[467, 493, 465],
[496, 498, 500],
[501, 499, 497],
];
let monkey_quads = [
[47, 1, 45, 3],
[4, 2, 46, 48],
[45, 3, 43, 5],
[6, 4, 44, 46],
[3, 9, 5, 7],
[8, 10, 6, 4],
[1, 11, 3, 9],
[10, 12, 4, 2],
[11, 13, 9, 15],
[16, 14, 10, 12],
[9, 15, 7, 17],
[18, 16, 8, 10],
[15, 21, 17, 19],
[20, 22, 18, 16],
[13, 23, 15, 21],
[22, 24, 16, 14],
[23, 25, 21, 27],
[28, 26, 22, 24],
[21, 27, 19, 29],
[30, 28, 20, 22],
[27, 33, 29, 31],
[32, 34, 30, 28],
[25, 35, 27, 33],
[34, 36, 28, 26],
[35, 37, 33, 39],
[40, 38, 34, 36],
[33, 39, 31, 41],
[42, 40, 32, 34],
[39, 45, 41, 43],
[44, 46, 42, 40],
[37, 47, 39, 45],
[46, 48, 40, 38],
[47, 37, 49, 51],
[52, 38, 50, 48],
[37, 35, 51, 53],
[54, 36, 52, 38],
[35, 25, 53, 55],
[56, 26, 54, 36],
[25, 23, 55, 57],
[58, 24, 56, 26],
[23, 13, 57, 59],
[60, 14, 58, 24],
[13, 11, 59, 63],
[64, 12, 60, 14],
[11, 1, 63, 65],
[66, 2, 64, 12],
[1, 47, 65, 49],
[50, 48, 66, 2],
[89, 174, 91, 176],
[176, 175, 91, 90],
[87, 172, 89, 174],
[175, 173, 90, 88],
[85, 170, 87, 172],
[173, 171, 88, 86],
[83, 168, 85, 170],
[171, 169, 86, 84],
[81, 166, 83, 168],
[169, 167, 84, 82],
[79, 92, 164, 146],
[147, 93, 165, 80],
[92, 94, 146, 148],
[149, 95, 147, 93],
[94, 96, 148, 150],
[151, 97, 149, 95],
[96, 98, 150, 152],
[153, 99, 151, 97],
[98, 100, 152, 154],
[155, 101, 153, 99],
[100, 102, 154, 156],
[157, 103, 155, 101],
[102, 104, 156, 158],
[159, 105, 157, 103],
[104, 106, 158, 160],
[161, 107, 159, 105],
[106, 108, 160, 162],
[163, 109, 161, 107],
[108, 67, 162, 68],
[68, 67, 163, 109],
[110, 128, 162, 160],
[161, 129, 163, 111],
[128, 179, 160, 158],
[159, 180, 161, 129],
[126, 156, 179, 158],
[159, 157, 180, 127],
[124, 154, 126, 156],
[157, 155, 127, 125],
[122, 152, 124, 154],
[155, 153, 125, 123],
[120, 150, 122, 152],
[153, 151, 123, 121],
[118, 148, 120, 150],
[151, 149, 121, 119],
[116, 146, 118, 148],
[149, 147, 119, 117],
[114, 164, 116, 146],
[147, 165, 117, 115],
[114, 181, 164, 177],
[177, 182, 165, 115],
[110, 162, 112, 68],
[68, 163, 113, 111],
[112, 68, 183, 178],
[178, 68, 184, 113],
[177, 181, 178, 183],
[184, 182, 178, 177],
[135, 137, 174, 176],
[176, 137, 175, 136],
[133, 135, 172, 174],
[175, 136, 173, 134],
[131, 133, 170, 172],
[173, 134, 171, 132],
[166, 187, 168, 185],
[186, 188, 169, 167],
[131, 170, 185, 168],
[169, 171, 186, 132],
[144, 190, 187, 189],
[189, 190, 188, 145],
[185, 187, 69, 189],
[189, 188, 69, 186],
[130, 131, 69, 185],
[186, 132, 69, 130],
[142, 193, 144, 191],
[192, 194, 145, 143],
[140, 195, 142, 193],
[194, 196, 143, 141],
[139, 197, 140, 195],
[196, 198, 141, 139],
[138, 71, 139, 197],
[198, 71, 139, 138],
[190, 144, 70, 191],
[192, 145, 70, 190],
[70, 191, 208, 206],
[207, 192, 208, 70],
[71, 199, 197, 200],
[201, 199, 198, 71],
[197, 200, 195, 202],
[203, 201, 196, 198],
[195, 202, 193, 204],
[205, 203, 194, 196],
[193, 204, 191, 206],
[207, 205, 192, 194],
[199, 204, 200, 202],
[203, 205, 201, 199],
[199, 208, 204, 206],
[207, 208, 205, 199],
[139, 140, 177, 164],
[165, 141, 177, 139],
[140, 142, 164, 211],
[212, 143, 165, 141],
[142, 144, 211, 213],
[214, 145, 212, 143],
[144, 187, 213, 166],
[167, 188, 214, 145],
[81, 209, 166, 213],
[214, 210, 167, 82],
[209, 215, 213, 211],
[212, 216, 214, 210],
[79, 164, 215, 211],
[212, 165, 216, 80],
[131, 130, 222, 72],
[72, 130, 223, 132],
[133, 131, 220, 222],
[223, 132, 221, 134],
[135, 133, 218, 220],
[221, 134, 219, 136],
[137, 135, 217, 218],
[219, 136, 217, 137],
[217, 218, 231, 229],
[230, 219, 231, 217],
[218, 220, 229, 227],
[228, 221, 230, 219],
[220, 222, 227, 225],
[226, 223, 228, 221],
[222, 72, 225, 224],
[224, 72, 226, 223],
[224, 231, 225, 229],
[230, 231, 226, 224],
[183, 181, 232, 234],
[235, 182, 233, 184],
[112, 183, 254, 232],
[233, 184, 255, 113],
[110, 112, 256, 254],
[255, 113, 257, 111],
[181, 114, 234, 252],
[253, 115, 235, 182],
[114, 116, 252, 250],
[251, 117, 253, 115],
[116, 118, 250, 248],
[249, 119, 251, 117],
[118, 120, 248, 246],
[247, 121, 249, 119],
[120, 122, 246, 244],
[245, 123, 247, 121],
[122, 124, 244, 242],
[243, 125, 245, 123],
[124, 126, 242, 240],
[241, 127, 243, 125],
[126, 179, 240, 236],
[237, 180, 241, 127],
[179, 128, 236, 238],
[239, 129, 237, 180],
[128, 110, 238, 256],
[257, 111, 239, 129],
[238, 256, 276, 258],
[259, 257, 277, 239],
[236, 238, 278, 276],
[277, 239, 279, 237],
[240, 236, 274, 278],
[279, 237, 275, 241],
[242, 240, 272, 274],
[275, 241, 273, 243],
[244, 242, 270, 272],
[273, 243, 271, 245],
[246, 244, 268, 270],
[271, 245, 269, 247],
[248, 246, 266, 268],
[269, 247, 267, 249],
[250, 248, 264, 266],
[267, 249, 265, 251],
[252, 250, 262, 264],
[265, 251, 263, 253],
[234, 252, 280, 262],
[263, 253, 281, 235],
[256, 254, 258, 260],
[261, 255, 259, 257],
[254, 232, 260, 282],
[283, 233, 261, 255],
[232, 234, 282, 280],
[281, 235, 283, 233],
[67, 108, 73, 284],
[285, 109, 73, 67],
[108, 106, 284, 286],
[287, 107, 285, 109],
[106, 104, 286, 288],
[289, 105, 287, 107],
[104, 102, 288, 290],
[291, 103, 289, 105],
[102, 100, 290, 292],
[293, 101, 291, 103],
[100, 98, 292, 294],
[295, 99, 293, 101],
[98, 96, 294, 296],
[297, 97, 295, 99],
[96, 94, 296, 298],
[299, 95, 297, 97],
[94, 92, 298, 300],
[301, 93, 299, 95],
[308, 309, 338, 328],
[329, 309, 339, 308],
[307, 308, 336, 338],
[339, 308, 337, 307],
[306, 307, 340, 336],
[337, 307, 341, 306],
[89, 91, 340, 306],
[306, 91, 341, 90],
[87, 89, 334, 340],
[341, 90, 335, 88],
[85, 87, 330, 334],
[335, 88, 331, 86],
[83, 85, 332, 330],
[331, 86, 333, 84],
[330, 336, 332, 338],
[339, 337, 333, 331],
[330, 334, 336, 340],
[341, 335, 337, 331],
[326, 332, 328, 338],
[339, 333, 329, 327],
[81, 83, 326, 332],
[333, 84, 327, 82],
[209, 342, 215, 344],
[345, 343, 216, 210],
[81, 326, 209, 342],
[343, 327, 210, 82],
[79, 215, 346, 344],
[345, 216, 347, 80],
[79, 346, 92, 300],
[301, 347, 93, 80],
[77, 324, 304, 352],
[353, 325, 304, 77],
[304, 352, 78, 350],
[351, 353, 78, 304],
[78, 350, 305, 348],
[349, 351, 305, 78],
[305, 348, 309, 328],
[329, 349, 309, 305],
[326, 328, 342, 348],
[349, 329, 343, 327],
[296, 298, 310, 318],
[319, 299, 311, 297],
[76, 316, 77, 324],
[325, 317, 77, 76],
[302, 358, 303, 356],
[357, 359, 303, 302],
[303, 356, 75, 354],
[355, 357, 75, 303],
[75, 354, 76, 316],
[317, 355, 76, 75],
[292, 294, 364, 362],
[363, 295, 365, 293],
[364, 362, 366, 368],
[369, 363, 367, 365],
[366, 368, 372, 370],
[371, 369, 373, 367],
[372, 370, 374, 376],
[377, 371, 375, 373],
[314, 378, 376, 374],
[375, 379, 377, 315],
[316, 354, 378, 374],
[375, 355, 379, 317],
[354, 356, 374, 372],
[373, 357, 375, 355],
[356, 358, 372, 366],
[367, 359, 373, 357],
[358, 360, 366, 364],
[365, 361, 367, 359],
[290, 292, 360, 364],
[365, 293, 361, 291],
[74, 360, 302, 358],
[359, 361, 302, 74],
[284, 286, 290, 288],
[289, 287, 291, 285],
[284, 290, 74, 360],
[361, 291, 74, 285],
[294, 296, 362, 310],
[311, 297, 363, 295],
[310, 312, 362, 368],
[369, 313, 363, 311],
[312, 382, 368, 370],
[371, 383, 369, 313],
[314, 376, 382, 370],
[371, 377, 383, 315],
[348, 350, 384, 386],
[387, 351, 385, 349],
[318, 384, 320, 386],
[387, 385, 321, 319],
[298, 300, 318, 384],
[385, 301, 319, 299],
[300, 344, 384, 342],
[343, 345, 385, 301],
[314, 322, 378, 380],
[381, 323, 379, 315],
[316, 378, 324, 380],
[381, 379, 325, 317],
[320, 386, 322, 380],
[381, 387, 323, 321],
[350, 352, 386, 380],
[381, 353, 387, 351],
[400, 388, 402, 414],
[415, 389, 403, 401],
[400, 402, 398, 404],
[405, 403, 399, 401],
[398, 404, 396, 406],
[407, 405, 397, 399],
[396, 406, 394, 408],
[409, 407, 395, 397],
[394, 408, 392, 410],
[411, 409, 393, 395],
[392, 410, 390, 412],
[413, 411, 391, 393],
[410, 420, 412, 418],
[419, 421, 413, 411],
[408, 422, 410, 420],
[421, 423, 411, 409],
[406, 424, 408, 422],
[423, 425, 409, 407],
[404, 426, 406, 424],
[425, 427, 407, 405],
[402, 428, 404, 426],
[427, 429, 405, 403],
[402, 414, 428, 416],
[417, 415, 429, 403],
[318, 320, 442, 444],
[445, 321, 443, 319],
[320, 390, 444, 412],
[413, 391, 445, 321],
[310, 318, 312, 442],
[443, 319, 313, 311],
[382, 430, 388, 414],
[415, 431, 389, 383],
[412, 418, 444, 440],
[441, 419, 445, 413],
[438, 446, 440, 444],
[445, 447, 441, 439],
[434, 446, 436, 438],
[439, 447, 437, 435],
[432, 448, 434, 446],
[447, 449, 435, 433],
[430, 448, 450, 432],
[433, 449, 451, 431],
[414, 430, 416, 450],
[451, 431, 417, 415],
[312, 448, 382, 430],
[431, 449, 383, 313],
[312, 442, 448, 446],
[447, 443, 449, 313],
[416, 450, 476, 452],
[453, 451, 477, 417],
[450, 432, 452, 462],
[463, 433, 453, 451],
[432, 434, 462, 460],
[461, 435, 463, 433],
[434, 436, 460, 458],
[459, 437, 461, 435],
[436, 438, 458, 456],
[457, 439, 459, 437],
[438, 440, 456, 454],
[455, 441, 457, 439],
[440, 418, 454, 474],
[475, 419, 455, 441],
[428, 416, 464, 476],
[477, 417, 465, 429],
[426, 428, 466, 464],
[465, 429, 467, 427],
[424, 426, 468, 466],
[467, 427, 469, 425],
[422, 424, 470, 468],
[469, 425, 471, 423],
[420, 422, 472, 470],
[471, 423, 473, 421],
[418, 420, 474, 472],
[473, 421, 475, 419],
[458, 456, 478, 480],
[481, 457, 479, 459],
[478, 480, 484, 482],
[483, 481, 485, 479],
[484, 482, 486, 488],
[489, 483, 487, 485],
[486, 488, 492, 490],
[491, 489, 493, 487],
[464, 476, 492, 486],
[487, 477, 493, 465],
[452, 484, 476, 486],
[487, 485, 477, 453],
[452, 462, 484, 478],
[479, 463, 485, 453],
[458, 478, 460, 462],
[463, 479, 461, 459],
[454, 474, 456, 480],
[481, 475, 457, 455],
[472, 482, 474, 480],
[481, 483, 475, 473],
[470, 488, 472, 482],
[483, 489, 473, 471],
[468, 490, 470, 488],
[489, 491, 471, 469],
[466, 492, 468, 490],
[491, 493, 469, 467],
[392, 390, 502, 504],
[505, 391, 503, 393],
[394, 392, 500, 502],
[503, 393, 501, 395],
[396, 394, 498, 500],
[501, 395, 499, 397],
[398, 396, 496, 498],
[499, 397, 497, 399],
[400, 398, 494, 496],
[497, 399, 495, 401],
[388, 400, 506, 494],
[495, 401, 507, 389],
[494, 502, 506, 504],
[505, 503, 507, 495],
[494, 496, 502, 500],
[501, 497, 503, 495],
[314, 382, 506, 388],
[389, 383, 507, 315],
[314, 506, 322, 504],
[505, 507, 323, 315],
[320, 322, 390, 504],
[505, 323, 391, 321],
];
for i in 0..monkey.faces.quads.len() {
assert!(monkey.faces.quads[i] == monkey_quads[i].map(|x| x - 1));
}
for i in 0..monkey.faces.tris.len() {
assert!(monkey.faces.tris[i] == monkey_tris[i].map(|x| x - 1));
}
}
#[test_case]
fn count_faces() {
let obj = "f 0/0/0 1/1897/1 0/0/0\n\
f 1/1/14 2/22/28979 3/3/3\n\
f 4/43423/4 2/2/223 6/6/6 7/23/3124\n\
f 1/1/134 5/5/345 3/3/3"
.as_bytes();
let faces = count_faces(obj);
assert!(faces.quads == 1);
assert!(faces.tris == 3);
}
#[test_case]
fn count_face_u16s() {
let tri = "f 1/1/1 2/2/2 3/3/3\n".as_bytes();
let t2 = "f 0/0/0 1/1897/1 0/0/0\n".as_bytes();
let quad = "f 1/1/1 2/2/2 3/3/3 4/4/4\n".as_bytes();
let q2 = "f 4/43423/4 2/2/223 6/6/6 7/23/3124\n".as_bytes();
assert!(count_u16(tri, 0) == 3);
assert!(count_u16(t2, 0) == 3);
assert!(count_u16(quad, 0) == 4);
assert!(count_u16(q2, 0) == 4);
}
}