Skip to content

Commit

Permalink
Documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatum committed May 8, 2016
1 parent b1021f3 commit b04d622
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 102 deletions.
29 changes: 14 additions & 15 deletions README.md
Expand Up @@ -18,24 +18,23 @@ As of Feb. 8, Glam Engine was renamed to gl-engine. There was already an excelle
import Bunny from 'bunny'
import { Mesh, PerspectiveCamera, FlatMaterial, Scene, Geometry, Engine } from 'gl-engine'

Engine(function onReady( engine, scene ) {

var camera = PerspectiveCamera()
var material = FlatMaterial({ color : [0.1,0.3,0.4] })
var geometry = Geometry( Bunny )
var mesh = Mesh( geometry, material )
Engine(function onReady(engine, scene) {
var camera = PerspectiveCamera()
var material = FlatMaterial({ color : [0.1,0.3,0.4] })
var geometry = Geometry(Bunny)
var mesh = Mesh(geometry, material)

scene.add( camera )
scene.add( mesh )
scene.add(camera)
scene.add(mesh)

mesh.position[1] = -5
camera.position[2] = 20
mesh.position[1] = -5
camera.position[2] = 20

engine.on('update', function(e) {
mesh.euler[0] = e.elapsed * 0.0001
mesh.euler[1] = e.elapsed * 0.001
scene.render( camera )
})
engine.on('update', function(e) {
mesh.euler[0] = e.elapsed * 0.0001
mesh.euler[1] = e.elapsed * 0.001
scene.render(camera)
})
})
```
Then you will get a [spinning flat bunny](http://requirebin.com/?gist=TatumCreative/40970c039f8c0ce44ae2).
Expand Down
51 changes: 29 additions & 22 deletions docs/README.md
@@ -1,25 +1,32 @@
# gl-engine API Documentation

## API
### Engine
* **[Engine](./api/engine.md)** - [`gl-engine/lib/engine`](./api/engine.md)
* **[Geometry](./api/geometry.md)** - [`gl-engine/lib/geometry`](./api/geometry.md)
* **[Mesh](./api/mesh.md)** - [`gl-engine/lib/mesh`](./api/mesh.md)
* **[ForwardRenderer](./api/renderer-forward.md)** - [`gl-engine/lib/renderer/forward`](./api/renderer-forward.md)
* **[Scene](./api/scene.md)** - [`gl-engine/lib/scene`](./api/scene.md)
* **[Transform](./api/transform.md)** - [`gl-engine/lib/transform`](./api/transform.md)

| object | path |
| --------------------------------------------------- | ---------------------------------------------------------- |
| [PerspectiveCamera](./api/camera-perspective.md) | [gl-engine/lib/camera/perspective](./api/camera-perspective.md) |
| [OrbitControls](./api/controls-orbit.md) | [gl-engine/lib/controls/orbit](./api/controls-orbit.md) |
| [Engine](./api/engine.md) | [gl-engine/lib/engine](./api/engine.md) |
| [Geometry](./api/geometry.md) | [gl-engine/lib/geometry](./api/geometry.md) |
| [DirectionalLight](./api/light-directional.md) | [gl-engine/lib/light/directional](./api/light-directional.md) |
| [FlatMaterial](./api/material-flat.md) | [gl-engine/lib/material/flat](./api/material-flat.md) |
| [LitMaterial](./api/material-lit.md) | [gl-engine/lib/material/lit](./api/material-lit.md) |
| [FogAugment](./api/material-augment-fog.md) | [gl-engine/lib/augment/fog](./api/material-augment-fog.md) |
| [NormalColorAugment](./api/material-augment-fog.md) | [gl-engine/lib/augment/normal-color](./api/material-augment-normal-color.md) |
| [LambertAugment](./api/material-augment-fog.md) | [gl-engine/lib/augment/lambert](./api/material-augment-lambert.md) |
| [Mesh](./api/mesh.md) | [gl-engine/lib/mesh](./api/mesh.md) |
| [ForwardRenderer](./api/renderer-forward.md) | [gl-engine/lib/renderer/forward](./api/renderer-forward.md) |
| [MultipassRenderer](./api/renderer-multipass.md) | [gl-engine/lib/renderer/multipass](./api/renderer-multipass.md) |
| [MultipassDebug](./api/renderer-multipass-debug.md) | [gl-engine/lib/renderer/multipass/debug](./api/renderer-multipass-debug.md) |
| [BloomPass](./api/pass-bloom.md) | [gl-engine/lib/pass/bloom](./api/pass-bloom) |
| [DepthPass](./api/pass-depth.md) | [gl-engine/lib/pass/depth](./api/pass-depth) |
| [FXAAPass](./api/pass-fxaa.md) | [gl-engine/lib/pass/fxaa](./api/pass-fxaa) |
| [Scene](./api/scene.md) | [gl-engine/lib/scene](./api/scene.md) |
| [Transform](./api/transform.md) | [gl-engine/lib/transform](./api/transform.md) |
### Camera
* **[PerspectiveCamera](./api/camera-perspective.md)** - [`gl-engine/lib/camera/perspective`](./api/camera-perspective.md)
* **[OrbitControls](./api/controls-orbit.md)** - [`gl-engine/lib/controls/orbit`](./api/controls-orbit.md)

### Lighting
* **[DirectionalLight](./api/light-directional.md)** - [`gl-engine/lib/light/directional`](./api/light-directional.md)

### Materials
* **[FlatMaterial](./api/material-flat.md)** - [`gl-engine/lib/material/flat`](./api/material-flat.md)
* **[LitMaterial](./api/material-lit.md)** - [`gl-engine/lib/material/lit`](./api/material-lit.md)

### Material Augments
* **[FogAugment](./api/material-augment-fog.md)** - [`gl-engine/lib/augment/fog`](./api/material-augment-fog.md)
* **[NormalColorAugment](./api/material-augment-fog.md)** - [`gl-engine/lib/augment/normal-color`](./api/material-augment-normal-color.md)
* **[LambertAugment](./api/material-augment-fog.md)** - [`gl-engine/lib/augment/lambert`](./api/material-augment-lambert.md)

### Multipass Renderer
* **[MultipassRenderer](./api/renderer-multipass.md)** - [`gl-engine/lib/renderer/multipass`](./api/renderer-multipass.md)
* **[MultipassDebug](./api/renderer-multipass-debug.md)** - [`gl-engine/lib/renderer/multipass/debug`](./api/renderer-multipass-debug.md)
* **[BloomPass](./api/pass-bloom.md)** - [`gl-engine/lib/pass/bloom`](./api/pass-bloom)
* **[DepthPass](./api/pass-depth.md)** - [`gl-engine/lib/pass/depth`](./api/pass-depth)
* **[FXAAPass](./api/pass-fxaa.md)** - [`gl-engine/lib/pass/fxaa`](./api/pass-fxaa)
12 changes: 6 additions & 6 deletions docs/api/camera-perspective.md
Expand Up @@ -27,7 +27,7 @@ scene.render(camera)

## API

### `PerspectiveCamera( properties ) -> perspectiveCamera`
### `PerspectiveCamera(properties -> perspectiveCamera`

This function creates the `perspectiveCamera` object.

Expand Down Expand Up @@ -101,19 +101,19 @@ Creates a new picking ray from the 2D screen-space `vec2` point (i.e. the mouse)
The ray is an instance of [ray-3d](https://github.com/Jam3/ray-3d), and it can be used for hit-testing.

```js
var ray = camera.createPickingRay( mouse )
if( ray.intersectsSphere( center, radius ) ) {
var ray = camera.createPickingRay(mouse
if(ray.intersectsSphere(center, radius {
console.log("Hit!")
}
```
#### `camera.use( controlsFunction, controlsProperties ) => camera`
#### `camera.use(controlsFunction, controlsProperties => camera`
Use a camera control like [OrbitControls](./controls-orbit.md) to control how the camera behaves.
```js
var camera = PerspectiveCamera()
.use( OrbitControls, {
.use(OrbitControls, {
distance : 10,
target : [0,20,0]
})
Expand All @@ -123,7 +123,7 @@ var camera = PerspectiveCamera()
Updates the camera's projection and view matrices based on the controls and the camera's current state (position, direction, viewport, etc).
#### `camera.updateModelView( modelMatrix )`
#### `camera.updateModelView(modelMatrix`
Updates the camera's model view matrix based on the provided model matrix.
Expand Down
6 changes: 3 additions & 3 deletions docs/api/controls-orbit.md
Expand Up @@ -14,15 +14,15 @@ Controls for orbiting a camera around a point.

```js
var camera = PerspectiveCamera()
.use( OrbitControls, {
.use(OrbitControls, {
distance : 10,
target : [0,20,0]
})

camera.controls.distance = 12
```

#### `controls = OrbitControls( options )`
#### `controls = OrbitControls(options`

| property | default | description |
| -------------- | ----------- | ----------- |
Expand Down Expand Up @@ -51,7 +51,7 @@ Update the controls. This is typically handled automatically if the `camera.use(

#### `controls.updateController(position, direction, up)`

Use the controls to update a camera's position vector, direction vector, and up vector. This is handled automatically when used with the `camera.use( OrbitControls )` syntax.
Use the controls to update a camera's position vector, direction vector, and up vector. This is handled automatically when used with the `camera.use(OrbitControls` syntax.

## properties

Expand Down
4 changes: 2 additions & 2 deletions docs/api/engine.md
Expand Up @@ -15,7 +15,7 @@ The engine automatically sets up the basic tools for working on a WebGL visualiz
```js
import { Engine } from "gl-engine"

Engine(function( engine, scene ) {
Engine(function(engine, scene {

// Add things to your scene here

Expand All @@ -27,7 +27,7 @@ Engine(function( engine, scene ) {

## API

### Engine( options )
### Engine(options

The default exported function creates the `engine` object.

Expand Down
4 changes: 2 additions & 2 deletions docs/api/geometry.md
Expand Up @@ -18,12 +18,12 @@ import CreateBox from 'geo-3d-box'

var box = Box({size: 5})
// box contains a positions and cells properties
var geometry = Geometry( box )
var geometry = Geometry(box
```
## API
### Geometry( data )
### Geometry(data
The default exported function creates the `geometry` object.
Expand Down
10 changes: 5 additions & 5 deletions docs/api/light-directional.md
Expand Up @@ -16,7 +16,7 @@ A light that comes from a consistent direction, simulating something like a sun.
import { DirectionalLight, PerspectiveCamera, Engine } from gl-engine
import MyMesh from './my-mesh'

Engine( (engine, scene) => {
Engine((engine, scene) => {

var camera = PerspectiveCamera()

Expand All @@ -25,16 +25,16 @@ Engine( (engine, scene) => {
direction: [ 0.5, -0.5, 0.5 ]
})

scene.add( light )
scene.add( MyMesh )
scene.add(light
scene.add(MyMesh

engine.on( 'update', () => scene.render( camera ) )
engine.on('update', () => scene.render(camera
})
```
## API
### DirectionalLight( properties )
### DirectionalLight(properties
| property | type | description |
| ------------ | ----------- | ----------- |
Expand Down
8 changes: 4 additions & 4 deletions docs/api/material-augment-fog.md
Expand Up @@ -54,9 +54,9 @@ material.shading.fog.color[0] *= 0.8
| color | RGB array | The color of the fog. |


### FogAugment( MaterialFactory|material, fogProperties ) => material
### FogAugment(MaterialFactory|material, fogProperties => material

The FogAugment is easiest to use with the `material.use( FogAugment, fogProperties )` interface.
The FogAugment is easiest to use with the `material.use(FogAugment, fogProperties` interface.
However it is perfectly valid to use as a function. It returns a factory function that creates
the original type of material with your augments.

Expand All @@ -75,14 +75,14 @@ or

```
var fogProperties = { color : [1,0,0], near: 10, far: 100 }
var flatRedFog = FogAugment( FlatMaterial, fogProperties )
var flatRedFog = FogAugment(FlatMaterial, fogProperties
var material = flatRedFog()
```

```
var flatProperties = { color : [0,0,1] }
var fogProperties = { color : [1,0,0], near: 10, far: 100 }
var flatBlue = FlatMaterial(flatProperties)
var flatBlueWithRedFog = FogAugment( flatBlue, fogProperties )
var flatBlueWithRedFog = FogAugment(flatBlue, fogProperties
var material = flatBlueWithRedFog()
```
10 changes: 5 additions & 5 deletions docs/api/material-augment-lambert.md
Expand Up @@ -20,7 +20,7 @@ var material =
LitMaterial({
color : [0.1, 0.1, 0.1] // ambient color
})
.use( LambertAugment, {
.use(LambertAugment, {
diffuse : [1, 0, 0] // red diffuse
})
// Additional augments can be added here
Expand Down Expand Up @@ -55,9 +55,9 @@ The properties can be accessed directly from the material as follows.
material.shading.color //ambient
material.shading.lambert.diffuse // diffuse

### LambertAugment( MaterialFactory|material ) => material
### LambertAugment(MaterialFactory|material => material

The LambertAugment is easiest to use with the `material.use( LambertAugment, lambertProperties )` interface.
The LambertAugment is easiest to use with the `material.use(LambertAugment, lambertProperties` interface.
However it is perfectly valid to use as a function. The function returns a factory function that creates
the original type of material with your augments.

Expand All @@ -73,12 +73,12 @@ or


```
var lambert = LambertAugment( LitMaterial )
var lambert = LambertAugment(LitMaterial
var material = lambert()
```

```
var litBlue = LitMaterial({ color : [0,0,1] })
var litBlueLambert = LambertAugment( litBlue )
var litBlueLambert = LambertAugment(litBlue
var material = litBlueLambert()
```
8 changes: 4 additions & 4 deletions docs/api/material-augment-normal-colors.md
Expand Up @@ -46,9 +46,9 @@ material.shading.normalColors.amount = 0.8
| amount | number | How much of the normal color to show over the base material color. Defaults to 1.0 which is 100%. |


### NormalColorsAugment( MaterialFactory|material, normalColorsProperties ) => material
### NormalColorsAugment(MaterialFactory|material, normalColorsProperties => material

The NormalColorsAugment is easiest to use with the `material.use( NormalColorsAugment, normalColorsProperties )` interface.
The NormalColorsAugment is easiest to use with the `material.use(NormalColorsAugment, normalColorsProperties` interface.
However it is perfectly valid to use as a function. It returns a factory function that creates
the original type of material with your augments.

Expand All @@ -67,14 +67,14 @@ or

```
var normalColorsProperties = { amount : 1.0 }
var normalMaterial = NormalColorsAugment( LitMaterial, normalColorsProperties )
var normalMaterial = NormalColorsAugment(LitMaterial, normalColorsProperties
var material = normalMaterial()
```

```
var litProperties = { color : [1,0,1] }
var normalColorsProperties = { amount : 0.5 }
var litMagenta = LitMaterial(litProperties)
var magentaWithNormalColors = NormalColorsAugment( litMagenta, normalColorsProperties )
var magentaWithNormalColors = NormalColorsAugment(litMagenta, normalColorsProperties
var material = magentaWithNormalColors()
```
10 changes: 5 additions & 5 deletions docs/api/material-flat.md
Expand Up @@ -20,8 +20,8 @@ import Bunny from 'bunny'


var material = Material()
var geometry = Geometry( Bunny )
var mesh = Mesh( geometry, material )
var geometry = Geometry(Bunny
var mesh = Mesh(geometry, material

material.shading.color = [0.1,0.3,0.4]
```
Expand All @@ -40,7 +40,7 @@ material.shading.color = [0.1,0.3,0.4]
## API
### Material( data )
### Material(data
The default exported function creates the `flatMaterial` object.
Expand Down Expand Up @@ -81,7 +81,7 @@ An object containing the shading options.
| transparent | boolean | Flags the material as using transparency. There are additional sorting costs to having transparency. |
| recompile | boolean | Tell the renderer to recompile the shader from the fragSource and vertSource. |
#### `flatMaterial.setUniforms( shader, camera, mesh )`
#### `flatMaterial.setUniforms(shader, camera, mesh`
Updates the uniforms for the material. This is called internally by the renderer.
Expand All @@ -91,7 +91,7 @@ Updates the uniforms for the material. This is called internally by the renderer
| camera | camera | A gl-engine camera |
| mesh | mesh | A gl-engine mesh |
#### `flatMaterial.setAttributes( geometry, buffers )`
#### `flatMaterial.setAttributes(geometry, buffers`
Uses [gl-geometry](https://github.com/hughsk/gl-geometry) to set the attributes before rendering.
Expand Down
10 changes: 5 additions & 5 deletions docs/api/material-lit.md
Expand Up @@ -17,8 +17,8 @@ import { Mesh, LitMaterial, Geometry } from 'gl-engine'
import Bunny from 'bunny'

var material = LitMaterial()
var geometry = Geometry( Bunny )
var mesh = Mesh( geometry, material )
var geometry = Geometry(Bunny
var mesh = Mesh(geometry, material

material.shading.color = [0.1,0.3,0.4]
```
Expand All @@ -34,7 +34,7 @@ material.shading.color = [0.1,0.3,0.4]
## API
### LitMaterial( data )
### LitMaterial(data
The default exported function creates the `litMaterial` object.
Expand Down Expand Up @@ -75,7 +75,7 @@ An object containing the shading options.
| transparent | boolean | Flags the material as using transparency. There are additional sorting costs to having transparency. |
| recompile | boolean | Tell the renderer to recompile the shader from the fragSource and vertSource. |
#### `litMaterial.setUniforms( shader, camera, mesh )
#### `litMaterial.setUniforms(shader, camera, mesh

Updates the uniforms for the material. This is called internally by the renderer.

Expand All @@ -85,7 +85,7 @@ Updates the uniforms for the material. This is called internally by the renderer
| camera | camera | A gl-engine camera |
| mesh | mesh | A gl-engine mesh |

#### `litMaterial.setAttributes( geometry, buffers )
#### `litMaterial.setAttributes(geometry, buffers
Uses [gl-geometry](https://github.com/hughsk/gl-geometry) to set the attributes before rendering.
Expand Down

0 comments on commit b04d622

Please sign in to comment.