Skip to content

Instantly share code, notes, and snippets.

@Volksfeld
Created October 19, 2019 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Volksfeld/3248ecf2066f38201786fbf9b7eca6a7 to your computer and use it in GitHub Desktop.
Save Volksfeld/3248ecf2066f38201786fbf9b7eca6a7 to your computer and use it in GitHub Desktop.
AR Portal Scene created with NSSBoxes.
func setupScene() {
let node = SCNNode()
node.position = SCNVector3.init(0, 0, 0)
let leftWall = createBox(isDoor: false)
leftWall.position = SCNVector3.init((-length / 2) + width, 0, 0)
leftWall.eulerAngles = SCNVector3.init(0, 180.0.degreesToRadians, 0)
let rightWall = createBox(isDoor: false)
rightWall.position = SCNVector3.init((length / 2) - width, 0, 0)
let topWall = createBox(isDoor: false)
topWall.position = SCNVector3.init(0, (height / 2) - width, 0)
topWall.eulerAngles = SCNVector3.init(0, 0, 90.0.degreesToRadians)
let bottomWall = createBox(isDoor: false)
bottomWall.position = SCNVector3.init(0, (-height / 2) + width, 0)
bottomWall.eulerAngles = SCNVector3.init(0, 0, -90.0.degreesToRadians)
let backWall = createBox(isDoor: false)
backWall.position = SCNVector3.init(0, 0, (-length / 2) + width)
backWall.eulerAngles = SCNVector3.init(0, 90.0.degreesToRadians, 0)
let leftDoorSide = createBox(isDoor: true)
leftDoorSide.position = SCNVector3.init((-length / 2 + width) + (doorLength / 2), 0, (length / 2) - width)
leftDoorSide.eulerAngles = SCNVector3.init(0, -90.0.degreesToRadians, 0)
let rightDoorSide = createBox(isDoor: true)
rightDoorSide.position = SCNVector3.init((length / 2 - width) - (doorLength / 2), 0, (length / 2) - width)
rightDoorSide.eulerAngles = SCNVector3.init(0, -90.0.degreesToRadians, 0)
//Adding Nodes to Main Node
node.addChildNode(leftWall)
node.addChildNode(rightWall)
node.addChildNode(topWall)
node.addChildNode(bottomWall)
node.addChildNode(backWall)
node.addChildNode(leftDoorSide)
node.addChildNode(rightDoorSide)
self.sceneView.scene.rootNode.addChildNode(node)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment