scenekit

Is it normal for an SCNNode pivot to change the nodes position?

不问归期 提交于 2020-01-25 14:24:07
问题 I'm trying to rotate a block by setting its pivot point to any of the corners, but it seems as though setting the pivot point actually repositions the node, keeping the point exactly where it was... for example SCNBox *box = [SCNBox boxWithWidth:1 height:2 length:1 chamferRadius:0]; SCNNode *node = [SCNNode nodeWithGeometry:box]; node.position = SCNVector3Make(0, 0, 0); [self.scene.rootNode addChildNode:node]; node.pivot = SCNMatrix4MakeTranslation(0.5, -1, 0.5); [node runAction:[SCNAction

Swift Load A 3d Asset from URL Xcode

↘锁芯ラ 提交于 2020-01-25 11:28:25
问题 I have a simple HTTP server running and Im trying to fetch this scenekit from my local server but IT shows me NIL error, or Error Loading Scene. I dont understand how to load this model from my simple local host. How to configure my code so that I will be able to fetch any Scenekit from remote or local server. Thanks in advance do { let shipScene = try SCNScene(url: URL(fileURLWithPath: "http://localhost:8080/chair.scn") , options: nil) // Set the scene to the view sceneView.scene = shipScene

Handling 3D Interaction and UI Controls in Augmented Reality

瘦欲@ 提交于 2020-01-25 07:30:08
问题 I'm playing with this Code example. And I'm having trouble finding where can I replace the existing 3d objects with my own 3d objects programmatically created? I want to keep all the existing functionality in the code example but with my own objects! Creating of 3d object. self.geometry = SCNBox(width: width!/110, height: height!/110, length: 57 / 700, chamferRadius: 0.008) self.geometry.firstMaterial?.diffuse.contents = UIColor.red self.geometry.firstMaterial?.specular.contents = UIColor

SceneKit shader modifier for geometry entry points works in iOS but not OS X

*爱你&永不变心* 提交于 2020-01-23 13:30:13
问题 I'm in the early stages of making a SceneKit shader modifier (for the geometry entry point) that displaces a plane's geometry according to a height-map texture. The plan is to use it for creating terrain. In iOS (edit: the iOS Simulator) the shader works as it should, but does print this warning to the console: SceneKit: error, modifier without code is invalid When building for OS X however, the shader gets a fatal error, and the terrain geometry just displays as a pink rectangle. This is the

How to use a pan gesture to rotate a camera in SceneKit using quaternions

和自甴很熟 提交于 2020-01-23 11:04:10
问题 I'm building a 360 video viewer using the iOS SceneKit framework. I'd like to use a UIPanGestureRecognizer to control the camera's orientation. SCNNodes have several properties we can use to specify their rotation: rotation (a rotation matrix), orientation (a quaternion), eulerAngles (per axis angles). Everything I've read says to avoid using euler angles in order to avoid gimbal lock. I'd like to use quaternions for a few reasons which I won't go into here. I'm having trouble getting this to

Add SCNText to SCNScene with ARKit

元气小坏坏 提交于 2020-01-22 09:57:25
问题 I just started studying for ARKitexample and Scenekit. I read a few Scenekit and found out that in order to add text, I need to use SCNText. I try to write like this but it doesn't show. guard let pointOfView = sceneView.pointOfView else { return } let text = SCNText(string: "Hello", extrusionDepth: 4) let textNode = SCNNode(geometry: text) textNode.geometry = text textNode.position = SCNVector3Make(pointOfView.position.x, pointOfView.position.y, pointOfView.position.z) sceneView.scene

Subclassing SCNNode

删除回忆录丶 提交于 2020-01-21 15:21:15
问题 I am importing a simple dae file. I want some of the nodes to be a subclass of SCNNode - MySCNNode. MySCNNode *node = [scnView.scene.rootNode childNodeWithName:@"Box1" recursively:YES]; //additional initialization goes here Tried casting to (MySCNNode *) too. But this is not working. "node" is still an SCNNode. Why? I need to add a few properties and methods to SCNNode. So I subclassed SCNNode. I want the nodes from the scene(imported from a dae) to have the properties and behaviour. The

SCNLevelOfDetails delegate/notification

时光毁灭记忆、已成空白 提交于 2020-01-16 14:35:40
问题 I'm using SCNLevelOfDetails with SceneKit. I was wondering if there's a way to know when the engine changes the levelOfDetails for a particular node's geometry. Many thanks. 回答1: I'm answering my own question. To give more context, we needed to know when the LOD would change in order to stop an idle animation, our model is skinned. What happens if you don't disable this animation when the LOD changes is that the geo goes all over the place and it looks wrong. The solution for us was to clone

SCNLevelOfDetails delegate/notification

吃可爱长大的小学妹 提交于 2020-01-16 14:35:27
问题 I'm using SCNLevelOfDetails with SceneKit. I was wondering if there's a way to know when the engine changes the levelOfDetails for a particular node's geometry. Many thanks. 回答1: I'm answering my own question. To give more context, we needed to know when the LOD would change in order to stop an idle animation, our model is skinned. What happens if you don't disable this animation when the LOD changes is that the geo goes all over the place and it looks wrong. The solution for us was to clone

Recalculate SCNNode geometry based on transformation

早过忘川 提交于 2020-01-16 09:12:40
问题 Is there a way to solidify a SCNNode scale and orientation by recalculating its geometry? Basically I am loading a SCNNode out of a scn file that was converted from a sketchup file that was exported to a DAE file. Because ARKit works in meters and with a different axis orientation I have to set the loaded SCNNode’s scale (to 0.0254) and eulerangle (x -90deg) to correctly show it. This all works fine however thus scaling and rotation messes up some logic down the line because this logic also