MCPcopy
hub / github.com/pascalorg/editor / commitSlabDrawing

Function commitSlabDrawing

packages/nodes/src/slab/tool.tsx:62–73  ·  view source on GitHub ↗
(levelId: LevelNode['id'], points: Array<[number, number]>)

Source from the content-addressed store, hash-verified

60}
61
62function commitSlabDrawing(levelId: LevelNode['id'], points: Array<[number, number]>): string {
63 const { createNode, nodes } = useScene.getState()
64 const slabCount = Object.values(nodes).filter((n) => n.type === 'slab').length
65 const name = `Slab ${slabCount + 1}`
66 // A placed slab preset seeds `toolDefaults.slab` (thickness, material, …)
67 // before the tool activates; the drawn polygon always wins.
68 const defaults = useEditor.getState().toolDefaults.slab ?? {}
69 const slab = SlabNode.parse({ ...defaults, name, polygon: points })
70 createNode(slab, levelId)
71 triggerSFX('sfx:structure-build')
72 return slab.id
73}
74
75export const SlabTool: React.FC = () => {
76 const cursorRef = useRef<Group>(null)

Callers 2

onGridClickFunction · 0.85
onGridDoubleClickFunction · 0.85

Calls 2

triggerSFXFunction · 0.90
createNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…