Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

@igloo/krpano

Version 0.2.12.

A JavaScript module which can create a cubemap from a KRPano scene and provide a mechanism for synchronising views between different krpano instances.

...

It'll probably look something like this:

Code Block
languagehtml
<body>
  <div id="pano"></div>
</body>

<script>
  embedpano({
    xml: 'tour.xml',
    target: 'pano',
    // your other options
  });
</script>

Adding igloo_krpano.js:

Code Block
languagehtml
<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

https

<https://example.com/krpano/mytour/tour.html>

normal behaviour

.../tour.html?igloo

cubemap drawn

.../tour.html?igloo&igloo_cubemap_showui

cubemap drawn with ui

.../tour.html?igloo_viewsync

normal; viewsync set up to work inside @igloo/krpano-wrapper

Configuration

Behaviour can be modified by passing an options object to the iglooKrPano function.

Code Block
languagets
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
languagejs
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

igloo

Create cubemap

igloomode

Create cubemap

igloo_cubemap

Create cubemap

igloo_cubemap_showui

Do not remove UI from cubemap

igloo_viewsync

Send viewsync messages using handleViewsyncOut and setupViewsyncIn

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.

...

Developed with krpano 1.21.2 (build 2023-12-11). Only compatible with krpano versions 1.21 or newer., but it should be comaptible with any non-ancient krpano release.

It's been tested with:

  • krpano 1.21.2 (build 2023-12-11)

...

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.

...