CLI, along with several examples, plus model downloading
This commit is contained in:
1 parent
4f9e73a418
commit
51ace681a7
22 files changed
+1804
-18
No files matched your search
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/sh
|
||||
# Downloads the NASA spacecraft models the example scenes use into
|
||||
# examples/models/nasa/ (gitignored).
|
||||
#
|
||||
# Source: NASA 3D Resources (https://github.com/nasa/NASA-3D-Resources), pinned
|
||||
# to one commit and checked by sha256. NASA describes the collection as free and
|
||||
# without copyright; NASA's logos and insignia have their own restrictions, see
|
||||
# https://www.nasa.gov/nasa-brand-center/images-and-media/.
|
||||
#
|
||||
# Most of the collection is stored with Draco mesh compression, which this
|
||||
# crate's loader does not read yet, so those models are decoded with
|
||||
# gltf-transform (Node, via npx). Node is needed only here, not to build or run
|
||||
# anything.
|
||||
#
|
||||
# landsat8 Landsat 8, 85k triangles, meters.
|
||||
# icesat2 ICESat-2, 752k triangles, meters; the heavy model for benchmarks.
|
||||
# ssl1300 A Space Systems Loral 1300 communications satellite, 182k
|
||||
# triangles; its units are 10 cm, so scenes scale it by 0.1.
|
||||
# ostm OSTM / Jason-2, 65k triangles; its units are about 29 cm, so
|
||||
# scenes scale it by 3.5 (3.5 x 1.9 m, solar panels 1.4 x 0.9 m).
|
||||
# ace Advanced Composition Explorer, 26k triangles; its units are about
|
||||
# 5 mm, so scenes scale it by 0.00485 (a 1.6 m body).
|
||||
|
||||
set -eu
|
||||
|
||||
commit=11ebb4ee043715aefbba6aeec8a61746fad67fa7
|
||||
base="https://raw.githubusercontent.com/nasa/NASA-3D-Resources/$commit/3D%20Models"
|
||||
gltf_transform='@gltf-transform/cli@4.5.1'
|
||||
|
||||
out="$(cd "$(dirname "$0")/.." && pwd)/examples/models/nasa"
|
||||
mkdir -p "$out"
|
||||
work=$(mktemp -d)
|
||||
# npx runs from its own empty directory; downloads are only ever passed as paths.
|
||||
tools=$(mktemp -d)
|
||||
trap 'command rm -rf "$work" "$tools"' EXIT
|
||||
|
||||
# name, path under 3D Models/, sha256 of the download, whether it is Draco-compressed
|
||||
fetch() {
|
||||
name=$1 path=$2 sum=$3 draco=$4
|
||||
if [ -f "$out/$name.glb" ]; then
|
||||
echo "have $name"
|
||||
return
|
||||
fi
|
||||
echo "fetching $name"
|
||||
curl -fsSL "$base/$path" -o "$work/$name.glb"
|
||||
echo "$sum $work/$name.glb" | sha256sum -c --quiet -
|
||||
if [ "$draco" = yes ]; then
|
||||
(cd "$tools" && npx --yes "$gltf_transform" copy "$work/$name.glb" "$work/$name.decoded.glb" >/dev/null)
|
||||
mv "$work/$name.decoded.glb" "$out/$name.glb"
|
||||
else
|
||||
mv "$work/$name.glb" "$out/$name.glb"
|
||||
fi
|
||||
}
|
||||
|
||||
fetch landsat8 "Landsat%208/Landsat%208.glb" \
|
||||
8b599e867be20589cd35e55ed1d46da104299b430b1827b548a25d3fad0a314d yes
|
||||
fetch icesat2 "Ice,%20Clouds,%20and%20Land%20Elevation%20Satellite-2%20(ICESat-2)%20(C)/Ice,%20Clouds,%20and%20Land%20Elevation%20Satellite-2%20(ICESat-2)%20(C).glb" \
|
||||
a842b4d58c32bb612b258489cf9680d439fdb73186ad793deb8fcdd6aa93a8a9 yes
|
||||
fetch ssl1300 "Space%20Systems%20Loral%20(SSL-1300)/Space%20Systems%20Loral%20(SSL-1300).glb" \
|
||||
63cd644d67ee49ab79e313bb6cb0495e9f6072d421a84e116c2c3f9c40bf9c0c yes
|
||||
fetch ostm "Ocean%20Surface%20Topography%20Mission%20(OSTM%20Jason-2)/Ocean%20Surface%20Topography%20Mission%20(OSTM%20Jason-2).glb" \
|
||||
61c58c2b1c9afce77186a781f699aad5b026573b2cb52e4476d7afd57eae2d04 yes
|
||||
fetch ace "Advanced%20Composition%20Explorer/Advanced%20Composition%20Explorer.glb" \
|
||||
b03a394e57b6af3a1f3700f450d94a67dd3eaec8a00e125d2d005bd1359b6e9c no
|
||||
|
||||
echo "models in $out"
|
||||
Reference in new issue
Block a user