@a2f0/skyline 0.1.3 → 0.1.5
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 +7 -0
- package/lib/skyline-package.d.ts +9 -1
- package/lib/skyline-package.js +7 -1
- package/package.json +1 -1
- package/site/skyline-3d.html +20 -0
package/docs/package.md
CHANGED
|
@@ -111,6 +111,13 @@ 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.
|
|
116
|
+
Open, the bar shows the camera hint and the OpenStreetMap credit for the streets
|
|
117
|
+
and footprints. Set `attribution: false` to leave the credit out. OpenStreetMap's
|
|
118
|
+
[licence](https://www.openstreetmap.org/copyright) requires crediting its contributors
|
|
119
|
+
wherever its data is shown, so do this only when the host page credits
|
|
120
|
+
© OpenStreetMap contributors itself.
|
|
114
121
|
A small independent **show original** button remains available until the first
|
|
115
122
|
3D frame succeeds, and reappears if the graphics context is lost. The SVG stays
|
|
116
123
|
reachable even if WebGL, the scene document, or its bootstrap script cannot load.
|
package/lib/skyline-package.d.ts
CHANGED
|
@@ -8,6 +8,14 @@ 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";
|
|
13
|
+
/**
|
|
14
|
+
* Show the OpenStreetMap credit with the 3D scene's controls. Shown by default. OpenStreetMap's
|
|
15
|
+
* licence requires that credit wherever its data appears, so hide it only when the host page
|
|
16
|
+
* credits OpenStreetMap contributors itself.
|
|
17
|
+
*/
|
|
18
|
+
attribution?: boolean;
|
|
11
19
|
}
|
|
12
20
|
export interface SkylineInstance {
|
|
13
21
|
/** The viewer's frame; its styles are isolated from the host application. */
|
|
@@ -20,4 +28,4 @@ export interface SkylineInstance {
|
|
|
20
28
|
* this module never touches the DOM; call it after mounting a browser component.
|
|
21
29
|
* The container controls placement and size. Destroy it when that component leaves.
|
|
22
30
|
*/
|
|
23
|
-
export declare function mountSkyline(container: HTMLElement, { assetsUrl, title, navigation }: SkylineOptions): SkylineInstance;
|
|
31
|
+
export declare function mountSkyline(container: HTMLElement, { assetsUrl, title, navigation, controls, attribution }: SkylineOptions): SkylineInstance;
|
package/lib/skyline-package.js
CHANGED
|
@@ -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", attribution = true }) {
|
|
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,10 @@ 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");
|
|
24
|
+
if (!attribution)
|
|
25
|
+
viewerUrl.searchParams.set("attribution", "hidden");
|
|
20
26
|
element.src = viewerUrl.href;
|
|
21
27
|
element.allowFullscreen = true;
|
|
22
28
|
element.style.cssText = "display:block;width:100%;height:100%;border:0";
|
package/package.json
CHANGED
package/site/skyline-3d.html
CHANGED
|
@@ -78,6 +78,26 @@
|
|
|
78
78
|
</div>
|
|
79
79
|
</div>
|
|
80
80
|
</footer>
|
|
81
|
+
<script>
|
|
82
|
+
// Settings from this page's address, then from the viewer that frames it, applied before
|
|
83
|
+
// the bar's first frame. ?controls=open starts the bar open, with no fold; skyline-3d.ts
|
|
84
|
+
// folds it from there. ?attribution=hidden leaves out the OpenStreetMap credit.
|
|
85
|
+
(() => {
|
|
86
|
+
const settings = new URLSearchParams(location.search);
|
|
87
|
+
try {
|
|
88
|
+
if (parent !== window && parent.document.querySelector("#skyline-3d-scene")?.contentWindow === window) {
|
|
89
|
+
for (const [key, value] of new URLSearchParams(parent.location.search)) if (!settings.has(key)) settings.set(key, value);
|
|
90
|
+
}
|
|
91
|
+
} catch { /* A scene embedded on another origin reads only its own address. */ }
|
|
92
|
+
if (settings.get("controls") === "open") {
|
|
93
|
+
const toggle = document.querySelector("#menu-toggle");
|
|
94
|
+
toggle.setAttribute("aria-expanded", "true");
|
|
95
|
+
toggle.title = "Hide the controls";
|
|
96
|
+
document.querySelector(".control-bar").classList.add("open");
|
|
97
|
+
}
|
|
98
|
+
if (settings.get("attribution") === "hidden") document.querySelector(".attribution").hidden = true;
|
|
99
|
+
})();
|
|
100
|
+
</script>
|
|
81
101
|
<div class="tooltip" id="tooltip" aria-hidden="true" hidden></div>
|
|
82
102
|
<div class="context-menu" id="building-menu" hidden>
|
|
83
103
|
<p class="context-menu-title" id="building-menu-title"></p>
|