Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified apps/editor/public/audios/sfx/item_delete.mp3
Binary file not shown.
Binary file modified apps/editor/public/audios/sfx/structure_delete.mp3
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { useFrame } from '@react-three/fiber'
import { useCallback, useRef } from 'react'
import * as THREE from 'three'
import { duplicateRoofSubtree } from '../../lib/roof-duplication'
import { sfxEmitter } from '../../lib/sfx-bus'
import { emitDeleteSFX, sfxEmitter } from '../../lib/sfx-bus'
import { duplicateStairSubtree } from '../../lib/stair-duplication'
import useEditor from '../../store/use-editor'
import { formatMeasurement, MeasurementPill } from './measurement-pill'
Expand Down Expand Up @@ -514,11 +514,7 @@ export function FloatingActionMenu() {
(e: React.MouseEvent) => {
e.stopPropagation()
if (!selectedId) return
if (node?.type === 'item') {
sfxEmitter.emit('sfx:item-delete')
} else {
sfxEmitter.emit('sfx:structure-delete')
}
emitDeleteSFX(node?.type)
setSelection({ selectedIds: [] })
useScene.getState().deleteNode(selectedId as AnyNodeId)
},
Expand Down
8 changes: 2 additions & 6 deletions packages/editor/src/components/editor/selection-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
hasActivePaintMaterial,
resolveActivePaintMaterialFromSelection,
} from '../../lib/material-paint'
import { sfxEmitter } from '../../lib/sfx-bus'
import { emitDeleteSFX } from '../../lib/sfx-bus'
import useEditor, {
type MaterialTargetRole,
type Phase,
Expand Down Expand Up @@ -1555,11 +1555,7 @@ export const SelectionManager = () => {
event.stopPropagation()

// Play appropriate SFX
if (node.type === 'item') {
sfxEmitter.emit('sfx:item-delete')
} else {
sfxEmitter.emit('sfx:structure-delete')
}
emitDeleteSFX(node.type)

useScene.getState().deleteNode(node.id as AnyNodeId)
if (node.parentId) useScene.getState().dirtyNodes.add(node.parentId as AnyNodeId)
Expand Down
8 changes: 2 additions & 6 deletions packages/editor/src/hooks/use-keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
copySelectedNodesToEditorClipboard,
pasteEditorClipboardToLevel,
} from '../lib/scene-clipboard'
import { sfxEmitter } from '../lib/sfx-bus'
import { emitDeleteSFX, sfxEmitter } from '../lib/sfx-bus'
import { toggleWindowOpenState } from '../lib/window-interaction'
import useEditor from '../store/use-editor'

Expand Down Expand Up @@ -322,11 +322,7 @@ export const useKeyboard = ({
// Play appropriate SFX based on what's being deleted
if (selectedNodeIds.length === 1) {
const node = useScene.getState().nodes[selectedNodeIds[0]!]
if (node?.type === 'item') {
sfxEmitter.emit('sfx:item-delete')
} else {
sfxEmitter.emit('sfx:structure-delete')
}
emitDeleteSFX(node?.type)
} else {
sfxEmitter.emit('sfx:structure-delete')
}
Expand Down
16 changes: 16 additions & 0 deletions packages/editor/src/lib/sfx-bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,19 @@ export function initSFXBus() {
export function triggerSFX(event: keyof SFXEvents) {
sfxEmitter.emit(event)
}

/**
* Node types whose deletion should use the lighter item-delete cue rather
* than the heavier structure-delete one. Shelves are furniture-like placeable
* objects, so they sound like items being removed, not structures demolished.
*/
const ITEM_DELETE_NODE_TYPES = new Set(['item', 'shelf'])

/**
* Emit the delete SFX appropriate for a deleted node's type.
*/
export function emitDeleteSFX(nodeType: string | undefined) {
sfxEmitter.emit(
nodeType && ITEM_DELETE_NODE_TYPES.has(nodeType) ? 'sfx:item-delete' : 'sfx:structure-delete',
)
}
4 changes: 2 additions & 2 deletions packages/editor/src/lib/sfx-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const SFX: Record<string, SFXConfig> = {
src: '/audios/sfx/item_delete.mp3',
rateRange: [0.9, 1.1],
volumeRange: [0.9, 1.0],
panJitter: 0.15,
panJitter: 0.05,
},
itemPick: {
src: '/audios/sfx/item_pick.mp3',
Expand Down Expand Up @@ -77,7 +77,7 @@ export const SFX: Record<string, SFXConfig> = {
src: '/audios/sfx/structure_delete.mp3',
rateRange: [0.9, 1.1],
volumeRange: [0.9, 1.0],
panJitter: 0.15,
panJitter: 0.08,
},
snapshotCapture: {
// Shutter should sound consistent — no variation.
Expand Down
Loading