Skip to content

WebGPU: measurement dimension lines use unsupported GLSL LineMaterial #51

Description

@rihokirss

Length measurement labels and endpoint markers appear in the WebGPU viewer, but the dimension lines are missing. The console reports:

THREE.NodeBuilder: Material "LineMaterial" is not compatible.

Versions

  • @thatopen-platform/components-beta: 3.5.18
  • @thatopen-platform/components-front-beta: 3.5.16
  • @thatopen-platform/fragments-beta: 3.5.9
  • three: 0.185.0
  • Linux, Chromium, hardware WebGPU on AMD RDNA 3 (no WebGL fallback)

Reproduction

In an initialized beta world using the WebGPU PostproductionRenderer, create a stock LengthMeasurement and add a line within the camera view:

import * as THREE from "three/webgpu";
import * as OBCF from "@thatopen-platform/components-front-beta";

const measurement = components.get(OBCF.LengthMeasurement);
measurement.world = world;
measurement.list.add(new OBCF.Line(
  new THREE.Vector3(-2, -2, 0),
  new THREE.Vector3(2, 2, 2),
));
// Camera looking at the origin from approximately (8, 7, 10).

console.log(measurement.linesMaterial.type); // "LineMaterial"
console.log(measurement.linesMaterial.isShaderMaterial); // true

Expected: a visible colored dimension line joining the endpoints, alongside its label.

Actual: labels/endpoints render, but the line does not; the material compatibility warning appears. The equivalent measurement works in a WebGL viewer.

Source-level cause

The beta Measurement base class creates a NearPlaneLineMaterial, which extends the GLSL LineMaterial from three/examples/jsm/lines/LineMaterial.js. DimensionLine.createLine() also constructs the WebGL LineSegments2. The WebGPU path needs the node-material equivalents.

Locally verified workaround

In the WebGPU build only:

  1. Replace the default measurement line material with Line2NodeMaterial, preserving the color and 2 px width, with depthTest: false and depthWrite: false.
  2. Give this adapter material an isLineMaterial flag so the current DimensionLine factory creates segment geometry instead of a plain THREE.Line.
  3. Replace the dimension's line object with three/examples/jsm/lines/webgpu/LineSegments2.js, reusing its LineSegmentsGeometry and material. Keep it under the same parent and update dimension.lineElement, so geometry updates, visibility, and disposal continue to work.

This restored the lines without modifying the beta packages. A guard leaves an upstream node material untouched when one becomes available.

Validation

  • Reproduced using the stock beta LengthMeasurement class, independently of a custom measurement subclass.
  • On the same hardware WebGPU backend, a 9×9 pixel region around a point one-quarter along the stock dimension had 0 blue pixels before and 21 after applying the adapter; the compatibility warning disappeared.
  • Verified preview and committed lines in free and edge modes, plus a local orthogonal mode built on createLineElement(); checked resize, hide/show, and deletion.
  • Verified both the minimal FXAA pipeline and enabled postproduction; no new browser rendering errors.
  • The stable WebGL viewer's measurements still pass the same checks.

Could the beta measurement factory select the appropriate line material and line object for the renderer? The shared Measurement base suggests other measurement tools using its fat-line material may also need the same adaptation; those tools were not tested here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions