scenekit

How to I turn off the ambient light in Scene Kit (with Swift)?

旧时模样 提交于 2019-12-09 16:24:08
问题 When I create a new Scene Kit Game using the Swift language, there is already some come which gives this result : I want to turn off the ambient light which is lighting the cube but I don't get how to do that since there isn't any light explicitly attached to any node. Her's the Game View Controller code : import SceneKit import QuartzCore class GameViewController: NSViewController { @IBOutlet var gameView: GameView override func awakeFromNib(){ // create a new scene let scene = SCNScene() //

SceneKit won't scale a dynamic body

笑着哭i 提交于 2019-12-09 13:07:29
问题 I have a sphere that is a dynamic body. I would like to animate the scale of this sphere so that it grows in size: let sphere = SCNNode(geometry: SCNSphere(radius: 1)) scene.rootNode.addChildNode(sphere) sphere.physicsBody = SCNPhysicsBody.dynamicBody() sphere.runAction(SCNAction.scaleTo(10, duration: 1)) However, this does not seem to work. The sphere falls down due to gravity, but stays the same size. If I comment out the line that gives the sphere its physics body, then the scaling

How do you play a video with alpha channel using AVFoundation?

家住魔仙堡 提交于 2019-12-09 12:11:44
问题 I have an AR application which uses SceneKit , and imports a video on to scene using AVPlayer and thereby adding it as a child node of an SKVideo node. The video is visible as it is supposed to, but the transparency in the video is not achieved. Code as follows: let spriteKitScene = SKScene(size: CGSize(width: self.sceneView.frame.width, height: self.sceneView.frame.height)) spriteKitScene.scaleMode = .aspectFit guard let fileURL = Bundle.main.url(forResource: "Triple_Tap_1", withExtension:

SKVideoNode (embedded in SKScene) as texture for for Scene Kit Node not working

戏子无情 提交于 2019-12-09 05:52:59
问题 I'm attempting to map a video as texture to a primitive cylinder for a VR project by using Scenekit: an SKVideoNode embedded in an SKScene as a texture for a SceneKit SCNTube object, and I just can't get video to display as a still image would. PLayground code below should generate moving video mapped to cylinder, but the mapping does not work: EDIT: ADDED SINGLE LINE AT END OF LISTING TO FIX. CODE BELOW SHOULD WORK import UIKit import SceneKit // for 3D mapping import SpriteKit // for

Unable to activate constraint with anchors

时光毁灭记忆、已成空白 提交于 2019-12-09 05:07:33
问题 So, I'm trying to create a sceneView programatically class ViewController: UIViewController, ARSCNViewDelegate { var sceneView: ARSCNView = ARSCNView() let configuration = ARWorldTrackingConfiguration() override func viewDidLoad() { super.viewDidLoad() self.sceneView.debugOptions = [ARSCNDebugOptions.showFeaturePoints, ARSCNDebugOptions.showWorldOrigin] self.configuration.planeDetection = .horizontal self.sceneView.session.run(configuration) self.sceneView.delegate = self self.sceneView

iOS: drawbacks of disabling Metal API Validation in order to fix pipeline failed assertion?

对着背影说爱祢 提交于 2019-12-08 21:05:30
Adding a SKEmitterNode to a SceneKit Scene via a SpriteKit overlay generates the following exception: -[MTLDebugRenderCommandEncoder validateFramebufferWithRenderPipelineState:]:1196: failed assertion `For color attachment 0, the render pipeline's pixelFormat (MTLPixelFormatRGBA8Unorm_sRGB) does not match the framebuffer's pixelFormat (MTLPixelFormatBGR10_XR).' This exception occurs on an iPhone 7 device, but does not appear in the simulator. Searching online yielded one valid workaround: disabling Metal API Validation (in Edit Scheme > Options). What are the drawbacks or gotchas with this

iDevice attitude: stabilising quaternion

大憨熊 提交于 2019-12-08 12:54:55
问题 I'm trying to use iDevice's attitude self.motionManager.deviceMotion.attitude.quaternion the device is resting on the table, but the values are not the same. how to stabilise these values without causing bad rotation? I'm using the device attitude to rotate the camera node. (x = -0.0055437298906573507, y = -0.0078092851375721247, z = -0.041180405121897398, w = 0.999105828407855) (x = -0.0061666945840810842, y = -0.0067849414785486747, z = -0.041464744435584115, w = 0.99909789881469635) (x =

How do it convert 2D Points From 3d Points in ArKit iOS

你离开我真会死。 提交于 2019-12-08 12:02:13
问题 how do i get the 2d points to plot on to uiview from 3d SCNNode. Suppose i have following SCNNodes pos(1.002163 -0.524722 -0.770023) pos(1.174463 -0.765098 -0.607172) pos(0.668790 -0.744061 -0.696863) pos(0.781208 -0.744061 -1.228943) And i need 2d points from above .I am new to arkit please help me 回答1: You are looking for projectPoint let projectedPoint = sceneView.projectPoint(pos) 来源: https://stackoverflow.com/questions/50741286/how-do-it-convert-2d-points-from-3d-points-in-arkit-ios

Alpha map in SceneKit

て烟熏妆下的殇ゞ 提交于 2019-12-08 11:48:34
问题 I am trying to correctly show the eyelashes of a model. I am using alpha map for the eyelashes but I have no idea how to correctly set it up in Xcode. See image below. (the same alpha map is used in Blender and when set transparency all is good). thanks 回答1: Transparency mapping in iOS is different to anything I've ever seen in all my years of 3D/CAD. You must use a .png file with transparent areas transparent, and opaque areas as black. 回答2: It's hard to tell by just a screenshot of the

scenekit, how to bend an object

☆樱花仙子☆ 提交于 2019-12-08 11:48:23
问题 I'm new to 3D. I have a straight stick object which is a SCNBox, and at some stage I want to bend it (with animation). Is there any way to achieve this? Or do I have to use multiple objects to simulate a SCNBox in the first place, and then move and rotate those objects to simulate bending? 回答1: SCNBox has a heightSegmentCount property that you can use to produce more vertices. Using a shader modifier you'll be able to bend the cube. That's how the grass blades are animated in Fox: Building a