ScratchData LogoScratchData
Back to kriblo_test's profile

Example: Simple 3D Pen

KRkriblo_test•Created October 9, 2023
Example: Simple 3D Pen
25
18
199 views
View on Scratch

Instructions

This example demonstrate 3D positioning (for using the pen extension), and a method to calculate sprite size (for stamping using the pen extension). In this example, Bounce is an invisible sprite which bounces around the 2D stage and calculates it's relative 2Dx and 2Dy coordinates. The Pen sprite draws a 3D rectangle and uses the Bounce relative screen position to stamp a basketball costume in that rectangle. Commented code inside, by me (@kriblo). 3D math. Simply put: 2Dx = VF * (3Dx / 3Dz) 2Dy = VF * (3Dy / 3Dz) The greater the 3Dz (farther away), the smaller the 2Dx & 2Dy (closer to the center). VF, view factor or focal length, determines the perspective. The greater the VF, the more stretched out the perspective (greater 2Dx & 2Dy). As a bonus, sound volume and pan (left/right) is calculated using Bounce screen coordinates.

Project Details

Project ID905230101
CreatedOctober 9, 2023
Last ModifiedOctober 12, 2023
SharedOctober 10, 2023
Visibilityvisible
CommentsAllowed