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 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; |
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 BurnFadeParams_h | |
#define BurnFadeParams_h | |
struct BurnFadeParams { | |
float progress; | |
float scale; | |
float hueRotate; | |
float edgeWidth; | |
float emberRange; | |
}; |
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 | |
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 }) { |
NewerOlder