|
17 | 17 | { |
18 | 18 | "imports": { |
19 | 19 | "three": "/node_modules/three/build/three.module.js", |
20 | | - "randomcolor": "https://cdn.jsdelivr.net/npm/randomcolor/+esm", |
| 20 | + "lil-gui": "/node_modules/three/examples/jsm/libs/lil-gui.module.min.js", |
21 | 21 | "@photo-sphere-viewer/core": "/dist/core/index.module.js", |
22 | 22 | "@photo-sphere-viewer/map-plugin": "/dist/map-plugin/index.module.js", |
23 | 23 | "@photo-sphere-viewer/markers-plugin": "/dist/markers-plugin/index.module.js" |
|
26 | 26 | </script> |
27 | 27 |
|
28 | 28 | <script type="module"> |
| 29 | + import { GUI } from 'lil-gui'; |
| 30 | + import { addColorPicker } from './scripts/LilGuiColorPicker.js'; |
| 31 | + import { addTextarea } from './scripts/LilGuiTextarea.js'; |
29 | 32 | import { Viewer } from '@photo-sphere-viewer/core'; |
30 | | - import randomColor from 'randomcolor'; |
| 33 | + import randomColor from 'https://cdn.jsdelivr.net/npm/randomcolor/+esm'; |
31 | 34 | import { MapPlugin } from '@photo-sphere-viewer/map-plugin'; |
32 | 35 | import { MarkersPlugin } from '@photo-sphere-viewer/markers-plugin'; |
33 | 36 |
|
|
125 | 128 |
|
126 | 129 | if (view === 'maximized') { |
127 | 130 | map.setZoom(100); |
| 131 | + gui.hide(); |
128 | 132 | } else if (view === 'normal') { |
129 | 133 | map.setZoom(40); |
| 134 | + gui.show(); |
| 135 | + } else { |
| 136 | + gui.show(); |
130 | 137 | } |
131 | 138 | }); |
132 | 139 |
|
|
155 | 162 | } |
156 | 163 |
|
157 | 164 | window.viewer = viewer; |
| 165 | + |
| 166 | + const overlayImage = map.config.overlayImage; |
| 167 | + const config = { |
| 168 | + // position |
| 169 | + center: { ...map.config.center, }, |
| 170 | + rotation: map.config.rotation / Math.PI * 180, |
| 171 | + |
| 172 | + // display |
| 173 | + shape: map.config.shape, |
| 174 | + size: map.config.size, |
| 175 | + position: map.config.position.join(' '), |
| 176 | + static: map.config.static, |
| 177 | + minZoom: Math.round(Math.exp(map.config.minZoom) * 100), |
| 178 | + maxZoom: Math.round(Math.exp(map.config.maxZoom) * 100), |
| 179 | + overlayImage: map.config.overlayImage !== null, |
| 180 | + |
| 181 | + // pin |
| 182 | + pinImage: map.config.pinImage, |
| 183 | + pinSize: map.config.pinSize, |
| 184 | + coneColor: map.config.coneColor, |
| 185 | + coneSize: map.config.coneSize, |
| 186 | + |
| 187 | + // hotspot |
| 188 | + spotStyle: { |
| 189 | + size: map.config.spotStyle.size, |
| 190 | + color: map.config.spotStyle.color, |
| 191 | + hoverSize: map.config.spotStyle.hoverSize ?? map.config.spotStyle.size, |
| 192 | + hoverColor: map.config.spotStyle.hoverColor ?? map.config.spotStyle.color, |
| 193 | + hoverBorderSize: map.config.spotStyle.hoverBorderSize, |
| 194 | + hoverBorderColor: map.config.spotStyle.hoverBorderColor, |
| 195 | + }, |
| 196 | + }; |
| 197 | + |
| 198 | + const gui = new GUI({ title: 'Map Plugin Options' }); |
| 199 | + |
| 200 | + const position = gui.addFolder('Position'); |
| 201 | + position.add(config.center, 'x', 0, 1600, 1).name('center.x'); |
| 202 | + position.add(config.center, 'y', 0, 1200, 1).name('center.y'); |
| 203 | + position.add(config, 'rotation', 0, 360, 1); |
| 204 | + |
| 205 | + const display = gui.addFolder('Display'); |
| 206 | + display.add(config, 'shape', ['round', 'square']); |
| 207 | + display.add(config, 'size'); |
| 208 | + display.add(config, 'position', ['top left', 'top right', 'bottom left', 'bottom right']); |
| 209 | + display.add(config, 'minZoom', 10, 100, 1); |
| 210 | + display.add(config, 'maxZoom', 10, 400, 1); |
| 211 | + display.add(config, 'static'); |
| 212 | + display.add(config, 'overlayImage'); |
| 213 | + |
| 214 | + const pin = gui.addFolder('Pin'); |
| 215 | + addTextarea(pin, config, 'pinImage', 10); |
| 216 | + pin.add(config, 'pinSize', 5, 100, 1); |
| 217 | + addColorPicker(pin, config, 'coneColor', false); |
| 218 | + pin.add(config, 'coneSize', 5, 100, 1); |
| 219 | + |
| 220 | + const hotspot = gui.addFolder('Hotstpots (spotStyle)'); |
| 221 | + hotspot.add(config.spotStyle, 'size', 5, 50, 1); |
| 222 | + addColorPicker(hotspot, config.spotStyle, 'color', true); |
| 223 | + hotspot.add(config.spotStyle, 'hoverSize', 5, 50, 1); |
| 224 | + addColorPicker(hotspot, config.spotStyle, 'hoverColor', true); |
| 225 | + hotspot.add(config.spotStyle, 'hoverBorderSize', 0, 20, 1); |
| 226 | + addColorPicker(hotspot, config.spotStyle, 'hoverBorderColor', true); |
| 227 | + hotspot.close(); |
| 228 | + |
| 229 | + gui.onChange(() => { |
| 230 | + map.setOptions({ |
| 231 | + ...config, |
| 232 | + rotation: config.rotation + 'deg', |
| 233 | + overlayImage: config.overlayImage ? overlayImage : null, |
| 234 | + }); |
| 235 | + |
| 236 | + document.querySelector('.lil-gui').style.right = (config.position === 'top right') ? 'auto' : ''; |
| 237 | + }); |
158 | 238 | </script> |
159 | 239 | </body> |
160 | 240 | </html> |
0 commit comments