# space-travel

> WebGL space scene with lightspeed warp effect

Latest version **2.0.1** (published 2026-06-12) · The Unlicense license · 0 weekly downloads

## Install

```sh
npm install space-travel
pnpm add space-travel
yarn add space-travel
bun add space-travel
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-06-12 |
| First published | 2021-05-01 |
| Weekly downloads | 0 |
| License | The Unlicense |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20.19 |
| Dependencies | 4 |
| Unpacked size | 236.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 70 |
| Author | Florent Requin |
| Maintainers | frequin |
| Keywords | webgl, canvas, ogl, space, stars, lightspeed |

## Links

- npm: https://www.npmjs.com/package/space-travel
- Repository: https://github.com/frequin/space-travel
- Homepage: https://github.com/frequin/space-travel#readme
- Issues: https://github.com/frequin/space-travel/issues
- npm.io page: https://npm.io/package/space-travel

## Dependencies (4)

- [ogl](https://npm.io/package/ogl.md) ^1.0.11
- [zod](https://npm.io/package/zod.md) ^4.4.3
- [modern-normalize](https://npm.io/package/modern-normalize.md) ^3.0.1
- [uint8array-extras](https://npm.io/package/uint8array-extras.md) ^1.5.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2026-06-12
- 2.0.0 — 2026-06-12
- 1.1.0 — 2024-06-09
- 1.0.6 — 2021-05-01

## README

# Space Travel

[demo](https://webgl-space-travel.requin.pro/)

WebGL space scene with lightspeed warp effect.

**Strongly** inspired by https://nova.app/. Entirely rewritten in typescript.

Use [OGL](https://github.com/oframe/ogl) minimal WebGL library under the hood.

## Usage

### Script

```html
<canvas id="space-travel"></canvas>
<script type="module">
  import SpaceTravel from "https://unpkg.com/space-travel?module";
  new SpaceTravel({ canvas: document.getElementById("space-travel") }).start();
