Skip to content

Instantly share code, notes, and snippets.

View warpling's full-sized avatar

Ryan McLeod warpling

View GitHub Profile
@Matt54
Matt54 / MeshResource+generateSpecificSphere.swift
Last active July 9, 2024 13:10
Creates a sphere MeshResource with a specified number of latitude and longitude bands (for lower poly sphere)
extension MeshResource {
static func generateSpecificSphere(radius: Float, latitudeBands: Int = 10, longitudeBands: Int = 10) throws -> MeshResource {
let vertexCount = (latitudeBands + 1) * (longitudeBands + 1)
let indexCount = latitudeBands * longitudeBands * 6
var desc = MyVertex.descriptor
desc.vertexCapacity = vertexCount
desc.indexCapacity = indexCount
let mesh = try LowLevelMesh(descriptor: desc)
@Matt54
Matt54 / FibonacciLatticeView.swift
Created July 9, 2024 01:02
RealityKit View using fibonacci lattice to evenly distribute points around a sphere
import RealityKit
import SwiftUI
struct FibonacciLatticeView: View {
@State private var rotationAngles: SIMD3<Float> = [0, 0, 0]
@State private var modulationTimer: Timer?
@State private var time: Double = 0.0
@State private var lastRotationUpdateTime = CACurrentMediaTime()
let overallSphereRadius: Float = 0.0875
@KhaosT
KhaosT / Cloud Gaming on Apple Vision Pro.md
Last active July 13, 2024 18:23
Guide for clouding gaming on Apple Vision Pro

Cloud Gaming on Apple Vision Pro

GeForce Now

Cloud Gaming is a great way to enjoy graphically demanding games on Apple Vision Pro.

Since Safari on visionOS does not support PWA mode, here is how you can access cloud gaming services on Apple Vision Pro.

What’s needed

/*
* Copyright (C) 2023 Daniel Levi
*
* Originally based on Apple's header for WebKit. The file within this repo
* named LICENSE_APPLE contains the copyright notice provided by Apple
*
* This header is based on my own disassembly of libMobileGestalt and contains
* 760 keys that should support any iOS version up until iOS 17.
*
*/
@dejager
dejager / RoundedPolygon.swift
Created October 18, 2022 05:57
A SwiftUI Shape that draws a polygon with a given number of corners and a corner radius.
//
// RoundedPolygon.swift
//
// Created by Nate on 2022-10-17.
//
import SwiftUI
struct RoundedPolygon: Shape {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
for (i, view) in scrollView.subviews.enumerated() {
var ty = 0.0
if scrollView.contentOffset.y < 0 {
// We're scrolling past the top of the scroll view.
// Translate each item in the scroll view by some amount based on its index and scroll offset.
ty = CGFloat(i) * abs(offsetY) / 8.0 * pow(1.12, CGFloat(i))
}
view.transform = CGAffineTransform(translationX: 0, y: ty)
}
@PimCoumans
PimCoumans / AnimationSequece.swift
Last active May 21, 2024 15:12
Simple way to chain and group multiple UIView animations
import UIKit
protocol StepAnimatable {
/// Start a sequence where you add each step in the `addSteps` closure. Use the provided `AnimationSequence` object
/// to add each step which should either be an actual animation or a delay.
/// The `completion` closure is executed when the last animation has finished.
/// - Parameters:
/// - addSteps: Closure used to add steps to the provided `AnimationSequence` object
/// - completion: Executed when the last animation has finished.
@PimCoumans
PimCoumans / UIView+TimingFunction.swift
Last active April 22, 2022 09:51
Adds CAMediaTimingFunction to UIView animation using a convenient CATransaction wrapper method
extension CATransaction {
/// Executes the provided `actions` closure wrapped in `CATransaction`.
/// Optionally adds all the specific properties to commit the transaction with
/// - Parameters:
/// - duration: Duration of transaction
/// - timingFunction: Specific timing function to use with transaction
/// - disableActions: Wether actual animation should happen during transaction
/// - actions: What to do while transaction is commited
/// - completion: Closure to be executed when transaction is completes
///
import Foundation
extension CFRunLoop {
static func performNext(work: @escaping () -> Void) {
CFRunLoopPerformBlock(CFRunLoopGetMain(), CFRunLoopMode.defaultMode.rawValue, work)
}
}
global.THREE = require("three");
const canvasSketch = require('canvas-sketch');
const Random = require('canvas-sketch-util/random');
const gradientHeight = 512;
const settings = {
dimensions: [ 2048, gradientHeight * 2 ]
};