Use live snap settings in polygon editor and slab actions
This commit is contained in:
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|||||||
import { BufferGeometry, Float32BufferAttribute, type Line, type Object3D } from 'three'
|
import { BufferGeometry, Float32BufferAttribute, type Line, type Object3D } from 'three'
|
||||||
import { EDITOR_LAYER } from '../../../lib/constants'
|
import { EDITOR_LAYER } from '../../../lib/constants'
|
||||||
import { sfxEmitter } from '../../../lib/sfx-bus'
|
import { sfxEmitter } from '../../../lib/sfx-bus'
|
||||||
|
import { snapToHalf } from '../item/placement-math'
|
||||||
|
|
||||||
const Y_OFFSET = 0.02
|
const Y_OFFSET = 0.02
|
||||||
|
|
||||||
@@ -187,8 +188,8 @@ export const PolygonEditor: React.FC<PolygonEditorProps> = ({
|
|||||||
// Listen to grid:move events to track cursor position
|
// Listen to grid:move events to track cursor position
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onGridMove = (event: GridEvent) => {
|
const onGridMove = (event: GridEvent) => {
|
||||||
const gridX = Math.round(event.localPosition[0] * 2) / 2
|
const gridX = snapToHalf(event.localPosition[0])
|
||||||
const gridZ = Math.round(event.localPosition[2] * 2) / 2
|
const gridZ = snapToHalf(event.localPosition[2])
|
||||||
const newPosition: [number, number] = [gridX, gridZ]
|
const newPosition: [number, number] = [gridX, gridZ]
|
||||||
|
|
||||||
// Play snap sound when cursor moves to a new grid cell during drag
|
// Play snap sound when cursor moves to a new grid cell during drag
|
||||||
|
|||||||
@@ -266,9 +266,11 @@ export function SlabPanel() {
|
|||||||
value={node.material}
|
value={node.material}
|
||||||
/>
|
/>
|
||||||
</PanelSection>
|
</PanelSection>
|
||||||
|
<PanelSection title="Actions">
|
||||||
<ActionGroup>
|
<ActionGroup>
|
||||||
<ActionButton icon={<Move className="h-3.5 w-3.5" />} label="Move" onClick={handleMove} />
|
<ActionButton icon={<Move className="h-3.5 w-3.5" />} label="Move" onClick={handleMove} />
|
||||||
</ActionGroup>
|
</ActionGroup>
|
||||||
|
</PanelSection>
|
||||||
</PanelWrapper>
|
</PanelWrapper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user