Problems encountered during Gable Roof drawing
An error occurred while drawing the Gable Roof.
@boqiwen can you paste the error message as well?
@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 (
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:
roofstays 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 add pr?
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!