• Stars
    star
    489
  • Rank 89,990 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 4 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

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

RealityUI

RealityUI is a collection of User Interface classes for RealityKit. The classes included in RealityUI aim to offer familiar User Interface guidelines, but in a 3D setting for Augmented and Virtual Reality through RealityKit.

The User Interface controls in this repository so far are made to be familiar to what people are used to with 2D interfaces, however the plan is to expand the tools on offer to new and unique controls, which are more appropriate for an Augmented Reality and Virtual Reality context.


RealityUI Elements in a RealityKit VR space

Requirements

  • iOS 13 or macOS 10.15
  • Swift 5.4
  • Xcode 12

Content

Installation

Swift Package Manager

Add the URL of this repository to your Xcode 11+ Project under Project > Swift Packages.

https://github.com/maxxfrazer/RealityUI.git

Usage

Add import RealityUI to the top of your swift file to start.

Registering RealityUI Components

All components used in RealityUI must be registered before they are used, simply call RealityUI.registerComponents() anywhere in your app before any classes starting with RUI are initialised to avoid issues with that. For more information on what is meant by registering components see Apple's documentation here.

Activating Gestures

Enabling RealityUI gestures can be doen by calling RealityUI.enableGestures(.all, on: ARView), with ARView being your instance of an ARView object.

RUISlider, RUISwitch, RUIStepper and RUIButton all use .longTouch, and if you are adding elements that use the protocol HasClick you can use the gesture .tap. I would just recommend using .all when enabling gestures, as these will inevitably move around as RealityUI develops.

RealityUI.enableGestures(.all, on: arView)


Control Entities

By default all RealityUI Entities are quite large. This is used to standardize the sizes so that you always know what to expect. For example, all UI thumbs are spheres with a diameter of 1 meter, which is 1 unit in RealityKit, ± any padding adjustments. All RealityUI Entities face [0, 0, -1] by default. To have them point at the user camera, or .zero, you can use the .look(at:,from:,relativeTo:) method like so: .look(at: .zero, from: [0, 0, 1]). Or if you want it to turn around straight away if you've positioned it at [0, 0, -1], set the orientation to simd_quatf(angle: .pi, axis: [0, 1, 0]). Using the .look() method works here by setting the at: value to the direction the button should be used from.

RUISwitch

RUISwitch is a 3D toggle switch with an on and off state. Default bounding box is 2x1x1m

RUISwitches with and without light responsiveness

More details

RUIStepper

RUIStepper is used to increment or decrement a value. Default bounding box is 2x1x0.25m

RUIStepper with light responsiveness

More details

RUISlider

An interactive track to represent an interpolated value. Default bounding box is 10x1x1m including thumb.

RUISlider with light responsiveness

More details

RUIButton

RUIButton is used to initiate a specified action. The action here will only trigger if the gesture begins on a button, and also ends on the same button. This is similar to the touchUpInside UIControl Event. Default button bounding box before depressing the button into the base is [1, 1, 0.3]

RUIButton with light responsiveness

More details


Gestures

All of the RealityUI Control Entities use custom gestures that aren't standard in RealityKit, but some of them have been isolated so anyone can use them to manipulate their own RealityKit scene.

Turn

Unlock the ability to rotate a RealityKit entity with just one finger.

Turning key

More details

Tap

Create an object in your RealityKit scene with an action, and it will automatically be picked up whenever the user taps on it!

No Gif for this one, but check out RealityUI Gestures wiki to see how to add HasClick to an entity in your application.


Animations

There aren't many animations added by default to RealityKit, especially none that you can set to repeat. See the wiki page on how to use these animations.

Spin

Spin an Entity around an axis easily using ruiSpin.

Spinning Star More details

Shake

Shake an entity to attract attention, or signal something was incorrect.

Shaking Phone Icon More details


Text

It's already possible to place text in RealityKit, but I felt it needed a little upgrade.

With RUIText you can easily create an Entity with the specified text placed with its bounding box centre at the middle of your entity.

Hello Text Hello Text More details


More

More information on everything provided in this Swift Package in the GitHub Wiki, and also the documentation.

Also see the Example Project for iOS in this repository.

More Repositories

1

FocusEntity

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

ARKit-SCNPath

Create paths for your Augmented Reality environments using just points to represent the centre of the path.
Swift
352
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