scenekit

Resetting ARKit coordinates

白昼怎懂夜的黑 提交于 2019-12-12 10:49:45
问题 I have a simple question. If I wanted to start a game and place the board right in front of me: gameBoard!.position = SCNVector3(0, 0, -0.6) This works until I leave the game and come back again. Can I show the game board in exact same position in front of camera or 0.6m in front of me? I might have physically moved to another position. 回答1: If you want to reset you ARSession, you have to pause, remove all nodes and rerun your session by resetting tracking and removing anchors. I made a reset

AVPlayerLayer as SCNMaterial not rendered, audio playing fine

╄→гoц情女王★ 提交于 2019-12-12 10:43:30
问题 i'm trying to use a AVPlayerLayer as a SCNMaterial to be assigned to a SCNSphere. Based on: https://developer.apple.com/library/mac/samplecode/SceneKit_Slides_WWDC2013/Listings/Scene_Kit_Session_WWDC_2013_Sources_Slides_ASCSlideMaterialLayer_m.html I create a player, create a player layer and have tried with and without a backgroundLayer to assign as material for my SCNSphere Issue is, I get the same result reported here: SCNMaterialProperty not rendering layer Audio plays, video not rendered

Could not cast value of type 'UIView' to 'SCNView'

爷,独闯天下 提交于 2019-12-12 09:55:06
问题 App was building fine until I started adding buttons to the storyboard then I got the above error. It stops at this line of code inside my GameViewController. let scnView = self.view as! SCNView The storyboard itself has its custom class set to GameViewController (theres no option for SCNView). GameViewController itself inherits from UIViewController. Im using Xcode7.2. 回答1: Make sure to also import SceneKit at the top of the file. import SceneKit Open the “Main.storyboard” File. Select

Custom vertex attributes in SceneKit

ε祈祈猫儿з 提交于 2019-12-12 09:23:00
问题 I'm using SceneKit to generate some custom geometry. This is working fine, but I'm struggling to find a way to include custom vertex attributes. Specifically, I'm looking to include an additional SCNVector3 per vertex. I've found plenty of examples which make use of shaderModifiers to include GLSL/Metal code that relies upon custom uniform values, but haven't come across a way of including vertex attributes . Is this possible with SceneKit, or is my thinking backwards? 回答1: there doesn't seem

SceneKit Orbital Transformations

北慕城南 提交于 2019-12-12 07:38:51
问题 So having started with SceneKit all has gone well so far until I stumbled upon transformations, thinking that it would be like CA3d* transformations on layers. However it seems I quite wrong and transformation work quite differently with regards to how the Z-axis works. For example I am trying to accomplish a 3d orbital style movement, similar to a carousel look. This piece of CA3D code works brilliantly to do that: var trans = CATransform3DIdentity trans = CATransform3DRotate(trans, deg *

Xcode: could not load ModelIO.framework, SceneKit.framework, etc

风格不统一 提交于 2019-12-12 07:12:39
问题 Before updating to macOS Mojave my app ran fine without errors, however, I get this error after the update. I have been Googling for 2 days but it seems no one has run into this error yet. Note: The app does run as expected. The 3D model file is in the .scn format. Buildtime error: /scntool:-1: Could not load ModelIO.framework ((null)) /scntool:-1: Could not load SceneKit.framework ((null)) /scntool:-1: Could not load PhysicsKit.framework ((null)) /scntool:-1: Could not load Jet.framework (

Get vector in SCNNode environment from touch location swift

倖福魔咒の 提交于 2019-12-12 04:14:17
问题 I have the position and orientation of my camera, the CGPoint touch location on the screen, I need the line (preferably vector) in the direction that I touched on the screen in my 3d SCNNode environment, how can I get this? A code snippet would be very helpful. 回答1: You can use the SCNSceneRenderer.unprojectPoint(_:) method for this. This method, which is implemented by SCNView , takes the coordinates of your point as a SCNVector3 . Set the first two elements in the coordinate space of your

How to implement a 3D compass with SceneKit

被刻印的时光 ゝ 提交于 2019-12-12 03:58:09
问题 Currently I am confused in terms of making a functionality of 3D compass. With SceneKit, I loaded an arrow object and then fetched sensor data like the code below (The effect is this video) let motionManager = CMMotionManager() motionManager.deviceMotionUpdateInterval = 1.0/60.0 if motionManager.isDeviceMotionAvailable { motionManager.startDeviceMotionUpdates(to: OperationQueue.main, withHandler: { (devMotion, error) -> Void in arrow.orientation = SCNQuaternion(-CGFloat((motionManager

SceneKit Child node position not changed during Parent node rotation

江枫思渺然 提交于 2019-12-12 03:49:41
问题 I'm trying to recode the camera management in SceneKit. For that, I use UIPanGestureRecognizer for the rotation of camera around an object (In this case around the centre of scene). Next I get the different ratio or length to determinate the angle to add at axes (X, Y, Z) of imaginary sphere where camera is attached (cameraOrbit in code). My problem is that I use the position of camera to determinate the angle to add at sphere. But the position is constant. When I change the sphere rotation,

Heavy SceneKit scene in UINavigationViewController takes too long to dealloc

僤鯓⒐⒋嵵緔 提交于 2019-12-12 03:39:42
问题 My app uses standard UINavigationViewController. At some point, user has navigated to a ViewController which shows a SceneKit Scene. This scene is very heavy in memory, since it has around 6000 geometries and each geometry has its own Material (this needs to be this way). When user clicks the back button at the top bar in order to return to the previous viewController, the app correctly pops the current View Controller and shows the one below. However, for around 4 seconds, the UI of the new