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 ImageSphere: View { | |
let cgImage: CGImage | |
@State private var rotationAngle: Float = 0 | |
@State private var previousSize: SIMD3<Float> = .zero | |
var body: some View { | |
GeometryReader3D { proxy in |
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 GradientTextureSphereView: View { | |
let cgImage: CGImage | |
@State private var rotationAngle: Float = 0 | |
@State private var previousSize: SIMD3<Float> = .zero | |
var body: some View { | |
GeometryReader3D { proxy in |
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 OpacityThresholdSphere: View { | |
let outerCGImage: CGImage | |
let innerCGImage: CGImage | |
@State private var outerEntity: Entity? | |
@State private var innerEntity: Entity? | |
@State private var rotationAngle: Float = 0 | |
@State private var frameDuration: TimeInterval = 0.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 RealityKit | |
import SwiftUI | |
struct GlowingSphere: View { | |
@State private var opacity: Float = 1.0 | |
@State private var isForward: Bool = false | |
var body: some View { | |
GeometryReader3D { proxy in | |
RealityView { content in |
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 FlowerPetal: View { | |
@State private var rotationAngle: Float = 0 | |
var body: some View { | |
RealityView { content in | |
let leafEntity = try! leafEntity() | |
content.add(leafEntity) |
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 GlowingLowPolySphere: View { | |
@State private var opacity: Float = 1.0 | |
@State private var isForward: Bool = false | |
@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() |
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 AddBlendModeView: View { | |
var isSphereOnTop: Bool = true | |
@State var rootEntity: Entity? | |
var body: some View { | |
RealityView { content in | |
} update: { content in |
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 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 |
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
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) |
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 ExtrudedTextView: View { | |
let entity: Entity = try! getEntity() | |
var body: some View { | |
RealityView { content in | |
// hack to align text in volume | |
entity.transform.translation.x -= 0.21 |