Class: Mizar

Mizar

Creates an instance of the Mizar API.

new Mizar(options)

Parameters:
Name Type Description
options Mizar.inputParameters Configuration for Mizar

Members


AnimationFactory

Creates an animation

ServiceFactory

Creates a service

ProviderFactory

Creates a provider

VERSION

Static variable, API version.
SemVer concept is used for versioning

ANIMATION

Static variable, supported animation type

LAYER

Static variable, supported layer type

GEOMETRY

Static variable, supported geometry type

Static variable, supported navigation type

CONTEXT

Static variable, supported context type

PROJECTION

Static variable, supported projection type

CRS

Static variable, supported coordinate reference system type

SERVICE

Static variable, supported service type

UTILITY

Static variable, supported utility type

PROVIDER

Static variable, supported provider type

Methods


getSkyContext()

Returns the sky context.
Returns:
Type
SkyContext | null

getPlanetContext()

Returns the planet context.
Returns:
Type
PlanetContext | null

getActivatedContext()

Returns the selected context
Returns:
Type
PlanetContext | SkyContext

setActivatedContext(contextMode)

Selects the context as default context according to the context mode.
Once a context is selected, methods can be applied to it.
Parameters:
Name Type Description
contextMode CONTEXT select one context among context
Fires:
  • Mizar#mizarMode:toggle
Throws:
contextMode not valid - a valid contextMode is included in the list CONTEXT
Type
RangeError

getRenderContext()

Returns the rendering context.
Returns:
the rendering context
Type
RenderContext

getOptions()

Returns the options
Returns:
- Mizar's options
Type
Mizar.parameters

getCrs()

Returns the coordinate reference system related to the selected context
See:
Returns:
the coordinate reference system
Type
Crs

setCrs(coordinateSystem)

Sets the coordinate reference system related to the selected context
Parameters:
Name Type Description
coordinateSystem AbstractProjection.configuration | AbstractProjection.azimuth_configuration | AbstractProjection.mercator_configuration coordinate system description
See:

createContext(contextMode, options)

Creates a context according to the context mode.
The created context is selected automatically as default context. The rendering context for the new context is retrieved from the previous context.
Parameters:
Name Type Description
contextMode CONTEXT Select on context among context
options AbstractContext.skyContext | AbstractContext.planetContext Options for the context, See options.planetContext or options.skycontext configuration for Mizar
Fires:
  • Mizar#mizarMode:toggle
Throws:
contextMode not valid - a valid contextMode is included in the list CONTEXT
Type
RangeError

toggleDimension()

Switches 2D <--> 3D, only for planetary context.
When this method is used in a sky context, and exception is thrown
Throws:
"Not implemented" - Will throw an exception for Sky mode. In this version, the sky cannot be projected in 2D

toggleContext(gwLayer, options, callback)

Switches planetary <---> sky context
Parameters:
Name Type Description
gwLayer PlanetLayer planet layer
options AbstractContext.planetContext options for the planet
callback toggleContextCallback Call at the end of the toggle
Fires:
  • Mizar#mizarMode:toggle

getSkyLayers()

Returns the sky layers, which have been added by Mizar#addLayer.
Returns:
the layers
Type
Array.<Layer>

getPlanetLayers()

Returns the planet layers, which have been added by Mizar#addLayer
Returns:
the layers
Type
Array.<Layer>

getLayers(mode)

Returns the layers for a specific context.
When no context is specified, the layers from the selected context are returned.
Parameters:
Name Type Description
mode CONTEXT | undefined Context on which the function is applied
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
the layers
Type
Array.<Layer>

getAllLayers()

Returns all the layers regardless of the context.
Returns:
the layers
Type
Array.<Layer>

getLayerByID(layerID, mode)

Returns the layer by its ID according to the context.
When no context is specified, the layer from the selected context is returned.
The ID is a unique layer identifier, which is returned when the layer description is added to Mizar
Parameters:
Name Type Description
layerID Layer's ID
mode CONTEXT | undefined Context on which the function is applied
See:
Returns:
The layer or undefined when the layer is not found
Type
Layer | undefined

getLayerByName(layerName, mode)

Returns the layer by its name according to the context.
When no context is specified, the layer from the selected context is returned.
Note: The name may not be unique. In this case, the first layer having this name is returned
Parameters:
Name Type Description
layerName string Layer's name, provided in the layer description when the layer is added
mode CONTEXT | undefined Context on which the function is applied
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
the layer or undefined when the layer is not found
Type
Layer | undefined

addLayer(layerDescription [, layerPlanet])

Adds a layer according to the selected context.
When layerPlanet is not provided, then the layer is added to the selected context otherwise the layer is added to the layerPlanet.
Parameters:
Name Type Argument Description
layerDescription Object See the base properties AbstractLayer.configuration and a specific layer for specific properties
layerPlanet PlanetLayer <optional>
the planet with which the layer must be linked
See:
To Do:
  • Bug to fix : PlanetLayer should use this function to create layer when the context changes
