I'm currently working on a 3D rendering engine in JavaScript. I've successfully rendered a cube and can rotate it. My cube is represented by 3D points in an array ([x, y, z]):

var cube = [[-20,-20,5],[20,-20,5],[-20,20,5],[20,20,5],

Now that I can render a basic cube I'd like to try rendering something more complicated to make sure my math works well. It's there a standard 3D object file i can import and use or I have to manually specify the 3D positions of every vertex like I did with the cube?


2 Answers 2


I'm not completely familiar with it, but I think that for your convenience, I would take a look into the Wavefront .obj file format.

As I understand, a lot of 3d software implement this file format as a convenience to transfer from one 3d app to another.

Since the format is text based, you could 'code' your first shapes at first by hand, and then use a 3d software like Blender to make more complex objects.

You'll have to change the way you "read" your 3d objects, however, but it's for the best :)

Another advantage of using an open file format is that you'll already have a bunch of features right away, without having the burden of thinking how to structure them.

Be aware that different software use different hand-ness and coordinate system convention, so it may differ a bit from your implementation (for instance, a software might think the y axis is up, while another, or your own, thinks that z axis is up.

  • \$\begingroup\$ Thank you, i researched lot more about 3d modeling, 3d objects, wavefront, etc and wrote a .obj importer and a parser and modified my draw algorithm to be able to draw .obj models. Right now my engine can render, rotate, escale and translate imported 3d .obj objects. I had some troubles with faces, vertex and indices but i solve it so i can draw the triangles where they have to be. Right now i'm working in ilumination and shadow based on facing orientation. Thanks for your answer, it opened many new doors ;) \$\endgroup\$
    – PRDeving
    Nov 12, 2015 at 9:30
  • \$\begingroup\$ @RDeving glad I could help! \$\endgroup\$
    – Vaillancourt
    Nov 12, 2015 at 14:30

Take a look at existing 3d model formats like Wavefront or Collada. They usually contain much more than a list of vertices, but you could write a function that extracts that particular details. Once you can extract vertices I'd look into rendering polygons.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .