Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
2c830aa
WIP experiment with wasm32
brendan-duncan Aug 4, 2025
8926336
add missing cmake updates
brendan-duncan Aug 6, 2025
7703c0c
disable blend2d and CesiumVectorData from wasm builds
brendan-duncan Aug 6, 2025
70185b6
changes to get compilation going
brendan-duncan Aug 6, 2025
22f50ce
re-add blend2d to wasm build
brendan-duncan Aug 7, 2025
c71c326
change MAXIMUM_MEMORY to wasm32 limit
brendan-duncan Aug 8, 2025
0ab8381
Fix up wasm32 cmake build
brendan-duncan Aug 8, 2025
852ba2d
fix non-wasm build
brendan-duncan Aug 12, 2025
ca2f95b
comment out use of std::formatter
brendan-duncan Aug 19, 2025
f465fd9
wasm build updates
brendan-duncan Aug 23, 2025
a5e925c
wasm build fix
brendan-duncan Aug 23, 2025
8329b52
Start working on size_t warnings on 32-bit
brendan-duncan Aug 23, 2025
1e1663b
Add HAS_FUTIME to emscripten defines for tidyhtml
brendan-duncan Aug 24, 2025
1ff5014
32-bit warning fixes
brendan-duncan Aug 25, 2025
88c3716
clean up 32-bit warmings
brendan-duncan Aug 25, 2025
6e43196
install blend2d for wasm builds
brendan-duncan Aug 26, 2025
a37c73e
Add option to build wasm64
brendan-duncan Aug 27, 2025
b7330ea
fix typo from wasm32 builds
brendan-duncan Aug 27, 2025
90d1c96
disable blend2d wasm install for now
brendan-duncan Sep 1, 2025
3f416be
Add EM_CONFIG to VCPKG_ENV_PASSTHROUGH_UNTRACKED
brendan-duncan Sep 4, 2025
1aa2788
Merge branch 'main' into experiment_wasm
brendan-duncan Sep 20, 2025
56f2dc8
fix wasm build after merger
brendan-duncan Sep 21, 2025
50b1530
don't need specialized wasm compiler flags anymore
brendan-duncan Sep 22, 2025
1c13589
Merge branch 'main' into experiment_wasm
brendan-duncan Oct 5, 2025
abf28c5
Fix merge errors
brendan-duncan Oct 5, 2025
99f1404
clean-up merge changes
brendan-duncan Oct 5, 2025
733bc2c
clean up to match main
brendan-duncan Oct 5, 2025
de5ed6e
code cleanup
brendan-duncan Oct 5, 2025
3b1b0f9
don't check in package-lock.json
brendan-duncan Oct 6, 2025
cf18fd0
Merge branch 'main' into experiment_wasm
brendan-duncan Oct 19, 2025
c754a5f
clang-format
brendan-duncan Oct 20, 2025
9787c25
Attemp to add wasm build to CI.
kring Oct 20, 2025
d66de9a
Better job name.
kring Oct 20, 2025
5d44fd4
fix wasm build errors
brendan-duncan Oct 21, 2025
167a728
Merge remote-tracking branch 'origin/main' into experiment_wasm
kring Oct 21, 2025
39c1ac8
Use the overlay triplets.
kring Oct 21, 2025
f245947
clang-format
kring Oct 21, 2025
fb01236
Make openssl configure script exectuable.
kring Oct 21, 2025
f54db5f
clang-tidy
kring Oct 21, 2025
b40e3ec
Use wasmXX-emscripten-cesium triplets.
kring Oct 22, 2025
614458e
Don't use ezvcpg for wasm build, attempt to run tests.
kring Oct 22, 2025
e4c0150
Back to ezvcpkg for now.
kring Oct 22, 2025
62ef573
Don't let OpenSSL try to dlopen in wasm builds.
kring Oct 22, 2025
8d3d70a
set EXIT_RUNTIME so test runner exits
brendan-duncan Oct 23, 2025
f6d83fb
Fix dodgy store of a reference to a temporary in a global variable.
kring Oct 24, 2025
d0427df
Consistently use non-header-only spdlog.
kring Oct 27, 2025
000d27c
Remove ada-url overlay port.
kring Oct 27, 2025
a72529e
Add Emscripten 4.0.13 build.
kring Oct 27, 2025
97883d1
Add overlay port for ada-url in Emscripten 3.1.39 build.
kring Oct 27, 2025
e390112
Debug failed sparse checkout.
kring Oct 27, 2025
5e554d3
More github actions flailing.
kring Oct 27, 2025
84a9574
Don't let actions/checkout delete everything.
kring Oct 27, 2025
eaf77c0
Don't remove directory.
kring Oct 27, 2025
a93b082
Remove debug step.
kring Oct 27, 2025
0e53ac9
Remove blend2d overlay.
kring Oct 27, 2025
c913278
Re-add blend2d overlay port.
kring Oct 27, 2025
60faebd
Update vcpkg and remove blend2d overlay port.
kring Oct 28, 2025
077e9f3
Disable cpp-httplib on Emscripten, rather than downgrading it.
kring Oct 28, 2025
f66d9da
More thorough removal of cpp-httplib from wasm builds.
kring Oct 28, 2025
b800bec
Revert to 2025.09.17 version of vcpkg.
kring Oct 28, 2025
3080d41
Re-add blend2d overlay port.
kring Oct 28, 2025
12ee3f0
Revert change that was only necessary after glm upgrade.
kring Oct 28, 2025
52e5736
Try again to remove blend2d and upgrade vcpkg.
kring Oct 29, 2025
8d9ee6f
Suppress incorrect clang-tidy warning.
kring Oct 29, 2025
16be63a
Use KTX-Software branch from my PR.
kring Nov 4, 2025
25cc1e8
Only install [core] features of ktx.
kring Nov 4, 2025
0aaaee2
Fix hash and feature name.
kring Nov 4, 2025
b33640a
Use vcpkg from my PR.
kring Nov 5, 2025
de6f08b
Try removing openssl overlay port again.
kring Nov 5, 2025
1e9f39d
Add no-dso option on Emscripten 3.1.39.
kring Nov 5, 2025
d1bffc5
Switch back to main vcpkg repo.
kring Nov 5, 2025
b23852c
Merge remote-tracking branch 'origin/main' into experiment_wasm
kring Nov 6, 2025
5f06bc1
Minor tweaks for coding conventions.
kring Nov 6, 2025
eecc1e9
Fix (and simplify) test data embedding.
kring Nov 6, 2025
58e8baf
Remove workaround for tidyhtml.
kring Nov 6, 2025
221611f
Fix data build that I thought was working...
kring Nov 6, 2025
00c35a1
Remove tidyhtml specific compiler option.
kring Nov 6, 2025
ccba7b2
More coding convention tweaks.
kring Nov 6, 2025
f42203e
Improve web server for testing WebAssembly builds.
kring Nov 6, 2025
22e9dbc
Remove unnecessary package.json.
kring Nov 6, 2025
c96485f
Yet another attempt at the data build.
kring Nov 6, 2025
65b6c86
clang-tidy
kring Nov 6, 2025
d9d3130
Clean up and centralize compiler flags.
kring Nov 7, 2025
110382a
Add WASM64 build.
kring Nov 7, 2025
198c22c
Fix typo.
kring Nov 7, 2025
77715ec
Fix 64-bit Emscripten build.
kring Nov 7, 2025
3f372f7
Use Node 24 for WASM64 tests.
kring Nov 7, 2025
8b86d7f
Use any version >= 24.
kring Nov 7, 2025
c5ea386
Add option to disable libjpeg-turbo.
kring Nov 10, 2025
d92188a
Implement 32-bit hash combine function from Boost.
kring Nov 10, 2025
e9a9415
Better implementation of hashing on 32/64 bit platforms.
kring Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,70 @@ jobs:
run: |
cd build
ctest -V
EmscriptenBuild:
strategy:
fail-fast: false
matrix:
version: [ "3.1.39", "4.0.13" ]
memory: [ "32", "64" ]
exclude:
- version: "3.1.39"
memory: "64"
name: Emscripten v${{matrix.version}} ${{matrix.memory}}bit memory
env:
CACHE_KEY: "emscripten-${{matrix.version}}-${{matrix.memory}}"
runs-on: windows-2022
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Use NodeJS 24 for WebAssembly 64-bit memory support
if: ${{ matrix.memory == '64' }}
uses: actions/setup-node@v6
with:
node-version: '>=24'
- name: Checkout vcpkg 2025.02.14 packages for use with Emscripten 3.1.39
if: ${{ matrix.version == '3.1.39' }}
uses: actions/checkout@v4
with:
repository: microsoft/vcpkg
clean: false
ref: 2025.02.14
path: extern/vcpkg/temp
sparse-checkout-cone-mode: false
sparse-checkout: |
ports/ada-url
- name: Move overlay ports to the correct location
if: ${{ matrix.version == '3.1.39' }}
run: |
mv extern/vcpkg/temp/ports/* extern/vcpkg/ports/
- name: Add OpenSSL "no-dso" option on older Emscripten versions
if: ${{ matrix.version == '3.1.39' }}
run: |
echo "
if(PORT MATCHES "openssl")
set(VCPKG_CONFIGURE_MAKE_OPTIONS "no-dso")
endif()
" >> extern/vcpkg/triplets/wasm32-emscripten-cesium.cmake
- name: Install latest CMake 3 and Ninja
uses: lukka/get-cmake@latest
with:
cmakeVersion: "3.31.6"
- name: Install nasm
uses: ilammy/setup-nasm@v1
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{matrix.version}}
- name: Verify
run: emcc -v
- name: Compile Debug Configuration
run: |
$env:VCPKG_ROOT="$env:VCPKG_INSTALLATION_ROOT"
$MEMORYPROPERTY="${{matrix.memory}}" -eq "64" ? "-DCESIUM_WASM64=ON" : ""
emcmake cmake -B build -S . -DCMAKE_BUILD_TYPE=Debug $MEMORYPROPERTY
cmake --build build --config Debug --parallel
- name: Test Debug Configuration
run: |
node build/CesiumNativeTests/cesium-native-tests.js
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build
build-*
doxygen
Testing
node_modules
Expand All @@ -8,7 +9,5 @@ CMakeSettings.json
.cache
*.DS_Store
test.db
build-wsl
.idea
build-debug
clang-tidy.log
85 changes: 75 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ if (NOT VCPKG_LIBRARY_LINKAGE)
set(VCPKG_LIBRARY_LINKAGE static)
endif()

get_filename_component(toolchainFile "${CMAKE_TOOLCHAIN_FILE}" NAME)
if(toolchainFile STREQUAL "Emscripten.cmake")
set(CESIUM_TARGET_WASM ON)
# Include the toolchain directly as ezvcpkg will overwrite the
# toolchain before it's loaded
include(${CMAKE_TOOLCHAIN_FILE})
endif()

# By default, Use ezvcpkg to install dependencies. But don't use
# ezvcpkg if it appears that this configuration is using vcpkg
# manifest mode already, either by building cesium-native directly,
Expand All @@ -24,6 +32,13 @@ endif()

option(CESIUM_USE_EZVCPKG "use ezvcpkg helper" ${CESIUM_USE_EZVCPKG_DEFAULT})
option(CESIUM_DISABLE_CURL "Disable cesium-native's use of libcurl" OFF)
option(CESIUM_DISABLE_LIBJPEG_TURBO "Disable cesium-native's use of libjpeg-turbo. JPEG images will be decoded with STB instead." OFF)
option(CESIUM_WASM64 "Enable 64-bit WebAssembly target" OFF)

if (CESIUM_TARGET_WASM)
# Make sure curl is disabled on wasm builds, as it is not supported.
set(CESIUM_DISABLE_CURL ON)
endif()

if(CESIUM_USE_EZVCPKG)
# Keep vcpkg from running in manifset mode. It will try to because
Expand All @@ -50,6 +65,15 @@ if (NOT VCPKG_TRIPLET)
elseif(DETECTED_VCPKG_TRIPLET STREQUAL "x64-windows")
# cesium-native requires static linking on Windows
set(VCPKG_TRIPLET "x64-windows-static-md")
elseif(DETECTED_VCPKG_TRIPLET STREQUAL "wasm32-emscripten")
# Use our custom triplet for wasm builds. Most importantly, this
# enables multithreading support. Also switch to 64-bit wasm if
# requested.
if (CESIUM_WASM64)
set(VCPKG_TRIPLET "wasm64-emscripten-cesium")
else()
set(VCPKG_TRIPLET "wasm32-emscripten-cesium")
endif()
else()
set(VCPKG_TRIPLET "${DETECTED_VCPKG_TRIPLET}")
endif()
Expand Down Expand Up @@ -87,6 +111,10 @@ if (NOT VCPKG_OVERLAY_TRIPLETS)
endif()
endif()

if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/extern/vcpkg/triplets")
list(APPEND VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_SOURCE_DIR}/extern/vcpkg/triplets")
endif()

message(STATUS "VCPKG_OVERLAY_TRIPLETS ${VCPKG_OVERLAY_TRIPLETS}")

# These packages are used in the public headers of Cesium libraries, so we need to distribute the headers and binaries
Expand All @@ -98,13 +126,13 @@ set(PACKAGES_PUBLIC asyncplusplus expected-lite fmt glm rapidjson spdlog stb ada
# to distribute the binaries for linking, but not the headers, as downstream consumers don't need them
# OpenSSL and abseil are both dependencies of s2geometry
set(PACKAGES_PRIVATE
abseil draco ktx modp-base64 meshoptimizer openssl s2geometry
libjpeg-turbo sqlite3 tinyxml2 libwebp zlib-ng picosha2
earcut-hpp cpp-httplib[core] libmorton zstd
abseil draco ktx[core] modp-base64 meshoptimizer openssl s2geometry
sqlite3 tinyxml2 libwebp zlib-ng picosha2
earcut-hpp libmorton zstd
)

# asmjit needed by blend2d on non-iOS platforms (iOS doesn't support JIT)
if(NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS")
# asmjit needed by blend2d on non-iOS platforms (iOS and Wasm don't support JIT)
if(NOT CESIUM_TARGET_WASM AND NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS")
list(APPEND PACKAGES_PRIVATE blend2d asmjit)
else()
# Use [core] feature to disable default jit feature.
Expand All @@ -115,16 +143,37 @@ if(NOT CESIUM_DISABLE_CURL)
list(APPEND PACKAGES_PRIVATE curl)
endif()

if(NOT CESIUM_DISABLE_LIBJPEG_TURBO)
list(APPEND PACKAGES_PRIVATE libjpeg-turbo)
endif()

# We use cpp-httplib to host a local web server for OAuth2 authorization. That's not
# going to work at all on the web, and the latest versions of cpp-httplib only support
# 64-bit platforms anyway, so skip it entirely for WebAssembly builds.
if(NOT CESIUM_TARGET_WASM)
list(APPEND PACKAGES_PRIVATE "cpp-httplib[core]")
endif()

# Packages only used for testing
set(PACKAGES_TEST doctest)

if(CESIUM_TARGET_WASM)
# vcpkg will attempt to second-guess our CMAKE_C_COMPILER setting, choosing to go with the value of CC instead.
# While normally this is the correct value to go with, for wasm we need to be using emcc and em++.
# So we set CC and CXX to emcc and em++ here so vcpkg will pick them up properly.
# Does this make sense? No. Does it work? Somehow. ¯\_(ツ)_/¯
set(ENV{CC} ${CMAKE_C_COMPILER})
set(ENV{CXX} ${CMAKE_CXX_COMPILER})
endif()

if(CESIUM_USE_EZVCPKG)
set(PACKAGES_ALL ${PACKAGES_PUBLIC})
list(APPEND PACKAGES_ALL ${PACKAGES_PRIVATE})
list(APPEND PACKAGES_ALL ${PACKAGES_TEST})

ezvcpkg_fetch(
COMMIT 2025.09.17
COMMIT afc0a2e01ae104a2474216a2df0e8d78516fd5af
REPO microsoft/vcpkg
PACKAGES ${PACKAGES_ALL}
# Clean the build trees after building, so that we don't use a ton a disk space on the CI cache
CLEAN_BUILDTREES
Expand All @@ -149,6 +198,16 @@ project(cesium-native
LANGUAGES CXX C
)

if(CESIUM_TARGET_WASM)
if(CESIUM_WASM64)
set(CMAKE_SIZEOF_VOID_P 8)
else()
set(CMAKE_SIZEOF_VOID_P 4)
endif()
# Tells emscripten to output an HTML harness for the generated WASM
set(CMAKE_EXECUTABLE_SUFFIX ".html")
endif()

include(GNUInstallDirs)
include(CMakeDependentOption)

Expand Down Expand Up @@ -318,9 +377,7 @@ find_package(doctest CONFIG REQUIRED)
find_package(draco CONFIG REQUIRED)
find_package(expected-lite CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)
find_package(httplib CONFIG REQUIRED)
find_package(Ktx CONFIG REQUIRED)
find_package(libjpeg-turbo CONFIG REQUIRED)
find_package(libmorton CONFIG REQUIRED)
find_package(meshoptimizer CONFIG REQUIRED)
find_package(OpenSSL REQUIRED)
Expand All @@ -331,15 +388,23 @@ find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(WebP CONFIG REQUIRED)
find_package(zlib-ng CONFIG REQUIRED)

# asmjit should not be included with iOS builds as iOS doesn't support JIT compilation.
if(NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS")
# asmjit should not be included with iOS or Wasm builds as they don't support JIT compilation.
if(NOT CESIUM_TARGET_WASM AND NOT IOS AND NOT VCPKG_CMAKE_SYSTEM_NAME MATCHES "iOS")
find_package(asmjit CONFIG REQUIRED)
endif()

if(NOT CESIUM_DISABLE_CURL)
find_package(CURL REQUIRED)
endif()

if(NOT CESIUM_DISABLE_LIBJPEG_TURBO)
find_package(libjpeg-turbo CONFIG REQUIRED)
endif()

if(NOT CESIUM_TARGET_WASM)
find_package(httplib CONFIG REQUIRED)
endif()

# Private Library (s2geometry)
add_subdirectory(extern EXCLUDE_FROM_ALL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class SubtreeAvailability {
bool isContentAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId,
uint64_t contentId) const noexcept;
size_t contentId) const noexcept;

/**
* @brief Determines if content for a given tile in the octree is available.
Expand All @@ -247,7 +247,7 @@ class SubtreeAvailability {
bool isContentAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId,
uint64_t contentId) const noexcept;
size_t contentId) const noexcept;

/**
* @brief Determines if content for a given tile in the subtree is available.
Expand All @@ -262,7 +262,7 @@ class SubtreeAvailability {
bool isContentAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
uint64_t contentId) const noexcept;
size_t contentId) const noexcept;

/**
* @brief Sets the availability state of the content for a given tile in the
Expand All @@ -276,7 +276,7 @@ class SubtreeAvailability {
void setContentAvailable(
const CesiumGeometry::QuadtreeTileID& subtreeId,
const CesiumGeometry::QuadtreeTileID& tileId,
uint64_t contentId,
size_t contentId,
bool isAvailable) noexcept;

/**
Expand All @@ -291,7 +291,7 @@ class SubtreeAvailability {
void setContentAvailable(
const CesiumGeometry::OctreeTileID& subtreeId,
const CesiumGeometry::OctreeTileID& tileId,
uint64_t contentId,
size_t contentId,
bool isAvailable) noexcept;

/**
Expand All @@ -309,7 +309,7 @@ class SubtreeAvailability {
void setContentAvailable(
uint32_t relativeTileLevel,
uint64_t relativeTileMortonId,
uint64_t contentId,
size_t contentId,
bool isAvailable) noexcept;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,10 @@ void copyStringsToBuffers(
for (const auto& str : arrayMember.GetArray()) {
OffsetType byteLength = static_cast<OffsetType>(
str.GetStringLength() * sizeof(rapidjson::Value::Ch));
std::memcpy(valueBuffer.data() + offset, str.GetString(), byteLength);
std::memcpy(
valueBuffer.data() + offset,
str.GetString(),
size_t(byteLength));
std::memcpy(
offsetBuffer.data() + offsetIndex * sizeof(OffsetType),
&offset,
Expand Down Expand Up @@ -1075,8 +1078,7 @@ void updateStringArrayProperty(
++it;
}

const uint64_t totalByteLength =
totalCharCount * sizeof(rapidjson::Value::Ch);
const size_t totalByteLength = totalCharCount * sizeof(rapidjson::Value::Ch);
std::vector<std::byte> valueBuffer;
std::vector<std::byte> stringOffsetBuffer;
PropertyComponentType stringOffsetType = PropertyComponentType::None;
Expand Down
2 changes: 1 addition & 1 deletion Cesium3DTilesContent/src/PntsToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ void decodeDracoMetadata(
const std::unique_ptr<draco::PointCloud>& pPointCloud,
rapidjson::Document& batchTableJson,
PntsContent& parsedContent) {
const uint64_t pointsLength = parsedContent.pointsLength;
const size_t pointsLength = parsedContent.pointsLength;
std::vector<std::byte>& data = parsedContent.dracoBatchTableBinary;

const auto& dracoMetadataSemantics = parsedContent.dracoMetadataSemantics;
Expand Down
Loading
Loading