feat(core): expose generic host integration primitives

This commit is contained in:
Aymeric Rabot
2026-07-19 17:11:43 +02:00
parent 2084892383
commit 8f1c834e56
39 changed files with 2471 additions and 166 deletions
+25 -20
View File
@@ -11,6 +11,7 @@ import {
markToolCancelConsumed,
triggerSFX,
useEditor,
usePathDraftPreview,
} from '@pascal-app/editor'
import { useViewer } from '@pascal-app/viewer'
import { Html } from '@react-three/drei'
@@ -162,6 +163,30 @@ const PipeSegmentTool = () => {
const altAnchorRef = useRef<{ clientY: number; baseY: number } | null>(null)
const lastClientYRef = useRef<number | null>(null)
const displayStart =
draftStart &&
cursorPos &&
sloped &&
system === 'waste' &&
!startPortRef.current &&
!startBodyRef.current &&
!snapTarget &&
!altActive
? ([
draftStart[0],
draftStart[1] +
Math.hypot(cursorPos[0] - draftStart[0], cursorPos[2] - draftStart[2]) * DRAIN_SLOPE,
draftStart[2],
] as [number, number, number])
: draftStart
useEffect(() => {
usePathDraftPreview
.getState()
.setDraft('pipe-segment', displayStart ? [displayStart] : [], cursorPos, { diameter, system })
}, [cursorPos, diameter, displayStart, system])
useEffect(() => () => usePathDraftPreview.getState().clear('pipe-segment'), [])
useEffect(() => {
if (!activeLevelId) return
@@ -613,26 +638,6 @@ const PipeSegmentTool = () => {
if (!activeLevelId) return null
// Free waste start lifts at commit so the run falls ONTO the grid —
// mirror that here so the preview line / pill match the placed pipe.
// A snapped end (snapTarget set) keeps the start where it is.
const displayStart =
draftStart &&
cursorPos &&
sloped &&
system === 'waste' &&
!startPortRef.current &&
!startBodyRef.current &&
!snapTarget &&
!altActive
? ([
draftStart[0],
draftStart[1] +
Math.hypot(cursorPos[0] - draftStart[0], cursorPos[2] - draftStart[2]) * DRAIN_SLOPE,
draftStart[2],
] as [number, number, number])
: draftStart
const pillParts = cursorPos
? [
...(['x', 'y', 'z'] as const).map((axis, i) => ({