would like to program 3d graphic in p5.js/ a simple cube with all the rotations and translations

without any 3d libraries. only code.

Tagged:

Answers

  • hi koogs, sorry, but i want to do nativ 3d programming. without all the objects. if you have only 8 points of the cube and then you have to use the rotation matrixes.

  • Well, p5js is itself a library -- however, if you want to look at an implementation of a cube / box and then write your own, then a great place to start might be the source code for p5js box.

    Check out p5.js/src/webgl/primitives.js -- starting at the line "p5.prototype.box = function()"

    For examples of basic implementations of geometric functions, check out p5.js/src/webgl/p5.Geometry.js

    If you want to do "native" programming then a JavaScript client-side library like p5.js is a terrible choice for a language. I'd recommend looking at something like OpenFrameWorks so that you can work in C++. If you want to write everything in "native" JavaScript then you don't want to be using P5js at all.

  • It sounds like an assignment.

    Have an array containing triplets for x, y, z (createVector?) And a list of connections between them.

    Each frame, rotate each point then iterate through the connections list drawing lines between the points.

Sign In or Register to comment.