feat: enhance conveyor collider functionality and improve scene visibility toggle
This commit is contained in:
@@ -168,7 +168,7 @@ const SideBarRight: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDisplayComponent("none");
|
setDisplayComponent("none");
|
||||||
}, [viewVersionHistory, activeModule, subModule, isVersionSaved, selectedFloorItem, selectedWall, selectedFloor, selectedAisle, toolMode, selectedDecal]);
|
}, [viewVersionHistory, activeModule, subModule, isVersionSaved, selectedFloorItem, selectedWall, selectedFloor, selectedAisle, toolMode, selectedDecal, selectedCollider]);
|
||||||
|
|
||||||
const renderComponent = () => {
|
const renderComponent = () => {
|
||||||
switch (displayComponent) {
|
switch (displayComponent) {
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ function Model({ asset, isRendered, loader }: { readonly asset: Asset, isRendere
|
|||||||
asset={asset}
|
asset={asset}
|
||||||
/> */}
|
/> */}
|
||||||
|
|
||||||
{asset.eventData && asset.eventData.type === 'Conveyor' && fieldData &&
|
{asset.eventData && asset.eventData.type === 'Conveyor' && fieldData && activeModule === 'simulation' &&
|
||||||
<RibbonCollider
|
<RibbonCollider
|
||||||
key={asset.modelUuid}
|
key={asset.modelUuid}
|
||||||
boundingBox={boundingBox}
|
boundingBox={boundingBox}
|
||||||
|
|||||||
@@ -19,5 +19,5 @@ export default function StatsHelper() {
|
|||||||
return () => window.removeEventListener("keydown", handleKeyDown);
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return visible ? <Perf position="bottom-left" className="scene-performance-stats"/> : null;
|
return visible ? <Perf position="bottom-left" className="scene-performance-stats" /> : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,6 +335,7 @@ function CurvedConveyorCollider({
|
|||||||
side={THREE.DoubleSide}
|
side={THREE.DoubleSide}
|
||||||
transparent
|
transparent
|
||||||
opacity={0.7}
|
opacity={0.7}
|
||||||
|
visible={false}
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
))}
|
))}
|
||||||
@@ -354,6 +355,7 @@ function CurvedConveyorCollider({
|
|||||||
key={`highlight-${index}`}
|
key={`highlight-${index}`}
|
||||||
geometry={geometry}
|
geometry={geometry}
|
||||||
position={[0, 0.002, 0]} // Slightly above conveyor
|
position={[0, 0.002, 0]} // Slightly above conveyor
|
||||||
|
// visible={false}
|
||||||
>
|
>
|
||||||
<meshBasicMaterial
|
<meshBasicMaterial
|
||||||
color={forward ? "#00ff0044" : "#ff000044"}
|
color={forward ? "#00ff0044" : "#ff000044"}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function NormalConveyorCollider({ points, boundingBox, asset, forward, isPaused,
|
|||||||
const conveyorSpeed = 2;
|
const conveyorSpeed = 2;
|
||||||
const lastClickTime = useRef(0);
|
const lastClickTime = useRef(0);
|
||||||
const [hoverState, setHoverState] = useState(false);
|
const [hoverState, setHoverState] = useState(false);
|
||||||
const[localForward,setLocalForward]=useState()
|
const [localForward, setLocalForward] = useState()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClick = (e: MouseEvent) => {
|
const handleClick = (e: MouseEvent) => {
|
||||||
@@ -215,6 +215,7 @@ function NormalConveyorCollider({ points, boundingBox, asset, forward, isPaused,
|
|||||||
side={THREE.DoubleSide}
|
side={THREE.DoubleSide}
|
||||||
transparent
|
transparent
|
||||||
opacity={0.5}
|
opacity={0.5}
|
||||||
|
visible={false}
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
</RigidBody>
|
</RigidBody>
|
||||||
@@ -231,6 +232,7 @@ function NormalConveyorCollider({ points, boundingBox, asset, forward, isPaused,
|
|||||||
key={`highlight-${index}`}
|
key={`highlight-${index}`}
|
||||||
geometry={geometry}
|
geometry={geometry}
|
||||||
position={[0, 0.002, 0]}
|
position={[0, 0.002, 0]}
|
||||||
|
// visible={false}
|
||||||
>
|
>
|
||||||
<meshBasicMaterial
|
<meshBasicMaterial
|
||||||
color={forward ? "#00ff0044" : "#ff000044"}
|
color={forward ? "#00ff0044" : "#ff000044"}
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ function YSplitConveyorCollider({ points, boundingBox, asset, forward, isPaused,
|
|||||||
side={THREE.DoubleSide}
|
side={THREE.DoubleSide}
|
||||||
transparent
|
transparent
|
||||||
opacity={0.5}
|
opacity={0.5}
|
||||||
|
visible={false}
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
</RigidBody>
|
</RigidBody>
|
||||||
@@ -230,6 +231,7 @@ function YSplitConveyorCollider({ points, boundingBox, asset, forward, isPaused,
|
|||||||
key={`highlight-${index}`}
|
key={`highlight-${index}`}
|
||||||
geometry={geometry}
|
geometry={geometry}
|
||||||
position={[0, 0.002, 0]}
|
position={[0, 0.002, 0]}
|
||||||
|
// visible={false}
|
||||||
>
|
>
|
||||||
<meshBasicMaterial
|
<meshBasicMaterial
|
||||||
color={forward ? "green" : "red"}
|
color={forward ? "green" : "red"}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useMemo } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { Canvas } from "@react-three/fiber";
|
import { Canvas } from "@react-three/fiber";
|
||||||
import { Physics } from "@react-three/rapier";
|
import { Physics } from "@react-three/rapier";
|
||||||
import { Color, SRGBColorSpace } from "three";
|
import { Color, SRGBColorSpace } from "three";
|
||||||
@@ -8,7 +8,6 @@ import Builder from "../builder/builder";
|
|||||||
import Visualization from "../visualization/visualization";
|
import Visualization from "../visualization/visualization";
|
||||||
import Setup from "./setup/setup";
|
import Setup from "./setup/setup";
|
||||||
import Simulation from "../simulation/simulation";
|
import Simulation from "../simulation/simulation";
|
||||||
import PhysicsSimulator from "./physics/physicsSimulator";
|
|
||||||
import Collaboration from "../collaboration/collaboration";
|
import Collaboration from "../collaboration/collaboration";
|
||||||
import useModuleStore from "../../store/useModuleStore";
|
import useModuleStore from "../../store/useModuleStore";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
@@ -19,6 +18,7 @@ import { useLoadingProgress, useSocketStore } from "../../store/builder/store";
|
|||||||
import { compressImage } from "../../utils/compressImage";
|
import { compressImage } from "../../utils/compressImage";
|
||||||
|
|
||||||
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout"; }) {
|
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout"; }) {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
const map = useMemo(() => [
|
const map = useMemo(() => [
|
||||||
{ name: "forward", keys: ["ArrowUp", "w", "W"] },
|
{ name: "forward", keys: ["ArrowUp", "w", "W"] },
|
||||||
{ name: "backward", keys: ["ArrowDown", "s", "S"] },
|
{ name: "backward", keys: ["ArrowDown", "s", "S"] },
|
||||||
@@ -58,6 +58,18 @@ export default function Scene({ layout }: { readonly layout: "Main Layout" | "Co
|
|||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [activeModule, assets, loadingProgress]);
|
}, [activeModule, assets, loadingProgress]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handleKeyDown = (event: KeyboardEvent) => {
|
||||||
|
if (event.key === "F1") {
|
||||||
|
event.preventDefault();
|
||||||
|
setVisible(prev => !prev);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<KeyboardControls map={map}>
|
<KeyboardControls map={map}>
|
||||||
<Canvas
|
<Canvas
|
||||||
@@ -72,11 +84,9 @@ export default function Scene({ layout }: { readonly layout: "Main Layout" | "Co
|
|||||||
>
|
>
|
||||||
<Setup />
|
<Setup />
|
||||||
<Collaboration />
|
<Collaboration />
|
||||||
<Physics gravity={[0, -9.81, 0]} allowedLinearError={50} numSolverIterations={50} debug >
|
<Physics gravity={[0, -9.81, 0]} allowedLinearError={50} numSolverIterations={50} debug={visible} >
|
||||||
<Builder />
|
<Builder />
|
||||||
{/* <Physics gravity={[0, -9.81, 0]} allowedLinearError={50} numSolverIterations={50} > */}
|
|
||||||
<Simulation />
|
<Simulation />
|
||||||
<PhysicsSimulator />
|
|
||||||
</Physics>
|
</Physics>
|
||||||
<Visualization />
|
<Visualization />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import Products from './products/products';
|
|||||||
import Trigger from './triggers/trigger';
|
import Trigger from './triggers/trigger';
|
||||||
import useModuleStore from '../../store/useModuleStore';
|
import useModuleStore from '../../store/useModuleStore';
|
||||||
import SimulationAnalysis from './analysis/simulationAnalysis';
|
import SimulationAnalysis from './analysis/simulationAnalysis';
|
||||||
|
import PhysicsSimulator from '../scene/physics/physicsSimulator';
|
||||||
import { useSceneContext } from '../scene/sceneContext';
|
import { useSceneContext } from '../scene/sceneContext';
|
||||||
|
|
||||||
function Simulation() {
|
function Simulation() {
|
||||||
@@ -62,6 +63,8 @@ function Simulation() {
|
|||||||
|
|
||||||
<SimulationAnalysis />
|
<SimulationAnalysis />
|
||||||
|
|
||||||
|
<PhysicsSimulator />
|
||||||
|
|
||||||
</>
|
</>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user