This is a thin Swift wrapper around the popular and excellent Open Asset Import Library library.
It provides a swifty and typesafe API.
Open Asset Import Library (short name: Assimp) is a portable Open Source library to import various well-known 3D model formats in a uniform manner. The most recent version also knows how to export 3d files and is therefore suitable as a general-purpose 3D model converter. Loads 40+ 3D file formats into one unified and clean data structure.
🚀 Getting Started
These instructions will get your copy of the project up and running on your local machine and provide a code example.
- Swift Package Manager (SPM)
- Swiftlint for linting - (optional)
- SwiftEnv for Swift version management - (optional)
Extend the following lines in your
Package.swift file or use it to create a new project.
// swift-tools-version:5.0 import PackageDescription let package = Package( name: "YourPackageName", dependencies: [ .package(url: "https://github.com/ctreffs/SwiftAssimp.git", from: "1.0.0") ], targets: [ .target( name: "YourTargetName", dependencies: ["Assimp"]) ] )
Since it's a system library wrapper you need to install the assimp library either via
brew install assimp
apt-get install libassimp-dev
depending on you platform.
📝 Code Example
import Assimp let scene: AiScene = try AiScene(file: <path/to/model/file.obj>, flags: [.removeRedundantMaterials, .genSmoothNormals])) // get meshes let meshes: [AiMesh] = scene.meshes // get materials let matrials: [AiMaterial] = scene.materials // get the root node of the scene graph let rootNode: [AiNode] = scene.rootNode
See the unit tests for more examples.
💁 Help needed
This project is in an early stage and needs a lot of love. If you are interested in contributing, please feel free to do so!
Things that need to be done are, among others:
- ☐ Wrap more assimp functions and types
- ☐ Support for Cocoapods packaging
- ☐ Support for Carthage packaging
- ☐ Write some additional tests to improve coverage
See also the list of contributors who participated in this project.
This project is licensed under the 3-Clause BSD License - see the LICENSE file for details.
- assimp licensed under 3-clause BSD license
🙏 Original code
Since Swift Assimp is merely a wrapper around assimp it obviously depends on it.
Support them if you can!
Open Asset Import Library (assimp)
A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data.