Reference · The Sun, Moon and planets: pure parts
plainPainterconstant
The default look: a sphere in the planet's colour, lit by the Sun, and for the Sun a glowing disc.
Import it
import { plainPainter } from "@johnmorrisdotca/chikyu-earth/space";
Definition
const plainPainter: { make(three: ThreeParts, name: string): BodyDrawing; } & BodyPainter = {
make(three, name) {
if (name === "Sun") {
const geometry = quad(three);
const material = new three.ShaderMaterial({ vertexShader: GLOW_VERT, fragmentShader: GLOW_FRAG, uniforms: { tint: { value: new three.Color(PLAIN_COLOR(name)) } }, transparent: true, depthWrite: false });
const mesh = new three.Mesh(geometry, material);
mesh.renderOrder = 4;
mesh.frustumCulled = false;
mesh.scale.setScalar(3.2);
const group = new three.Group();
group.add(mesh);
return {
object: group,
billboard: true,
dispose() {
geometry.dispose();
material.dispose();
},
};
}
const geometry = sphere(three, 48, 24);
const sun = { value: new three.Vector3(1, 0, 0) };
const material = new three.ShaderMaterial({ vertexShader: SURFACE_VERT, fragmentShader: BODY_FRAG, uniforms: { map: { value: null }, tint: { value: new three.Color(PLAIN_COLOR(name)) }, textured: { value: 0 }, sunDir: sun, ambient: { value: 0.2 } } });
return {
object: new three.Mesh(geometry, material),
light(toSun) {
sun.value.set(toSun[0], toSun[1], toSun[2]);
},
dispose() {
geometry.dispose();
material.dispose();
},
};
},
}
Members
| Name | Type | Description |
|---|---|---|
make | ((three: ThreeParts, name: string) => BodyDrawing) & ((three: ThreeParts, name: string, context?: PaintContext) => BodyDrawing | Promise<BodyDrawing>) | |
moons (optional) | ((planet: PlanetName, ms: number) => readonly BodyMoon[]) | undefined | |
looks (optional) | readonly string[] | undefined |
Examples
import { plainPainter } from "@johnmorrisdotca/chikyu-earth/space";
console.log(typeof plainPainter.make);