Skip to content

Instantly share code, notes, and snippets.

@drewolbrich
drewolbrich / Entity+Opacity.swift
Last active March 30, 2026 18:17
An Entity extension that supports animated changes the opacity of an entity and its descendants
//
// Entity+Opacity.swift
//
// Created by Drew Olbrich on 10/25/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / WindowBarGestureModifier.swift
Last active February 25, 2026 06:54
A visionOS RealityView view modifier that handles drag gestures
//
// WindowBarGestureModifier.swift
//
// Created by Drew Olbrich on 10/25/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / View+WindowGeometryPreferences.swift
Last active January 17, 2026 18:59
A visionOS SwiftUI view modifier that can be used to hide a window's resize handles or to constrain a window's aspect ratio
//
// View+WindowGeometryPreferences.swift
//
// Created by Drew Olbrich on 1/30/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / UIColor+Blended.swift
Last active January 9, 2026 21:16
Blends together two UIColors, returning a dynamic color
//
// UIColor+Blended.swift
//
// Created by Drew Olbrich on 5/16/21.
// Copyright © 2021 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / Scene+ImmersiveEnvironmentBehavior_visionOS26.swift
Last active August 25, 2025 23:26
A wrapper around immersiveEnvironmentBehavior that applies it only on visionOS 26.0 and later, and is a no-op on earlier versions of visionOS
//
// Scene+ImmersiveEnvironmentBehavior_visionOS26.swift
//
// Created by Drew Olbrich on 8/20/25.
// Copyright © 2025 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / UIView+HitTest.swift
Created June 18, 2025 15:41
Replacement for UIView.hitTest(_:with:) that detects hits on subviews outside the bounds of the parent view
//
// UIView+HitTest.swift
//
// Created by Drew Olbrich on 2/5/20.
// Copyright © 2022 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / MeshEntity+GenerateSolidInteriorModel.swift
Last active May 20, 2025 14:01
A RealityKit ModelEntity extension that replaces its model with a new model with reversed triangle indices
//
// MeshEntity+GenerateSolidInteriorModel.swift
//
// Created by Drew Olbrich on 12/16/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / View+WindowBarVisibility.swift
Created May 16, 2025 15:19
A view modifier that wraps `persistentSystemOverlays` and gives it a more memorable and descriptive name on visionOS
//
// View+WindowBarVisibility.swift
//
// Created by Drew Olbrich on 5/15/25.
// Copyright © 2025 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / ShaderGraphMaterial+LoadFileAsync.swift
Last active May 15, 2025 03:51
A wrapper around ShaderGraphMaterial(named:from:in:) with helpful comments about unrecognized shader graph properties for "Error 1"
//
// ShaderGraphMaterial+LoadFileAsync.swift
//
// Created by Drew Olbrich on 5/14/25.
// Copyright © 2025 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@drewolbrich
drewolbrich / ScaledVolumeContentView.swift
Last active April 1, 2025 23:56
An example of how to make visionOS volumes work correctly with Settings > Display > Appearance > Window Zoom
//
// ScaledVolumeContentView.swift
// VolumeScaleExample
//
// Created by Drew Olbrich on 11/6/23.
// Copyright © 2023 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy