Skip to content

Instantly share code, notes, and snippets.

View SergeiMeza's full-sized avatar

Sergei Meza SergeiMeza

View GitHub Profile
@SergeiMeza
SergeiMeza / LightBeamSynthView.swift
Created September 22, 2025 17:22 — forked from Matt54/LightBeamSynthView.swift
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?
@SergeiMeza
SergeiMeza / MarchingCubesParams.h
Created September 22, 2025 17:20 — forked from Matt54/MarchingCubesParams.h
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;
@SergeiMeza
SergeiMeza / SDFPrimitives.metal
Created September 22, 2025 17:19 — forked from Matt54/SDFPrimitives.metal
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
@SergeiMeza
SergeiMeza / AnimatingTorusSystem.swift
Created September 22, 2025 17:19 — forked from Matt54/AnimatingTorusSystem.swift
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 }) {
@SergeiMeza
SergeiMeza / MarchingCubesBlobParams.h
Created September 22, 2025 16:45 — forked from Matt54/MarchingCubesBlobParams.h
RealityKit Marching Cubes Blob (Metal + LowLevelMesh)
#ifndef MarchingCubesBlobParams_h
#define MarchingCubesBlobParams_h
#include <simd/simd.h>
typedef struct {
simd_float3 center;
float radius;
} Sphere;
@SergeiMeza
SergeiMeza / MarchingCubesColorBlobParams.h
Created September 22, 2025 15:37 — forked from Matt54/MarchingCubesColorBlobParams.h
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;
@SergeiMeza
SergeiMeza / EasingCurve.swift
Created September 22, 2025 15:36 — forked from Matt54/EasingCurve.swift
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))

Videos

@SergeiMeza
SergeiMeza / Firecloud Nearby GeoQuery
Created September 20, 2018 12:15 — forked from zirinisp/Firecloud Nearby GeoQuery
Firecloud Nearby GeoQuery
import CoreLocation
extension CLLocationCoordinate2D {
func boundingBox(radius: CLLocationDistance) -> (max: CLLocationCoordinate2D, min: CLLocationCoordinate2D) {
// 0.0000089982311916 ~= 1m
let offset = 0.0000089982311916 * radius
let latMax = self.latitude + offset
let latMin = self.latitude - offset
// 1 degree of longitude = 111km only at equator
@SergeiMeza
SergeiMeza / country_codes.json
Created September 11, 2018 19:56 — forked from orenitamar/country_codes.json
Two letter country code mapping, grouped by continent/region
{
"europe": {
"va": "vatican city",
"ch": "switzerland",
"ad": "andorra",
"ee": "estonia",
"is": "iceland",
"am": "armenia",
"al": "albania",
"cz": "czech republic",