Class: Viewer

bu.street. Viewer

This is 3D viewer that uses internally Three.js classes to show 3D objects, 3D geometries and 360 panorama imagery. This viewer is based on Marzipano viewer but expands the capabilities further away to support any 3D objects to be rendered in the scene. The Marzipano viewer is based on an internal set of objects to render 360 panoramas. This viewer uses internally Three.js, a more flexible and robust API to render 3D objects, including 360 panoramas.

Note that with bu.street.Viewer and all its subclasses, any property set in the options is set as a ol.Object property on the viewer object, so is observable, and has get/set accessors.


new Viewer(options)

Parameters:
Name Type Description
options bu.street.ViewerOptions

Viewer options.

Source:
bu-street/streetviewer.js
Fires:

Extends

Members


autorotate :number

Time in milliseconds to wait to start an autorotateTimeout movement if no other movement has been set. If not value then never autorotates.

Type:
  • number
Source:
bu-street/streetviewer.js

debugPanel :Element

Element to show debug info. Donot use directly. Use addDebugData instead.

Type:
  • Element
Source:
bu-street/streetviewer.js

extraZoomLevels :number|undefined

This property represents the number of zoom levels to add to existing zoom levels defined in any panorama. In the new zoom levels the tiles will be rescaled.

Type:
  • number | undefined
Source:
bu-street/streetviewer.js

state :bu.ViewerState

Type:
Inherited From:
Source:
bu/viewer.js

totalZoomLevels :number|undefined

This property represents the maximum number of zoom levels. Zoom levels defined in any panorama will be redefined to have this number. If this number is greater than the size of the last zoom level defined in the panorama metadata, then the tiles will be shown rescaled.

Type:
  • number | undefined
Source:
bu-street/streetviewer.js

viewType :bu.ViewType|undefined

Type:
Overrides:
Source:
bu-street/streetviewer.js

Methods


addDebugData(group, property, format)

Adds a debug data to the debug panel. If data was previously added then replace the previous value.

Parameters:
Name Type Description
group string

The group the debug data belongs to.

property string

The debug property inside the given group.

format string

Pattern to be filled. The rest of the arguments are the values for filling the pattern. To ouptput a message without any pattern just pass the message in the format param.

Source:
bu-street/streetviewer.js

addInteraction(id, interaction)

Adds a bu.interaction.Interaction to the viewer.

Parameters:
Name Type Description
id string

Identifier of the interaction.

interaction bu.interaction.Interaction

The interaction to add.

Source:
bu-street/streetviewer.js

addLayer(layer)

Adds the given layer to the top of this viewer. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on ol.Collection.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

Inherited From:
Source:
bu/viewer.js

<abstract> clone()

Clones this viewer reinitializing the new one with main values of current one. This is an abstract method that must be implemented in derived classes.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer cloned.

Type
bu.Viewer

copyHotspots(image, images)

Returns a bu.PanoramaMetadata with hotspots copied from a collection of bu.street.Hotspot or bu.PanoramaMetadata.

Parameters:
Name Type Description
image bu.PanoramaMetadata

The image to copy hotspots to.

images Array.<(bu.street.Hotspot|bu.PanoramaMetadata)>

A collection of hotspots or images.

Source:
bu-street/streetviewer.js
Returns:

The resulting image.

Type
bu.PanoramaMetadata

getAttributions()

Returns the list of ol.Attribution currently visible in the viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

Attributions.

Type
Array.<Object.<string, ol.Attribution>>

getBrightness()

Returns the current brightness value of the viewer. Value range in [-100,100].

Source:
bu-street/streetviewer.js
Returns:

The brightness.

Type
number

getCenter()

Returns the current center of the viewer. This center is the point where the 360 image is shot. Coordinates are always in WGS84 latlon, first value in the coordinate is longitude and second latitude.

Source:
bu-street/streetviewer.js
Returns:

The viewer center.

Type
bu.Coordinate

getContrast()

Returns the current contrast value of the viewer. Value range in [-100,100].

Source:
bu-street/streetviewer.js
Returns:

The contrast.

Type
number

getCrosshair()

Get the element that serves as a mid crosshair in the viewer, useful for debugging purposes.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer overlay that shows the crosshair.

Type
Element

getDebugGrid()

Returns if the debug grid should be visible or not when debug mode is true.

Inherited From:
Source:
bu/viewer.js
Returns:

If visible or not.

Type
boolean

