Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VoxxxelAR/ARVoxelKit
Voxel graphics framework using ARKit + SceneKit
https://github.com/VoxxxelAR/ARVoxelKit
arkit scenekit swift voxel
Last synced: about 1 month ago
JSON representation
Voxel graphics framework using ARKit + SceneKit
- Host: GitHub
- URL: https://github.com/VoxxxelAR/ARVoxelKit
- Owner: VoxxxelAR
- License: mit
- Created: 2017-09-26T16:49:57.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-15T16:28:49.000Z (about 7 years ago)
- Last Synced: 2024-07-31T15:01:27.229Z (4 months ago)
- Topics: arkit, scenekit, swift, voxel
- Language: Swift
- Homepage:
- Size: 9.99 MB
- Stars: 81
- Watchers: 5
- Forks: 9
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift - ARVoxelKit - Voxel graphic framework using ARKit. (Libs / Augmented Reality)
- awesome-swift - ARVoxelKit - Voxel graphics framework using ARKit + SceneKit ` 📝 4 years ago ` (Augmented Reality [🔝](#readme))
README
# ARVoxelKit
Lightweight Framework for Voxel graphic using AR + SceneKit[![Build Status](https://travis-ci.org/VoxxxelAR/ARVoxelKit.svg?branch=master)](https://travis-ci.org/VoxxxelAR/ARVoxelKit)
![](preview.gif)
## Requirements
ARVoxelKit requires iOS 11 and devices, which support ARKit## Usage
1. Import libraries as follows:
``` swift
import ARVoxelKit
import ARKit
import SceneKit
```2. Setup your ARSCNView with VKSceneManager manager in you ViewContoller:
``` swift
var sceneManager: VKSceneManager?@IBOutlet open var sceneView: ARSCNView! {
didSet { sceneManager = VKSceneManager(with: sceneView) }
}override open func viewDidLoad() {
super.viewDidLoad()
sceneManager.delegate = self
}override open func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
sceneManager?.launchSession()
}override open func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneManager?.pauseSession()
}
```
3. Conform your delegate instance to VKSceneManagerDelegate:``` swift
public protocol VKSceneManagerDelegate: class {
var voxelSize: CGFloat { get }
func vkSceneManager(_ manager: VKSceneManager, shouldResetSessionFor state: VKARSessionState) -> Bool
func vkSceneManager(_ manager: VKSceneManager, didUpdateState state: VKARSessionState)
func vkSceneManager(_ manager: VKSceneManager, didFocus node: VKDisplayable, face: VKVoxelFace)
func vkSceneManager(_ manager: VKSceneManager, didDefocus node: VKDisplayable?)
func vkSceneManager(_ manager: VKSceneManager, countOfVoxelsIn scene: ARSCNView) -> Int
func vkSceneManager(_ manager: VKSceneManager, voxelFor index: Int) -> VKVoxelNode
}
```4. You can add/remove voxels by calling manager methods:
``` swift
public func add(new voxel: VKVoxelNode)
public func add(new voxel: VKVoxelNode, to otherVoxel: VKVoxelNode, face: VKVoxelFace)
public func add(new voxel: VKVoxelNode, to tile: VKTileNode)
public func remove(_ voxel: VKVoxelNode)
```5. Edit surfaces, tiles, voxels using paint command:
``` swift
public enum VKPaintCommand {
case color(content: UIColor)
case faceColor(content: UIColor, face: VKVoxelFace)
case colors(contents: [UIColor])
case image(content: UIImage)
case faceImage(content: UIImage, face: VKVoxelFace)
case images(contents: [UIImage])
case gradient(contents: [UIColor], start: CGPoint, end: CGPoint)
case faceGradient(contents: [UIColor], start: CGPoint, end: CGPoint, face: VKVoxelFace)
case transparency(value: CGFloat)
case faceTransparency(value: CGFloat, face: VKVoxelFace)
}
```
for example:
``` swift
voxel.apply([.color(content: VKConstants.defaultFaceColor),
.transparency(value: 1)], animated: true)
```
6. Change default setup by changing VKConstants values## Example
Check our example by running ARVoxelKitExample target