3D Boxes

The Box Tool allows you to draw three-dimensional boxes that remain editable in Inkscape but display normally in other SVG renderers. A box is composed of an SVG Group of six paths. Information about the vanishing points, and so forth are stored in the Inkscape Name Space. This extra information is only used by the Box Tool. All other tools treat the box as a normal Group. The sides of the box can be styled independently (or even deleted).

To draw a 3D box select the Box Tool by clicking on the icon icon (Shift+F4) in the Tool Box. Use a Left Mouse Drag to draw the left side of the box (in the x-y plane). The start of the drag sets one corner while the end of the drag sets the opposite corner. The other sides of the box are automatically drawn with the right side of the box set to a default width. Pressing the Shift while creating the box changes the function of the cursor to defining the depth (width of the right side or z dimension) of the box.

Simple 3D box.
A simple 3D box showing two sides and the box coordinate system. There are an additional four hidden sides.

When a box is selected and the Box Tool active, a variety of handles are displayed. The eight handles at the corners of the box are used to adjust the size of the box. The four in front (see figure below) change the size of the left box face in the x-y plane. The other four change the depth (z) of the box. Holding the Shift down swaps the functions of the handles. With the Ctrl down, the handles are restricted in movement to lines along the box edges or to a box diagonal. This allows adjusting one dimension of a box face while keeping the other fixed in the first case or keeping the aspect ratio fixed in the latter case.

Dragging the Cross handle moves the box while keeping the same perspective. Without a modifier key, the box is kept in the x-y plane. Holding the Ctrl down while dragging limits movement to lines along the box edge or along the box diagonal. Holding down the Shift while dragging moves the box in the z direction.

A 3D box with handles.
A simple 3D box showing showing its handles. Two of the Front Resize handles are labeled. The other two are directly above those. The four remaining handles at the corners of the box are the Back Resize handles. The cross in the middle is use to move the box while keeping the same perspective.

By default, a box is drawn with two vanishing points, one each on the left (x) and right (z) sides. The vanishing points are initially placed at the edge of the page, halfway between the top and bottom. These points are determined when the SVG drawing is first created so resizing the page does not move them. The vanishing points can be dragged to new locations. Dragging the points a ways off the page will probably give you a more satisfactory perspective than the default.

All boxes that share the same vanishing points will change together. If you wish to change the vanishing points of just selected boxes, hold down the Shift while dragging. If multiple boxes are selected with different vanishing points, dragging a vanishing point for one box near that of another box will merge the points together.

A 3D box with handles.
All the boxes share the same vanishing points. The stack was created by duplicating the bottom-center box and then dragging the Move In Perspective handle with the Shift key or Ctrl key. Two moves were required for each box.
A 3D box with handles.
The same boxes as in the previous figure but with both the x and z vanishing points moved up and right.

Perspectives

The Box Tool can be used to draw boxes with 1, 2, and 3-point perspectives as well as a box using an isometric projection. The above examples use a 2-point perspective with two vanishing points. The type of perspective is changed via the Box Tool Tool Controls. Each of the three perspective points (x, y, and z) can be set to infinity or to a specific point. To set or unset a perspective point to infinity, toggle the Parallel Lines button ( icon ) in the Tool Controls next to the appropriate angle (or use the keyboard shortcuts: Shift+X, Shift+Y, and Shift+Z that are available when using the Box Tool). When set to infinity, the direction of a perspective point is set by an Angle parameter. The angles can be changed via the entry boxes in the Tool Controls or by using the keyboard shortcuts: x: [, ]; y: (, ); and z: {, }. The angles will be changed by the Rotation snap angle (15° by default, settable in the Steps section of the Inkscape Preferences dialog). With the Alt key, the angle change will be 0.5°.

The Box Tool Controls.
The Box Tool-Tool Controls, showing the default parameters for a 2-point perspective.

1-point Perspective:  Set the x and y vanishing points to infinity by using the x and y Parallel Line buttons ( icon ) in the Tool Controls. Set Angle X to 180° and Angle Y to 90°. Toggle off the Parallel Line button for z and drag the vanishing point to the desired point (typically near the center of the drawing).

1-Point Perspective.
The boxes have been drawn using a 1-point perspective. The front side of the outer box has been made transparent.

2-point Perspective:  The default perspective. Set the y vanishing point to infinity by toggling on the y Parallel Line button ( icon ) in the Tool Controls. Set Angle Y to 90°. Enable the x and z vanishing points by toggling off their Parallel Line buttons. Drag the x and z vanishing point to the desired points (typically at the same level on opposite sides of the page).

3-point Perspective:  Enable the x, y, and z vanishing points by toggling off their Parallel Line buttons ( icon ) in the Tool Controls. Drag the x, y, and z vanishing points to the desired places. Typically the x and z vanishing points are at the same level on opposite sides of the page. They are either above or below the page depending on if the observer is looking down or up at the scene. The y vanishing point is then on the opposite side, either below or above the page.

3-Point Perspective.
The box has been drawn with a 3-point perspective. The vanishing points have been dragged off the page as indicated by the red, yellow, and blue lines. Dragging the y vanishing point below the others turns the box inside out. The proper perspective can be achieved by changing the z-order of the sides or by swapping the x and z vanishing points.

Isometric Projection:  Boxes can be drawn with an Isometric Projection by toggling on all Parallel Line buttons in the Tool Controls and setting the x, y, and z angles to be: 150°, 90°, and 30°, respectively.

The perspective information is stored in the defs section of the SVG file. Look for the inkscape:perspective tag. With the XML Editor one can precisely place vanishing points. There is a triplet of numbers for each point (e.g., "inkscape:vp_x"). The first two are the x and y coordinates of the vanishing point and the third is a flag to indicate if the perspective lines converge or are parallel.

Attributes

The attributes of the six sides can be changed independently. To select one of the sides, one must use one of the methods of selecting an object in a Group. There is one problem: The common method for entering a Group, namely double-clicking on an object with the Select Tool, won't work as this enables the Box Tool instead. The Group can be entered by selecting the box and using Ctrl+Enter or by selecting the Enter group line from the pop-up menu when you Right Click on the box. Using Ctrl+Left Mouse Click will select a side of the box without entering the Group. Using Ctrl+Alt+Left Mouse Click to select a hidden side.

By default, a box will always be drawn with sides of the same default colors (shades of blue), even after editing the attributes for one side. This behavior can be changed by selecting the Last used style option on the 3D Box page in the Inkscape Preferences dialog. If this option is selected, Inkscape will remember the Fill and Stroke colors independently for each side. Changing the color of one side will change the Current style for all other shapes but the inverse is not true.

[Warning]Nested Boxes

Inkscape does not prevent you from creating a box inside another box Group. This can lead to strange behavior.