Display a 3D Tiles point cloud.

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
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 updates
Opacity
Show volumes
Cast shadow
Receive shadow
Error target
Point size
Brightness
Contrast
Saturation
Enabled
Mode
Elevation
Lower bound
Upper bound
Layers
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
# Coordinate Distance to camera
Double-click on the scene for picking
100%
index.js
import { Vector3 } from "three";
import { MapControls } from "three/examples/jsm/controls/MapControls.js";

import Instance from "@giro3d/giro3d/core/Instance.js";
import Tiles3D from "@giro3d/giro3d/entities/Tiles3D.js";
import Inspector from "@giro3d/giro3d/gui/Inspector.js";

const tmpVec3 = new Vector3();

Instance.registerCRS(
  "EPSG:2154",
  "+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs",
);

const instance = new Instance({
  target: "view",
  crs: "EPSG:2154",
  backgroundColor: 0xcccccc,
});

// Configure Point Cloud
const pointcloud = new Tiles3D({
  url: "https://3d.oslandia.com/3dtiles/eglise_saint_blaise_arles/tileset.json",
});

function placeCamera(position, lookAt) {
  instance.view.camera.position.set(position.x, position.y, position.z);
  instance.view.camera.lookAt(lookAt);

  const controls = new MapControls(instance.view.camera, instance.domElement);
  controls.target.copy(lookAt);
  controls.enableDamping = true;
  controls.dampingFactor = 0.25;
  instance.view.setControls(controls);

  instance.notifyChange(instance.view.camera);
}

// add pointcloud to scene
function initializeCamera() {
  const bbox = pointcloud.getBoundingBox();

  instance.view.camera.far = 2.0 * bbox.getSize(tmpVec3).length();

  const ratio = bbox.getSize(tmpVec3).x / bbox.getSize(tmpVec3).z;
  const position = bbox.min
    .clone()
    .add(bbox.getSize(tmpVec3).multiply(new Vector3(0, 0, ratio * 0.5)));
  const lookAt = bbox.getCenter(tmpVec3);
  lookAt.z = bbox.min.z;
  placeCamera(position, lookAt);
}

instance.add(pointcloud).then(initializeCamera);

Inspector.attach("inspector", instance);

const resultsTable = document.getElementById("results-body");
const formatter = new Intl.NumberFormat();

function format(point) {
  return `x: ${formatter.format(point.x)}\n
            y: ${formatter.format(point.y)}\n
            z: ${formatter.format(point.z)}`;
}

instance.domElement.addEventListener("dblclick", (e) => {
  const picked = instance.pickObjectsAt(e, { radius: 5, limit: 10 });

  if (picked.length === 0) {
    const row = document.createElement("tr");
    const count = document.createElement("th");
    count.setAttribute("scope", "row");
    count.innerText = "-";
    const coordinates = document.createElement("td");
    coordinates.innerText = "-";
    const distanceToCamera = document.createElement("td");
    distanceToCamera.innerText = "-";
    row.append(count, coordinates, distanceToCamera);
    resultsTable.replaceChildren(row);
  } else {
    const rows = picked.map((p, i) => {
      const row = document.createElement("tr");
      const count = document.createElement("th");
      count.setAttribute("scope", "row");
      count.innerText = `${i + 1}`;
      const coordinates = document.createElement("td");
      coordinates.innerHTML = format(p.point);
      const distanceToCamera = document.createElement("td");
      distanceToCamera.innerText = formatter.format(p.distance);
      row.append(count, coordinates, distanceToCamera);
      return row;
    });
    resultsTable.replaceChildren(...rows);
  }
});
index.html
<!doctype html>
<html lang="en">
  <head>
    <title>3D Tiles Point Cloud</title>
    <meta charset="UTF-8" />
    <meta name="name" content="pointcloud" />
    <meta name="description" content="Display a 3D Tiles point cloud." />
    <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/next/examples/css/example.css"
    />
  </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-body" style="max-width: 30vw; overflow: auto">
          <!-- Result table -->
          <table class="table small">
            <thead>
              <tr>
                <th scope="col">#</th>
                <th scope="col">Coordinate</th>
                <th scope="col">Distance to camera</th>
              </tr>
            </thead>
            <tbody id="results-body">
              <tr>
                <th scope="row" colspan="4">
                  Double-click on the scene for picking
                </th>
              </tr>
            </tbody>
          </table>
        </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": "pointcloud",
    "dependencies": {
        "@giro3d/giro3d": "git+https://gitlab.com/giro3d/giro3d.git"
    },
    "devDependencies": {
        "vite": "^3.2.3"
    },
    "scripts": {
        "start": "vite",
        "build": "vite build"
    }
}