https://github.com/maxvol/scenekitdsl
Swift DSL for SceneKit
https://github.com/maxvol/scenekitdsl
dsl scenekit swift
Last synced: 9 months ago
JSON representation
Swift DSL for SceneKit
- Host: GitHub
- URL: https://github.com/maxvol/scenekitdsl
- Owner: maxvol
- License: mit
- Created: 2019-01-31T05:45:35.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-01T19:37:11.000Z (almost 6 years ago)
- Last Synced: 2025-04-29T08:43:30.972Z (about 1 year ago)
- Topics: dsl, scenekit, swift
- Language: Swift
- Size: 23.4 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SceneKitDSL
Swift DSL for SceneKit
See demo project DSLSceneGame (https://github.com/maxvol/DSLSceneGame) for reference.
Build scene in a hierarchically structured way
```swift
scene.rootNode.apply {
// create and add a camera to the scene
$0.node {
$0.camera { _ in }
// place the camera
$0.position = SCNVector3(x: 0, y: 0, z: 15)
}
// create and add a light to the scene
$0.node {
$0.light {
$0.type = .omni
}
$0.position = SCNVector3(x: 0, y: 10, z: 10)
}
// create and add an ambient light to the scene
$0.node {
$0.light {
$0.type = .ambient
$0.color = UIColor.darkGray
}
$0.position = SCNVector3(x: 0, y: 10, z: 10)
}
}
```
...instead of
```swift
// create and add a camera to the scene
let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
scene.rootNode.addChildNode(cameraNode)
// place the camera
cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
// create and add a light to the scene
let lightNode = SCNNode()
lightNode.light = SCNLight()
lightNode.light!.type = .omni
lightNode.position = SCNVector3(x: 0, y: 10, z: 10)
scene.rootNode.addChildNode(lightNode)
// create and add an ambient light to the scene
let ambientLightNode = SCNNode()
ambientLightNode.light = SCNLight()
ambientLightNode.light!.type = .ambient
ambientLightNode.light!.color = UIColor.darkGray
scene.rootNode.addChildNode(ambientLightNode)
```
Carthage setup -
```
github "maxvol/SceneKitDSL" ~> 0.0.4
```