Contents

secondmouseau/swiftx

πŸ“– Documentation: <https://secondmouseau.github.io/SwiftX/>

Install

dependencies: [
    .package(url: "https://github.com/SecondMouseAU/SwiftX.git", from: "1.0.0"),
],
// target:
.target(name: "YourTarget", dependencies: [.product(name: "SwiftX", package: "SwiftX")]),

Use

import SwiftX

let mesh = try X.read(contentsOf: url)          // welded, degenerate faces dropped
print(mesh.vertexCount, mesh.triangleCount)

for t in 0..<mesh.triangleCount {
    let i = t * 3
    let a = mesh.positions[Int(mesh.indices[i])]
    // …
}

Everything is configurable via X.Options β€” weldEpsilon (seam welding; nil to keep raw indexing), dropDegenerate, scale, and flipZ (left-/right-handed). X.looksLikeX(data) sniffs the "xof " signature.

Scope & notes

SwiftX is a geometry reader: no rig/animation, materials, textures, or writing. The compressed flavours (tzip/bzip) use Apple's Compression framework for raw-DEFLATE; on platforms without it, compressed files throw X.Error.compressionUnavailable while text/binary .x still work. Multi-block MSZip (files >32 KB uncompressed) is a future addition β€” single-block (the vast majority of parts) is fully supported.

In simulators like RailSim, the .x files are individual parts and the assembly (which parts, how many, where placed) lives in separate text definition files. SwiftX reads the parts; the assembly is a separate concern.

License

MIT.

Package Metadata

Repository: secondmouseau/swiftx

Default branch: main

README: README.md