Tycho Geometry — zero-dependency pure-MoonBit mesh data, parametric primitive generators, and geometry-only format IO (OBJ)
let cube = @tgeo.box(width=1.0, height=1.0, depth=1.0)
let ball = @tgeo.sphere(radius=0.5, width_segments=32, height_segments=16)
let parts = @tgeo.parse_obj_text(text) // Array[(String, MeshData)]
// 2D shape -> flat mesh / solid / wireframe
let square = @tgeo.Shape2D::new([
@tmath.Vec2::new(-0.5, -0.5), @tmath.Vec2::new(0.5, -0.5),
@tmath.Vec2::new(0.5, 0.5), @tmath.Vec2::new(-0.5, 0.5),
])
let flat = @tgeo.shape(square)
let solid = @tgeo.extrude(square, options=@tgeo.ExtrudeOptions::new(depth=0.4))
let outline = @tgeo.edges(solid) // LineDatamoon test --target nativepub suberror GeometryError {
InvalidMesh(String)
InvalidGltf(String)
UnsupportedExtension(String)
}fn ExtrudeOptions::new(depth? : Float, steps? : Int, extrude_path? : Array[Vec3]?, bevel_enabled? : Bool, bevel_thickness? : Float, bevel_size? : Float, bevel_offset? : Float, bevel_segments? : Int) -> ExtrudeOptionspub(all) struct GltfAnimationChannel {
node : Int
path : GltfAnimationPath
interpolation : GltfAnimationInterpolation
times : Array[Float]
values : Array[Vec4]
}pub(all) struct GltfMaterial {
name : String
base_color : Vec4
metallic : Float
roughness : Float
emissive : Vec3
alpha_mode : GltfAlphaMode
double_sided : Bool
base_color_tex : Int
normal_tex : Int
metallic_roughness_tex : Int
transmission : Float
ior : Float
iridescence : Float
iridescence_ior : Float
iridescence_thickness : Float
clearcoat : Float
clearcoat_roughness : Float
}pub(all) struct GltfScene {
meshes : Array[MeshData]
materials : Array[GltfMaterial]
nodes : Array[GltfNode]
roots : Array[Int]
textures : Array[GltfTexture]
images : Array[Bytes]
animations : Array[GltfAnimation]
}pub(all) struct MeshData {
// private fields
}fn MeshData::add_morph_target(self : MeshData, positions : FixedArray[Vec3]) -> Unit raise GeometryErrorfn MeshData::set_skin(self : MeshData, joints : FixedArray[Vec4], weights : FixedArray[Vec4]) -> Unit raise GeometryErrorfn MeshData::set_tangents(self : MeshData, tangents : FixedArray[Vec4]?) -> Unit raise GeometryErrorpub(all) struct MeshGroup {
start : Int
count : Int
material_slot : Int
}fn box(width? : Float, height? : Float, depth? : Float, width_segments? : Int, height_segments? : Int, depth_segments? : Int) -> MeshDatafn capsule(radius? : Float, length? : Float, cap_segments? : Int, radial_segments? : Int) -> MeshDatafn circle(radius? : Float, segments? : Int, theta_start? : Float, theta_length? : Float) -> MeshDatafn cone(radius? : Float, height? : Float, radial_segments? : Int, height_segments? : Int, open_ended? : Bool, theta_start? : Float, theta_length? : Float) -> MeshDatafn cylinder(radius_top? : Float, radius_bottom? : Float, height? : Float, radial_segments? : Int, height_segments? : Int, open_ended? : Bool, theta_start? : Float, theta_length? : Float) -> MeshDatafn plane(width? : Float, height? : Float, width_segments? : Int, height_segments? : Int) -> MeshDatafn ring(inner? : Float, outer? : Float, theta_segments? : Int, phi_segments? : Int, theta_start? : Float, theta_length? : Float) -> MeshDatafn sphere(radius? : Float, width_segments? : Int, height_segments? : Int, phi_start? : Float, phi_length? : Float, theta_start? : Float, theta_length? : Float) -> MeshDatafn torus(radius? : Float, tube? : Float, radial_segments? : Int, tubular_segments? : Int, arc? : Float) -> MeshDatafn torus_knot(radius? : Float, tube? : Float, tubular_segments? : Int, radial_segments? : Int, p? : Int, q? : Int) -> MeshDataInstall
Download zipTycho Geometry — zero-dependency pure-MoonBit mesh data, parametric primitive generators, and geometry-only format IO (OBJ)