Skip to content

Finalize CesiumJS support for KHR_mesh_primitive_restart #13629

Description

@markschlosseratbentley

Summary

KHR_mesh_primitive_restart is the successor to the published EXT_mesh_primitive_restart extension. Instead of the EXT's mesh-level primitiveGroups JSON (one glTF primitive per sub-strip plus a separate "combined" accessor), the KHR extension has no JSON payload at all: a primitive's own indices accessor may contain inline "restart" values (the maximum value for the accessor's component type (0xff / 0xffff / 0xffffffff)). Each of these terminates the current strip and begins a new one. This allows many line strips to be batched into a single primitive, avoiding significant glTF JSON bloat for polyline-heavy assets.

We suspect CesiumJS already supports this format de facto, but not officially; there are no tests, no fixture, no docs, and no CHANGES entry.

Current state

  • ModelUtility.supportedExtensions already whitelists KHR_mesh_primitive_restart (added in Vector Tiles: Support 3DTILES_content_gltf_vector and EXT_mesh_polygon #13478 for vector tiles / 3DTILES_content_gltf), so extensionsRequired declaring it does not throw.
  • We believe the loader never validates the core-glTF prohibition on max-value indices, so inline restart values pass through GltfLoader transparently.
  • WebGL 2 should have PRIMITIVE_RESTART_FIXED_INDEX behavior permanently enabled for indexed draws, so restart works on the GPU with zero renderer changes.
  • The original EXT primitiveGroups format has explicit handling in getMeshPrimitives.js with fixture + 6 specs in GltfLoaderSpec.js; that support should be retained for backward compatibility (for now, at least).

Proposed work

  1. Test assets: add a KHR-format test asset (single LINE_STRIP primitive with inline restart values, extensionsUsed + extensionsRequired). Ideally a styled line-strip asset (BENTLEY_materials_line_style pattern + CUMULATIVE_DISTANCE) to exercise the styling path as well. Keep the existing EXT fixture (Specs/Data/Models/glTF-2.0/MeshPrimitiveRestart/).
  2. Specs: add a "loads model with KHR_mesh_primitive_restart" spec to GltfLoaderSpec.js. Keep the 6 existing EXT specs.
  3. Docs: update the Model.js JSDoc extension list to add KHR_mesh_primitive_restart linking Add KHR_mesh_primitive_restart KhronosGroup/glTF#2569.
  4. CHANGES.md entry? Unsure if necessary.
  5. (Optional; is this necessary?) Conformance: buildVectorGltfFromMVT.js emits inline 0xffffffff restart values in LINE_STRIP index buffers but does not seem to declare any restart extension in the generated glTF. Considering adding KHR_mesh_primitive_restart to its extensionsUsed/extensionsRequired.

Known limitations (to document, not necessarily fix)

  • WebGL 1: no hardware primitive restart; supporting it would require CPU index-splitting preprocessing. Not implemented.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions