Service#
Provides functionality for drawing objects in the flight scene, the map view, the editor and the tracking station.
Note
For drawing and interacting with the user interface, see the UI service. Objects drawn by a client are removed when that client disconnects.
- Drawing.addLine(start, end, referenceFrame[, visible])#
Draw a line in the scene.
- Arguments:
start (
[number, number, number]) – Position of the start of the line.end (
[number, number, number]) – Position of the end of the line.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the positions are in.visible (
boolean) – Whether the line is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addDirection(direction, referenceFrame[, length[, visible]])#
Draw a direction vector in the scene, starting from the origin of the given reference frame.
- Arguments:
direction (
[number, number, number]) – Direction to draw the line in.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the direction is in and defines the start position.length (
number) – The length of the line. Defaults to1e+01.visible (
boolean) – Whether the line is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addDirectionFromCom(direction, referenceFrame[, length[, visible]])#
Draw a direction vector in the scene, from the center of mass of the active vessel.
- Arguments:
direction (
[number, number, number]) – Direction to draw the line in.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the direction is in.length (
number) – The length of the line. Defaults to1e+01.visible (
boolean) – Whether the line is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight
- Drawing.addAxes(referenceFrame[, length[, visible]])#
Draw the axes of a reference frame in the scene, as arrows from its origin.
- Arguments:
referenceFrame (
SpaceCenter.ReferenceFrame) – The reference frame.length (
number) – The length of each axis. Defaults to1e+01.visible (
boolean) – Whether the axes are visible. Defaults totrue.
- Returns:
The lines for the x, y and z axes, colored red, green and blue.
- Return type:
ArrayofDrawing.Line- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addPolygon(vertices, referenceFrame[, visible])#
Draw a polygon in the scene, defined by a list of vertices.
- Arguments:
vertices (
Arrayof[number, number, number]) – Vertices of the polygon.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the vertices are in.visible (
boolean) – Whether the polygon is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addPolyline(vertices, referenceFrame[, visible])#
Draw an open line through a list of vertices in the scene.
- Arguments:
vertices (
Arrayof[number, number, number]) – Vertices of the line.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the vertices are in.visible (
boolean) – Whether the line is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addCircle(center, normal, radius, referenceFrame[, visible])#
Draw a circle in the scene.
- Arguments:
center (
[number, number, number]) – Position of the center of the circle.normal (
[number, number, number]) – Normal of the plane of the circle.radius (
number) – Radius of the circle, in meters.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position and normal are in.visible (
boolean) – Whether the circle is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
Note
Throws an exception if the normal is zero.
- Drawing.addArc(center, normal, startDirection, angle, radius, referenceFrame[, visible])#
Draw an arc of a circle in the scene.
- Arguments:
center (
[number, number, number]) – Position of the center of the arc.normal (
[number, number, number]) – Normal of the plane of the arc.startDirection (
[number, number, number]) – Direction from the center to the start of the arc.angle (
number) – Angle of the arc, in radians.radius (
number) – Radius of the arc, in meters.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position and directions are in.visible (
boolean) – Whether the arc is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
Note
The arc turns counterclockwise about the normal, seen from the side it points to. Throws an exception if the normal is zero, or the start direction is parallel to it.
- Drawing.addOrbit(orbit[, visible])#
Draw the path of an orbit in the scene.
- Arguments:
orbit (
SpaceCenter.Orbit) – The orbit.visible (
boolean) – Whether the path is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station
Note
The path follows the orbit as it changes, and ends where the orbit leaves the sphere of influence of its body.
- Drawing.addPoint(position, referenceFrame[, visible])#
Draw a point in the scene, as a dot that keeps its size on screen.
- Arguments:
position (
[number, number, number]) – Position of the point.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position is in.visible (
boolean) – Whether the point is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addBox(center, size, referenceFrame[, rotation[, visible]])#
Draw the edges of a box in the scene.
- Arguments:
center (
[number, number, number]) – Position of the center of the box.size (
[number, number, number]) – Lengths of the sides of the box along its x, y and z axes, in meters.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position and rotation are in.rotation (
[number, number, number, number]) – Rotation of the box, as a quaternion. Defaults to[0.0, 0.0, 0.0, 1.0].visible (
boolean) – Whether the box is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addSphere(center, radius, referenceFrame[, visible])#
Draw a solid sphere in the scene.
- Arguments:
center (
[number, number, number]) – Position of the center of the sphere.radius (
number) – Radius of the sphere, in meters.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position is in.visible (
boolean) – Whether the sphere is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
- Drawing.addText(text, referenceFrame, position, rotation[, visible])#
Draw text in the scene.
- Arguments:
text (
string) – The string to draw.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the text position is in.position (
[number, number, number]) – Position of the text.rotation (
[number, number, number, number]) – Rotation of the text, as a quaternion.visible (
boolean) – Whether the text is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
Draw a marker on the navball, pointing in the given direction.
- Arguments:
direction (
[number, number, number]) – Direction that the marker points in.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the direction is in.visible (
boolean) – Whether the marker is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight
- Drawing.addMapMarker(position, referenceFrame[, icon[, caption[, visible]]])#
Draw a marker in the map view, with one of the game’s own map icons.
- Arguments:
position (
[number, number, number]) – Position of the marker.referenceFrame (
SpaceCenter.ReferenceFrame) – Reference frame that the position is in.icon (
Drawing.MapMarkerIcon) – The icon that the marker is drawn with. Defaults toDrawing.MapMarkerIcon.generic.caption (
string) – The caption shown when the mouse is over the marker. Defaults to"".visible (
boolean) – Whether the marker is visible. Defaults totrue.
- Return type:
- Game Scenes:
Flight, Tracking Station
- Drawing.addImage(data)#
Load an image that markers can be drawn with, from the contents of a PNG or JPEG file. The transparency of a PNG image is kept.
- Arguments:
data (
Uint8Array) – The contents of the image file.
- Return type:
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph
Note
Throws an exception if the data is not a PNG or JPEG image.
- Drawing.clear([clientOnly])#
Remove all objects being drawn.
- Arguments:
clientOnly (
boolean) – If true, only remove objects created by the calling client. Defaults tofalse.
- Game Scenes:
Flight, Tracking Station, Editor Vab, Editor Sph