Code Monkey home page Code Monkey logo

realityvideo's Introduction

RealityVideo

Allows you to record videos in RealityKit. Just replace your ARView with RealityView, then you can call the methods on RealityView myARView.startRecording() myARView.endRecording(). No additional setup neccessary.

SwiftUI Example

// 1. Initialize RealityView for SwiftUI
struct ARViewContainer: UIViewRepresentable {
    var arView: RealityView!

    func makeUIView(context: Context) -> RealityView {
        // 2. (Optional) set up options for recording
        // note: audio settings must be set before initialization
        let settings = RealityVideoSettings()
        settings.outputURL = FileManager....some location in the file system
        arView = RealityView(settings: settings)
        // you are responsible for this file, RealityVideo simply writes to that location
        // Load the "Box" scene from the "Experience" Reality File
        let boxAnchor = try! Experience.loadBox()

        // Add the box anchor to the scene
        arView.scene.anchors.append(boxAnchor)
        return arView
    }

    func updateUIView(_ uiView: RealityView, context: Context) {}

}
    
struct ContentView: View {
    // 3. Add the swiftui view
    var arView: ARViewContainer = ARViewContainer()
    
    var body: some View {
        ZStack {
            arView.edgesIgnoringSafeArea(.all)
            Button {
                // 4. start recording
                switch arView.arView.captureState {
                case .idle:
                    arView.arView.startRecording()
                case .capturing:
                    arView.arView.endRecording { 
                        // optionally perform some work when recording finishes
                    }
                default:
                    break
                }
            } label: {
                Text("Record")
            }
            .buttonStyle(.borderedProminent)
        }
    }
}

realityvideo's People

Contributors

tad-swift avatar

Stargazers

Tim Kersey avatar Christopher Webb avatar Avinash Peddi avatar  avatar Afzal Muhammad avatar tangyumeng avatar 苹果API搬运工 avatar Artyom Mihailovich avatar Max Cobb avatar  avatar Engelie Romero avatar  avatar

Watchers

 avatar

Forkers

max2594

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.