Results 1 to 2 of 2

Thread: Create Custom Vector3 Variable

  1. #1
    Join Date
    Oct 2012

    Question Create Custom Vector3 Variable

    Hey there fellow devs, im looking for some help if possible, at the moment I'm been ask to create a cube in opengl, which I have done, but now I need to make it in vertex, edge face structure, now I had my cube created by just createing a huge array with each vertex point, but how can I create a custom variable, like a custom struct in C++

    C++ code
    struct Vector3{
      float x, float y, float z
    does this work for JavaScript or is there a different way, cheers for the help


  2. #2
    Join Date
    Aug 2008
    There are no classes/structs in JavaScript, but you can create something similar to classes. (Check out this article on the subject: http://www.phpied.com/3-ways-to-defi...ascript-class/)

    Basically, the easiest way to create your vector here would be something like this:
    var vector = {x:7, y:48, z:3.5};
    alert(vector.z); // 3.5!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center