Skip to content

Samples — Apple Platforms

Looking for Android samples?

See Samples for Jetpack Compose sample apps with source code.

These samples demonstrate SceneViewSwift capabilities using SwiftUI + RealityKit on iOS, macOS, and visionOS. The iOS demo app ships 59 demos covering every category.

.package(url: "https://github.com/sceneview/sceneview.git", from: "4.16.10")

All demo source files live in samples/ios-demo/SceneViewDemo/Views/Demos/.


Demo catalog

The iOS demo app organises all samples under six categories, mirroring the Android catalog.

3D Basics

Demo Source What it shows
Model Viewer ModelViewerDemo.swift Load a USDZ with orbit camera, IBL, and animation
Geometry GeometryDemo.swift Procedural shapes — cube, sphere, cylinder, cone, plane
Animation AnimationDemo.swift playAllAnimations(), autoRotate, timeline scrubbing
Multi-Model MultiModelDemo.swift Multiple models loaded and placed in one scene
Scene Gallery SceneGalleryDemo.swift Carousel of USDZ models with Sketchfab integration

Lighting

Demo Source What it shows
Lighting LightingDemo.swift Directional, point, and spot lights with PBR materials
Movable Light MovableLightDemo.swift Drag a LightNode around the scene
Dynamic Sky DynamicSkyDemo.swift Time-of-day slider drives DynamicSkyNode
Fog FogDemo.swift Linear / exponential / height-based atmospheric fog
Environment EnvironmentDemo.swift HDR environment presets (.studio, .outdoor, .night)

Content

Demo Source What it shows
3D Text TextDemo.swift Extruded 3D text with depth, color, and font control
Lines & Paths LinesPathsDemo.swift LineNode, PathNode, axis gizmo
Image Planes ImageDemo.swift ImageNode — textures on planes in 3D space
Billboard BillboardDemo.swift Camera-facing labels and sprites
Video Texture VideoTextureDemo.swift VideoNode — play / pause / loop video on a 3D plane
Texture Streaming TextureStreamingDemo.swift Swap PBR material presets in real time — no geometry rebuild

Interaction

Demo Source What it shows
Camera Controls CameraControlsDemo.swift .orbit, .pan, .firstPerson; native Apple modes .none/.tilt/.dolly (iOS 18+)
Collision & Hit Test CollisionHitTestDemo.swift Ray-casting against geometry, highlight on tap
Gesture Editing GestureEditingDemo.swift Drag, scale, and rotate entities via multi-touch gestures

Advanced

Demo Source What it shows
Physics PhysicsDemo.swift Rigid-body simulation — tap to spawn bouncing balls
Double Pendulum DoublePendulumDemo.swift Chaotic double-pendulum physics
Custom Mesh CustomMeshDemo.swift MeshNode.fromVertices — raw vertex data
PBR Materials MaterialsDemo.swift Full PBR material parameter explorer
Spatial Audio SpatialAudioDemo.swift SpatialAudioNode — positional audio tied to scene entities
Reflection Probes ReflectionProbesDemo.swift Local cubemap reflection probes
Shape Extrude ShapeExtrudeDemo.swift ShapeNode — extrude a 2D path into a 3D solid
Occlusion Material OcclusionMaterialDemo.swift Occluder plane that hides entities behind virtual geometry
Debug Overlay DebugOverlayDemo.swift Live FPS counter + sphere stress test

AR (iOS only)

AR samples require a physical device with ARKit support (A9+ chip, iOS 18+).

Demo Source What it shows
AR Placement ARPlacementDemo.swift Tap-to-place USDZ on a detected plane
AR Instant Placement ARInstantPlacementDemo.swift Place without waiting for plane detection
AR Orbital OrbitalARDemo.swift Orbit camera in AR passthrough mode
AR Lighting ARLightingDemo.swift ARKit environmental lighting estimation
AR Recording ARRecorderDemo.swift ReplayKit-backed AR session capture
AR Image Tracking ARImageTrackingDemo.swift Track printed reference images
Augmented Faces ARAugmentedFacesDemo.swift Front-camera face pose tracking (AnchorNode.face())
AR Depth Occlusion ARDepthOcclusionDemo.swift LiDAR depth occlusion on supported devices
AR People Occlusion ARPeopleOcclusionDemo.swift Occlude AR content behind real people
AR Body Tracker ARBodyTrackerDemo.swift Full-body skeleton tracking
AR Scene Mesh ARSceneMeshDemo.swift LiDAR scene reconstruction mesh
AR Debug (Rerun) RerunDebugDemo.swift Live AR debug data streamed to Rerun.io viewer

Minimal working examples

Model viewer

import SwiftUI
import SceneViewSwift

struct ModelViewerSample: View {
    @State private var model: ModelNode?

    var body: some View {
        SceneView { root in
            if let model {
                root.addChild(model.entity)
            }
        }
        .environment(.studio)
        .cameraControls(.orbit)
        .task {
            model = try? await ModelNode.load("models/car.usdz")
                .scaleToUnits(1.0)
                .withGroundingShadow()
            model?.playAllAnimations()
        }
    }
}

Procedural geometry

import SwiftUI
import SceneViewSwift

struct GeometryShapesSample: View {
    var body: some View {
        SceneView {
            GeometryNode.cube(size: 0.3, color: .red)
                .position(.init(x: -0.6, y: 0.15, z: -2))
            GeometryNode.sphere(
                radius: 0.2,
                material: .pbr(color: .gray, metallic: 1.0, roughness: 0.2)
            )
            .position(.init(x: 0.4, y: 0.2, z: -2))
        }
        .environment(.studio)
        .cameraControls(.orbit)
    }
}

Camera controls with native Apple modes

import SwiftUI
import SceneViewSwift

struct CameraControlsSample: View {
    @State private var mode: CameraControlMode = .orbit

    var body: some View {
        SceneView { root in
            let cube = GeometryNode.cube(size: 0.35, color: .orange)
            root.addChild(cube.entity)
        }
        .cameraControls(mode)
        .ignoresSafeArea()
        // mode options: .orbit | .pan | .firstPerson
        // native Apple modes (iOS 18+, not available on visionOS):
        //   .none | .tilt | .dolly
    }
}

AR tap-to-place

import SwiftUI
import SceneViewSwift

struct ARTapToPlaceSample: View {
    @State private var model: ModelNode?

    var body: some View {
        ARSceneView(
            planeDetection: .horizontal,
            showPlaneOverlay: true,
            showCoachingOverlay: true,
            onTapOnPlane: { position, arView in
                guard let model else { return }
                let anchor = AnchorNode.world(position: position)
                anchor.add(model.entity)
                arView.scene.addAnchor(anchor.entity)
            }
        )
        .ignoresSafeArea()
        .task {
            model = try? await ModelNode.load("models/chair.usdz")
                .scaleToUnits(0.5)
        }
    }
}

Running the samples

3D samples

3D samples run on iOS 18+, macOS 15+, and visionOS 1+. They work in both the Simulator and on physical devices.

AR samples

AR samples require:

  • A physical iPhone or iPad with ARKit support (A9 chip or later)
  • iOS 18 or later
  • Camera permission granted

Tip

For best AR tracking, use a well-lit environment with textured surfaces. Plain white surfaces and glass are difficult for ARKit to detect.


Android samples

Looking for Android (Jetpack Compose) samples? See the Android samples page.