Goofy 3d Rotation & rendering behind the camera

I made this 3d rotation with help of scratch wiki.. but it looks.. goofy. :no_mouth:
whats wrong u think?

It looks great!
The only problem is that it tries to render when the shape is behind the camera, causing weird lines to be drawn.
I don't know what specific script you're using, but I would reccomend checking if the render z is less than the camera z, and if so, don't render it.

Your code wrongly uses yaw & roll as pitch.
Also, FOV (field of view) has an opposite meaning than the focal length for this calculation.
Test project

I'm not sure why you think it's "goofy." 3D is like that! The reason it doesn't look quite so strange in your real world vision is that instead of seeing a wire frame with transparent faces, you see only the surfaces that aren't obscured by other surfaces.

well yeah but when I use my sliders to change rotation.. it also changed the shape of my cube! Thanks to @dardoro! isnt that makes more sense? why I didnt have 3 veriables to control each rotation axis..Urgh. I dont know how Scratch managed to do that or its just incorrect info..
@silver_star I dont know how to do that tbh. I tried some z if elses.. it didnt really worked.. z veriable is just a dividing thing to x and y in my code.. I dont know how to use it with fov(if necessary)...

any help about last part is appreciated!

It works fine apart from the z stuff which you mentioned.
I will look at your code later when I get back from school.

Following the usual convention, the z-axis is facing toward the viewer, so only points LESS than camera-z should be rendered.
3d rotation test script pic

I messed around a bit.. turns out my code is kinda mirrored & reversed & stuff render.. I fixed it and went with something like this;
3d rotation fixed script pic
checking the z position after scale&Rotate thing.. otherwise if i rotate it.. it would start removing points from back. Thanks for the help! i will try to improve this

(wasd, eq)

Ooh, like it! I didn't have to look at the script at all!
Now I would recommend a different cube script.
3d cubes added onto and broken by silver_star - Snap! Build Your Own Blocks (
This needs some fixing but I think you get the basic idea, don't you.

that is.. quite heavy lol. and I see why.. filling the squares added to list!

Click the link again. It works better than previous version, but I can't really see anything.

yea I actually tried to do smth like that and failed to complete. I made the pen size(basically quality) adjustable for each square but i also need to make it dynamic so when I get close.. pen size gotta be bigger because basically square is bigger now.. i tried to do some stuff with square z(scaled & rotated version) and camera z but it didnt really worked.. :no_mouth: even tho its still not compact to work with. im thinking about learning to convert them to triangles.. ppl tend to use triangles alot.. so now or later i gotta learn it ¯_(ツ)_/¯.
its crazy how many different way to fill a triangle exist. this one is my favorite. you should check it out!

I like it!
If you convert it to triangles, you just update the script of triangle for the points of it to be 3d, then you don't need to change the pen size.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.