C++17 port of three.js (r129)

Overview

threepp (Work in progress)

Cross-platform C++17 port of the popular Javascript 3D library three.js r129.

Current state of the project

Most of the core library has been ported, including basic rendering capabilities, however much remains to be done..

What works?
  • Box, Sphere, Plane, Cylindrical and Tube geometries
  • 2D Textures
  • Transparency
  • OrbitControls
  • AmbientLight, DirectionalLight, PointLight
  • Most materials
  • RenderTarget
  • Raycasting against Mesh

But, but why?

This is mostly a personal exercise. Don't expect much support, although contributions are welcome.

How to build

In order to successfully build threepp, you'll need conan in order to handle dependencies.

pip install conan

With conan installed, invoke run_conan_install.sh. This will fetch all necessary third party libraries as listed in conanfile.txt.

note that this command is hardcoded to use the default CLion build folders (cmake-build-<target>)

You can now build the project as a regular CMake project using e.g., the command line.

Implementation notes

In general, you'll find that math classes are value types, while threepp expect smart pointers for other types. For convenience, geometries, materials etc. has a static ::create function that returns a std::shared_ptr. There should never be a need to handle memory explicitly using threepp. Yay!

Example

#include "threepp/threepp.hpp"

using namespace threepp;

int main() {

    Canvas canvas;

    auto scene = Scene::create();
    auto camera = PerspectiveCamera::create(75, canvas.getAspect(), 0.1f, 100);
    camera->position.z = 5;

    GLRenderer renderer(canvas);
    renderer.checkShaderErrors = true;
    renderer.setSize(canvas.getSize());

    OrbitControls controls{camera, canvas};

    auto light = AmbientLight::create(Color(0xffffff).multiplyScalar(0.75f));
    scene->add(light);

    auto group = Group::create();

    {
        const auto boxGeometry = BoxGeometry::create();
        const auto boxMaterial = MeshPhongMaterial::create();
        boxMaterial->color.setHex(0xff0000);
        auto box = Mesh::create(boxGeometry, boxMaterial);
        box->position.setX(-1);
        group->add(box);
    }

    {
        const auto boxGeometry = BoxGeometry::create();
        const auto boxMaterial = MeshPhongMaterial::create();
        boxMaterial->color.setHex(0x00ff00);
        auto box = Mesh::create(boxGeometry, boxMaterial);
        box->position.setX(1);
        group->add(box);
    }

    scene->add(group);

    const auto planeGeometry = PlaneGeometry::create(5, 5);
    const auto planeMaterial = MeshLambertMaterial::create();
    planeMaterial->color.setHex(Color::gray);
    planeMaterial->side = DoubleSide;
    auto plane = Mesh::create(planeGeometry, planeMaterial);
    plane->position.setY(-1);
    plane->rotateX(math::degToRad(90));
    scene->add(plane);

    canvas.onWindowResize([&](WindowSize size) {
        camera->aspect = size.getAspect();
        camera->updateProjectionMatrix();
        renderer.setSize(size);
    });

    group->rotation.setOrder(Euler::YZX);
    canvas.animate([&](float dt) {
        group->rotation.y += 0.5f * dt;

        renderer.render(scene, camera);
    });
}
Issues
  • Can you make installation procedure more clear?

    Can you make installation procedure more clear?

    I'm on OSX - this looks like a nice project!

    Trying to install, I do this, all fine.

    conan remote add ais https://ais.jfrog.io/artifactory/api/conan/ais-conan-local
    

    Then on this step - I am stuck.

    Then add a dependency to:
    threepp/<version>@ais/stable (stable channel -> releases)
    threepp/<version>@ais/testing (development builds -> master)
    threepp/<version>@ais/testing-<branch> (development builds -> branches)
    

    I am not familiar enough with conan to do this. Can you make the instructions more clear? What command do I need to run to do this? Thanks for your help with this.

    opened by PaulHaeberli 9
  • Failed Attempting to Build on Linux

    Failed Attempting to Build on Linux

    hey folks, thanks for the great work on this project...

    its prolly not a bug but i get the following error when trying to build on Ubuntu 21.10. via cmake

    any thoughts?

    
    glad/0.1.34: ERROR: Error downloading binary package: 'glad/0.1.34:7cd8e60b35bfb26d6dc0e23acc1bb0467b1b6545'
    ERROR: HTTPSConnectionPool(host='center.conan.io', port=443): Max retries exceeded with url: /v1/ping (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1129)')))
    
    Unable to connect to conancenter=https://center.conan.io
    1. Make sure the remote is reachable or,
    2. Disable it by using conan remote disable,
    Then try again.
    
    

    i can do cpp but not so hot on conan/cmake/devops. thanks, sean

    opened by seanbutler 3
  • Framebuffer size and Canvas size should be  different

    Framebuffer size and Canvas size should be different

    On a Mac with Retina display the screen size is wrong and you only get an image in the bottom quater of the screen.

    To fix you need to use

    int width,height;
    glfwGetFramebufferSize(window,&width,&height);
    size_.width=width;
    size_.height=height; 
    

    In the Canvas::Impl method after window construction.

    Also the resize event needs changing

      static void window_size_callback(GLFWwindow *w, int width, int height) {
          auto p = static_cast<Canvas::Impl *>(glfwGetWindowUserPointer(w));
          glfwGetFramebufferSize(w,&width,&height);
          p->size_ = {width, height};
          if (p->resizeListener) p->resizeListener.value().operator()(p->size_);
      }
    

    It may be better to split frambuffer size and canvas size into different things as this will cause issues with some platforms. Great project BTW.

    opened by jmacey 7
