scenekit

How do I use a web mercator projection map for SCNMaterial on an SCNShere geometry?

帅比萌擦擦* 提交于 2019-12-01 09:45:21
问题 I have a simple globe view in my app. Previously we were using WhirlyGlobe, but have opted to use SceneKit instead. Everything works great and we are happy with it EXCEPT we used map tiles in Whirly Globe and the do not work (as far as I can tell) in SceneKit. We want to use that map (tiled, split or as one file) on an SCNSphere geometry. I copied the satellite map that Apple uses in their documentation and it looks right, but is not the map we need. Our map is in web/sphere mercator

SCNMaterialProperty not rendering layer

被刻印的时光 ゝ 提交于 2019-12-01 09:28:01
问题 SCNMaterialProperty's contents property on SCNMaterial is unable to render when assigned a AVPlayerLayer. Note this is only a issue on a physical device, works fine on the simulator (Xcode 6.0.1). I am creating my SCNode as such: SCNNode *videoBall = [SCNNode node]; videoBall.position = SCNVector3Make(-5, 5, -18); videoBall.geometry = [SCNSphere sphereWithRadius:5]; videoBall.geometry.firstMaterial.locksAmbientWithDiffuse = YES; videoBall.geometry.firstMaterial.diffuse.contents = [self

linearGravityField() is not affecting physics bodies in the scene SceneKit

我们两清 提交于 2019-12-01 08:39:09
问题 I'm trying to use a SCNPhysicsField.linearGravityField object to affect only specific objects in my scene. The problem is, that I can't seem to get it to affect anything. Here's a sample of my code in Swift: let downGravityCatagory = 1 << 0 let fieldDown = SCNPhysicsField.linearGravityField() let fieldUp = SCNPhysicsField.linearGravityField() let fieldNode = SCNNode() let sceneView = view as! SCNView sceneView.scene = scene sceneView.scene!.physicsWorld.gravity = SCNVector3(x: 0, y: 0, z: 0)

WKWebView is showing only background

末鹿安然 提交于 2019-12-01 08:33:40
问题 I have a simple ARKit app (SceneKit). I create a SCNBox and then I'd like to add a web view on the front side of the cube. func createBox(position: SCNVector3) { let box = SCNBox(width: 0.1, height: 0.1, length: 0.1, chamferRadius: 1) guard let url = URL(string: "https://www.google.com") else { return } let request = URLRequest(url: url) let webView = WKWebView(frame: CGRect(x: 0, y: 0, width: 500, height: 500), configuration: WKWebViewConfiguration()) webView.load(request) let sides = [

What is the type of SCNVector3 components? CGFloat or Float?

China☆狼群 提交于 2019-12-01 07:48:57
问题 The apple documentation gives the declaration of SCNVector3 : typedef struct SCNVector3 { CGFloat x, y , z; } SCNVector3; Or when trying to write an overload function : func * (left: SCNVector3, right: CGFloat) -> SCNVector3 { return SCNVector3Make(left.x * right, left.y * right, left.z * right) } I get the "cannot invoke ' ' with an argument list of type" error. Aren't left.x, left.y and left.z supposed to be CGfloat ? How and when is it decided if CGFloat will be a double or a float? 回答1:

How can I calculate a multi-axis SCNVector4 rotation for a SCNNode?

自闭症网瘾萝莉.ら 提交于 2019-12-01 06:47:21
问题 The SCNNode take a rotation using a SCNVector4 , which has an angle (w) and a magnitude how that angle applies to each axis (x, y, z). For example, to rotate 45 degrees around the x-axis I'd create a SCNVector4 like this: SCNVector4Make(1.0f, 0, 0, DEG2RAD(45)) What I'd like to do is rotate it across all three axis, for example: 45 degrees on the x-axis, 15 degrees on the y-axis and -135 degress across the z-axis. Does anyone know the math to calculate the final SCNVector4 ? 回答1: You'll need

SceneKit - Lighting and casting shadows

蹲街弑〆低调 提交于 2019-12-01 05:55:12
I'm trying to create a spot light that illuminates a cube. The surface underneath should then show a shadow. Unfortunately I wasn't able to achieve this. The light ignores the cube and casts the light on both - the surface and the cube - regardless that the cube is in the way. How it looks like: The code, I just set castsShadow to YES on every node for testing, but nothing so far helped: BOOL shadows = YES; _baseNode.castsShadow = shadows; _scene.rootNode.castsShadow = shadows; SCNBox *box = [SCNBox boxWithWidth: 50 height: 50 length: 50 chamferRadius: 10]; box.firstMaterial.diffuse.contents =

removing SCNNode does not free memory before creating new SCNNode

故事扮演 提交于 2019-12-01 05:55:01
I am building an app that uses Scenekit to display a scene based on information returned from a data base. I have created a custom class with a class func that creates a SCNNode containing everything that needs to be drawn and returns it to my SCNView. Before calling this function I remove any existing nodes. Everything works great until I need to call it a second time. After removing the old SCNNode The memory is not deallocated before creating the new one. Is there a standard way of removing and replacing an SCNNode without overloading memory? I'm new to iOS dev and have never really done

Total height of SCNNode childNodes

微笑、不失礼 提交于 2019-12-01 05:53:23
问题 I'm currently using the following to get the total height of all of the child nodes in a SCNNode . Is there a more efficient/better/shorter/more swift-like way to do this? CGFloat(columnNode.childNodes.reduce(CGFloat()) { let geometry = $1.geometry! as SCNBox return $0 + geometry.height }) 回答1: Yes, and a way that'll get you a more correct answer, too. Summing the height of all the child nodes' geometries... only works if the geometry is an SCNBox doesn't account for the child nodes'

SceneKit: understanding the pivot property of SCNNode

时光怂恿深爱的人放手 提交于 2019-12-01 05:01:16
问题 The goal is to increase the length of a SCNBox such that it only grows in the positive-z direction. This answer suggests playing with the pivot property. However, the documentation for the pivot property is sparse on the SCNNode page, and there is nothing on the SCNBox page. Can someone explain how the pivot property works? 回答1: Changing a node's pivot is conceptually the same as inserting an intermediate node between this node and its parent. This can be useful in different cases. One