editor icon indicating copy to clipboard operation
editor copied to clipboard

Problems encountered during Gable Roof drawing

Open boqiwen opened this issue 8 months ago • 5 comments

An error occurred while drawing the Gable Roof.

Image Image

boqiwen avatar Mar 24 '26 16:03 boqiwen

@boqiwen can you paste the error message as well?

isaacxavierzarspada avatar Mar 24 '26 16:03 isaacxavierzarspada

@boqiwen can you paste the error message as well?你能粘贴错误信息吗?

Cannot read properties of undefined (reading 'toFixed') ../../packages/editor/src/components/ui/sidebar/panels/site-panel/roof-tree-node.tsx (46:36) @ RoofTreeNode

44 | // Calculate dimensions: length × total width (leftWidth + rightWidth) 45 | const totalWidth = node.leftWidth + node.rightWidth

46 | const sizeLabel = ${node.length.toFixed(1)}×${totalWidth.toFixed(1)}m | ^ 47 | const defaultName = Roof (${sizeLabel}) 48 | 49 | return (

boqiwen avatar Mar 24 '26 16:03 boqiwen

I reproduced this on current main and confirmed the crash.

Root cause: the sidebar/tree UI was still reading roof dimensions from the parent roof node (length, leftWidth, rightWidth), but the actual canonical roof geometry now lives on child roof-segment nodes. When a newly created or migrated roof didn’t have those legacy parent fields, RoofTreeNode hit undefined.toFixed(...).

I fixed this from the model layer instead of only adding a null guard:

  • roof stays a container node
  • new roofs always create a child roof-segment
  • scene migration repairs broken roofs that have no segment child
  • the sidebar/panel now read dimensions from the primary roof-segment

After the change, drawing a gable roof no longer crashes and older broken roof objects are repaired on load.

yash27-lab avatar Mar 24 '26 20:03 yash27-lab

@yash27-lab add pr?

kleenkanteen avatar Mar 26 '26 04:03 kleenkanteen

This has been fixed on main. The sidebar tree node was reading roof dimensions (length, leftWidth, rightWidth) directly from the parent roof node, but those properties could be undefined for newly created or migrated roofs — causing the Cannot read properties of undefined (reading 'toFixed') crash.

The fix refactored the tree node to read geometry from child roof-segment nodes instead, which is where the canonical dimensions live. Drawing a gable roof no longer crashes, and older roof objects are handled correctly on load.

Thanks for reporting @boqiwen, and thanks @yash27-lab for the solid root cause analysis!

open-pascal avatar Apr 07 '26 14:04 open-pascal