Skip to content

Commit

Permalink
Merge pull request #20 from Klebert-Engineering/feature/intro-cesium-…
Browse files Browse the repository at this point in the history
…usage
  • Loading branch information
josephbirkner authored Aug 9, 2023
2 parents 667ae0b + 41283e2 commit 7e8c6d7
Show file tree
Hide file tree
Showing 28 changed files with 367 additions and 60,727 deletions.
38 changes: 26 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,37 @@ project(erdblick)
include(FetchContent)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_FLAGS "-Wall")

# Treat warnings as errors, with some exceptions for Cesium.
set (ERDBLICK_CXX_FLAGS
"-Wall -Wno-error=sign-conversion -Wno-sign-compare -Wno-sign-conversion -Wno-unused-local-typedefs -Wno-comment -Wno-effc++")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ERDBLICK_CXX_FLAGS} -Wno-bool-compare")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ERDBLICK_CXX_FLAGS} -Wno-error=shorten-64-to-32")
endif()

# External dependencies.

message("Building for ${CMAKE_SYSTEM_NAME}.")

FetchContent_Declare(tinygltf
GIT_REPOSITORY "https://github.com/syoyo/tinygltf.git"
GIT_TAG "v2.8.9"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(tinygltf)
FetchContent_Declare(glm
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
GIT_TAG "0.9.9.8"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(glm)

# Fetch cesium-native
set(CESIUM_TESTS_ENABLED OFF)
set(CESIUM_GLM_STRICT_ENABLED OFF)
set(CESIUM_TRACING_ENABLED OFF)
set(DRACO_JS_GLUE OFF CACHE BOOL "Disable JS glue for Draco" FORCE)
FetchContent_Declare(
cesiumnative
GIT_REPOSITORY https://github.com/Klebert-Engineering/cesium-native.git
GIT_TAG "main"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(cesiumnative)

FetchContent_Declare(mapget
GIT_REPOSITORY "https://github.com/Klebert-Engineering/mapget"
Expand All @@ -28,12 +48,6 @@ FetchContent_Declare(yaml-cpp
GIT_SHALLOW ON)
FetchContent_MakeAvailable(yaml-cpp)

FetchContent_Declare(glm
GIT_REPOSITORY "https://github.com/g-truc/glm.git"
GIT_TAG "0.9.9.8"
GIT_SHALLOW ON)
FetchContent_MakeAvailable(glm)

add_subdirectory(libs/core)

add_custom_target(static-web-files ALL
Expand Down
6 changes: 4 additions & 2 deletions ci/10_linux_build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ ci_dir="$(realpath ${BASH_SOURCE[0]} | xargs -I{} dirname {})"
source "$ci_dir/emsdk/emsdk_env.sh"
cd "$ci_dir/.."

export EMSCRIPTEN="$ci_dir/emsdk/upstream/emscripten"

rm -rf build && mkdir build
cd build
mkdir deps
mkdir assets
emcmake cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF ..
cmake --build . -- -j
5 changes: 4 additions & 1 deletion ci/20_linux_rebuild.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ set -e

ci_dir="$(realpath ${BASH_SOURCE[0]} | xargs -I{} dirname {})"
source "$ci_dir/emsdk/emsdk_env.sh"

export EMSCRIPTEN="$ci_dir/emsdk/upstream/emscripten"

cd "$ci_dir/../build"
cmake --build .
cmake --build . -- -j
9 changes: 6 additions & 3 deletions libs/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ target_include_directories(erdblick-core

target_link_libraries(erdblick-core
PUBLIC
tinygltf
Cesium3DTilesWriter
CesiumGeospatial
CesiumGltf
CesiumGltfWriter
glm
mapget-model
yaml-cpp
glm)
yaml-cpp)

3 changes: 2 additions & 1 deletion libs/core/include/erdblick/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class SharedUint8Array
std::shared_ptr<std::vector<uint8_t>> getArray();

void writeToArray(const char* start, const char* end);
void writeToArray(std::string& content);
void writeToArray(std::string const& content);
void writeToArray(std::vector<std::byte> const& content);

std::string toString() const;

Expand Down
15 changes: 14 additions & 1 deletion libs/core/include/erdblick/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ class FeatureLayerRenderer
{
public:
FeatureLayerRenderer();
void render(

/**
* Convert a TileFeatureLayer to a GLB buffer.
* Returns the cartesian origin of the tile.
*/
mapget::Point render(
const FeatureLayerStyle& style,
const std::shared_ptr<mapget::TileFeatureLayer>& layer,
SharedUint8Array& result);

/**
* Create a Cesium tileset-wrapper for a GLB-converted TileFeatureLayer URL.
*/
void makeTileset(
std::string const& tileGlbUrl,
mapget::Point const& origin,
SharedUint8Array& glbResultBuffer);
};

Expand Down
6 changes: 5 additions & 1 deletion libs/core/src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ EMSCRIPTEN_BINDINGS(FeatureLayerRendererBind)
.function("getSize", &SharedUint8Array::getSize)
.function("getPointer", &SharedUint8Array::getPointer);

////////// Point
em::class_<mapget::Point>("Point");

////////// FeatureLayerStyle
em::class_<FeatureLayerStyle>("FeatureLayerStyle").constructor<SharedUint8Array&>();

Expand All @@ -50,7 +53,8 @@ EMSCRIPTEN_BINDINGS(FeatureLayerRendererBind)
////////// FeatureLayerRenderer
em::class_<FeatureLayerRenderer>("FeatureLayerRenderer")
.constructor()
.function("render", &FeatureLayerRenderer::render);
.function("render", &FeatureLayerRenderer::render)
.function("makeTileset", &FeatureLayerRenderer::makeTileset);

////////// TestDataProvider
em::class_<TestDataProvider>("TestDataProvider")
Expand Down
9 changes: 8 additions & 1 deletion libs/core/src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void SharedUint8Array::writeToArray(const char* start, const char* end)
array_.assign(start, end);
}

void SharedUint8Array::writeToArray(std::string& content)
void SharedUint8Array::writeToArray(std::string const& content)
{
array_.assign(content.begin(), content.end());
}
Expand All @@ -43,4 +43,11 @@ std::shared_ptr<std::vector<uint8_t>> SharedUint8Array::getArray()
return std::make_shared<std::vector<uint8_t>>(array_);
}

void SharedUint8Array::writeToArray(const std::vector<std::byte>& content)
{
array_.reserve(content.size());
for (auto& byte : content)
array_.emplace_back((uint8_t)byte);
}

}
Loading

0 comments on commit 7e8c6d7

Please sign in to comment.