Listens to Events:
  • AbstractLayer#visibility:changed
Returns:
a unique identifier
Type
string

removeLayer(layerID, mode)

Removes a layer by its ID according to the context.
When no context is specified, then the function is applied on the selected context.
Parameters:
Name Type Description
layerID string Layer's ID
mode CONTEXT | undefined Context on which the function is applied
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
True when the layer is added otherwise False
Type
boolean

setBackgroundLayer(layerName, mode)

Sets the background layer according to the selected context.
When no context is specified, then the function is applied on the selected context.
Note 1: The name is not a unique identifier. The first layer matching at this name is returned
Note 2: The layer must be added before
Parameters:
Name Type Description
layerName string Layer's name, which has been provided in the layer description
mode CONTEXT | undefined Context on which the function is applied
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
True when the layer is set as background otherwise False
Type
boolean

setBackgroundLayerByID(layerID, mode)

Sets the background layer by ID according to the context.
When no context is specified, then the function is applied on the selected context. Note: The layer must be added before
Parameters:
Name Type Description
layerID string Unique layer identifier.
mode CONTEXT | undefined Context on which the function is applied.
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
True when the layer is set as background otherwise False
Type
boolean

setBaseElevation(layerName, mode)

Sets the base elevation by its layer's name according to the context.
When no context is specified, then the function is applied on the selected context. Note: The layer must be added before
Parameters:
Name Type Description
layerName string Name of the layer
mode CONTEXT | undefined Context on which the function is applied
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Returns:
True when the base elevation is set otherwise false
Type
boolean

searchOnLayerDescription(query, mode)

Looks through each value in the list according to the context, returning an array of all the values that match the query.
The query is performed on the name and the description of each layer.
When no context is specified, the function is applied on the selected context.
Parameters:
Name Type Description
query string query on the layer'name or description
mode CONTEXT | undefined Context on which the query is run.
See:
Returns:
Type
Array.<Layer>

searchSkyLayer(query)

Looks through each value in the sky layers, returning an array of all the values that match the query.
The query is performed on the name and the description of each layer
Parameters:
Name Type Description
query string query on the layer'name or description
Returns:
An array of layers matching the constraint
Type
Array.<Layer>

searchPlanetLayer(query)

Looks through each value in the planets layers, returning an array of all the values that match the query.
The query is performed on the name and the description of each layer
Parameters:
Name Type Description
query string query on the layer'name or description
Returns:
An array of layers matching the constraint
Type
Array.<Layer>

registerNoStandardDataProvider(type, loadFunc, mode)

Registers no standard data provider in a predefined context.
When no context is specified, the function is applied to the selected context.
Parameters:
Name Type Description
type string data provider key
loadFunc function Function to convert the data
mode CONTEXT | undefined Context
See:
Throws:
Will throw an error when the mode is not part of CONTEXT
Type
RangeError
Example

Registers planets on the sky

var planetProvider = ProviderFactory.create(Mizar.PROVIDER.Planet);
  this.registerNoStandardDataProvider("planets", planetProvider.loadFiles);

createStats(options)

Creates and get Stats Object
Parameters:
Name Type Description
options Object Configuration properties for stats. See Stats for options
Returns:
Type
Stats

render()

Renders the canvas.

dispose()

Disposes the Mizar's contexts (planet and sky)

destroy()

Destroys Mizar

Type Definitions


inputParameters

Input Mizar parameters
Type:
  • Object
Properties:
Name Type Argument Description
canvas Object | string div ID or div element
configuration Mizar.inputConfiguration <optional>
Mizar global configuration
skyContext AbstractContext.skyContext <optional>
Sky context configuration
planetContext AbstractContext.planetContext <optional>
Planet context configuration

parameters

Mizar parameters
Type:
  • Object
Properties:
Name Type Argument Description
canvas Object | string div ID or div element
configuration Mizar.configuration <optional>
Mizar global configuration
skyContext AbstractContext.skyContext <optional>
Sky context configuration
planetContext AbstractContext.planetContext <optional>
Planet context configuration

inputConfiguration

Mizar configuration
Type:
  • Object
Properties:
Name Type Argument Default Description
mizarBaseUrl string <optional>
Used to access to MizarWidget resources
debug boolean <optional>
false Debug mode
isMobile boolean <optional>
false Mobile support
positionTracker AbstractTracker.position_configuration <optional>
Position tracker configuration
elevationTracker AbstractTracker.elevation_configuration <optional>
Elevation tracker configuration
registry Object <optional>
Hips service registry
Properties
Name Type Description
hips string Hips Registry

configuration

Mizar configuration
Type:
Properties:
Name Type Description
mizarAPIUrl string URL of this script, used to reference shaders and CSS of Mizar API