Factory Building 3D


Play it here: TurboWarp | Scratch


A textured 3D demo project inspired by the abandoned Hartsville Nuclear Plant and the game Infra.

WASD to move. Arrows or mouse (click and drag) to look around.
1,2,3,4,5,6,7 keys to choose resolution.


Adding your own model

Note: This project is now succeeded by TM3D and NPP3D. I recommend using them instead. They are designed to be more usable by others and come with a lot more features. FB3D is extremely limiting and also has many issues of its own (the tri filler for example has bugs).

Download the Blender file (useful to see how it's done): FB3D.blend

You first need 2 things:

A 3D model in .obj file format. Software doesn't matter, it's only the data within that file which does. I do not provide tutorials for other software. The faces should have UV data. For performance reasons you can split up the model into multiple objects. Name them 1, 2, 3, etc. (I used 4 in my factory, if you go to free cam and clip outside, you'll see each section load in/out as you move about).

A texture. You should have one RGB 8-bit-per-channel image for the entire model. It provides all the colour data, no modifications are made within scratch including lighting so you will have to use 3D software to bake the lighting into it. The image can be any size but note the limitation of scratch's lists being 200,000 items. That's why my texture is 440x440. This texture should be in a format made for scratch - simply a list of numbers starting from the bottom left and going to the right for each row. I use my image editor project to generate this from a BMP file but other people have other methods.

With those 2 files you can then put them into this project.

There's a sprite for importing .obj and the main thing you need to do there is import the data into the list with each item being a line of that file (it's just text). Look at mine to get an idea if you don't know. The texture data can be imported to a list in the project too. Note that the format expects each item to be a base-10 conversion of hexadecimal RGB (so essentially the numbers 0-16777215). There are some blocks and scripts in that same texture sprite that you may need to run to compress the image and store in a variable. The way I have it set up is the texture gets decompressed when the project starts as it is a bit too big to save (load texture broadcast). Note that you also need to change the texture size variables to match the dimensions of your texture.

Additionally you probably want collisions and for that you need an extra .obj file. It should contain the 3D floor composed of triangles, and the walls, just a bunch of line segments (the project ignores the line segment z axis and calculates collision in 2D like my golf game). Import it into the physics sprite in the same way as the visible model.

Finally there are a few adjustments to make in Scratch. Manually edit the room bounding box list to correctly contain the "rooms" (the separate sections of the visible mesh as mentioned above). This list determines which rooms should be visible based on the camera's position. Display the room if the camera is in its bounding box. The list expects a room number followed by 2 sets of x,y coordinates (bottom left, top right). Then see the other sprites and make changes as needed, for example the sound emitters, footstep sound locations, and the start point of the camera.


What have people said about the project?

According to commenters, the project looks like...