This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import ModelIO | |
| import simd | |
| nonisolated func loadMeshWithModelIO(from url: URL) throws -> TriangleMesh { | |
| let asset = MDLAsset(url: url) | |
| guard asset.count > 0 else { | |
| throw NSError(domain: "ModelIO", code: 1, userInfo: [NSLocalizedDescriptionKey: "No objects found in file"]) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Metal | |
| import RealityKit | |
| import SwiftUI | |
| #Preview { ExtrudedTextLowLevelMeshView() } | |
| struct ExtrudedTextLowLevelMeshView: View { | |
| @State var lowLevelMesh: LowLevelMesh? | |
| @State var originalVerticesBuffer: MTLBuffer? | |
| @State var timer: Timer? | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef MarchingCubesColorBlobParams_h | |
| #define MarchingCubesColorBlobParams_h | |
| #include <simd/simd.h> | |
| typedef struct { | |
| simd_float3 center; | |
| float radius; | |
| simd_float3 color; | |
| float _pad; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef MarchingCubesBlobParams_h | |
| #define MarchingCubesBlobParams_h | |
| #include <simd/simd.h> | |
| typedef struct { | |
| simd_float3 center; | |
| float radius; | |
| } Sphere; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef HeightMapParams_h | |
| #define HeightMapParams_h | |
| struct HeightMapParams { | |
| simd_float2 size; | |
| simd_uint2 dimensions; | |
| }; | |
| #endif /* HeightMapParams_h */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RealityKit | |
| import SwiftUI | |
| struct BubbleRealityView: View { | |
| @State private var currentEntity: Entity? | |
| @State private var morphFactor: Float = 0.0 | |
| @State private var frameDuration: TimeInterval = 0.0 | |
| @State private var lastUpdateTime = CACurrentMediaTime() | |
| static let animationFrameDuration: TimeInterval = 1.0 / 120.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AVFoundation | |
| /** | |
| * AVAssetExportSession is initialized with an AVComposition, and that composition and all of its constituent | |
| * components are not sendable. Because `composition` is isolated to the main actor here, the call to the | |
| * non-isolated method `export(to:as:)` sends it across an isolation region and that is unsafe. | |
| */ | |
| @MainActor | |
| class UnsafeMovieExporter { | |
| let composition = AVMutableComposition() |
NewerOlder