chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:05:14 +08:00
commit 2a547be7fe
7904 changed files with 1000926 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.16...3.27)
# If you use the example outside of the Rerun SDK you need to specify
# where the rerun_c build is to be found by setting the `RERUN_CPP_URL` variable.
# This can be done by passing `-DRERUN_CPP_URL=<path to rerun_sdk_cpp zip>` to cmake.
if(DEFINED RERUN_REPOSITORY)
add_executable(example_clock main.cpp)
rerun_strict_warning_settings(example_clock)
else()
project(example_clock LANGUAGES CXX)
add_executable(example_clock main.cpp)
# Set the path to the rerun_c build.
set(RERUN_CPP_URL "https://github.com/rerun-io/rerun/releases/latest/download/rerun_cpp_sdk.zip" CACHE STRING "URL to the rerun_cpp zip.")
# Download the rerun_sdk
include(FetchContent)
FetchContent_Declare(rerun_sdk URL ${RERUN_CPP_URL})
FetchContent_MakeAvailable(rerun_sdk)
endif()
# Link against rerun_sdk.
target_link_libraries(example_clock PRIVATE rerun_sdk)
+24
View File
@@ -0,0 +1,24 @@
<!--[metadata]
title = "Clock"
thumbnail = "https://static.rerun.io/clock/8c49e25f5cac4d6a1d7d0490b14cf6881bdb707b/480w.png"
thumbnail_dimensions = [480, 480]
-->
<picture>
<source media="(max-width: 480px)" srcset="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/480w.png">
<source media="(max-width: 768px)" srcset="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/768w.png">
<source media="(max-width: 1024px)" srcset="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/1024w.png">
<source media="(max-width: 1200px)" srcset="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/1200w.png">
<img src="https://static.rerun.io/clock/05e69dc20c9a28005f1ffe7f0f2ac9eeaa95ba3b/full.png" alt="Clock example screenshot">
</picture>
An example visualizing an analog clock with hour, minute and seconds hands using Rerun Arrow3D primitives.
To build it from a checkout of the repository (requires a Rust toolchain):
```bash
cmake .
cmake --build . --target example_clock
./examples/cpp/clock/example_clock
```
+56
View File
@@ -0,0 +1,56 @@
#include <rerun.hpp>
#include <algorithm> // std::max
#include <cmath>
#include <string>
using namespace std::chrono;
constexpr float TAU = 6.28318530717958647692528676655900577f;
void log_hand(
const rerun::RecordingStream& rec, const char* name, seconds step, float angle, float length,
float width, uint8_t blue
) {
const auto tip = rerun::Vec3D{length * sinf(angle * TAU), length * cosf(angle * TAU), 0.0f};
const auto c = static_cast<uint8_t>(angle * 255.0f);
const auto color =
rerun::Color{static_cast<uint8_t>(255 - c), c, blue, std::max<uint8_t>(128, blue)};
rec.set_time_duration("sim_time", step);
rec.log(
std::string("world/") + name + "_pt",
rerun::Points3D(rerun::Position3D(tip)).with_colors(color)
);
rec.log(
std::string("world/") + name + "hand",
rerun::Arrows3D::from_vectors(rerun::Vector3D(tip))
.with_origins({{0.0f, 0.0f, 0.0f}})
.with_colors(color)
.with_radii({width * 0.5f})
);
}
int main() {
const float LENGTH_S = 20.0f;
const float LENGTH_M = 10.0f;
const float LENGTH_H = 4.0f;
const float WIDTH_S = 0.25f;
const float WIDTH_M = 0.4f;
const float WIDTH_H = 0.6f;
const int num_steps = 10000;
const auto rec = rerun::RecordingStream("rerun_example_clock");
rec.spawn().exit_on_failure();
rec.log_static("world", rerun::ViewCoordinates::RIGHT_HAND_Y_UP);
rec.log_static("world/frame", rerun::Boxes3D::from_half_sizes({{LENGTH_S, LENGTH_S, 1.0f}}));
for (int step = 0; step < num_steps; step++) {
log_hand(rec, "seconds", seconds(step), (step % 60) / 60.0f, LENGTH_S, WIDTH_S, 0);
log_hand(rec, "minutes", seconds(step), (step % 3600) / 3600.0f, LENGTH_M, WIDTH_M, 128);
log_hand(rec, "hours", seconds(step), (step % 43200) / 43200.0f, LENGTH_H, WIDTH_H, 255);
}
}