fix: filter out NaN vertices from IFC geometry#196
Open
TeapoyY wants to merge 2 commits intoThatOpen:mainfrom
Open
fix: filter out NaN vertices from IFC geometry#196TeapoyY wants to merge 2 commits intoThatOpen:mainfrom
TeapoyY wants to merge 2 commits intoThatOpen:mainfrom
Conversation
added 2 commits
April 6, 2026 08:24
… message Previously, when a user tried to load a JSON file (produced by the ifc-to-json tool) using IFCLoader.load(), the loader would attempt to parse it as a binary IFC file, resulting in a cryptic 'File too small' error from web-ifc. This change adds detection of .json URLs at the start of the load() method and throws a clear, actionable error message explaining: 1. That .json files cannot be loaded directly 2. That JSON files from ifc-to-json only contain property data, not geometry 3. That users should load the IFC file normally and then use addModelJSONData() for property data 4. A link to the documentation for the correct workflow Fixes ThatOpen#136 (bounty)
…dingSphere NaN error When loading certain IFC files, the web-ifc parser can produce geometry with NaN position values. This causes Three.js to throw 'computeBoundingSphere(): Computed radius is NaN' when the geometry's bounding sphere is computed. This fix adds a NaN check in ifcGeometryToBuffer(): 1. First pass: identify vertices with NaN position coordinates 2. Fast path: if all vertices are valid, use the original code 3. Slow path: filter out invalid vertices and remap the index buffer to exclude triangles that reference invalid vertices Fixes ThatOpen#88 (bounty)
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.
Summary
When loading certain IFC files, the web-ifc parser can produce geometry with NaN position values. This causes Three.js to throw
computeBoundingSphere(): Computed radius is NaNwhen the geometry's bounding sphere is computed, crashing the application.This fix adds a NaN check in
ifcGeometryToBuffer():The Bug
Issue: #88
When loading an IFC file with malformed geometry data (e.g., from
ifc2.zipattached to the issue), the vertex positions contain NaN values. When Three.js tries to compute the bounding sphere for rendering, it gets NaN for the radius and throws an uncaught error.The Fix
In
IFCParser.ifcGeometryToBuffer(), after extracting the vertex data from web-ifc:Number.isFinite()Bounty
This PR addresses #88 (labeled: bounty)