What I'm try to do, is replicate some digital instrument gauge ...using Spritekit..
On my project I have to use a SpriteKit Scene as material for Scenekit SCNnode.
In order to do that I create a sub class of SKscene and and apply it as "material.diffuse.contents" of the SCNNode.
all working fine, I can see my SKscene as material of the SCNNode.
Here the issue:
I try to animate/replicate the correct indication of the instrument based of some value my app received from other source.
To do so, i decide to use the SKsceneDelegate and use the method "update(_ currentTime: TimeInterval)"
simply the update method look for the sknode of the green needle "fulcro" remove it , and make a new line calculating the angle and new coordinate for the new line.
Like this I should have a smooth needle indication...
Here is the update method inside my subclass SKscene:
override func update(_ currentTime: TimeInterval) {
guard let fulcroToRemove = self.childNode(withName: "fulcro") else {return}
fulcroToRemove.removeFromParent() // issue here...
let fulcro = SKNode()
fulcro.name = "fulcro"
fulcro.position = CGPoint(x: 300, y: 260)
let line = makeLine(startPos: CGPoint(x: 0, y: 0),
endPos: getCoordinate(angleDeg: getCurrentEGT()),
name: "EGT_LINE")
fulcro.addChild(line)
self.addChild(fulcro)
}
here how I apply the material SKscene to my SCNnode
class LowerECAM : SCNNode {
var systems: PlaneSystems
init(systems: PlaneSystems) {
self.systems = systems
super.init()
createLowerECAM()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented for Make Cockpit")
}
func createLowerECAM(){
systems.lowerECAMView.presentScene(systems.newAPU)
let plane = SCNPlane(width: 1, height: 1)
let material = SCNMaterial()
material.isDoubleSided = true
material.diffuse.contents = systems.lowerECAMView.scene // apply here
plane.materials = [material]
let lowerECAM = SCNNode(geometry: plane)
lowerECAM.eulerAngles = SCNVector3(deg2rad(180), deg2rad(90), 0)
lowerECAM.scale = SCNVector3(3.3, 3.3, 3.3)
self.name = "LowerECAM"
self.addChildNode(lowerECAM)
}
func deg2rad(_ number: Double) -> Double {
return number * .pi / 180
}
func rad2deg(_ number: Double) -> Double {
return number * 180 / .pi
}
}
But.. I'm getting the following crash:
Question?? why scene kit crash when the render I'm using is the Spritekit render.. ?? I did't even write the SceneKit render method..
The issue looks like is when I remove the "fulcro" but I can't find the solution.
I tried to make a new project only with spritekit and it works perfect.. can't understand why as material of SCNode it crash.
Any Suggestion.. Appreciate..
Thanks a lot
Post
Replies
Boosts
Views
Activity
Hi guys, in one of the video of WWDC 21 I saw this spectacular image of a green fluid over the sofa 🛋
i can’t find to much tutorial online, How could be done this? I was looking into the particle system of SceneKit but looks like not doing exactly the same think( is more for smoke and fire)
this fluid look more 3D.
what I should look for reproduce this fluid.. thanks
Looking for some help to start my research.
Hello, I created in Blender a simple cube with 2 animations, one animation move up and down the cube and second one rotating cube on his position.
I exported this file in glb format and I tried to converted using Reality Converter, unfortunately I can only see 1 animation.
Is there any limitation of Reality Converter? Can I include more than 1 animation?
The original file glb has the 2 animation inside, as you can see from the screenshot I checked the file using a online viewer for glb and there are no problem, both animations are in.
The converter unfortunately see only the last one created.
Any reason or explanation? I believe is a limitation on Reality Converter
Regards
I wrote this simple app to try to fetch and add data to my airport Database in the background.
I'm trying to add some data to the airport table in the background using swift-data, I create a loop that should add and save 100 test airports in a table but when I run the code I only get add 1 airport at the time and the number get add is random, any idea why?
How to use swiftData in the background? So far not so many examples.
actor JsonImporter: ModelActor {
let executor: any ModelExecutor
let context: ModelContext
init(modelContainer: ModelContainer) {
context = ModelContext(modelContainer)
executor = DefaultModelExecutor(context: context)
}
func parseJsonDBAirport() async {
for i in 1...100{
print("loop \(i)")
let airport = Airport(lastPicked: Date(), icao: "test \(i)")
context.insert(airport)
do{
try context.save()
}catch {
print("Error")
}
}
}
}
Using on the view:
struct SettingsView: View {
@Environment (\.modelContext) var mc
var body: some View {
Button {
Task(priority: .background){
let importer = JsonImporter(modelContainer: mc.container)
await importer.parseJsonDBAirport()
}
} label: {
Text("Parse Json airport")
}
NavigationLink {
Airports(dm: dm)
} label: {
HStack{
Image(systemName: "person.2.badge.gearshape.fill")
Text("Airports")
}
}
}
}
my main actor is following:
@main
struct Pilot_VisionApp: App {
var dm = DataManager.shared
var body: some Scene {
WindowGroup {
SettingsView(dm: dm)
}
.modelContainer(for: [UserModel.self, Flight.self, Aircraft.self, CrewModel.self, Airport.self])
}
}
and the airport list as following:
import SwiftUI
import SwiftData
struct Airports: View {
let dm: DataManager
@Query(filter: nil, sort: [SortDescriptor(\Airport.lastPicked)], animation: .default) var airports: [Airport]
var body: some View {
List{
Text("Airport Contains : \(airports.count)")
ForEach(airports) { apt in
Text("icao: \(apt.icao ?? "")")
}
}
}
}
not sure why when I press the button the loop runs correctly I get the printout 100 times but when I open the list of my airport I only see 1 airport saved, every time I press the button one more airport is added to the table but should be 100 airports every time I press the button.
How shuld be use swiftdata in background?
thanks
I just updated xcode 15.2 and I want to try to use Reality Composer Pro, I saw on the Apple developer video that it should be under Xcode -> developer tool -> Reality Composer Pro but when I open that I don't have Composer.
On the Apple webpage for Rality Composer is written "Reality Composer for macOS is bundled with Xcode, which is available on the Mac App Store."
Where i can find the Composer Pro?
Thanks
Hello, I’m trying to move my app into vision OS, my app is used for pilot to study the airplane system, is a 3d airplane cockpit build with scene kit and I use sprite scene to animate the cockpit instruments .
Scenekit allow to apply as material a sprite scene , so I could animate easy all the different instruments and indication there, but I can’t find this option on reality compose pro , is this possible? any suggestions I can look into to animate and simulate instruments.
try to update my app from iOS 17 to io 18, I'm using SwiftData to save the data on the memory, on iOS 17 all works fine but I tried to export my app to iOS 18 and I get a strange error when I try to delate a playlist from SwiftData memory.
Thread 10: Fatal error: Never access a full future backing data - PersistentIdentifier(id: SwiftData.PersistentIdentifier.ID(url: x-coredata://4885953A-BDB2-4CD1-9299-B2FBBB899EB7/PlaylistItem/p372), implementation: SwiftData.PersistentIdentifierImplementation) with Optional(B2A80504-2FE1-4C86-8341-3DDE8B6AB913)
the code where this error happen is very simple,
func deletePlaylist(_ playlist: PlayListModel) async throws {
print("attempt to delate :, \(playlist.playlistName)")
context.delete(playlist)
try context.save() // error here on the save
}
Error only happen on iOS 18 not on the 17.
I’m unable to install iOS 18.1 on my device , the update not show up on the developer beta update, how can I fix .
i already installed ios 18, I have over 200 GB of space and I have an iPhone 15 pro max .
I’m developing an app for IPTV where users can add their own links to TV channels and watch them through the app. Since not all IPTV links use HTTPS, I’ve set NSAllowsArbitraryLoads to true in the Info.plist.
Apple mentions that if you set this to true, you need to provide an explanation. What kind of explanation do they require, and how should I provide it?
Thanks!