31 lines
1.6 KiB
PowerShell
31 lines
1.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
$root = $PSScriptRoot
|
|
$assets = @(
|
|
@{ Id = 'leafy_grass'; Folder = 'Vegetations' },
|
|
@{ Id = 'rock_ground'; Folder = 'Rocks' },
|
|
@{ Id = 'rocks_ground_05'; Folder = 'Gravel' },
|
|
@{ Id = 'coast_sand_02'; Folder = 'Sand' }
|
|
)
|
|
foreach ($asset in $assets) {
|
|
$dir = Join-Path $root "$($asset.Folder)/$($asset.Id)"
|
|
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
$files = Invoke-RestMethod "https://api.polyhaven.com/files/$($asset.Id)"
|
|
foreach ($kind in @('Diffuse', 'nor_gl', 'Rough')) {
|
|
$file = $files.$kind.'2k'.jpg
|
|
if (-not $file) { throw "Missing 2K JPEG $kind for $($asset.Id)" }
|
|
$destination = Join-Path $dir "$kind.jpg"
|
|
if (-not (Test-Path -LiteralPath $destination) -or (Get-FileHash -Algorithm MD5 -LiteralPath $destination).Hash.ToLowerInvariant() -ne $file.md5) {
|
|
Invoke-WebRequest -Uri $file.url -OutFile $destination
|
|
}
|
|
if ((Get-FileHash -Algorithm MD5 -LiteralPath $destination).Hash.ToLowerInvariant() -ne $file.md5) { throw "Checksum mismatch: $destination" }
|
|
}
|
|
}
|
|
$dir = Join-Path $root 'Heightdata/Copernicus'
|
|
New-Item -ItemType Directory -Force -Path $dir | Out-Null
|
|
$tile = 'Copernicus_DSM_COG_10_N46_00_E007_00_DEM'
|
|
$destination = Join-Path $dir "$tile.tif"
|
|
if (-not (Test-Path -LiteralPath $destination)) {
|
|
Invoke-WebRequest -Uri "https://copernicus-dem-30m.s3.amazonaws.com/$tile/$tile.tif" -OutFile $destination
|
|
}
|
|
if ((Get-FileHash -Algorithm MD5 -LiteralPath $destination).Hash.ToLowerInvariant() -ne 'd75ca33280e101b7e83b2fbef81e853b') { throw "Checksum mismatch: $destination" }
|