Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:17:02+00:00 2026-06-13T03:17:02+00:00

im trying to great a array of vector3’s in JavaScript, im trying to create

  • 0

im trying to great a array of vector3’s in JavaScript, im trying to create a Vertex, Edge, Face structure for a openGL cube, now im quite new to JavaScript but as HTML5 supports it, i feel JS should be a language i understand and now :),

Now I dont know how to declare a struct in JS and then how I would implement it into a array type?

I have something like this but i’m not sure if that’s correct.

var vector3 = (x=0,y=0,z=0);

but then how would I use that for a array?

Cheers for the help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:17:03+00:00Added an answer on June 13, 2026 at 3:17 am

    I would create an Object:

    var vector3 = {
        x:0,
        y:0,
        z:0
    };
    

    You can access the individual fields with code such as:

    var tmp = vector3.x;
    

    To place points in a vector

    var myPolygon = [
        {x: 3, y: 8, z: -8},
        {x: 3, y: 4, z: 10},
        {x: 9, y: 8, z: -8},
    ];
    

    You could write a vector type with this too so you do not have to write x, y, and z every time:

    var vec3 = {x:0,y:0,z:0};
    
    var demoVec = vec3;
    var demo2Vec = vec3;
    demoVec.x+=demo2Vec.y;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort any array with array_multisort() and everything is working great. However,
I'm trying to create local table with JQGrid, It's all working great until Im
I'm trying to create a 2D array in XNA which I'll be using as
I'm trying to create a function that will run through an array and collect
I am trying to create a base class that is a wrapper around std::array
I'm trying to create an array of 144 FloatBuffers so I can easily access
Would be great to get some direction re trying to use sqlite for my
I'm having a great deal of difficulty trying to figure out the logic behind
I'm trying to compile this function from Learn You a Haskell for Great Good
I received some great help on joining a table to itself and am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.