Skip to content

xizhonghua/threecpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

threecpp

Another C++ version of three.js

Example

#include "three.h"
using namespace three;

class BasicWindowApp: public WindowApp {
private:
  Scene scene;
  PerspectiveCamera camera { 60, width_ * 1.0 / height_, 1, 10000 };
  BoxGeometry geometry { 200, 200, 200 };
  MeshBasicMaterial material1, material2;
  Mesh mesh1 { &geometry, &material1 }, mesh2 { &geometry, &material2 };
  OpenGLRenderer renderer;

public:
  BasicWindowApp() :
      WindowApp(800, 450, "examples/Basic") {
  }

  void initScene() override {
    renderer.setSize(width_, height_);

    camera.position.z = 800;

    material1.color(Color(0x0000ff)).wireframe(true);
    material2.color(Color(0xff0000)).wireframe(false);

    mesh1.position.x -= 300;
    mesh2.position.x += 300;

    scene.add(&mesh1);
    scene.add(&mesh2);
  }

  void animate() override {
    mesh1.rotation.x += 0.5;
    mesh1.rotation.y += 1.0;

    mesh2.rotation.x += 1.0;
    mesh2.rotation.y += 0.5;

    renderer.render(&scene, &camera);
  }
};

int main(void) {
  return BasicWindowApp().init().run();
}

Current Status

For demo purpose

Contact

xizhonghua AT gmail

Releases

No releases published

Packages

No packages published

Languages