# @rreusser/regl-camera

> Camera for regl

Latest version **1.1.0** (published 2017-02-09) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @rreusser/regl-camera
pnpm add @rreusser/regl-camera
yarn add @rreusser/regl-camera
bun add @rreusser/regl-camera
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2017-02-09 |
| First published | 2017-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mikola Lysenko |
| Maintainers | rreusser |
| Keywords | regl, camera, 3d, orbit, turntable |

## Links

- npm: https://www.npmjs.com/package/@rreusser/regl-camera
- Repository: https://github.com/rreusser/regl-camera
- Homepage: https://github.com/rreusser/regl-camera#readme
- Issues: https://github.com/rreusser/regl-camera/issues
- npm.io page: https://npm.io/package/@rreusser/regl-camera

## Dependencies (3)

- [gl-mat4](https://npm.io/package/gl-mat4.md) ^1.1.4
- [mouse-wheel](https://npm.io/package/mouse-wheel.md) ^1.2.0
- [mouse-change](https://npm.io/package/mouse-change.md) ^1.3.0

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2017-02-09

## README

# @rreusser/regl-camera
A basic reusable "turntable" camera component for [regl](http://regl.party).  (Secretly just [spherical coordinates](https://en.wikipedia.org/wiki/Spherical_coordinate_system).)


## THIS FORK

***Is a fork of `regl-camera` published separately at @rreusser/regl-camera.***

## Example

```javascript
const regl = require('regl')()
const camera = require('regl-camera')(regl, {
  center: [0, 2.5, 0]
})

const bunny = require('bunny')
const normals = require('angle-normals')

const drawBunny = regl({
  frag: `
    precision mediump float;
    varying vec3 vnormal;
    void main () {
      gl_FragColor = vec4(abs(vnormal), 1.0);
    }`,
  vert: `
    precision mediump float;
    uniform mat4 projection, view;
    attribute vec3 position, normal;
    varying vec3 vnormal;
    void main () {
      vnormal = normal;
      gl_Position = projection * view * vec4(position, 1.0);
    }`,
  attributes: {
    position: bunny.positions,
    normal: normals(bunny.cells, bunny.positions)
  },
  elements: bunny.cells
})

regl.frame(() => {
  regl.clear({
    color: [0, 0, 0, 1]
  })
  camera(() => {
    drawBunny()
  })
})
```

## Install

```
npm i regl-camera
```

## API

### Constructor

#### `var camera = require('regl-camera')(regl[, options])`
`module.exports` of `regl-camera` is a constructor for the camera.  It takes the following arguments:

* `regl` is a handle to the regl instance
* `options` is an object with the following optional properties:
  + `center` which is the center of the camera
  + `theta` the theta angle for the camera
  + `phi` the phi angle for the camera
  + `distance` the distance from the camera eye to the center
  + `up` the up vector for the camera
  + `mouse` set to `false` to turn off mouse events
  + `damping` multiplier for inertial damping (default 0.9). Set to 0 to disable inertia.

### Command usage

#### `camera(block)`
`regl-camera` sets up an environment with the following variables in both the context and uniform blocks:

| Variable | Type | Description |
|----------|------|-------------|
| `view`   | `mat4` | The view matrix for the camera |
| `projection` | `mat4` | The projection matrix for the camera |
| `center` | `vec3` | The center of the camera |
| `eye` | `vec3` | The eye coordinates of the camera |
| `up` | `vec3` | The up vector for the camera matrix |
| `theta` | `float` | Latitude angle parameter in radians |
| `phi` | `float` | Longitude angle parameter in radians |
| `distance` | `float` | Distance from camera to center of objective |

**Note**
These properties can also be accessed and modified directly by accessing the object

## License
(c) 2016 Mikola Lysenko. MIT License

---
_Source: https://npm.io/package/@rreusser/regl-camera · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
