zonr bug fix
This commit is contained in:
@@ -3,7 +3,7 @@ import { CameraControls } from '@react-three/drei';
|
||||
import { ThreeEvent, useThree } from '@react-three/fiber';
|
||||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { useActiveTool, useDeletableFloorItem, useSelectedFloorItem, useToggleView } from '../../../../../../store/builder/store';
|
||||
import { useActiveTool, useDeletableFloorItem, useSelectedFloorItem, useToggleView, useZoneAssetId } from '../../../../../../store/builder/store';
|
||||
import useModuleStore, { useSubModuleStore } from '../../../../../../store/useModuleStore';
|
||||
import { useSocketStore } from '../../../../../../store/builder/store';
|
||||
import { useSceneContext } from '../../../../../scene/sceneContext';
|
||||
@@ -20,9 +20,11 @@ import { upsertProductOrEventApi } from '../../../../../../services/simulation/p
|
||||
export function useModelEventHandlers({
|
||||
boundingBox,
|
||||
groupRef,
|
||||
asset
|
||||
}: {
|
||||
boundingBox: THREE.Box3 | null,
|
||||
groupRef: React.RefObject<THREE.Group>,
|
||||
asset: Asset
|
||||
}) {
|
||||
const { controls, gl, camera } = useThree();
|
||||
const { activeTool } = useActiveTool();
|
||||
@@ -32,12 +34,13 @@ export function useModelEventHandlers({
|
||||
const { socket } = useSocketStore();
|
||||
const { eventStore, productStore, assetStore, undoRedo3DStore } = useSceneContext();
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { removeAsset } = assetStore();
|
||||
const { getAssetById, removeAsset } = assetStore();
|
||||
const { zoneAssetId, setZoneAssetId } = useZoneAssetId();
|
||||
const { removeEvent, getEventByModelUuid } = eventStore();
|
||||
const { getIsEventInProduct, addPoint, deleteEvent } = productStore();
|
||||
const { setSelectedAsset, clearSelectedAsset } = useSelectedAsset();
|
||||
const { deletableFloorItem, setDeletableFloorItem } = useDeletableFloorItem();
|
||||
const { setSelectedFloorItem } = useSelectedFloorItem();
|
||||
const { selectedFloorItem, setSelectedFloorItem } = useSelectedFloorItem();
|
||||
const { selectedProductStore } = useProductContext();
|
||||
const { selectedProduct } = selectedProductStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
@@ -66,6 +69,19 @@ export function useModelEventHandlers({
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!zoneAssetId) return
|
||||
if (zoneAssetId.id === asset.modelUuid) {
|
||||
handleDblClick(asset);
|
||||
}
|
||||
}, [zoneAssetId])
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedFloorItem) {
|
||||
setZoneAssetId(null);
|
||||
}
|
||||
}, [selectedFloorItem])
|
||||
|
||||
const handleDblClick = (asset: Asset) => {
|
||||
if (asset && activeTool === "cursor" && boundingBox && groupRef.current && activeModule === 'builder') {
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ function Model({ asset, isRendered, loader }: { readonly asset: Asset, isRendere
|
||||
});
|
||||
}, []);
|
||||
|
||||
const { handleDblClick, handleClick, handlePointerOver, handlePointerOut, handleContextMenu } = useModelEventHandlers({ boundingBox, groupRef });
|
||||
const { handleDblClick, handleClick, handlePointerOver, handlePointerOut, handleContextMenu } = useModelEventHandlers({ boundingBox, groupRef, asset });
|
||||
|
||||
return (
|
||||
<group
|
||||
|
||||
Reference in New Issue
Block a user