2025-03-25 08:30:03 +00:00
|
|
|
import * as THREE from 'three'
|
|
|
|
import { EffectComposer, N8AO, Outline } from '@react-three/postprocessing'
|
|
|
|
import { BlendFunction } from 'postprocessing'
|
2025-03-25 11:05:54 +00:00
|
|
|
import { useDeletableFloorItem, useSelectedActionSphere, useSelectedPath, useSelectedWallItem, useselectedFloorItem } from '../../../store/store';
|
2025-03-25 08:30:03 +00:00
|
|
|
import * as Types from '../../../types/world/worldTypes'
|
|
|
|
import * as CONSTANTS from '../../../types/world/worldConstants';
|
|
|
|
|
|
|
|
export default function PostProcessing() {
|
|
|
|
const { deletableFloorItem, setDeletableFloorItem } = useDeletableFloorItem();
|
|
|
|
const { selectedWallItem, setSelectedWallItem } = useSelectedWallItem();
|
|
|
|
const { selectedFloorItem, setselectedFloorItem } = useselectedFloorItem();
|
2025-03-25 11:05:54 +00:00
|
|
|
const { selectedActionSphere } = useSelectedActionSphere();
|
2025-03-25 08:30:03 +00:00
|
|
|
const { selectedPath } = useSelectedPath();
|
|
|
|
|
|
|
|
function flattenChildren(children: any[]) {
|
|
|
|
const allChildren: any[] = [];
|
|
|
|
children.forEach(child => {
|
|
|
|
allChildren.push(child);
|
|
|
|
if (child.children && child.children.length > 0) {
|
|
|
|
allChildren.push(...flattenChildren(child.children));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return allChildren;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<EffectComposer autoClear={false}>
|
|
|
|
<N8AO color="black" aoRadius={20} intensity={7} distanceFalloff={4} aoSamples={32} denoiseRadius={6} denoiseSamples={16} />
|
|
|
|
{deletableFloorItem &&
|
|
|
|
<Outline
|
|
|
|
selection={flattenChildren(deletableFloorItem.children)}
|
|
|
|
selectionLayer={10}
|
|
|
|
width={3000}
|
|
|
|
blendFunction={BlendFunction.ALPHA}
|
|
|
|
edgeStrength={5}
|
|
|
|
resolutionScale={2}
|
|
|
|
pulseSpeed={0}
|
|
|
|
visibleEdgeColor={CONSTANTS.outlineConfig.assetDeleteColor}
|
|
|
|
hiddenEdgeColor={CONSTANTS.outlineConfig.assetDeleteColor}
|
|
|
|
blur={true}
|
|
|
|
xRay={true}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{selectedWallItem &&
|
|
|
|
<Outline
|
|
|
|
selection={
|
|
|
|
selectedWallItem.children[1].children[0].children.filter(
|
|
|
|
(child: Types.Mesh) => child.name !== "CSG_REF"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
selectionLayer={10}
|
|
|
|
width={3000}
|
|
|
|
blendFunction={BlendFunction.ALPHA}
|
|
|
|
edgeStrength={5}
|
|
|
|
resolutionScale={2}
|
|
|
|
pulseSpeed={0}
|
|
|
|
visibleEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
hiddenEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
blur={true}
|
|
|
|
xRay={true}
|
|
|
|
/>}
|
|
|
|
{selectedFloorItem &&
|
|
|
|
<Outline
|
|
|
|
selection={flattenChildren(selectedFloorItem.children)}
|
|
|
|
selectionLayer={10}
|
|
|
|
width={3000}
|
|
|
|
blendFunction={BlendFunction.ALPHA}
|
|
|
|
edgeStrength={5}
|
|
|
|
resolutionScale={2}
|
|
|
|
pulseSpeed={0}
|
|
|
|
visibleEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
hiddenEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
blur={true}
|
|
|
|
xRay={true}
|
|
|
|
/>
|
|
|
|
}
|
2025-03-25 11:05:54 +00:00
|
|
|
{selectedActionSphere &&
|
2025-03-25 08:30:03 +00:00
|
|
|
<Outline
|
2025-03-25 11:05:54 +00:00
|
|
|
selection={[selectedActionSphere.point]}
|
2025-03-25 08:30:03 +00:00
|
|
|
selectionLayer={10}
|
|
|
|
width={750}
|
|
|
|
blendFunction={BlendFunction.ALPHA}
|
|
|
|
edgeStrength={15}
|
|
|
|
resolutionScale={2}
|
|
|
|
pulseSpeed={0}
|
|
|
|
visibleEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
hiddenEdgeColor={CONSTANTS.outlineConfig.assetSelectColor}
|
|
|
|
blur={true}
|
|
|
|
xRay={true}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{selectedPath &&
|
|
|
|
<Outline
|
|
|
|
selection={flattenChildren(selectedPath.group.children)}
|
|
|
|
selectionLayer={10}
|
|
|
|
width={750}
|
|
|
|
blendFunction={BlendFunction.ALPHA}
|
|
|
|
edgeStrength={15}
|
|
|
|
resolutionScale={2}
|
|
|
|
pulseSpeed={0}
|
|
|
|
visibleEdgeColor={0x6f42c1}
|
|
|
|
hiddenEdgeColor={0x6f42c1}
|
|
|
|
blur={true}
|
|
|
|
xRay={true}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
</EffectComposer>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|