fix(nodes): coalesce node.children to [] in container renderers (#333)

Guards building/ceiling/site/wall renderers with `(node.children ?? [])` so a node whose `children` array is missing (legacy/unparsed scene data) no longer crashes the renderer with "Cannot read properties of undefined (reading 'map')" (EDITOR-C0). Matches the existing guard in roof/renderer.tsx and the Array.isArray check in the parametric renderer.

Note: the schema declares `children: z.array(...).default([])`, so this can only be hit by data that bypasses Zod normalization on load. This is a defense-in-depth crash-stopper; the deeper fix is to normalize/parse legacy nodes in migrateNodes (use-scene.ts) so missing arrays are repaired before render — tracked as a follow-up.
This commit is contained in:
Anton
2026-06-03 14:30:12 -04:00
committed by GitHub
parent 1256331aa6
commit 98eeb1da90
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ export const BuildingRenderer = ({ node }: { node: BuildingNode }) => {
rotation={[node.rotation[0], node.rotation[1], node.rotation[2]]}
{...handlers}
>
{node.children.map((childId) => (
{(node.children ?? []).map((childId) => (
<NodeRenderer key={childId} nodeId={childId} />
))}
</group>
+1 -1
View File
@@ -127,7 +127,7 @@ export const CeilingRenderer = ({ node }: { node: CeilingNode }) => {
scale={0}
visible={false}
/>
{node.children.map((childId) => (
{(node.children ?? []).map((childId) => (
<NodeRenderer key={childId} nodeId={childId} />
))}
</mesh>
+1 -1
View File
@@ -139,7 +139,7 @@ export const SiteRenderer = ({ node }: { node: SiteNode }) => {
return (
<group ref={ref} {...handlers}>
{/* Render children (buildings and items) */}
{node.children.map((childId) => (
{(node.children ?? []).map((childId) => (
<NodeRenderer key={childId} nodeId={childId as AnyNodeId} />
))}
+1 -1
View File
@@ -78,7 +78,7 @@ const WallRenderer = ({ node }: { node: WallNode }) => {
{...handlers}
/>
{node.children.map((childId) => (
{(node.children ?? []).map((childId) => (
<NodeRenderer key={`${node.id}:${childId}`} nodeId={childId} />
))}
</mesh>