scenekit

Align 3D object parallel to vertical plane detected by estametedVerticalPlane

不问归期 提交于 2019-12-11 16:44:15
问题 I have this book, but I'm currently remixing the furniture app from the video tutorial that was free on AR/VR week. I would like to have a 3D wall canvas aligned with the wall/vertical plane detected. This is proving to be harder than I thought. Positioning isn't an issue. Much like the furniture placement app you can just get the column3 of the hittest.worldtransform and provide the new geometry this vector3 for position. But I do not know what I have to do to get my 3D object rotated to

How to Center the Pivot Point of a Model in SceneKit Editor

岁酱吖の 提交于 2019-12-11 16:28:45
问题 Is there anyway to center the pivot of a model? Currently (by default) it is set to the bottom left. I want to set to the center. How can I do that? Here is the image: UPDATE : I added another node and added the chair as a child. So, now it works better but it does not rotate all the way and it resets the position if I continue to rotate. Here is the code for the panned operation: @objc func panned(recognizer :UIPanGestureRecognizer) { var newAngleY :Float = 0.0 if recognizer.state ==

SCNSceneSource init is giving Ambiguous use of 'init(URL:options:)' error

淺唱寂寞╮ 提交于 2019-12-11 16:12:06
问题 This init is giving me an error: Ambiguous use of 'init(URL:options:)' let sceneSource = SCNSceneSource(URL: url, options: [SCNSceneSourceAnimationImportPolicyKey : SCNSceneSourceAnimationImportPolicyDoNotPlay])! Please help me understand what the issue is, and how I might go about fixing it. Thanks so much for any advice! 回答1: You used uppercase letters in the URL parameter instead of lowercase. Replace let sceneSource = SCNSceneSource(URL: url, options:

adding a lot of custom nodes to scene takes a long time to load

丶灬走出姿态 提交于 2019-12-11 14:28:57
问题 I am building a scenekit app however I am having issues with some of the finer details. I created a scene and I am adding custom geometry to it and it works fine until the number of nodes gets to about 100. It is ideal to add a large number of nodes to a scene and is there a cleaner way to do it? for i in 0..<modelArr!.count { let model = modelArr![i] let pos: [SCNVector3] = Parser.loadPosition(model) let norm:[SCNVector3] = Parser.loadNormals(model) let ind:[CInt] = Parser.loadIndices(model)

Get pixel color in sceneKit View, iOS, Swift

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 13:23:30
问题 I try to get the color of a specific pixel in my sceneKit view. However, I only get the color of my background. In my scene I have a sphere with an image on the texture. Can somebody help me? import UIKit extension UIView { func getColourFromPoint(point:CGPoint) -> UIColor { let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()! let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue) var pixelData:[UInt8] = [0, 0, 0, 0] let context = CGBitmapContextCreate(

allowRotation in SceneKit?

眉间皱痕 提交于 2019-12-11 13:13:06
问题 How can I disallow rotation of a node in SceneKit? For ex., I want a model (cone) to be dynamic, jumping and flying, but always vertically oriented? I tried fix it like in apple's vehicle demo, it is bad solution. Also I tried below code, but model just slowly and glitchy falls down - (void)renderer:(id<SCNSceneRenderer>)aRenderer didSimulatePhysicsAtTime:(NSTimeInterval)time{ _node.rotation = SCNVector4Make(0, 0, 0, 0); //[_node.physicsBody resetTransform]; // - tried this too } ...and

CATransform3DScale expecting CATransform3D struct not SCNMatrix4

给你一囗甜甜゛ 提交于 2019-12-11 11:37:27
问题 I am trying to put some 3D text in my app, but I need to scale it, here is the code I'm trying to use: SCNText *text = [SCNText textWithString:@"Some Text" extrusionDepth:4.f]; SCNNode *textNode = [SCNNode nodeWithGeometry:text]; textNode.position = SCNVector3Make(-1, 5, 0); textNode.transform = CATransform3DScale(textNode.transform, .1f, .1f, .1f); [root addChildNode:textNode]; and I get a CATransform3DScale expecting CATransform3D struct not SCNMatrix4 or something of the sort. If I don't

Adding camera in SCNScene

时光毁灭记忆、已成空白 提交于 2019-12-11 09:06:26
问题 import UIKit import SceneKit class Scene: SCNScene { var cameraPosition = SCNVector3Make(0, 0, 10) var lightPosition = SCNVector3Make(0, 0, 0) var ship = SCNNode() func setup() { createCameraNode() createShipNode() createAmbientLight() createLight() } func createCameraNode () { let cameraNode = SCNNode() cameraNode.camera = SCNCamera() cameraNode.position = cameraPosition self.rootNode.addChildNode(cameraNode) } func createShipNode() { ship = self.rootNode.childNodeWithName("ship",

SceneKit : how to update SCNGeometrySource

断了今生、忘了曾经 提交于 2019-12-11 08:30:48
问题 I am working on an very awesome iOS project. And i decided to use sceneKit as main Framework. I got an issue : How to update the node's SCNGeometrySource, when i apply an animation on it ? 回答1: That is the expected behavior. When you move a node, it does not change the point data for the attached geometry object. The same is true for transforms. Instead, the point data in the geometry (and the geometry source) is always relative to the geometry itself. When the scene is rendered, the node's

Subclassing SCNScene in Swift - override init

雨燕双飞 提交于 2019-12-11 07:46:50
问题 I'm getting some compiler errors in Xcode 6 using Swift which I have a hard time wrapping my head around. I'm trying to create a scene by subclassing SCNScene, but keep getting errors on the initialisers. The basic structure of my code is: class SpaceScene: SCNScene { override init(named: String) { super.init(named: named) } } This results in an error on line 2 with the message "Initializer does not override a designated initializer from its superclass", although SCNScene clearly has such an