Reference · How a body is drawn with three.js
BodyLooktype
What a body looks like in three.js: the shader code of its surface, how it glows, its atmosphere and its painted map.
Import it
import type { BodyLook } from "@johnmorrisdotca/wakusei-planets/look";
Definition
interface BodyLook {
id: BodyId;
surface: string;
emissive?: boolean;
atmosphere?: Atmosphere;
limb?: number;
relief?: number;
wrap?: number;
ambient?: number;
painted?: PaintedMap;
mapped?: boolean;
}
Members
| Name | Type | Description |
|---|---|---|
id | BodyId | |
surface | string | GLSL that defines |
emissive (optional) | boolean | undefined | A glowing body (the Sun): no shading from outside light. |
atmosphere (optional) | Atmosphere | undefined | |
limb (optional) | number | undefined | How much the disc darkens toward the limb, 0 to 1. Default 0. |
relief (optional) | number | undefined | How strongly the height shows as relief, 0 to 2. Default 0.6. |
wrap (optional) | number | undefined | How far light wraps round the terminator: 0 is a hard edge (no air), 0.3 a soft one. Default 0.04, or 0.3 with an atmosphere. |
ambient (optional) | number | undefined | How much of the night side shows (0 to 1). Default 0.04. |
painted (optional) | PaintedMap | undefined | |
mapped (optional) | boolean | undefined | Draw the painted map in the realistic look too: for a body with no honest drawing from numbers (the Earth's continents). |
Examples
import { registerLook, type BodyLook } from "@johnmorrisdotca/wakusei-planets/look";
const look: BodyLook = { id: "moon", surface: "vec4 surface(vec3 p) { return vec4(vec3(0.7), 0.0); }", ambient: 0.02 };
console.log(registerLook(look).id);moonWhat it prints (run when this page was built)