Orbital Camera is an extension that can manage it's own life-cycle

This commit is contained in:
Ricardo Matias
2019-11-21 13:56:09 +01:00
parent 7377f35a00
commit ead9b8a0d3
2 changed files with 68 additions and 18 deletions

View File

@@ -1,3 +1,38 @@
# orx-camera
3D camera and controls for OPENRNDR. This supersedes the to be deprecated functionality in OPENRNDR.
3D camera and controls for OPENRNDR. This supersedes the to be deprecated functionality in OPENRNDR.
## Usage
```kotlin
val camera = OrbitalCamera(Vector3.UNIT_Z * 1000.0, Vector3.ZERO, 90.0, 0.1, 2000.0)
val controls = OrbitalControls(camera, keySpeed = 10.0)
val debug3d = Debug3D(1000, 100)
extend(camera)
extend(controls) // adds both mouse and keyboard bindings
extend {
debug3d.draw(drawer)
drawer.perspective(90.0, width*1.0 / height, 0.1, 5000.0)
drawer.shadeStyle = shadeStyle {
vertexTransform = """x_viewMatrix = p_view"""
parameter("view", camera.viewMatrix())
}
drawer.fill = ColorRGBa.PINK
drawer.circle(0.0, 0.0, 500.0)
}
```
### Keybindings
* `w` - move forwards (+z)
* `s` - move backwards (-z)
* `Left` or `a` - strafe left (-x)
* `Right` or `d` - strafe right (+x)
* `Up` or `e` - move up (+y)
* `Down` or `q` - move up (-y)
* `Page Up` - zoom in
* `Page Down` - zoom out