import { type SpawnNode, useLiveTransforms, useRegistry } from '@pascal-app/core' import { useMemo, useRef } from 'react' import type { Group } from 'three' import { Color, Shape } from 'three' import { useNodeEvents } from '../../../hooks/use-node-events' import useViewer from '../../../store/use-viewer' const SPAWN_COLOR = new Color('#22c55e') export const SpawnRenderer = ({ node }: { node: SpawnNode }) => { const ref = useRef(null!) const handlers = useNodeEvents(node, 'spawn') const liveTransform = useLiveTransforms((state) => state.get(node.id)) const walkthroughMode = useViewer((state) => state.walkthroughMode) useRegistry(node.id, 'spawn', ref) const materialProps = useMemo( () => ({ color: SPAWN_COLOR, emissive: SPAWN_COLOR, emissiveIntensity: 0.08, metalness: 0.03, roughness: 0.42, }), [], ) const arrowShape = useMemo(() => { const shape = new Shape() // Positive local Y becomes negative world Z after the -90deg X rotation below, // so this tip points "forward" for the player/spawn direction. shape.moveTo(0, 0.24) shape.lineTo(-0.18, -0.14) shape.lineTo(0.18, -0.14) shape.closePath() return shape }, []) return ( ) }