Skip to content

Instantly share code, notes, and snippets.

View KTRosenberg's full-sized avatar

Karl Toby Rosenberg KTRosenberg

  • New York University
View GitHub Profile
@Matt54
Matt54 / MorphModelToSphereView.swift
Last active June 22, 2025 12:38
RealityKit Morph To Sphere with LowLevelMesh and LowLevelTexture
import SwiftUI
import RealityKit
import Metal
struct MorphModelToSphereView: View {
@State var entity: ModelEntity?
@State var lowLevelMesh: LowLevelMesh?
@State var originalVertices: [VertexData] = []
@State var originalTexture: LowLevelTexture?
@State var processedTexture: LowLevelTexture?
@Matt54
Matt54 / ApplePlaneExample.swift
Last active June 10, 2025 00:57
RealityKit comparison of Apple's LowLevelMesh plane example on CPU to a Metal GPU implementation
import Foundation
import RealityKit
import SwiftUI
// See: https://developer.apple.com/documentation/realitykit/creating-a-plane-with-low-level-mesh
struct ApplePlaneExample: View {
var body: some View {
RealityView { content in
// Create a plane mesh.
if let planeMesh = try? PlaneMesh(size: [0.2, 0.2], dimensions: [16, 16]), let mesh = try? MeshResource(from: planeMesh.mesh) {
@Matt54
Matt54 / LightBeamSynthView.swift
Last active September 22, 2025 17:22
RealityView of light beam synth with touch gesture interactions
import AVFoundation
import SwiftUI
import RealityKit
#Preview { LightBeamSynthView() }
struct LightBeamSynthView: View {
@Environment(\.physicalMetrics) var physicalMetrics
@State var outerCylinderEntity: Entity?
@State var innerCylinderEntity: Entity?
@State var touchEntity: Entity?
@jamesporter
jamesporter / ContentView.swift
Created April 17, 2024 21:59
Metal and Swift(UI) Raymarching App
import SwiftUI
struct ContentView: View {
let startDate = Date()
var body: some View {
GeometryReader { gp in
TimelineView(.animation) { ctx in
Rectangle()
.ignoresSafeArea()
import SwiftUI
import RealityKit
import AVFoundation
import MetalKit
struct ImmersiveView: View {
@State var textureResource: TextureResource?
var body: some View {
RealityView { content in
@naphipps
naphipps / box2d_v3_alpha_task_api_with_npe.cpp
Last active June 25, 2024 19:17
Example of how to hook up to box2d V3-alpha task API
/*
I used this in sample.cpp/hpp of the box2d V3-alpha project.
This is just an example of a non-enkiTS job system used with box2d V3-alpha
- Nathan Phipps 1/14/24
*/
// --------- begin of inside sample.cpp ---------
@neubig
neubig / dispatch_openai_requests.py
Last active February 19, 2024 17:55
A simple script to get results from the OpenAI Asynchronous API
# NOTE:
# You can find an updated, more robust and feature-rich implementation
# in Zeno Build
# - Zeno Build: https://github.com/zeno-ml/zeno-build/
# - Implementation: https://github.com/zeno-ml/zeno-build/blob/main/zeno_build/models/providers/openai_utils.py
import openai
import asyncio
from typing import Any
@hirrolot
hirrolot / CoC.ml
Last active November 19, 2025 22:54
How to implement dependent types in 80 lines of code
type term =
| Lam of (term -> term)
| Pi of term * (term -> term)
| Appl of term * term
| Ann of term * term
| FreeVar of int
| Star
| Box
let unfurl lvl f = f (FreeVar lvl)
@d7samurai
d7samurai / .readme.md
Last active October 26, 2025 05:56
Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer

Minimal D3D11 sprite renderer: basic back-to-front sprite rendering reference code with example sprite sheet animation logic. As usual: Complete, runnable single-function app. No modern C++ / OOP / obscuring cruft.

adventurer

Swap out the sprite sheet with a font atlas for a lightweight GUI / text renderer. Clip individual sprites and glyphs by offsetting screenPos and atlasPos to top left corner of visible area and adjusting size accordingly (all values in pixels):

sprite.screenPos.x += 17;
sprite.screenPos.y += 10;
<!--
Go to Line 153 for the start of Uniform Buffer Object related code and intro
Prerequsite:
You at least know what uniforms are in the context of WebGL
and mininally understand the concepts involved in creating a square in WebGL
-->
<html>