This file contains 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 AddBlendGlitchView: View { | |
@State var rootEntity: Entity? | |
@State private var offsetTimer: Timer? | |
@State var isOffset: Bool = false | |
@State private var jitterTimer: Timer? | |
@State private var rotationAngles: SIMD3<Float> = [0, 0, 0] | |
@State private var rotateAndScaleTimer: Timer? |
This file contains 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 SwiftUI | |
import RealityKit | |
struct SphereApproximationComparisonView: View { | |
var icospheres: [Entity] = (MeshQuality.allCases).map { quality in | |
return try! generateEntity(radius: 0.1, meshQuality: quality, type: .icosphere) | |
} | |
var gridSpheres: [Entity] = (MeshQuality.allCases).map { quality in | |
return try! generateEntity(radius: 0.1, meshQuality: quality, type: .grid) |
This file contains 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 TriangleCountView: View { | |
let generateSphereEntity = createEntity(resource: .generateSphere(radius: 0.5), material: getMaterial()) | |
let generateSpecificSphereEntity = try! createEntity(resource: .generateSpecificSphere(radius: 0.5, latitudeBands: 15, longitudeBands: 15), material: getMaterial()) | |
@State var numberOfLatitudeBands: Int = 15 | |
@State var numberOfLongitudeBands: Int = 15 | |
@State var sphereRadius: Float = 0.5 | |
This file contains 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 |
This file contains 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 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 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 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 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 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 |
NewerOlder