Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • CreatiCode
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

CreatiCode Scratch Forum

  1. CreatiCode Forum
  2. Knowledge Base
  3. Tutorials
  4. 3D - A Painting in a Frame (Difficulty: 2)

3D - A Painting in a Frame (Difficulty: 2)

Scheduled Pinned Locked Moved Tutorials
1 Posts 1 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CreatiCodeI Offline
    CreatiCodeI Offline
    CreatiCode
    wrote on last edited by admin
    #1

     

    Key Topics Covered

    • Initializing 3D scenes
    • Using boxes
    • Updating texture with shared file
    • Updating textures
    • Updating scale
    • Using rectangle tubes
    • 3D text
    • Camera configuration

     
     

    Introduction

    In this tutorial, you will create a program that displays a famous painting in a frame like this, so that the user can appreciate it from different angles and distances:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/81136448-1f03-4efd-8932-95c44541bd06.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 1 - An “Empty” Scene with 3D Axes

    Please create a new project, remove the dog sprite, and add these blocks in the “Empty1” sprite. You can find the “initialize 3D scene” and the “show 3D axis” blocks in the “3D Scene” category.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/43a6f24e-b195-4762-a219-822a46559d96.png" width="400" style="filter: drop-shadow(0.35rem 0.35rem 0.4rem rgba(0, 0, 0, 0.5));">

    As shown, the X-axis points to the right, the Y-axis points forward (into the screen), and the Z-axis points up. You can drag your mouse on the stage to rotate the camera around it:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/dcebc38b-cc87-4eb8-a3f1-6252211315eb.gif" width="460" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 2 - A Flat Box

    We first need to add a big flat box to serve as our “canvas”. It will be a square shape in the X and Z directions (size of 1000 each), but very thin in the Z direction (size of 1). The color won’t matter, since we will paint over the box.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/5b1b6398-964f-482b-bbb6-c23b3c6420a5.png" width="600" style="">

    This is what you’ll get. You need to zoom out the camera to view it.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/042b3ea6-b4ac-47d7-980b-4bb2fe5a39d8.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 3 - Find a Painting Image Online

    Next, you need to find an image online for the painting you would like to show.

    First, open a search engine like Google, and search by the painting’s name or artist. Switch to the “images”, and browse through the list like this:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d6e02450-04c6-4476-ba6b-b2c66a411185.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     
    Once you have picked a painting you like, select it, then right-click on the image preview, and select “copy image address”. This will copy the URL of that image into your computer’s clipboard.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/e160b222-086f-48b3-9879-cea8e9f2fa72.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">

     
    In this tutorial, we are using the following URL for “Wheatfield with Crows” by Van Gogh:

    ,

    Note that in most cases, you can use these images for free only for learning purposes. If you are building a project for commercial use, then you need to get a proper license for using the image.

     
     

    Share an Image Yourself

    Very often, you can find an image online, but it is not easy to get the URL for that image. As an alternative, you can share that image yourself on the CreatiCode platform through these steps:

    1. Download the image file onto your computer.
    2. On the CreatiCode platform, on the “My Stuff” page, click “My Files” on the left
    3. On the new page, click the “+ Share a New File” button on the top right, and select the image file you downloaded, then confirm to upload and share this file
    4. After the image has been shared, find its name in the list of files, and then click the “copy file URL” button below that file name. Now the URL will be stored in your clipboard, and you can proceed to step 4 below

     
     

    Step 4 - Use the Image as a Texture

    Next, let’s use that image as the texture of the box, using the “add texture with shared file” block. Since our box is 1000 by 1000, you need to set the “unit size” of the texture to 1000 as well, so that the image will fit onto the box face exactly. Also, you need to delete the URL in the block’s input, and paste the new URL you copied in step 3.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1750506c-06c1-42df-bc1f-66efe2805e90.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">
     
    Now your box should be covered with the painting you selected:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4000dd86-ed32-407a-81da-746b2dc39b2a.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 5 - Adjust the Height

    Most paintings are not square-shaped. In other words, the ratio between the width and height (called “aspect ratio”) is not 1. We can fix this by scaling the box.

    For this example, the painting’s height is slightly smaller than half of its width. Therefore, we need to scale down the box to 48% in the Z direction like this:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/1b5bf6ba-7a26-441a-90d2-c2aa77c58a0f.png" width="600" style="">
     
    Now the box’s width is still 1000, but its height is only 480. It looks much closer to the original painting now.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/76349880-9dae-4134-af8a-0ddec6d5792a.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 6 - Add a Picture Frame

    Next, let’s add a picture frame around the painting, using a rectangle tube. Suppose the thickness of the frame border is 20, then the 2 borders on the left and right adds 40 units in total. We know the painting itself is 1000 by 480, so the rectangle tube has to be 1040 by 520.

    We also need to rotate the frame, since by default it will face up.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f02422d4-6d58-4bfe-8c91-d010b3f1cf55.png" width="900" style="">
     

    Now we get a frame around the painting:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a5530630-e5f1-47e4-9e49-44c4986fd8f8.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 7 - Apply a Wooden Texture to the Frame

    To make the picture frame look more realistic, we can apply a texture to it, such as “Marble06”. You can also play with the texture size to get different visual effects. For example, if we use a texture size of 3000, the texture image will be more stretched out.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/042af8f7-e5c6-43ea-98d7-c3c47d0aa014.png" width="900" style="">
     

    This is how it looks after applying the texture:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2a0b1ec5-3bb5-4c8e-8c23-ce33a54f9f99.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 8 - Add the Description

    We can add a description that includes the painting’s name and artist, using a 3D text object. Its width should roughly match the width of the painting, which is 1000. Also, the description needs to be moved below the painting. Since the height of the painting is 480, the bottom edge of it would be at a Z-position of -240. Also, the frame border is 20, so the text needs to be below the Z-position of -260.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/815f47ac-efab-4d80-adf9-2c331e8a68ce.png" width="1000" style="">
     
    The description will look like this:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/b74091ed-cf80-46c9-975c-64cfd41bb5fe.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 9 - Move the Camera to the Front

    Since the description is facing the front direction (positive Y direction), we need to rotate the text by 180 degrees, or move the camera to the front. In this case, it is better to move the camera, since we need to move the camera to a good view distance to show the entire painting as well.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4ae64bb7-2eea-43ec-bd01-632d9205e378.png" width="700" style="">
     
    Now the user gets a good view of the painting when they click the green flag, no need to rotate or zoom the camera:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/bfd46dc1-11b4-4225-962e-76d11dc080c0.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 10 - A Starfield Background

    To enhance the viewing experience, we can add a beautiful background, using the “set sky” block. It should be inserted at the beginning of the program, since it will take some time to load the background image, and setting the sky would move the camera further away as well.

    Also, it’s a good time to hide the 3D axis now as we are mostly done with the development:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/2f6ccb39-919c-4dd4-8adb-345887668379.png" width="400" style="">
     
    Now we get a good background that also changes as we move the camera.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/d97ac97b-8d50-4f9b-b88a-39eb0e2bff39.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 11 - Camera Animation

    To produce a more fun viewing experience, we can start the camera at a different position, then move it to the front view position through animation.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/800ff42b-6f87-4985-b2a8-07867538e975.png" width="1200" style="">

     
    Here is the final demo:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/81136448-1f03-4efd-8932-95c44541bd06.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Creative Ideas

    Here are some fun ideas you can try to modify this project:

    • Multiple Paintings: you can try to create a gallery of multiple paintings and arrange them in the 3D space
    • Description Text: you can add more descriptive text on the painting or around it. For example, the user can click a button to show the description, then click it again to hide it.
    • Thick Text: you can try to use the “add 3D thick text” block for the description, which supports more font styles.
    1 Reply Last reply
    0
    • CreatiCodeI CreatiCode pinned this topic on

    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

    With your input, this post could be even better 💗

    Register Login
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • CreatiCode