SceneKit

RSS for tag

Create 3D games and add 3D content to apps using high-level scene descriptions using SceneKit.

Posts under SceneKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

SceneKit.write to DAE(Collada) format output binary file instead of Collada XML
I am using Scenekit.write method to export a scene data to DAE(Collada) format. File is exported correctly but it's not a collada XML file rather a binary file. With more investigation I found an Apple binary pList file, And while renaming it's extension to pList, I can view geometry data as standard plist. This file is opening in XCode but not in any other DAE viewer. I am on Xcode 14.3 and IOS 16.
0
0
450
May ’23
Accessing SubViews in SwiftUI, as seen in UIKit
Is there a way to mimic this functionality found in UIKit in SwiftUI? Long story short, I am creating an interactive SceneKit view (currently in UIKit) that anchors 2D UIViews over nodes, for navigation and labelling. I would like to migrate over to SwiftUI, but I am having difficulties mimicking this functionality. let subViews = self.view.subviews.compactMap{$0 as? UIButton} if let view = subViews.first(where: {$0.currentTitle == label}) { view.center = self.getScreenPoint(renderer: renderer, node: node) } Can anyone help me with this? Thanks!
1
1
1.7k
Apr ’23
Exporting DAE animations for Scenekit
I checked out the FOX2 example for Scenekit that showcases the new animation protocol. I was rooting around in the character files trying todiscover how they were organizned, and noticed that the following files had no geometry only the rig for the animation and hence the animationdata as well.These are the files that I'm referring to:•max_idle.sc•max_jump.scn•max_spin.scnHow were these created and exported for Scenekit and with which exporter? Maya, Max, C4D? OpenCollada?What are the recommended settings? How do you export just rigs and animation data for Scenekit without the model? A shoutout to the Scenkit dev team: you guys are creating an amazing game engine(thank you), it's well organized and easy to use.However but you're neglecting a very important aspect. There are no tutorials on how to export authored content files(modles with rigs and animation) for Scenekit. This is super important information, and without putting some more thought into how to teach people how to do this, your framework will continue to see very little adoption.Please, please begin to address this. With ARKit combined with Scenekit you have good chance of seeing many people use this framework.
12
1
12k
Apr ’23
RoomPlan API
I am using RoomPlan API in my application. Working fine for small apartments but when I am trying to scan a bigger apartment which takes more time greater than 15 minutes the API automatically stopped and finished the scan even though part of the apartment is still pending scanning. I need the original structure like a point cloud in 3D, the USDZ model has a white mesh structure. Is there any way to get a real 3D view from RoomPlan API or USDZ model. How I can change the colour of scanning lines. I am getting RSFloorPlan class value when scanning finished. How I can get this Floor Plan, I mean I need its 2d structure as we what we are scanning. Thanks! Ramneet Singh (iOS developer)
2
1
2.4k
Apr ’23
SwiftUI version of centring multiple subviews at once, as seen in UIKit (SCNSceneRendererDelegate)
I have been using UIKit to build out a relatively complex SceneKit scene with 2D labels that are being composed over nodes in the scene. I am using the following to fetch the subview 'names' and projecting their 3D position as a 2D point, and then setting the centre of the label views as this point. Code is below: Project point: let projectedPoint = renderer.projectPoint(node.position) let screenPoint = CGPoint(x: CGFloat(projectedPoint.x), y: CGFloat(projectedPoint.y)) return screenPoint Absolute position update: viewTest.center = self.getScreenPoint(renderer: renderer, node: node) What is the SwiftUI version of this approach? I have used a published array containing all CGPoints, but it lags and becomes non-responsive after a few seconds of interactions. Thank you - happy to share more code is needed!
0
0
617
Apr ’23
SceneKit in XCode
Hello, I am developing a swift playground using XCode for the Swift Student Challenge and in my playground I will have a 3d scene. I opened a project that uses SceneKit from a previous year and used it to learn the program and everything works great in it. However, when I open a project and do everything from scratch (the code is exactly the same) the 3d scene does not appear. Is there an extra configuration that SceneKit needs? Thank you
2
0
858
Apr ’23
Creating Floor Plan with RoomPlan
Hi, I am trying to create a 2D floor plan from the 3D model that RoomPlan creates. This was a FAQ in the augmented-reality Apple Slack channel and the answer given was "RoomPlan outputs a 3D floor plan. You may set the z-coordinate to 0, which will flatten it and thus give you a 2D top-down floor plan." Does anyone know what this z-coordinate is and how to change it? Thank you
6
0
2.9k
Mar ’23
Crash inside SceneKit [SCNPhysicsField _removeOwner]
I'm seeing a decent number of crash reports from our app where SceneKit is crashing internally relating to SCNPhysicsField. The stack looks like: objc_msgSend -[SCNPhysicsField _removeOwner] -[SCNNode dealloc] AutoreleasePoolPage::releaseUntil(objc_object**) -[UIApplication _run] UIApplicationMain main start It must be that I am removing a node that has a physics field on it and it randomly crashes. Probably threading related? Anyone know if there is a workaround, maybe setting physicsField to nil first before trying to remove the node? Thanks
2
0
1.6k
Mar ’23
SCNScene(named: "art.scnassets/diceCollada_copy.scn") return nil and fatal error
The file path is the same and the target is set. But I keep getting errors. Please help me guard let scene = SCNScene(named: "art.scnassets/diceCollada_copy.scn") else { fatalError() return } Error 2023-03-28 08:56:55.650242+0900 ARDicee[42923:11318833] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") 2023-03-28 08:56:55.660247+0900 ARDicee[42923:11318833] Metal GPU Frame Capture Enabled 2023-03-28 08:56:55.660395+0900 ARDicee[42923:11318833] Metal API Validation Enabled ARDicee/ViewController.swift:56: Fatal error 2023-03-28 08:56:55.768975+0900 ARDicee[42923:11318833] ARDicee/ViewController.swift:56: Fatal error
0
0
791
Mar ’23
Unable to render a point cloud in my SwiftUI app
The project is building without any errors or warnings and when I run the app I'm able to see the camera view. But when I click on the start scanning button the camera view freezes and nothing happens. It is supposed to start plotting red points in the environment when I tap the start scanning button and when I tap the stop scanning button it should direct me to another screen to display the point cloud itself. The following are the different files in my project. Please let me know what I'm doing incorrectly. ContentView.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Foundation struct ContentView: View { @StateObject var scanner = ScannerViewController() var body: some View { NavigationView { VStack { ARViewContainer().edgesIgnoringSafeArea(.all) HStack { Spacer() Button(action: { scanner.startScanning() }, label: { Text("Start Scanning") }) .padding() Spacer() NavigationLink(destination: PointCloudView(pointCloud: scanner.pointCloud, pointSize: 5.0)) { Text("Stop Scanning") } .padding() Spacer() } } .navigationBarTitle(Text("Scan an Object")) } } struct ARViewContainer: UIViewRepresentable { func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) return arView } func updateUIView(_ uiView: ARView, context: Context) { } } } PointCloudView.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Foundation struct PointCloudView: View { var pointCloud: [SIMD3<Float>] var pointSize: CGFloat var body: some View { ZStack { ForEach(pointCloud, id: \.self) { point in Sphere() .frame(width: pointSize, height: pointSize, alignment: .center) .position(CGPoint(x: CGFloat(point.x), y: CGFloat(point.y))) .foregroundColor(.red) } } } } struct Sphere: Shape { func path(in rect: CGRect) -> Path { let center = CGPoint(x: rect.width / 2, y: rect.height / 2) let radius = min(rect.width, rect.height) / 2 let path = Path { p in p.addArc(center: center, radius: radius, startAngle: .zero, endAngle: .degrees(360), clockwise: true) } return path } } ScannerViewController.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Combine import Foundation class ScannerViewController: NSObject, ObservableObject { private var cancellables = Set<AnyCancellable>() @Published var isScanning = false @Published var pointCloud: [SIMD3<Float>] = [] private let arSession = ARSession() private var arConfiguration: ARConfiguration { let configuration = ARWorldTrackingConfiguration() configuration.planeDetection = .horizontal configuration.environmentTexturing = .automatic return configuration } func startScanning() { print("started scanning") isScanning = true arSession.run(arConfiguration) } func stopScanning() { print("stopped scanning") isScanning = false arSession.pause() } func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) { print("continusoyl called") guard isScanning else { return } // Get the current ARFrame guard let currentFrame = self.arSession.currentFrame else { return } // Generate the point cloud data from the ARFrame guard let pointCloud = currentFrame.rawFeaturePoints?.points else { return } // Convert the point cloud data to a format that can be displayed in the PointCloudView let convertedPointCloud = pointCloud.map { point in SIMD3<Float>(point.x, point.y, point.z) } // Pass the converted point cloud data to the PointCloudView DispatchQueue.main.async { self.pointCloud = convertedPointCloud } } } I've tried using both SceneKit and Metal to render the point cloud and referred to apple's documentation: https://developer.apple.com/documentation/arkit/environmental_analysis/displaying_a_point_cloud_using_scene_depth I've also tried building a storyboard project but storyboard and SceneKit have been creating a lot of errors. Using metal and swiftui builds without errors at the very least but still doesn't function.
1
0
868
Mar ’23
WKInterfaceSCNScene works fine on simulator, but delayed start on watch
I have a fairly simple WKInterfaceSCNScene in my Apple Watch app (the SCNScene contains only: camera, floor, cylinder). It runs a ~3-second animation. It works terrific on the simulator, but when I run it on my actual watch (series 7), it delays for about 6 seconds, then the animation displays properly. Is the watch's processor so much slower than the simulator on my laptop? I could probably deal with a 0.5 second delay, but 6 seconds? Thoughts?
1
0
1.1k
Mar ’23
Glb to USDZ losing normals
Hello, When I try to convert glb containing shape keys, I am losing normals in geometry sources. I need those shape keys so Is there a way to keep normals while keeping shape keys. Is there a problem with reality converter? the glb file: https://drive.google.com/file/d/17F5vIymfCJSy9zP9dI3oHcVcP8_5CWjd/view?usp=sharing the usdz file, created by reality converter: (https://drive.google.com/file/d/18AVnotD2_8UJvf1KpmK9Gw_oldRvlmIS/view) for visiual representation:
1
1
1.3k
Mar ’23
Pass interpolated values to SceneKit Fragment Shader
I have a SceneKit fragment shader where I need to make some decisions about the alpha value based on an interpolated value between the vertexes. At each vertex there is a value and I need to know what the interpolated value for the given position that the fragment shader is determining the color for. Is there a way to do this? This is what my shader looks like. #pragma arguments float myInterpolatedVlaue; #pragma transparent #pragma body //Sample logic.  The actual logic has more too it. if (myInterpolatedVlaue > 1.0 ) {     _output.color.a = 0; } I want to set a value at each vertex and then get the interpolated value in my fragment shader. I would like to have myInterpolatedVlaue be set based on the interpolated values from the value at each vertex.
1
0
894
Mar ’23
SKView creation crashes in macOS Ventura beta 13.3 (22E5230e)
Hi, One user reported me that my app is crashing under macOS Ventura beta 13.3 (22E5230e) After investigation is seems that creating an SKView, either by code (SKView* skView = [[SKView alloc] initWithFrame:self.view.frame]) Or by Storyboards ([SKView initWithCoder:]) Crashes the app immediately. It seems to me that this bug is so visible that I cannot understand how apple managed to release it in a public beta. Anyone having the same problem, or knowing a workaround ? Note : here is my feedback assistant report FB12032892
0
0
863
Mar ’23
Default scenekit project not working.
When I open A completely new project of game-scenekit, It fails to work when the project is run. On line 18 in gameViewController there is a thread error : Fatal error: Unexpectedly found nil while unwrapping an Optional value. I try to fix it by replacing with '?' and the project runs but with a blank black screen. Any Ideas on why its like this?
0
0
525
Mar ’23
How to improve the captured image's resolution?
To create signatures for human faces and compare the similarities, I'm using ARKit's captureImage from ARFrame which is derived from the front facing camera with ARFaceTrackingConfiguration. However, compared to using the Vision and AVFoundation frameworks, the quality of the signature analysis is significantly impacted by the captureImage's low resolution. The resolution of the capturedImage in ARKit is just 640x480, according to capturedDepthData even though the video format is set to the highest resolution. let configuration = ARFaceTrackingConfiguration() if let videoFormat = ARFaceTrackingConfiguration.supportedVideoFormats.sorted(by: { ($0.imageResolution.width * $0.imageResolution.height) < ($1.imageResolution.width * $1.imageResolution.height) }).last { configuration.videoFormat = videoFormat } I tried using captureHighResolutionFrame and as well as change the video format: if let videoFormat = ARFaceTrackingConfiguration.recommendedVideoFormatForHighResolutionFrameCapturing { configuration.videoFormat = videoFormat } However, according to the documentation: The system delivers a high-resolution frame out-of-band, which means that it doesn't affect the other frames that the session receives at a regular interval The asynchronous nature of taking the high resolution images seems to result alternating between the standard captured image and the high resolution images rather than replacing the regular captured images. This is a concern because, depending on the size variations, displayTransform and CGAffineTransform must be used in different ways to scale the images. Not only that I need to able to use the frames continuously at either 30 fps or 60 fps, as they're produced rather than taking pictures occasionally, which the captureHighResolutionFrame method seems to be designed for considering the shutter sound. In order to use the captured image, I'm currently transforming it in the following way let image: CIImage = CIImage(cvImageBuffer: imageBuffer) let imageSize: CGSize = CGSize(width: CVPixelBufferGetWidth(imageBuffer), height: CVPixelBufferGetHeight(imageBuffer)) let normalizeTransform: CGAffineTransform = CGAffineTransform(scaleX: 1.0 / imageSize.width, y: 1.0 / imageSize.height) let flipTransform: CGAffineTransform = metadata.orientation.isPortrait ? CGAffineTransform(scaleX: -1, y: -1).translatedBy(x: -1, y: -1) : .identity guard let viewPort: CGRect = face.viewPort else { return nil } let viewPortSize: CGSize = viewPort.size guard let displayTransform: CGAffineTransform = face.arFrame?.displayTransform(for: metadata.orientation, viewportSize: CGSize(width: viewPortSize.width, height: viewPortSize.height)) else {   return nil } let scaleX: CGFloat = viewPortSize.width let scaleY: CGFloat = viewPortSize.height let viewPortTransform: CGAffineTransform = CGAffineTransform(scaleX: scaleX, y: scaleY) let scaledImage: CIImage = image   .transformed(by: normalizeTransform     .concatenating(flipTransform)     .concatenating(displayTransform)     .concatenating(viewPortTransform)   )   .cropped(to: viewPort)
2
0
1.8k
Feb ’23
How to mimic the way apple implements medals in their fitness app?
Hi all, I am currently making a fitness app and want to replicate the way Apple incorporate medals in their Fitness app. They have a page called awards and it looks like a collection view of different medals that the user can unlock. Once unlocking a medal the user can tap on the medal and it opens to a full screen intractable scene where the user can rotate the medal etc. I have had a play around with SceneKit and managed to get a medal loaded into a scene and display it in the app. However my functionality does not look as smooth or as polished as Apples. Does anyone have any idea on how they have managed to present all of the different Scene-kit scenes in a collection-view for example? Or how they have achieved the smooth transition between tapping on the medal in the collection-view and the scene. I guess this is created using SwiftUI. Can this be replicated in Storyboards? Thanks!
4
0
3.2k
Feb ’23
SceneKit.write to DAE(Collada) format output binary file instead of Collada XML
I am using Scenekit.write method to export a scene data to DAE(Collada) format. File is exported correctly but it's not a collada XML file rather a binary file. With more investigation I found an Apple binary pList file, And while renaming it's extension to pList, I can view geometry data as standard plist. This file is opening in XCode but not in any other DAE viewer. I am on Xcode 14.3 and IOS 16.
Replies
0
Boosts
0
Views
450
Activity
May ’23
Accessing SubViews in SwiftUI, as seen in UIKit
Is there a way to mimic this functionality found in UIKit in SwiftUI? Long story short, I am creating an interactive SceneKit view (currently in UIKit) that anchors 2D UIViews over nodes, for navigation and labelling. I would like to migrate over to SwiftUI, but I am having difficulties mimicking this functionality. let subViews = self.view.subviews.compactMap{$0 as? UIButton} if let view = subViews.first(where: {$0.currentTitle == label}) { view.center = self.getScreenPoint(renderer: renderer, node: node) } Can anyone help me with this? Thanks!
Replies
1
Boosts
1
Views
1.7k
Activity
Apr ’23
Exporting DAE animations for Scenekit
I checked out the FOX2 example for Scenekit that showcases the new animation protocol. I was rooting around in the character files trying todiscover how they were organizned, and noticed that the following files had no geometry only the rig for the animation and hence the animationdata as well.These are the files that I'm referring to:•max_idle.sc•max_jump.scn•max_spin.scnHow were these created and exported for Scenekit and with which exporter? Maya, Max, C4D? OpenCollada?What are the recommended settings? How do you export just rigs and animation data for Scenekit without the model? A shoutout to the Scenkit dev team: you guys are creating an amazing game engine(thank you), it's well organized and easy to use.However but you're neglecting a very important aspect. There are no tutorials on how to export authored content files(modles with rigs and animation) for Scenekit. This is super important information, and without putting some more thought into how to teach people how to do this, your framework will continue to see very little adoption.Please, please begin to address this. With ARKit combined with Scenekit you have good chance of seeing many people use this framework.
Replies
12
Boosts
1
Views
12k
Activity
Apr ’23
RoomPlan API
I am using RoomPlan API in my application. Working fine for small apartments but when I am trying to scan a bigger apartment which takes more time greater than 15 minutes the API automatically stopped and finished the scan even though part of the apartment is still pending scanning. I need the original structure like a point cloud in 3D, the USDZ model has a white mesh structure. Is there any way to get a real 3D view from RoomPlan API or USDZ model. How I can change the colour of scanning lines. I am getting RSFloorPlan class value when scanning finished. How I can get this Floor Plan, I mean I need its 2d structure as we what we are scanning. Thanks! Ramneet Singh (iOS developer)
Replies
2
Boosts
1
Views
2.4k
Activity
Apr ’23
Reloading SceneKit scene after app goes to foreground
Hello, is it good practice to reload SceneKit 3D scene every time app goes to foreground from background? For example when app is for a long time in the background and then it goes to foreground, reload the app, to make sure everything is loaded? Is it necessary in normal circumstances? Thanks, Krzysztof
Replies
0
Boosts
0
Views
475
Activity
Apr ’23
how to draw/Place an arrow shape/annotation in all direction using Two Points, Start point vector and end point vector in SceneKit?
in sceneview how can we draw arrow in all direction using Two Points like Start point vector and end point vector (draw arrow like Up side , Downside , left side up and down, right side up and down ) see attachment for arrow shape
Replies
0
Boosts
0
Views
726
Activity
Apr ’23
SwiftUI version of centring multiple subviews at once, as seen in UIKit (SCNSceneRendererDelegate)
I have been using UIKit to build out a relatively complex SceneKit scene with 2D labels that are being composed over nodes in the scene. I am using the following to fetch the subview 'names' and projecting their 3D position as a 2D point, and then setting the centre of the label views as this point. Code is below: Project point: let projectedPoint = renderer.projectPoint(node.position) let screenPoint = CGPoint(x: CGFloat(projectedPoint.x), y: CGFloat(projectedPoint.y)) return screenPoint Absolute position update: viewTest.center = self.getScreenPoint(renderer: renderer, node: node) What is the SwiftUI version of this approach? I have used a published array containing all CGPoints, but it lags and becomes non-responsive after a few seconds of interactions. Thank you - happy to share more code is needed!
Replies
0
Boosts
0
Views
617
Activity
Apr ’23
SceneKit in XCode
Hello, I am developing a swift playground using XCode for the Swift Student Challenge and in my playground I will have a 3d scene. I opened a project that uses SceneKit from a previous year and used it to learn the program and everything works great in it. However, when I open a project and do everything from scratch (the code is exactly the same) the 3d scene does not appear. Is there an extra configuration that SceneKit needs? Thank you
Replies
2
Boosts
0
Views
858
Activity
Apr ’23
Creating Floor Plan with RoomPlan
Hi, I am trying to create a 2D floor plan from the 3D model that RoomPlan creates. This was a FAQ in the augmented-reality Apple Slack channel and the answer given was "RoomPlan outputs a 3D floor plan. You may set the z-coordinate to 0, which will flatten it and thus give you a 2D top-down floor plan." Does anyone know what this z-coordinate is and how to change it? Thank you
Replies
6
Boosts
0
Views
2.9k
Activity
Mar ’23
Crash inside SceneKit [SCNPhysicsField _removeOwner]
I'm seeing a decent number of crash reports from our app where SceneKit is crashing internally relating to SCNPhysicsField. The stack looks like: objc_msgSend -[SCNPhysicsField _removeOwner] -[SCNNode dealloc] AutoreleasePoolPage::releaseUntil(objc_object**) -[UIApplication _run] UIApplicationMain main start It must be that I am removing a node that has a physics field on it and it randomly crashes. Probably threading related? Anyone know if there is a workaround, maybe setting physicsField to nil first before trying to remove the node? Thanks
Replies
2
Boosts
0
Views
1.6k
Activity
Mar ’23
SCNScene(named: "art.scnassets/diceCollada_copy.scn") return nil and fatal error
The file path is the same and the target is set. But I keep getting errors. Please help me guard let scene = SCNScene(named: "art.scnassets/diceCollada_copy.scn") else { fatalError() return } Error 2023-03-28 08:56:55.650242+0900 ARDicee[42923:11318833] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") 2023-03-28 08:56:55.660247+0900 ARDicee[42923:11318833] Metal GPU Frame Capture Enabled 2023-03-28 08:56:55.660395+0900 ARDicee[42923:11318833] Metal API Validation Enabled ARDicee/ViewController.swift:56: Fatal error 2023-03-28 08:56:55.768975+0900 ARDicee[42923:11318833] ARDicee/ViewController.swift:56: Fatal error
Replies
0
Boosts
0
Views
791
Activity
Mar ’23
Unable to render a point cloud in my SwiftUI app
The project is building without any errors or warnings and when I run the app I'm able to see the camera view. But when I click on the start scanning button the camera view freezes and nothing happens. It is supposed to start plotting red points in the environment when I tap the start scanning button and when I tap the stop scanning button it should direct me to another screen to display the point cloud itself. The following are the different files in my project. Please let me know what I'm doing incorrectly. ContentView.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Foundation struct ContentView: View { @StateObject var scanner = ScannerViewController() var body: some View { NavigationView { VStack { ARViewContainer().edgesIgnoringSafeArea(.all) HStack { Spacer() Button(action: { scanner.startScanning() }, label: { Text("Start Scanning") }) .padding() Spacer() NavigationLink(destination: PointCloudView(pointCloud: scanner.pointCloud, pointSize: 5.0)) { Text("Stop Scanning") } .padding() Spacer() } } .navigationBarTitle(Text("Scan an Object")) } } struct ARViewContainer: UIViewRepresentable { func makeUIView(context: Context) -> ARView { let arView = ARView(frame: .zero) return arView } func updateUIView(_ uiView: ARView, context: Context) { } } } PointCloudView.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Foundation struct PointCloudView: View { var pointCloud: [SIMD3<Float>] var pointSize: CGFloat var body: some View { ZStack { ForEach(pointCloud, id: \.self) { point in Sphere() .frame(width: pointSize, height: pointSize, alignment: .center) .position(CGPoint(x: CGFloat(point.x), y: CGFloat(point.y))) .foregroundColor(.red) } } } } struct Sphere: Shape { func path(in rect: CGRect) -> Path { let center = CGPoint(x: rect.width / 2, y: rect.height / 2) let radius = min(rect.width, rect.height) / 2 let path = Path { p in p.addArc(center: center, radius: radius, startAngle: .zero, endAngle: .degrees(360), clockwise: true) } return path } } ScannerViewController.swift import AVFoundation import ARKit import RealityKit import SceneKit import SwiftUI import Combine import Foundation class ScannerViewController: NSObject, ObservableObject { private var cancellables = Set<AnyCancellable>() @Published var isScanning = false @Published var pointCloud: [SIMD3<Float>] = [] private let arSession = ARSession() private var arConfiguration: ARConfiguration { let configuration = ARWorldTrackingConfiguration() configuration.planeDetection = .horizontal configuration.environmentTexturing = .automatic return configuration } func startScanning() { print("started scanning") isScanning = true arSession.run(arConfiguration) } func stopScanning() { print("stopped scanning") isScanning = false arSession.pause() } func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) { print("continusoyl called") guard isScanning else { return } // Get the current ARFrame guard let currentFrame = self.arSession.currentFrame else { return } // Generate the point cloud data from the ARFrame guard let pointCloud = currentFrame.rawFeaturePoints?.points else { return } // Convert the point cloud data to a format that can be displayed in the PointCloudView let convertedPointCloud = pointCloud.map { point in SIMD3<Float>(point.x, point.y, point.z) } // Pass the converted point cloud data to the PointCloudView DispatchQueue.main.async { self.pointCloud = convertedPointCloud } } } I've tried using both SceneKit and Metal to render the point cloud and referred to apple's documentation: https://developer.apple.com/documentation/arkit/environmental_analysis/displaying_a_point_cloud_using_scene_depth I've also tried building a storyboard project but storyboard and SceneKit have been creating a lot of errors. Using metal and swiftui builds without errors at the very least but still doesn't function.
Replies
1
Boosts
0
Views
868
Activity
Mar ’23
WKInterfaceSCNScene works fine on simulator, but delayed start on watch
I have a fairly simple WKInterfaceSCNScene in my Apple Watch app (the SCNScene contains only: camera, floor, cylinder). It runs a ~3-second animation. It works terrific on the simulator, but when I run it on my actual watch (series 7), it delays for about 6 seconds, then the animation displays properly. Is the watch's processor so much slower than the simulator on my laptop? I could probably deal with a 0.5 second delay, but 6 seconds? Thoughts?
Replies
1
Boosts
0
Views
1.1k
Activity
Mar ’23
Glb to USDZ losing normals
Hello, When I try to convert glb containing shape keys, I am losing normals in geometry sources. I need those shape keys so Is there a way to keep normals while keeping shape keys. Is there a problem with reality converter? the glb file: https://drive.google.com/file/d/17F5vIymfCJSy9zP9dI3oHcVcP8_5CWjd/view?usp=sharing the usdz file, created by reality converter: (https://drive.google.com/file/d/18AVnotD2_8UJvf1KpmK9Gw_oldRvlmIS/view) for visiual representation:
Replies
1
Boosts
1
Views
1.3k
Activity
Mar ’23
Pass interpolated values to SceneKit Fragment Shader
I have a SceneKit fragment shader where I need to make some decisions about the alpha value based on an interpolated value between the vertexes. At each vertex there is a value and I need to know what the interpolated value for the given position that the fragment shader is determining the color for. Is there a way to do this? This is what my shader looks like. #pragma arguments float myInterpolatedVlaue; #pragma transparent #pragma body //Sample logic.  The actual logic has more too it. if (myInterpolatedVlaue > 1.0 ) {     _output.color.a = 0; } I want to set a value at each vertex and then get the interpolated value in my fragment shader. I would like to have myInterpolatedVlaue be set based on the interpolated values from the value at each vertex.
Replies
1
Boosts
0
Views
894
Activity
Mar ’23
ARKit + SceneKit. Scaled triangles appear after applying depth video with alpha channel on SCNPlane
I am using ARKit + SceneKit. After applying depth video with alpha channel on SCNPlane, scaled triangles appear. How to remove these triangles and vertices that remained on the SCNPlane with depth 0.0. Result The video for videotexture
Replies
2
Boosts
1
Views
950
Activity
Mar ’23
SKView creation crashes in macOS Ventura beta 13.3 (22E5230e)
Hi, One user reported me that my app is crashing under macOS Ventura beta 13.3 (22E5230e) After investigation is seems that creating an SKView, either by code (SKView* skView = [[SKView alloc] initWithFrame:self.view.frame]) Or by Storyboards ([SKView initWithCoder:]) Crashes the app immediately. It seems to me that this bug is so visible that I cannot understand how apple managed to release it in a public beta. Anyone having the same problem, or knowing a workaround ? Note : here is my feedback assistant report FB12032892
Replies
0
Boosts
0
Views
863
Activity
Mar ’23
Default scenekit project not working.
When I open A completely new project of game-scenekit, It fails to work when the project is run. On line 18 in gameViewController there is a thread error : Fatal error: Unexpectedly found nil while unwrapping an Optional value. I try to fix it by replacing with '?' and the project runs but with a blank black screen. Any Ideas on why its like this?
Replies
0
Boosts
0
Views
525
Activity
Mar ’23
How to improve the captured image's resolution?
To create signatures for human faces and compare the similarities, I'm using ARKit's captureImage from ARFrame which is derived from the front facing camera with ARFaceTrackingConfiguration. However, compared to using the Vision and AVFoundation frameworks, the quality of the signature analysis is significantly impacted by the captureImage's low resolution. The resolution of the capturedImage in ARKit is just 640x480, according to capturedDepthData even though the video format is set to the highest resolution. let configuration = ARFaceTrackingConfiguration() if let videoFormat = ARFaceTrackingConfiguration.supportedVideoFormats.sorted(by: { ($0.imageResolution.width * $0.imageResolution.height) < ($1.imageResolution.width * $1.imageResolution.height) }).last { configuration.videoFormat = videoFormat } I tried using captureHighResolutionFrame and as well as change the video format: if let videoFormat = ARFaceTrackingConfiguration.recommendedVideoFormatForHighResolutionFrameCapturing { configuration.videoFormat = videoFormat } However, according to the documentation: The system delivers a high-resolution frame out-of-band, which means that it doesn't affect the other frames that the session receives at a regular interval The asynchronous nature of taking the high resolution images seems to result alternating between the standard captured image and the high resolution images rather than replacing the regular captured images. This is a concern because, depending on the size variations, displayTransform and CGAffineTransform must be used in different ways to scale the images. Not only that I need to able to use the frames continuously at either 30 fps or 60 fps, as they're produced rather than taking pictures occasionally, which the captureHighResolutionFrame method seems to be designed for considering the shutter sound. In order to use the captured image, I'm currently transforming it in the following way let image: CIImage = CIImage(cvImageBuffer: imageBuffer) let imageSize: CGSize = CGSize(width: CVPixelBufferGetWidth(imageBuffer), height: CVPixelBufferGetHeight(imageBuffer)) let normalizeTransform: CGAffineTransform = CGAffineTransform(scaleX: 1.0 / imageSize.width, y: 1.0 / imageSize.height) let flipTransform: CGAffineTransform = metadata.orientation.isPortrait ? CGAffineTransform(scaleX: -1, y: -1).translatedBy(x: -1, y: -1) : .identity guard let viewPort: CGRect = face.viewPort else { return nil } let viewPortSize: CGSize = viewPort.size guard let displayTransform: CGAffineTransform = face.arFrame?.displayTransform(for: metadata.orientation, viewportSize: CGSize(width: viewPortSize.width, height: viewPortSize.height)) else {   return nil } let scaleX: CGFloat = viewPortSize.width let scaleY: CGFloat = viewPortSize.height let viewPortTransform: CGAffineTransform = CGAffineTransform(scaleX: scaleX, y: scaleY) let scaledImage: CIImage = image   .transformed(by: normalizeTransform     .concatenating(flipTransform)     .concatenating(displayTransform)     .concatenating(viewPortTransform)   )   .cropped(to: viewPort)
Replies
2
Boosts
0
Views
1.8k
Activity
Feb ’23
How to mimic the way apple implements medals in their fitness app?
Hi all, I am currently making a fitness app and want to replicate the way Apple incorporate medals in their Fitness app. They have a page called awards and it looks like a collection view of different medals that the user can unlock. Once unlocking a medal the user can tap on the medal and it opens to a full screen intractable scene where the user can rotate the medal etc. I have had a play around with SceneKit and managed to get a medal loaded into a scene and display it in the app. However my functionality does not look as smooth or as polished as Apples. Does anyone have any idea on how they have managed to present all of the different Scene-kit scenes in a collection-view for example? Or how they have achieved the smooth transition between tapping on the medal in the collection-view and the scene. I guess this is created using SwiftUI. Can this be replicated in Storyboards? Thanks!
Replies
4
Boosts
0
Views
3.2k
Activity
Feb ’23