Skip to content

fix(importer): keep transform x direction at the same precision as y - #357

Open
elyrank wants to merge 1 commit into
ThatOpen:mainfrom
elyrank:fix/transform-x-direction-precision
Open

elyrank wants to merge 1 commit into
ThatOpen:mainfrom
elyrank:fix/transform-x-direction-precision

Conversation

@elyrank

@elyrank elyrank commented Nov 10, 2026

Copy link
Copy Markdown

Description

Fixes #355.

IfcFileReader.decompose() and SpaceBoundaryReader.decompose() rounded the x direction of each transform to 3 decimals while the y direction and position kept 5. For placements rotated by a non-round angle this skews the basis, so elements drift up to ~0.5 mm per metre. This rounds x with the same precision as y (ap).

Side effect: local-transform dedup hashes now keep x at 5 decimals, like y, so a model can get slightly more distinct local transforms.

FragmentsModels/src/edit/element.ts also has const p = 1000, but there it is only a change-detection check, so it is left alone.

How it was tested

  • New fixture resources/ifc/rotated-placement.ifc: one 10 m extruded box placed at 10° about Z.
  • New test in ifc-file-reader.test.ts imports it and compares every world vertex (transform applied, getCoordinates() subtracted) with the analytic corners, tolerance 0.1 mm.
  • I could not run yarn install / vitest in my environment, so the suite was not run locally. Instead I applied the same edit to a copy of the published 3.6.1 dist/index.cjs and ran the same check with Node and web-ifc 0.0.78 on the fixture: max vertex error 2.0 mm before, 0.022 mm after.

What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following:

  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Follow the Conventional Commits v1.0.0 standard for PR naming.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves.
  • Ideally, include relevant tests that fail without this PR but pass with it.

🤖 Generated with Claude Code

IfcFileReader.decompose() and SpaceBoundaryReader.decompose() rounded the
x direction to 3 decimals while the y direction and position kept 5. For a
placement rotated by a non-round angle this skews the basis, so the far end
of a 10 m element moves by about 2 mm. Round x with the same precision as y.

Adds a rotated-placement.ifc fixture and a test that compares the imported
world vertices with their analytic positions.

Co-Authored-By: Claude Opus 5.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.

IfcImporter rounds a transform's x direction to 3 decimals while y and position keep 5, so rotated elements drift ~0.5 mm/m

1 participant