Big Bad Beetle Blocks
A Scratch-like language for 3D
ByBeetle Blocks is an interesting twist on the “block-building programming language” idea. Instead of a flat, boring plane, you move a beetle around 3D space, drawing cubes, spheres and all sorts of other shapes.
Beetle Blocks [1] lets you build 3D objects by ordering the Beetle Blocks beetle around. You do this in true Scratch-like fashion by dropping blocks containing commands such as move
, go to
and rotate
onto the workspace. You can then chain several blocks together to build programs, just like in any block-based program (Figure 1).
The difference here is that with Beetle Blocks everything happens in 3D. In Scratch, for instance, you can turn the kitty sprite on only one axis only – it's yaw axis (see Figure 2 on the next page). In Beetle Blocks on the other hand you can rotate the beetle, three axes, on its yaw, pitch and roll axes, using a block like this:
Likewise, while you only needed two coordinates, x and y, to place your sprites in Scratch, Beetle Blocks needs three to position your beetle: x, y and z.
You can also decide to draw lines and curves, or extrude them. This in practice means that as the beetle walks it you can have it leave a 3D sausage-like trail behind it.
Beetle Pi
Despite what the main website says, Beetle Blocks works fine in Firefox. Sadly, it does not work in the Pi's default browser Chromium ; the editor site won't even load. So, if you haven't got it yet, go grab yourself Firefox for your Pi with the command:
sudo apt-get install firefox-esr
Firefox will install in the Internet submenu. Open it and go to the online editor [2].
Wait for the interface to completely appear, including the little picture of the cyan-colored beetle, before you start working. Otherwise, the interface may freeze for a few seconds.
Dragging and dropping blocks onto the workspace is generally fine on a Raspberry Pi 3, although sometimes it can be sluggish. Performance is better if you use openSUSE (included in this month's DVD) instead of Raspbian. This may be because openSUSE, being a true 64-bit operating system, makes the most of the Pi's hardware.
If you want to work offline, you can download all the Beetle Blocks framework from the project's GitHub with:
git clone https://github.com/ericrosenbaum/BeetleBlocks
Open Firefox, press [Ctrl]+[O], and navigate to the directory where you downloaded Beetle Blocks. Inside the run/ subdirectory, click on the index.html file, and a local editor will open in your browser.
Beetle Server
Beetle Blocks is written in pure JavaScript, so doesn't need a server or any external dependencies to run. However, if you want other people such as students in your classroom to access the Beetle Blocks web page, you can run your own basic web server locally.
The web server lighttpd is a good choice since, as it's name suggests, it's very light and will not overload your Pi. Besides, for serving a bunch of JavaScript it's all you'll really need.
Open a terminal window and type:
$ sudo apt-get install lighttpd
Once installation is complete, the server will launch automatically. You can check by opening Firefox on your Pi and navigating to 127.0.0.1 (or, from another computer, put your Pi's IP into a web browser). If you see something like Figure 3, everything is fine.
Next copy other the contents of Beetle Blocks' run/ subdirectory to a subdirectory under /var/www/html/ like so:
$ sudo mkdir /var/www/html/bb $ cd /download/directory/BeetleBlocks $ sudo cp -Rv run/* /var/www/bb/html/
Now, using a web browser on another computer, go to http://<RPi's IP>/bb (Figure 4).

Most of the code for Beetle Blocks runs in the browser anyway, so loading the program from a Pi for an entire classroom is quite doable.
Basic Shapes
One of the cool things you can do with Beetle Blocks is draw a shape at the beetle's position. Open the Shapes category and drag out…
… then click on it. The beetle will draw a sphere. This may not sound like much, but think of the applications: this is probably the easiest way to draw and visualize 3D objects.
Take for example, the code, in Listing 1. It uses this technique of moving the beetle and drawing an object to generate a complex 3D function. It essentially consists of a loop within a loop, the innermost counts from -10 to 10 for y the position of the beetle.
The outer does the same for the x position. z, the vertical position of the beetle, is the result of multiplying the cosine of y by the sine of x. You then use a go to
block with your x, y and z values to simply draw a sphere.
This generates the rather marvelous-looking 3D graph shown in Figure 5.
The other thing you can do is extrude. This makes the beetle leave a 3D trail as it "walks". The program in Listing 2 shows how to do this and builds the "sausage pyramid" seen in Figure 6.
Your own shapes
Beetle Blocks is based on Snap! [3] and, as we explained in issue 6 [4], this means you can combine blocks to build your own instructions. Right click on an empty region in the central workspace and a menu will pop-up. Choose Make a block and Beetle Blocks will then bring up a wizard which will allow you to create your own by combining several basic blocks. This means you can use the block editor to create more and more complex shapes from basic shapes and embed them in your own blocks to simplify your programs.
At some stage you will want to save your programs permanently to your hard disk. You can do this by clicking on the file icon in the upper toolbar and selecting Download project as…. You can then download your work as an XML file. You can open your program later in any other instance of Beetle Blocks by choosing Import project or blocks from the File menu. The XML file also saves all the custom blocks you may have created for the project.
You can also extract your custom blocks from the project and save them independently to re-use them later in other projects. Click on the File icon at the top of the screen and this time choose Download My Blocks as…. This will open a window showing the custom blocks you created for the project. You can then mark the ones you want to save. Import your blocks into a new project by selecting Importing project and blocks… from the File menu and the navigating to where you saved the XML file containing the blocks.
Another interesting entry within the File menu is the option to export your 3D object as an STL file. Click on File and go to Download 3D model as… and pick STL. STL is quickly becoming the standard file format used to exchange 3D objects between different applications (Figure 7). This has an exciting side effect; whatever you tell the beetle to draw can later be turned into a physical object thanks to the magic of home 3D printing.
Conclusion
Beetle Blocks is fun, easy and 3D. Anyone familiar with Scratch will be able produce complex shapes and visualize 3D functions in minutes. It works well on the Raspberry Pi and you can even get real, physical objects from what you design thanks to its export to STL feature. store.
Info
- Beetle Blocks: http://beetleblocks.com
- Beetle Blocks online editor: http://beetleblocks.com/run/
- Snap!: https://snap.berkeley.edu/
- A Web-based Alternative to Scratch, Issue 6: http://www.raspberry-pi-geek.com/Archive/2014/06/A-web-based-alternative-to-Scratch
next page » 1 2 3
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

News
-
Ubuntu 25.04 Coming Soon
Ubuntu 25.04 (Plucky Puffin) has been given an April release date with many notable updates.
-
Gnome Developers Consider Dropping RPM Support
In a move that might shock a lot of users, the Gnome development team has proposed the idea of going straight up Flatpak.
-
openSUSE Tumbleweed Ditches AppArmor for SELinux
If you're an openSUSE Tumbleweed user, you can expect a major change to the distribution.
-
Plasma 6.3 Now Available
Plasma desktop v6.3 has a couple of pretty nifty tricks up its sleeve.
-
LibreOffice 25.2 Has Arrived
If you've been hoping for a release that offers more UI customizations, you're in for a treat.
-
TuxCare Has a Big AlmaLinux 9 Announcement in Store
TuxCare announced it has successfully completed a Security Technical Implementation Guide for AlmaLinux OS 9.
-
First Release Candidate for Linux Kernel 6.14 Now Available
Linus Torvalds has officially released the first release candidate for kernel 6.14 and it includes over 500,000 lines of modified code, making for a small release.
-
System76 Refreshes Meerkat Mini PC
If you're looking for a small form factor PC powered by Linux, System76 has exactly what you need in the Meerkat mini PC.
-
Gnome 48 Alpha Ready for Testing
The latest Gnome desktop alpha is now available with plenty of new features and improvements.
-
Wine 10 Includes Plenty to Excite Users
With its latest release, Wine has the usual crop of bug fixes and improvements, along with some exciting new features.