-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All code changes and content added for visionOS video #2
- Loading branch information
Showing
42 changed files
with
740 additions
and
311 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// | ||
// CapsuleDetails.swift | ||
// Inspiration4 | ||
// | ||
// Created by Dilmer Valecillos on 10/8/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CapsuleDetails: View { | ||
@State private var orbitOn = false | ||
@State private var lightOn = true | ||
@State private var isShowing = false | ||
|
||
let turnOnLight: () -> Void | ||
let turnOffLight: () -> Void | ||
let turnOnOrbit: () -> Void | ||
let turnOffOrbit: () -> Void | ||
|
||
var body: some View { | ||
VStack { | ||
Button { | ||
isShowing.toggle() | ||
} label: { | ||
Label("Rocket Options", systemImage: "gear") | ||
} | ||
.controlSize(.mini) | ||
.font(.system(size: 10)) | ||
} | ||
if isShowing { | ||
VStack { | ||
Text("The Dragon spacecraft is capable of carrying up to 7 passengers to and from Earth orbit, and beyond. It is the only spacecraft currently flying that is capable of returning significant amounts of cargo to Earth, and is the first private spacecraft to take humans to the space station.") | ||
.font(.system(size: 8)) | ||
|
||
HStack(alignment:.top) { | ||
VStack(alignment:.leading) { | ||
Toggle(isOn: $lightOn){ | ||
Text("Light \(!lightOn ? "Off" : "On")") | ||
.font(.system(size: 8, weight:. bold)) | ||
.onChange(of: lightOn, { | ||
if lightOn { | ||
turnOnLight() | ||
} | ||
else | ||
{ | ||
turnOffLight() | ||
} | ||
}) | ||
} | ||
} | ||
|
||
VStack(alignment:.leading) { | ||
Toggle(isOn: $orbitOn){ | ||
Text("Orbit \(!orbitOn ? "Off" : "On")") | ||
.font(.system(size: 8, weight:. bold)) | ||
.onChange(of: orbitOn, { | ||
if orbitOn { | ||
turnOnOrbit() | ||
} | ||
else | ||
{ | ||
turnOffOrbit() | ||
} | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
.padding(EdgeInsets(top: 5, leading: 25, bottom: 0, trailing: 25)) | ||
.frame(width: 300, height: 120) | ||
.glassBackgroundEffect() | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// EquipmentCard.swift | ||
// Inspiration4 | ||
// | ||
// Created by Dilmer Valecillos on 10/8/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct EquipmentCard: View { | ||
@Binding var isShowing: Bool | ||
let toggleTitle: String | ||
let imageName: String | ||
let openCard: () async -> Void | ||
let dismissCard: () async -> Void | ||
|
||
var body: some View { | ||
VStack { | ||
Image(imageName) | ||
.resizable() | ||
.frame(width: 300, height: 300) | ||
.padding(20) | ||
|
||
Toggle(isShowing ? "Hide \(toggleTitle)" : "Show \(toggleTitle)", isOn: $isShowing) | ||
.onChange(of: isShowing, initial: false) { isShowing, initial in | ||
Task { | ||
if !isShowing { | ||
await openCard() | ||
} else { | ||
await dismissCard() | ||
} | ||
} | ||
} | ||
.toggleStyle(.button) | ||
.padding(25) | ||
} | ||
.glassBackgroundEffect() | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Credits to Apple for providing this example! | ||
import RealityKit | ||
|
||
extension Entity { | ||
func setSunlight(intensity: Float?) { | ||
if let intensity { | ||
Task { | ||
guard let resource = try? await EnvironmentResource(named: "Sunlight") else { return } | ||
var iblComponent = ImageBasedLightComponent( | ||
source: .single(resource), | ||
intensityExponent: intensity) | ||
|
||
components.set(iblComponent) | ||
components.set(ImageBasedLightReceiverComponent(imageBasedLight: self)) | ||
} | ||
} else { | ||
components.remove(ImageBasedLightComponent.self) | ||
components.remove(ImageBasedLightReceiverComponent.self) | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.