Giter Site home page Giter Site logo

maxxfrazer / arkit-scnpath Goto Github PK

View Code? Open in Web Editor NEW
357.0 23.0 41.0 14.48 MB

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

License: MIT License

Ruby 3.83% Swift 92.31% Shell 3.86%
arkit scenekit augmented-reality swift ios geometry-processing arkit-scnpath scenekit-arkit

arkit-scnpath's Introduction

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

arkit-scnpath's People

Contributors

maxxfrazer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arkit-scnpath's Issues

Find a way to make this work with RealityKit

Feature Request

What do you want to add?

The same path geometry working in RealityKit - without exporting from SceneKit as a USDz

How should it look like?

The same as in SceneKit

Notes

RealityKit doesn't seem to support custom geometries, I'll continue to investigate but want to get this repo working with RealityKit.

Material cutting out on curved surfaces.

A feature request

What do you want to add?

If this feature is already here I would truly appreciate someone pointing it out, thanks in advance!

I have multiple planes created by a list of paths.

I also have 1 material that I would like to repeat across these planes, but as it stands now it seems to cut when the curve appears. I am not quite sure how this cut happens yet, but I would appreciate a way for it to not be cut.

How should it look like?

Please add images.

Simply a material that works across multiple curved planes.

ARSmartHItTest error

Hello Im getting error in ViewController class

Error:-
Cannot assign value of type 'ARSCNView?' to type 'ARSmartHitTest?'

Line no :- 38
self.focusSquare.viewDelegate = self.sceneView

Please suggest.

Getting distance between you and path.

Hi,
This is just an improvement or a question... is there a way to calculate the minimum distance between the path and the center of the camera? Supposing that you are not on the path and you want to calculate the minimum distance between you and the path.
Another option is: instead to calculate the distance, is there a way to check if the focusNode is on the path or not?
Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.