Owner
Lars Ivar Hatledal
Associate professor @ NTNU Aalesund, Norway
Lars Ivar Hatledal
Axel Gneiting 1.4k Aug 8, 2022
Port of Doom 3 for PSVITA. (Based on https://github.com/emileb/d3es-multithread )

ABOUT Combination of the excellent dhewm3 and d3wasm projects, now with multithreaded frontend and backend renderering. Forked from: https://github.co

Rinnegatamante 22 Jun 12, 2022
Port of Wolfenstein 3D to the PSP with improved controls, autorun, automap and correct aspect ratio.

wolf3Dpsp Fork of Wolfenstein 3D port for the PSP by Zack and Chilly Willy with improved controls, autorun enabled by default, automap and correct asp

Wesley Daflita 3 Jun 22, 2022
Android port of 3D Pinball for Windows – Space Cadet

SpaceCadetPinball Android port of 3D Pinball for Windows – Space Cadet Based on: https://github.com/k4zmu2a/SpaceCadetPinball TODO Add proper controls

Iscle 92 Jul 21, 2022
A Celeste Classic port for the TI-84+CE and TI-83PCE graphing calculators.

CEleste A Celeste Classic port for the TI-84+CE and TI-83PCE graphing calculators. Usage (A video tutorial for the following steps is also available h

John Cesarz 32 Jul 17, 2022
A C++ port of Wave Function Collapse Tiling

Wave Function Collapse in C++ This is a C++ port of https://github.com/mxgmn/WaveFunctionCollapse. All sample images come from https://github.com/mxgm

Emil Ernerfeldt 283 Jul 15, 2022
this repo creating three fractals using minilibix (created by 42-Network) and it contains three fractals

Welcome to the beautiful worlds of fractals Hi my name is yahya AKA Ma3ert this projects create three fractals using the minilibix library which's cre

null 3 Mar 22, 2022
Port-Fin(port finder) is a tool which scans for open and closed port on a website/host.

Port-Fin(port finder) is a tool which scans for open and closed port on a website/host. This tool scans the state of the well known/common ports.

AnonabdulJ 4 Dec 14, 2021
Three split ergo keyboard with macropad running QMK

IIICC Three piece split keyboard with macropad running QMK Features Split ergo Additional optional macropad with OLED and rotary encoder Central Hub d

null 30 Jul 30, 2022
Pseudofermion functional renormalization group solver for (frustrated) quantum magnets in two and three spatial dimensions.

SpinParser SpinParser ("Spin Pseudofermion Algorithms for Research on Spin Ensembles via Renormalization") is a software platform to perform pseudofer

Finn Lasse Buessen 20 Jul 16, 2022
Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimensional grid

Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimens

Davide Faconti 284 Aug 8, 2022
A fully-functional open source and open hardware mechanical USB computer keyboard with only three keys!

threeboard threeboard is a fully-functional open source and open hardware mechanical USB computer keyboard with only three keys. It supports multiple

Conor Taylor 97 May 23, 2022
This project contains three scripts to help working with the steam-runtime, especially outside of Steam.

This project contains three scripts to help working with the steam-runtime, especially outside of Steam. See these blog posts for more details: steam-

Jørgen P. Tjernø 11 Oct 22, 2021
C/C++ Application to solve irrigation rotation whatever two-turn rotation or three-turn rotation, longitudinal section design, hydraulic calculations, and design of hydraulic structures like weirs and tail escape.

Irrigation works C/C++ Application to solve irrigation rotation whatever two-turn rotation or three-turn rotation, longitudinal section design, hydrau

Mohamed Jamal Ghayyad 1 Jun 24, 2022
By putting in a lot of speed, the speed sequence is sorted and divided, three types of speed interval distribution maps are generated.(including broken line graph,histogram and curve graph)

Auto-drawing-speed-range-map By putting in a lot of speed, the speed sequence is sorted and divided, three types of speed interval distribution maps a

wellwellAllwen 4 May 14, 2022
C++11 port of docopt

docopt.cpp: A C++11 Port Contents docopt creates beautiful command-line interfaces Isn't it awesome how getopt (and boost::program_options for you fan

null 970 Aug 2, 2022
C++ Requests: Curl for People, a spiritual port of Python Requests

C++ Requests: Curl for People Announcements The cpr project has new maintainers: Fabian Sauter and Tim Stack. TLDR C++ Requests is a simple wrapper ar

Huu Nguyen 4.8k Aug 2, 2022
Cross-platform, Serial Port library written in C++

Serial Communication Library (Linux and OS X) (Windows) This is a cross-platform library for interfacing with rs-232 serial like ports written in C++.

William Woodall 1.6k Aug 7, 2022
Nintendo Switch port of https://github.com/fgsfdsfgs/max_vita

Max Payne Mobile Nintendo Switch port This is a wrapper/port of the Android version of Max Payne Mobile. It loads the original game binary, patches it

fgsfds 28 Jul 29, 2022
Lean4 port of Arduino balance car controller

lean4-balance-car This is a small proof-of-concept exercise to show a Lean 4 program controlling a real robotics platform which requires low latency c

Galois, Inc. 31 Jul 11, 2022
Sonic the Hedgehog (1991, Sega Genesis / MegaDrive) C Port

SoniCPort Sonic the Hedgehog (1991, Sega Genesis / MegaDrive) C Port Dependencies SDL2 (if COMPILE_SDL2 is set to ON) pkg-config (for builds that requ

CuckyDev 96 Jun 28, 2022
Doom classic port to lightweight RISC‑V

Doom classic port to lightweight RISC-V This is a port to try and make adapting/running doom to simple RISC-V platform easier with the code to adapt w

Sylvain 51 Jul 14, 2022
QEMU port for t8030

QEMU README QEMU is a generic and open source machine & userspace emulator and virtualizer. QEMU is capable of emulating a complete machine in softwar

null 1.2k Jul 29, 2022
C++11 port of docopt

docopt.cpp: A C++11 Port Contents docopt creates beautiful command-line interfaces Isn't it awesome how getopt (and boost::program_options for you fan

null 970 Aug 2, 2022
Dynamic patch `wslhost.exe` to listen port on any interface.

WSLHostPatcher Dynamic patch wslhost.exe to listen port on any interfaces. How it work The localhost port actually forward by wslhost.exe on Windows,

CzBiX 366 Aug 5, 2022
Trial port of the rtf_433 Library for use with OpenMQTTGateway on a ESP32 and a CC1101 Transceiver

This is an attempt at creating an Arduino library for use on ESP32 boards with a CC1101 transceiver with the device decoders from the rtl_433 package.

Northern Man 72 Jul 26, 2022
Port of my M5Stack Core 2 audio monitor project to generic ESP32s with TFT screens

ESP32 Audio Monitor This is a port of this project to work with any ESP32 device with a TFT display. You can watch a video explainer here (YouTube) wh

atomic14 45 Jul 19, 2022
Doom port for InfOS - the University of Edinburgh Informatics research operating system used in the UG3 OS course

Doom on InfOS InfOS is the Informatics research operating system, designed specifically for the UG3 Operating Systems course. This project aims to por

Cheng Kai 14 Jun 19, 2022
Port of Golang channels to C++

Copper is a C++ library of a powerful queue object for communication between threads. It is based on Go's channels and follows the quote: Don't commun

null 155 Jul 18, 2022