Illustrates the optional vertical skirts on maps.

Giro3D version
THREE.js version
OpenLayers version
CRS
Memory usage (CPU)
Memory usage (GPU)
Frames
Clear color
Clear alpha
Status
Local clipping enabled
Capabilities
WebGL 2
Max texture units
Max texture size
Precision
Max fragment shader uniforms
Logarithmic depth buffer
Max shader attributes
Check shader errors
EXT_clip_control
EXT_color_buffer_float
EXT_color_buffer_half_float
EXT_conservative_depth
EXT_depth_clamp
EXT_float_blend
EXT_polygon_offset_clamp
EXT_texture_compression_bptc
EXT_texture_compression_rgtc
EXT_texture_filter_anisotropic
EXT_texture_mirror_clamp_to_edge
EXT_texture_norm16
NV_shader_noperspective_interpolation
OES_draw_buffers_indexed
OES_sample_variables
OES_shader_multisample_interpolation
OES_texture_float_linear
OVR_multiview2
WEBGL_clip_cull_distance
WEBGL_compressed_texture_astc
WEBGL_compressed_texture_etc
WEBGL_compressed_texture_etc1
WEBGL_compressed_texture_s3tc
WEBGL_compressed_texture_s3tc_srgb
WEBGL_debug_renderer_info
WEBGL_debug_shaders
WEBGL_lose_context
WEBGL_multi_draw
WEBGL_polygon_mode
WEBGL_stencil_texturing
MSAA
EDL
EDL Radius
EDL Strength
Inpainting
Inpainting steps
Inpainting depth contrib.
Point cloud occlusion
Type
FOV
Automatic plane computation
Far plane
Near plane
Max far plane
Min near plane
Width (pixels)
Height (pixels)
x
y
z
x
y
z
color
Enable cache
Default TTL (seconds)
Capacity (MB)
Capacity (entries)
Entries
Memory usage (approx)
Pending requests
Memory tracker
Identifier
Memory usage (CPU)
Memory usage (GPU)
Status
Render order
Enable
Plane normal X
Plane normal Y
Plane normal Z
Distance
Helper size
Negate plane
👁️ Visible
❄️ Freeze
🪟 Opacity
🔳 Show volumes
Volume color
Discard no-data values
Sidedness
Front
Depth test
Visible tiles
Reachable tiles
Loaded tiles
Complete paints
Cast shadow
Receive shadow
Show grid
Background
Background opacity
Show tiles outlines
Tile outline color
Show extent
Extent color
Show bounding spheres
Subdivision threshold
Show tile info
Image size
Elevation range
Layer info
Deformation
Wireframe
Tile subdivisions
Show collider meshes
Stitching
Enabled
Mode
LightBased
Hillshade intensity
Z factor
Hillshade zenith
Hillshade azimuth
Elevation layers only
Enable
Color
Opacity
X step
Y step
X Offset
Y Offset
Thickness
Enable
Color
Thickness
Opacity
Primary interval (m)
Secondary interval (m)
Brightness
Contrast
Saturation
Layer count
Render state
Normal
Layers
Identifier
Memory usage (CPU)
Memory usage (GPU)
Source CRS
Status
Resolution factor
Visible
Frozen
Interpretation
Loaded images
Blending mode
Normal
Brightness
Contrast
Saturation
Opacity
Show extent
Extent color
Enabled
Mode
Elevation
Lower bound
Upper bound
Type
Color space
Data type
Flip Y
Synchronous
CRS
Memory usage (CPU)
Memory usage (GPU)
Loaded/Requested
CRS
Zoom levels
Main URL
Inner source
Identifier
Memory usage (CPU)
Memory usage (GPU)
Source CRS
Status
Resolution factor
Visible
Frozen
Interpretation
Loaded images
Minimum elevation
Maximum elevation
Show extent
Extent color
Enabled
Mode
Elevation
Lower bound
Upper bound
Type
Color space
Data type
Flip Y
Synchronous
CRS
Memory usage (CPU)
Memory usage (GPU)
Loaded/Requested
CRS
Zoom levels
Main URL
Inner source
Show helpers
Show hidden objects
Name filter
Hierarchy
Properties
isObject3D
uuid
name
type
matrixAutoUpdate
matrixWorldAutoUpdate
matrixWorldNeedsUpdate
visible
castShadow
receiveShadow
frustumCulled
renderOrder
x
y
z
x
y
z
Parameters
0% © Mapbox

