Skip to content

Instantly share code, notes, and snippets.

View SergeiMeza's full-sized avatar

Sergei Meza SergeiMeza

View GitHub Profile
@Matt54
Matt54 / EasingCurve.swift
Last active October 5, 2025 18:27
RealityKit Explode and Assemble SDF Shape (Metal + LowLevelMesh + Marching Cubes)
import Foundation
enum EasingCurve {
case linear
case easeIn(Float)
case easeOut(Float)
case easeInOut(Float)
func apply(_ t: Float) -> Float {
let t = max(0, min(1, t))
@Matt54
Matt54 / MarchingCubesColorBlobParams.h
Last active November 21, 2025 20:55
RealityKit Color-Blending Metaballs (Metal + LowLevelMesh + Marching Cubes)
#ifndef MarchingCubesColorBlobParams_h
#define MarchingCubesColorBlobParams_h
#include <simd/simd.h>
typedef struct {
simd_float3 center;
float radius;
simd_float3 color;
float _pad;
@Matt54
Matt54 / MarchingCubesBlobParams.h
Created August 19, 2025 23:21
RealityKit Marching Cubes Blob (Metal + LowLevelMesh)
#ifndef MarchingCubesBlobParams_h
#define MarchingCubesBlobParams_h
#include <simd/simd.h>
typedef struct {
simd_float3 center;
float radius;
} Sphere;
@Matt54
Matt54 / SDFPrimitives.metal
Created August 13, 2025 03:45
LowLevelMesh shape shifting with Marching Cubes and SDF interpolation
#include <metal_stdlib>
using namespace metal;
#define SDFShapeTypeSphere 0u
#define SDFShapeTypeBox 1u
#define SDFShapeTypeTorus 2u
#define SDFShapeTypeRoundedBox 3u
#define SDFShapeTypeBoxFrame 4u
#define SDFShapeTypeLink 5u
#define SDFShapeTypeOctahedron 6u
@Matt54
Matt54 / MarchingCubesParams.h
Last active September 22, 2025 17:20
Marching Cubes Metaballs in RealityKit (Metal + LowLevelMesh)
#ifndef MarchingCubesParams_h
#define MarchingCubesParams_h
#include <simd/simd.h>
struct MarchingCubesParams {
simd_uint3 cells;
simd_float3 origin;
simd_float3 cellSize;
float isoLevel;
simd_float3 centerA;
@Matt54
Matt54 / AnimatingTorusSystem.swift
Created July 20, 2025 12:40
RealityKit LowLevelMesh Glowing Torus Spinner
import RealityKit
public struct AnimatingTorusSystem: System {
public init(scene: RealityKit.Scene) {}
public func update(context: SceneUpdateContext) {
let entities = context.entities(matching: Self.query,
updatingSystemWhen: .rendering)
for torus in entities.compactMap({ $0 as? LoopingTorusEntity }) {
@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?
@yusuke024
yusuke024 / ViewController.swift
Created November 16, 2018 03:15
Recording video with AVAssetWriter
import UIKit
import AVFoundation
class ViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
switch AVCaptureDevice.authorizationStatus(for: .video) {
case .notDetermined: