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