Creating an object


Dec. 21, 2014

The simplest shape to create is probably a cube so let's start by making a 200×200×200 pixel cube, centred at the origin (0, 0, 0).

Nodes

Start by defining an array of nodes. Each node is object with x, y and z properties. Notice that the nodes represent all eight possible permutation of 100 and -100.

var nodes = [
    {x: -100, y: -100, z: -100},
    {x: -100, y: -100, z:  100},
    {x: -100, y:  100, z: -100},
    {x: -100, y:  100, z:  100},
    {x:  100, y: -100, z: -100},
    {x:  100, y: -100, z:  100},
    {x:  100, y:  100, z: -100},
    {x:  100, y:  100, z:  100}
];

Leave a comment

cancel reply