Skip to content

Instantly share code, notes, and snippets.

@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+WindowGeometryPreferences.swift
Last active May 9, 2025 22:53
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 / View+AttachmentPivot.swift
Last active August 11, 2024 03:36
A view modifier that sets the pivot position when the view is used as a ViewAttachmentEntity in a RealityView
//
// View+AttachmentPivot.swift
//
// Created by Drew Olbrich on 4/11/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 / ScrollViewProxy+ScrollToAnimated.swift
Created May 11, 2024 22:22
A wrapper for ScrollViewProxy/scrollTo that works around a bug where withAnimation doesn't always work
//
// ScrollViewProxy+ScrollToAnimated.swift
//
// Created by Drew Olbrich on 5/11/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 / CoordinateSpaceAxesEntity.swift
Last active May 14, 2024 23:42
A RelaityKit entity that draws coordinate space axes
//
// CoordinateSpaceAxesEntity.swift
//
// Created by Drew Olbrich on 7/8/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 / DefaultWindowPlacement_visionOS2.swift
Last active August 11, 2024 03:35
A wrapper around SwiftUI defaultWindowPlacement that is a no-op on visionOS 1
//
// DefaultWindowPlacement_visionOS2.swift
//
// Created by Drew Olbrich on 6/11/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 / VolumeWorldAlignment_visionOS2.swift
Last active August 11, 2024 03:35
A wrapper around visionOS 2 volumeWorldAlignment that is a no-op in visionOS 1
//
// VolumeWorldAlignment_visionOS2.swift
//
// Created by Drew Olbrich on 6/15/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 / VolumeBaseplateVisibility_visionOS2.swift
Last active August 11, 2024 03:34
A wrapper around volumeBaseplateVisibility that applies it only on visionOS 2 and later, and is a no-op on visionOS 1
//
// VolumeBaseplateVisibility_visionOS2.swift
//
// Created by Drew Olbrich on 6/25/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 / InputNotWorkingIndicator.swift
Last active August 11, 2024 03:33
A recreation of the Mac Virtual Display "Input temporarily not working" indicator
//
// InputNotWorkingIndicator.swift
//
// Created by Drew Olbrich on 6/26/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 / PushWindow_visionOS2.swift
Last active August 12, 2024 02:45
A workaround for pushWindow not being available on visionOS 1.
//
// PushWindow_visionOS2.swift
//
// Created by Drew Olbrich on 7/1/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