From Test-Scratch-Wiki

A 3D project made in Scratch.
File:3D Game.png
The rendering of a 3D landscape in a PC game from 2005.
The rendering of a 3D world in a recent 2014 video game called Middle Earth: Shadow of Mordor.

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 积木 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 积木.

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. One of these methods is a basic raycaster.

Difference in the Third-Dimension

When computers render graphics, mainly the graphics processing unit, rendering a 3D object, landscape, or environment takes a lot more processing power than a 2D environment. This is because 3D graphics take up space (not as in storage space but the geometric property) while a 2D environment takes up a plane. Space has depth, so the processor has to perform various algorithms to create the illusion of a 3D environment on a 2D screen. Due to these algorithms and larger objects needed to render, 3D 专案 on Scratch typically lag more than 2D games.

In addition, many 2D graphics are pre-rendered meaning the instructions for how to create the graphics were already carried out or pre-coded rather than the graphics card having to render the graphics anew. Rendering is the process of creating an array of coloured pixels based on a set of instructions, such as in Scratch's 向量图形. Displaying is taking what was rendered and sending it off to a monitor to be seen. Because 2D graphics are seen from one perspective, they can be pre-rendered as bitmap images, but 3D graphics can be viewed at thousands of different angles and must follow instructions for rendering the graphics. One of the common instruction engines used to render 3D graphics is DirectX, which is found on the Windows operating system.

Screenshot from a 1996 3D game, Sonic 3D Blast. Look at how it's different from the images above.

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. This complex technique is usually used in films and TV shows using computer-generated imagery (CGI).


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


File:Shadow model.png
An example of a model, which is the Shadow the Hedgehog model taken from Sonic Generations

While no projects using this method could be found, it is technically possible in Scratch. Rasterization is the technique of using a number of polygons to make up an image, then using a form of ray tracing to render them. First, one starts with a list of vertices making up polygons. Then, drawing a straight line from each vertex to the camera, and coloring in the area of the polygon, one can construct an image. This method is usually the method of choice for most real-time games, for its speed and relative photorealism.

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 类游戏 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 画笔类积木.

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.

Perspective is usually used, but there are simpler projections, such as the orthographic projections, that are also used. It can be built using trigonometry and the perspective formula or with quaternions.

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 [[Eng:#3D Projection|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).


—3d using non-rotating method)

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

This method is done by using images of a 3D model in different poses and setting them for use in a 2D game. This is extremely easy and can be used by inexperienced users.



This method was invented by The2000. It uses 2-dimensional images cloned. They first clones are made at the bottom and the main sprite slowly moves upwards and in any horizontal position. The size and brightness of the sprite increases as well. The brightness starts at -100, but slowly goes up. The size starts at 100, and goes up as well. The method is very simple and can be used by average users.



Some users want a 3D editor to be implemented into Scratch. The Scratch Team has rejected this suggestion, stating that it would make Scratch confusing for beginners.[5] Some users argue the point, saying that to make it less confusing, it could be restricted to only Scratchers,[6] or saying that there could be two separate editors,[7] but the suggestion remains rejected.[5]

2.5D projects

2.5D projects are projects which use 2D graphics in 3D-like environments. They are less laggier and easier to create then 3D projects. Methods include 分身, stamping, and mouse locating. This term also applies to projects in which use 3D models but use them in 2D way.[8]




Cookies help us deliver our services. By using our services, you agree to our use of cookies.