added functions to return the node/cable clicked on all the way up to the parent

This commit is contained in:
csawatzky 2026-04-23 15:56:59 -06:00
parent 0701be2539
commit f4d1167e4d
5 changed files with 113 additions and 165 deletions

View file

@ -6,8 +6,8 @@ import GrainFillFlat from "../Systems/Inventory/GrainFillFlat";
import BinCables from "../Systems/Cables/BinCables";
import { Vector3 } from "three";
import { useMemo } from "react";
import { BuildCableData } from "../Data/BuildCableData";
import { BuildNodeData } from "../Data/BuildNodeData";
import { BuildCableData, CableData } from "../Data/BuildCableData";
import { BuildNodeData, NodeData } from "../Data/BuildNodeData";
import NodePointCloud from "../Systems/Heatmap/NodePointCloud";
import { pond } from "protobuf-ts/pond";
import GrainCableFill from "../Systems/Inventory/GrainCableFill";
@ -27,13 +27,14 @@ interface Props {
* optional: the percent of the bin to fill using a level top, this will be used with manual and lidar controls
*/
fillPercent?: number
nodeClick?: (node: NodeData, cable: CableData) => void
}
export default function Bin3dView(props: Props){
//this function will generate a 3D model of a bin based on its settings using multiple meshes, cylinder for the body, cone for the roof
// and either a cone for the hopper or circle for flat bottom, it is possible to also use lathe geometry for this as well,
// it might even work better because we can control the smoothness easier with it being only one mesh rather than 3
const {bin, scale = 100, fillPercent} = props
const {bin, scale = 100, fillPercent, nodeClick} = props
const binCenter = useMemo(() => new Vector3(0, 0, 0), []);
const cableData = useMemo(() => BuildCableData(bin), [bin]);
const nodeData = useMemo(() => BuildNodeData(cableData), [cableData]);
@ -80,7 +81,14 @@ export default function Bin3dView(props: Props){
{/* grain - cylinder*/}
{grainInventory()}
{/* cables */}
<BinCables cableData={cableData} nodeData={nodeData} bin={bin} binCenter={binCenter}/>
<BinCables cableData={cableData} nodeData={nodeData} bin={bin} binCenter={binCenter}
onNodeClick={(node, cable) => {
// console.log(node)
// console.log(cable)
if(nodeClick){
nodeClick(node, cable)
}
}}/>
<NodePointCloud bin={bin} nodes={nodeData} />
</group>