#include "web3d.h"

int main(void) {
    int color;
    start();
    
    pushMatrix();
    translate(-125, 0, 0);
    fill(color = hsl360(PHYLLOTAXIS360, 100, 50));
    sphere(10);                                     // 球
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    box(20, 20, 20);                                // 直方体
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    cone(10, 20);                                   // 円錐
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    cylinder(10, 20);                               // 円柱
    
    translate(50, 0, 0);
    pushMatrix();
    scale(0.2, 0.2, 0.2);
    translate(0, -60, 0);
    rotateY(-2*PI/3);
    object("duck.dae", 0, 0, 0);                           // COLLADAオブジェクト
    popMatrix();
    
    translate(50, 0, 0);
    imageBB("hidari3tomoe.png", 0, 0, 0, 20, 20);     // 画像     
    popMatrix();
    
    pushMatrix();
    translate(-125, 60, -60);
    
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    rotateX(-PI/4);
    ellipse(0, 0, 20, 20);                         // 楕円 （厚みなし） 
    popMatrix();
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    translate(-20, 0, 0);
    rotateX(-PI/4);
    textFont("monospace", 10);
    text("Hello,", 0, 0, 0);                       // 文字列 （厚みなし）
    popMatrix();

    thickness(5);                                    // 平面図形に厚みをセット
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    rotateX(-PI/4);
    ellipse(0, 0, 20, 20);                         // 楕円 （厚みつき）
    popMatrix();
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    rotateY(-PI/6);
    translate(-20, 0, 0);
    textFont("monospace", 10);
    text("World", 0, 0, 0);                        // 文字列 （厚みつき）
    popMatrix();
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    rotateY(-PI/6);
    rect(-14.14, -10, 28.28, 20);                  // 長方形 （厚みつき）
    popMatrix();
    
    translate(50, 0, 0);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    pushMatrix();
    scale(0.25, 0.25, 1);
    rotateX(PI);
    translate(0, -40, 0);
    
    // http://blog.burlock.org/html5/130-path  via  examples/webgl_geometry_shapes.html
    begin2DShape();                                   // 2D図形 （厚みつき）
    vertex2D(25, 25);
    bezierVertex2D( 25,  25,  20,   0,   0,   0);
    bezierVertex2D(-30,   0, -30,  35, -30,  35);
    bezierVertex2D(-30,  55, -10,  77,  25,  95);
    bezierVertex2D( 60,  77,  80,  55,  80,  35);
    bezierVertex2D( 80,  35,  80,   0,  50,   0);
    bezierVertex2D( 35,   0,  25,  25,  25,  25);
    end2DShape();       
    popMatrix();

    popMatrix();
    
    thickness(0);
    translate(0, 30, 60);
    pushMatrix();
    rotateZ(PI/6);
    translate(-100, 0, 0);
    textFont("monospace", 16);
    fill(color = rotateH360(color, PHYLLOTAXIS360));
    fillOpacity(0.2);
    text("3D API examples", 0, 0, 0);
    popMatrix();
    
    finish();

    return 0;
}
