Reference · Rockets, variants, parts and the fit check
embedCodefunction
The text of one embed. The module one imports the package; the data one is a data:image/svg+xml address for an <img>.
Import it
import { embedCode } from "@johnmorrisdotca/uchusen-rockets";
Definition
function embedCode(options: RocketOptions, kind?: EmbedKind, settings?: EmbedSettings): string
Parameters
| Name | Type | Description |
|---|---|---|
options | RocketOptions | The rocket and how it looks. |
kind (optional) | "data" | "iframe" | "link" | "svg" | "module" | "element" | Which way to write it. Defaults to the element. |
settings (optional) | EmbedSettings | Where the demo and the CDN are, if not the package's own. |
Returns
string
The text to paste into a page. A painted rocket's credit is part of it.
Examples
import { embedCode } from "@johnmorrisdotca/uchusen-rockets";
console.log(embedCode({ rocket: "falcon-9", variant: "block-5", look: "thick" }));
console.log(embedCode({ rocket: "falcon-9", variant: "block-5" }, "iframe"));<script type="importmap">
{ "imports": { "three": "https://cdn.jsdelivr.net/npm/three@0.186.1/build/three.module.js", "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.186.1/examples/jsm/" } }
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/@johnmorrisdotca/uchusen-rockets@0/dist/element.js"></script>
<uchusen-rocket
rocket="falcon-9"
variant="block-5"
look="thick"
></uchusen-rocket>
<iframe
src="https://johnmorrisdotca.github.io/uchusen-rockets/embed.html?rocket=falcon-9&variant=block-5"
title="Rocket"
loading="lazy"
style="width:100%;max-width:480px;aspect-ratio:3 / 4;border:0"
></iframe>What it prints (run when this page was built)