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

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
872
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
532
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.9k
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
What is the correct way to position SceneKit nodes?
I have a small SceneKit app which recognizes an image and then places colored spheres on it, one in the center of the image and one on each of the four corners. If I add the sphere nodes to the root node, the code that positions the balls in the right quadrants looks like this:    let lowerLeft = SCNVector3(x - width/2, y - height/2, z)    let lowerRight = SCNVector3(x + width/2, y - height/2, z)    let upperRight = SCNVector3(x + width/2, y + height/2, z)    let upperLeft = SCNVector3(x - width/2, y + height/2, z)   let center = SCNVector3(x, y, z) Where x, y and z are set from the image anchor’s transform matrix. The image is vertical, so this means that the z axis is pointing towards the camera, +y is pointing up, and +x is to the right. This is all in world coordinates, since the spheres are “siblings” of the image. This situation is less than ideal because when you move the camera, the spheres move with it instead of staying with the image. If I add the sphere nodes as children of the image node, the code to place the spheres looks like this:    let lowerLeft = SCNVector3(x - width/2, y, z + height/2)    let lowerRight = SCNVector3(x + width/2, y, z + height/2)    let upperRight = SCNVector3(x - width/2, y, z - height/2)    let upperLeft = SCNVector3(x + width/2, y, z - height/2)    let center = SCNVector3(x, y, z) Now x, y and z are all set to zero, because our origin is now the origin of the anchor's node, which is located at the center of the image. This keeps the spheres with the image when the camera moves.  But the orientation of the axes (is that the plural of axis???) has changed. Now the y axis is pointing towards the camera, -z is pointing up, and -x is to the right. So the coordinate system has been rotated around x (to bring z to vertical) and then around z (to reverse the +/- of x). What this means is that in order to do the calculations properly in a generic case, I’d need to figure out which way the axes are pointing and account for that.  This seems wrong, like there should be some way of doing this where SceneKit has already taken that into account.  But I have done a lot of Googling and have not been able to find one.  I do see a lot of examples that say things like “to position a node 1 meter above another node, set its position to [0, 1, 0]”.  But that still requires knowing that the +y axis is “up”, even though no-one mentions it when they say this. This app also exhibits the same problem I wrote about in https://developer.apple.com/forums/thread/724778, which was a RealityKit app, but that is a separate issue.
0
0
838
Feb ’23
SCNNode.position is sometimes not reflected on screen
The desired outcome of the code below is that both the red and yellow spheres should be at the same position at the center of the scene, (0, 0, 0), but instead the red sphere remains at its initial position (1, 0, 0). Commenting out any of the lines marked in the code, strangely, solves the issue. The code shows a simplified version of some other code, so it would be desirable to keep the order of the lines as they currently are. Am I doing something wrong? class GameViewController: NSViewController {          override func viewDidLoad() {         super.viewDidLoad()                  let scene = SCNScene(named: "art.scnassets/ship.scn")!                  let cameraNode = SCNNode()         cameraNode.camera = SCNCamera()         scene.rootNode.addChildNode(cameraNode)         cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)                  let lightNode = SCNNode()         lightNode.light = SCNLight()         lightNode.light!.type = .omni         lightNode.position = SCNVector3(x: 0, y: 10, z: 10)         scene.rootNode.addChildNode(lightNode)                  let scnView = self.view as! SCNView         scnView.scene = scene                  let parent0 = SCNNode()         scene.rootNode.addChildNode(parent0)         let parent1 = SCNNode()         scene.rootNode.addChildNode(parent1)         let sphere0 = SCNNode(geometry: SCNSphere(radius: 1))         sphere0.geometry!.firstMaterial!.diffuse.contents = NSColor.red                  let sphere1 = SCNNode(geometry: SCNSphere(radius: 1))         sphere1.geometry!.firstMaterial!.diffuse.contents = NSColor.yellow                  sphere0.position = SCNVector3(x: -1, y: 0, z: 0) // commenting out this line solves the issue         parent1.addChildNode(sphere0) // or commenting out this line solves the issue         sphere0.position = SCNVector3(x: 0, y: 0, z: 0)         parent0.addChildNode(sphere1) // or commenting out this line solves the issue                  DispatchQueue.main.asyncAfter(deadline: .now() + 1) {             print(sphere0.worldPosition, sphere1.worldPosition)         }     } }
1
0
993
Feb ’23
SCNCylinder shows mirrored texture for base and top elements
SCNBox renders the textures correctly, but SCNCylinder seems to mirror the base and top textures. The following code reproduces the issue (just set the image variable to the name of the image you're using, in this case an image with the number 2 in it): class GameViewController: NSViewController { let image = "art.scnassets/image.heic"          override func viewDidLoad() {         super.viewDidLoad()                  let scene = SCNScene(named: "art.scnassets/ship.scn")!                  let cameraNode = SCNNode()         cameraNode.camera = SCNCamera()         scene.rootNode.addChildNode(cameraNode)         cameraNode.position = SCNVector3(x: 0, y: 3, z: 3)         let scnView = self.view as! SCNView         scnView.scene = scene                  let node = SCNNode(geometry: SCNCylinder(radius: 0.5, height: 1))         node.geometry!.materials = [SCNMaterial(), SCNMaterial(), SCNMaterial()]         node.geometry!.materials[1].diffuse.contents = image         node.geometry!.materials[2].diffuse.contents = image         node.position.x = -1         node.runAction(.repeatForever(.rotate(by: 1, around: SCNVector3(x: 1, y: 0, z: 0), duration: 1)))         scene.rootNode.addChildNode(node)         let node2 = SCNNode(geometry: SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0))         node2.geometry!.materials = [SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial()]         node2.geometry!.materials[4].diffuse.contents = image         node2.geometry!.materials[5].diffuse.contents = image         node2.position.x = 1         node2.runAction(.repeatForever(.rotate(by: 1, around: SCNVector3(x: 1, y: 0, z: 0), duration: 1)))         scene.rootNode.addChildNode(node2)         cameraNode.look(at: SCNVector3(x: 0, y: 0, z: 0))     } }
0
0
741
Feb ’23
Programmatically created SCNMaterial vs SceneKit Viewer
In the viewer, the model looks great. I then bring it into the scene and it looks great. But I want to change the material programmatically. Yet this makes it look ugly. It's a physically based light model and a metallic material. Yet renders like a relatively flat phong. The detail of the other maps is there. The color is just flat and off. To eliminate all other variables, I started applying my programmatic material right after creating the node. The material is intended to be the exact same as the one I set in the viewer. Yet I get the same ugly result when I set it to the programmatically created version. Then I only changed the diffuse contents. And this looks great. Hopefully this isn't a stupid question as I can't find any similar complaints. But what parameter is being set in the viewer that I am missing in the SCNMaterial? The following is my attempt to copy all the settings from my viewer and repeat it in code. Nothing has really changed anything from just setting the usual content values: let material = SCNMaterial()         material.lightingModel = .physicallyBased         let matScale: Float = 1.0///25.4         material.isDoubleSided = false         material.diffuse.contents = UIImage(named: "basecolor.png")         //material.diffuse.contentsTransform = SCNMatrix4MakeScale(matScale, matScale, matScale)         material.diffuse.wrapS = .repeat         material.diffuse.wrapT = .repeat         material.diffuse.mipFilter = .nearest         material.diffuse.magnificationFilter = .linear         material.diffuse.minificationFilter = .linear         material.diffuse.mappingChannel = 0         material.diffuse.maxAnisotropy = 1.0         material.metalness.contents = UIImage(named: "scuffed_metalic.png")         material.metalness.wrapS = .repeat         material.metalness.wrapT = .repeat         material.metalness.mipFilter = .nearest         material.metalness.magnificationFilter = .linear         material.metalness.minificationFilter = .linear         material.metalness.mappingChannel = 0         material.metalness.maxAnisotropy = 1.0         material.roughness.contents = UIImage(named: "scuffed_roughness.png")         material.roughness.wrapS = .repeat         material.roughness.wrapT = .repeat         material.roughness.mipFilter = .nearest         material.roughness.magnificationFilter = .linear         material.roughness.minificationFilter = .linear         material.roughness.mappingChannel = 0         material.roughness.maxAnisotropy = 1.0         material.normal.contents = UIImage(named: "scuffed_normal.png")         material.normal.wrapS = .repeat         material.normal.wrapT = .repeat         material.normal.mipFilter = .nearest         material.normal.magnificationFilter = .linear         material.normal.minificationFilter = .linear         material.normal.mappingChannel = 0         material.normal.maxAnisotropy = 1.0         material.metalness.intensity = 1.0         material.roughness.intensity = 1.0//0.0//0.3         material.normal.intensity = 1.0         material.diffuse.intensity = 1.0        material.multiply.contents = UIColor.white         material.multiply.intensity = 1.0         material.transparent.contents = UIColor.white         material.transparent.intensity = 1.0         material.clearCoatNormal.contents = UIColor.white         material.clearCoatNormal.intensity = 1.0         material.locksAmbientWithDiffuse = true         material.emission.contents = UIColor.black         material.emission.intensity = 1.0         material.selfIllumination.contents = UIColor.black         material.selfIllumination.intensity = 1.0         material.clearCoatRoughness.contents = UIColor.black         material.clearCoatRoughness.intensity = 1.0         material.displacement.contents = UIColor.black         material.displacement.intensity = 1.0         material.transparencyMode = .default         material.shininess = 1.0         material.fresnelExponent = 0.0         material.cullMode = .back         material.blendMode = .alpha         material.writesToDepthBuffer = true         material.readsFromDepthBuffer = true         material.locksAmbientWithDiffuse = true         material.isLitPerPixel = true
4
0
1.8k
Jan ’23
No gobo support for SpotLights in RealityKit
I want to add a gobo effect to a spotlight in RealityKit. I looked in all information, but I could not find support for it, while I saw that it is supported in SceneKit. However, I can not use SceneKit in combination with the RealityKit application I was already writing, and it would be a lot of effort to go back to SceneKit. Is there a solution to or add gobo effects for spotlights in RealityKit, or use the combination of RealityKit and SceneKit in an AR application?
2
0
957
Jan ’23
How to make SceneView in TimelineView use Always on Display
I am rewriting my watch app in SwiftUI in order to make the app work with the always on display. I have got it working well for text and images, which update even when the watch is lowered and the display is faded. However I also use a SceneView and this does not update whilst the watch is lowered. Is it possible to update the SceneView when the watch is lowered? And if so then how would I do this? Is there somewhere I can access the date/time from within the SceneView, which may cause it to update? Thanks.
0
0
971
Jan ’23
Export animation from .dae
Hello guys,In WWDC 2015 - Session 606 - Enhancements to SceneKit there was an Fox example project which is available to download.Can anyone say what is the correct collada file setttings when exporting model with skeletal animation from 3D tool into .dae file? For example in the demo project there is a "walk.scn".I used 3D tool (Cheetah3D) to make a simple model with simple skeletal animation and export it in .dae, but I can't get my model to be animated on the scene.If I use non skeletal animation in 3D tool and export it in .dae then model animation on the scene works perfect.Maybe someone succeed with exporting model with skeletal animation using another 3D tool like Blender?
14
0
14k
Jan ’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
872
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
532
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.9k
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
3d animation : lip syncing
I have a simple 3d avatar in the form of an FBX file. I can convert that to a scene file for SceneKit. I need to make it talk, at runtime. So I need a way to go from audio to movements of the mouse. How can I do that? Any pointer appreciated, thanks!
Replies
2
Boosts
0
Views
2.8k
Activity
Feb ’23
What is the correct way to position SceneKit nodes?
I have a small SceneKit app which recognizes an image and then places colored spheres on it, one in the center of the image and one on each of the four corners. If I add the sphere nodes to the root node, the code that positions the balls in the right quadrants looks like this:    let lowerLeft = SCNVector3(x - width/2, y - height/2, z)    let lowerRight = SCNVector3(x + width/2, y - height/2, z)    let upperRight = SCNVector3(x + width/2, y + height/2, z)    let upperLeft = SCNVector3(x - width/2, y + height/2, z)   let center = SCNVector3(x, y, z) Where x, y and z are set from the image anchor’s transform matrix. The image is vertical, so this means that the z axis is pointing towards the camera, +y is pointing up, and +x is to the right. This is all in world coordinates, since the spheres are “siblings” of the image. This situation is less than ideal because when you move the camera, the spheres move with it instead of staying with the image. If I add the sphere nodes as children of the image node, the code to place the spheres looks like this:    let lowerLeft = SCNVector3(x - width/2, y, z + height/2)    let lowerRight = SCNVector3(x + width/2, y, z + height/2)    let upperRight = SCNVector3(x - width/2, y, z - height/2)    let upperLeft = SCNVector3(x + width/2, y, z - height/2)    let center = SCNVector3(x, y, z) Now x, y and z are all set to zero, because our origin is now the origin of the anchor's node, which is located at the center of the image. This keeps the spheres with the image when the camera moves.  But the orientation of the axes (is that the plural of axis???) has changed. Now the y axis is pointing towards the camera, -z is pointing up, and -x is to the right. So the coordinate system has been rotated around x (to bring z to vertical) and then around z (to reverse the +/- of x). What this means is that in order to do the calculations properly in a generic case, I’d need to figure out which way the axes are pointing and account for that.  This seems wrong, like there should be some way of doing this where SceneKit has already taken that into account.  But I have done a lot of Googling and have not been able to find one.  I do see a lot of examples that say things like “to position a node 1 meter above another node, set its position to [0, 1, 0]”.  But that still requires knowing that the +y axis is “up”, even though no-one mentions it when they say this. This app also exhibits the same problem I wrote about in https://developer.apple.com/forums/thread/724778, which was a RealityKit app, but that is a separate issue.
Replies
0
Boosts
0
Views
838
Activity
Feb ’23
SCNNode.position is sometimes not reflected on screen
The desired outcome of the code below is that both the red and yellow spheres should be at the same position at the center of the scene, (0, 0, 0), but instead the red sphere remains at its initial position (1, 0, 0). Commenting out any of the lines marked in the code, strangely, solves the issue. The code shows a simplified version of some other code, so it would be desirable to keep the order of the lines as they currently are. Am I doing something wrong? class GameViewController: NSViewController {          override func viewDidLoad() {         super.viewDidLoad()                  let scene = SCNScene(named: "art.scnassets/ship.scn")!                  let cameraNode = SCNNode()         cameraNode.camera = SCNCamera()         scene.rootNode.addChildNode(cameraNode)         cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)                  let lightNode = SCNNode()         lightNode.light = SCNLight()         lightNode.light!.type = .omni         lightNode.position = SCNVector3(x: 0, y: 10, z: 10)         scene.rootNode.addChildNode(lightNode)                  let scnView = self.view as! SCNView         scnView.scene = scene                  let parent0 = SCNNode()         scene.rootNode.addChildNode(parent0)         let parent1 = SCNNode()         scene.rootNode.addChildNode(parent1)         let sphere0 = SCNNode(geometry: SCNSphere(radius: 1))         sphere0.geometry!.firstMaterial!.diffuse.contents = NSColor.red                  let sphere1 = SCNNode(geometry: SCNSphere(radius: 1))         sphere1.geometry!.firstMaterial!.diffuse.contents = NSColor.yellow                  sphere0.position = SCNVector3(x: -1, y: 0, z: 0) // commenting out this line solves the issue         parent1.addChildNode(sphere0) // or commenting out this line solves the issue         sphere0.position = SCNVector3(x: 0, y: 0, z: 0)         parent0.addChildNode(sphere1) // or commenting out this line solves the issue                  DispatchQueue.main.asyncAfter(deadline: .now() + 1) {             print(sphere0.worldPosition, sphere1.worldPosition)         }     } }
Replies
1
Boosts
0
Views
993
Activity
Feb ’23
capturing body motion in 3d occlusion material
Hi there. My question is about adding occlusion material to imported usdz file that using in capture body motion in 3d sample. How can ı do that?
Replies
0
Boosts
0
Views
695
Activity
Feb ’23
SCNCylinder shows mirrored texture for base and top elements
SCNBox renders the textures correctly, but SCNCylinder seems to mirror the base and top textures. The following code reproduces the issue (just set the image variable to the name of the image you're using, in this case an image with the number 2 in it): class GameViewController: NSViewController { let image = "art.scnassets/image.heic"          override func viewDidLoad() {         super.viewDidLoad()                  let scene = SCNScene(named: "art.scnassets/ship.scn")!                  let cameraNode = SCNNode()         cameraNode.camera = SCNCamera()         scene.rootNode.addChildNode(cameraNode)         cameraNode.position = SCNVector3(x: 0, y: 3, z: 3)         let scnView = self.view as! SCNView         scnView.scene = scene                  let node = SCNNode(geometry: SCNCylinder(radius: 0.5, height: 1))         node.geometry!.materials = [SCNMaterial(), SCNMaterial(), SCNMaterial()]         node.geometry!.materials[1].diffuse.contents = image         node.geometry!.materials[2].diffuse.contents = image         node.position.x = -1         node.runAction(.repeatForever(.rotate(by: 1, around: SCNVector3(x: 1, y: 0, z: 0), duration: 1)))         scene.rootNode.addChildNode(node)         let node2 = SCNNode(geometry: SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0))         node2.geometry!.materials = [SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial(), SCNMaterial()]         node2.geometry!.materials[4].diffuse.contents = image         node2.geometry!.materials[5].diffuse.contents = image         node2.position.x = 1         node2.runAction(.repeatForever(.rotate(by: 1, around: SCNVector3(x: 1, y: 0, z: 0), duration: 1)))         scene.rootNode.addChildNode(node2)         cameraNode.look(at: SCNVector3(x: 0, y: 0, z: 0))     } }
Replies
0
Boosts
0
Views
741
Activity
Feb ’23
Tracking and Visualizing Faces demo crashes
I tried running the Tracking and Visualizing Faces demo and unfortunately, it crashes at let url = Bundle.main.url(forResource: resourceName, withExtension: "scn", subdirectory: "Models.scnassets")! The "Models.scnassets" is available in the project.
Replies
2
Boosts
0
Views
982
Activity
Feb ’23
how to align 3d model in real world
I am trying to align my previously built model with the real world. Like, making a white ball to be earth while using AR app on an ios device. How can I do that? Any help would be good!
Replies
3
Boosts
0
Views
1.9k
Activity
Feb ’23
White screen with scenekit
I am very new to SceneKit and have been following online tutorials. When I use the scene editor and produce objects in the scene editor, when I run the app, all I can see is a blank screen. Am i missing something here?
Replies
0
Boosts
0
Views
600
Activity
Jan ’23
Programmatically created SCNMaterial vs SceneKit Viewer
In the viewer, the model looks great. I then bring it into the scene and it looks great. But I want to change the material programmatically. Yet this makes it look ugly. It's a physically based light model and a metallic material. Yet renders like a relatively flat phong. The detail of the other maps is there. The color is just flat and off. To eliminate all other variables, I started applying my programmatic material right after creating the node. The material is intended to be the exact same as the one I set in the viewer. Yet I get the same ugly result when I set it to the programmatically created version. Then I only changed the diffuse contents. And this looks great. Hopefully this isn't a stupid question as I can't find any similar complaints. But what parameter is being set in the viewer that I am missing in the SCNMaterial? The following is my attempt to copy all the settings from my viewer and repeat it in code. Nothing has really changed anything from just setting the usual content values: let material = SCNMaterial()         material.lightingModel = .physicallyBased         let matScale: Float = 1.0///25.4         material.isDoubleSided = false         material.diffuse.contents = UIImage(named: "basecolor.png")         //material.diffuse.contentsTransform = SCNMatrix4MakeScale(matScale, matScale, matScale)         material.diffuse.wrapS = .repeat         material.diffuse.wrapT = .repeat         material.diffuse.mipFilter = .nearest         material.diffuse.magnificationFilter = .linear         material.diffuse.minificationFilter = .linear         material.diffuse.mappingChannel = 0         material.diffuse.maxAnisotropy = 1.0         material.metalness.contents = UIImage(named: "scuffed_metalic.png")         material.metalness.wrapS = .repeat         material.metalness.wrapT = .repeat         material.metalness.mipFilter = .nearest         material.metalness.magnificationFilter = .linear         material.metalness.minificationFilter = .linear         material.metalness.mappingChannel = 0         material.metalness.maxAnisotropy = 1.0         material.roughness.contents = UIImage(named: "scuffed_roughness.png")         material.roughness.wrapS = .repeat         material.roughness.wrapT = .repeat         material.roughness.mipFilter = .nearest         material.roughness.magnificationFilter = .linear         material.roughness.minificationFilter = .linear         material.roughness.mappingChannel = 0         material.roughness.maxAnisotropy = 1.0         material.normal.contents = UIImage(named: "scuffed_normal.png")         material.normal.wrapS = .repeat         material.normal.wrapT = .repeat         material.normal.mipFilter = .nearest         material.normal.magnificationFilter = .linear         material.normal.minificationFilter = .linear         material.normal.mappingChannel = 0         material.normal.maxAnisotropy = 1.0         material.metalness.intensity = 1.0         material.roughness.intensity = 1.0//0.0//0.3         material.normal.intensity = 1.0         material.diffuse.intensity = 1.0        material.multiply.contents = UIColor.white         material.multiply.intensity = 1.0         material.transparent.contents = UIColor.white         material.transparent.intensity = 1.0         material.clearCoatNormal.contents = UIColor.white         material.clearCoatNormal.intensity = 1.0         material.locksAmbientWithDiffuse = true         material.emission.contents = UIColor.black         material.emission.intensity = 1.0         material.selfIllumination.contents = UIColor.black         material.selfIllumination.intensity = 1.0         material.clearCoatRoughness.contents = UIColor.black         material.clearCoatRoughness.intensity = 1.0         material.displacement.contents = UIColor.black         material.displacement.intensity = 1.0         material.transparencyMode = .default         material.shininess = 1.0         material.fresnelExponent = 0.0         material.cullMode = .back         material.blendMode = .alpha         material.writesToDepthBuffer = true         material.readsFromDepthBuffer = true         material.locksAmbientWithDiffuse = true         material.isLitPerPixel = true
Replies
4
Boosts
0
Views
1.8k
Activity
Jan ’23
No gobo support for SpotLights in RealityKit
I want to add a gobo effect to a spotlight in RealityKit. I looked in all information, but I could not find support for it, while I saw that it is supported in SceneKit. However, I can not use SceneKit in combination with the RealityKit application I was already writing, and it would be a lot of effort to go back to SceneKit. Is there a solution to or add gobo effects for spotlights in RealityKit, or use the combination of RealityKit and SceneKit in an AR application?
Replies
2
Boosts
0
Views
957
Activity
Jan ’23
Reality Converter is having trouble converting this glb file of mine.
[https://aaronwoods.info/blood-v1.glb) I've tried everything. I think it might be because I compressed it with a tool from this site, https://gltf.report/. But i need the usdz file as well, and i need that file to also be small.
Replies
0
Boosts
0
Views
1.3k
Activity
Jan ’23
RoomPlanAPI object textures
Hi, I want to extract real textures of the objects detected by RoomPlanAPI. So, that i can apply them later on to the model generated by RoomPlan. I want to create an illusion of the real room so that i can have the control over the objects. Does anyone have any idea how can i do that?
Replies
1
Boosts
0
Views
1.2k
Activity
Jan ’23
How to make SceneView in TimelineView use Always on Display
I am rewriting my watch app in SwiftUI in order to make the app work with the always on display. I have got it working well for text and images, which update even when the watch is lowered and the display is faded. However I also use a SceneView and this does not update whilst the watch is lowered. Is it possible to update the SceneView when the watch is lowered? And if so then how would I do this? Is there somewhere I can access the date/time from within the SceneView, which may cause it to update? Thanks.
Replies
0
Boosts
0
Views
971
Activity
Jan ’23
Export animation from .dae
Hello guys,In WWDC 2015 - Session 606 - Enhancements to SceneKit there was an Fox example project which is available to download.Can anyone say what is the correct collada file setttings when exporting model with skeletal animation from 3D tool into .dae file? For example in the demo project there is a "walk.scn".I used 3D tool (Cheetah3D) to make a simple model with simple skeletal animation and export it in .dae, but I can't get my model to be animated on the scene.If I use non skeletal animation in 3D tool and export it in .dae then model animation on the scene works perfect.Maybe someone succeed with exporting model with skeletal animation using another 3D tool like Blender?
Replies
14
Boosts
0
Views
14k
Activity
Jan ’23
Animating ARSCNView Frame Doesn't Affect
Is there a reason why animating the frame or bounds of an ARSCNView doesn't animate the camera layer? I can see the frame size animate but the camera feed snaps to position without any animation before the completion handler. Am I doing something wrong or is this the expected outcome?
Replies
0
Boosts
1
Views
1.3k
Activity
Jan ’23
Move a character with SceneKit
Hello I would like to move a character in swift with SceneKit. I use a gamePad to move the character. It works well at first but when the camera changes orientation, the character is not going in the right direction at all...
Replies
1
Boosts
0
Views
1.4k
Activity
Jan ’23