<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[3D - 3D Art with Random Boxes (Difficulty: 2)]]></title><description><![CDATA[<p dir="auto"> </p>
<h2><a class="anchor-offset" name="key-topics-covered"></a>Key Topics Covered</h2>
<ul>
<li><a href="/topic/14/adding-boxes-to-a-3d-scene">Using boxes</a></li>
<li><a href="/topic/491/the-pick-random-block">Picking a random number</a></li>
<li><a href="/topic/20/3d-coordinates-and-positions">3D coordinates and positions</a></li>
<li><a href="/topic/103/working-with-colors">Working with colors</a></li>
<li><a href="/topic/491/the-pick-random-block">Picking a random number</a></li>
</ul>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="introduction"></a>Introduction</h2>
<p dir="auto">In this tutorial, you will build a 3D world using a lot of boxes, and you will learn how to make use of randomness in creating 3D art.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/21dcb7ca-3e41-4b16-9d2a-3ca5c386fbce.gif" width="510" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-1-create-a-new-project"></a>Step 1 - Create a New Project</h2>
<p dir="auto">First, please create a new project on the CreatiCode playground, remove Sprite1, and add the following blocks to the Empty1 sprite:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b7539842-17c9-4a93-859a-63b92c93576d.png" width="400" /><br />
 <br />
An empty 3D scene will be created.</p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-2-add-10-boxes-repeatedly"></a>Step 2 - Add 10 Boxes Repeatedly</h2>
<p dir="auto">Next, let’s use a repeat loop to add 10 boxes. You can pick any color for the boxes.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f805fb7c-abfe-43e9-b5dd-18612fa6c086.png" width="550" /><br />
 <br />
Note that since the boxes are all overlapping, it would appear you only have one box:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7b7ca040-9fd4-46a7-a35e-efb896d7e66c.gif" width="480" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-3-move-boxes-to-random-positions"></a>Step 3 - Move Boxes to Random Positions</h2>
<p dir="auto">To separate the boxes, we can <a href="/topic/20/3d-coordinates-and-positions">move them to random X/Y/Z positions</a>, using the “<a href="https://www.forum.creaticode.com/topic/491/the-pick-random-block" target="_blank" rel="noopener noreferrer nofollow ugc">pick random</a>” block.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1b173c75-dfd9-4f90-8da1-a40943e16fb7.png" width="1100" /><br />
 <br />
The value of the X position of each box will be a random number between -300 and 300, and the same for the Y and Z positions:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/62924281-a1fb-49ea-b61d-796d8477ab50.gif" width="480" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-4-random-box-shapes"></a>Step 4 - Random Box Shapes</h2>
<p dir="auto">Next, let’s change each box to a random shape. Since the shape of a box is controlled by its width/height/depth, we can set all 3 numbers randomly.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/fe2687e6-fbcd-456f-8615-b970e5fbdb9e.png" width="1000" /><br />
 <br />
Note that the size of the box should not be negative in any dimension, so we are making them random numbers between 10 and 100.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/3ef4e839-0ba6-4028-b4b1-3e3654133b33.gif" width="490" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-5-random-box-colors"></a>Step 5 - Random Box Colors</h2>
<p dir="auto">Now let’s make the box colors random as well. To do that, we can not use the color picker dropdown to set the color. Instead, we need to use the <a href="/topic/103/working-with-colors">color calculator block</a>. In this example, we’ll make the color and saturation random, and keep the brightness at 100.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/c9e39e04-25ed-4742-80f7-4dcb562c9f8d.gif" width="1000" /><br />
 <br />
As a result, every time we would get boxes of different colors. Since we are setting the “color” value to be random between 1 and 30, the resulting colors will be randomly selected between red and green.</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/83db3308-507e-493c-b9e5-73e6f675a86a.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-6-more-boxes"></a>Step 6 - More Boxes</h2>
<p dir="auto">Now let’s try to use more boxes, and expand the range of colors and position values:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/6ba60339-0864-45cb-918d-855757a8146a.png" width="1000" /><br />
 <br />
You’ll find the result more interesting, but it will also take longer to run:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/bbe4bf2f-bef1-4923-837d-05ab8545e807.gif" width="490" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-7-speed-up"></a>Step 7 - Speed Up</h2>
<p dir="auto">To speed up the program, a very common solution is to avoid screen refreshes: instead of updating the computer screen after adding each box, we can just wait until all boxes are added, then refresh the screen only once.</p>
<p dir="auto">To do that, make a new block called “add boxes”, and check “Run without screen refresh”:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/9dc29af0-fa23-4e98-ab8b-cf2449bd8f25.png" width="700" style="border-radius:5px;border:1px solid #29622d" /><br />
 <br />
Next, move the repeat loop into the definition of “add boxes”:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/54e3a81f-8abd-4176-b528-2890e260d4f4.png" width="700" /><br />
 <br />
Now our program will run at least 10 times faster!</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a701671d-7c3e-46ac-83fa-d85f4500b296.gif" width="500" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="step-8-set-a-sky-background"></a>Step 8 - Set a Sky Background</h2>
<p dir="auto">Lastly, to make our scene look really nice, we can add a star-like sky. Note that we would also need to move the camera closer after setting the sky to a starfield:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1223499b-5bc9-420b-a908-f96e7b35ee35.png" width="400" /></p>
<p dir="auto"> <br />
And here is the final demo:</p>
<p dir="auto"><img src="https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/21dcb7ca-3e41-4b16-9d2a-3ca5c386fbce.gif" width="510" style="border-radius:5px;border:1px solid #29622d" /></p>
<p dir="auto"> <br />
 </p>
<h2><a class="anchor-offset" name="next-steps"></a>Next Steps</h2>
<p dir="auto">Try to apply the new techniques you learned to build some new artwork. Here are some ideas:</p>
<ul>
<li><strong>Different Shapes</strong>: instead of using only boxes, why not try other shapes?</li>
<li><strong>Different Angles</strong>: you can rotate the shapes randomly as well, right?</li>
<li><strong>Shapes on the ground</strong>: you can try to place the shapes all on the ground, such as on the gra*s land.</li>
</ul>
]]></description><link>https://forum.creaticode.com/topic/573/3d-3d-art-with-random-boxes-difficulty-2</link><generator>RSS for Node</generator><lastBuildDate>Fri, 09 Oct 2026 10:51:39 GMT</lastBuildDate><atom:link href="https://forum.creaticode.com/topic/573.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Sep 2022 03:44:36 GMT</pubDate><ttl>60</ttl></channel></rss>