<script src="http://spelprogrammering.nu/simple.js">
function createCube()
{
cubePoints = [];
for (var x = -1; x <= 1; x+=2)
for (var y = -1; y <= 1; y+=2)
for (var z = -1; z <= 1; z+=2)
cubePoints.push(new math.Point3D(x, y, z, "green", 300));
cubeLinesFrom = [0, 0, 0, 4, 4, 6, 6, 2, 3, 3, 1, 7];
cubeLinesTo = [1, 4, 2, 5, 6, 7, 2, 3, 1, 7, 5, 5];
}
function createPyramid()
{
pyramidPoints = [];
pyramidPoints.push(new math.Point3D(1, 1, -1, "orange", 300));
pyramidPoints.push(new math.Point3D(-1, 1, -1, "orange", 300));
pyramidPoints.push(new math.Point3D(-1, -1, -1, "orange", 300));
pyramidPoints.push(new math.Point3D(1, -1, -1, "orange", 300));
pyramidPoints.push(new math.Point3D(0, 0, 1, "orange", 300));
pyramidLinesFrom = [0, 0, 0, 1, 1, 2, 2, 3, 3];
pyramidLinesTo = [1, 3, 4, 2, 4, 3, 4, 2, 4];
}
function start()
{
createCube();
createPyramid();
save();
translate(-400, -200);
for (index in cubePoints)
cubePoints[index].rotate(0.25,0.25,0);
for (index in cubeLinesFrom)
cubePoints[cubeLinesFrom[index]].
lineTo(cubePoints[cubeLinesTo[index]], "green", 10);
restore();
translate(450, 200);
for (index in pyramidPoints)
pyramidPoints[index].rotate(-1.5,0.3,0);
for (index in pyramidLinesFrom)
pyramidPoints[pyramidLinesFrom[index]].
lineTo(pyramidPoints[pyramidLinesTo[index]], "orange", 10);
}
</script>