API¶
Additionally, the common API of a module is available.
Methods¶
loadView3d()¶
Asynchronous method that loads a specific 3d view from a venue.
Input:
load_options
(object): Object with the information of the 3d view to be loaded. Its properties are:venue_id
(string): venue id.view_id
(string): view id. It is usually a seat id or a section id, and the ids, in general, match those found inmap_viewer
maps.reset_camera_rotation
(boolean) [optional]: resets the camera rotation so the new view will be looking at the front.true
by default.false
is useful in some plugins, like navigation plugin.
Output:
promise
(Promise): loadView3d returns a promise that will be resolved if the 3d view is loaded successfully, or it will be rejected if there was a problem when loading the 3d view.- If the promise is resolved successfully, the first argument will be an object with the
property
instance
, with the reference to the module. - If the promise is rejected, the first argument will be an error with a property
instance
with the module instance that failed to load.
- If the promise is resolved successfully, the first argument will be an object with the
property
Warning
This method is asynchronous.
Example:
loadSpace3d()¶
Warning
Experimental. It may change in the future.
Asynchronous method that loads a specific 3d space from a venue.
Input:
options
(object): Object with the information of the 3d view to be loaded. Its properties are:venue_id
(string): venue id.space_id
(string): space id.set_id
(string) [optional]: venue set id.rotation
([number, number]) [optional]: Initial camera position (phi, theta)in spherical coords.reset_camera_rotation
(boolean) [optional]: resets the camera rotation or keep the last camera position.
Output:
promise
(Promise): loadSpace3d returns a promise that will be resolved if the 3d space is loaded successfully, or it will be rejected if there was a problem when loading the 3d view.- If the promise is resolved successfully, the first argument will be an object with the property
instance
, with the reference to the module. - If the promise is rejected, the first argument will be an error with a property
instance
with the module instance that failed to load.
- If the promise is resolved successfully, the first argument will be an object with the property
Warning
This method is asynchronous.
Example:
checkView3d()¶
Asynchronous method that checks if a specific 3d view exists.
Input:
options
(object): Object with the information of the 3d view to be checked. Its properties are:venue_id
(string): venue id.view_id
(string): view id. It is usually a seat id or a section id, and the ids, in general, match those found inmap_viewer
maps.
Output:
promise
(Promise): returns a promise that will be resolved with a boolean, beingtrue
if the view exists, orfalse
if it does not. The promises will be rejected if there is another problem, for example if you do not have permissions to access this venue, regardless of whether the view exists or not.
Warning
This method might generate a 403 error in console if the view does not exist. This error message cannot be prevented to be shown in console, but is harmless and no javascript error is thrown.
Warning
This method is asynchronous.
Example:
getThumbnail()¶
Asynchronous method that returns an image with a preview of the 3d view.
The returned image has a size of 256x256 pixels.
Warning
Not all venues have 3d panoramic views, so you might get an error if the image does not exist.
Input:
options
(object): Object with the information of the preview to be downloaded. Its properties are:venue_id
(string): venue id.view_id
(string): view id. It is usually a seat id or a section id, and the ids, in general, match those found inmap_viewer
maps.
url
(boolean) [optional]:true
if you want that the promise to be resolved in a url,false
will be resolved in an image.false
by default.
Output:
promise
(Promise): If the image is downloaded successfully, thePromise
resolves with the image. If the flag url isfalse
it is resolved in an url.
Example:
isInitialized()¶
Returns true if the module has been initialized.
Output:
initialized
(boolean):true
if it has been initialized,false
otherwise.
Example:
isLoaded()¶
Returns true if there is a 3d view currently loaded.
Output:
loaded
(boolean):true
if a 3d view is completely loaded,false
otherwise.
Example:
reset()¶
unloads the current 3d view (if any). It is necessary to call loadView3d again after this.
Example:
subscribe()¶
Allows the subscription to callbacks. This is the same as passing the callbacks when loading the module.
Input:
callback_name
(string): Any callback of the list.callback_func
(function): Function that will be called when triggered.
Example:
unsubscribe()¶
Removes a callback previously added with subscribe method or loading the module.
Input:
callback_name
(string): Any callback of the list.callback_func
(function): reference to the function to be removed.
Example:
getViewDescription()¶
Asynchronous method that resolves in a panoramic view description.
Input:
options
(object) [optional]:true
Optional object with the information of the 3d view to get its description. If no input is passed, it will get the description of the current loaded view (if any). Its properties are:venue_id
(string)view_id
(string)
Output:
description
(Promise): promise that will be resolved with an object with "title" and "description".
Example:
open()¶
Appends the 3d viewer to the DOM.
Example:
close()¶
Detaches the 3d viewer from the DOM.
Example:
getVenueId()¶
Returns the id of the current loaded venue.
Output:
current_venue
(string|null): returns the id of the current loaded venue. If there is no venue loaded yet, it will returnnull
.
Example:
getViewId()¶
Returns the id of the current loaded 3d view.
Output:
current_view
(string|null): returns the id of the current loaded 3d view. If there is no view loaded yet, it will returnnull
.
Example:
getSpaceId()¶
Warning
Experimental. It may change in the future.
Returns the id of the current loaded 3d space.
Output:
current_view
(string|null): returns the id of the current loaded 3d space. If there is no space loaded yet, it will returnnull
.
Example:
getSceneType()¶
Warning
Experimental. It may change in the future.
Returns the scene configuration.
Output:
scene_type
("pano"|"space"|null): returns if the scene is a pano or space. If there is no view loaded yet, it will returnnull
.
Example:
setContainer()¶
Changes the container where the 3d viewer is.
Input:
div_element
(string | HTMLDivElement): if the input is a string, it must be de unique id of anHTMLDivElement
. Otherwise, it must be theHTMLDivElement
itself.
Example:
toggleFullscreen()¶
enables/disables full screen mode.
This method triggers the following callbacks:
fullscreen_enabled
fullscreen_disabled
Warning
Due to browser security measures, this method should be called from an event triggered by the user. Otherwise, the browser could cancel the action.
Output:
promise
(Promise): It will be resolved once the fullscreen request has been fullfilled. If the request fails, for example if the browser blocks de request because it has been requested outside a user event, it will be rejected.
Example:
rotateCamera()¶
Rotates the camera a certain angle.
Input:
spherical
([number, number]): phi and theta coords.inertia
(boolean?): the rotation will generate inertia if this istrue
.false
by default.
lookAt()¶
Rotate the camera to look at the vec coords.
Input:
load_options
(object): Object with the information of the map to be loaded. Its properties are:target
([number, number, number] | Viewer3dNode): iftarget
is a vector this indicate where the camera should look. If it's a node the camera will look at it.time
(number?) = 0: time of the interpolation animation from the current camera rotationlocal
(boolean?) = false:true
if the point is in local coordinates.false
by default. Ignored if target is not a node.behavior
("no_rotation" | "look_at" | "normal" | "best_view" | "node_look_at_vector" | "default"?) = "default": In 3DSpaces
it indicates how we should interprate the rotation and movement. In 3DPanos
it's ignored.
Input:
Warning
Deprecated input. Use the other input instead.
vec
([number, number, number]): position to look at.time
(number): how many ms should last the transition.local
(boolean?): Is thevec
input in venue coords or relative to the pano.
Output:
look_at_promise
(Promise): returns the transition promise to detect when it end. The promise will be rejected if the venue is not loaded or if the user interrupts the animation.
Example:
Properties¶
aspect_ratio¶
Changes or returns the 3d viewer aspect ratio. It only works if fixed_aspect_ratio
is true
.
Input/Output:
aspect_ratio
(number): aspect ratio from the 3d viewer. The value is obtained by dividing height/width. For instance, to use a 16:9 aspect ratio, the division is9/16
. This is set to9/16
by default.
Example:
pixel_ratio¶
Sets the canvas pixel ratio. By default, it is set to 1
.
For more info check this.
Warning
Increasing this value may affect performance.
Input/Output:
pixel_ratio
(number): pixel ratio.
Example:
fov¶
Changes or returns the 3d viewer field of view.
Input/Output:
fov
(number): field of view of the camera, in degrees.
Example:
azimuth_limit¶
Changes or returns the spherical azimuth limit.
Input/Output:
[min, max]
([number, number]): min and maximum azimuth (horizontal move), in degrees ([0, 360]).
Example:
polar_limit¶
Changes or returns the spherical polar limit.
Input/Output:
[min, max]
([number, number]): min and maximum polar (horizontal move), in degrees ([0, 180]).
Example:
Flags¶
fixed_aspect_ratio¶
Info
You can set this flag when initializing process has finished (loadModule
).
Specifies the rescaling mode of the 3d viewer.
- If
true
: The 3d viewer will take up the 100% of the container width, and the height will be computed multiplying the width by theaspect_ratio
. For instance, if aspect_ratio = 0.5, the height will be 500px when the Viewer container has width of 1000px. - If
false
: The Viewer will take up the 100% of the container width and height. It is important to ensure that the container has some height or it will be set as 0px.aspect_ratio
will be ignored.
Input/Output:
fixed_aspect_ratio
(boolean):true
enables the fixed_aspect_ratio mode.false
disables it. This is set totrue
by default.
Example:
show_fullscreen_button¶
Info
You can set this flag when initializing process has finished (loadModule
).
show/hides fullscreen button.
- If
true
: The 3d viewer will take up the 100% of the container width, and the height will be computed multiplying the width by theaspect_ratio
. For instance, if aspect_ratio = 0.5, the height will be 500px when the Viewer container has width of 1000px. - If
false
: The Viewer will take up the 100% of the container width and height. It is important to ensure that the container has some height or it will be set as 0px.aspect_ratio
will be ignored.
Input/Output:
show_fullscreen_button
(boolean):true
shows the button.false
hides it. This is set totrue
by default.
Example:
show_loading_screen¶
Info
You can set this flag when initializing process has finished (loadModule
).
Enables/disables the loading screen while a view is loading.
- If
true
: It will show a loading screen animation while loading. - If
false
: no loading screen.
Input/Output:
show_loading_screen
(boolean):true
enables the loading screen.false
disables it. This is set totrue
by default.
Example:
show_tutorial¶
Info
You can set this flag when initializing process has finished (loadModule
).
Enables/disables the tutorial animation the first time a view is loaded.
- If
true
: A tutorial animation with a predefined movement will be shown the first time a view is loaded. - If
false
: No tutorial animation will be shown.
Input/Output:
show_tutorial
(boolean):true
enables the tutorial.false
disables it. This is set totrue
by default.
Example:
keyboard_arrows_rotation¶
Info
You can set this flag when initializing process has finished (loadModule
).
allows using the left/right keyboard arrows to rotate the camera when a view is loaded.
- If
true
: left and right keyboard arrows will rotate the view. - If
false
: disables keyboard arrow rotation.
Input/Output:
keyboard_arrows_rotation
(boolean):true
enables arrow keys rotation.false
disables arrow keys rotation. This is set totrue
by default.
Example:
zooming¶
Info
You can set this flag when initializing process has finished (loadModule
).
Enables or disables zooming with mouse or touch. Not all 3D views allows to zoom, independently of the value of this flag.
- If
true
: allows zooming on the 3d view (if the view allows it) with mouse scroll or pinch. - If
false
: disables zooming on the view with scroll or pinch. You still can zoom in and out with interface buttons or other API methods. Disabling it will allow scrolling on the page over the view.
Input/Output:
zooming
(boolean):true
enables zooming.false
disables it. This is set totrue
by default.
Example:
panning¶
Info
You can set this flag when initializing process has finished (loadModule
).
Enables or disables panning with mouse or touch.
- If
true
: allows panning with mouse or touch. - If
false
: disables panning on the view when using mouse or touch. You still can move with interface buttons or other methods.
Input/Output:
panning
(boolean):true
enables panning.false
disables it. This is set totrue
by default.