3D Graphics For Gamelab

3D Graphics For Gamelab

I’ve been working on a 3d renderer for game lab for a while now, [[HERE]]

Features

It's a working 3d renderer that is fairly reliable. The main focus on the program is to condense rendering a line/face to a single object:
  {Type:"quad",V1:{x:-10, y:10, z:-10}, V2:{x:10, y:10, z:-10}, V3:{x:10, y:-10, z:-10}, V4:{x:-10,y:-10,z:-10}, Color:"red"},

Currently, the program uses perspective projection, instead of orthogonal. I haven’t worked out a reliable method to implement orthogonal so that is the reason it isn’t available.

Speed

Unfortunately too many objects can slow down the game, and by that I mean > 50 3d points (This is actually dependent on your computer). In the game, I have created a cube, which consists of 6 faces. Each face contains 4 3d points, therefore a single cube would contain 24. However, multiple points are in the same place so it is possible to shorten down the amount of points to only 8.

Modifying it

There are many uses for 3D graphics. A working game would be this one: [[HERE]] This game is just a proof of concept for some kind of 3d rpg game, where you could chat with NPCS and stuff. Also take note that the camera system is different than the first one, which was essentially freecam. How a camera behaves is not part of the renderer and should be implemented independently. Creating objects to render is very simple: Change the contents of the array game (should be line 147).

2 Likes

Is there a way that you could create a raycasting demo?
not raytracing, raycasting is what the original DOOM and Wolfenstein 3D used.

Sorry for bump but noticed this has been getting a lot of traction. Don’t use this. I’ve created another thing based on WEBGL that can render 100+ objects with textures.

Take a look at this one. https://studio.code.org/projects/gamelab/vV0LzNXD1FKzoZAoFgvF8YrDO8hgfU_3gs3YOj40yNQ

How does this work I don’t get it.

Works by utilizing multiple equations and calculations to display a 3d figure onto a 2d display, your screen.

If you want to have a somewhat basic understanding of what’s going on, please refer to this video - How to make a 3D Engine in Scratch 3.0
Though made in Scratch, both engines are very similar in design, and are built upon the same fundamental concepts surrounding 3d rendering.

If you want a more thorough explanation, I’d watch 3D Graphics Engine Part #1 - Triangles & Projection, minutes 16 to 28 about Field of View and Matrixes. They provide a much deeper guide of all the math going on with these renderers (though this video is a little more difficult to digest).

Have fun :slight_smile:

I was wondering if there was a way to put textures on the faces of the shapes in the NEON project, such as an image url or an animation stored in the animation bar?