{"id":13423559,"url":"https://github.com/markaren/threepp","last_synced_at":"2025-04-05T01:03:43.258Z","repository":{"id":45582270,"uuid":"377162982","full_name":"markaren/threepp","owner":"markaren","description":"C++17 port of three.js (r129)","archived":false,"fork":false,"pushed_at":"2024-04-13T05:52:15.000Z","size":59614,"stargazers_count":555,"open_issues_count":7,"forks_count":48,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-14T05:08:25.387Z","etag":null,"topics":["3d-graphics","cpp","emscripten","opengl","threejs","wasm"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/markaren.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-06-15T12:56:46.000Z","updated_at":"2024-04-15T11:48:39.992Z","dependencies_parsed_at":"2024-04-15T11:58:41.720Z","dependency_job_id":null,"html_url":"https://github.com/markaren/threepp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markaren%2Fthreepp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markaren%2Fthreepp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markaren%2Fthreepp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markaren%2Fthreepp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markaren","download_url":"https://codeload.github.com/markaren/threepp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271514,"owners_count":20911587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-graphics","cpp","emscripten","opengl","threejs","wasm"],"created_at":"2024-07-31T00:00:37.460Z","updated_at":"2025-04-05T01:03:43.239Z","avatar_url":"https://github.com/markaren.png","language":"C++","readme":"## threepp (Work in progress)\n\nCross-platform C++20 port of the popular Javascript 3D library [three.js](https://github.com/mrdoob/three.js/) [r129](https://github.com/mrdoob/three.js/tree/r129).\n\n\n#### Current state of the project\n\nMost of the core library has been ported, including advanced rendering capabilities, \nhowever much remains to be done..\n\n##### What works?\n\n* Line, Points, Mesh, InstancedMesh\n* Geometries [Box, Sphere, Plane, Cylindrical, Capsule, Tube, ++]  \n* Lights [Ambient, Directional, Point, Spot, Hemi]\n* Raycasting [Mesh, Line, Points]\n* 2D/3D Textures, 3D text, Sprites, RenderTarget, CubeMaps\n* Transparency, Shadows\n* Morphtargets, Bones\n* Controls [Orbit, Fly, Drag]\n* Water and Sky shaders\n* Built-in text rendering and font loading [typeface.json, TTF]\n* Loaders [Binary STL, OBJ/MTL, SVG, URDF]\n* Basic Audio support using [miniaudio](https://miniaud.io/docs/manual/index.html)\n* Generic model loader based on [Assimp](https://github.com/assimp/assimp)\n* Easy integration with [Dear ImGui](https://github.com/ocornut/imgui)\n\nBuilds on Windows, Linux, MacOS, MinGW and with Emscripten.\n\n### But, but why?\n\nBecause fun. \n\n\n### How to build\n\n`threepp` comes bundled with all required core dependencies. \n\nUse CMake for project configuration and building.\n\nDo note that you may also use a system installation of GLFW3 if you want or have issues with the bundled setup by passing\n`-DTHREEPP_USE_EXTERNAL_GLFW=ON` to CMake.\n\n###### Windows\n```shell\ncmake . -A x64 -B build -DCMAKE_BUILD_TYPE=\"Release\"\ncmake --build build --config \"Release\"\n```\n\n###### Unix\n```shell\ncmake . -B build -DCMAKE_BUILD_TYPE=\"Release\"\ncmake --build build\n```\n\nHowever, some of the examples (and headers) require additional dependencies. \nTo make use of all features and to enable/build all examples, the use of [vcpkg](https://vcpkg.io/en/index.html) is encouraged.\n\n#### Using vcpkg for getting optional dependecies (using manifest mode)\n\nCall CMake with `-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake`\n\nAdd optional features by listing them with `-DVCPKG_MANIFEST_FEATURES=feature1;feature2`\n\nSee [vcpkg.json](vcpkg.json) for available features.\n\nNote, however, that under MinGW you'll need to specify the vcpkg triplet:\n```shell\n-DVCPKG_TARGET_TRIPLET=x64-mingw-[static|dynamic]  # choose either `static` or `dynamic`.\n-DVCPKG_HOST_TRIPLET=x64-mingw-[static|dynamic]    # \u003c-- needed only if MSVC cannot be found. \n```\n\n##### Building examples with Emscripten\n\nPass to CMake:\n```shell\n-DCMAKE_TOOLCHAIN_FILE=\"[path to emscripten]\\emsdk\\upstream\\emscripten\\cmake\\Modules\\Platform\\Emscripten.cmake\"\n```\nWhen using vcpkg, however, do:\n```shell\n-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=\"[path to emscripten]\\emsdk\\upstream\\emscripten\\cmake\\Modules\\Platform\\Emscripten.cmake\"\n```\nThis will generate .html versions of a subset of the examples to be loaded in a browser.\n\n\n##### Optional downstream dependencies\n\nWhen consuming `threepp` in your own application, \nsome headers will require additional dependencies in order to compile.\n\n| **Header**   | **Dependency** | **Description**                               |\n|--------------|----------------|-----------------------------------------------|\n| AssimpLoader | assimp         | Import a wide variety of different 3D formats |\n| ImguiContext | imgui          | ImGUI utility                                 |\n\n\n### Implementation notes\n\nIn general, you'll find that math classes are value types, while `threepp` expect smart pointers for other types. \nFor convenience, geometries, materials etc. has a static `::create` function that returns a `std::shared_ptr`.\nThus, you don't necessarily need to handle memory explicitly using `threepp`.\nFurthermore, materials, geometries and textures are automatically disposed when they go out of scope.\nYay!\n\n### Example\n\n```cpp\n#include \"threepp/threepp.hpp\"\n\nusing namespace threepp;\n\nauto createBox(const Vector3\u0026 pos, const Color\u0026 color) {\n    auto geometry = BoxGeometry::create();\n    auto material = MeshPhongMaterial::create();\n    material-\u003ecolor = color;\n    \n    auto box = Mesh::create(geometry, material);\n    box-\u003eposition.copy(pos);\n    \n    return box;\n}\n\nauto createPlane() {\n    auto planeGeometry = PlaneGeometry::create(5, 5);\n    auto planeMaterial = MeshLambertMaterial::create();\n    planeMaterial-\u003ecolor = Color::gray;\n    planeMaterial-\u003eside = Side::Double;\n    \n    auto plane = Mesh::create(planeGeometry, planeMaterial);\n    plane-\u003eposition.y = -1;\n    plane-\u003erotateX(math::degToRad(90));\n    \n    return plane;\n}\n\nint main() {\n\n    Canvas canvas(\"Demo\");\n    GLRenderer renderer{canvas.size()};\n\n    auto scene = Scene::create();\n    auto camera = PerspectiveCamera::create(75, canvas.aspect(), 0.1f, 100);\n    camera-\u003eposition.z = 5;\n    \n    OrbitControls controls{*camera, canvas};\n\n    auto light = HemisphereLight::create();\n    scene-\u003eadd(light);\n\n    auto plane = createPlane();\n    scene-\u003eadd(plane);\n    \n    auto group = Group::create();\n    group-\u003eadd(createBox({-1, 0, 0}, Color::green));\n    group-\u003eadd(createBox({1, 0, 0}, Color::red));\n    scene-\u003eadd(group);\n\n    canvas.onWindowResize([\u0026](WindowSize size) {\n        camera-\u003easpect = size.aspect();\n        camera-\u003eupdateProjectionMatrix();\n        renderer.setSize(size);\n    });\n    \n    Clock clock;\n    canvas.animate([\u0026]() {\n        \n        float dt = clock.getDelta();\n        group-\u003erotation.y += 1.f * dt;\n\n        renderer.render(*scene, *camera);\n    });\n}\n\n```\n\n## Consuming threepp\n\nThreepp is available as a CMake package and can be consumed in a number of ways.\n\n#### CMake FetchContent (recommended)\n\n`threepp` is compatible with CMake's `FetchContent`:\n\n```cmake\ninclude(FetchContent)\nset(THREEPP_BUILD_TESTS OFF)\nset(THREEPP_BUILD_EXAMPLES OFF)\nFetchContent_Declare(\n        threepp\n        GIT_REPOSITORY https://github.com/markaren/threepp.git\n        GIT_TAG tag_or_commit_hash\n)\nFetchContent_MakeAvailable(threepp)\n#...\ntarget_link_libraries(main PUBLIC threepp::threepp)\n```\n\nThis is the preferred approach, as it enables users to update the targeted threepp version at will.\n\nAn example is provided [here](tests/threepp_fetchcontent_test).\nSee also [this demo](https://github.com/markaren/threepp_wxwidgets), which additionally uses WxWidgets as the Window system.\n\n\n### Screenshots\n![Fonts](doc/screenshots/fonts.png)\n![LeePerrySmith](doc/screenshots/LeePerrySmith.png)\n![Shadows](doc/screenshots/Shadows.PNG)\n![FlyControls](doc/screenshots/fly.PNG)\n![Crane](doc/screenshots/crane.png)\n![Optimization](doc/screenshots/Optimization.PNG)\n![Physics](doc/screenshots/instanced_physics.PNG)\n![Water](doc/screenshots/OlympicOctopus.PNG)\n![MotorController](doc/screenshots/motor_controller.PNG)\n","funding_links":[],"categories":["C++","Libraries"],"sub_categories":["C++"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkaren%2Fthreepp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkaren%2Fthreepp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkaren%2Fthreepp/lists"}