getDebugMessage()

Returns a debug message in several paragraphs to include in a div.

Source:
bu-street/streetviewer.js
Returns:

Debug message.

Type
string

getDebugMode()

Returns the current debug mode of the viewer. If true then the debug mode is activated. Debug mode is a special mode that show extra information in the viewer of tiles and other tools that are useful when debugging. Initially any viewer uses the global bu.DEBUG property to set if debug mode must be used. The initial value could later be change through this property.

Inherited From:
Source:
bu/viewer.js
Returns:

The debug mode.

Type
boolean

getFOV()

Returns the current FOV of the viewer in decimal degrees. FOV or Field of View is the angle of the 360 image that is currently visible in the viewer. It depends on the size of the viewer and the angular resolution of the current zoom level. Changing this value causes the same effect of changing zoom level but this value gives more grain control. Value range is [0,360) though values up 180 aren't logical ones in a 2D screen. The projection in a 2D screen is limited to values far under 180. Values above 180 have sense, on the contrary, for VR screens.

Source:
bu-street/streetviewer.js
Returns:

The viewer FOV.

Type
number

getImage()

Returns the current street image. It return null if no image is currently loaded.

Source:
bu-street/streetviewer.js
Returns:

The image.

Type
bu.street.Image | null

getImageID()

Returns the image ID of the BlomURBEX street image currently loaded.

Source:
bu-street/streetviewer.js
Returns:

The image ID.

Type
string

getInteractionContainer()

Returns the interaction container.

Source:
bu-street/streetviewer.js
Returns:
Type
Element

getInteractions()

Returns the array of interactions.

Source:
bu-street/streetviewer.js
Returns:
Type
Array.<bu.interaction.Interaction>

getLayer()

Get the layer used in the viewer. The layer property is a filter for sets of images when requesting for panoramas.

Source:
bu-street/streetviewer.js
Returns:

A layer for this viewer.

Type
string

getLayerGroup()

Get the layergroup associated with this viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

A layer group containing the layers in this viewer.

Type
ol.layer.Group

getLayers()

Get the collection of layers associated with this viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

Layers.

Type
ol.Collection.<ol.layer.Base>

getNDCEventPixel(event)

Returns the NDC pixel position (Normalized Device Coordinates) for a browser event relative to the viewport.

Parameters:
Name Type Description
event Event

Event.

Source:
bu-street/streetviewer.js
Returns:

NDC pixel as two values x and y.

Type
Array.<number>

getOverlayContainerStopEvent()

Get the element that serves as a container for overlays that don't allow event propagation. Elements added to this container won't let mousedown and touchstart events through to the viewer, so clicks and gestures on an overlay don't trigger any event.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer's overlay container that stops events.

Type
Element

getPitch()

Returns the current pitch value of the viewer in decimal degrees. Valid range is [-90, 90]. When pitch value is 0 the viewer is aligned with horizon, -90 value is the highest angle we can target of the image and 90 is the lowest.

Source:
bu-street/streetviewer.js
Returns:

The pitch value of the viewer. Range is [-90,90].

Type
number

getRoll()

Returns the current roll value of the viewer in decimal degrees. Valid range is [-180, 180]. This value has no sense in normal displays, where always be zero, but has a lowest of sense in VR/AR displays where head can roll even to 180 degrees (very unsual but possible). When roll value is 0 the viewer is aligned with horizon, -180/180 is upside down.

Source:
bu-street/streetviewer.js
Returns:

The roll value of the viewer. Range is [-180,180].

Type
number

getRotation()

Returns the current rotation of the viewer in decimal degrees with north equal zero and values increasing towards east. Value range is [0,360).

Source:
bu-street/streetviewer.js
Returns:

The viewer rotation.

Type
bu.Coordinate

getSize()

Get the size of this viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The size in pixels of the viewer in the DOM.

Type
bu.Size | undefined

getState()

Return the viewer state.

Inherited From:
Source:
bu/viewer.js
Returns:
Type
bu.ViewerState

getTarget()

Get the target in which the viewer is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that.

Inherited From:
Source:
bu/viewer.js
Returns:

The Element or id of the Element that the viewer is rendered in.

Type
Element | string | undefined

getTargetElement()

Get the DOM element into which this viewer is rendered. In contrast to getTarget this method always return an Element, or null if the viewer has no target.

Inherited From:
Source:
bu/viewer.js
Returns:

The element that the viewer is rendered in.

Type
Element

getTime()

Returns the current time filter of the viewer. Valid time values are any string with pattern YYYYMMDD or with pattern YYYYMMDD-YYYYMMDD. First filters images before the date, and second filters images between the dates.

Inherited From:
Source:
bu/viewer.js
Returns:

The time string.

Type
string

getTimeValues()

Returns the current time value as a pair of values [minDate,maxDate]. If time value has pattern YYYYMMDD then minDate = -Infinity and maxDate a number with 8 digits following YYYYMMDD pattern. If time value has pattern YYYYMMDD-YYYYMMDD then minDate and maxDate are numbers with 8 digits following YYYYMMDD pattern. If time value is not valid pattern then null is returned.

Inherited From:
Source:
bu/viewer.js
Returns:

The time as a pair of values.

Type
Array.<number>

getViewport()

Return the viewport of the viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewport.

Type
Element

getViewType()

Return the type of the viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer type.

Type
bu.ViewType

getYaw()

Returns the current yaw value of the viewer in decimal degrees. Valid range is [-180, 180]. When yaw value is 0 the viewer is aligned with the vehicle direction. Yaw and rotation are related by the directionYaw value that all panorama images has as metadata. directionYaw is the angle between north and vehicle direction.

Source:
bu-street/streetviewer.js
Returns:

The yaw value of the viewer. Range is [-180, 180].

Type
number

getZoom()

Get the zoom level or undefined if not found.

Source:
bu-street/streetviewer.js
Returns:
Type
number | undefined

openImage(image)

Opens image.

Parameters:
Name Type Description
image bu.street.Image

The street image.

Source:
bu-street/streetviewer.js

removeInteraction(id)

Removes a bu.interaction.Interaction from the viewer.

Parameters:
Name Type Description
id string

Identifier of the interaction.

Source:
bu-street/streetviewer.js

removeLayer(layer)

Removes the given layer from this viewer.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

Inherited From:
Source:
bu/viewer.js
Returns:

The removed layer (or undefined if the layer was not found).

Type
ol.layer.Base | undefined

<abstract> render()

Renders the viewer.

Inherited From:
Source:
bu/viewer.js

setBrightness(brightness)

Sets the current brightness value of the viewer. Value range in [-100,100].

Parameters:
Name Type Description
brightness number

The brightness.

Source:
bu-street/streetviewer.js

setCenter(center)

Sets the current center of the viewer. If this center do not matches the point where a 360 image was shot then the neareast shotpoint is searched. Coordinates are always in WGS84 latlon, first value in the coordinate is longitude and second latitude.

Parameters:
Name Type Description
center bu.Coordinate

The viewer center.

Source:
bu-street/streetviewer.js

setContrast(contrast)

Sets the current contrast value of the viewer. Value range in [-100,100].

Parameters:
Name Type Description
contrast number

The contrast.

Source:
bu-street/streetviewer.js

setCrosshairVisibility(visible)

Sets the crosshair visibility.

Parameters:
Name Type Description
visible boolean

If visible or not.

Inherited From:
Source:
bu/viewer.js

setDebugGrid(visible)

Sets if the debug grid should be visible or not when debug mode is true.

Parameters:
Name Type Description
visible boolean

If visible or not.

Inherited From:
Source:
bu/viewer.js

setDebugMode(debugmode)

Sets the debug mode of the viewer. If true then the debug mode is activated. Debug mode is a special mode that show extra information in the viewer of tiles and other tools that are useful when debugging. Initially any viewer uses the global bu.DEBUG property so set if debug mode must be used. The initial value could later be change through this property.

Parameters:
Name Type Description
debugmode boolean

The debug mode.

Inherited From:
Source:
bu/viewer.js

setFOV(fov)

Sets the current FOV of the viewer in decimal degrees. FOV or Field of View is the angle of the 360 image that is currently visible in the viewer. It depends on the size of the viewer and the angular resolution of the current zoom level. Changing this value causes the same effect of changing zoom level but this value gives more grain control. Value range is [0,360) though values up 180 aren't logical ones in a 2D screen. The projection in a 2D screen is limited to values far under 180. Values above 180 have sense, on the contrary, for VR screens.

Parameters:
Name Type Description
fov number

The viewer FOV.

Source:
bu-street/streetviewer.js

setImage(image)

Sets the BlomURBEX street imaage to be shown.

Parameters:
Name Type Description
image bu.street.Image

The street image.

Source:
bu-street/streetviewer.js

setImageID(imageid)

Sets the image ID of the BlomURBEX street image to be shown.

Parameters:
Name Type Description
imageid string

The image ID.

Source:
bu-street/streetviewer.js

setLayer(layerGroup)

Sets the layer of the viewer. The layer property is a filter for sets of images when requesting for panoramas.

Parameters:
Name Type Description
layerGroup string

A layer for the viewer.

Source:
bu-street/streetviewer.js

setLayerGroup(layerGroup)

Sets the layergroup of the viewer.

Parameters:
Name Type Description
layerGroup ol.layer.Group

A layer group containing the layers in the viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js

setPitch(pitch)

Sets the current pitch value of the viewer in decimal degrees. Valid range is [-90, 90] for normal displays and [-180,180] for VR/AR displays. When pitch value is 0 the viewer is aligned with horizon, -90 value is the highest angle we can target of the image and 90 is the lowest.

Parameters:
Name Type Description
pitch number

The pitch value.

Source:
bu-street/streetviewer.js

setRoll()

Sets the current roll value of the viewer in decimal degrees. Valid range is [-180, 180]. This value has no sense in normal displays, where always be zero, but has a lowest of sense in VR/AR displays where head can roll even to 180 degrees (very unsual but possible). When roll value is 0 the viewer is aligned with horizon, -180/180 is upside down.

Source:
bu-street/streetviewer.js
Returns:

The roll value.

Type
number

setRotation(rotation)

Sets the current rotation of the viewer in decimal degrees with north equal zero and values increasing towards east. Value range is [0,360).

Parameters:
Name Type Description
rotation bu.Coordinate

The viewer rotation.

Source:
bu-street/streetviewer.js

setSize(size)

Set the size of this viewer.

Parameters:
Name Type Description
size bu.Size | undefined

The size in pixels of the viewer in the DOM.

Inherited From:
Source:
bu/viewer.js

setSyncingHandlers(handler)

Sets the listeners to the events of the viewer that will cause other synced viewers to be updated. This is an abstract method. It must be overriden in derived classes.

Parameters:
Name Type Description
handler function

The handler that will manage the events.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

Array of key listeners for later easy disposal.

Type
Array.<ol.EventsKey>

setTarget(target)

Set the target element to render this viewer into.

Parameters:
Name Type Description
target Element | string | undefined

The Element or id of the Element that the viewer is rendered in.

Inherited From:
Source:
bu/viewer.js

setTime(time)

Sets the current time filter of the viewer. Valid time values are any string with pattern YYYYMMDD or with pattern YYYYMMDD-YYYYMMDD. First filters images before the date, and second filters images between the dates.

Parameters:
Name Type Description
time string

The time string.

Inherited From:
Source:
bu/viewer.js

setYaw(yaw)

Sets the current yaw value of the viewer in decimal degrees. Valid range is [-180, 180] When yaw value is 0 the viewer is aligned with the vehicle direction. Yaw and rotation are related by the directionYaw value that all panorama images has as metadata. directionYaw is the angle between north and vehicle direction.

Parameters:
Name Type Description
yaw number

The viewer yaw.

Source:
bu-street/streetviewer.js

setZoom(zoom)

Sets the zoom of the viewer.

Parameters:
Name Type Description
zoom number

Zoom

Source:
bu-street/streetviewer.js

syncWithViewer(viewer, viewIndex, syncProperties, event)

Synchronizes this viewer with another one knowing its viewIndex and its sync options.

Parameters:
Name Type Description
viewer bu.Viewer

The viewer to sync with.

viewIndex number

The index in the layout of the viewer to sync with.

syncProperties bu.SyncProperties

The syncing properties.

event ol.events.Event

The event that triggered the syncing action.

Inherited From:
Overrides:
Source:
bu/viewer.js

updateImage(image)

Opens image if already set or sets image if not.

Parameters:
Name Type Description
image bu.street.Image

The street image.

Source:
bu-street/streetviewer.js

updateSize()

Force a recalculation of the viewer viewport size. This should be called when third-party code changes the size of the viewer viewport.

Inherited From:
Source:
bu/viewer.js

zoomByDelta(delta)

Zooms the viewer the number of zoom levels defined by delta.

Parameters:
Name Type Description
delta number

Delta zoom levels.

Source:
bu-street/streetviewer.js