Visitar URL original
fix(importer): record coordinates for models without meshes by elyrank · Pull Request #358 · ThatOpen/engine_fragment · GitHub
Skip to content

fix(importer): record coordinates for models without meshes - #358

Open
elyrank wants to merge 1 commit into
ThatOpen:mainfrom
elyrank:fix/grids-only-coordinates
Open

elyrank wants to merge 1 commit into
ThatOpen:mainfrom
elyrank:fix/grids-only-coordinates

Conversation

@elyrank

@elyrank elyrank commented Nov 10, 2026

Copy link
Copy Markdown

Description

Fixes #356.

IfcFileReader reported the coordination matrix as the model's coordinates only from the StreamMeshes callback, but GridReader always premultiplies every grid placement by that matrix. A model with no meshes (e.g. a grids-only IFC) kept identity coordinates while its grids were shifted, so FragmentsModels placed them off by the whole shift.

This moves the reporting into one helper, loadCoordinates(), called from the mesh callback as before and once more right before GridReader runs. It is a no-op once coordinates were reported, so models with meshes are unchanged.

How it was tested

  • New fixture resources/ifc/grids-only-georeferenced.ifc: a site at (500 km, 200 km, 12 m), one grid 10 m / 20 m / 3 m from it with a FootPrint curve representation, and no other elements.
  • New test in grid-reader.test.ts checks that the coordinates are non-zero and that the grid's transform origin minus the coordinates equals its IFC world placement in three.js axes, (500010, 15, -200020).
  • 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:
    • fixture: coordinates (0, 0, 0) and an error of 500 km before; (-500010, -15, 200020) and an error of 1e-11 m after.
    • grids-baseline.ifc, just_wall.ifc, school_str.ifc, dedup_repro.ifc: same coordinates before and 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 reported the coordination matrix only from the mesh callback,
but GridReader always premultiplies every grid placement by it. A model that
has no meshes (e.g. a grids-only IFC) kept identity coordinates while its
grids were shifted, so FragmentsModels placed them off by the whole shift.

Move the reporting into one helper and also call it before reading the
grids, so the coordinates always match the shift the grids were given.

Adds a grids-only-georeferenced.ifc fixture and a test that checks a grid's
origin minus the model coordinates equals its IFC world placement.

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: a model without meshes (e.g. grids only) records zero coordinates, so its grids load off by the coordination shift

1 participant