JS SDK: the 3D roof and panel editor

The Numsolar JS SDK is the 3D roof and panel editor behind the configurator and the offer editor: draw the roofs, place the panels, see the sun and the shade.

Version0.66.8 (the version Numsolar serves today)
Host API version51 (ROOF_EDITOR_HOST_API_VERSION)
BuildsES module dist/index.js, UMD dist/index.umd.cjs, styles dist/style.css, types dist/index.d.ts
Made withTypeScript, Preact 10, Three.js, Tailwind CSS
The SDK is not a stand-alone npm package: it loads its roofs, panels and products from a Numsolar account over a live connection. For your website, use the embedded configurator below. To build your own tool on the editor, write to contact@numsolar.com.

Put the configurator on your website

The embedded configurator is the SDK with your packages and your colours. Visitors draw their roof, see the panels and the price, and ask you for an offer.

  1. In Numsolar, open Funnels and add an embed: its packages, its language and its slug (the last part of its address).
  2. Add your website's address to the embed's URLs. The browser shows the embed only inside the websites listed there.
  3. Put an iframe on your page:
HTML
<iframe
  src="https://numsolar.com/sv/embedded/YOUR-SLUG"
  title="Solar configurator"
  style="width: 100%; height: 900px; border: 0"
  allow="fullscreen"
></iframe>

/sv/embedded/<slug> shows it in Swedish, /en/embedded/<slug> in English. For ads, e-mail and flyers, use your public link /i/<your slug> instead: it opens the configurator with your brand, no iframe needed.

The editor's host API

For partners who run the editor in their own page with a Numsolar connection. The page that shows the editor is the host: it mounts the editor, then sends commands and gets events.

Mount the editor

JavaScript
import ns, { renderComboEditor } from "solar-wizard"; // dist/index.js
import "solar-wizard/style.css";

const numsolar = new ns.lib.Numsolar({ redirectUri: "/" });
const editor = document.getElementById("editor");

renderComboEditor(editor, {
  class: "flex-1",
  lang: "sv",        // the interface language: "sv" or "en"
  numsolar,
  chrome: "host",    // version 30+: only the 3D canvas, your page draws the controls
});

numsolar.connection.connect();

renderComboEditor(element, options)

Option Type Description
numsolarrequired Numsolar The connection and the data (new ns.lib.Numsolar({redirectUri})).
lang string The interface language.
class string CSS classes for the editor's root.
chrome "sdk" | "host" ["sdk"] "host" (version 30+) mounts only the 3D canvas: no SDK menu, toolbars or 2D editors.
overlayParent HTMLElement Where pop-up menus and dialogs go. Default document.body.
roofEditorProps object Options of the 3D editor, for example eventPrefix (default "roof-editor:").
menuProps, panelsEditorProps, orthoEditorProps object Options of the SDK's menu and 2D editors (with chrome: "sdk").

removeComboEditor(element) unmounts it.

Commands and events

Commands and events travel on numsolar.eventBus, named <prefix><name> (the prefix is "roof-editor:"). Read the names from RoofEditorApp.HOST_EVENTS and check RoofEditorApp.HOST_API_VERSION before you use a newer one: an older SDK ignores what it does not know. Commands may be sent at once, before the scene is ready: the editor keeps the latest one and runs it on its first frame.

JavaScript
const app = ns.apps.RoofEditorApp;
const prefix = app.DEFAULT_EVENT_PREFIX;   // "roof-editor:"
const EV = app.HOST_EVENTS;

numsolar.eventBus.on(prefix + EV.SCENE_READY, (e) => {
  console.log("roofs:", e.detail.structures.length);
});
numsolar.eventBus.emit(prefix + EV.CAMERA_PRESET, { preset: "house", animate: true });

if ((app.HOST_API_VERSION ?? 1) >= 2) {
  numsolar.eventBus.emit(prefix + EV.VIEW_MODE, { mode: "view" }); // no edit handles
}
NameDirectionPayloadSince
camera-presethost → SDK{preset, animate?, durationMs?, fill?}; presets panels, house, battery, equipment, illustration, solar, plan1
batteryhost → SDK{kwh}; null or 0 removes it1
view-modehost → SDK{mode: "view" | "edit"}2
select-facehost → SDK{structureId, doubleLineId}3
focushost → SDK{structureId, doubleLineId, animate?, inset?}, or null to end5
scene-readySDK → host{structures, installations}, once, after the first frame with roofs1
camera-viewSDK → host{preset} when a camera move lands1
view-levelhost → SDK{level: map | building | roof, electrical?} (electrical, a true/false field on map and building, since 44)41
roof-blocks-selectedSDK → host{structureId, blockId}: a box picked in 3D51

The other commands and events (obstacles, trees, equipment and wiring, the solar map, the Illustration, drawing buildings, panel racks) are in the SDK's README, with one row per host API version.

Panel fitting

"Fill with solar panels" runs inside Numsolar for the configurator and the API. It is not a public service.