• Stars
    star
    352
  • Rank 120,622 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create paths for your Augmented Reality environments using just points to represent the centre of the path.

ARKit-SCNPath

Functions and classes for creating path geometries in a SceneKit application on iOS. Main use-case being for ARKit. I'm hoping to add RealityKit support once it is possible to generate meshes. (If anyone knows a way how, please let me know!)

Version License Platform Swift Package Manager Swift 5.0 Actions Status

Introduction

Navigation seems to be a strong point for people making AR apps. So here's a class to easily create a path in AR along a set of centre points. This class can also be used to draw out a racetrack, road for an animated character to follow, or even draw a pentagram on the floor!

Check out the full tutorial on Medium on how I made the examples in the below gifs using this Pod and about 30 lines of non boilerplate code.

Please feel free to use and contribute this library however you like. I only ask that you let me know when you're doing so, so I can see some cool uses of it!

If you're having issues with Swift Package dependencies there's some great resources online: https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app

Requirements

  • Swift 5.0
  • iOS 11.0

Compatibility

  • SceneKit
  • RealityKit

Example

It's as easy as this to make a node with this path as a geometry:

let pathNode = SCNPathNode(path: [
	SCNVector3(0, -1, 0),
	SCNVector3(0, -1, -1),
	SCNVector3(1, -1, -1)
])

Alternatively, you can grab the geometry directly:

let pathGeometry = SCNGeometry.path(path: [
	SCNVector3(0, -1, 0),
	SCNVector3(0, -1, -1),
	SCNVector3(1, -1, -1)
])

The y value is set to -1 just as an example that assumes the origin of your scene graph is 1m above the ground. Use plane detection to actually hit the ground correctly.

Other parameters that can be passed into both the SCNPathNode class and the SCNGeometry.path functions:

name description default example
path Array of SCNVector3 points to make up the path no default [SCNVector3(0,-1,0), SCNVector3(0,-1,-1), SCNVector3(1,-1,-1)]
width width of the path in meters 0.5 0.1
curvePoints number of points to make up the curved look when the path is turning to a new direction. 8 16
materials materials to be applied to the geometry. a blue SCNMaterial [SCNMaterial()]
curveDistance distance from the centre of the curve as a multiple of half the width to set the corner radius. Minimum value is 1. 1.5 2

Here's some basic examples of what you can do with this Package:

Path Example 1 Path Example Texture Repeating Path Example Creating

More Repositories

1

RealityUI

A Swift Package for creating familiar UI Elements and animations in RealityKit. For both Augmented Reality or Virtual Reality scenes.
Swift
489
star
2

FocusEntity

Bringing the scanning box from SceneKit to RealityKit
Swift
364
star
3

RealityKit-CardFlip

An example app using Apple's new RealityKit framework
Swift
94
star
4

SceneKit-SCNLine

Draw a tube or thick line in SceneKit
Swift
90
star
5

MultipeerHelper

A light swift wrapper around the iOS MultipeerConnectivity framework. Including an example project using RealityKit's MultipeerConnectivityService.
Swift
85
star
6

RealityGeometries

A collection of additional geometries ready for use in RealityKit 2
Swift
64
star
7

SceneKit-PortalMask

Clean class to create a portal in SceneKit for use in ARKit.
Swift
63
star
8

ARKit-FocusNode

FocusSquare class taken straight from Apple's ARKit examples and packed up for anyone to use with ease.
Swift
51
star
9

SceneKit-Bezier-Animations

Create animations over Bezier curves of any number of points
Swift
48
star
10

RKPointPin

A UIView which points at a RealityKit Entity from screenspace
Swift
43
star
11

SCNShaderModifier-Examples

Basic examples of shaders in SceneKit + ARKit
Swift
35
star
12

ARKit-QRScanner

Functions for scanning QR codes in ARKit
Swift
25
star
13

SCNCustomGeometries-Part2

To accompany Part 2 of my Medium post
Swift
17
star
14

SCNCustomGeometries

Repository to go with my Medium post about making geometries in SceneKit
Swift
12
star
15

ARKit-Marble-Labyrinth

Example of making a marble roll around inside of a marker image
Swift
12
star
16

ARKit-SmartHitTest

I've put a function found in Apple's ARKit examples into a Swift Package & CocoaPod so it's easy to use.
Swift
10
star
17

RealityToolkit

Useful functions for RealityKit projects
Swift
10
star
18

Swift-Graph3D

A class to create a routing graph for positions in 3D coordinate space
Swift
10
star
19

RKProgressBar

A simple RealityKit Entity class for creating a geometry to show progress in the form of a capsule
Swift
9
star
20

Agora-UIKit

Swift
3
star
21

RealityKit-Package-Collection

A collection of the best RealityKit packages.
3
star
22

SceneKit-SCNTextNode

SCNTextNode creates a node with a text geometry that's more easily customisable for ARKit or just SceneKit.
Swift
2
star
23

maxx-bash_profile

My bash profile (and similar) filled with functions I've made and aliases gathered from various places.
Shell
1
star
24

Agora-Token-Swift

Example of how to fetch an Agora RTC Token into a Swift application
Swift
1
star