@igloo/krpano
Version 0.2.02
.
A JavaScript module which can create a cubemap from a KRPano scene and provide a mechanism for synchronising views between different krpano instances.
Download:
View file | ||
---|---|---|
|
Usage
Extend the HTML script tag which embeds your krpano tour.
It'll probably look something like this:
Code Block | ||
---|---|---|
| ||
<body> <div id="pano"></div> </body> <script> embedpano({ xml: 'tour.xml', target: 'pano', // your other options }); </script> |
Adding igloo_krpano.js:
Code Block | ||
---|---|---|
| ||
<body> <div id="pano"></div> </body> <!-- add type="module" to allow imports from igloo_krpano.js --> <script type="module"> import { iglooKrPano } from './igloo_krpano.js'; // import function embedpano({ xml: 'tour.xml', target: 'pano', // ... onready: iglooKrPano(), // add onready to embedpano options, passing the result of calling iglooKrPano to it. }); </script> |
...
Here's an tl;dr of the default behaviour, with the call to iglooKrPano
included. See configuration and URL parameter sections below for more detailed info.
url | behaviour |
---|
| normal behaviour |
| cubemap drawn |
| cubemap drawn with ui |
| normal; viewsync set up to work inside |
Configuration
Behaviour can be modified by passing an options object to the iglooKrPano
function.
Code Block | ||
---|---|---|
| ||
type IglooKrPanoOptions = { drawCubemap?: (() => boolean) | boolean; doViewsync?: (() => boolean) | boolean; showUi?: (() => boolean) | boolean; handleViewsyncOut?: (msg: Viewsync.Message) => void; setupViewsyncIn?: (callback: (msg: Viewsync.Message) => void) => void; }; |
...
To modify this behaviour, pass a boolean or a boolean-returning-function.
Code Block | ||
---|---|---|
| ||
embedpano({ // ... onready: iglooKrPano({ drawCubemap: true }), }); // or embedpano({ // ... onready: iglooKrPano({ drawCubemap: () => true }), }); |
...
These URL parameters are used when the default configuration is set. Overriding showUi
, drawCubemap
, or doViewsync
will mean these parameters aren't used.
Parameter | Behaviour |
---|---|
| Create cubemap |
| Create cubemap |
| Create cubemap |
| Do not remove UI from cubemap |
| Send viewsync messages using |
Viewsync
In order to facilitate synchronisation of separate krpano instances (possibly in separate browsers or on separate machines), iglooKrPano()
can set up viewsync.
...
The default viewsync behaviour uses postMessage
to pass messages to @igloo/krpano-wrapper
, but won't post (or act on) any messages to (or from) urls other than those used by the wrapper. This may have implications on any existing message handling.
Pre-requisites
This will only work in browsers that support ES modules, which is every major browser release since mid-2018.
...
References
Changelog
...
0.2.2
Fix: Allow origins other than
localhost:800
for posting viewsync messages.
0.2.1
Fix: Added logging related to older krpano versions not being supported.
0.2.0
Changed: UI is removed from cubemaps by default, and can be opted into through creation options.
...
0.1.0
Initial release