Fix opening remounts after merged wall reparenting
This commit is contained in:
@@ -173,7 +173,14 @@ function buildWallMergePlans(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
const [primary, secondary] = candidates
|
const sortedCandidates = [...candidates].sort((a, b) => {
|
||||||
|
const attachmentDiff = (b.children?.length ?? 0) - (a.children?.length ?? 0)
|
||||||
|
if (attachmentDiff !== 0) {
|
||||||
|
return attachmentDiff
|
||||||
|
}
|
||||||
|
return a.id.localeCompare(b.id)
|
||||||
|
})
|
||||||
|
const [primary, secondary] = sortedCandidates
|
||||||
if (
|
if (
|
||||||
!primary ||
|
!primary ||
|
||||||
!secondary ||
|
!secondary ||
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { type DoorNode, useRegistry } from '@pascal-app/core'
|
import { type DoorNode, useRegistry, useScene } from '@pascal-app/core'
|
||||||
import { useMemo, useRef } from 'react'
|
import { useLayoutEffect, useMemo, useRef } from 'react'
|
||||||
import type { Mesh } from 'three'
|
import type { Mesh } from 'three'
|
||||||
import { useNodeEvents } from '../../../hooks/use-node-events'
|
import { useNodeEvents } from '../../../hooks/use-node-events'
|
||||||
import { createMaterial, DEFAULT_DOOR_MATERIAL } from '../../../lib/materials'
|
import { createMaterial, DEFAULT_DOOR_MATERIAL } from '../../../lib/materials'
|
||||||
@@ -8,6 +8,9 @@ export const DoorRenderer = ({ node }: { node: DoorNode }) => {
|
|||||||
const ref = useRef<Mesh>(null!)
|
const ref = useRef<Mesh>(null!)
|
||||||
|
|
||||||
useRegistry(node.id, 'door', ref)
|
useRegistry(node.id, 'door', ref)
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
useScene.getState().markDirty(node.id)
|
||||||
|
}, [node.id])
|
||||||
const handlers = useNodeEvents(node, 'door')
|
const handlers = useNodeEvents(node, 'door')
|
||||||
const isTransient = !!(node.metadata as Record<string, unknown> | null)?.isTransient
|
const isTransient = !!(node.metadata as Record<string, unknown> | null)?.isTransient
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export const WallRenderer = ({ node }: { node: WallNode }) => {
|
|||||||
</mesh>
|
</mesh>
|
||||||
|
|
||||||
{node.children.map((childId) => (
|
{node.children.map((childId) => (
|
||||||
<NodeRenderer key={childId} nodeId={childId} />
|
<NodeRenderer key={`${node.id}:${childId}`} nodeId={childId} />
|
||||||
))}
|
))}
|
||||||
</mesh>
|
</mesh>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useRegistry, type WindowNode } from '@pascal-app/core'
|
import { useRegistry, useScene, type WindowNode } from '@pascal-app/core'
|
||||||
import { useMemo, useRef } from 'react'
|
import { useLayoutEffect, useMemo, useRef } from 'react'
|
||||||
import type { Mesh } from 'three'
|
import type { Mesh } from 'three'
|
||||||
import { useNodeEvents } from '../../../hooks/use-node-events'
|
import { useNodeEvents } from '../../../hooks/use-node-events'
|
||||||
import { createMaterial, DEFAULT_WINDOW_MATERIAL } from '../../../lib/materials'
|
import { createMaterial, DEFAULT_WINDOW_MATERIAL } from '../../../lib/materials'
|
||||||
@@ -8,6 +8,9 @@ export const WindowRenderer = ({ node }: { node: WindowNode }) => {
|
|||||||
const ref = useRef<Mesh>(null!)
|
const ref = useRef<Mesh>(null!)
|
||||||
|
|
||||||
useRegistry(node.id, 'window', ref)
|
useRegistry(node.id, 'window', ref)
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
useScene.getState().markDirty(node.id)
|
||||||
|
}, [node.id])
|
||||||
const handlers = useNodeEvents(node, 'window')
|
const handlers = useNodeEvents(node, 'window')
|
||||||
const isTransient = !!(node.metadata as Record<string, unknown> | null)?.isTransient
|
const isTransient = !!(node.metadata as Record<string, unknown> | null)?.isTransient
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user