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 - Go Around the Globe (Difficulty: 1)

3D - Go Around the Globe (Difficulty: 1)

Scheduled Pinned Locked Moved Tutorials
1 Posts 1 Posters 3.2k 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 orbit cameras
    • Camera configuration
    • The widget extension
    • The button widget
       
       

    Introduction

    In this tutorial, you will build a project that tells us where is your home country and where you would like to visit:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a529a1df-35aa-4ee6-9078-6e3340ecda90.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">
     
     

    Step 1 - Load the “Globe” Scene

    Please create a new project on the CreatiCode playground, remove the dog sprite, and add these blocks in the “Empty1” sprite.

    Load the “Globe” scene using the “initialize 3D scene” block in the “3D Scene” category.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/49abaad6-d348-426e-bf98-2cbe0b8dcd12.png" width="400" style="">
     
    Now you can rotate the camera around the globe:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/37449077-690f-4ab6-a846-b7fecda2774d.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     

    Step 2 - Find where you are on the globe

    Now please try to find where you are on the globe by rotating and zooming the camera. For example, suppose your location is close to Chicago (USA), you can try to put that at the center of the camera view:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/53df87cf-3849-4d8e-abe4-d774ad9bb7c0.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Step 3 - Move the Camera Automatically

    Now we want to move the camera automatically so the user will not have to rotate the camera.

    To move the camera, you need to use the “set camera” block. And to find out the camera position, you can use the camera property reporter block. Here is how to use both of them together:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7eb548c0-d56e-42ca-b897-184792d561a1.gif" width="500" style="">
     
    So your program should look like this after you are done. It will move the camera to where you are on the globe automatically.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f84f351d-74ee-458b-9dfe-f32805df17e9.png" width="800" style="">

     
     

    Step 4 - A New Button for Destination

    Next, let’s add a button for jumping to your destination on the globe. Add the “widget” extension, then add the “add button” block.

    For example, suppose you would like to visit Spain. Then you can set the text on the button to “Spain”.

    5ab727b2-007e-4c38-8b27-0637564ae1d9-image.png
     
    After you click this block (by itself), a new button will be added at the center of the screen. You can turn on the “widget position” tool, and then move or resize the button. The numbers in the “add button” block will change accordingly.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7bc4352c-8654-4369-8380-47ac0991bb58.gif" width="1000" style="border-radius: 5px; border: 1px solid #29622d;">
     
    Here is an example of the final program with the new block:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/7e899344-5eb7-41ff-b7c7-13dcb7845254.png" width="700" style="">

     
     

    Step 5 - Handle The Button Click Event

    When the user clicks the button, we want to switch the camera to look at Spain on the globe. That logic can be implemented with 2 blocks:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/f57266e9-4661-4f0c-9a2e-7fd4c8939b03.png" width="500" style="">

     

    Note that for the “when widget named xx clicked” block, the “buton1” will not appear in the dropdown if you haven’t added that button yet. In other words, you need to first run the “add button” block above at least once before using this “when” block.

    Now we just need to find out the exact camera distance and angles. The method is very similar to steps 2 and 3. We first move the camera by hand, then find out the camera parameters.

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/4f2933d8-b3fb-48ae-aedc-c7272609a5ae.gif" width="900" style="border-radius: 5px; border: 1px solid #29622d;">

     
    Now your program should contain 2 stacks:

    edf53d11-b0a2-42c8-8cf8-37d07246dad6-image.png

     
     

    Step 6 - Camera Animation

    Currently, when the user clicks the “Spain” button, our camera would jump to the new view. To make the transition more smooth, we can add some animations, similar to what we see in Google Earth.

    There can be many ways to move the camera. In this example, we will first zoom the camera out by increasing its distance from the globe to 11000 in 1.5 seconds. Second, we will keep the distance, but rotate the camera to the new angles in 3 seconds. Lastly, we zoom in on the camera to get closer to Spain in 1.5 seconds:

    e0c5d6e1-ba08-4def-a6b3-926a4b60af9e-image.png

     
    Now we get a pretty good camera animation:

    https://cdncreaticodecom.b-cdn.net/scratch-gui-projects/forum/a529a1df-35aa-4ee6-9078-6e3340ecda90.gif" width="470" style="border-radius: 5px; border: 1px solid #29622d;">

     
     

    Creative Ideas

    You can apply this idea to build many other interesting projects that show different parts of the globe. Here are some ideas for you to explore:

    • You can change the color of the button to make it look better
    • You can add another “Home” button that will bring the camera back to your current location on the globe.
    • You can build a project that shows the world’s largest/smallest/most populated countries on the globe.
    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