Skirts are vertical side on the edges of map tiles that give volume to maps.

index.js
import { AmbientLight, Color, DirectionalLight } from "three";
import { MapControls } from "three/examples/jsm/controls/MapControls.js";

import XYZ from "ol/source/XYZ.js";

import Instance from "@giro3d/giro3d/core/Instance.js";
import Coordinates from "@giro3d/giro3d/core/geographic/Coordinates.js";
import Extent from "@giro3d/giro3d/core/geographic/Extent.js";
import ColorLayer from "@giro3d/giro3d/core/layer/ColorLayer.js";
import ElevationLayer from "@giro3d/giro3d/core/layer/ElevationLayer.js";
import Map from "@giro3d/giro3d/entities/Map.js";
import { MapLightingMode } from "@giro3d/giro3d/entities/MapLightingOptions.js";
import MapboxTerrainFormat from "@giro3d/giro3d/formats/MapboxTerrainFormat.js";
import Inspector from "@giro3d/giro3d/gui/Inspector.js";
import TiledImageSource from "@giro3d/giro3d/sources/TiledImageSource.js";

function bindNumberInput(id, onChange) {
  const element = document.getElementById(id);
  if (!(element instanceof HTMLInputElement)) {
    throw new Error(
      "invalid binding element: expected HTMLInputElement, got: " +
        element.constructor.name,
    );
  }

  element.onchange = () => {
    onChange(element.valueAsNumber);
  };

  const callback = (v) => {
    element.value = v.toString();
    onChange(element.valueAsNumber);
  };

  return [callback, element.valueAsNumber, element];
}

function bindColorPicker(id, onChange) {
  const element = document.getElementById(id);
  if (!(element instanceof HTMLInputElement)) {
    throw new Error(
      "invalid binding element: expected HTMLInputElement, got: " +
        element.constructor.name,
    );
  }

  element.oninput = function oninput() {
    // Let's change the classification color with the color picker value
    const hexColor = element.value;
    onChange(new Color(hexColor));
  };

  const externalFunction = (v) => {
    element.value = `#${new Color(v).getHexString()}`;
    onChange(element.value);
  };

  return [externalFunction, new Color(element.value), element];
}

// Chamonix Mont-Blanc coordinates
const poi = new Coordinates("EPSG:4326", 6.8697, 45.9231)
  .as("EPSG:3857")
  .toVector3();

const extentSize = 30_000;
const extent = Extent.fromCenterAndSize(
  "EPSG:3857",
  { x: poi.x, y: poi.y },
  extentSize,
  extentSize,
);

const instance = new Instance({
  target: "view",
  crs: extent.crs,
  backgroundColor: null,
});

let skirtDepth = 0;
let skirtColor = new Color("#faf0e6");

const center = extent.centerAsVector3();

const directionalLight = new DirectionalLight("white", 3);
const ambientLight = new AmbientLight("white", 1);

directionalLight.position.set(center.x - 5000, center.y - 2000, 10000);
directionalLight.target.position.copy(center);

instance.add(directionalLight);
instance.add(directionalLight.target);
instance.add(ambientLight);

directionalLight.updateMatrixWorld(true);
directionalLight.target.updateMatrixWorld(true);

let map;

const key =
  "pk.eyJ1IjoidG11Z3VldCIsImEiOiJjbGJ4dTNkOW0wYWx4M25ybWZ5YnpicHV6In0.KhDJ7W5N3d1z3ArrsDjX_A";

// Adds a XYZ elevation layer with MapBox terrain RGB tileset
const elevationLayer = new ElevationLayer({
  extent,
  preloadImages: true,
  resolutionFactor: 1 / 8,
  minmax: { min: 0, max: 5000 },
  source: new TiledImageSource({
    format: new MapboxTerrainFormat(),
    source: new XYZ({
      url: `https://api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${key}`,
      projection: "EPSG:3857",
      crossOrigin: "anonymous",
    }),
  }),
});

// Adds a XYZ color layer with MapBox satellite tileset
const satelliteLayer = new ColorLayer({
  extent,
  resolutionFactor: 1.5,
  preloadImages: true,
  source: new TiledImageSource({
    source: new XYZ({
      url: `https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.webp?access_token=${key}`,
      projection: "EPSG:3857",
      crossOrigin: "anonymous",
    }),
  }),
});

function load() {
  map = new Map({
    extent,
    lighting: {
      enabled: true,
      mode: MapLightingMode.LightBased,
      elevationLayersOnly: true,
    },
    subdivisionThreshold: 1,
    terrain: {
      segments: 64,
      enabled: true,
      skirts: {
        enabled: true,
        depth: skirtDepth,
      },
    },
    backgroundColor: skirtColor,
  });

  instance.add(map);

  map.addLayer(elevationLayer);
  map.addLayer(satelliteLayer);
}

load();

const controls = new MapControls(instance.view.camera, instance.domElement);

instance.view.camera.position.set(
  poi.x - extentSize - 15000,
  poi.y - extentSize - 15000,
  35_000,
);
controls.target.set(poi.x, poi.y, 2000);

instance.view.setControls(controls);

Inspector.attach("inspector", instance);

bindNumberInput("skirt-depth", (v) => {
  skirtDepth = v;
  if (map) {
    instance.remove(map);
  }
  load();
});

bindColorPicker("color", (newColor) => {
  skirtColor = new Color(newColor);
  if (map) {
    map.backgroundColor = skirtColor;
    instance.notifyChange(map);
  }
});
index.html
<!doctype html>
<html lang="en">
  <head>
    <title>Map vertical skirts</title>
    <meta charset="UTF-8" />
    <meta name="name" content="map_skirts" />
    <meta
      name="description"
      content="Illustrates the optional vertical skirts on maps."
    />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="icon" href="https://giro3d.org/images/favicon.svg" />
    <link
      href="https://giro3d.org/assets/bootstrap-custom.css"
      rel="stylesheet"
    />
    <script src="https://giro3d.org/assets/bootstrap.bundle.min.js"></script>
    <link
      rel="stylesheet"
      type="text/css"
      href="https://giro3d.org/latest/examples/css/example.css"
    />

    <style>
      #view canvas {
        background: rgb(132, 170, 182);
        background: radial-gradient(
          circle,
          rgba(132, 170, 182, 1) 0%,
          rgba(37, 44, 48, 1) 100%
        );
      }
    </style>
  </head>

  <body>
    <div id="view" class="m-0 p-0 w-100 h-100"></div>
    <div
      id="inspector"
      class="position-absolute top-0 start-0 mh-100 overflow-auto"
    ></div>

    <div class="side-pane-with-status-bar">
      <div class="card">
        <div class="card-header">Parameters</div>
        <div class="card-body">
          <!-- Color -->
          <label class="form-check-label w-100 mb-2" for="color"
            >Skirt color</label
          >
          <div class="input-group">
            <input
              type="color"
              class="form-control form-control-color float-end"
              id="color"
              value="#faf0e6"
              title="color"
              autocomplete="off"
            />
          </div>

          <!-- Skirt depth -->
          <label for="skirt-depth" class="form-label mt-2"
            >Skirt depth (meters)</label
          >
          <div class="input-group">
            <input
              type="number"
              min="-10000"
              max="10000"
              value="0"
              step="500"
              class="form-control"
              id="skirt-depth"
              autocomplete="off"
            />
          </div>
        </div>
      </div>
    </div>

    <script type="module" src="index.js"></script>
    <script>
      /* activate popovers */
      const popoverTriggerList = [].slice.call(
        document.querySelectorAll('[data-bs-toggle="popover"]'),
      );
      popoverTriggerList.map(
        // bootstrap is used as script in the template, disable warning about undef
        // eslint-disable-next-line no-undef
        (popoverTriggerEl) =>
          new bootstrap.Popover(popoverTriggerEl, {
            trigger: "hover",
            placement: "left",
            content: document.getElementById(
              popoverTriggerEl.getAttribute("data-bs-content"),
            ).innerHTML,
            html: true,
          }),
      );
    </script>
  </body>
</html>
package.json
{
    "name": "map_skirts",
    "dependencies": {
        "@giro3d/giro3d": "0.43.2"
    },
    "devDependencies": {
        "vite": "^3.2.3"
    },
    "scripts": {
        "start": "vite",
        "build": "vite build"
    }
}