Reference · Rockets, variants, parts and the fit check
shipLevelsfunction
A ship in two passes: the coarse pieces of every module at once, for a first picture, and the fine pass as one batch of pieces for each module, nearest first if order says so. Adding the batches one after another
gives the same ship as shipPieces at the fine level; a viewer adds one a frame, so the picture never waits for the detail.
Import it
import { shipLevels } from "@johnmorrisdotca/uchusen-rockets";
Definition
function shipLevels(ship: ShipList, options?: ModuleOptions, order?: readonly number[]): { coarse: Piece[]; fine: () => Generator<{ place: number; pieces: Piece[]; }>; }
Parameters
| Name | Type | Description |
|---|---|---|
ship | ShipList | The ship's list. |
options (optional) | ModuleOptions | What to draw, for every module. |
order (optional) | readonly number[] | undefined | The places in the order the fine pass should take them. Left out: the order of the list. |
Returns
{ coarse: Piece[]; fine: () => Generator<{ place: number; pieces: Piece[]; }>; }
The coarse pieces, and a function that yields the fine batches.
Examples
import { SAMPLE_SHIPS, shipLevels } from "@johnmorrisdotca/uchusen-rockets";
const { coarse, fine } = shipLevels(SAMPLE_SHIPS.scout);
console.log(coarse.length, [...fine()].length);43 11What it prints (run when this page was built)