Revision as of 23:58, 9 May 2013 by Lucario621 (talk | contribs) (3D Projection: Added a tutorial)

Three Dimensional or 3D can refer to "something having three dimensions e.g. width, length, and depth or x, y, and z."[1]

Scratch does not provide tools for displaying, creating or manipulating 3D graphics; however, Scratch does provide blocks for 2D (x,y) sprite movement, sprite resizing, pen drawing, math functions, lists and more. Many (if not all) 3D methods can be recreated with Scratch blocks.

Creating the illusion of 3D in Scratch can be a large challenge, requiring advanced algorithms or 3D programs; there are also simpler methods, making it easy for anyone to start playing with 3D in Scratch.

3D Methods Used in Scratch

There are many Scratch projects that use one or more of following methods to display 3D graphics. These methods are in order of difficulty. Examples are in order of creation.

Ray Tracing

"In computer graphics, ray tracing is a technique for generating an image by tracing the path of light through pixels in an image plane and simulating the effects of its encounters with virtual objects."[2]

This is a very slow technique (and even slower in Scratch) but recreates natural effects like reflection, shading and shadows.


(Canthiar also created a set tutorial projects that explain the ray tracer math.)

Ray casting

"Ray casting ... can be thought of as an abridged, and significantly faster, version of the ray tracing algorithm." [3]

This method was used in early 3D games like Wolfenstein 3D to get fast, real-time performance out of slow computers.


3D Projection

"3D projection is any method of mapping three-dimensional points to a two-dimensional plane."[4]

3D projection allows projects to define an x,y,z location for a sprite, then place it on the screen. This method has been used to draw 3D objects using lists and the pen block.

Sprites can be resized based on the distance from the camera/viewer. This method can work very fast in Scratch, making it more ideal for games.

Lines can also be drawn between the projected points to create wireframe 3D renderings.

3D Projection Example


(RHY3756547 created a tutorial project that explains 3D projection math.)

Exporting from 3D Programs

Creating a 3D Object in a 3D Graphics Program, then saving it as a Wavefront (.obj) file. The lines and vertices are taken from the object file, and imported into 2 lists.

For every pair of number in the lines list, it will use the respective X, Y, and Z variables and draws a line using 3D projection (see above).

The camera is rotatable according to the mouse x and y.

Although the script is complicated, some users have just provided the script and allowed anyone to change the list values to get their object.


Pre-rendered Graphics

Images created with 3D programs like Blender or Google SketchUp are imported as costumes in a sprite. Costumes portraying different angles of the object are switched quickly to make the object appear to rotate.


Sliced 3D method

Main article: Animating a 3D Object

This is the 2nd simplest method in Scratch. It works by stacking or stamping 2D sprites, starting from the bottom up, offset up slightly for each layer. This set of drawings can be rotated to rotate the 3D object. As well as changing Y to make this image you can use change the X of an sprite and be able to give it a "flip" effect instead of a rotating one. It uses the same idea as the "Y" stamping.


Non-rotating Method

This is the simplest method in Scratch. It works by using size for the z position and does not rotate. It has an illusion that makes the sprites look like they are rotating but they are not. When a sprite touches 1 side, it goes to the other side (not touching it) and if a sprite touches the other side, it goes to the first side (again, not touching it).


Stamping Method

Use the stamping block found in the pen section, you must stamp the sprite in a certain way depending on the location of the sprite, in relation to the center of the project stage.


3D Models Only

Using a top-down approach as seen by 30bla30 in his project Dogfighting Scratchers-Flying Ace, and in his unreleased game, Scratch Theft Auto. The game is not 3-dimensional, but the models are. This method is extremely easy to use.



  1. Wikipedia:3D
  2. Wikipedia:Ray tracing (graphics)
  3. Wikipedia:Ray casting
  4. Wikipedia:3D projection

See Also