Refactor viewer hover styles and remove preview state
This commit is contained in:
@@ -7,22 +7,14 @@ import {
|
||||
createMaterialFromPresetRef,
|
||||
DEFAULT_STAIR_MATERIAL,
|
||||
} from '../../../lib/materials'
|
||||
import useViewer from '../../../store/use-viewer'
|
||||
|
||||
export const FenceRenderer = ({ node }: { node: FenceNode }) => {
|
||||
const ref = useRef<Mesh>(null!)
|
||||
const handlers = useNodeEvents(node, 'fence')
|
||||
const materialPreview = useViewer((state) =>
|
||||
state.materialPreview?.target === 'fence' && state.materialPreview.nodeId === node.id
|
||||
? state.materialPreview
|
||||
: null,
|
||||
)
|
||||
const material = useMemo(() => {
|
||||
const presetMaterial = createMaterialFromPresetRef(
|
||||
materialPreview?.materialPreset ?? node.materialPreset,
|
||||
)
|
||||
const presetMaterial = createMaterialFromPresetRef(node.materialPreset)
|
||||
if (presetMaterial) return presetMaterial
|
||||
const mat = materialPreview?.material ?? node.material
|
||||
const mat = node.material
|
||||
if (!mat) return DEFAULT_STAIR_MATERIAL
|
||||
return createMaterial(mat)
|
||||
}, [
|
||||
@@ -31,11 +23,6 @@ export const FenceRenderer = ({ node }: { node: FenceNode }) => {
|
||||
node.material?.preset,
|
||||
node.material?.properties,
|
||||
node.material?.texture,
|
||||
materialPreview?.materialPreset,
|
||||
materialPreview?.material,
|
||||
materialPreview?.material?.preset,
|
||||
materialPreview?.material?.properties,
|
||||
materialPreview?.material?.texture,
|
||||
])
|
||||
|
||||
useRegistry(node.id, 'fence', ref)
|
||||
|
||||
Reference in New Issue
Block a user