Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions types/pannellum/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,30 @@ declare namespace Pannellum {
scale?: boolean;
}

/** A tour configuration */
interface TourOptions {
/**
* The `default` property contains options that are used for each scene,
* but options specified for individual scenes override these options. The
* `default` property is required to have a `firstScene` property that contains
* the scene ID for the first scene to be displayed.
*/
default: ConfigOptions & {
firstScene: string;
};

/**
* The `scenes` property contains a dictionary of scenes, specified by scene
* IDs. The values assigned to these IDs are specific to each scene.
*/
scenes: {
[sceneId: string]: ConfigOptions;
};

/** @deprecated -- undocumented alternative to `default.firstScene`. */
firstScene?: string;
}

class Renderer {
/**
* Create a new panorama renderer.
Expand Down Expand Up @@ -532,7 +556,7 @@ declare namespace Pannellum {
* @param container - The container (div) element for the viewer, or its ID.
* @param initialConfig - Initial configuration for the viewer.
*/
constructor(container: HTMLElement | string, initialConfig: ConfigOptions);
constructor(container: HTMLElement | string, initialConfig: ConfigOptions | TourOptions);

/**
* Checks whether or not a panorama is loaded.
Expand Down Expand Up @@ -888,14 +912,12 @@ interface Window {
renderer(container: HTMLElement): Pannellum.Renderer;
};
pannellum: {
viewer(container: HTMLElement | string, initialConfig: Pannellum.ConfigOptions): Pannellum.Viewer;
viewer(
container: HTMLElement | string,
initialConfig: Pannellum.ConfigOptions | Pannellum.TourOptions,
): Pannellum.Viewer;
};
}

declare const libpannellum: {
renderer(container: HTMLElement): Pannellum.Renderer;
};

declare const pannellum: {
viewer(container: HTMLElement | string, initialConfig: Pannellum.ConfigOptions): Pannellum.Viewer;
};
declare const libpannellum: Window["libpannellum"];
declare const pannellum: Window["pannellum"];
24 changes: 24 additions & 0 deletions types/pannellum/pannellum-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,27 @@ viewer.addScene("myScene", {
viewer.addScene("myScene", {
// test that all properties are optional
});

// Test tour configurations
const tourOptions: Pannellum.TourOptions = {
default: {
firstScene: "s1",
sceneFadeDuration: 1000,
author: "Me",
},
scenes: {
s1: {
showFullscreenCtrl: false,
autoLoad: false,
compass: false,
yaw: 0,
type: "equirectangular",
preview: "",
panorama: "",
northOffset: 1.3,
},
s2: {},
},
};

pannellum.viewer("abc", tourOptions);