Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 11 committers (18.2%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.3%) to scientific vocabulary
Keywords
Repository
C++20 port of three.js (r129)
Basic Info
Statistics
- Stars: 694
- Watchers: 16
- Forks: 76
- Open Issues: 7
- Releases: 0
Topics
Metadata Files
README.md
threepp (Work in progress)
Cross-platform C++20 port of the popular Javascript 3D library three.js r129.
Current state of the project
Most of the core library has been ported, including advanced rendering capabilities, however much remains to be done..
What works?
- Line, Points, Mesh, InstancedMesh
- Geometries [Box, Sphere, Plane, Cylindrical, Capsule, Tube, ++]
- Lights [Ambient, Directional, Point, Spot, Hemi]
- Raycasting [Mesh, Line, Points]
- 2D/3D Textures, 3D text, Sprites, RenderTarget, CubeMaps
- Transparency, Shadows
- Morphtargets, Bones
- Controls [Orbit, Fly, Drag]
- Water and Sky shaders
- Built-in text rendering and font loading [typeface.json, TTF]
- Loaders [Binary STL, OBJ/MTL, SVG, URDF]
- Animations (limited to transforms)
- Basic Audio support using miniaudio
- Generic model loader based on Assimp
- Easy integration with Dear ImGui
Builds on Windows, Linux, MacOS, MinGW and with Emscripten.
But, but why?
Because fun.
How to build
threepp comes bundled with all required core dependencies.
Use CMake for project configuration and building.
Do note that you may also use a system installation of GLFW3 if you want or have issues with the bundled setup by passing
-DTHREEPP_USE_EXTERNAL_GLFW=ON to CMake.
Windows
shell
cmake . -A x64 -B build -DCMAKE_BUILD_TYPE="Release"
cmake --build build --config "Release"
Unix
shell
cmake . -B build -DCMAKE_BUILD_TYPE="Release"
cmake --build build
Building examples with Emscripten
Pass to CMake:
shell
-DCMAKE_TOOLCHAIN_FILE="[path to emscripten]\emsdk\upstream\emscripten\cmake\Modules\Platform\Emscripten.cmake"
This will generate .html versions of a subset of the examples to be loaded in a browser.
Optional downstream dependencies
When consuming threepp in your own application,
some headers will require additional dependencies to compile.
| Header | Dependency | Description | |--------------|----------------|-----------------------------------------------| | AssimpLoader | assimp | Import a wide variety of different 3D formats | | ImguiContext | imgui | ImGUI utility |
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.
Thus, you don't necessarily need to handle memory explicitly using threepp.
Furthermore, materials, geometries and textures are automatically disposed when they go out of scope.
Yay!
Example
```cpp
include "threepp/threepp.hpp"
using namespace threepp;
auto createBox(const Vector3& pos, const Color& color) { auto geometry = BoxGeometry::create(); auto material = MeshPhongMaterial::create(); material->color = color;
auto box = Mesh::create(geometry, material);
box->position.copy(pos);
return box;
}
auto createPlane() { auto planeGeometry = PlaneGeometry::create(5, 5); auto planeMaterial = MeshLambertMaterial::create(); planeMaterial->color = Color::gray; planeMaterial->side = Side::Double;
auto plane = Mesh::create(planeGeometry, planeMaterial);
plane->position.y = -1;
plane->rotateX(math::degToRad(90));
return plane;
}
int main() {
Canvas canvas("Demo");
GLRenderer renderer{canvas.size()};
auto scene = Scene::create();
auto camera = PerspectiveCamera::create(75, canvas.aspect(), 0.1f, 100);
camera->position.z = 5;
OrbitControls controls{*camera, canvas};
auto light = HemisphereLight::create();
scene->add(light);
auto plane = createPlane();
scene->add(plane);
auto group = Group::create();
group->add(createBox({-1, 0, 0}, Color::green));
group->add(createBox({1, 0, 0}, Color::red));
scene->add(group);
canvas.onWindowResize([&](WindowSize size) {
camera->aspect = size.aspect();
camera->updateProjectionMatrix();
renderer.setSize(size);
});
Clock clock;
canvas.animate([&]() {
float dt = clock.getDelta();
group->rotation.y += 1.f * dt;
renderer.render(*scene, *camera);
});
}
```
Consuming threepp
Threepp is available as a CMake package and can be consumed in a number of ways.
CMake FetchContent (recommended)
threepp is compatible with CMake's FetchContent:
```cmake include(FetchContent) set(THREEPPBUILDTESTS OFF) set(THREEPPBUILDEXAMPLES OFF) FetchContentDeclare( threepp GITREPOSITORY https://github.com/markaren/threepp.git GITTAG tagorcommithash ) FetchContent_MakeAvailable(threepp)
...
targetlinklibraries(main PUBLIC threepp::threepp) ```
This is the preferred approach, as it enables users to update the targeted threepp version at will.
An example is provided here. See also this demo, which additionally uses WxWidgets as the Window system.
Screenshots
Owner
- Name: Lars Ivar Hatledal
- Login: markaren
- Kind: user
- Location: Norway
- Company: NTNU Aalesund
- Website: https://www.ntnu.edu/employees/laht
- Repositories: 24
- Profile: https://github.com/markaren
Associate professor @ NTNU Aalesund, Norway
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: threepp
message: >-
If you publish papers using this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Lars Ivar
family-names: Hatledal
email: laht@ntnu.no
affiliation: NTNU
orcid: 'https://orcid.org/0000-0001-6436-7213'
repository-code: 'https://github.com/markaren/threepp'
abstract: >-
Cross-platform C++ port of the popular Javascript 3D
library three.js
license: MIT
GitHub Events
Total
- Issues event: 8
- Watch event: 67
- Delete event: 8
- Issue comment event: 25
- Push event: 53
- Pull request event: 14
- Fork event: 20
- Create event: 5
Last Year
- Issues event: 8
- Watch event: 67
- Delete event: 8
- Issue comment event: 25
- Push event: 53
- Pull request event: 14
- Fork event: 20
- Create event: 5
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Lars Ivar Hatledal | l****t@n****o | 1,067 |
| Lars Ivar Hatledal | l****t@h****o | 181 |
| tonghao.yuan | y****o@g****m | 1 |
| Salama Ashoush | s****h@g****m | 1 |
| Rob | 8****h | 1 |
| Josef Graus | j****s | 1 |
| Daniel Lin | 8****r | 1 |
| Bertil Chapuis | b****s@g****m | 1 |
| Ashton Fagg | 1****g | 1 |
| Andrew Davis | d****a@e****u | 1 |
| Morteza Hakimi Siboni | m****i@m****m | 1 |
Committer Domains (Top 20 + Academic)
Dependencies
- actions/checkout v3 composite
- lukka/run-vcpkg v10 composite
- glad *
- glfw3 *
- stb *