Skip to content

Instantly share code, notes, and snippets.

View ynagatomo's full-sized avatar

Yasuhito Nagatomo ynagatomo

View GitHub Profile
@ynagatomo
ynagatomo / RealityRendererTest.swift
Last active January 25, 2026 00:19 — 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
@ynagatomo
ynagatomo / SD2ContentView.swift
Created December 4, 2022 08:56
An iOS app that generates images using Stable-Diffusion-v2 CoreML models.
//
// ContentView.swift
// coremlsd2test
//
// Created by Yasuhito Nagatomo on 2022/12/03.
//
// A sample code using Apple/ml-stable-diffusion library.
// Preparation:
// 1. convert the PyTorch Stable-Diffusion v2 model to coreml models using Apple's tools.
// 2. import the coreml models into the iOS project.
// Type-safe State Machine with Phantom Type May 2022 @AtarayoSD
import Foundation
protocol State {}
// Transitions
protocol TransferableToB {}
protocol TransferableToC {}
protocol TransferableToD {}
@ynagatomo
ynagatomo / ContentView.swift
Created November 16, 2023 08:30
A sample of Head-up Display Component for visionOS
// ContentView.swift
import SwiftUI
import RealityKit
import RealityKitContent
struct ContentView: View {
@State private var showImmersiveSpace = false
@State private var immersiveSpaceIsShown = false
@ynagatomo
ynagatomo / TipKitContentView.swift
Created May 24, 2024 09:01
A sample code that uses TipKit in visionOS.
//
// TipKitTestApp.swift
// TipKitTest
//
// Created by Yasuhito Nagatomo on 2024/05/24.
//
// A sample code that uses TipKit in visionOS.
//
// References:
// - Article: Swift with Majid, Discovering app features with TipKit. Basics., 07 May 2024
// Modified TAATHub/GradientBorderAnimation.swift on 2025/03/01, Y.Nagatomo
// https://gist.github.com/TAATHub/0d312611e0b31265f85d3c555bf43039
// Gradient Border Animation
// See Also: https://x.com/sucodeee/status/1894700908824395843
import SwiftUI
struct ContentView: View {
@State var rotation: CGFloat = 0
@ynagatomo
ynagatomo / RealityDump.swift
Last active October 30, 2024 20:32
A simple dump function to show the RealityKit Entity, ModelEntity, and AnchorEntity object.
// RealityDump.swift
// Created by Yasuhito NAGATOMO on 2022/02/22.
import Foundation
import RealityKit
#if DEBUG
// swiftlint:disable line_length
private let keywords = [ // (string, indentLevel [1...])
@ynagatomo
ynagatomo / Extension+ModelComponent.swift
Created April 29, 2024 11:48
An extension of ModelComponent, to dump its MeshResource.Model such as positions and normals.
extension ModelComponent {
/// Dump the MeshResource.Model
func dumpMeshResourceModel() {
let printSIMD3Float = { (value: SIMD3<Float>) in
print("(\(value.x), \(value.y), \(value.z)), ", terminator: "")
}
let printSIMD2Float = { (value: SIMD2<Float>) in
print("(\(value.x), \(value.y)), ", terminator: "")
}
@ynagatomo
ynagatomo / sample-vm-problem.swift
Created May 20, 2024 00:38
This sample shows Observable object instances with `@Observable and @State` are created many times when a view that has the property is evaluated. So avoid heavy initializations on the Observable classes.
//
// ObservableTwiceInitProblemTestApp.swift
// ObservableTwiceInitProblemTest
//
// Created by Yasuhito Nagatomo on 2024/05/20.
//
// Modified christianselig/sample-view-model-init.swift
// https://gist.github.com/christianselig/d88b1a4d1989b973689ae62d4691162f
//
// This sample shows Observable object instances with `@Observable and @State`
@ynagatomo
ynagatomo / ContentView.swift
Created November 25, 2023 06:58
Custom Debug Window in visionOS
//
// ContentView.swift
// DebugWindow
//
// Created by Yasuhito Nagatomo on 2023/11/25.
//
import SwiftUI
import RealityKit
import RealityKitContent