Skip to content

Instantly share code, notes, and snippets.

@Matt54
Matt54 / ModelIOLoader.swift
Last active October 14, 2025 07:33
PLY to RealityKit with Grid-Based Decimation (Example: HD Skeleton Scan)
import Foundation
import ModelIO
import simd
nonisolated func loadMeshWithModelIO(from url: URL) throws -> TriangleMesh {
let asset = MDLAsset(url: url)
guard asset.count > 0 else {
throw NSError(domain: "ModelIO", code: 1, userInfo: [NSLocalizedDescriptionKey: "No objects found in file"])
}
@IvanCampos
IvanCampos / AGENTS.md
Last active October 27, 2025 07:57
codex-cli files for ~/.codex

AGENTS.md — VisionOS Swift + RealityKit Agent Guide

Role & Persona

You are a senior Swift + RealityKit engineer building production‑quality visionOS apps for Apple Vision Pro. Output only what is requested in Deliverables, nothing else.

Project Context

  • Platform: visionOS 26
  • Language: Swift (SwiftUI + RealityKit)
  • Device: Apple Vision Pro on macOS (Xcode toolchain)
@Matt54
Matt54 / FlamesTextAnimationView.swift
Created November 21, 2024 00:15
RealityView with centered and spaced out extruded text that sequentially fades in/out and has flames for it's material texture
import SwiftUI
import RealityKit
struct FlamesTextAnimationView: View {
var textLines: [String] = ["WELCOME", "TO", "APP NAME"]
let commandQueue: MTLCommandQueue
let computePipeline: MTLComputePipelineState
@State private var texture: LowLevelTexture?
let timer = Timer.publish(every: 1.0 / 120.0, on: .main, in: .common).autoconnect()
@State private var time: Float = 0
@Matt54
Matt54 / LowLevelTextureTextView.swift
Created November 20, 2024 04:24
Animated LowLevelTexture extruded text RealityView that according to the text's bounds
import RealityKit
import SwiftUI
struct LowLevelTextureTextView: View {
let commandQueue: MTLCommandQueue
let computePipeline: MTLComputePipelineState
@State private var texture: LowLevelTexture?
let timer = Timer.publish(every: 1.0 / 120.0, on: .main, in: .common).autoconnect()
@State private var time: Float = 0
@Matt54
Matt54 / MorphSphere.metal
Last active May 26, 2025 16:41
RealityView - organic, wave-like sphere morphing using LowLevelMesh and Metal
#include <metal_stdlib>
using namespace metal;
struct VertexData {
float3 position;
float3 normal;
float2 uv;
};
struct MorphingSphereParams {
@arthurschiller
arthurschiller / realitview_scene+subscriptions.swift
Created August 4, 2024 11:23
RealityView Example for accessing scene and subscribing to events
import SwiftUI
import RealityKit
import Combine
struct ContentView: View {
@Environment(\.realityKitScene) var scene: RealityKit.Scene?
@State private var didAddEntitySubscription: Cancellable?
@Matt54
Matt54 / FlowerPetal.swift
Last active October 12, 2024 21:27
A flower petal / leaf looking RealityKit view created from a LowLevelMesh
import RealityKit
import SwiftUI
struct FlowerPetal: View {
@State private var rotationAngle: Float = 0
var body: some View {
RealityView { content in
let leafEntity = try! leafEntity()
content.add(leafEntity)
@gonchar
gonchar / a_visionOS_Xcode_snippets
Last active May 8, 2024 13:12
visionOS Xcode snippets
// hello
@banjun
banjun / UserActivityWindowGroup.swift
Last active September 17, 2025 20:07
Open new window on drop UserActivity
import SwiftUI
// prerequisites in Info.plist: NSUserActivityTypes contains type, UIApplicationSceneManifest/UIApplicationSupportsMultipleScenes = YES
// accepts NSUserActivity.targetContentIdentifier = type
// see also: https://developer.apple.com/documentation/swiftui/scene/handlesexternalevents(matching:)
struct UserActivityWindowGroup<Content: View, Payload: Codable>: Scene {
var type: String
@ViewBuilder var content: (Payload) -> Content
init(type: String, payloadType: Payload.Type, @ViewBuilder content: @escaping (Payload) -> Content) {
@ynagatomo
ynagatomo / RealityRendererTest.swift
Last active August 29, 2025 18:49 — forked from arthurschiller/RealityRendererTest.swift
RealityRenderer Test (visionOS)
//
// RealityRendererView.swift
// RealityRendererTest
//
// Created by Arthur Schiller on 11.01.24.
//
// Change Log: by Yasuhito Nagatomo
// - Added ImageBasedLighting, Mar 2, 2024
// - Added Camera a rotation animation, Mar 2, 2024