also displaying the inventory control type next to "Bin Fill" in the inventory summary and added a fallback to display the inventory in the bin using the basic grain fill when there are no nodes to be able to render the heatmaps, also adjusted the brightness and colour of the basic grain fill

This commit is contained in:
csawatzky 2026-06-16 12:40:07 -06:00
parent 370134a401
commit a4ed52db1e
5 changed files with 61 additions and 36 deletions

View file

@ -6,7 +6,7 @@ import { Bin } from "models";
import BinShell from "../BinParts/BinShell";
import GrainFillFlat from "../Systems/Inventory/GrainFillFlat";
import BinCables from "../Systems/Cables/BinCables";
import { Vector3 } from "three";
// import { Vector3 } from "three";
import { useMemo } from "react";
import { BuildCableData, CableData } from "../Data/BuildCableData";
import { BuildNodeData, NodeData } from "../Data/BuildNodeData";
@ -14,10 +14,10 @@ import { pond } from "protobuf-ts/pond";
import GrainCableFill from "../Systems/Inventory/GrainCableFill";
import TempHeatMap from "../Systems/Heatmap/TempHeatMap";
import NodePointCloud from "../Systems/Heatmap/NodePointCloud";
import { Box } from "@mui/material";
// import { Box } from "@mui/material";
import MoistureHeatMap from "../Systems/Heatmap/MoistureHeatmap";
import { grainYBoundsFromFillPercent } from "../utils/grainFillBounds";
import { RadiansToDegrees } from "common/TrigFunctions";
// import { RadiansToDegrees } from "common/TrigFunctions";
// import { GrainCable } from "models/GrainCable"
// Fallback dimensions used when a bin has no advanced dimensions configured.
@ -40,6 +40,10 @@ interface Props {
*/
fillPercent?: number
nodeClick?: (node: NodeData, cable: CableData) => void
/**
* When true, renders the basic fill and suppresses the heatmaps.
* Heatmaps already simulate the grain level so showing both is redundant.
*/
showGrain?: boolean
showTempHeatmap?: boolean
showMoistureHeatmap?: boolean
@ -108,25 +112,30 @@ export default function Bin3dView(props: Props) {
const resetCameraFn = React.useRef<(() => void) | null>(null);
const grainInventory = () => {
const grainColour = "#fff300";
//note that adjusting the opacity is how to adjust the brightness, less makes it dimmer
if (isCableInventory) {
return (
<GrainCableFill
diameter={dims.diameter}
colour={grainColour}
nodes={nodeData}
sidewallHeight={dims.sidewallHeight}
fallbackFillPercent={fillPercent}
hopperHeight={dims.hopperHeight}
grainOpacity={0.3}
// grainOpacity={0.7}
/>
)
} else if (fillPercent) {
return (
<GrainFillFlat
diameter={dims.diameter}
colour={grainColour}
sidewallHeight={dims.sidewallHeight}
hopperHeight={dims.hopperHeight}
fillPercent={fillPercent}
grainOpacity={0.3}
// grainOpacity={0.7}
/>
)
}
@ -155,8 +164,6 @@ export default function Bin3dView(props: Props) {
renderOrder={4}
/>
{showGrain && grainInventory()}
<BinCables
displayTemp={showTemp}
displayMoisture={showMoisture}
@ -172,24 +179,25 @@ export default function Bin3dView(props: Props) {
{showHotspots && <NodePointCloud bin={bin} nodes={nodeData} />}
{/* note that the heatmaps internally use render order 1,2, and 3 for the three separate coloured meshes */}
{showTempHeatmap && (
<TempHeatMap
{showGrain ? grainInventory() :
showTempHeatmap && nodeData.length > 0
? <TempHeatMap
binDimensions={dims}
targetTemp={bin.targetTemp()}
nodes={nodeData}
flatMaxY={flatGrainBounds?.maxY}
flatMinY={flatGrainBounds?.minY}
/>
)}
{showMoistureHeatmap && (
<MoistureHeatMap
binDimensions={dims}
targetMoisture={bin.targetMoisture()}
nodes={nodeData}
flatMaxY={flatGrainBounds?.maxY}
flatMinY={flatGrainBounds?.minY}
/>
)}
: showMoistureHeatmap && nodeData.length > 0
? <MoistureHeatMap
binDimensions={dims}
targetMoisture={bin.targetMoisture()}
nodes={nodeData}
flatMaxY={flatGrainBounds?.maxY}
flatMinY={flatGrainBounds?.minY}
/>
: grainInventory()
}
</group>