Skip to content

Conversation

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Jan 12, 2026

Description

Fixes gsplat sorting not working in release builds when targeting ES2020.

Problem

When SWC transpiles to ES2020, static class fields are moved outside the class body:

// ES2022 (native)
class Foo {
    static BAR = 42;
}

// ES2020 (transpiled)
class Foo {}
Foo.BAR = 42;

Since GSplatSortBinWeights is stringified via .toString() and injected into a web worker, the static properties were lost after transpilation. This caused NUM_BINS and WEIGHT_TIERS to be undefined in the worker, breaking the sorting algorithm.

Solution

Convert static class fields to static getters, which are ES2015 syntax and remain inside the class body when stringified:

// Before
static NUM_BINS = 32;

// After  
static get NUM_BINS() {
    return 32;
}

Testing

  • Verified gsplat sorting works correctly with npm run build && npm run serve
  • Both WebGL and WebGPU backends affected and fixed

@mvaligursky mvaligursky self-assigned this Jan 12, 2026
@mvaligursky mvaligursky added the area: graphics Graphics related issue label Jan 12, 2026
@mvaligursky mvaligursky requested a review from a team January 12, 2026 15:42
@mvaligursky mvaligursky merged commit 130f340 into main Jan 12, 2026
7 checks passed
@mvaligursky mvaligursky deleted the mv-es2020-compatibility branch January 12, 2026 15:51
mvaligursky added a commit that referenced this pull request Jan 12, 2026
…8373)

Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants