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

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
820
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
844
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
675
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.7k
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
943
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
958
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
Change the shape of points in SCNGeometry pointcloud
Hello, I'm developing an iOS app with ARKit and SceneKit, where a point cloud is shown in AR. For this, I create a SCNGeometryElement with SCNGeometryPrimitiveType.Point as type and a SCNGeometrySource with SCNGeometrySource.FromVertices. This way, the resulting points are added into the AR as spheres, which results in holes between the elements, even if it is a dense point cloud. Is it possible, to change the shape of those points to e.g. cubes, so that a dense cloud would close the holes? I've already looked into SCNShaderModifiers and SCNPrograms, but I could not find a simple solution to change the appearance of those points/spheres, without having to create a huge amount of nodes or geometries, which would lead to performance issues. I hope that you can help me with this problem. Thanks!
0
0
894
Jan ’23
PhysicsBody.applyForce() is not independent of speed, timeStep and FPS
I've setup a scene with SceneKit where a ball is rolling on a plan. I've simulated the grass friction with applyForce() in order to make it stop after a while (dampen & friction parameters do not reach that effect). Everything works well till I play with runtime parameters, like scnScene.physicsWorld.timeStep, sceneView.preferredFramesPerSecond and scnScene.physicsWorld.speed. I did a comparison with default gravity. Let's take a plan, with a light slope and launch a ball on it: let planSlope = (Float.pi/180.0)*3.0 planNode.rotation = SCNVector4(x:0, y:0, z:1, w: planSlope) ... let impulse =  Float(ballMass) * speed // N.s = m*v let forceVector = simd_float3(1.0, 0.0, 0.0) let force = SCNVector3(forceVector * impulse) ballNode.physicsBody?.applyForce(force, asImpulse: true) The ball will climb the slope up till a certain distance and come back after. If I change timeStep, FPS or speed, the ball is still reaching the same point. That's great. Now, I disable gravity and create a custom force to simulate it using applyForce(): scnScene.physicsWorld.gravity = SCNVector3(0.0, 0.0, 0.0) func physicsWorld(_ physicsWorld: SCNPhysicsWorld, didUpdate physicsContact: SCNPhysicsContact) { ... let gravity = simd_float3(0.0, -9.8, 0.0) let mass = (ballNode.physicsBody?.mass)! let force = SCNVector3(gravity * Float(mass)) ballNode.physicsBody?.applyForce(force, asImpulse: false) This gives exactly the same good result with default constants: scnScene.physicsWorld.speed = 1.0 scnScene.physicsWorld.timeStep = 1.0/60.0 sceneView.preferredFramesPerSecond = 60 But as soon as I change one of them, the distance changes: scnScene.physicsWorld.speed = 2.0 scnScene.physicsWorld.timeStep = 1.0/120.0 sceneView.preferredFramesPerSecond = 30 So, I needed to take them into account on the force: func physicsWorld(_ physicsWorld: SCNPhysicsWorld, didUpdate physicsContact: SCNPhysicsContact) { ... let gravity = simd_float3(0.0, -9.8, 0.0) // Compensate timeStep & FPS & Speed !? gravity *= Float(scnScene.physicsWorld.timeStep)/(1.0/60.0) gravity *= (1.0/60.0)/(1.0/Float(sceneView.preferredFramesPerSecond)) gravity *= 1.0/Float(scnScene.physicsWorld.speed) let mass = (ballNode.physicsBody?.mass)! let force = SCNVector3(gravity * Float(mass)) ballNode.physicsBody?.applyForce(force, asImpulse: false) That's weird, I guess I missed something? The risk is that if FPS changes dynamically due to GPU overload, the result will differ.
0
0
1.1k
Dec ’22
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.6k
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
820
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
844
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
607
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
675
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
965
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
535
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.7k
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
943
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
906
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
958
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.3k
Activity
Jan ’23
Change the shape of points in SCNGeometry pointcloud
Hello, I'm developing an iOS app with ARKit and SceneKit, where a point cloud is shown in AR. For this, I create a SCNGeometryElement with SCNGeometryPrimitiveType.Point as type and a SCNGeometrySource with SCNGeometrySource.FromVertices. This way, the resulting points are added into the AR as spheres, which results in holes between the elements, even if it is a dense point cloud. Is it possible, to change the shape of those points to e.g. cubes, so that a dense cloud would close the holes? I've already looked into SCNShaderModifiers and SCNPrograms, but I could not find a simple solution to change the appearance of those points/spheres, without having to create a huge amount of nodes or geometries, which would lead to performance issues. I hope that you can help me with this problem. Thanks!
Replies
0
Boosts
0
Views
894
Activity
Jan ’23
relighting the real world using RealityKit
Is there an example on how I could perform relighting the real-world using RealityKit (or SceneKit or ARKit if possible)? What I mean is thatI would like to use lights in the virtual world to shine on objects (or using depth map) of the real world. thanks
Replies
2
Boosts
0
Views
1.6k
Activity
Jan ’23
how to reset node to default viewofpoint with animaiton after use camercontroller change viewofpoint
load scene with scenekit, and set allowsCameraControl to yes; after rotate node use gesutre, how can i reset node to defult with animation?
Replies
0
Boosts
0
Views
521
Activity
Dec ’22
PhysicsBody.applyForce() is not independent of speed, timeStep and FPS
I've setup a scene with SceneKit where a ball is rolling on a plan. I've simulated the grass friction with applyForce() in order to make it stop after a while (dampen & friction parameters do not reach that effect). Everything works well till I play with runtime parameters, like scnScene.physicsWorld.timeStep, sceneView.preferredFramesPerSecond and scnScene.physicsWorld.speed. I did a comparison with default gravity. Let's take a plan, with a light slope and launch a ball on it: let planSlope = (Float.pi/180.0)*3.0 planNode.rotation = SCNVector4(x:0, y:0, z:1, w: planSlope) ... let impulse =  Float(ballMass) * speed // N.s = m*v let forceVector = simd_float3(1.0, 0.0, 0.0) let force = SCNVector3(forceVector * impulse) ballNode.physicsBody?.applyForce(force, asImpulse: true) The ball will climb the slope up till a certain distance and come back after. If I change timeStep, FPS or speed, the ball is still reaching the same point. That's great. Now, I disable gravity and create a custom force to simulate it using applyForce(): scnScene.physicsWorld.gravity = SCNVector3(0.0, 0.0, 0.0) func physicsWorld(_ physicsWorld: SCNPhysicsWorld, didUpdate physicsContact: SCNPhysicsContact) { ... let gravity = simd_float3(0.0, -9.8, 0.0) let mass = (ballNode.physicsBody?.mass)! let force = SCNVector3(gravity * Float(mass)) ballNode.physicsBody?.applyForce(force, asImpulse: false) This gives exactly the same good result with default constants: scnScene.physicsWorld.speed = 1.0 scnScene.physicsWorld.timeStep = 1.0/60.0 sceneView.preferredFramesPerSecond = 60 But as soon as I change one of them, the distance changes: scnScene.physicsWorld.speed = 2.0 scnScene.physicsWorld.timeStep = 1.0/120.0 sceneView.preferredFramesPerSecond = 30 So, I needed to take them into account on the force: func physicsWorld(_ physicsWorld: SCNPhysicsWorld, didUpdate physicsContact: SCNPhysicsContact) { ... let gravity = simd_float3(0.0, -9.8, 0.0) // Compensate timeStep & FPS & Speed !? gravity *= Float(scnScene.physicsWorld.timeStep)/(1.0/60.0) gravity *= (1.0/60.0)/(1.0/Float(sceneView.preferredFramesPerSecond)) gravity *= 1.0/Float(scnScene.physicsWorld.speed) let mass = (ballNode.physicsBody?.mass)! let force = SCNVector3(gravity * Float(mass)) ballNode.physicsBody?.applyForce(force, asImpulse: false) That's weird, I guess I missed something? The risk is that if FPS changes dynamically due to GPU overload, the result will differ.
Replies
0
Boosts
0
Views
1.1k
Activity
Dec ’22