Sync monorepo PRs #243 and #248 to the open-source editor. Move/Rotate Building: - New move-building-tool with grid snapping, R/T rotation, and Esc cancel - Floating building action menu with move button - Building helper with keyboard shortcut hints - BuildingRenderer now applies position and rotation from node data Building-Relative Coordinate System: - GridEvent gains localPosition (building-local coords) - use-grid-events computes building-local intersection from building mesh - ToolManager wraps building-relative tools in a building-local <group> - All tools (wall, slab, ceiling, stair, roof, zone, polygon-editor, placement coordinator) updated to use event.localPosition - Placement coordinator adds worldToBuildingLocal helper for cursor position conversion 2D Floorplan Fix: - SVG layers wrapped in <g transform=rotate(...)> for building rotation - Pointer-to-plan conversion un-rotates when building is rotated - Grid events from 2D include localPosition Store Changes: - useEditor movingNode union includes BuildingNode - NodeActionMenu onDelete is now optional (buildings can move but not delete)
25 lines
734 B
TypeScript
25 lines
734 B
TypeScript
import { type BuildingNode, useRegistry } from '@pascal-app/core'
|
|
import { useRef } from 'react'
|
|
import type { Group } from 'three'
|
|
import { useNodeEvents } from '../../../hooks/use-node-events'
|
|
import { NodeRenderer } from '../node-renderer'
|
|
|
|
export const BuildingRenderer = ({ node }: { node: BuildingNode }) => {
|
|
const ref = useRef<Group>(null!)
|
|
|
|
useRegistry(node.id, node.type, ref)
|
|
const handlers = useNodeEvents(node, 'building')
|
|
return (
|
|
<group
|
|
position={node.position}
|
|
ref={ref}
|
|
rotation={[node.rotation[0], node.rotation[1], node.rotation[2]]}
|
|
{...handlers}
|
|
>
|
|
{node.children.map((childId) => (
|
|
<NodeRenderer key={childId} nodeId={childId} />
|
|
))}
|
|
</group>
|
|
)
|
|
}
|