From ec56fa9d78310afa6d581b5deff0b252266e274e Mon Sep 17 00:00:00 2001 From: mgermerie <73115044+mgermerie@users.noreply.github.com> Date: Fri, 7 Jan 2022 17:14:53 +0100 Subject: [PATCH] example(Widgets): add a plugin to display widgets --- docs/config.json | 5 +- examples/config.json | 2 +- examples/css/widgets.css | 214 +++++++++++++++++ examples/images/widget-logo.svg | 66 +++++ .../{misc_compass.html => misc_widgets.html} | 88 +++---- utils/gui/Main.js | 2 + utils/gui/Navigation.js | 225 ++++++++++++++++++ webpack.config.js | 4 + 8 files changed, 554 insertions(+), 52 deletions(-) create mode 100644 examples/css/widgets.css create mode 100644 examples/images/widget-logo.svg rename examples/{misc_compass.html => misc_widgets.html} (65%) create mode 100644 utils/gui/Main.js create mode 100644 utils/gui/Navigation.js diff --git a/docs/config.json b/docs/config.json index 7837c876f0..110d51519b 100644 --- a/docs/config.json +++ b/docs/config.json @@ -124,7 +124,8 @@ "Plugins": [ "DragNDrop", "FeatureToolTip", - "TIFFParser" + "TIFFParser", + "Navigation" ] }, "tutorialSections": { @@ -162,7 +163,7 @@ } }, "source": { - "include": [ "src", "examples/js/plugins" ], + "include": [ "src", "examples/js/plugins", "utils/gui" ], "exclude": [ "src/ThreeExtended" ] }, "plugins": ["plugins/markdown"] diff --git a/examples/config.json b/examples/config.json index be9fcb8e1f..ba9c0f0706 100644 --- a/examples/config.json +++ b/examples/config.json @@ -76,7 +76,7 @@ "misc_custom_controls": "Define custom controls", "misc_custom_label": "Custom label popup", "misc_camera_traveling": "Camera traveling", - "misc_compass": "Display a compass" + "misc_widgets": "Display widgets" }, "Plugins": { diff --git a/examples/css/widgets.css b/examples/css/widgets.css new file mode 100644 index 0000000000..df4a823d60 --- /dev/null +++ b/examples/css/widgets.css @@ -0,0 +1,214 @@ +/* ---------- WIDGETS GROUP SETTINGS : ------------------------------------------------------------------------------ */ + +#widgets { + position: absolute; + z-index: 10; + + display: flex; + align-items: center; +} + +/* Define widget group flex direction according to widget position and direction settings */ +.column-widget.top-widget { + flex-direction: column; +} +.column-widget.bottom-widget { + flex-direction: column-reverse; +} +.row-widget.left-widget { + flex-direction: row; +} +.row-widget.right-widget { + flex-direction: row-reverse; +} + +/* Define widget group position according to widget position settings. */ +.top-widget { + top: 10px; +} +.bottom-widget { + bottom: 10px; +} +.left-widget { + left: 10px; +} +.right-widget { + right: 10px; +} + +/* Define spacing between each widgets according to position and direction settings. */ +.column-widget.top-widget > *:not(:first-child), +.column-widget.bottom-widget > *:not(:last-child) { + margin-top: 5px; +} +.column-widget.top-widget > *:not(:last-child), +.column-widget.bottom-widget > *:not(:first-child) { + margin-bottom: 5px; +} +.row-widget.left-widget > *:not(:first-child), +.row-widget.right-widget > *:not(:last-child) { + margin-left: 5px; +} +.row-widget.left-widget > *:not(:last-child), +.row-widget.right-widget > *:not(:first-child) { + margin-right: 5px; +} + + + +/* ---------- WIDGET BUTTON BAR : ----------------------------------------------------------------------------------- */ + +/* Define button-bar flex direction according to widget position and direction settings. */ +#widgets .widget-button-bar { + display: flex; +} +.column-widget.top-widget .widget-button-bar { + flex-direction: column; +} +.column-widget.bottom-widget .widget-button-bar { + flex-direction: column-reverse; +} +.row-widget.left-widget .widget-button-bar { + flex-direction: row; +} +.row-widget.right-widget .widget-button-bar { + flex-direction: row-reverse; +} + + + +/* ---------- BUTTONS GENERIC STYLE : ------------------------------------------------------------------------------- */ + +#widgets .widget-button { + background-color: #313336bb; + border: 1px solid #222222; + padding: 0; + + display: flex; + align-items: center; + justify-content: center; + + font-weight: 900; + font-size: 15px; +} +#widgets .widget-button:hover { + cursor: pointer; +} +#widgets .widget-button:active { + background-color: #222222; +} + + + +/* ---------- BUTTONS SHAPE AND POSITION WITHIN BUTTON-BAR : -------------------------------------------------------- */ + +#widgets .widget-button-bar > .widget-button { + height: 30px; + width: 30px; + + color: white; +} + +/* Buttons shape and position within a column direction widget group. */ +.column-widget.top-widget .widget-button-bar > .widget-button:first-child, +.column-widget.bottom-widget .widget-button-bar > .widget-button:last-child { + border-radius: 7px 7px 0 0; +} +.column-widget.top-widget .widget-button-bar > .widget-button:last-child, +.column-widget.bottom-widget .widget-button-bar > .widget-button:first-child { + border-radius: 0 0 7px 7px; +} +.column-widget.top-widget .widget-button-bar > .widget-button:not(:last-child), +.column-widget.bottom-widget .widget-button-bar > .widget-button:not(:first-child) { + margin-bottom: -1px; +} + +/* Buttons shape and position within a row direction widget group. */ +.row-widget.left-widget .widget-button-bar > .widget-button:first-child, +.row-widget.right-widget .widget-button-bar > .widget-button:last-child { + border-radius: 7px 0 0 7px; +} +.row-widget.left-widget .widget-button-bar > .widget-button:last-child, +.row-widget.right-widget .widget-button-bar > .widget-button:first-child { + border-radius: 0 7px 7px 0; +} +.row-widget.left-widget .widget-button-bar > .widget-button:not(:last-child), +.row-widget.right-widget .widget-button-bar > .widget-button:not(:first-child) { + margin-right: -1px; +} + +/* Buttons shape and position within a single button button-bar. */ +#widgets .widget-button-bar > .widget-button:only-child { + border-radius: 7px; +} + + + +/* ---------- SPECIFIC SHAPE AND POSITION FOR ZOOM-IN AND ZOOM-OUT BUTTON-BAR AND BUTTONS : ------------------------- */ + +#zoom-button-bar { + display: flex; +} +.column-widget #zoom-button-bar { + flex-direction: column; +} +.row-widget #zoom-button-bar { + flex-direction: row-reverse; +} + +/* Zoom buttons shape and position within a COLUMN direction widget group. */ +.column-widget #zoom-button-bar > .widget-button:first-child { + border-radius: 7px 7px 0 0; +} +.column-widget #zoom-button-bar > .widget-button:last-child { + border-radius: 0 0 7px 7px; +} +.column-widget.bottom-widget #zoom-button-bar > .widget-button:not(:last-child) { + margin-top: 0; + margin-bottom: -1px; +} + +/* Zoom buttons shape and position within a ROW direction widget group. */ +.row-widget #zoom-button-bar > .widget-button:first-child { + border-radius: 0 7px 7px 0; +} +.row-widget #zoom-button-bar > .widget-button:last-child { + border-radius: 7px 0 0 7px; +} +.row-widget.left-widget #zoom-button-bar > .widget-button:not(:last-child) { + margin-right: 0; + margin-left: -1px; +} + +/* Zoom button shape and position if user decides to show only one of the two zoom buttons. */ +#widgets #zoom-button-bar > .widget-button:only-child { + border-radius: 7px; +} + +/* Style of zoom buttons content. */ +#widgets .widget-zoom-button-logo { + width: 50%; + height: 50%; + + background-image: url('../images/widget-logo.svg'); + background-size: 100%; +} +#widgets #zoom-out-logo { + background-position: center -100%; +} + + + +/* ---------- SPECIFIC COMPASS SETTINGS : --------------------------------------------------------------------------- */ + +#widgets #compass { + width: 60px; + height: 60px; + + border-radius: 50%; + + background-image: url('../images/compass.svg'); + background-repeat: no-repeat; + background-size: auto 90%; + background-position: center; +} diff --git a/examples/images/widget-logo.svg b/examples/images/widget-logo.svg new file mode 100644 index 0000000000..0441055341 --- /dev/null +++ b/examples/images/widget-logo.svg @@ -0,0 +1,66 @@ + + + \ No newline at end of file diff --git a/examples/misc_compass.html b/examples/misc_widgets.html similarity index 65% rename from examples/misc_compass.html rename to examples/misc_widgets.html index b1b48d3d22..9b9481e514 100644 --- a/examples/misc_compass.html +++ b/examples/misc_widgets.html @@ -1,6 +1,6 @@
-