Reputation: 4983
I follow Spline docs here: https://docs.spline.design/doc/-/docFKClkdmir#download-xcode-demo then downloaded source code demo and tried to run on XCode, but 3D avatar did now show up.
There are no error on XCode console.
import SwiftUI
import SplineRuntime
struct ContentView: View {
var body: some View {
VStack {
ScrollView(.horizontal, showsIndicators: false) {
HStack {
ForEach(itemsData.items) { item in
ZStack {
Circle()
.frame(width: 300, height: 300)
.foregroundColor(item.color)
// Using SplineView with URL
if let url = URL(string: item.url) {
SplineView(sceneFileURL: url)
.frame(width: 470, height: 470)
.cornerRadius(300)
.scrollTransition { content, phase in
content
.scaleEffect(phase.isIdentity ? 1 : 0.75)
}
}
}
.containerRelativeFrame(.horizontal, count: 1, spacing: 0)
.scrollTransition { content, phase in
content
.opacity(phase.isIdentity ? 1 : 0.5)
.scaleEffect(phase.isIdentity ? 1 : 0.75)
}
}
}
.frame(height: 200)
.scrollTargetLayout()
}
.contentMargins(64, for: .scrollContent)
.scrollTargetBehavior(.viewAligned)
// Other UI components remain unchanged
Text("Pick your avatar")
.font(.system(size: 24))
.padding()
.padding()
Button("I like it!") {}
.fontWeight(.bold)
.font(.system(size: 20))
.foregroundColor(.white)
.padding()
.frame(width: 198, height: 70)
.background(
Color(red: 1, green: 0.36, blue: 0.36)
.cornerRadius(40)
.shadow(color: Color.red.opacity(0.4), radius: 10, y: 12)
)
}
.statusBar(hidden: true)
}
}
struct Item: Identifiable {
let id = UUID()
let color: Color
let url: String
}
struct itemsData {
static var items = [
//To duplicate and remix the Spline scene go to -> https://app.spline.design/file/a2770bba-eb91-4dce-9cec-44857322d7ad
Item(color: Color(red: 1, green: 0.36, blue: 0.36), url: "https://build.spline.design/apai3cgJoCAFm2n0Pp7C/scene.splineswift"),
//To duplicate and remix the Spline scene go to -> https://app.spline.design/file/5f77c44e-411e-4420-93ac-438fe058c4ae
Item(color: .teal, url: "https://build.spline.design/Et5hpzdGRTjv3AN3uCIL/scene.splineswift"),
//To duplicate and remix the Spline scene go to -> https://app.spline.design/file/30f38922-2b3f-488e-bc78-14dd25fd2ba1
Item(color: .yellow, url: "https://build.spline.design/jTcGoCgzb7UnfLMJd2cP/scene.splineswift")
]
}
Any help!
Upvotes: 0
Views: 27