# gl-skybox

> Draws a skybox into a 3D scene.

Latest version **1.0.1** (published 2016-01-02) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install gl-skybox
pnpm add gl-skybox
yarn add gl-skybox
bun add gl-skybox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-01-02 |
| First published | 2016-01-02 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Rye Terrell |
| Maintainers | wwwtyro |
| Keywords | stackgl, skybox |

## Links

- npm: https://www.npmjs.com/package/gl-skybox
- Repository: https://github.com/wwwtyro/gl-skybox
- Homepage: https://github.com/wwwtyro/gl-skybox#readme
- Issues: https://github.com/wwwtyro/gl-skybox/issues
- npm.io page: https://npm.io/package/gl-skybox

## Dependencies (6)

- [gl-mat4](https://npm.io/package/gl-mat4.md) ^1.1.4
- [glslify](https://npm.io/package/glslify.md) ^5.0.0
- [gl-state](https://npm.io/package/gl-state.md) ^1.0.0
- [gl-shader](https://npm.io/package/gl-shader.md) ^4.1.1
- [geo-3d-box](https://npm.io/package/geo-3d-box.md) ^1.0.4
- [gl-geometry](https://npm.io/package/gl-geometry.md) ^1.3.0

## Recent versions

- 1.0.1 (latest) — 2016-01-02
- 1.0.0 — 2016-01-02

## README

# gl-skybox

Draws a skybox into a 3D scene.

## Install

```sh
npm install gl-skybox
```

## Example

```js
var mat4 = require('gl-mat4')
var createCubemap = require('gl-cubemap-placeholder')
var createSkybox = require('gl-skybox')

var cubemap = createCubemap(gl, 512)
cubemap.generateMipmap()
cubemap.minFilter = gl.LINEAR_MIPMAP_LINEAR
cubemap.magFilter = gl.LINEAR

var skybox = createSkybox(gl, cubemap)

var view = mat4.create()
var projection = mat4.create()

mat4.lookAt(view, [0, 0, 0], [0, 0, -1], [0, 1, 0])
mat4.perspective(projection, Math.PI / 2, width/height, 0.1, 10.0)

skybox.draw({
  view: view,
  projection: projection
})

```

## API

```js
var createSkybox = require('gl-skybox')
```

### Constructor

#### `var skybox = createSkybox(gl, cubemap)`

Takes a WebGL context `gl` and a [gl-texture-cube](https://github.com/wwwtyro/gl-texture-cube)
object `cubemap`. Returns an object `skybox` ready for rendering into your
scene.

### Methods

#### `skybox.draw(camera)`

Draws the skybox into your scene.

Takes a `camera` object that defines the view and projection matrices:

```js
{
  view: gl-mat4 matrix,
  projection: gl-mat4 matrix
}
```

This function will take care of centering the skybox and projection near/far
values for you, so there is no need to make a view/projection matrix specifically
for rendering the skybox. It will also disable depth buffer read/writes and
then restore them to whatever you had them set to before returning, so there's
no need to handle that yourself.

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