.. default-domain:: js .. highlight:: js .. module:: Drawing :no-index: Service ======= .. module:: Drawing 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. .. function:: addLine(start, end, referenceFrame[, visible]) Draw a line in the scene. :param start: Position of the start of the line. :type start: ``[number, number, number]`` :param end: Position of the end of the line. :type end: ``[number, number, number]`` :param referenceFrame: Reference frame that the positions are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the line is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Line` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addDirection(direction, referenceFrame[, length[, visible]]) Draw a direction vector in the scene, starting from the origin of the given reference frame. :param direction: Direction to draw the line in. :type direction: ``[number, number, number]`` :param referenceFrame: Reference frame that the direction is in and defines the start position. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param length: The length of the line. Defaults to ``1e+01``. :type length: ``number`` :param visible: Whether the line is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Line` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addDirectionFromCom(direction, referenceFrame[, length[, visible]]) Draw a direction vector in the scene, from the center of mass of the active vessel. :param direction: Direction to draw the line in. :type direction: ``[number, number, number]`` :param referenceFrame: Reference frame that the direction is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param length: The length of the line. Defaults to ``1e+01``. :type length: ``number`` :param visible: Whether the line is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Line` :Game Scenes: Flight .. function:: addAxes(referenceFrame[, length[, visible]]) Draw the axes of a reference frame in the scene, as arrows from its origin. :param referenceFrame: The reference frame. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param length: The length of each axis. Defaults to ``1e+01``. :type length: ``number`` :param visible: Whether the axes are visible. Defaults to ``true``. :type visible: ``boolean`` :returns: The lines for the x, y and z axes, colored red, green and blue. :rtype: ``Array`` of :class:`Drawing.Line` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addPolygon(vertices, referenceFrame[, visible]) Draw a polygon in the scene, defined by a list of vertices. :param vertices: Vertices of the polygon. :type vertices: ``Array`` of ``[number, number, number]`` :param referenceFrame: Reference frame that the vertices are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the polygon is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Polygon` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addPolyline(vertices, referenceFrame[, visible]) Draw an open line through a list of vertices in the scene. :param vertices: Vertices of the line. :type vertices: ``Array`` of ``[number, number, number]`` :param referenceFrame: Reference frame that the vertices are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the line is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Polyline` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addCircle(center, normal, radius, referenceFrame[, visible]) Draw a circle in the scene. :param center: Position of the center of the circle. :type center: ``[number, number, number]`` :param normal: Normal of the plane of the circle. :type normal: ``[number, number, number]`` :param radius: Radius of the circle, in meters. :type radius: ``number`` :param referenceFrame: Reference frame that the position and normal are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the circle is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Circle` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. note:: Throws an exception if the normal is zero. .. function:: addArc(center, normal, startDirection, angle, radius, referenceFrame[, visible]) Draw an arc of a circle in the scene. :param center: Position of the center of the arc. :type center: ``[number, number, number]`` :param normal: Normal of the plane of the arc. :type normal: ``[number, number, number]`` :param startDirection: Direction from the center to the start of the arc. :type startDirection: ``[number, number, number]`` :param angle: Angle of the arc, in radians. :type angle: ``number`` :param radius: Radius of the arc, in meters. :type radius: ``number`` :param referenceFrame: Reference frame that the position and directions are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the arc is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Arc` :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. .. function:: addOrbit(orbit[, visible]) Draw the path of an orbit in the scene. :param orbit: The orbit. :type orbit: :class:`SpaceCenter.Orbit` :param visible: Whether the path is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.OrbitPath` :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. .. function:: addPoint(position, referenceFrame[, visible]) Draw a point in the scene, as a dot that keeps its size on screen. :param position: Position of the point. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame that the position is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the point is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Point` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addBox(center, size, referenceFrame[, rotation[, visible]]) Draw the edges of a box in the scene. :param center: Position of the center of the box. :type center: ``[number, number, number]`` :param size: Lengths of the sides of the box along its x, y and z axes, in meters. :type size: ``[number, number, number]`` :param referenceFrame: Reference frame that the position and rotation are in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param rotation: Rotation of the box, as a quaternion. Defaults to ``[0.0, 0.0, 0.0, 1.0]``. :type rotation: ``[number, number, number, number]`` :param visible: Whether the box is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Box` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addSphere(center, radius, referenceFrame[, visible]) Draw a solid sphere in the scene. :param center: Position of the center of the sphere. :type center: ``[number, number, number]`` :param radius: Radius of the sphere, in meters. :type radius: ``number`` :param referenceFrame: Reference frame that the position is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the sphere is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Sphere` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addText(text, referenceFrame, position, rotation[, visible]) Draw text in the scene. :param text: The string to draw. :type text: ``string`` :param referenceFrame: Reference frame that the text position is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param position: Position of the text. :type position: ``[number, number, number]`` :param rotation: Rotation of the text, as a quaternion. :type rotation: ``[number, number, number, number]`` :param visible: Whether the text is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.Text` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. function:: addNavballMarker(direction, referenceFrame[, visible]) Draw a marker on the navball, pointing in the given direction. :param direction: Direction that the marker points in. :type direction: ``[number, number, number]`` :param referenceFrame: Reference frame that the direction is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param visible: Whether the marker is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.NavballMarker` :Game Scenes: Flight .. function:: addMapMarker(position, referenceFrame[, icon[, caption[, visible]]]) Draw a marker in the map view, with one of the game's own map icons. :param position: Position of the marker. :type position: ``[number, number, number]`` :param referenceFrame: Reference frame that the position is in. :type referenceFrame: :class:`SpaceCenter.ReferenceFrame` :param icon: The icon that the marker is drawn with. Defaults to ``Drawing.MapMarkerIcon.generic``. :type icon: :class:`Drawing.MapMarkerIcon` :param caption: The caption shown when the mouse is over the marker. Defaults to ``""``. :type caption: ``string`` :param visible: Whether the marker is visible. Defaults to ``true``. :type visible: ``boolean`` :rtype: :class:`Drawing.MapMarker` :Game Scenes: Flight, Tracking Station .. function:: 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. :param data: The contents of the image file. :type data: ``Uint8Array`` :rtype: :class:`Drawing.Image` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph .. note:: Throws an exception if the data is not a PNG or JPEG image. .. function:: clear([clientOnly]) Remove all objects being drawn. :param clientOnly: If true, only remove objects created by the calling client. Defaults to ``false``. :type clientOnly: ``boolean`` :Game Scenes: Flight, Tracking Station, Editor Vab, Editor Sph