added wall asset visiblity toggle and code optimization
This commit is contained in:
@@ -17,7 +17,7 @@ import { useSceneContext } from "../../../../../../modules/scene/sceneContext";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
function HumanMechanics() {
|
||||
const [activeOption, setActiveOption] = useState<"worker" | "manufacturer" | "operator">("worker");
|
||||
const [activeOption, setActiveOption] = useState<"worker" | "manufacturer" | "operator" | "assembler">("worker");
|
||||
const [speed, setSpeed] = useState("0.5");
|
||||
const [loadCount, setLoadCount] = useState(0);
|
||||
const [manufactureCount, setManufactureCount] = useState(0);
|
||||
@@ -118,7 +118,7 @@ function HumanMechanics() {
|
||||
const handleSelectActionType = (actionType: string) => {
|
||||
if (!selectedAction.actionId || !currentAction || !selectedPointData) return;
|
||||
|
||||
const updatedAction = { ...currentAction, actionType: actionType as "worker" | "manufacturer" | "operator" };
|
||||
const updatedAction = { ...currentAction, actionType: actionType as "worker" | "manufacturer" | "operator" | "assembler" };
|
||||
const updatedActions = selectedPointData.actions.map(action => action.actionUuid === updatedAction.actionUuid ? updatedAction : action);
|
||||
const updatedPoint = { ...selectedPointData, actions: updatedActions };
|
||||
|
||||
@@ -306,6 +306,11 @@ function HumanMechanics() {
|
||||
actionName: `Action ${selectedPointData.actions.length + 1}`,
|
||||
actionType: "worker",
|
||||
loadCount: 1,
|
||||
assemblyCount: 1,
|
||||
assemblyCondition: {
|
||||
conditionType: 'material',
|
||||
materialType: "Default material"
|
||||
},
|
||||
manufactureCount: 1,
|
||||
loadCapacity: 1,
|
||||
processTime: 10,
|
||||
|
||||
@@ -271,6 +271,11 @@ function AssetsGroup({ plane }: { readonly plane: RefMesh }) {
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
loadCount: 1,
|
||||
assemblyCount: 1,
|
||||
assemblyCondition: {
|
||||
conditionType: 'material',
|
||||
materialType: "Default material"
|
||||
},
|
||||
manufactureCount: 1,
|
||||
loadCapacity: 1,
|
||||
processTime: 10,
|
||||
|
||||
@@ -389,6 +389,11 @@ async function handleModelLoad(
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
loadCount: 1,
|
||||
assemblyCount: 1,
|
||||
assemblyCondition: {
|
||||
conditionType: 'material',
|
||||
materialType: "Default material"
|
||||
},
|
||||
manufactureCount: 1,
|
||||
loadCapacity: 1,
|
||||
processTime: 10,
|
||||
|
||||
@@ -17,9 +17,9 @@ import material1 from '../../../../../assets/textures/floor/factory wall texture
|
||||
|
||||
function Wall({ wall }: { readonly wall: Wall }) {
|
||||
const { wallStore, wallAssetStore } = useSceneContext();
|
||||
const { walls, addDecal } = wallStore();
|
||||
const { wallAssets, getAssetsByWall } = wallAssetStore();
|
||||
const assets = getAssetsByWall(wall.wallUuid);
|
||||
const { walls } = wallStore();
|
||||
const { wallAssets, getWallAssetsByWall, setVisibility } = wallAssetStore();
|
||||
const assets = getWallAssetsByWall(wall.wallUuid);
|
||||
const { selectedWall, setSelectedWall, setSelectedDecal } = useBuilderStore();
|
||||
const { togglView } = useToggleView();
|
||||
const { activeModule } = useModuleStore();
|
||||
@@ -28,6 +28,7 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
||||
const { getWallType, isWallFlipped } = useWallClassification(walls);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const meshRef = useRef<any>();
|
||||
const prevVisibleRef = useRef<boolean | null>(null);
|
||||
const wallType = getWallType(wall);
|
||||
|
||||
const wallFlipped = isWallFlipped(wall);
|
||||
@@ -89,15 +90,23 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
||||
const v = new THREE.Vector3();
|
||||
const u = new THREE.Vector3();
|
||||
|
||||
if (!wallVisibility && wallType.type === 'room') {
|
||||
let nextVisible = true;
|
||||
|
||||
if (!wallVisibility && wallType.type === "room") {
|
||||
meshRef.current.getWorldDirection(v);
|
||||
camera.getWorldDirection(u);
|
||||
if (!u || !v) return;
|
||||
setVisible((2 * v.dot(u)) <= 0.1);
|
||||
} else {
|
||||
setVisible(true);
|
||||
nextVisible = (2 * v.dot(u)) <= 0.1;
|
||||
}
|
||||
})
|
||||
|
||||
if (prevVisibleRef.current !== nextVisible) {
|
||||
prevVisibleRef.current = nextVisible;
|
||||
setVisible(nextVisible);
|
||||
assets.forEach((asset) => {
|
||||
setVisibility(asset.modelUuid, nextVisible);
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<mesh
|
||||
@@ -107,7 +116,7 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
||||
key={wall.wallUuid}
|
||||
userData={wall}
|
||||
>
|
||||
{(assets.length > 0 || (walls[0].wallUuid === wall.wallUuid && wallAssets.length > 0)) ?
|
||||
{(assets.length > 0 || (walls[0].wallUuid === wall.wallUuid && wallAssets.length > 0)) && visible ?
|
||||
<Base
|
||||
castShadow
|
||||
receiveShadow
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { useThree } from '@react-three/fiber';
|
||||
import { CameraControls, Html, ScreenSpace } from '@react-three/drei';
|
||||
import { useContextActionStore, useRenameModeStore, useSelectedAssets } from '../../../../store/builder/store';
|
||||
@@ -12,6 +12,8 @@ function ContextControls() {
|
||||
const { selectedAssets } = useSelectedAssets();
|
||||
const { setContextAction } = useContextActionStore();
|
||||
const { setIsRenameMode } = useRenameModeStore();
|
||||
const rightDrag = useRef(false);
|
||||
const isRightMouseDown = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedAssets.length === 1) {
|
||||
@@ -68,8 +70,28 @@ function ContextControls() {
|
||||
useEffect(() => {
|
||||
const canvasElement = gl.domElement;
|
||||
|
||||
const onPointerDown = (evt: any) => {
|
||||
if (evt.button === 2) {
|
||||
isRightMouseDown.current = true;
|
||||
rightDrag.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
const onPointerMove = () => {
|
||||
if (isRightMouseDown.current) {
|
||||
rightDrag.current = true;
|
||||
}
|
||||
};
|
||||
|
||||
const onPointerUp = (evt: any) => {
|
||||
if (evt.button === 2) {
|
||||
isRightMouseDown.current = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleContextClick = (event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
if (rightDrag.current) return;
|
||||
if (selectedAssets.length > 0) {
|
||||
setMenuPosition({ x: event.clientX - gl.domElement.width / 2, y: event.clientY - gl.domElement.height / 2 });
|
||||
setCanRender(true);
|
||||
@@ -85,6 +107,9 @@ function ContextControls() {
|
||||
};
|
||||
|
||||
if (selectedAssets.length > 0) {
|
||||
canvasElement.addEventListener('pointerdown', onPointerDown);
|
||||
canvasElement.addEventListener('pointermove', onPointerMove);
|
||||
canvasElement.addEventListener('pointerup', onPointerUp);
|
||||
canvasElement.addEventListener('contextmenu', handleContextClick)
|
||||
} else {
|
||||
setCanRender(false);
|
||||
@@ -95,6 +120,9 @@ function ContextControls() {
|
||||
}
|
||||
|
||||
return () => {
|
||||
canvasElement.removeEventListener('pointerdown', onPointerDown);
|
||||
canvasElement.removeEventListener('pointermove', onPointerMove);
|
||||
canvasElement.removeEventListener('pointerup', onPointerUp);
|
||||
canvasElement.removeEventListener('contextmenu', handleContextClick);
|
||||
};
|
||||
}, [gl, selectedAssets]);
|
||||
|
||||
@@ -19,7 +19,7 @@ function MoveControls2D({
|
||||
movedObjects,
|
||||
setMovedObjects,
|
||||
pastedObjects,
|
||||
setpastedObjects,
|
||||
setPastedObjects,
|
||||
duplicatedObjects,
|
||||
setDuplicatedObjects,
|
||||
rotatedObjects,
|
||||
@@ -525,7 +525,7 @@ function MoveControls2D({
|
||||
};
|
||||
|
||||
const clearSelection = () => {
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setMovedObjects([]);
|
||||
setRotatedObjects([]);
|
||||
|
||||
@@ -28,7 +28,7 @@ const SelectionControls2D: React.FC = () => {
|
||||
const [movedObjects, setMovedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [rotatedObjects, setRotatedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [copiedObjects, setCopiedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [pastedObjects, setpastedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [pastedObjects, setPastedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [duplicatedObjects, setDuplicatedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const { activeModule } = useModuleStore();
|
||||
const { socket } = useSocketStore();
|
||||
@@ -216,7 +216,7 @@ const SelectionControls2D: React.FC = () => {
|
||||
}, [selectionBox, pointer, controls, selectedPoints, setSelectedPoints]);
|
||||
|
||||
const clearSelection = () => {
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
clearSelectedPoints();
|
||||
};
|
||||
@@ -594,7 +594,7 @@ const SelectionControls2D: React.FC = () => {
|
||||
return (
|
||||
<>
|
||||
|
||||
<MoveControls2D movedObjects={movedObjects} setMovedObjects={setMovedObjects} pastedObjects={pastedObjects} setpastedObjects={setpastedObjects} duplicatedObjects={duplicatedObjects} setDuplicatedObjects={setDuplicatedObjects} rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} />
|
||||
<MoveControls2D movedObjects={movedObjects} setMovedObjects={setMovedObjects} pastedObjects={pastedObjects} setPastedObjects={setPastedObjects} duplicatedObjects={duplicatedObjects} setDuplicatedObjects={setDuplicatedObjects} rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} />
|
||||
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -12,17 +12,7 @@ import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
// import { setAssetsApi } from "../../../../../services/factoryBuilder/asset/floorAsset/setAssetsApi";
|
||||
|
||||
const CopyPasteControls3D = ({
|
||||
copiedObjects,
|
||||
setCopiedObjects,
|
||||
pastedObjects,
|
||||
setpastedObjects,
|
||||
setDuplicatedObjects,
|
||||
movedObjects,
|
||||
setMovedObjects,
|
||||
rotatedObjects,
|
||||
setRotatedObjects,
|
||||
}: any) => {
|
||||
const CopyPasteControls3D = () => {
|
||||
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
||||
const { toggleView } = useToggleView();
|
||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||
@@ -32,7 +22,7 @@ const CopyPasteControls3D = ({
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { addEvent } = eventStore();
|
||||
const { projectId } = useParams();
|
||||
const { assets, addAsset, updateAsset, removeAsset, getAssetById } = assetStore();
|
||||
const { assets, addAsset, updateAsset, removeAsset, getAssetById, copiedObjects, setCopiedObjects, pastedObjects, setPastedObjects, setDuplicatedObjects, movedObjects, setMovedObjects, rotatedObjects, setRotatedObjects } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { userId, organization } = getUserData();
|
||||
@@ -177,7 +167,7 @@ const CopyPasteControls3D = ({
|
||||
return clone;
|
||||
});
|
||||
|
||||
setpastedObjects(newPastedObjects);
|
||||
setPastedObjects(newPastedObjects);
|
||||
|
||||
raycaster.setFromCamera(pointer, camera);
|
||||
const intersectionPoint = new THREE.Vector3();
|
||||
@@ -430,6 +420,11 @@ const CopyPasteControls3D = ({
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
loadCapacity: 1,
|
||||
assemblyCount: 1,
|
||||
assemblyCondition: {
|
||||
conditionType: 'material',
|
||||
materialType: "Default material"
|
||||
},
|
||||
manufactureCount: 1,
|
||||
loadCount: 1,
|
||||
processTime: 10,
|
||||
@@ -593,7 +588,7 @@ const CopyPasteControls3D = ({
|
||||
|
||||
const clearSelection = () => {
|
||||
setMovedObjects([]);
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setRotatedObjects([]);
|
||||
setSelectedAssets([]);
|
||||
|
||||
@@ -13,15 +13,7 @@ import { handleAssetPositionSnap } from "./functions/handleAssetPositionSnap";
|
||||
|
||||
// import { setAssetsApi } from "../../../../../services/factoryBuilder/asset/floorAsset/setAssetsApi";
|
||||
|
||||
const DuplicationControls3D = ({
|
||||
duplicatedObjects,
|
||||
setDuplicatedObjects,
|
||||
setpastedObjects,
|
||||
movedObjects,
|
||||
setMovedObjects,
|
||||
rotatedObjects,
|
||||
setRotatedObjects,
|
||||
}: any) => {
|
||||
const DuplicationControls3D = () => {
|
||||
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
||||
const { toggleView } = useToggleView();
|
||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||
@@ -31,7 +23,7 @@ const DuplicationControls3D = ({
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { addEvent } = eventStore();
|
||||
const { projectId } = useParams();
|
||||
const { assets, addAsset, updateAsset, removeAsset, getAssetById } = assetStore();
|
||||
const { assets, addAsset, updateAsset, removeAsset, getAssetById, duplicatedObjects, setDuplicatedObjects, setPastedObjects, movedObjects, setMovedObjects, rotatedObjects, setRotatedObjects } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
const { userId, organization } = getUserData();
|
||||
@@ -497,6 +489,11 @@ const DuplicationControls3D = ({
|
||||
actionName: "Action 1",
|
||||
actionType: "worker",
|
||||
loadCapacity: 1,
|
||||
assemblyCount: 1,
|
||||
assemblyCondition: {
|
||||
conditionType: 'material',
|
||||
materialType: "Default material"
|
||||
},
|
||||
manufactureCount: 1,
|
||||
loadCount: 1,
|
||||
processTime: 10,
|
||||
@@ -660,7 +657,7 @@ const DuplicationControls3D = ({
|
||||
|
||||
const clearSelection = () => {
|
||||
setMovedObjects([]);
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setRotatedObjects([]);
|
||||
setSelectedAssets([]);
|
||||
|
||||
@@ -15,17 +15,7 @@ import { useVersionContext } from "../../../../builder/version/versionContext";
|
||||
|
||||
// import { setAssetsApi } from '../../../../../services/factoryBuilder/asset/floorAsset/setAssetsApi';
|
||||
|
||||
function MoveControls3D({
|
||||
movedObjects,
|
||||
setMovedObjects,
|
||||
pastedObjects,
|
||||
setpastedObjects,
|
||||
duplicatedObjects,
|
||||
setDuplicatedObjects,
|
||||
rotatedObjects,
|
||||
setRotatedObjects,
|
||||
boundingBoxRef,
|
||||
}: any) {
|
||||
function MoveControls3D({ boundingBoxRef }: any) {
|
||||
const { camera, controls, gl, scene, pointer, raycaster } = useThree();
|
||||
const plane = useMemo(() => new THREE.Plane(new THREE.Vector3(0, 1, 0), 0), []);
|
||||
|
||||
@@ -38,7 +28,7 @@ function MoveControls3D({
|
||||
const { projectId } = useParams();
|
||||
const { assetStore, eventStore, productStore, undoRedo3DStore } = useSceneContext();
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { updateAsset, getAssetById } = assetStore();
|
||||
const { updateAsset, getAssetById, movedObjects, setMovedObjects, pastedObjects, setPastedObjects, duplicatedObjects, setDuplicatedObjects, rotatedObjects, setRotatedObjects } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
@@ -186,7 +176,7 @@ function MoveControls3D({
|
||||
canvasElement.removeEventListener("keydown", onKeyDown);
|
||||
canvasElement?.removeEventListener("keyup", onKeyUp);
|
||||
};
|
||||
}, [camera, controls, scene, toggleView, selectedAssets, socket, pastedObjects, duplicatedObjects, movedObjects, rotatedObjects, keyEvent]);
|
||||
}, [camera, controls, scene, toggleView, selectedAssets, socket, pastedObjects, duplicatedObjects, movedObjects, rotatedObjects, keyEvent, initialStates]);
|
||||
|
||||
const calculateDragOffset = useCallback((point: THREE.Object3D, hitPoint: THREE.Vector3) => {
|
||||
const pointPosition = new THREE.Vector3().copy(point.position);
|
||||
@@ -220,7 +210,7 @@ function MoveControls3D({
|
||||
}
|
||||
});
|
||||
setAxisConstraint(null);
|
||||
}, 100)
|
||||
}, 50)
|
||||
}, [movedObjects, initialStates, updateAsset]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -462,7 +452,7 @@ function MoveControls3D({
|
||||
};
|
||||
|
||||
const clearSelection = () => {
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setMovedObjects([]);
|
||||
setRotatedObjects([]);
|
||||
|
||||
@@ -14,16 +14,7 @@ import { handleAssetRotationSnap } from "./functions/handleAssetRotationSnap";
|
||||
|
||||
// import { setAssetsApi } from '../../../../../services/factoryBuilder/asset/floorAsset/setAssetsApi';
|
||||
|
||||
function RotateControls3D({
|
||||
rotatedObjects,
|
||||
setRotatedObjects,
|
||||
movedObjects,
|
||||
setMovedObjects,
|
||||
pastedObjects,
|
||||
setpastedObjects,
|
||||
duplicatedObjects,
|
||||
setDuplicatedObjects
|
||||
}: any) {
|
||||
function RotateControls3D() {
|
||||
const { camera, gl, scene, pointer, raycaster } = useThree();
|
||||
|
||||
const { toggleView } = useToggleView();
|
||||
@@ -35,7 +26,7 @@ function RotateControls3D({
|
||||
const { projectId } = useParams();
|
||||
const { assetStore, eventStore, productStore, undoRedo3DStore } = useSceneContext();
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { updateAsset } = assetStore();
|
||||
const { updateAsset, rotatedObjects, setRotatedObjects, movedObjects, setMovedObjects, pastedObjects, setPastedObjects, duplicatedObjects, setDuplicatedObjects } = assetStore();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
const { selectedVersion } = selectedVersionStore();
|
||||
|
||||
@@ -161,7 +152,7 @@ function RotateControls3D({
|
||||
canvasElement.removeEventListener("keydown", onKeyDown);
|
||||
canvasElement?.removeEventListener("keyup", onKeyUp);
|
||||
};
|
||||
}, [camera, scene, toggleView, selectedAssets, rotatedObjects, pastedObjects, duplicatedObjects, movedObjects, keyEvent]);
|
||||
}, [camera, scene, toggleView, selectedAssets, rotatedObjects, pastedObjects, duplicatedObjects, movedObjects, keyEvent, initialPositions, initialRotations]);
|
||||
|
||||
const resetToInitialRotations = useCallback(() => {
|
||||
setTimeout(() => {
|
||||
@@ -185,7 +176,7 @@ function RotateControls3D({
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 100)
|
||||
}, 50)
|
||||
}, [rotatedObjects, initialRotations, initialPositions, updateAsset]);
|
||||
|
||||
useFrame(() => {
|
||||
@@ -397,7 +388,7 @@ function RotateControls3D({
|
||||
}, [rotatedObjects, eventStore, productStore, selectedProduct, updateBackend, projectId, updateAsset, organization, socket, selectedVersion, userId]);
|
||||
|
||||
const clearSelection = () => {
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setMovedObjects([]);
|
||||
setRotatedObjects([]);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef } from "react";
|
||||
import * as THREE from "three";
|
||||
import { useThree } from "@react-three/fiber";
|
||||
import { SelectionHelper } from "../selectionHelper";
|
||||
@@ -23,18 +23,13 @@ const SelectionControls3D: React.FC = () => {
|
||||
const { camera, controls, gl, scene, raycaster, pointer } = useThree();
|
||||
const { toggleView } = useToggleView();
|
||||
const { selectedAssets, setSelectedAssets } = useSelectedAssets();
|
||||
const [movedObjects, setMovedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [rotatedObjects, setRotatedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [copiedObjects, setCopiedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [pastedObjects, setpastedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const [duplicatedObjects, setDuplicatedObjects] = useState<THREE.Object3D[]>([]);
|
||||
const boundingBoxRef = useRef<THREE.Mesh>();
|
||||
const { activeModule } = useModuleStore();
|
||||
const { socket } = useSocketStore();
|
||||
const { contextAction, setContextAction } = useContextActionStore()
|
||||
const { assetStore, eventStore, productStore, undoRedo3DStore } = useSceneContext();
|
||||
const { push3D } = undoRedo3DStore();
|
||||
const { removeAsset, getAssetById } = assetStore();
|
||||
const { removeAsset, getAssetById, movedObjects, rotatedObjects, copiedObjects, pastedObjects, duplicatedObjects, setPastedObjects, setDuplicatedObjects } = assetStore();
|
||||
const selectionBox = useMemo(() => new SelectionBox(camera, scene), [camera, scene]);
|
||||
const { toolMode } = useToolMode();
|
||||
const { selectedVersionStore } = useVersionContext();
|
||||
@@ -267,13 +262,13 @@ const SelectionControls3D: React.FC = () => {
|
||||
}, [selectionBox, pointer, controls, selectedAssets, setSelectedAssets]);
|
||||
|
||||
const clearSelection = () => {
|
||||
setpastedObjects([]);
|
||||
setPastedObjects([]);
|
||||
setDuplicatedObjects([]);
|
||||
setSelectedAssets([]);
|
||||
};
|
||||
|
||||
const deleteSelection = () => {
|
||||
if (selectedAssets.length > 0 && duplicatedObjects.length === 0) {
|
||||
if (selectedAssets.length > 0 && duplicatedObjects.length === 0 && pastedObjects.length === 0) {
|
||||
|
||||
const undoActions: UndoRedo3DAction[] = [];
|
||||
const assetsToDelete: AssetData[] = [];
|
||||
@@ -366,21 +361,22 @@ const SelectionControls3D: React.FC = () => {
|
||||
selectedUUIDs.forEach((uuid: string) => {
|
||||
removeAsset(uuid);
|
||||
});
|
||||
|
||||
echo.success("Selected models removed!");
|
||||
clearSelection();
|
||||
}
|
||||
echo.success("Selected models removed!");
|
||||
clearSelection();
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<MoveControls3D movedObjects={movedObjects} setMovedObjects={setMovedObjects} pastedObjects={pastedObjects} setpastedObjects={setpastedObjects} duplicatedObjects={duplicatedObjects} setDuplicatedObjects={setDuplicatedObjects} rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} boundingBoxRef={boundingBoxRef} />
|
||||
<MoveControls3D boundingBoxRef={boundingBoxRef} />
|
||||
|
||||
<RotateControls3D rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} movedObjects={movedObjects} setMovedObjects={setMovedObjects} pastedObjects={pastedObjects} setpastedObjects={setpastedObjects} duplicatedObjects={duplicatedObjects} setDuplicatedObjects={setDuplicatedObjects} />
|
||||
<RotateControls3D />
|
||||
|
||||
<DuplicationControls3D duplicatedObjects={duplicatedObjects} setDuplicatedObjects={setDuplicatedObjects} setpastedObjects={setpastedObjects} movedObjects={movedObjects} setMovedObjects={setMovedObjects} rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} boundingBoxRef={boundingBoxRef} />
|
||||
<DuplicationControls3D />
|
||||
|
||||
<CopyPasteControls3D copiedObjects={copiedObjects} setCopiedObjects={setCopiedObjects} pastedObjects={pastedObjects} setpastedObjects={setpastedObjects} setDuplicatedObjects={setDuplicatedObjects} movedObjects={movedObjects} setMovedObjects={setMovedObjects} rotatedObjects={rotatedObjects} setRotatedObjects={setRotatedObjects} boundingBoxRef={boundingBoxRef} />
|
||||
<CopyPasteControls3D />
|
||||
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { Object3D } from 'three';
|
||||
import { create } from 'zustand';
|
||||
import { immer } from 'zustand/middleware/immer';
|
||||
|
||||
interface AssetsStore {
|
||||
assets: Assets;
|
||||
movedObjects: Object3D[];
|
||||
rotatedObjects: Object3D[];
|
||||
copiedObjects: Object3D[];
|
||||
pastedObjects: Object3D[];
|
||||
duplicatedObjects: Object3D[];
|
||||
|
||||
// Asset CRUD operations
|
||||
addAsset: (asset: Asset) => void;
|
||||
@@ -12,6 +18,12 @@ interface AssetsStore {
|
||||
resetAsset: (modelUuid: string) => void;
|
||||
setAssets: (assets: Assets) => void;
|
||||
|
||||
setMovedObjects: (objects: Object3D[]) => Object3D[];
|
||||
setRotatedObjects: (objects: Object3D[]) => Object3D[];
|
||||
setCopiedObjects: (objects: Object3D[]) => Object3D[];
|
||||
setPastedObjects: (objects: Object3D[]) => Object3D[];
|
||||
setDuplicatedObjects: (objects: Object3D[]) => Object3D[];
|
||||
|
||||
// Asset properties
|
||||
setName: (modelUuid: string, newName: string) => void;
|
||||
setPosition: (modelUuid: string, position: [number, number, number]) => void;
|
||||
@@ -44,6 +56,11 @@ export const createAssetStore = () => {
|
||||
return create<AssetsStore>()(
|
||||
immer((set, get) => ({
|
||||
assets: [],
|
||||
movedObjects: [],
|
||||
rotatedObjects: [],
|
||||
copiedObjects: [],
|
||||
pastedObjects: [],
|
||||
duplicatedObjects: [],
|
||||
|
||||
// Asset CRUD operations
|
||||
addAsset: (asset) => {
|
||||
@@ -94,6 +111,41 @@ export const createAssetStore = () => {
|
||||
});
|
||||
},
|
||||
|
||||
setMovedObjects: (objects) => {
|
||||
set((state) => {
|
||||
state.movedObjects = objects;
|
||||
});
|
||||
return objects;
|
||||
},
|
||||
|
||||
setRotatedObjects: (objects) => {
|
||||
set((state) => {
|
||||
state.rotatedObjects = objects;
|
||||
});
|
||||
return objects;
|
||||
},
|
||||
|
||||
setCopiedObjects: (objects) => {
|
||||
set((state) => {
|
||||
state.copiedObjects = objects;
|
||||
});
|
||||
return objects;
|
||||
},
|
||||
|
||||
setPastedObjects: (objects) => {
|
||||
set((state) => {
|
||||
state.pastedObjects = objects;
|
||||
});
|
||||
return objects;
|
||||
},
|
||||
|
||||
setDuplicatedObjects: (objects) => {
|
||||
set((state) => {
|
||||
state.duplicatedObjects = objects;
|
||||
});
|
||||
return objects;
|
||||
},
|
||||
|
||||
// Asset properties
|
||||
setName: (modelUuid, newName) => {
|
||||
set((state) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ interface WallAssetStore {
|
||||
setOpacity: (uuid: string, opacity: number) => void;
|
||||
|
||||
getWallAssetById: (uuid: string) => WallAsset | undefined;
|
||||
getAssetsByWall: (wallUuid: string) => WallAsset[];
|
||||
getWallAssetsByWall: (wallUuid: string) => WallAsset[];
|
||||
}
|
||||
|
||||
export const createWallAssetStore = () => {
|
||||
@@ -93,7 +93,7 @@ export const createWallAssetStore = () => {
|
||||
return get().wallAssets.find(a => a.modelUuid === uuid);
|
||||
},
|
||||
|
||||
getAssetsByWall: (wallUuid) => {
|
||||
getWallAssetsByWall: (wallUuid) => {
|
||||
return get().wallAssets.filter(a => a.wallUuid === wallUuid);
|
||||
},
|
||||
}))
|
||||
|
||||
12
app/src/types/simulationTypes.d.ts
vendored
12
app/src/types/simulationTypes.d.ts
vendored
@@ -96,12 +96,22 @@ interface StorageAction {
|
||||
interface HumanAction {
|
||||
actionUuid: string;
|
||||
actionName: string;
|
||||
actionType: "worker" | "manufacturer" | "operator";
|
||||
actionType: "worker" | "manufacturer" | "operator" | "assembler";
|
||||
processTime: number;
|
||||
swapMaterial?: string;
|
||||
manufacturePoint?: { position: [number, number, number] | null; rotation: [number, number, number] | null; }
|
||||
assemblyPoint?: { position: [number, number, number] | null; rotation: [number, number, number] | null; }
|
||||
pickUpPoint?: { position: [number, number, number] | null; rotation: [number, number, number] | null; }
|
||||
dropPoint?: { position: [number, number, number] | null; rotation: [number, number, number] | null; }
|
||||
assemblyCount: number;
|
||||
assemblyCondition: {
|
||||
conditionType: "material";
|
||||
materialType: string;
|
||||
source?: {
|
||||
sourceUuid: string;
|
||||
sourceActionUuid: string;
|
||||
}[];
|
||||
}
|
||||
loadCount: number;
|
||||
manufactureCount: number;
|
||||
loadCapacity: number;
|
||||
|
||||
Reference in New Issue
Block a user