cameras
Version:
Cameras for 3D rendering.
67 lines (48 loc) • 2.71 kB
Markdown
# cameras
[](https://www.npmjs.com/package/cameras)
[](https://www.npmjs.com/package/cameras)
[](https://bundlephobia.com/package/cameras)
[](https://github.com/dmnsgn/cameras/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/cameras/blob/main/LICENSE.md)
Cameras for 3D rendering.
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)

## Installation
```bash
npm install cameras
```
## Usage
See the [demo](https://dmnsgn.github.io/cameras/) and its [source](index.html).
```js
import { PerspectiveCamera } from "cameras";
const perspectiveCamera = new PerspectiveCamera({
fov: Math.PI / 2,
near: 1,
far: 1000,
position: [3, 3, 3],
target: [0, 1, 0],
});
// Create controls
const perspectiveCameraControls = new Controls({
element: regl._gl.canvas,
camera: perspectiveCamera,
});
// Update controls and set camera with controls position/target
perspectiveCameraControls.update();
perspectiveCamera.position = perspectiveCameraControls.position;
perspectiveCamera.target = perspectiveCameraControls.target;
// Update view matrices (call when changing position/target/up)
perspectiveCamera.update();
// Update projection matrix (call when changing near/far/view and other camera type specific options)
perspectiveCamera.updateProjectionMatrix();
```
## API
See the [documentation](https://dmnsgn.github.io/cameras/docs) and [Typescript types](src/types.ts).
## License
MIT. See [license file](https://github.com/dmnsgn/cameras/blob/main/LICENSE.md).