Reference · The Milky Way: a brightness map and soft bands to draw
milkyWayTexturefunction
The Milky Way painted as a texture for a WebGL sky (or a canvas): a picture twice as wide as it is high covering the whole sky, coloured from the brightness grid by a ramp. It is read with
detail (1 by default, see MilkyWayDetailOptions), so the dust lanes (the Great Rift, the Coalsack, the Cygnus Rift) are sharper than the plain grid gives them. Made from the package's
numbers alone: no photograph is read. Pure: it returns new pixels and keeps nothing but the grid it unpacks once.
Seen from inside a sphere, the sky runs the other way round from a map: give a sphere this texture with its across direction flipped (in three.js, texture.wrapS = RepeatWrapping and
texture.repeat.x = -1), or turn the sphere inside out by scaling it by -1 across.
Import it
import { milkyWayTexture } from "@johnmorrisdotca/hoshi-stars/milky-way";
Definition
function milkyWayTexture(options?: MilkyWayTextureOptions): MilkyWayTexturePixels
Parameters
| Name | Type | Description |
|---|---|---|
options (optional) | MilkyWayTextureOptions |
|
Returns
MilkyWayTexturePixels
The pixels.
Examples
import { milkyWayTexture } from "@johnmorrisdotca/hoshi-stars/milky-way";
const { width, height, data } = milkyWayTexture({ width: 2048 });
// a canvas: context.putImageData(new ImageData(data, width, height), 0, 0)
// three.js: new DataTexture(data, width, height) with flipY true, colorSpace SRGBColorSpace and needsUpdate true
console.log(width, height); // 2048 10242048 1024What it prints (run when this page was built)