@a2f0/skyline 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/package.md CHANGED
@@ -111,6 +111,8 @@ controls from the application's header and CSS. Embedding hides the standalone
111
111
  toolbar and study links so they do not overlap the host's navigation. Set
112
112
  `navigation: true` to show them. It retains stars, the traced
113
113
  loading silhouette, star controls, original comparison, and building details.
114
+ The scene's control bar starts folded behind its star; set `controls: 'open'` to
115
+ start it open, with no fold, from its first frame. Visitors can still fold it.
114
116
  A small independent **show original** button remains available until the first
115
117
  3D frame succeeds, and reappears if the graphics context is lost. The SVG stays
116
118
  reachable even if WebGL, the scene document, or its bootstrap script cannot load.
@@ -8,6 +8,8 @@ export interface SkylineOptions {
8
8
  title?: string;
9
9
  /** Show the standalone toolbar and study links. Hidden by default when embedded. */
10
10
  navigation?: boolean;
11
+ /** Start the 3D scene's control bar open, or folded behind its star. Closed by default. */
12
+ controls?: "open" | "closed";
11
13
  }
12
14
  export interface SkylineInstance {
13
15
  /** The viewer's frame; its styles are isolated from the host application. */
@@ -20,4 +22,4 @@ export interface SkylineInstance {
20
22
  * this module never touches the DOM; call it after mounting a browser component.
21
23
  * The container controls placement and size. Destroy it when that component leaves.
22
24
  */
23
- export declare function mountSkyline(container: HTMLElement, { assetsUrl, title, navigation }: SkylineOptions): SkylineInstance;
25
+ export declare function mountSkyline(container: HTMLElement, { assetsUrl, title, navigation, controls }: SkylineOptions): SkylineInstance;
@@ -3,7 +3,9 @@
3
3
  * this module never touches the DOM; call it after mounting a browser component.
4
4
  * The container controls placement and size. Destroy it when that component leaves.
5
5
  */
6
- export function mountSkyline(container, { assetsUrl, title = "Interactive Chicago skyline", navigation = false }) {
6
+ export function mountSkyline(container, { assetsUrl, title = "Interactive Chicago skyline", navigation = false, controls = "closed" }) {
7
+ if (controls !== "open" && controls !== "closed")
8
+ throw new TypeError('Skyline controls must be "open" or "closed".');
7
9
  const document = container.ownerDocument;
8
10
  const base = new URL(assetsUrl, document.baseURI);
9
11
  if (!/^(https?:)$/.test(base.protocol))
@@ -17,6 +19,8 @@ export function mountSkyline(container, { assetsUrl, title = "Interactive Chicag
17
19
  const viewerUrl = new URL("index.html", base);
18
20
  if (!navigation)
19
21
  viewerUrl.searchParams.set("embed", "1");
22
+ if (controls === "open")
23
+ viewerUrl.searchParams.set("controls", "open");
20
24
  element.src = viewerUrl.href;
21
25
  element.allowFullscreen = true;
22
26
  element.style.cssText = "display:block;width:100%;height:100%;border:0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2f0/skyline",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Interactive Chicago skyline viewer and reusable Three.js building models",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -78,6 +78,23 @@
78
78
  </div>
79
79
  </div>
80
80
  </footer>
81
+ <script>
82
+ // ?controls=open, on this page's address or on the viewer that frames it, starts the bar
83
+ // open from its first frame, with no fold; skyline-3d.ts folds it from there.
84
+ (() => {
85
+ let controls = new URLSearchParams(location.search).get("controls");
86
+ try {
87
+ if (!controls && parent !== window && parent.document.querySelector("#skyline-3d-scene")?.contentWindow === window) {
88
+ controls = new URLSearchParams(parent.location.search).get("controls");
89
+ }
90
+ } catch { /* A scene embedded on another origin reads only its own address. */ }
91
+ if (controls !== "open") return;
92
+ const toggle = document.querySelector("#menu-toggle");
93
+ toggle.setAttribute("aria-expanded", "true");
94
+ toggle.title = "Hide the controls";
95
+ document.querySelector(".control-bar").classList.add("open");
96
+ })();
97
+ </script>
81
98
  <div class="tooltip" id="tooltip" aria-hidden="true" hidden></div>
82
99
  <div class="context-menu" id="building-menu" hidden>
83
100
  <p class="context-menu-title" id="building-menu-title"></p>