Reference · Facts, line drawings and positions
addBodyfunction
Add a body to a scene (once), in its place in the order of the sky for an automatic layout, or at the front and to the right of the others for a manual one.
Import it
import { addBody } from "@johnmorrisdotca/wakusei-planets";
Definition
function addBody(scene: Portrait, body: BodyId): Portrait
Parameters
| Name | Type | Description |
|---|---|---|
scene | Portrait | The scene to add to; it is not changed. |
body | BodyId | The body's name. |
Returns
Portrait
A new scene with the body, or the same one when it is already there.
Examples
import { addBody, defaultPortrait } from "@johnmorrisdotca/wakusei-planets";
const scene = addBody(addBody(defaultPortrait(), "saturn"), "earth");
console.log(scene.items.map((item) => item.body).join(", "));earth, saturnWhat it prints (run when this page was built)