Euclid is a Swift library for creating and manipulating 3D geometry using techniques such as extruding or "lathing" 2D paths to create solid 3D shapes, and CSG (Constructive Solid Geometry) to combine or subtract those shapes from one another.
Euclid is the underlying implementation for the open source ShapeScript scripting language and ShapeScript Mac and iOS apps. Anything you can build in ShapeScript can be replicated programmatically in Swift using this library.
If you would like to support the development of Euclid, please consider buying a copy of ShapeScript (the app itself is free, but there is an in-app purchase to unlock some features). You can also donate directly to the project via PayPal:
Euclid is packaged as a dynamic framework that you can import into your Xcode project. You can install this manually, or by using CocoaPods, Carthage, or Swift Package Manager.
Note: Euclid requires Xcode 14+ to build, and runs on iOS 11+ or macOS 10.13+.
To install Euclid using CocoaPods, add the following to your Podfile:
pod 'Euclid', '~> 0.7.8'
To install using Carthage, add this to your Cartfile:
github "nicklockwood/Euclid" ~> 0.7.8
To install using Swift Package Manager, add this to the dependencies:
section in your Package.swift file:
.package(url: "https://github.com/nicklockwood/Euclid.git", .upToNextMinor(from: "0.7.8")),
Feel free to open an issue in Github if you have questions about how to use the library, or think you may have found a bug.
If you wish to contribute improvements to the documentation or the code itself, that's great! But please read the CONTRIBUTING.md file before submitting a pull request.
See the included projects for examples of how Euclid can be used in conjunction with SceneKit or RealityKit to generate and render a nontrivial 3D shape. Example
uses storyboards, is built for iOS, and runs in "Designed for iPad" mode on macOS and visionOS.
ExampleVisionPro
uses SwiftUI and a RealityView in a volumetric window, and runs only on visionOS.
Full documentation for all Euclid types and functions can be found here.
The Euclid framework is primarily the work of Nick Lockwood.
Special thanks go to Evan Wallace, whose JavaScript CSG library provided the inspiration for Euclid in the first place, along with the BSP algorithm used for Euclid's CSG operations.
Thanks also go to Joseph Heck for implementing the DocC documentation, Andy Geers for several bug fixes and improvements, and Patrick Goley who first suggested "Euclid" for the library name.