A Scratch-like language for 3D

Liudmila Pantelejenkova

Big Bad Beetle Blocks

Beetle 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).

Figure 1: Follow the Beetle Blocks beetle around in 3D space to draw objects.

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:

Figure 2: You can rotate an object on any of these axes in 3D space.

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.

Figure 3: With lighttpd you'll be able to access a local version of Beetle Blocks from anywhere.

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).

Figure 4: You can run Beetle Blocks from a server so several people can make their own 3D designs at the same time.

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.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content