</script>
```

### Module

```console
$ npm install space-travel
```

From your application js file :

```js
import SpaceTravel from "space-travel";
new SpaceTravel({ canvas: document.getElementById("space-travel") }).start();
```

### Interactions

You can bind DOM events to interact with instance state (`throttle`, `opacity`) or call methods (`pause()`, `resume()`, `resize()`).
See [src/main.ts](https://github.com/frequin/space-travel/blob/master/src/main.ts) as an example.

## Documentation

### `class SpaceTravel`

#### constructor

```js
const scene = new SpaceTravel(parameters);
```

#### `parameters`

| name                            | value                            | description                                                                                        |
| ------------------------------- | -------------------------------- | -------------------------------------------------------------------------------------------------- |
| `parameters.canvas`             | **required**                     | HTML canvas to be rendered                                                                         |
| `parameters.throttle`           | _optionnal_ default : `0`        | Number between `0` and `1`. Initial speed with relative increasing intensity.                      |
| `parameters.throttleLerpFactor` | _optionnal_ default : `0.035`    | Number defining an acceleration factor to reach a new throttle value                               |
| `parameters.opacity`            | _optionnal_ default : `1`        | Number between `0` and `1`. Initial global opacity.                                                |
| `parameters.opacityLerpFactor`  | _optionnal_ default : `0.016`    | Number between `0` and `1`. Number defining an acceleration factor to reach a new opacity value.   |
| `parameters.startOpacity`       | _optionnal_ default : `0`        | Number between `0` and `1`. Global opacity on scene creation before reaching `parameters.opacity`. |
| `parameters.backgroundColor`    | _optionnal_ default : `0x08000f` | Color (hex number or css string value) filling the canvas background                               |
| `parameters.starfield`          | _optionnal_                      | starfield parameters (see below)                                                                   |
| `parameters.nebulae`            | _optionnal_                      | nebulae parameters (see below)                                                                     |

#### `starfield` parameters

| name                            | value                                                                               | description                                                                             |
| ------------------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| `starfield.count`               | _optionnal_ default : `1500`                                                        | Number of stars in the scene                                                            |
| `starfield.container`           | _optionnal_ default : `{ length: 40, depth: 40 }`                                   | Object defining length and depth of the box containing the stars                        |
| `starfield.colorRange`          | _optionnal_ default : `{ min: 0x3068ff, max: 0xf34f94 }`                            | Object defining minimum and maximum star random colors (hex number or css string value) |
| `starfield.thicknessRange`      | _optionnal_ default : `{ min: 0.035, max: 0.06 }`                                   | Object defining minimum and maximum star thickness related to `throttle` value          |
| `starfield.rayLengthRange`      | _optionnal_ default : `{ min: 0.1, max: 2.5 }`                                      | Object defining minimum and maximum star ray length related to `throttle` value         |
| `starfield.stretchFactorRange`  | _optionnal_ default : `{ min: 0, max: 1.5 }`                                        | Object defining minimum and maximum star stretch factor related to `throttle` value     |
| `starfield.shakeSpeedFactor`    | _optionnal_ default : `0.001`                                                       | Number defining the camera random offset related to `throttle` value                    |
| `starfield.shakeStrengthFactor` | _optionnal_ default : `0.0035`                                                      | Number defining the intensity of the shaking                                            |
| `starfield.speedRange`          | _optionnal_ default : `{ min: 0.5, max: 60 }`                                       | Object defining minimum and maximum speed of the stars related to `throttle` value      |
| `starfield.particleTextureUrl`  | _optionnal_ default : `"https://webgl-space-travel.requin.pro/particle-sprite.png"` | Url of the particle texture image                                                       |
| `starfield.noiseTextureUrl`     | _optionnal_ default : `"https://webgl-space-travel.requin.pro/noise.jpg"`           | Url of the noise image used to generate the shaking effect                              |

#### `nebulae` parameters

Array of `nebula` parameters (see below)

Default value :

```js
[
  {
    textureUrl: "https://webgl-space-travel.requin.pro/clouds1.jpg",
    colorRange: { min: 0xff0042, max: 0xff0042 },
    opacityRange: { min: 0.05, max: 0.2 },
    speedRange: { min: 0.0025, max: 0.175 },
    repeatOffsetRange: { min: [1, 1], max: [0.33, 1] },
    fallOffDistance: -8,
    rotationSpeedRange: { min: 1, max: 30 }
  },
  {
    textureUrl: "https://webgl-space-travel.requin.pro/noise3.jpg",
    colorRange: { min: 0x2659fd, max: 0x2659fd },
    opacityRange: { min: 0.05, max: 0.25 },
    speedRange: { min: 0.003, max: 0.075 },
    repeatOffsetRange: { min: [0.5, 1], max: [0.25, 1] },
    fallOffDistance: -6,
    rotationSpeedRange: { min: 0.5, max: 25 }
  },
  {
    textureUrl: "https://webgl-space-travel.requin.pro/noise3.jpg",
    colorRange: { min: 0x8500ef, max: 0x8500ef },
    opacityRange: { min: 0.02, max: 0.25 },
    speedRange: { min: 0.002, max: 0.1125 },
    repeatOffsetRange: { min: [0.75, 1], max: [0.35, 1] },
    fallOffDistance: -6,
    rotationSpeedRange: { min: 1.09, max: 31 }
  }
];
```

#### `nebula` parameters

| name                        | value                                                    | description                                                                                       |
| --------------------------- | -------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `nebula.textureUrl`         | _optionnal_ default : `""`                               | Texture image url                                                                                 |
| `nebula.colorRange`         | _optionnal_ default : `{ min: 0xff0000, max: 0x0000ff }` | Object defining minimum and maximum nebula color related to `throttle` value                      |
| `nebula.opacityRange`       | _optionnal_ default : `{ min: 0.5, max: 1 }`             | Object defining minimum and maximum nebula opacity related to `throttle` value                    |
| `nebula.repeatOffsetRange`  | _optionnal_ default : `{ min: [1, 1], max: [0.15, 1] }`  | Object defining minimum and maximum texture offset related to `throttle` value                    |
| `nebula.fallOffDistance`    | _optionnal_ default : `-8`                               | Number defining a maximum visibility depth distance for the texture                               |
| `nebula.speedRange`         | _optionnal_ default : `{ min: 0.0025, max: 0.525 }`      | Object defining minimum and maximum texture speed depth scrolling related to `throttle` value     |
| `nebula.rotationSpeedRange` | _optionnal_ default : `{ min: 1, max: 45 }`              | Object defining minimum and maximum texture rotation speed (in deg/s) related to `throttle` value |

#### properties

- `throttle`

Get or set a new `throttle` target value.

```js
scene.throttle = Math.min(1, scene.throttle + 0.1);
```

- `opacity`

Get or set a new `opacity` target value.

```js
scene.opacity = 0.5;
```

#### methods

- `start()`

Puts the scene into action.

```js
scene.start();
```

- `resume()`

Alias of `start()` method.

```js
scene.resume();
```

- `pause()`

Freeze the scene.

```js
scene.pause();
```

- `resize()`

Automatically resize the scene to fit the canvas current size.

```js
scene.resize();
```

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