Skip to content

fix(conversions): re-center mesh/polyhedron geometry so TransformControls attaches at the visual center - #33

Open
ericgozzi wants to merge 1 commit into
fix/viewer-connection-frame-budgeted-drainfrom
fix/center-geometry-transform-controls
Open

ericgozzi wants to merge 1 commit into
fix/viewer-connection-frame-budgeted-drainfrom
fix/center-geometry-transform-controls

Conversation

@ericgozzi

@ericgozzi ericgozzi commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • mesh.vertices/polyhedron.vertices arrive as absolute world coordinates and were written into the BufferGeometry unchanged, so the resulting THREE.Mesh always had its .position at the world origin. That renders correctly, but anything that reads .position/matrixWorld breaks. In particular, TransformControls.attach put the gizmo at the world origin instead of at the mesh.
  • New centerGeometry(), used by both meshToThreeJS and polyhedronToThreeJS, moves the geometry by -center and sets mesh.position = center. Every vertex stays at the same world position, and the object's origin is now at its visual center.

Stacked on #32; merge that first. Backend counterpart: compas-dev/compas_threejs#59 (scale-mode object_transform pivot fix).

Test plan

  • new tests/datastructures.test.ts (both conversions)
  • format, lint, typecheck, test, build:app, build:library

🤖 Generated with Claude Code

…rols attaches at the visual center

mesh.vertices/polyhedron.vertices arrive as absolute world coordinates and
get written into the BufferGeometry as-is, so the returned THREE.Mesh's own
.position stayed at the world origin no matter where the mesh actually sits.
That's invisible for rendering (the geometry itself is already in the right
place), but it broke anything reading .position/matrixWorld instead of the
geometry - notably TransformControls.attach, which planted the transform
gizmo at the world origin instead of the mesh's visual center.

Adds centerGeometry(), used by both meshToThreeJS and polyhedronToThreeJS:
translates the geometry by -center and sets mesh.position to that center,
keeping every rendered vertex at the same world position while giving the
object an origin a gizmo (or anything else keyed off object position) finds
where the mesh actually is.

Adds tests/datastructures.test.ts, covering both conversions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant