Repository navigation
PLYExporter: Fix export of quantized attributes. - #35192
Merged
Mugen87 merged 4 commits intoOct 24, 2026
Merged
Conversation
Collaborator
|
Sorry, but the suggested code was incredible confusing. I think it's better if we adapt the policy in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: -
Description
Since #33625,
PLYExporterpicks each PLY property type from the attribute's typed array. That breaks quantized geometry: positions and normals are transformed to world space before they are written, and normalized attributes are dequantized bygetX(), so the values are fractional. With an integer property type they get rounded (ASCII) or truncated (binary).Quantized glTF assets (
KHR_mesh_quantization, e.g. gltfpack or glTF-Transform output) hit this. Loadingexamples/models/gltf/facecap.glbwithGLTFLoaderand exporting the scene with{ binary: true }, which is what File > Export > PLY (BINARY) does in the editor, writesushort x/y/zandchar nx/ny/nz. Read back withPLYLoader, every coordinate of the 4368 vertices is 0, 1 or 65535, and every normal is 0. The ASCII export rounds coordinates to integers and normals to -1, 0 or 1. Before r185 these attributes were always written asfloat.This PR writes positions and normals as
floatagain (doublefor aFloat64Array, as now), and normalized uv and custom attributes asfloat. Colors keep their current handling. Geometries with float attributes export the same bytes as before. There was no unit test file forPLYExporter, so I added one that exports a small quantized mesh in both formats and reads it back.Ran:
npm run lint,npm run test-unit,npm run test-unit-addons(the new test fails without the fix) andnpx eslinton the changed files.Checked: the exported facecap bounding box now matches the dequantized one in three.js, and float meshes, colors, points,
Float64Arraypositions and custom attributes export byte-identical output before and after.