Class: SceneManager

SceneManager

A scene manager for Three.js capable of rendering panorama 360 images and vector data overlays.


new SceneManager(options)

Parameters:
Name Type Description
options Mapspace.street.threejs.SceneManagerOptions

Object with options as properties.

Source:
mapspace-street/scenemanager.js
Fires:
  • ol.events.Event#event:camerachanged
  • ol.events.Event#event:renderinvalid
  • ol.events.Event#event:resize

Extends

  • ol.Object

Members


facesOrder :string

The list of chars for cube face order.

Source:
mapspace-street/scenemanager.js

fovLimitEpsilon :number

A fov of exactly 0 or π breaks some computations, so we constrain it to the [fovLimitEpsilon, π - fovLimitEpsilon] interval. We use 9 decimal places for the epsilon value since this is the maximum number of significant digits for a 32-bit floating-point number. Note that after a certain zoom level, rendering quality will be affected by the loss of precision in floating-point computations.

Source:
mapspace-street/scenemanager.js

viewer :Mapspace.street.Viewer

The viewer.

Source:
mapspace-street/scenemanager.js

Methods


addAxisCollection(distance)

Adds the Mapspace.street.threejs.AxisCollection if no one is added.

Parameters:
Name Type Description
distance number

The length of axes or planes. Defaults to 100.

Source:
mapspace-street/scenemanager.js

addFeature(feature)

Adds the THREE.Object3D contained in a ol.Feature to the scene. The Object3D must be stored in observable property called Mapspace.STREET_GEOMETRY_NAME in the feature. Do not call render so a render call is needed after adding all required objects.

Parameters:
Name Type Description
feature ol.Feature

The feature to add.

Source:
mapspace-street/scenemanager.js

addIcon(svg, position, w, h, scale, name)

Adds a SVG icon. Returns the created object.

Parameters:
Name Type Argument Description
svg string

The string containing the SVG icon.

position Mapspace.Coordinate

Location for the icon in local coordinates.

w number

Width of SVG in pixels.

h number

Height of SVG in pixels.

scale number <nullable>

Scale to apply to returned object. If SVG is defined with default units (pixels) one pixel is converted to one meter. To avoid large SVG icons in the scene the passed scale will be used or 1 if no scale is passed.

name string <nullable>

Optional name for searching the icon.

Source:
mapspace-street/scenemanager.js
Returns:
Type
THREE.Object3D

addPopup(feature, popup)

Adds the THREE.Object3D that will set as a popup to a ol.Feature and to the scene. The Object3D passed will be added as subobject to the Object3D that must be stored in observable property called Mapspace.STREET_GEOMETRY_NAME in the feature. Do not call render so a render call is needed after adding all required objects. A subobject is a popup when has a value Mapspace.css.CLASS_MEASUREMENT_TOOLTIP or Mapspace.css.CLASS_ANNOTATION_TOOLTIP set to true in the userData of the subobject.

Parameters:
Name Type Description
feature ol.Feature

The feature to which add the popup.

popup THREE.Object3D

The popup.

Source:
mapspace-street/scenemanager.js

addVectorLayer(layer)

Adds all the THREE.Object3D objects contained in the provided vector layer and then calls render.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

Source:
mapspace-street/scenemanager.js

changeBrightness(brightness)

Change brightness.

Parameters:
Name Type Description
brightness number

Brightness.

Source:
mapspace-street/scenemanager.js

changeContrast(contrast)

Change contrast.

Parameters:
Name Type Description
contrast number

Contrast.

Source:
mapspace-street/scenemanager.js

forceRender()

Forces a render of the scene even if no change has occurred in the camera.

Source:
mapspace-street/scenemanager.js

getCoordinateAtGroundFromPixel(pixel)

Returns the coordinates at ground in local projection of a NDC pixel in screen.

Parameters:
Name Type Description
pixel Array.<number>

Two values with NDC x and y.

Source:
mapspace-street/scenemanager.js
Returns:

A three values x, y, z with coordinates at the ground level in local current projection. Local current projection is included in current image metadata as a srid property. Returns null if pixel do not intersects ground.

Type
Mapspace.Coordinate

getIcon(name)

Returns the icon with the given name or null if no one exists in the scene.

Parameters:
Name Type Description
name string

Name of the object.

Source:
mapspace-street/scenemanager.js
Returns:
Type
THREE.Object3D

highlightImagePointAtPixel(pixel)

Highlights the first image point found at the given pixel, if any.

Parameters:
Name Type Description
pixel Mapspace.Coordinate

The pixel as a NDC event pixel.

Source:
mapspace-street/scenemanager.js

isPopupsOfVectorLayerVisible(layer)

Returns true if all the subobjects that are defined as popups in each THREE.Object3D objects contained in the provided vector layer are visible.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

Source:
mapspace-street/scenemanager.js
Returns:
Type
boolean

isPopupsVisible(feature)

Returns true if the subobjects that are defined as popups in the THREE.Object3D object contained in the provided feature are visible.

Parameters:
Name Type Description
feature ol.Feature

The feature to change.

Source:
mapspace-street/scenemanager.js
Returns:
Type
boolean

logVisibleTiles()

Logs current visible tiles.

Source:
mapspace-street/scenemanager.js

openImage(rotation, done)

Open the current image of the viewer in the scene. This function does all the needed steps for opening a new image. If an opened image exists it transitions from one the next and finally calls to the done function at the end.

Parameters:
Name Type Description
rotation number

Rotation in decimal degrees to use to initialize the camera once the cubic panorama is initialized.

done function

Function to call once image is opened.

Source:
mapspace-street/scenemanager.js

removeAllVectorLayers()

Removes all the THREE.Object3D objects contained in all the vector layers currently loaded in the viewer this SceneManager belongs to and then calls render.

Source:
mapspace-street/scenemanager.js

removeAxisCollection()

Source:
mapspace-street/scenemanager.js

removeFeature(feature)

Removes the THREE.Object3D contained in a ol.Feature from the scene. The Object3D must be stored in observable property called Mapspace.STREET_GEOMETRY_NAME in the feature.Do not call render so a render call is needed after removing all required objects.

Parameters:
Name Type Description
feature ol.Feature

The feature to remove.

Source:
mapspace-street/scenemanager.js

removeIcon(object)

Removes an icon represented by passed object (the object returned by addIcon).

Parameters:
Name Type Description
object THREE.Object3D

Object with an icon.

Source:
mapspace-street/scenemanager.js

removePopup(feature)

Removes all the THREE.Object3D that are popups from the ol.Feature and from the scene. Do not call render so a render call is needed after removing all required objects.

Parameters:
Name Type Description
feature ol.Feature

The feature from which remove popups.

Source:
mapspace-street/scenemanager.js

removePopupsOfVectorLayer(layer)

Removes all the THREE.Object3D objects that are popups contained in the provided vector layer and then calls render.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

Source:
mapspace-street/scenemanager.js

removeVectorLayer(layer)

Removes all the THREE.Object3D objects contained in the provided vector layer and then calls render.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

Source:
mapspace-street/scenemanager.js

render()

Requests a new render of the scene using the current status of objects. The object in charge of managing the renders is the RenderLoop.

Source:
mapspace-street/scenemanager.js

setDebugGrid(debugGrid)

Shows or hides debug grid to the existing CubicPanorama.

Parameters:
Name Type Description
debugGrid boolean

True to show and false to hide.

Source:
mapspace-street/scenemanager.js

setDebugGridColor(debugColor)

Changes color of the debug grid.

Parameters:
Name Type Description
debugColor string

Color as CSS color.

Source:
mapspace-street/scenemanager.js

setFeatureVisible(feature, visible)

Changes the visibility of the THREE.Object3D object contained in the provided feature. Do not call render so a render call is needed after changing objects.

Parameters:
Name Type Description
feature ol.Feature

The feature to change.

visible boolean

If show the objects or hide them.

Source:
mapspace-street/scenemanager.js

setIconPosition(object, position)

Relocates an icon represented by passed object (the object returned by addIcon).

Parameters:
Name Type Description
object THREE.Object3D

Object with an icon.

position Mapspace.Coordinate

Coordinates in local space.

Source:
mapspace-street/scenemanager.js

setPopupPosition(feature, position, offset)

Relocates a popup.

Parameters:
Name Type Description
feature ol.Feature

The feature to relocate popup.

position Mapspace.Coordinate

Coordinates in local coordinates of the Object3D that is the parent of the popup. It is used to calculate the correct rotation for the popup.

offset Mapspace.Coordinate

Coordinate offset for popup relatives to parent object.

Source:
mapspace-street/scenemanager.js

setPopupsOfVectorLayerVisible(layer, visible)

Changes the visibility of the subobjects that are defined as popups in each THREE.Object3D objects contained in the provided vector layer and then calls render. A subobject is a popup when has a value Mapspace.css.CLASS_MEASUREMENT_TOOLTIP or Mapspace.css.CLASS_ANNOTATION_TOOLTIP set to true in the userData of the subobject.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

visible boolean

If show the objects or hide them.

Source:
mapspace-street/scenemanager.js

setPopupsVisible(feature, visible)

Changes the visibility of the subobjects that are defined as popups in the THREE.Object3D object contained in the provided feature. Do not call render so a render call is needed after changing objects. A subobject is a popup when has a value Mapspace.css.CLASS_MEASUREMENT_TOOLTIP or Mapspace.css.CLASS_ANNOTATION_TOOLTIP set to true in the userData of the subobject.

Parameters:
Name Type Description
feature ol.Feature

The feature to change.

visible boolean

If show the objects or hide them.

Source:
mapspace-street/scenemanager.js

setVectorLayerVisible(layer, visible)

Changes the visibility of the THREE.Object3D objects contained in the provided vector layer and then calls render.

Parameters:
Name Type Description
layer Mapspace.layer.Vector

The vector layer.

visible boolean

If show the objects or hide them.

Source:
mapspace-street/scenemanager.js

updateCamera(params)

Updates camera pointing to current yaw, pitch, roll and fov.

Parameters:
Name Type Description
params Mapspace.street.CameraParameters

Camera parameters.

Source:
mapspace-street/scenemanager.js

updateDepthMap(status)

Updates the visible tiles using the new status for the depth map.

Parameters:
Name Type Description
status boolean

Id the depth map must be visible or not.

Source:
mapspace-street/scenemanager.js

updateSize()

Updates the scene manager size to fill the containing element.

This function is automatically called when the browser window is resized. Most clients won't need to explicitly call it to keep the size up to date.

Source:
mapspace-street/scenemanager.js