-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
579423d
commit 403ed16
Showing
10 changed files
with
129 additions
and
0 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
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
40 changes: 40 additions & 0 deletions
40
Sources/LiveViewNativeRealityKit/Modifiers/RealityViewCameraControlsModifier.swift
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,40 @@ | ||
// | ||
// RealityViewCameraControlsModifier.swift | ||
// | ||
// | ||
// Created by Carson.Katri on 7/25/24. | ||
// | ||
|
||
#if os(iOS) || os(macOS) | ||
import LiveViewNative | ||
import LiveViewNativeStylesheet | ||
import SwiftUI | ||
import RealityKit | ||
|
||
@ParseableExpression | ||
struct _RealityViewCameraControlsModifier: ViewModifier { | ||
public static var name: String { "realityViewCameraControls" } | ||
|
||
let controls: CameraControls | ||
|
||
init(_ controls: CameraControls) { | ||
self.controls = controls | ||
} | ||
|
||
func body(content: Content) -> some View { | ||
content.realityViewCameraControls(controls) | ||
} | ||
} | ||
|
||
extension CameraControls: ParseableModifierValue { | ||
public static func parser(in context: ParseableModifierContext) -> some Parser<Substring.UTF8View, Self> { | ||
ImplicitStaticMember([ | ||
"dolly": .dolly, | ||
"none": .none, | ||
"orbit": .orbit, | ||
"pan": .pan, | ||
"tilt": .tilt, | ||
]) | ||
} | ||
} | ||
#endif |
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
31 changes: 31 additions & 0 deletions
31
Sources/LiveViewNativeRealityKit/Types/RealityViewCamera+AttributeDecodable.swift
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,31 @@ | ||
// | ||
// RealityViewCamera+AttributeDecodable.swift | ||
// | ||
// | ||
// Created by Carson.Katri on 7/25/24. | ||
// | ||
|
||
#if os(iOS) || os(macOS) | ||
import LiveViewNative | ||
import LiveViewNativeCore | ||
import RealityKit | ||
import SwiftUI | ||
|
||
extension RealityViewCamera: AttributeDecodable { | ||
public init(from attribute: Attribute?, on element: ElementNode) throws { | ||
guard let value = attribute?.value | ||
else { throw AttributeDecodingError.missingAttribute(Self.self) } | ||
|
||
switch value { | ||
case "virtual": | ||
self = .virtual | ||
case "worldTracking": | ||
self = .worldTracking | ||
default: | ||
throw AttributeDecodingError.badValue(Self.self) | ||
} | ||
} | ||
} | ||
#else | ||
typealias RealityViewCamera = String | ||
#endif |