SceneKit

RSS for tag

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

SceneKit Documentation

Posts under SceneKit subtopic

Post

Replies

Boosts

Views

Activity

Hittest doesn't work with SCNRenderer
I'm implementing an example app using ARKit + SceneKit. In order to do hittest on scenekit objects(nodes) in the scene, I used ARSCNView.hittest() and it worked well. However when I draw same scene with SCNRenderer(I'm writing also an offscreen renderer) and try to do hittest with SCNRenderer.hittest() but it doesn't return any results.I assumed the range of input points should be only inside of GPU viewport which is SCNRenderer.currentViewport. But it doesn't work Any idea how to do properly do hittest with SCNRenderer?Thanks in advance
6
0
2.5k
Oct ’21
Xcode SceneKit template not working
I created a project using "AR Reality App" template. When I run it, there are following error messages in the debug panel. There is no virtual box of Experience.rcproject in the physical world. What am I missing? I am sure this template was working before my updating iOS and Xcode to current/lates version. My testing environment: Xcode: Version 13.0 (13A233), iOS: 15.0.1 2021-10-08 19:00:56.253834+0300 FirstARProject[13602:894041] Metal GPU Frame Capture Enabled 2021-10-08 19:00:56.254115+0300 FirstARProject[13602:894041] Metal API Validation Enabled 2021-10-08 19:00:57.081193+0300 FirstARProject[13602:894041] [AssetTypes] Registering library (/System/Library/PrivateFrameworks/CoreRE.framework/default.metallib) that already exists in shader manager. Library will be overwritten. 2021-10-08 19:00:57.439006+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/suFeatheringCreateMergedOcclusionMask.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.491103+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arKitPassthrough.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.493113+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/drPostAndComposition.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.494988+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arSegmentationComposite.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.497119+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute0.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.499372+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute1.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.500704+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute2.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.524705+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute3.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.526440+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute4.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.527467+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute5.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.528473+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute6.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.529441+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute7.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.530827+0300 FirstARProject[13602:894041] [Foundation.Serialization] Json Parse Error line 18: Json Deserialization; unknown member 'EnableARProbes' - skipping. 2021-10-08 19:00:57.530896+0300 FirstARProject[13602:894041] [Foundation.Serialization] Json Parse Error line 20: Json Deserialization; unknown member 'EnableGuidedFilterOcclusion' - skipping. 2021-10-08 19:01:01.877601+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879167+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879276+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879796+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879906+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880011+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880096+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880177+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880450+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:02.732980+0300 FirstARProject[13602:894398] [Technique] ARWorldTrackingTechnique <0x11a48d2e0>: World tracking performance is being affected by resource constraints [2]
1
0
2k
Oct ’21
SceneKit Fox Code Crashes on M1
I'm trying to run the Fox game sample SceneKit code from WWDC2017, but it crashes when calculating the collision bounding box. // Setup collision shape let (min, max) = model.boundingBox Thread 1: EXC_BAD_ACCESS (code=1, address=0x7fffc0000020) This error only occurs on my M1 iMac, but runs fine on Intel (using Rosetta). I really want to get started on SceneKit development for M1 Macs so any help would be appreciated.
4
0
1.3k
Oct ’21
SceneKit Labs?
Are there any hands-on or directed labs for SceneKit anytime in the near future? Are there any recent SceneKit guides from Apple? There aren't many current resources online so I'm pretty much stuck just reading documentation and experimenting on my own (which feels inefficient).
0
0
691
Sep ’21
Several bizarre SCNCameraController arcball behaviors on iOS but not macOS.
Hello all,I have a pretty simple scene set up at the moment displaying a single centered molecule (molNode). I have been attempting to make use of SCNCameraController to avoid reimplementing arcball camera control. Unfortunately, I'm running into some very strange behaviors with the below settings on iOS, which do not seem to be present on macOS.I do not have a scene file, molNode is generated from a macromolecular information file. It consists, roughly, of a few hundred spheres and some cylinders. I have also included a snippet in which I perform a small hack to attach a light to the "free camera" node which SceneKit manages. At the first user interaction with the scene, SceneKit hijacks the only camera in the scene and attaches it to this node, so I use this observation to keep my directional light attached to the camera. This observation is handled every time one performs a double-tap to reset the viewport, as well as on the first user interaction. I doubt that it is related.// molNode is set up... // Camera and Lighting let camera = SCNCamera() camera.usesOrthographicProjection = true camera.orthographicScale = 30 let cameraNode = SCNNode() cameraNode.camera = camera // this camera will be removed from this node by SceneKit automatically. scene.rootNode.addChildNode(cameraNode) cameraNode.position = SCNVector3(x: 0, y: 0, z: 30) let ambientLightNode = SCNNode() ambientLightNode.light = SCNLight() ambientLightNode.light!.type = .ambient ambientLightNode.light!.color = UIColor(red: 0.14, green: 0.14, blue: 0.14, alpha: 1.0) scene.rootNode.addChildNode(ambientLightNode) let cameraLightNode = SCNNode() cameraLightNode.light = SCNLight() cameraLightNode.light!.type = .directional // defaults to (0, 0, -1), which matches the camera. cameraLightNode.light!.intensity = 800 scene.rootNode.addChildNode(cameraLightNode) // Scene View Setup let scnView = self.view as! SCNView scnView.preferredFramesPerSecond = 60 scnView.scene = scene scnView.allowsCameraControl = true scnView.defaultCameraController.interactionMode = .orbitArcball scnView.defaultCameraController.target = molNode.position scnView.defaultCameraController.inertiaEnabled = true self.povObservation = scnView.defaultCameraController.observe(\.pointOfView, options: [.new]) { (cameraController, change) in if let pointOfView = cameraController.pointOfView { // Whenever SceneKit creates a new pointOfView node and attaches the camera to it, // recover the camera light and attach it as well. cameraLightNode.removeFromParentNode() pointOfView.addChildNode(cameraLightNode) } }1. The first problem is that y-axis camera control is inverted. Drawing an arc vertically results in the opposite of expected rotation for the "pinch and drag the surface of the sphere" idiom of arcball control. This does not occur on macOS with mouse control. There, dragging the scene rotates as one would expect. This occurs in both arcball interaction modes. It does not occur in .orbitTurntable or .orbitAngleMapping... however turntable is not appropriate for my use case, and angleMapping does not handle rotations for diagonal drag/swipes intuitively (it results in rotations along multiple degrees of freedom).2. The second, even more confounding issue, has to do with inertia. While "drag" control is inverted, inertia is not. This produces some extremely jarring results, namely that a drag will move in one direction, but when released, the model continues moving inertially in the direction opposite to the drag. "Flicking" gestures therefore result in the kind of movement you would expect, while dragging does not. Even moreso than #1, this simply seems wrong and entirely unintuitive.I am somewhat apprehensive that this is an error/bug in SceneKit. If one watches the WWDC 2017 video (604) in which SCNCameraController is introduced, the demonstration of arcball control there works the way one would expect, e.g. without the inverted vertical orbiting. Presumably this is because the demo was on macOS.I have been attempting to find means to remedy these issues (without implementing my own arcball camera control), but have so far come up short.Thank you all in advance for any help you may be able to provide.
1
0
2.2k
Sep ’21
How to create our own Memoji
Hi , as we know apple AvatarKit is a private framework and we can not use it in our app our access user Memoji in anyways. so we decided to create our own Memoji in our app. any documents on how to build Memoji 3d model? our any tips or steps to flow to create our own Memoji ?
1
0
2.2k
Sep ’21
Changing the volume of an SCNAudioPlayer in real time - Swift
I know a similar question was asked here...(https://forums.developer.apple.com/thread/27681)...but it doesnt give an example of how to do it which is what I am after as I can't work it out from the information provided.I am trying to work out how I can change the volume of an SCNAudioPlayer in real time.Currently, I have an SCNAudioSource connected to an SCNAudioPlayer. This audio player is then assigned to a SCNNode so that my sound makes use of SceneKits spatial audio processing.As it stands, I am able to change the volume of each SCNNode using SCNAudioSource.volumetriggered by the boolean variable vol. An extract of my code for this is shown below:(audioSource, audioCount) = soundFileSelect(audioFileIndex: 0) audioSource?.isPositional = true if vol { audioSource?.volume = 1.0 } else { audioSource?.volume = 0.0 } let audioPlayer = SCNAudioPlayer(source: audioSource!) geometryNode.addAudioPlayer(audioPlayer) let play = SCNAction.playAudio(audioSource!, waitForCompletion: true) let loopPlay = SCNAction.repeatForever(play) geometryNode.runAction(loopPlay)However, this only changes the default volume setting of the audio source, and so only happens when the node is spawned. I am trying to change the volume of it in real time, after a button press.I feel I am missing something very simple, and have trolled the internet for documentation and examples but am really struggling. From Apple's API documentation I am fairly certain it can be done. As far as I can tell you have to use the audioNode property associated with the SCNAudioPlayer which forms part of the AVAudioMixing protocol. Using this AVAudioMxing volume property should be what I need!However, for the life of me I can't work out how to implement this process in code within my current setup. I can access mainMixer.volume/outputvolume such as:audioPlayer.audioNode?.engine?.mainMixerNode.outputVolume=0but this doesn't seem to have any effect.How do the AV and SCN components link together?Any help or examples of how one goes about implementing this would be hugely appreciated!Thanks in advanced.
3
0
18k
Sep ’21
SceneKits future
I have developed an app using SceneKit since Swift came out. Now SwiftUI is out and uses structs rather than classes. SceneKit is a cascade of classes. As a newbie, I am concerned that my code might be obsolete through depreciations soon after publication and I'd rather get ahead of the issues now. So, is SceneKit long-term viable? My first attempts at converting my custom classes to structs seems impossible without Apple leading the way. If I understand correctly, I can make a struct whose only member is an instance of a class, but the benefits of the struct, e.g., minimal memory, processing time, etc., are lost.
13
0
8.1k
Sep ’21
How to place image on SceneKit Geometry Object?
Hi devs, I've been following along with this tutorial https://developer.apple.com/videos/play/wwdc2015/606/ (yes I know its a few years old), but I can't recreate the part in the demo where he drags an image onto the box object to create the wooden block. I have the same image file but when I drag into the SceneKit editor nothing happens and no errors are thrown. Did this functionality change in later versions of Xcode/scenekit editor? How do I place an image on a geometry object now? Appreciate the help -atxnanners
1
0
1.1k
Sep ’21
Plane in 3d Space
I have plane from which I know a point and the normal. Both are SIMD3. I want to calculate a 2d coordinate system (directions of x and y in 3d space) , which makes scence to the User. The Planes can also be parallel to xy and so on. (But that is Easy). I also would be very thankful if there is away to get points which are on the plane to the 2D formt. I hope you could understand my english.
1
0
702
Sep ’21
How to get the vertices of SCNBox?
I created a SCNBox in real time based on a group of anchors that I do not know the locations in advance. I create the SCNBox using the following code:            let nodes: [SCNNode] = getMyNodes()           for node in nodes {             if(sceneView.anchor(for: node)?.name != nil) && (sceneView.anchor(for: node)?.name != "dot"){               parentNode.addChildNode(node)             }           }           let width = (abs(parentNode.boundingBox.0.x) + abs(parentNode.boundingBox.1.x))           let height = (abs(parentNode.boundingBox.0.y) + abs(parentNode.boundingBox.1.y))           let length = (abs(parentNode.boundingBox.0.z) + abs(parentNode.boundingBox.1.z))           let box = SCNBox(width: CGFloat(width), height: CGFloat(height), length: CGFloat(0.3), chamferRadius: 0)           let boxNode = SCNNode(geometry: box)           boxNode.position = parentNode.boundingSphere.center           box.firstMaterial?.diffuse.contents = UIColor.white           box.firstMaterial?.transparency = 0.4           boxNode.position = parentNode.boundingSphere.center           boxNode.name = "box"           boxNode.addChildNode(parentNode)           sceneView.scene.rootNode.addChildNode(boxNode)           boundingBox = boxNode So how do I get the vertices position of the box? The geometry of the node contains the location, length, width and height but it does not contain the location of its vertices. I also obtain the the location of the finger using the vision framework. I need to know the location of the vertex so I can enlarge or shrink the box with respect to the finger location. I tried to to calculate the vertex using the position of the center and the length and with but the location does not add back to the finger location. I think this has to do something with different scale system.
0
0
799
Sep ’21
Is it possible to access a specific SceneKit node via its "ID" number
I am using SceneKit to make a type of block pushing game and I am trying to access a specific node that I interact with. I know I can use the nodes name but I am trying to access a specific node that has the same name as other reference nodes, its a pushable block that I need to make an array of its past movement so that I can undo the players actions. I have printed the nodes details to the console and each one has a unique "ID" <SCNNode: 0x6000039ef300 'wall' pos(0.000000 0.500000 4.000000) but I can't seem to then get access to the node using this "ID" I can't find this documented anywhere so I don't know if this is even possible.
0
0
586
Sep ’21
How to Load Scene Kit View into Motion 5
I want to take a Scene kit view which is normally displayed in a .xib file like so:SCNView *sceneView = (SCNView *)self.view;This sceneview is then generally called by the awakeFromNib method from what I have seen.But instead of the view being created in the view i want to display it in the canvas of Motion 5 which grabbed via the FxPlug SDK via the renderOutput method in the FxPlug API as seen in the method signature. In the signature there is an outputImage where you cna grab the width and the height which represent the canvas in which to use for Motion. - (BOOL)renderOutput:(FxImage *)outputImage withInfo:(FxRenderInfo)renderInfoI want to be able to use the Scenekit SDK and functionaility that it provides but display what I create inside of Motion 5 via the FxPlug Framework. Is there a way to accomplish this? Is it possible to take a Scenekit and convert it into an FxImage so they are usable textures? I know this is a long shot but any help or guidance would be greatly appreciated.
2
0
1.2k
Aug ’21
SceneKit SCNVector math Crippled on M1
I've seen two crashes in the fox sample code already for simple SCNVector functions. The enemies also don't move - I suppose that's a Gameplay Kit error. I can see glimpses of other possible problems too - and of course the intermittent display stutter is there. (You know, the one on every OS after High Sierra for any Metal backed view) I tried both on m1 native and rosetta. Unless I have some wrong setting, SceneKit's SCNVector math seems crippled at the moment. Already sent reports... Can someone else confirm the crashes?
3
0
1.3k
Aug ’21
Hittest doesn't work with SCNRenderer
I'm implementing an example app using ARKit + SceneKit. In order to do hittest on scenekit objects(nodes) in the scene, I used ARSCNView.hittest() and it worked well. However when I draw same scene with SCNRenderer(I'm writing also an offscreen renderer) and try to do hittest with SCNRenderer.hittest() but it doesn't return any results.I assumed the range of input points should be only inside of GPU viewport which is SCNRenderer.currentViewport. But it doesn't work Any idea how to do properly do hittest with SCNRenderer?Thanks in advance
Replies
6
Boosts
0
Views
2.5k
Activity
Oct ’21
Xcode SceneKit template not working
I created a project using "AR Reality App" template. When I run it, there are following error messages in the debug panel. There is no virtual box of Experience.rcproject in the physical world. What am I missing? I am sure this template was working before my updating iOS and Xcode to current/lates version. My testing environment: Xcode: Version 13.0 (13A233), iOS: 15.0.1 2021-10-08 19:00:56.253834+0300 FirstARProject[13602:894041] Metal GPU Frame Capture Enabled 2021-10-08 19:00:56.254115+0300 FirstARProject[13602:894041] Metal API Validation Enabled 2021-10-08 19:00:57.081193+0300 FirstARProject[13602:894041] [AssetTypes] Registering library (/System/Library/PrivateFrameworks/CoreRE.framework/default.metallib) that already exists in shader manager. Library will be overwritten. 2021-10-08 19:00:57.439006+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/suFeatheringCreateMergedOcclusionMask.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.491103+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arKitPassthrough.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.493113+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/drPostAndComposition.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.494988+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arSegmentationComposite.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.497119+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute0.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.499372+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute1.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.500704+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute2.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.524705+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute3.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.526440+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute4.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.527467+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute5.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.528473+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute6.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.529441+0300 FirstARProject[13602:894041] [Assets] Resolving material name 'engine:BuiltinRenderGraphResources/AR/arInPlacePostProcessCombinedPermute7.rematerial' as an asset path -- this usage is deprecated; instead provide a valid bundle 2021-10-08 19:00:57.530827+0300 FirstARProject[13602:894041] [Foundation.Serialization] Json Parse Error line 18: Json Deserialization; unknown member 'EnableARProbes' - skipping. 2021-10-08 19:00:57.530896+0300 FirstARProject[13602:894041] [Foundation.Serialization] Json Parse Error line 20: Json Deserialization; unknown member 'EnableGuidedFilterOcclusion' - skipping. 2021-10-08 19:01:01.877601+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879167+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879276+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879796+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.879906+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880011+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880096+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880177+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:01.880450+0300 FirstARProject[13602:894041] throwing -10878 2021-10-08 19:01:02.732980+0300 FirstARProject[13602:894398] [Technique] ARWorldTrackingTechnique <0x11a48d2e0>: World tracking performance is being affected by resource constraints [2]
Replies
1
Boosts
0
Views
2k
Activity
Oct ’21
SceneKit Fox Code Crashes on M1
I'm trying to run the Fox game sample SceneKit code from WWDC2017, but it crashes when calculating the collision bounding box. // Setup collision shape let (min, max) = model.boundingBox Thread 1: EXC_BAD_ACCESS (code=1, address=0x7fffc0000020) This error only occurs on my M1 iMac, but runs fine on Intel (using Rosetta). I really want to get started on SceneKit development for M1 Macs so any help would be appreciated.
Replies
4
Boosts
0
Views
1.3k
Activity
Oct ’21
SceneKit Labs?
Are there any hands-on or directed labs for SceneKit anytime in the near future? Are there any recent SceneKit guides from Apple? There aren't many current resources online so I'm pretty much stuck just reading documentation and experimenting on my own (which feels inefficient).
Replies
0
Boosts
0
Views
691
Activity
Sep ’21
Several bizarre SCNCameraController arcball behaviors on iOS but not macOS.
Hello all,I have a pretty simple scene set up at the moment displaying a single centered molecule (molNode). I have been attempting to make use of SCNCameraController to avoid reimplementing arcball camera control. Unfortunately, I'm running into some very strange behaviors with the below settings on iOS, which do not seem to be present on macOS.I do not have a scene file, molNode is generated from a macromolecular information file. It consists, roughly, of a few hundred spheres and some cylinders. I have also included a snippet in which I perform a small hack to attach a light to the "free camera" node which SceneKit manages. At the first user interaction with the scene, SceneKit hijacks the only camera in the scene and attaches it to this node, so I use this observation to keep my directional light attached to the camera. This observation is handled every time one performs a double-tap to reset the viewport, as well as on the first user interaction. I doubt that it is related.// molNode is set up... // Camera and Lighting let camera = SCNCamera() camera.usesOrthographicProjection = true camera.orthographicScale = 30 let cameraNode = SCNNode() cameraNode.camera = camera // this camera will be removed from this node by SceneKit automatically. scene.rootNode.addChildNode(cameraNode) cameraNode.position = SCNVector3(x: 0, y: 0, z: 30) let ambientLightNode = SCNNode() ambientLightNode.light = SCNLight() ambientLightNode.light!.type = .ambient ambientLightNode.light!.color = UIColor(red: 0.14, green: 0.14, blue: 0.14, alpha: 1.0) scene.rootNode.addChildNode(ambientLightNode) let cameraLightNode = SCNNode() cameraLightNode.light = SCNLight() cameraLightNode.light!.type = .directional // defaults to (0, 0, -1), which matches the camera. cameraLightNode.light!.intensity = 800 scene.rootNode.addChildNode(cameraLightNode) // Scene View Setup let scnView = self.view as! SCNView scnView.preferredFramesPerSecond = 60 scnView.scene = scene scnView.allowsCameraControl = true scnView.defaultCameraController.interactionMode = .orbitArcball scnView.defaultCameraController.target = molNode.position scnView.defaultCameraController.inertiaEnabled = true self.povObservation = scnView.defaultCameraController.observe(\.pointOfView, options: [.new]) { (cameraController, change) in if let pointOfView = cameraController.pointOfView { // Whenever SceneKit creates a new pointOfView node and attaches the camera to it, // recover the camera light and attach it as well. cameraLightNode.removeFromParentNode() pointOfView.addChildNode(cameraLightNode) } }1. The first problem is that y-axis camera control is inverted. Drawing an arc vertically results in the opposite of expected rotation for the "pinch and drag the surface of the sphere" idiom of arcball control. This does not occur on macOS with mouse control. There, dragging the scene rotates as one would expect. This occurs in both arcball interaction modes. It does not occur in .orbitTurntable or .orbitAngleMapping... however turntable is not appropriate for my use case, and angleMapping does not handle rotations for diagonal drag/swipes intuitively (it results in rotations along multiple degrees of freedom).2. The second, even more confounding issue, has to do with inertia. While "drag" control is inverted, inertia is not. This produces some extremely jarring results, namely that a drag will move in one direction, but when released, the model continues moving inertially in the direction opposite to the drag. "Flicking" gestures therefore result in the kind of movement you would expect, while dragging does not. Even moreso than #1, this simply seems wrong and entirely unintuitive.I am somewhat apprehensive that this is an error/bug in SceneKit. If one watches the WWDC 2017 video (604) in which SCNCameraController is introduced, the demonstration of arcball control there works the way one would expect, e.g. without the inverted vertical orbiting. Presumably this is because the demo was on macOS.I have been attempting to find means to remedy these issues (without implementing my own arcball camera control), but have so far come up short.Thank you all in advance for any help you may be able to provide.
Replies
1
Boosts
0
Views
2.2k
Activity
Sep ’21
How to create our own Memoji
Hi , as we know apple AvatarKit is a private framework and we can not use it in our app our access user Memoji in anyways. so we decided to create our own Memoji in our app. any documents on how to build Memoji 3d model? our any tips or steps to flow to create our own Memoji ?
Replies
1
Boosts
0
Views
2.2k
Activity
Sep ’21
Changing the volume of an SCNAudioPlayer in real time - Swift
I know a similar question was asked here...(https://forums.developer.apple.com/thread/27681)...but it doesnt give an example of how to do it which is what I am after as I can't work it out from the information provided.I am trying to work out how I can change the volume of an SCNAudioPlayer in real time.Currently, I have an SCNAudioSource connected to an SCNAudioPlayer. This audio player is then assigned to a SCNNode so that my sound makes use of SceneKits spatial audio processing.As it stands, I am able to change the volume of each SCNNode using SCNAudioSource.volumetriggered by the boolean variable vol. An extract of my code for this is shown below:(audioSource, audioCount) = soundFileSelect(audioFileIndex: 0) audioSource?.isPositional = true if vol { audioSource?.volume = 1.0 } else { audioSource?.volume = 0.0 } let audioPlayer = SCNAudioPlayer(source: audioSource!) geometryNode.addAudioPlayer(audioPlayer) let play = SCNAction.playAudio(audioSource!, waitForCompletion: true) let loopPlay = SCNAction.repeatForever(play) geometryNode.runAction(loopPlay)However, this only changes the default volume setting of the audio source, and so only happens when the node is spawned. I am trying to change the volume of it in real time, after a button press.I feel I am missing something very simple, and have trolled the internet for documentation and examples but am really struggling. From Apple's API documentation I am fairly certain it can be done. As far as I can tell you have to use the audioNode property associated with the SCNAudioPlayer which forms part of the AVAudioMixing protocol. Using this AVAudioMxing volume property should be what I need!However, for the life of me I can't work out how to implement this process in code within my current setup. I can access mainMixer.volume/outputvolume such as:audioPlayer.audioNode?.engine?.mainMixerNode.outputVolume=0but this doesn't seem to have any effect.How do the AV and SCN components link together?Any help or examples of how one goes about implementing this would be hugely appreciated!Thanks in advanced.
Replies
3
Boosts
0
Views
18k
Activity
Sep ’21
SceneKits future
I have developed an app using SceneKit since Swift came out. Now SwiftUI is out and uses structs rather than classes. SceneKit is a cascade of classes. As a newbie, I am concerned that my code might be obsolete through depreciations soon after publication and I'd rather get ahead of the issues now. So, is SceneKit long-term viable? My first attempts at converting my custom classes to structs seems impossible without Apple leading the way. If I understand correctly, I can make a struct whose only member is an instance of a class, but the benefits of the struct, e.g., minimal memory, processing time, etc., are lost.
Replies
13
Boosts
0
Views
8.1k
Activity
Sep ’21
SceneKit Editor Question - Drag and Drop
Can I still drag and drop an image onto a Geometry object in SceneKit editor? I tried to do this on my M1 iMac on Xcode v13beta and it didn't work. Is there a new way to add images onto geometry objects?
Replies
0
Boosts
0
Views
579
Activity
Sep ’21
How to place image on SceneKit Geometry Object?
Hi devs, I've been following along with this tutorial https://developer.apple.com/videos/play/wwdc2015/606/ (yes I know its a few years old), but I can't recreate the part in the demo where he drags an image onto the box object to create the wooden block. I have the same image file but when I drag into the SceneKit editor nothing happens and no errors are thrown. Did this functionality change in later versions of Xcode/scenekit editor? How do I place an image on a geometry object now? Appreciate the help -atxnanners
Replies
1
Boosts
0
Views
1.1k
Activity
Sep ’21
Plane in 3d Space
I have plane from which I know a point and the normal. Both are SIMD3. I want to calculate a 2d coordinate system (directions of x and y in 3d space) , which makes scence to the User. The Planes can also be parallel to xy and so on. (But that is Easy). I also would be very thankful if there is away to get points which are on the plane to the 2D formt. I hope you could understand my english.
Replies
1
Boosts
0
Views
702
Activity
Sep ’21
How to get the vertices of SCNBox?
I created a SCNBox in real time based on a group of anchors that I do not know the locations in advance. I create the SCNBox using the following code:            let nodes: [SCNNode] = getMyNodes()           for node in nodes {             if(sceneView.anchor(for: node)?.name != nil) && (sceneView.anchor(for: node)?.name != "dot"){               parentNode.addChildNode(node)             }           }           let width = (abs(parentNode.boundingBox.0.x) + abs(parentNode.boundingBox.1.x))           let height = (abs(parentNode.boundingBox.0.y) + abs(parentNode.boundingBox.1.y))           let length = (abs(parentNode.boundingBox.0.z) + abs(parentNode.boundingBox.1.z))           let box = SCNBox(width: CGFloat(width), height: CGFloat(height), length: CGFloat(0.3), chamferRadius: 0)           let boxNode = SCNNode(geometry: box)           boxNode.position = parentNode.boundingSphere.center           box.firstMaterial?.diffuse.contents = UIColor.white           box.firstMaterial?.transparency = 0.4           boxNode.position = parentNode.boundingSphere.center           boxNode.name = "box"           boxNode.addChildNode(parentNode)           sceneView.scene.rootNode.addChildNode(boxNode)           boundingBox = boxNode So how do I get the vertices position of the box? The geometry of the node contains the location, length, width and height but it does not contain the location of its vertices. I also obtain the the location of the finger using the vision framework. I need to know the location of the vertex so I can enlarge or shrink the box with respect to the finger location. I tried to to calculate the vertex using the position of the center and the length and with but the location does not add back to the finger location. I think this has to do something with different scale system.
Replies
0
Boosts
0
Views
799
Activity
Sep ’21
Is it possible to access a specific SceneKit node via its "ID" number
I am using SceneKit to make a type of block pushing game and I am trying to access a specific node that I interact with. I know I can use the nodes name but I am trying to access a specific node that has the same name as other reference nodes, its a pushable block that I need to make an array of its past movement so that I can undo the players actions. I have printed the nodes details to the console and each one has a unique "ID" <SCNNode: 0x6000039ef300 'wall' pos(0.000000 0.500000 4.000000) but I can't seem to then get access to the node using this "ID" I can't find this documented anywhere so I don't know if this is even possible.
Replies
0
Boosts
0
Views
586
Activity
Sep ’21
Scenekit crashes after iOS Update to 14.7
After updating iOS to 14.7 I got a scenekit crash whenever I start opening an AR session. (com.apple.scenekit.scnview-renderer (19): EXC_BAD_ACCESS (code=2, address=0x1d934ec04) Any idea how this can be fixed? Best Anri02
Replies
2
Boosts
0
Views
906
Activity
Aug ’21
How to Load Scene Kit View into Motion 5
I want to take a Scene kit view which is normally displayed in a .xib file like so:SCNView *sceneView = (SCNView *)self.view;This sceneview is then generally called by the awakeFromNib method from what I have seen.But instead of the view being created in the view i want to display it in the canvas of Motion 5 which grabbed via the FxPlug SDK via the renderOutput method in the FxPlug API as seen in the method signature. In the signature there is an outputImage where you cna grab the width and the height which represent the canvas in which to use for Motion. - (BOOL)renderOutput:(FxImage *)outputImage withInfo:(FxRenderInfo)renderInfoI want to be able to use the Scenekit SDK and functionaility that it provides but display what I create inside of Motion 5 via the FxPlug Framework. Is there a way to accomplish this? Is it possible to take a Scenekit and convert it into an FxImage so they are usable textures? I know this is a long shot but any help or guidance would be greatly appreciated.
Replies
2
Boosts
0
Views
1.2k
Activity
Aug ’21
SceneKit SCNVector math Crippled on M1
I've seen two crashes in the fox sample code already for simple SCNVector functions. The enemies also don't move - I suppose that's a Gameplay Kit error. I can see glimpses of other possible problems too - and of course the intermittent display stutter is there. (You know, the one on every OS after High Sierra for any Metal backed view) I tried both on m1 native and rosetta. Unless I have some wrong setting, SceneKit's SCNVector math seems crippled at the moment. Already sent reports... Can someone else confirm the crashes?
Replies
3
Boosts
0
Views
1.3k
Activity
Aug ’21
Execution of the command buffer was aborted due to an error during execution. Too much geometry to support memoryless render pass attachments. (IOAF code 13)
Hi this is my problem: Execution of the command buffer was aborted due to an error during execution. Too much geometry to support memoryless render pass attachments. (IOAF code 13)How I Fix it?Thank you
Replies
4
Boosts
0
Views
3k
Activity
Jul ’21