• Stars
    star
    923
  • Rank 49,492 (Top 1.0 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 2 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 lightweight 3D renderer for SwiftUI.

Island

Prism

A lightweight 3D renderer for SwiftUI.

  • Works with any SwiftUI View.
  • Fully interactive and animatable.
  • Compatible with all SwiftUI modifiers.
  • No positioning side effects, unlike GeometryReader.
  • 100% SwiftUI β€” no SceneKit, SpriteKit, etc.
  • Powered by perspective transforms, so it's fast.
  • Supports sizing, extrusion, levitation, and more.
  • Compose complex scenes with a familiar API.
Logo cube Square that animates into a cube, with border 3 green cubes that bounce on click Thin, levitating blue prism Prism with an image on each side

Installation

Requires iOS 13+ or macOS Catalina and up. Prism can be installed through the Swift Package Manager.

https://github.com/aheze/Prism

Usage

Prism is designed to be easy to use. First, define a PrismConfiguration for customization. Then add a PrismCanvas, which can contain as many PrismViews as you'd like.

struct ContentView: View {
    @State var configuration = PrismConfiguration(
        tilt: 0.5, /// A value from 0 to 1, representing the perspective.
        size: CGSize(width: 200, height: 200), /// How big the prism is.
        extrusion: 100, /// The z height.
        levitation: 20, /// How far the prism is from the ground.
        shadowColor: Color.black, /// A dynamic shadow that's rendered underneath the prism.
        shadowOpacity: 0.25 /// The strength of the shadow.
    )

    var body: some View {
        PrismCanvas(tilt: configuration.tilt) {
            PrismView(configuration: configuration) {
                Color.blue
            } left: {
                Color.red
            } right: {
                Color.green
            }
        }
    }
}

Result, a multicolored cube

Example

The example app includes a bunch of samples to play with. Download it here!

Screenshot of example app

Customization

Prism supports extensive customization through the PrismConfiguration struct. Check out the example app for an editor!

Customization.mp4

Community

Author Contributing Need Help?
Prism is made by aheze. All contributions are welcome. Just fork the repo, then make a pull request. Open an issue or join the Discord server. You can also ping me on Twitter. Or read the source code β€” there's lots of comments.

Apps Using Prism

SwiftUICraft is Minecraft but made with Prism. You can move, add blocks, add water, switch worlds, and more. Thanks to Prism it's 100% SwiftUI with literally nothing else!

SwiftUICraft.mp4

Find is an app for browsing photos. Prism is used in the onboarding screen β€” download to check it out!

Find.mp4

If you have an app that uses Prism, just make a PR or message me.

License

MIT License

Copyright (c) 2023 A. Zheng

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

Popovers

A library to present popovers. Simple, modern, and highly customizable. Not boring!
Swift
1,944
star
2

Setting

Compose beautiful preference panels.
Swift
1,429
star
3

SwipeActions

Add customizable swipe actions to any view.
Swift
1,016
star
4

OpenFind

An app to find text in real life.
Swift
983
star
5

Multiliner

An Xcode source extension to expand lengthy lines.
Swift
829
star
6

Squirrel

Enable scrolling in the Xcode Simulator!
Swift
620
star
7

VariableBlurView

A one-file, App Store upload-safe version of Janum Trivedi's variable blur effect.
Swift
372
star
8

SwiftUICraft

Minecraft but made with SwiftUI.
Swift
303
star
9

RealityKitLaunchScreen

A launch screen made with SwiftUI and RealityKit. Used in the Find app.
Swift
239
star
10

SplitSheet

A lightweight, fully interactive split-screen sheet.
Swift
188
star
11

SupportDocs

Generate help centers for your iOS apps. Hosted by GitHub and always up-to-date.
Swift
161
star
12

ProgressGif

Add progress bars to gifs!
Swift
105
star
13

AppClipQuickStart

Make an app clip.
Swift
50
star
14

implicit-curves

Graph implicit curves in Swift
Swift
30
star
15

AccessibleReality

[Accepted] My WWDC21 Swift Student Challenge submission.
Swift
26
star
16

AlternativeARKit

A custom alternative to ARKit
Swift
22
star
17

PathMapper

Find the shortest distance between 2 points on a map!
Swift
19
star
18

StitchCounter

An app to count stitches in crochet patterns. Multiplatform.
Swift
19
star
19

MarkdownTextEditor

Markdown editor in SwiftUI 3
Swift
18
star
20

CustomSCNGeometry

How to make a custom SCNGeometry
Swift
17
star
21

ClassX

Swift
15
star
22

Missions

Missions for Midnight
Swift
13
star
23

QuickOCR

Drag-and-drop to find text. A work in progress.
Swift
12
star
24

ConnectFour

Literally just Connect 4 in SwiftUI
Swift
10
star
25

AnimateBetweenCollectionLayouts

Animate from "horizontal film strip" to "Vertical/expanded stack"
Swift
10
star
26

aheze

8
star
27

SixDegrees

Swift
8
star
28

MetalGradient

Swift
8
star
29

Projector

Forget the Simulator β€” swap your aspect ratio instead!
Swift
7
star
30

Buildings

Building block app made with SwiftUI
Swift
6
star
31

CalHacks

Swift
5
star
32

AcuteCalculator

Support files for Acute Calculator
5
star
33

ARKitCube

Demo app to render a cube with ARKit and SceneKit.
Swift
5
star
34

BarcodeScanner

Swift
3
star
35

ProjectorExample

Test out your app on different device sizes
Swift
3
star
36

VidQuery

CodeDay - Most Likely to Use winner
Swift
3
star
37

OpenFind-SupportDocs

Help center and other resources for Find app
Swift
3
star
38

TableViewReverseAnimation

Swift
3
star
39

PhotoLoadingTest

Swift
3
star
40

FastAssets

Testing to get photo assets quickly
Swift
2
star
41

SampleApp

A sample app for all purposes. Tap the squircle to spin it.
Swift
2
star
42

Find-Lists

Website for lists sharing in Find (getfind.app)
JavaScript
2
star
43

MyAppClipWebsite

Swift
2
star
44

StatusBarHide

Swift
2
star
45

Findbot

A Python bot. Check it out at https://getfind.app/discord
Python
2
star
46

DeveloperAssets

Just some images. Feel free to store yours here if you want.
Rich Text Format
2
star
47

FindHelp

Short tutorials/help docs for Find app. This is outdated, but I haven't gotten around to updating it
HTML
2
star
48

MyHelpCenter

Swift
2
star
49

FindAppSupport

Useful files that may be used in Find app
HTML
2
star
50

CardScanner

Swift
2
star
51

tdee-calculator

TypeScript
2
star
52

PlaygroundSync

Git for swift playgrounds, under development
Swift
1
star
53

Licenses

For hosting the licenses I use
1
star
54

schedules-ios

The iOS companion for Schedules
Swift
1
star
55

Assets

Just some file storage.
1
star
56

ReadmeTables

Tables don't need to be boring
1
star
57

LearningWebDev

Just learning web development, and following some tutorials! Testing on GitHub Pages.
HTML
1
star
58

SwiftUIImageTransitionTest

Swift
1
star
59

PhotoLoading

Memory issue
Swift
1
star
60

SwiftUISearchBar

Swift
1
star
61

SwiftUICamera

Swift
1
star
62

Find-Assets

Screenshots and other stuff for Find (getfind.app)
1
star
63

Medium

Support files for my Medium articles, but larger projects may have their own repository.
HTML
1
star
64

Find-Issues

Bug tracker for Find
1
star
65

TwoSetTableView

Swift
1
star
66

TargetContentOffsetTest

Demo repo for my question "UICollectionViewFlowLayout `targetContentOffset` - how to keep cells centered after orientation change?"
Swift
1
star
67

Find-Website-Old

Official website of Find app
CSS
1
star
68

TextFieldConstraintDemo

Demo repo for https://stackoverflow.com/questions/65928019/how-to-reduce-width-between-ui-components-in-my-case-uilabel-and-uitextfield
Swift
1
star