Home Reference Source
import {SpaceObject} from 'spacekit/src/SpaceObject.js'
public class | source

SpaceObject

Direct Subclass:

RotatingObject

Indirect Subclass:

ShapeObject, SphereObject

An object that can be added to a visualization.

Example:

const myObject = viz.addObject('planet1', {
  position: [0, 0, 0],
  scale: [1, 1, 1],
  particleSize: 5,
  labelText: 'My object',
  labelUrl: 'http://...',
  hideOrbit: false,
  ephem: new Spacekit.Ephem({...}),
  textureUrl: '/path/to/spriteTexture.png',
  basePath: '/base',
  ecliptic: {
    lineColor: 0xCCCCCC,
    displayLines: false,
  },
  theme: {
    color: 0xFFFFFF,
    orbitColor: 0x888888,
  },
});

Constructor Summary

Public Constructor
public

constructor(id: String, options: Object, contextOrSimulation: Object, autoInit: boolean)

Method Summary

Public Methods
public

get3jsObjects(): Array<THREE.Object>

Gets the THREE.js objects that represent this SpaceObject.

public

getBoundingObject(): THREE.Object3D

Specifies the object that is used to compute the bounding box.

public

Gets the color of this object.

public

Gets the unique ID of this object.

public

Gets label visilibity status.

public

Gets the {Orbit} object for this SpaceObject.

public

Gets the visualization coordinates of this object at a given time.

public

Initializes label and three.js objects.

public

Determines whether object is ready to be measured or added to scene.

public

Determines whether object is static (can't change its position) or whether its position can be updated (ie, it has ephemeris)

public

orbitAround(spaceObj: Object)

Make this object orbit another orbit.

public

Toggle the visilibity of the label.

public

Updates the position of this object.

public

update(jd: Number)

Updates the object and its label positions for a given time.

Public Constructors

public constructor(id: String, options: Object, contextOrSimulation: Object, autoInit: boolean) source

Params:

NameTypeAttributeDescription
id String

Unique id of this object

options Object

Options container

options.position Array<Number>

[X, Y, Z] heliocentric coordinates of object. Defaults to [0, 0, 0]

options.scale Array<Number>

Scale of object on each [X, Y, Z] axis. Defaults to [1, 1, 1]

options.particleSize Number

Size of particle if this object is a Kepler object being represented as a particle.

options.labelText String

Text label to display above object (set undefined for no label)

options.labelUrl String

Label becomes a link that goes to this url.

options.hideOrbit boolean

If true, don't show an orbital ellipse. Defaults false.

options.ephem Ephem

Ephemerides for this orbit

options.textureUrl String

Texture for sprite

options.basePath String

Base path for simulation assets and data

options.ecliptic Object

Contains settings related to ecliptic

options.ecliptic.lineColor Number

Hex color of lines that run perpendicular to ecliptic. @see Orbit

options.ecliptic.displayLines boolean

Whether to show ecliptic lines. Defaults false.

options.theme Object

Contains settings related to appearance of orbit

options.theme.color Number

Hex color of the object, if applicable

options.theme.orbitColor Number

Hex color of the orbit

contextOrSimulation Object

Simulation context or simulation object

autoInit boolean

Automatically initialize this object. If false you must call init() manually.

Public Methods

public get3jsObjects(): Array<THREE.Object> source

Gets the THREE.js objects that represent this SpaceObject. The first object returned is the primary object. Other objects may be returned, such as rings, ellipses, etc.

Return:

Array<THREE.Object>

A list of THREE.js objects

public getBoundingObject(): THREE.Object3D source

Specifies the object that is used to compute the bounding box. By default, this will be the first THREE.js object in this class's list of objects.

Return:

THREE.Object3D

THREE.js object

public getColor(): Number source

Gets the color of this object. Usually this corresponds to the color of the dot representing the object as well as its orbit.

Return:

Number

A hexidecimal color value, e.g. 0xFFFFFF

public getId(): String source

Gets the unique ID of this object.

Return:

String

Unique ID

public getLabelVisibility(): boolean source

Gets label visilibity status.

Return:

boolean

Whether label is visible.

public getOrbit(): Orbit source

Gets the {Orbit} object for this SpaceObject.

Return:

Orbit

Orbit object

public getPosition(jd: Number): Array<Number> source

Gets the visualization coordinates of this object at a given time.

Params:

NameTypeAttributeDescription
jd Number

JD date

Return:

Array<Number>

[X, Y,Z] coordinates

public init(): boolean source

Initializes label and three.js objects. Called automatically unless you've set autoInit to false in constructor (this init is suppressed by some child classes).

Return:

boolean

public isReady(): boolean source

Determines whether object is ready to be measured or added to scene.

Return:

boolean

True if ready

public isStaticObject(): boolean source

Determines whether object is static (can't change its position) or whether its position can be updated (ie, it has ephemeris)

Return:

boolean

Whether this object can change its position.

public orbitAround(spaceObj: Object) source

Make this object orbit another orbit.

Params:

NameTypeAttributeDescription
spaceObj Object

The SpaceObject that will serve as the origin of this object's orbit.

public setLabelVisibility(val: boolean) source

Toggle the visilibity of the label.

Params:

NameTypeAttributeDescription
val boolean

Whether to show or hide.

public setPosition(x: Number, y: Number, z: Number) source

Updates the position of this object. Applicable only if this object is a sprite and not a particle type.

Params:

NameTypeAttributeDescription
x Number

X position

y Number

Y position

z Number

Z position

public update(jd: Number) source

Updates the object and its label positions for a given time.

Params:

NameTypeAttributeDescription
jd Number

JD date