Fix orx-camera readme (#224)

This commit is contained in:
Abe Pazos
2022-02-28 21:02:41 +01:00
committed by GitHub
parent 299bebfe89
commit 7ab9e683bd

View File

@@ -5,24 +5,44 @@
## Usage ## Usage
```kotlin ```kotlin
val camera = OrbitalCamera(Vector3.UNIT_Z * 1000.0, Vector3.ZERO, 90.0, 0.1, 2000.0) import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.extras.camera.AxisHelper
import org.openrndr.extras.camera.GridHelper
import org.openrndr.extras.camera.OrbitalCamera
import org.openrndr.extras.camera.OrbitalControls
import org.openrndr.extras.meshgenerators.boxMesh
import org.openrndr.extras.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() = application {
program {
val camera = OrbitalCamera(
Vector3.UNIT_Z * 90.0, Vector3.ZERO, 90.0, 0.1, 5000.0
)
val controls = OrbitalControls(camera, keySpeed = 10.0) val controls = OrbitalControls(camera, keySpeed = 10.0)
val debug3d = Debug3D(1000, 100) val sphere = sphereMesh(radius = 25.0)
val cube = boxMesh(20.0, 20.0, 5.0, 5, 5, 2)
extend(camera) extend(camera)
extend(AxisHelper()) // shows XYZ axes as RGB lines
extend(GridHelper(100)) // debug ground plane
extend(controls) // adds both mouse and keyboard bindings extend(controls) // adds both mouse and keyboard bindings
extend { extend {
debug3d.draw(drawer) drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
drawer.perspective(90.0, width*1.0 / height, 0.1, 5000.0) drawer.stroke = ColorRGBa.WHITE
drawer.shadeStyle = shadeStyle { drawer.fill = null
vertexTransform = """x_viewMatrix = p_view""" repeat(10) {
parameter("view", camera.viewMatrix()) drawer.translate(0.0, 0.0, 10.0)
// 2D primitives are not optimized for 3D and can
// occlude each other
drawer.circle(0.0, 0.0, 50.0)
}
}
} }
drawer.fill = ColorRGBa.PINK
drawer.circle(0.0, 0.0, 500.0)
} }
``` ```