Skip to content

Drive splat orientation from DataTable.transform instead of per-format hardcoding#885

Merged
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:xf-dev
May 8, 2026
Merged

Drive splat orientation from DataTable.transform instead of per-format hardcoding#885
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:xf-dev

Conversation

@slimbuck
Copy link
Copy Markdown
Member

@slimbuck slimbuck commented May 8, 2026

Summary

  • Replace the hardcoded per-format getOrientation(filename) switch in asset-loader.ts with the transform returned by splat-transform's readers, so each format's authoring frame is described by data rather than baked into the editor.
  • loadGSplatData now returns { gsplatData, transform }; the asset loader hands the Quat rotation straight to Splat.
  • Splat's constructor takes a Quat and applies it via setLocalRotation, replacing the previous Vec3 Euler + setEulerAngles (avoids the deg→quat→deg round-trip and removes Euler ambiguity).

Why

The getOrientation switch returned (0, 0, 180) for PLY/splat/KSplat/SOG, (90, 0, 180) for LCC, and (0, 0, 0) for SPZ. Splat-transform already tags every DataTable with the correct authoring-frame Transform (PLY/splat/KSplat/SOG/SPZ → Transform.PLY = (0, 0, 180); LCC → (90, 0, 180)), so the per-format switch was duplicating information that the loader already provides — and the SPZ entry was wrong (this is what made SPZ files load 180° rotated relative to the equivalent PLY).

Compatibility

Requires @playcanvas/splat-transform with the SPZ coordinate-system fix (in flight at playcanvas/splat-transform#230). With that version, SPZ files load with the same (0, 0, 180) orientation as PLY and the two render identically.

Test plan

  • Load a .ply scene — orientation matches previous behavior.
  • Load the same scene as .spz — now orients identically to the PLY (was 180° around Y before).
  • Load a .lcc scene — orientation matches previous behavior (90, 0, 180).
  • Load .sog, .compressed.ply, .ksplat, .splat — all orient as before.

@slimbuck slimbuck requested a review from Copilot May 8, 2026 13:55
@slimbuck slimbuck self-assigned this May 8, 2026
@slimbuck slimbuck added the bug Something isn't working label May 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes how SuperSplat determines the initial orientation of loaded splat assets by using the authoring-frame transform provided by @playcanvas/splat-transform readers, instead of hardcoded per-format orientation logic in the editor. It also switches the Splat constructor to accept/apply a quaternion rotation directly to avoid Euler ambiguity and unnecessary conversions.

Changes:

  • Removed per-format getOrientation(filename) logic and now drive orientation from DataTable.transform.
  • Updated loadGSplatData to return { gsplatData, transform } and threaded that through the asset loader.
  • Updated Splat to take a Quat and apply it via setLocalRotation instead of Euler degrees.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/splat.ts Updates Splat construction to take/apply a Quat rotation (replacing Euler-based orientation).
src/io/read/loader.ts Changes loadGSplatData to return both converted GSplatData and the source Transform.
src/asset-loader.ts Removes hardcoded orientation switch and passes transform.rotation to Splat.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/asset-loader.ts
@slimbuck slimbuck marked this pull request as ready for review May 8, 2026 14:11
@slimbuck slimbuck requested a review from a team May 8, 2026 14:11
@slimbuck slimbuck merged commit 440bbf7 into playcanvas:main May 8, 2026
6 checks passed
Copy link
Copy Markdown

@josetiburcio55-cpu josetiburcio55-cpu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants